Skip to main content

/sync-logs - Session Log Git Backup

Sync project-scoped session logs to coditect-ai/coditect-core-sessions-logs GitHub repository with machine-partitioned, multi-tenant storage (ADR-155, ADR-159).

System Prompt

EXECUTION DIRECTIVE: When the user invokes /sync-logs, you MUST:

  1. IMMEDIATELY execute the script with appropriate arguments
  2. Default to --sync if no arguments provided
  3. Show full output from script execution
  4. Confirm completion with summary

Script: ~/.coditect/scripts/session-log-git-sync.py

Usage

# Sync ALL project logs to git (default)
/sync-logs
/sync-logs --sync

# Sync specific project only
/sync-logs --project PILOT
/sync-logs --project CUST-avivatec-fpa

# Sync by tenant (all CUST-{tenant}-* projects)
/sync-logs --tenant avivatec

# First time setup
/sync-logs --init

# Preview without changes
/sync-logs --dry-run

# Pull from all machines
/sync-logs --pull

# Check status
/sync-logs --status

# List all machines
/sync-logs --list-machines

# Force overwrite
/sync-logs --force

# Skip PII check (NOT recommended for customer data)
/sync-logs --skip-pii-check

Arguments

ArgumentDescription
--initInitialize git repository (first time setup)
--syncSync local logs to git and push (default)
--pullPull latest from all machines
--statusShow sync status
--list-machinesList all machines with logs
--project IDSync logs for a specific project only (e.g., PILOT, CUST-avivatec-fpa)
--tenant IDSync all projects for a tenant (e.g., avivatec matches CUST-avivatec-*)
--dry-runPreview changes without executing
--forceForce overwrite even if unchanged
--httpsUse HTTPS instead of SSH for git
--skip-pii-checkSkip PII scanning on customer files (NOT recommended)

Architecture

~/.coditect-data/session-logs/          # SSOT (ADR-155)
└── projects/
├── PILOT/{machine-uuid}/
│ ├── SESSION-LOG-2026-01-01.md
│ └── SESSION-LOG-2026-01-02.md
└── CUST-avivatec-fpa/{machine-uuid}/ (0o700 permissions)
└── SESSION-LOG-2026-01-01.md
↓ /sync-logs (with PII check for CUST-*)
~/.coditect-data/session-logs-git/ # Git repo clone
└── machines/{machine-uuid}/
└── projects/
├── PILOT/SESSION-LOG-*.md
└── CUST-avivatec-fpa/SESSION-LOG-*.md (0o700)
↓ git push (per-project repo routing via ADR-159)
github.com/coditect-ai/coditect-core-sessions-logs (private)

Execution

# The command runs:
python3 ~/.coditect/scripts/session-log-git-sync.py $ARGUMENTS

First Time Setup

/sync-logs --init

Creates:

  • Clones or initializes coditect-ai/coditect-core-sessions-logs
  • Creates machine directory: machines/{uuid}/
  • Creates MACHINE-MANIFEST.json with machine metadata

Daily Sync (Default)

/sync-logs
  1. Pulls latest changes from remote
  2. Copies new/modified logs to git repo
  3. Commits with descriptive message
  4. Pushes to remote

Multi-Machine Workflow

# On Machine A
/sync-logs

# On Machine B
/sync-logs --pull # Get Machine A's logs
/sync-logs # Push Machine B's logs

Success Output

✅ COMMAND COMPLETE: /sync-logs
Action: sync
Files synced: 5
Files skipped: 21 (unchanged)
Commit: chore(logs): sync 5 session logs from hostname
Pushed: origin/main

Completion Checklist

Before marking complete:

  • Script executed with correct arguments
  • Output displayed to user
  • Summary provided with file counts

Failure Indicators

This command has FAILED if:

  • ❌ Git repo not initialized (run --init first)
  • ❌ Machine ID not found (run CODITECT-CORE-INITIAL-SETUP.py)
  • ❌ Push failed (check SSH keys or use --https)
  • ❌ Session logs directory doesn't exist

When NOT to Use

  • For submodule git sync (use /git-sync instead)
  • For org.db + sessions.db (ADR-118) backup (use /backup)
  • For session exports (use /export and /cx)
  • For GCS cloud backup (use session-log-sync.py --push)

Multi-Tenant Security (J.27.3)

  • Customer directories (CUST-*) automatically get 0o700 permissions (owner-only)
  • PII scanning runs on all customer files before sync (email, SSN, phone, credit card)
  • Files with PII findings are excluded from sync with a warning
  • Use --skip-pii-check to override (NOT recommended for customer data)
  • Tenant filtering (--tenant avivatec) isolates sync to a single tenant's projects

Migration Script

Legacy flat logs (SESSION-LOG-*.md at root) can be attributed and migrated to project-scoped directories:

# Preview migration
python3 ~/.coditect/scripts/migrate-legacy-session-logs.py --dry-run

# Execute migration
python3 ~/.coditect/scripts/migrate-legacy-session-logs.py --migrate --verbose

Changelog

v2.0.0 (2026-02-08)

  • Added --project filter for project-specific sync
  • Added --tenant filter for multi-tenant isolation (J.27.3)
  • Added PII scanning for customer files before sync (J.27.3.4)
  • Added --skip-pii-check override
  • Updated architecture to project-scoped paths (ADR-155)
  • Added per-project repo routing (ADR-159)
  • Enforced 0o700 permissions on CUST-* directories

v1.0.0 (2026-01-24)

  • Initial release with machine-partitioned sync

Version: 2.0.0 Created: 2026-01-24 Updated: 2026-02-08 Author: CODITECT Team