Operator guide for reverting failed installer, database, Rust binary, and hook changes. Run commands from the repository root unless a section says otherwise.
Use this when install.py, auto-update-tools.py, or a local tool refresh leaves
the launcher or copied tools in a bad state.
python install.py --doctor --manifest > /tmp/sk-install-before.txt
python install.py --install-sk --quietpython install.py --uninstall-launcher
python install.py --doctor --manifestpython install.py --uninstall--uninstall preserves ~/.copilot/session-state/ and the knowledge database.
If the checkout was installed with editable pip, remove that wrapper first:
python -m pip uninstall copilot-session-knowledge
python install.py --uninstallgit fetch origin main
git switch main
git pull --ff-only
python install.py --install-sk --quiet
python install.py --doctor --manifestUse this before migrations, manual repair, or any change that writes
~/.copilot/session-state/knowledge.db.
POSIX:
python migrate.py ~/.copilot/session-state/knowledge.db --backup-only --backup-path /tmp/knowledge.db.backup
python migrate.py ~/.copilot/session-state/knowledge.dbWindows PowerShell:
New-Item -ItemType Directory -Force -Path "C:\Temp" | Out-Null
python migrate.py "$env:USERPROFILE\.copilot\session-state\knowledge.db" --backup-only --backup-path "C:\Temp\knowledge.db.backup"
python migrate.py "$env:USERPROFILE\.copilot\session-state\knowledge.db"Stop active writers first (sk watch, sync daemons, launchd services, CI jobs),
then replace the database and remove WAL sidecars:
rm -f ~/.copilot/session-state/knowledge.db-wal ~/.copilot/session-state/knowledge.db-shm
cp /tmp/knowledge.db.backup ~/.copilot/session-state/knowledge.db
python migrate.py ~/.copilot/session-state/knowledge.dbThe migration run should report Schema up to date.
Remove-Item "$env:USERPROFILE\.copilot\session-state\knowledge.db-wal" -ErrorAction SilentlyContinue
Remove-Item "$env:USERPROFILE\.copilot\session-state\knowledge.db-shm" -ErrorAction SilentlyContinue
Copy-Item "C:\Temp\knowledge.db.backup" "$env:USERPROFILE\.copilot\session-state\knowledge.db" -Force
python migrate.py "$env:USERPROFILE\.copilot\session-state\knowledge.db"mv ~/.copilot/session-state/knowledge.db ~/.copilot/session-state/knowledge.db.corrupt
mv ~/.copilot/session-state/knowledge.db-wal ~/.copilot/session-state/knowledge.db-wal.corrupt 2>/dev/null || true
mv ~/.copilot/session-state/knowledge.db-shm ~/.copilot/session-state/knowledge.db-shm.corrupt 2>/dev/null || true
python migrate.py ~/.copilot/session-state/knowledge.dbUse this when a released sk binary fails at startup, routes commands
incorrectly, or regresses native hooks/watch behavior.
POSIX:
bash sk-rust/install.sh
sk --helpWindows PowerShell:
powershell -ExecutionPolicy Bypass -File sk-rust\install.ps1
sk --helpIf the Rust binary is broken but Python tools are intact, move the binary aside and call the shim directly:
mv ~/.copilot/bin/sk ~/.copilot/bin/sk.broken
python ~/.copilot/tools/sk.py --help
python ~/.copilot/tools/sk.py hooks run sessionStartWindows PowerShell:
Rename-Item "$env:USERPROFILE\.copilot\bin\sk.exe" "sk.exe.broken"
python "$env:USERPROFILE\.copilot\tools\sk.py" --help
python "$env:USERPROFILE\.copilot\tools\sk.py" hooks run sessionStartcd sk-rust
cargo test --quiet
cargo clippy -- -D warnings
cd ..
python tests/test_py_rust_boundary.py --rust-bin sk-rust/target/debug/skUse sk-rust\target\debug\sk.exe for --rust-bin on Windows.
Use this when hook installation, tamper protection, or generated hook config blocks legitimate work.
python install.py --unlock-hookscp .git/hooks/pre-commit.backup .git/hooks/pre-commit
cp .git/hooks/pre-push.backup .git/hooks/pre-push
chmod +x .git/hooks/pre-commit .git/hooks/pre-pushWindows PowerShell:
Copy-Item .git\hooks\pre-commit.backup .git\hooks\pre-commit -Force
Copy-Item .git\hooks\pre-push.backup .git\hooks\pre-push -Forcepython install.py --deploy-hooks
python install.py --install-git-hooks
python install.py --lock-hooks
python tests/test_hook_compat.py
python tests/test_quality_gates.pyPrefer restoring hooks over bypassing them. If a human authorizes a one-off bypass, document the reason in the PR and run the same tests the hook would have enforced before merge.
Every PR that changes installer, migration, hook, Rust binary, or rollback
surfaces must include either command output or an explicit N/A reason for:
python test_security.pypython test_fixes.pypython run_all_tests.pypython tests/test_rollback_runbook.pypython tests/test_migration_rehearsal.pypython tests/test_install_sandbox.pypython tests/test_hook_compat.py- Cross-platform CI status: Linux, macOS, and Windows
- Migration rehearsal evidence when
migrate.pyor DB schema changes - Install sandbox evidence when installer/update scripts change
- Hook security/compat evidence when hook provisioning or hook rules change
This section documents failure modes that have been observed in practice, along with the recommended recovery path for each.
Symptom: sk --help or sk --version returns a non-zero exit code after a
binary upgrade. The startup-benchmark CI job detects this as a failed warmup run
and prints benchmark startup: warmup #1 failed.
Recovery:
# Roll back to the Python shim while investigating
mv ~/.copilot/bin/sk ~/.copilot/bin/sk.broken
python ~/.copilot/tools/sk.py --helpWindows PowerShell:
Rename-Item "$env:USERPROFILE\.copilot\bin\sk.exe" "sk.exe.broken"
python "$env:USERPROFILE\.copilot\tools\sk.py" --helpRe-run binary regression tests to confirm the Python shim is healthy:
python tests/test_py_rust_boundary.py --rust-bin ~/.copilot/bin/sk.brokenSymptom: migrate.py exits with sqlite3.OperationalError: database is locked
or similar. Usually caused by an active sk watch, sync daemon, or CI job.
Recovery:
- Stop all active writers:
python watch-sessions.py --stop 2>/dev/null || true
python sync-daemon.py --stop 2>/dev/null || true- Remove WAL sidecars (Windows PowerShell equivalent:
Remove-Item ... -ErrorAction SilentlyContinue):
rm -f ~/.copilot/session-state/knowledge.db-wal \
~/.copilot/session-state/knowledge.db-shm- Retry migration:
python migrate.py ~/.copilot/session-state/knowledge.dbSymptom: install.py --deploy-hooks prints hooks are locked; run --unlock-hooks first
or a hook hash verification error blocks the pre-commit.
Recovery:
python install.py --unlock-hooks
python install.py --deploy-hooks
python install.py --lock-hooks
python tests/test_hook_compat.pySymptom: sk.cmd runs but cmd.exe raises a parse error because line endings
are LF-only instead of CRLF. Detected by python tests/test_platform_compat.py
→ test_sk_cmd_launcher_content_uses_crlf.
Recovery:
Re-install the launcher from a clean checkout to regenerate the CRLF-correct file:
python install.py --uninstall-launcher
python install.py --install-sk --quiet
python tests/test_platform_compat.pySymptom: migrate.py --backup-only exits 0 but the backup file is missing or
zero bytes. Usually caused by insufficient disk space or a locked source file.
Recovery:
Verify the backup manually before running the forward migration:
python migrate.py ~/.copilot/session-state/knowledge.db --backup-only \
--backup-path ~/knowledge.db.backup
ls -lh ~/knowledge.db.backup # must be non-zero
sqlite3 ~/knowledge.db.backup "PRAGMA quick_check" # must return 'ok'
python migrate.py ~/.copilot/session-state/knowledge.dbWindows PowerShell:
python migrate.py "$env:USERPROFILE\.copilot\session-state\knowledge.db" `
--backup-only --backup-path "$env:USERPROFILE\knowledge.db.backup"
(Get-Item "$env:USERPROFILE\knowledge.db.backup").Length # must be >0
python migrate.py "$env:USERPROFILE\.copilot\session-state\knowledge.db"