Repository navigation
Description
Problem and verified cause
Dirty stage resumes use CycleRecorder._match_handoff in scripts/cycle.py and Handoffs.match in scripts/quota_state.py. Ownership records are created after a completed quota-exhausted process with unchanged HEAD and publication boundaries. This covers #389, not arbitrary interruption. Dispatch-attempt records already exist before execution, but do not preserve recoverable content after every interruption. A manual commit does not establish runtime attribution.
Scope
Extend existing attempt history and journal with durable, versioned recovery checkpoints; reuse Git objects and private recovery refs for content instead of introducing another state engine. Bind repository, task, PR, cycle, stage, attempt, workspace, branch, HEAD/tree, configuration and checkpoint chain. Persist intent before edits and complete checkpoints only after content is durable. Preserve original evidence.
Acceptance criteria
- Recover exact staged, unstaged and relevant untracked changes after interruption; cover interruption after local commit and repeated resumes.
- Detect missing/corrupt metadata, missing objects, wrong scope, changed HEAD and changed fingerprints without discarding work.
- Distinguish a completed checkpoint from later ambiguous edits. An attempt-start record or timestamp alone never proves authorship. Preserve external modifications and offer explicit, recorded inspection/adoption without calling it functional verification.
- Prevent concurrent toolkit writers; disclose that locks cannot establish authorship against arbitrary external writers.
- Inject crashes before/after object persistence and checkpoint persistence, including abrupt termination; repeated recovery creates no duplicate logical operation.
- Retain recoverable originals through retries and GC; define retention, permissions and coverage of binary files, modes, symlinks, submodules and ignored files. Never capture secrets or ignored artifacts automatically.
- Recovery grants no approval and skips no mandatory checks. User-authorized direct operations remain available under Core principle: agent capability parity - the toolkit must not restrict what the agent can run #450; automatic-recovery ambiguity is not a toolkit-wide veto.
- Absorbed from Quota exhaustion in a writing stage stops the cycle with dirty_workspace instead of handing the worktree to the fallback #525: quota exhaustion in a writing stage hands the same worktree to the configured fallback once, automatically, from the latest completed checkpoint, instead of stopping with
dirty_workspaceorworkspace_changed. - Quota exhaustion in a writing stage stops the cycle with dirty_workspace instead of handing the worktree to the fallback #525 AC-1: an implement stage with local commits and uncommitted edits hits quota; the fallback continues in the same worktree and the cycle goes on without a resume.
- Quota exhaustion in a writing stage stops the cycle with dirty_workspace instead of handing the worktree to the fallback #525 AC-2: a resolve stage with unpushed local commits hits quota; same.
- Quota exhaustion in a writing stage stops the cycle with dirty_workspace instead of handing the worktree to the fallback #525 AC-3: both executors exhausted; the cycle stops
BLOCKEDnaming both reset times. - Quota exhaustion in a writing stage stops the cycle with dirty_workspace instead of handing the worktree to the fallback #525 AC-4: telemetry records the reroute, the handed-over workspace state and checkpoint, and the exhaustion evidence; one automatic reroute per stage.
- Quota exhaustion in a writing stage stops the cycle with dirty_workspace instead of handing the worktree to the fallback #525 AC-5: regression tests for AC-1 to AC-4; the routing page describes the automatic handoff.
Design decisions (2026-11-29)
IR-001 Adoption. Edits after the last completed checkpoint are adopted only by an explicit operator command: the operator inspects the exact fingerprint (staged, unstaged and eligible untracked content); identity and time are recorded; the fingerprint is recomputed immediately before consumption and recovery stops if it changed. Adoption is bound to repository, cycle, task, PR, stage, attempt, workspace, HEAD and checkpoint; consumption is single-use, atomic and crash-idempotent. Provenance is operator_adopted, a separate contract from #389's operator_attested, reusing its fingerprint, identity, audit and single-use primitives where appropriate. The original checkpoint and evidence are preserved and adoption is a new event. No executor adopts its own ambiguous edits. Adoption never establishes executor authorship, grants permissions, counts as functional verification or bypasses mandatory checks or the secret exclusions.
IR-002 Retention and coverage. Lifecycle-based, never time-based. Private recovery refs and their reachable objects are kept until the checkpoint is consumed, the cycle is terminal and no active recovery depends on them; interrupted cycles and integrity failures are never pruned automatically; abandoned checkpoints need an explicit operator discard. Pruning is explicit, supports --dry-run, and is auditable, concurrency-safe and idempotent; fingerprints, metadata and provenance survive content pruning. Refs protect objects from ordinary git gc/git prune and are never published. Captured: text and binary content exactly, staged and unstaged states separately, eligible untracked files, Git-representable modes, symlinks without dereferencing, submodules by gitlink SHA only; dirty submodules are detected and reported as unsupported. Excluded: ignored files, identified secrets, sockets, devices and FIFOs. A checkpoint with excluded or unrestorable relevant content is never reported as complete. Tests cover ordinary GC, repeated recovery, interrupted pruning and active dependencies.
IR-003 Secrets. A documented, versioned, user-extensible secret-path exclusion list (for example .env* except templates such as .env.example, *.pem, *.key, *.p12, *.pfx, id_rsa, id_ed25519, .npmrc, .netrc, .pypirc, .aws/credentials, credentials.json, secrets.json) applies to tracked, staged, unstaged and untracked content, plus ignored files. Existing secret-content detection is reused when available, without adding a dependency. Exclusion and detection run before anything is written to the Git object store, and fail closed when a required check cannot complete. Excluded files stay untouched; only their path and reason code are recorded, never content. Coverage gaps are reported. Docs state that path exclusion and content scanning reduce exposure but cannot guarantee every secret is detected. Tests cover tracked and untracked secrets, ignored files, template exceptions, custom patterns, scanner failure and preservation of excluded files.
Dependencies and exclusions
Builds on closed #389; general recovery deliberately extends its quota-only scope. Related #262 and #323 have different responsibilities. No publication, remote rewrite or consolidation in this issue; quota-policy changes are limited to the absorbed #525 handoff. Add temporary-repository integration tests, with no production repository fixtures.
Update docs/routing.md, docs/review-cycle.md, persistence documentation and capability-parity audit where applicable. Planning: P1, M1; urgent because interrupted writing stages can require manual recovery.
Activity
docs: record that #503 absorbs #525 in the roadmap (#553)
datacas commentedon Nov 30, 2026
Findings on PR #554 head
be91c43that superseded reviews reported and the latest review (2026-11-30 15:30, comment 7283100590) does not repeat. They are recorded here before those review comments are deleted to clear a finding-ID clash across interrupted reviews (toolkit bug filed separately). Full original comments are archived on the owner's host.From review comment 7273378790 (2026-11-30T08:48:57Z)
[REV-001] · medium · open · - · blocks:no — Permission rerun after a quota handoff is verified against the stale quota checkpoint
Path:
scripts/cycle.py(_route_attempt,_check_checkpoint_handoff)._route_attemptruns_check_checkpoint_handofffor everynumber > 0whilerun.checkpoint_handoffis set, and nothing clears it after the fallback starts. The stage allows a third attempt, a rerun after a permission answer (for number in range(3)). If the fallback edits the worktree and then asks for a permission, attempt 2 is verified against the quota checkpoint. The fingerprint or HEAD no longer matches, so the rerun is blocked with "the worktree is not the quota checkpoint". The result is a stop after the user already answered the permission. Evidence is from code reading; no test covers handoff followed by a permission rerun (not executed).From review comment 7273378790 (2026-11-30T08:48:57Z)
[REV-002] · low · open · - · blocks:no — Checkpoint settled by
reconcile_pendingafter a crash never verifies asmatchesPath:
scripts/recovery_checkpoints.py(reconcile_pending,verify). After a crash following the ref, the row is completed withfingerprint=Noneplusfingerprint_unrecorded, and the status stayscomplete.verifythen comparescurrent["fingerprint"] != None, so an untouched worktree reportsfingerprint_changedand the automatic handoff gate rejects it. It fails safe, but the crash test does not assert the state. Storing the fingerprint in the commit metadata would avoid it. Code reading only.From review comment 7273378790 (2026-11-30T08:48:57Z)
[REV-003] · low · open · - · blocks:no — Retention doc and code disagree on interrupted checkpoints
Path:
docs/recovery-checkpoints.md,scripts/recovery_checkpoints.py(consume,prunable). The doc says interrupted checkpoints are never pruned.consumemarks every complete or incomplete checkpoint of the scope consumed after a later successful stage, andprunablehas no filter onkind='interrupted'. After the cycle is terminal an explicitprunecan remove them. Align the doc or exclude the kind.Documentation:
docs/recovery-checkpoints.mdis new, anddocs/README.md,configuration.md,routing.md,telemetry.md,instrumentation.md,review-cycle.md,capability-parity-audit.md(PA-53, PA-54) andCHANGELOG.mdare updated. Nothing missing was found.Security triage: the deterministic rule did not fire (no CI, secret-file, agent-config path or label changed; the runtime plan has
security_required: false). By own judgement the secret-exclusion and Git-object handling were read inline: staged, unstaged and untracked paths are excluded before objects are written, scanning fails closed, and ignored files are not captured.cc-security-reviewwas not run, sosecurity_audit_ran=false. No vulnerability was found.Acceptance criteria (
tests.version=2): The criteria are numbered in the order of the request. AC-1 to AC-6 (recovery, integrity, ambiguous edits, writer lock, crash injection, retention and secrets) and AC-8 to AC-13 (#525 handoff, tests, routing page) are covered bytests/test_recovery_checkpoints.pyandtests/test_quota_handoff.py, which pass. AC-7 (recovery grants no approval) is covered by the docs only, with no dedicated test, so it stays open. The abrupt-termination test usesos._exit, notSIGKILL.Checks run:
python3 -m unittest tests.test_quota_handoff tests.test_recovery_checkpoints tests.test_quota_resumepython3 scripts/validate-package.pybasedpyrightpython3 -m unittest discover -s testsCI (parallel policy, state only): pass:
Classify the change,Skills, manifests, and Bash installer,Windows test shard (windows-1/2/3). Fail:Windows test shard (windows-4)andPowerShell installer.mainpasses at its head. I could not read the failing job logs (gh run viewis refused in this stage), so the cause is unknown.Residual risk: REV-001 is unexecuted. The two failing Windows jobs are new on this head and need the CI gate. A lock cannot attribute edits made outside the toolkit, as the doc discloses.
ORCHESTRATION_RESULT (JSON)
ORCHESTRATION_RESULT
{"skill": "cc-initial-review", "status": "REVIEW_PASSED_AWAITING_CI", "issue_provider": "github", "issue_id": "503", "code_host": "github", "change_request_id": "554", "change_request_url": "#554", "pr_number": 554, "issue_number": 503, "head_sha": "be91c436bd2259e2fecd676169180d5de305e67a", "reviewed_head_sha": "be91c436bd2259e2fecd676169180d5de305e67a", "security_audit_ran": false, "review_run_id": "CCR-20261130-001", "reviewer": {"profile": "reviewer", "provider": "anthropic", "model_requested": "claude-sonnet-5-5", "model_resolved": null, "effort": "high"}, "plan_id": "plan-cycle-a3f8cac5ed4d443c95afb98862ec18de", "revision": 16, "digest": "f9a38a65d6fea7a83bec5718fe7c3e5aaf6227ee9f3d2ae549bb1cc246277177", "findings": [{"id": "REV-001", "severity": "medium", "status": "open", "disposition": "-", "blocks_approval": false, "category": "correctness", "path": "scripts/cycle.py", "line": 710}, {"id": "REV-002", "severity": "low", "status": "open", "disposition": "-", "blocks_approval": false, "category": "correctness", "path": "scripts/recovery_checkpoints.py", "line": 1303}, {"id": "REV-003", "severity": "low", "status": "open", "disposition": "-", "blocks_approval": false, "category": "documentation", "path": "docs/recovery-checkpoints.md", "line": 233}], "blocking_findings": [], "checks": {"head_sha": "be91c436bd2259e2fecd676169180d5de305e67a", "passed": 5, "failed": 2, "pending": 0}, "tests": {"version": 2, "conclusion": "passed", "commands": [{"command": "python3 -m unittest tests.test_quota_handoff tests.test_recovery_checkpoints tests.test_quota_resume", "result": "passed"}, {"command": "python3 scripts/validate-package.py", "result": "passed"}, {"command": "basedpyright", "result": "passed"}, {"command": "python3 -m unittest discover -s tests", "result": "passed"}], "acceptance": [{"id": "AC-1", "status": "met"}, {"id": "AC-2", "status": "met"}, {"id": "AC-3", "status": "met"}, {"id": "AC-4", "status": "met"}, {"id": "AC-5", "status": "met"}, {"id": "AC-6", "status": "met"}, {"id": "AC-7", "status": "open"}, {"id": "AC-8", "status": "met"}, {"id": "AC-9", "status": "met"}, {"id": "AC-10", "status": "met"}, {"id": "AC-11", "status": "met"}, {"id": "AC-12", "status": "met"}, {"id": "AC-13", "status": "met"}]}, "blocking": false}
END_ORCHESTRATION_RESULT
From review comment 7282461874 (2026-11-30T15:07:13Z)
[REV-002] · low · open · - · blocks:no — Same-process lock re-entry
Path:
scripts/recovery_checkpoints.py(WriterLock.acquire,release).When the lock file names this process's PID and host,
acquirereplaces it and reports success instead ofConcurrentWriter. Two recorders in one process (threads, or an embedding caller) can then both write the same worktree. The first holder'sreleaseremoves the lock under the second.docs/recovery-checkpoints.mdand PA-53 promise that a second toolkit writer is refused. Evidence: code inspection; the stages in the current driver run sequentially, so this is latent. Suggested fix: refuse same-PID re-entry unless the lock object is the same instance.Acceptance criteria (AC-1 to AC-13)
Each has a check in the executed tests below (63 targeted, then the full suite).
test_recovery_checkpointsCaptureAndRestoreTests,CrashInjectionTests(includingos._exit).IntegrityTests,AdoptionTests.WriterLockTests,test_quota_handoff.WriterAndAdoptionTests; the limit is disclosed in the docs.SecretTests,SubmoduleTests,RetentionTests,test_ordinary_gc_keeps_checkpoint_objects.test_quota_handoff.AutomaticHandoffTests(AC-1 implement, AC-2 resolve, AC-3 both exhausted, AC-4 one reroute),docs/routing.mdnew section.Security triage
The deterministic rule did not fire (no CI, secret, key, agent-configuration path or label matched). The reviewer's reading found the change handles secret exclusion, but the audit was skipped as no sensitive surface (authentication, authorization, public API, dependency) changed. The secret-exclusion code was read inline. It fails closed on path, content, size and read errors. Residual: a file rewritten between the scan and
update-indexis flaggedchanged_during_capture(checkpointincomplete), but its object may already be in the private object store. A separatecc-security-reviewpass did not run.Verification (executed in this stage, head
be91c43)recovery-testspython3 -m unittest tests.test_recovery_checkpoints tests.test_quota_handoff tests.test_quota_resumevalidate-packagepython3 scripts/validate-package.pyVALID: 16 skillsbasedpyrightbasedpyrightunittest-defaultpython3 -m unittestconfigured-testpython3 -m unittest discover -s testsWindows behaviour (the lock's dead-process path, POSIX modes) was not executed here.
CI (read once, parallel policy; not findings)
gh pr checks 554: pass: Classify the change, Skills, manifests, and Bash installer, Windows test shard windows-1, windows-2, windows-3. fail: Windows test shard (windows-4) after 17m20s (it holdstest_recovery_checkpointsandtest_quota_handoff), PowerShell installer after 3 s. The failure logs are not readable in this stage (gh run viewis not in the review command table), so the cause is unknown. The CI gate waits for and decides on these checks.Documentation
docs/recovery-checkpoints.md(new),routing.md,review-cycle.md,telemetry.md,instrumentation.md,configuration.md,capability-parity-audit.md(PA-53, PA-54),README.mdindex andCHANGELOG.mdare updated. The PR description lists the documentation reviewed. No missing page found. Capability parity (#450): the new stops cover the automatic path only; the operator can still inspect, restore, adopt or run any operation directly.Residual risks
Locks exclude toolkit writers only (disclosed). Secret detection reduces exposure and cannot guarantee it. Windows has no process-group exit proof, so a quota stop there still stops.
The 2026-11-29 21:16 review also reported the stale-quota-checkpoint rerun (its REV-002) and the retention doc/code mismatch (its REV-004), the same issues as the first and third items above.
fix(recovery): never veto a resume on adoption lookup or lock release…
fix(recovery): look up adoptions only for a lockable Git worktree
fix(recovery): restore exact bytes and symlinks under Git for Windows…
fix(recovery): keep filter-driver blobs cleaned and cover fully stage…
fix(recovery): name only kept regular files in the checkpoint metadata
fix(recovery): verify and restore the captured worktree state
test(recovery): match the scanned file by identity, not by path spelling
feat: durable recovery checkpoints and quota handoff for writing stag…