Skip to content

mutation-cursor reconciliation wiring - #305

Merged
davidabram merged 16 commits into
fix-loggingfrom
ref-recon
Oct 11, 2026
Merged

davidabram merged 16 commits into
fix-loggingfrom
ref-recon

Conversation

@davidabram

Copy link
Copy Markdown
Member

No description provided.

@davidabram
davidabram added this pull request to stack #302 October 8, 2026 21:58
@davidabram
davidabram force-pushed the ref-recon branch 9 times, most recently from 5f99e67 to de6a1b7 Compare October 9, 2026 07:31
@davidabram
davidabram removed this pull request from stack #302 October 10, 2026 08:24
@davidabram
davidabram added this pull request to stack #312 October 10, 2026 08:24
davidabram and others added 15 commits October 10, 2026 14:27
Document how to make the existing mutation-cursor ref reconciler operational through shared mutation-scope maintenance and `sce doctor --fix`, including automatic throttling, safety constraints, tests, and context synchronization.

Plan: mutation-cursor-ref-reconciliation-wiring (T01-T06)

Co-authored-by: SCE <sce@crocoder.dev>
Document the verified lock ownership, production call graph, advisory-only hook design, durable maintenance-state rules, and database-opening constraints needed to implement mutation-cursor ref reconciliation safely.
Cite the completed audit and its findings so the follow-up implementation tasks have explicit scope and evidence.
Plan: mutation-cursor-ref-reconciliation-wiring, T01

Co-authored-by: SCE <sce@crocoder.dev>
Add explicit reconciliation and hook advisory entrypoints that share one held worktree lock, persist bounded maintenance state, and record successful and failed passes. Add verified-existing agent-trace DB opening so maintenance does not create or migrate databases, while preserving the existing deletion path.

Plan: `mutation-cursor-ref-reconciliation-wiring.md` (T02)

Co-authored-by: SCE <sce@crocoder.dev>
Ensure explicit reconciliation uses the production-resolved, verified read-only database and reports state-persistence diagnostics without losing reconciliation errors. Distinguish pre-rename failures from post-rename durability uncertainty, require confirmed writes for advisory results, and add deterministic coverage for open races, WAL coexistence, lock ownership, and persistence failures.

Plan: mutation-cursor-ref-reconciliation-wiring (T02)

Co-authored-by: SCE <sce@crocoder.dev>
…scopes

Completed mutation-scope boundaries now run the advisory-only ref reconciliation check after coordination returns, while preserving hook results and avoiding reconciliation, Git, or database work on the hook path. The injected report is mapped to stable debug or warning logs, including durability and state failures, and is limited to Close and Flush boundaries.

Ref: context/plans/mutation-cursor-ref-reconciliation-wiring.md (T03)

Co-authored-by: SCE <sce@crocoder.dev>
Expose actionable reconciliation advisory outcomes through an injected diagnostic writer while retaining structured logging. Add outcome-specific diagnostics for durability and state-write failures, keep advisory delivery independent of mutation results, and cover the seven outcome shapes with focused tests.

Ref: context/plans/mutation-cursor-ref-reconciliation-wiring.md (T03)

Co-authored-by: SCE <sce@crocoder.dev>
Make `sce doctor --fix` execute one explicit snapshot-ref reconciliation pass and report typed outcomes, while plain `sce doctor` remains read-only and reports when maintenance is recommended. Add a runtime facade and injected seams to preserve doctor testability and expose counts, failure kinds, warnings, and busy results.

Update the `mutation-cursor-ref-reconciliation-wiring` plan and related context for T04.

Co-authored-by: SCE <sce@crocoder.dev>
Cover retention of durable roots across worktrees, fail-closed handling of malformed namespace refs, and advisory busy behavior while an explicit pass holds the lock. Parameterize the durable-root fixture so the production-path tests exercise foreign worktree roots without repairing missing pins.

Plan: mutation-cursor-ref-reconciliation-wiring (T05)

Co-authored-by: SCE <sce@crocoder.dev>
Add CLI, linked-worktree, cross-process, lock-contention, state-recovery, and cancellation tests for the ref reconciliation path, using narrow coordinator and snapshot seams to exercise real behavior without changing production semantics. Cover database verification and fail-closed behavior, durable state normalization and uncertain persistence, hook/advisory ordering, and doctor outcomes.

Plan: mutation-cursor-ref-reconciliation-wiring.md (T05)
T05 remains in progress for the explicitly recorded S9, S14, and S26 production-path gaps and guard-removal checks.

Co-authored-by: SCE <sce@crocoder.dev>
Remove obsolete dead-code allowances now that snapshot-ref reconciliation runs through `sce doctor --fix`, keep only justified single-event loader exceptions, and make unreachable checkout-identity outcomes and test-only wrappers explicit. Synchronize the reconciliation, doctor, storage, and overview context with the single-lock maintenance entrypoint, verified-existing DB contract, advisory boundary, typed outcomes, and deferred cleanup limitations.

Plan: `context/plans/mutation-cursor-ref-reconciliation-wiring.md` — T06

Co-authored-by: SCE <sce@crocoder.dev>
Expand doctor CLI coverage to assert successful exit status for reported reconciliation outcomes and to exercise recovery from failed, stale, invalid, corrupt, oversized, and unreadable maintenance state. Record the remediation evidence and completed coverage status for the reconciliation wiring plan.

Plan: mutation-cursor-ref-reconciliation-wiring (T05)

Co-authored-by: SCE <sce@crocoder.dev>
Preserve the persistence failure phase when advisory anchor or normalization writes complete replacement but cannot confirm directory durability. Render a durability-specific diagnostic for those outcomes, while retaining the existing write-failed wording for pre-rename failures and adding regression coverage for visible post-rename state.

Update the reconciliation plan's T05 durability semantics and scenario coverage to match the outcome mapping.
Plan: mutation-cursor-ref-reconciliation-wiring (T05)

Co-authored-by: SCE <sce@crocoder.dev>
Add regression coverage proving that maintenance opening of a missing Agent Trace database returns the typed missing-database error without creating state-root entries. Mark the mutation-cursor reconciliation plan's acceptance criteria complete and record validation evidence for the completed implementation.

Plan: mutation-cursor-ref-reconciliation-wiring
Tasks: T05, T06

Co-authored-by: SCE <sce@crocoder.dev>
The doctor reconciliation CLI test sandbox assumed a `state` directory under the temporary home, but on macOS the CLI resolves its state root to `Library/Application Support`. Resolve the sandbox state root per platform so the tests locate the same Agent Trace database and maintenance state as the CLI under test.

Co-authored-by: SCE <sce@crocoder.dev>
Consolidate redundant reconciliation, advisory, doctor, and maintenance-state tests into table-driven cases while strengthening assertions for exit statuses, ref inventories, pin preservation, typed failures, and read-only database behavior. Remove obsolete test-only lock-acquisition wrappers and align the CLI/context coverage documentation with the retained scenarios.

Plan: mutation-cursor-ref-reconciliation-wiring
Tasks: T05

Co-authored-by: SCE <sce@crocoder.dev>
Allow a retry when its backoff can finish before the contention deadline without requiring the busy timeout to fit in the remaining budget. Add boundary tests covering sleep and immediate retry eligibility.

Co-authored-by: SCE <sce@crocoder.dev>
@davidabram
davidabram removed this pull request from stack #312 October 10, 2026 22:50
@davidabram
davidabram added this pull request to stack #320 October 10, 2026 22:50
@davidabram
davidabram merged commit c960dc3 into remove-tokio-db-runtimes Oct 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant