Skip to content

Mutation cursor ref reconciliation - #246

Open
davidabram wants to merge 12 commits into
mutation-cursor-external-taintfrom
ref-rec
Open

Mutation cursor ref reconciliation#246
davidabram wants to merge 12 commits into
mutation-cursor-external-taintfrom
ref-rec

Conversation

@davidabram

Copy link
Copy Markdown
Member

No description provided.

@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sce-config-json Ready Ready Preview Aug 31, 2026 10:50pm

Request Review

davidabram and others added 8 commits September 1, 2026 14:31
Define the staged implementation path for conservative per-worktree SCE ref reconciliation. The plan specifies durable root discovery, fail-closed pin inventory, atomic conditional deletion under WorktreeLock, and tests needed to safely reclaim orphan pins without changing protocol semantics.

Plan: mutation-cursor-ref-reconciliation
Tasks: T01, T02, T03, T04, T05

Co-authored-by: SCE <sce@crocoder.dev>
Expose worktree-scoped and repository-wide sets of cursor and historical event tree IDs through single-statement UNION queries, preserving roots across atomic cursor advances and excluding unrelated or transient state.

Add coverage for deduplication, worktree isolation, empty repositories, and snapshot retention, and document the store contract.
Plan: mutation-cursor-ref-reconciliation.md T01

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

Enable future ref reconciliation to inventory only pins owned by a worktree and safely remove them without deleting refs that changed after inventory. Add validated PinnedRef inventory with distinct Git/malformed errors and SHA-conditioned batch deletion via one update-ref --stdin transaction, with tests covering scope, malformed refs, and atomic abort behavior.

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

Co-authored-by: SCE <sce@crocoder.dev>
Mutation-cursor pins must remain direct tree refs so a symbolic ref under one worktree's namespace cannot resolve into another worktree's pin.

Use NUL-delimited for-each-ref inventory with %(symref), reject symbolic refs, and fail closed by re-inventorying before an atomic git update-ref --no-deref --stdin deletion. Add race and transaction tests and update the runtime contract and plan state.

Plan: `mutation-cursor-ref-reconciliation`, T02 (AC7, AC10).

Co-authored-by: SCE <sce@crocoder.dev>
Replace manually generated test database paths and explicit cleanup with tempfile-owned directories so fixtures are isolated and cleaned up automatically. Add tempfile as a dev dependency and pass borrowed paths through the store test helpers.

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

Prevent parallel and cross-process test collisions by owning each temporary repository with tempfile::TempDir, replacing PID/counter-derived paths and manual cleanup with RAII teardown.

Clarify that mutation-cursor reconciliation removes only orphan or unreferenced pins, retains current and historical durable roots, and does not bound storage for indefinitely retained mutation history. Record the test-isolation follow-up and lifecycle clarification in the affected plans.

Plans: mutation-cursor-ref-reconciliation (T02); mutation-cursor-runtime-coordinator

Co-authored-by: SCE <sce@crocoder.dev>
Reclaim orphaned SCE-owned snapshot refs without deleting trees that remain durable roots in any worktree. Run inventory, local fail-closed validation, and repository-wide root retention under the shared WorktreeLock, then atomically delete only stale refs.

Add dedicated error/report contracts and coverage for linked-worktree retention, malformed or missing pins, idempotence, and no-object-reclamation. Keep this imperative maintenance outside the verified mutation-cursor protocol and defer harness wiring.

Plan: mutation-cursor-ref-reconciliation (T03)

Co-authored-by: SCE <sce@crocoder.dev>
Verify reconciliation waits for the worktree lock before scanning durable roots, so a pin created while the lock is held is retained after the pass proceeds. The regression uses channel synchronization and asserts the durable cursor ref survives without timing-based sleeps.

Plan: mutation-cursor-ref-reconciliation (T04)

Co-authored-by: SCE <sce@crocoder.dev>
Clarify that per-worktree reconciliation covers only still-identifiable active worktree namespaces, while retired-worktree cleanup remains future repository-scoped work. Make missing checkout identity an explicit skipped outcome and precisely reframe the T04 lock-race proof without overstating production CAS coverage.

Plan: mutation-cursor-ref-reconciliation (T05–T09); update the related acceptance criteria through AC18 and preserve fail-closed deletion guarantees.

Co-authored-by: SCE <sce@crocoder.dev>
davidabram and others added 3 commits September 1, 2026 15:53
A missing current checkout identity must not look like a successful zero-work reconciliation, since no per-worktree namespace can be derived or safely inspected. Return explicit `SkippedNoCheckoutIdentity` and avoid opening the database on that path, while preserving normal reports as `Reconciled`.

Update runtime tests for outcome handling and no-op safety. Document that per-worktree cleanup only reaches still-identifiable namespaces and that retired linked-worktree refs require future repository-scoped reconciliation.

Plan: mutation-cursor-ref-reconciliation (T05, T06)

Co-authored-by: SCE <sce@crocoder.dev>
Ensure reconciliation is serialized against the coordinator's complete pin-to-CAS critical section, including the real durable mutation commit. The deterministic cross-module test pauses a real coordinator after pinning and verifies reconciliation waits, then retains the committed tree and its durable event.

Update the runtime context and mark T07 complete with its verification evidence.
Plan: mutation-cursor-ref-reconciliation, T07

Co-authored-by: SCE <sce@crocoder.dev>
Reframe per-worktree ref cleanup around checkout identities currently derived by a worktree, covering deleted worktrees and checkout-id metadata loss or recreation as unowned namespaces requiring future repository-scoped cleanup. Correct report invariants for skipped outcomes and harden the missing-identity regression to compare full ref structure while preserving fail-closed, no-DB behavior.

Ref: context/plans/mutation-cursor-ref-reconciliation.md (T05, T06)

Co-authored-by: SCE <sce@crocoder.dev>
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