Prevent Unauthorized Metadata Ref Creation · Entire
Log in
xhigh effort → 5 angles × 8 candidates → 1-vote verify → sweep → ≤15 findings
You are reviewing for recall at extra-high effort: catch every real bug. At this level, catching real bugs matters more than avoiding false positives — a missed bug ships. Err on the side of surfacing.
Phase 0 — Gather the diff
Run git diff @{upstream}...HEAD (or git diff main...HEAD / git diff HEAD~1
if there's no upstream) to get the unified diff under review. If there are
uncommitted changes, or the range diff is empty, also run git diff HEAD and
include the working-tree changes in scope — the review often runs before the
commit. If a PR number, branch name, or file path was passed as an argument,
review that target instead. Treat this diff as the review scope.
Phase 1 — Find candidates (5 angles, up to 8 each)
Run 5 independent finder angles via the Agent tool. Each surfaces up to 8 candidate findings. Do NOT let one angle's conclusions suppress another's — if two angles flag the same line for different reasons, record both.
Angle A — line-by-line diff scan
Read every hunk in the diff, line by line. Then Read the enclosing function for
each hunk — bugs in unchanged lines of a touched function are in scope (the PR
re-exposes or fails to fix them). For every line ask: what input, state, timing,
or platform makes this line wrong? Look for inverted/wrong conditions,
off-by-one, null/undefined deref, missing await, falsy-zero checks,
wrong-variable copy-paste, error swallowed in catch, unescaped regex metachars.
Angle B — removed-behavior auditor
For every line the diff DELETES or replaces, name the invariant or behavior it enforced, then search the new code for where that invariant is re-established. If you can't find it, that's a candidate: a removed guard, a dropped error path, a narrowed validation, a deleted test that was covering a real case.
Angle C — cross-file tracer
For each function the diff changes, find its callers (Grep for the symbol) and check whether the change breaks any call site: a new precondition, a changed return shape, a new exception, a timing/ordering dependency. Also check callees: does a parallel change in the same PR make a call unsafe?
Angle D — language-pitfall specialist
Scan for the classic pitfalls of the diff's language/framework — for example:
JS falsy-zero, == coercion, closure-captured loop var; Python mutable default
args, late-binding closures; Go nil-map write, range-var capture; SQL injection;
timezone/DST drift; float equality. Flag any instance the diff introduces.
Angle E — wrapper/proxy correctness
When the PR adds or modifies a type that wraps another (cache, proxy, decorator,
adapter): check that every method routes to the wrapped instance and not back
through a registry/session/global — e.g. a caching provider holding a
delegate field that resolves IDs via session.get(...) instead of
delegate.get(...) will re-enter the cache or recurse. Also check that the
wrapper forwards all the methods the callers actually use.
Phase 2 — Verify (1-vote, 3-state)
Dedup candidates that point at the same line/mechanism, keeping the one with the most concrete failure scenario. For each remaining candidate, run one verifier via the Agent tool: give it the diff, the relevant file(s), and the candidate, and have it return exactly one of:
- CONFIRMED — can name the inputs/state that trigger it and the wrong output or crash. Quote the line.
- PLAUSIBLE — mechanism is real, trigger is uncertain (timing, env, config). State what would confirm it.
- REFUTED — factually wrong (code doesn't say that) or guarded elsewhere. Quote the line that proves it.
Keep candidates where the vote is CONFIRMED or PLAUSIBLE.
This is recall mode — a single non-REFUTED vote carries the finding. Do NOT drop on uncertainty.
Phase 3 — Sweep for gaps
Run one more finder as a fresh reviewer who has the verified list. Re-read
the diff and enclosing functions looking ONLY for defects not already listed.
Do not re-derive or re-confirm anything already there — the job is gaps. Focus
on what the first pass tends to miss: moved/extracted code that dropped a guard
or anchor; second-tier footguns (dataclass default evaluated once, hash()
non-determinism, lock-scope shrink, predicate methods with side effects);
setup/teardown asymmetry in tests; config defaults flipped.
Surface up to 8 additional candidates, each naming a defect not already on the list. If nothing new, return an empty sweep — do not pad.
Output
Return findings as a JSON array of at most 15 objects:
1
2
3
4
5
6
7
8
[\
{\
"file": "path/to/file.ext",\
"line": 123,\
"summary": "one-sentence statement of the bug",\
"failure_scenario": "concrete inputs/state → wrong output/crash"\
}\
]
Ranked most-severe first. If more than 15 survive, keep the 15 most
severe. If nothing survives verification, return [].
1mo ago·5m·16 calls
All 5 angle finders are running in parallel. Waiting for them to complete.
I have sufficient context. Let me now write the findings:
Findings (JSON):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
[\
{\
"file": "cmd/entire/cli/git_operations.go",\
"line": 475,\
"summary": "MirrorCommittedMetadataRefBestEffort inherits the 2-min WithTimeout ctx; near the deadline, ResolveCommittedRefs->settings.Load fails its internal `exec.CommandContext(ctx, \"git\", \"rev-parse\", \"--git-common-dir\")` and silently returns mirrorEnabled=false, skipping mirror after a successful fetch.",\
"failure_scenario": "fetchMetadataFromOrigin succeeds at ~1m59s; the post-fetch ctx is effectively expired. MirrorCommittedMetadataRefBestEffort calls ResolveCommittedRefs(ctx) -> settings.Load(ctx) -> clonePreferencesPathForWorktreeRoot(ctx) which runs exec.CommandContext with a dead deadline. Load errors out, MirrorsToV1CustomRef returns false (no log), HasMirror=false, and mirror is skipped without warning. v1 advances on disk; v1.1 mirror stays at the old hash. Subsequent v1.1 reads via the custom ref see stale data."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 31,\
"summary": "MirrorCommittedMetadataRef now force-sets the mirror via repo.Storer.SetReference, replacing the old SafelyAdvanceLocalRef path; any local-only commits ever reachable from the mirror are silently rewound to primary's tip.",\
"failure_scenario": "If a v1.1 mirror ref has, for any reason (concurrent worktree write, replay glitch, manual user op, prior bug), gained a commit not in v1, every strategy callsite (PostCommit, condensation, finalize, FetchMetadataBranch, push-fetch-rebase) will now rewind it without warning. The previous strategy-side helper used SafelyAdvanceLocalRef which preserved local-only commits via merge-base/cherry-pick. The new test TestMirrorCommittedMetadataRef_ReplacesLocallyAheadMirror documents this as intentional but it is a behavior change vs the deleted strategy.mirrorMetadataToV1CustomRef."\
},\
{\
"file": "cmd/entire/cli/settings/settings.go",\
"line": 995,\
"summary": "MirrorsToV1CustomRef swallows settings.Load errors with no log, so any mirror best-effort caller silently skips when settings load fails (transient FS error, ctx-cancelled exec, brief settings.json rename window).",\
"failure_scenario": "During an atomic settings.json rewrite (write-then-rename), a concurrent post-commit hook calls MirrorCommittedMetadataRefBestEffort -> ResolveCommittedRefs -> Load returns an os error briefly. MirrorsToV1CustomRef returns false silently; mirror is skipped for that write. The primary advances; v1.1 mirror diverges by one checkpoint. No warning is logged anywhere because the load error is swallowed inside settings.MirrorsToV1CustomRef and the BestEffort wrapper only logs when HasMirror=true."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 481,\
"summary": "mirrorSyncedMetadataBranch calls ResolveCommittedRefs and then MirrorCommittedMetadataRefBestEffort which calls ResolveCommittedRefs again; each call re-runs settings.Load including an `exec git rev-parse --git-common-dir`. In a multi-remote push the helper fires after every fetchAndRebase round-trip.",\
"failure_scenario": "Push touches N session branches; for each branch fetchAndRebaseSessionsCommon calls mirrorSyncedMetadataBranch which double-resolves settings (2 git exec calls + 2 file reads per call). On a multi-session push hook this measurably amplifies hook latency. Not a correctness bug, but the new helper imposes duplicate ResolveCommittedRefs work along the hot push path that didn't exist before. Could be eliminated by passing the already-resolved refs into the BestEffort variant."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 121,\
"summary": "FetchMetadataBranch returns nil and only logs a Warn when OpenRepository fails *after* a successful fetch+promote, masking a genuine repo-open failure.",\
"failure_scenario": "fetchURLIntoTmpRef and PromoteTmpRefSafely both succeed (the fetch worked, primary updated). OpenRepository then fails because paths.WorktreeRoot's `git rev-parse --show-toplevel` was killed by an expired ctx (caller may have used WithTimeout). The function logs at Warn and returns nil — claiming success — even though the open failure prevented mirroring. Caller cannot distinguish 'mirror skipped intentionally' from 'something genuinely broke after the fetch'. The earlier failure modes (fetch/promote) propagate errors; this one swallows."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 178,\
"summary": "fetchMetadataBranchIfMissing skips the fetch (and therefore the mirror) as soon as Primary (v1 branch) exists locally, even if the v1.1 mirror ref is missing on first opt-in.",\
"failure_scenario": "User opts into checkpoints_version=\"1.1\" on a repo that already has the v1 branch locally. On the next push, fetchMetadataBranchIfMissing finds refs.Primary present and returns early without fetching — so FetchMetadataBranch is never called and MirrorCommittedMetadataRefBestEffort never runs. The v1.1 ref stays absent until the next write hook (post-commit/condensation) happens to mirror it. Reads against the missing v1.1 ref fall through committed_read_store paths in a way the user doesn't anticipate from the v1.1 opt-in moment."\
},\
{\
"file": "cmd/entire/cli/git_operations.go",\
"line": 432,\
"summary": "fetchMetadataFromOrigin returns the error string \"primary metadata ref %s is not a branch\" formatted from refs.Primary even when the topology is fine (Primary is empty), which would happen only if a future ResolveCommittedRefs returned a zero-valued CommittedRefs.",\
"failure_scenario": "Today ResolveCommittedRefs always populates Primary with the v1 branch (even on settings-load failure), so this branch is unreachable. But the guard is intentionally defensive — if a future change to ResolveCommittedRefs ever returns a zero CommittedRefs (e.g., a new topology where Primary depends on settings that failed to load), the user-facing error message reads 'primary metadata ref is not a branch' (with empty name) which is unactionable. The IsBranch() guard handles the panic risk correctly but produces a confusing diagnostic when triggered."\
}\
]
Summary of investigation:
Read the diff for git_operations.go, strategy/checkpoint_remote.go, strategy/v1_custom_ref_mirror.go, strategy/push_common.go, checkpoint/committed_refs.go, plus the new test files and the deleted cli/v1_custom_ref_mirror*.go. Traced callsites through manual_commit_hooks.go, manual_commit_condensation.go, attach.go, explain.go, and verified settings.Load/MirrorsToV1CustomRef/ResolveCommittedRefs/OpenRepository behavior.
Things explicitly checked and ruled out:
- nil-deref on empty
refs.Primary:committedRefsForalways setsPrimaryto the v1 branch (even when settings load fails), and theIsBranch()guard rejects empty/non-branch values. Safe today. defer cancel()ordering:ctx, cancel := context.WithTimeout(...); defer cancel()is correct infetchMetadataFromOrigin. No leak.- Hardcoded "origin" in
plumbing.NewRemoteReferenceName("origin", branchName): preexisting pattern, matched to the hardcoded refspec; not introduced by this diff. - Tests using
paths.ClearWorktreeRootCache(): the affected tests allt.Chdir()and are marked non-parallel; no race with parallel tests in the same file. MirrorCommittedMetadataRef(non-best-effort) callers inattach.go/explain.goreturning the error: those paths just wrote to primary, soErrReferenceNotFoundcannot fire there. Strict-error mode is appropriate.errors.Is(err, plumbing.ErrReferenceNotFound)usage: consistent with the rest of the codebase.
Candidate findings (8 max requested, 7 returned) — see JSON above. Strongest signal: finding #1 (ctx-deadline silently disables mirror after slow fetches) and #3 (settings load errors swallowed without log anywhere in the chain). #2 documents a real behavior change vs the deleted strategy helper that the test suite normalizes as intended.
1mo ago·4.2s
Angle D complete. Waiting on remaining 4 angles.
Now I have enough analysis. Let me return the JSON findings.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 49,\
"summary": "MirrorCommittedMetadataRefBestEffort misclassifies a SetReference ErrReferenceNotFound as 'primary missing'.",\
"failure_scenario": "If repo.Storer.SetReference returns plumbing.ErrReferenceNotFound (e.g., a backing storage bug or refs/entire occupied as a file), errors.Is(err, plumbing.ErrReferenceNotFound) matches the wrapped 'set mirror ref %s' chain, so the best-effort caller logs Debug 'primary metadata ref unavailable' instead of Warn 'mirror failed', burying a real mirror write failure."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 117,\
"summary": "FetchMetadataBranch reports nil success even if PromoteTmpRefSafely advanced v1 but OpenRepository fails before the mirror runs.",\
"failure_scenario": "When v1.1 is enabled and PromoteTmpRefSafely succeeds (v1 ref now points at the fetched tip), an OpenRepository error causes the function to log a warning and return nil. v1.1 mirror stays stale; subsequent committed reads through the v1.1 read ref miss the just-fetched data with no error surfaced to the caller. Failure mode silent until later read returns 'not found'."\
},\
{\
"file": "cmd/entire/cli/git_operations.go",\
"line": 475,\
"summary": "MirrorCommittedMetadataRefBestEffort runs under a soon-to-expire 2-minute fetch timeout context.",\
"failure_scenario": "If fetchMetadataFromOrigin nearly exhausts its 2-minute timeout during fetch, the shadowed ctx is at or past deadline by the time the mirror call runs. ResolveCommittedRefs → settings.Load may hit ctx.Err() in any subsystem honoring ctx (e.g., paths.AbsPath chain), and settings.Load returns false on error, so MirrorsToV1CustomRef reports false, the mirror is skipped silently, and v1.1 reads stay stale after a successful v1 fetch."\
},\
{\
"file": "cmd/entire/cli/checkpoint/committed_read_store.go",\
"line": 11,\
"summary": "v1.1 fresh-clone read paths no longer seed the mirror from a populated v1 ref.",\
"failure_scenario": "User clones a repo (or pulls) with checkpoints_version='1.1' configured. v1 branch is present (from clone/pull), v1.1 ref does not exist. SyncCommittedReadRef previously seeded the mirror on first read; now NewCommittedReadStore reads refs/entire/checkpoints/v1.1 as-is and returns ErrCheckpointNotFound. `entire explain`, `entire checkpoint list`, `entire status`, and `headCheckpointFlags` all report nothing until a write/fetch CLI command happens to mirror — but a plain `git pull` will not."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 401,\
"summary": "fetchAndRebaseSessionsCommon mirrors even when no v1 write happened (localRef == remoteRef early return path).",\
"failure_scenario": "When local and remote v1 tips are already equal, no advancement occurred but mirrorSyncedMetadataBranch is invoked anyway. If the local mirror diverged due to a stale prior write (or was force-set to a different hash by a concurrent process), this call silently force-overwrites the mirror to match v1 — surprising for callers expecting a no-op fetch to leave refs untouched. Lower-risk variant of intentional behavior, but worth flagging."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch silently skips the mirror when refs.Primary is not a branch ref.",\
"failure_scenario": "If a future settings change made refs.Primary a non-branch reference (e.g., refs/entire/...), the !refs.Primary.IsBranch() guard returns early without mirroring even though fetchAndRebaseSessionsCommon just advanced the v1 branch. Same hidden divergence as #4: v1 is current, v1.1 mirror is stale, reads return wrong/missing data with no log."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 31,\
"summary": "MirrorCommittedMetadataRef force-sets the mirror to primary without checking that the mirror would not lose unique commits.",\
"failure_scenario": "Today the mirror is only written by these functions, so divergence is impossible — but a partial rollout where another path writes to refs/entire/checkpoints/v1.1 (a future v1.1-as-primary state) would cause local v1.1-only commits to be silently overwritten by the v1 tip. The old code used SafelyAdvanceLocalRef, which preserved local-only commits. Migration-time hazard."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 178,\
"summary": "fetchMetadataBranchIfMissing only checks refs.Primary; on v1.1 mode it still pulls v1 but doesn't ensure mirror is seeded if v1 already exists.",\
"failure_scenario": "If v1 branch already exists locally on a fresh clone (e.g., via `git clone --branch`), this function returns nil without fetching — and without mirroring. On v1.1 mode the mirror stays missing/stale, so the first write-time mirror call only updates when a write actually happens. Reads in the meantime return not-found despite v1 being populated."\
}\
]
```</result>
<usage><total_tokens>142415</total_tokens><tool_uses>53</tool_uses><duration_ms>342029</duration_ms></usage>
</task-notification>
1mo ago·4.0s
Angle A complete. Awaiting B, C, E.
Let me now also verify the MirrorCommittedMetadataRefBestEffort call inside fetchMetadataFromOrigin is conditional on v1.1. It calls ResolveCommittedRefs(ctx) internally, which is fine — if not in v1.1 mode, it's a no-op. Good.
Now let me check runStatus for any other relevant impacts. But honestly I have enough strong candidates. Let me also look once more if there's a regression in the MirrorCommittedMetadataRef error semantics for runAttach/generateCheckpointSummary:
In the old code, mirrorToV1CustomRef in cli was called AFTER a write that should always update v1, so primary-missing was an unexpected post-write inconsistency — the new code returns an error wrapping plumbing.ErrReferenceNotFound. The old code did the same. Match.
Let me also check if test for TestNewCommittedReadStore_V11Reads originally had a "reads remote-only metadata" test case (covered the fresh-clone fallback path) and the new test removed it:
Looking at the diff: the old test had "reads remote-only metadata" which set originV1Ref and removed local v1, expecting wantFound=true. The new test has "does not seed missing custom ref from origin v1" which sets originV1Ref, removes local v1, expecting wantFound=false. This is explicitly an asserted regression. The PR description acknowledges this design choice but it's worth flagging as a behavior change with user-visible impact.
Now let me also double-check entire explain would actually fail in fresh-clone v1.1 mode. The ListCommitted requires the read ref — and getSessionsBranchTree for v1.1 doesn't fall back to origin (per line 1792 check). So entire explain <id> would return "sessions ref ... not found" error.
Let me now also verify the explain command on fresh-clone gives a useful path forward. The user might just run git fetch origin entire/checkpoints/v1:entire/checkpoints/v1. Then the local v1 branch exists. But v1.1 mirror still doesn't. So they STILL can't read.
Now I have my findings. Let me also check entire status for a fresh clone in v1.1 mode actually showing wrong information:
Actually wait — status.go``headCheckpointFlags returns (false, false, "") on failure, which produces the "no checkpoint" status. Old behavior: would actually find the checkpoint via origin fallback. New behavior: silently treats as no checkpoint. Strong regression for v1.1 fresh clones with checkpoint HEAD.
Now I'll write up the findings:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
"findings": [\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/checkpoint/committed_read_store.go",\
"line": 11,\
"summary": "Fresh-clone v1.1 read paths lose origin/v1 fallback: NewCommittedReadStore binds to refs/entire/checkpoints/v1.1, getSessionsBranchTree explicitly skips the origin/entire/checkpoints/v1 fallback for any ref other than the default v1 branch, and the removed SyncCommittedReadRef was the only thing that previously seeded the v1.1 mirror from refs/remotes/origin/entire/checkpoints/v1. Nothing in the new code re-seeds on read.",\
"failure_scenario": "User clones a repo where teammate used entire with checkpoints_version=1.1 and ran 'entire enable'. After clone, refs/remotes/origin/entire/checkpoints/v1 exists; refs/heads/entire/checkpoints/v1 and refs/entire/checkpoints/v1.1 do not. Running 'entire list' returns 'sessions ref refs/entire/checkpoints/v1.1 not found'. Running 'entire explain <id>' returns the same error. Running 'entire status' on HEAD with an Entire-Checkpoint trailer silently shows neither review nor investigate flags (headCheckpointFlags swallows the error and returns false/false). Previously, syncMirrorForRead would have seeded the mirror from origin/v1 and all of these would work. No 'entire' command on this user's machine creates the mirror until they write a new checkpoint, but they can't generally write a checkpoint without first reading existing state."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/common.go",\
"line": 477,\
"summary": "EnsureMetadataBranch creates/updates the local v1 branch from refs/remotes/origin/entire/checkpoints/v1 (lines 477 and 500-505) but never updates the v1.1 mirror. 'entire enable' invokes EnsureSetup -> EnsureMetadataBranch, so the natural onboarding path for a fresh clone in v1.1 mode leaves the read-side mirror unseeded even though the v1 branch is now populated locally.",\
"failure_scenario": "Fresh clone in v1.1 mode + 'entire enable'. v1 branch is materialised from origin, but refs/entire/checkpoints/v1.1 still doesn't exist. The next 'entire list' / 'entire explain' / 'entire status' returns empty or an error because the read store is bound to the missing v1.1 mirror. Previously the next read would call SyncCommittedReadRef and seed the mirror. Now it doesn't."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/resume.go",\
"line": 606,\
"summary": "checkRemoteMetadata's v1.1 branch tells the user 'This ref is local-only. Try: entire explain <id>'. But 'entire explain' (via newExplainCheckpointLookup) also reads via the v1.1 mirror with no origin fallback (SyncCommittedReadRef call sites at explain.go:687, 851, 2005 all removed). On a fresh clone, the suggested follow-up command silently fails the same way, leaving the user in a loop.",\
"failure_scenario": "Fresh clone, v1.1 mode. User runs 'entire resume' for a checkpoint they see in 'git log'. resume falls through to checkRemoteMetadata, which prints 'Try: entire explain <id>'. User runs 'entire explain <id>', which fails with 'sessions ref refs/entire/checkpoints/v1.1 not found'. There is no documented escape hatch (the hint 'git fetch origin entire/checkpoints/v1:entire/checkpoints/v1' creates the v1 branch but not the v1.1 mirror, so explain still fails)."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/dispatch/mode_local.go",\
"line": 174,\
"summary": "Switch from NewGitStore(repo) (v1 branch with origin fallback) to NewCommittedReadStore(ctx, repo) (v1.1 mirror in v1.1 mode, no origin fallback) means 'entire dispatch' fails on fresh clones / post-pull states in v1.1 mode where the mirror is stale or missing.",\
"failure_scenario": "User dispatches work after a 'git pull' that updated origin/entire/checkpoints/v1 (or after a fresh clone). enumerateRepoCandidates calls store.ListCommitted which returns the sessions-ref-not-found error in v1.1 mode, so the dispatch command reports 'list committed checkpoints: ...' instead of finding checkpoints the user can see in git log. Previously NewGitStore + SyncCommittedReadRef gave a working read path in both cases."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/rewind.go",\
"line": 696,\
"summary": "restoreSessionTranscriptFromStrategy no longer calls SyncCommittedReadRef. After a teammate pushes new checkpoint metadata and the local user does 'git fetch origin entire/checkpoints/v1:entire/checkpoints/v1' (advancing the local v1 branch), the v1.1 mirror is still pointed at the previous v1 tip until some 'entire' write/fetch path runs. The user-visible read can return stale transcripts or 'checkpoint not found' for a freshly-fetched checkpoint.",\
"failure_scenario": "v1.1 mode. User fetches updated v1 metadata directly via plain git (e.g. via a CI script or 'git fetch ... refs/heads/entire/checkpoints/v1:refs/heads/entire/checkpoints/v1'). Local v1 branch advances; v1.1 mirror remains at old tip. User runs 'entire rewind <newCheckpointID>' — restoreSessionTranscriptFromStrategy reads via stale v1.1 mirror, ReadRawSessionLogForCheckpoint returns 'checkpoint not found' even though the metadata is reachable in v1. Previously, the call to SyncCommittedReadRef would have advanced the mirror to v1's tip before the read."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/explain.go",\
"line": 2005,\
"summary": "getBranchCheckpoints previously called SyncCommittedReadRef before reading; now it doesn't. In v1.1 mode, branch-checkpoint listings will miss any v1 updates fetched by tools other than entire's own write/fetch helpers (e.g. plain 'git fetch' refspec updates, CI-driven pulls).",\
"failure_scenario": "v1.1 mode. The local v1 branch was updated by an out-of-band 'git fetch' / 'git pull' but no entire-internal write or FetchMetadataBranch ran afterwards. 'entire explain' (no args), 'entire explain --since', or any caller of getBranchCheckpoints reads from the stale v1.1 mirror and silently omits the newer checkpoints the user just fetched."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 31,\
"summary": "MirrorCommittedMetadataRef replaced SafelyAdvanceLocalRef with a raw force-overwrite Storer.SetReference. Previously, the strategy-side mirror call preserved local-only commits on the mirror via ancestry-aware replay. Now it unconditionally overwrites the mirror to the primary's hash and discards any divergent history. The new test TestMirrorCommittedMetadataRef_ReplacesLocallyAheadMirror asserts this overwrite is intentional, but the old syncMirrorForRead detected divergence and *left the mirror untouched*, so any future code path or migration that lands divergent commits on refs/entire/checkpoints/v1.1 will silently lose them in the next entire write/fetch.",\
"failure_scenario": "Forward-compat hazard: a future migration that lands extra commits on refs/entire/checkpoints/v1.1 (e.g. a v1.2 rollout that briefly uses v1.1 as primary, or a doctor-time repair that materialises local-only data into the mirror) will be silently rewound to v1's tip the next time any hook condenses a session, runs attribution, finalises turns, fetches metadata, or attaches a session. Tests assert this is intentional today, but the loss-of-history semantics are now baked into hot paths instead of guarded by ancestry checks."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/review_context.go",\
"line": 101,\
"summary": "reviewCommittedCheckpointContext no longer calls SyncCommittedReadRef before reading. In v1.1 mode, the review context (used to surface prior reviews to a new review session) will read from a stale v1.1 mirror after any out-of-band v1 update, dropping the very review history the new review session needs to avoid duplicating work.",\
"failure_scenario": "v1.1 mode. User pulls a teammate's update that advances the local v1 metadata branch (e.g. via a plain 'git pull' with a configured refspec, or via a v1-targeting tool). The v1.1 mirror remains at the old tip. User runs 'entire review'; reviewCommittedCheckpointContext walks the stale mirror, fails to see the teammate's review, and feeds the agent context that hides already-reviewed work."\
}\
]
}
CANDIDATE FINDINGS (Angle B — removed-behavior auditor):
cmd/entire/cli/checkpoint/committed_read_store.go:11— Fresh-clone v1.1 read paths lose origin/v1 fallback.NewCommittedReadStorebinds torefs/entire/checkpoints/v1.1;getSessionsBranchTreeincommitted.go:1792explicitly only falls back torefs/remotes/origin/entire/checkpoints/v1when the read ref is the default v1 branch (not the v1.1 mirror). The removedSyncCommittedReadRefwas the only thing that previously seeded the v1.1 mirror from origin/v1. Failure: fresh clone of a v1.1-enabled repo →entire list,entire explain <id>,entire statusflags,entire dispatch,entire resumecheckRemoteMetadata branch,entire attachall silently fail or return empty because the mirror ref doesn't exist and nothing on the read path creates it.cmd/entire/cli/strategy/common.go:477—EnsureMetadataBranch(called fromEnsureSetup, i.e.entire enable) creates/updates the local v1 branch fromrefs/remotes/origin/entire/checkpoints/v1but never seeds the v1.1 mirror. Onboarding a fresh clone withentire enablein v1.1 mode therefore leaves the read-side mirror unseeded even though the v1 branch is now populated; the next read still fails.cmd/entire/cli/resume.go:606— v1.1 branch ofcheckRemoteMetadatainstructs the user to runentire explain <id>, butnewExplainCheckpointLookup(explain.go:851, with theSyncCommittedReadRefcall removed) also has no origin fallback in v1.1 mode. The suggested follow-up command fails the same way, looping the user with no documented escape hatch (the legacy hintgit fetch origin entire/checkpoints/v1:entire/checkpoints/v1creates the v1 branch but not the v1.1 mirror).cmd/entire/cli/dispatch/mode_local.go:174— Switched fromNewGitStore(repo)(v1 branch, with origin fallback) toNewCommittedReadStore(ctx, repo)(v1.1 mirror in v1.1 mode, no origin fallback). On a fresh clone in v1.1 mode,entire dispatchfails withlist committed checkpoints: sessions ref refs/entire/checkpoints/v1.1 not foundrather than discovering checkpoints reachable via origin/v1.cmd/entire/cli/rewind.go:696—restoreSessionTranscriptFromStrategyno longer callsSyncCommittedReadRef. After any out-of-band v1 update (plaingit fetch entire/checkpoints/v1:entire/checkpoints/v1, CI-driven pulls), the v1.1 mirror lags v1.entire rewind <newCheckpointID>reads via the stale mirror and returns "checkpoint not found" or stale transcripts despite the metadata being present in v1.cmd/entire/cli/explain.go:2005—getBranchCheckpointslost itsSyncCommittedReadRefcall. In v1.1 mode, branch-scoped listings (defaultentire explain,entire explain --since, all branch-list consumers) silently omit any v1 updates fetched by tools other than entire's own write/fetch helpers.cmd/entire/cli/strategy/v1_custom_ref_mirror.go:31—MirrorCommittedMetadataRefreplacedSafelyAdvanceLocalRefwith rawStorer.SetReference. The new behavior is asserted intentional byTestMirrorCommittedMetadataRef_ReplacesLocallyAheadMirrorand the testTestMirrorCommittedMetadataRef_V1MissingErrors(replacing the prior no-op contractTestMirrorMetadataToV1CustomRef_V1MissingNoOp). The CLI callersrunAttach(attach.go:321) andgenerateCheckpointSummary(explain.go:927) now propagateplumbing.ErrReferenceNotFound-wrapped errors that the prior strategy-side helper would have logged as Debug. Both call sites are post-WriteCommitted, so primary-missing should be impossible — but if it ever surfaces (e.g. concurrent ref pruning, broken storer, ref blocked by stale lock), what used to be a Debug log now fails the whole user-facing command with"checkpoint was written to refs/heads/entire/checkpoints/v1, but failed to mirror to refs/entire/checkpoints/v1.1: ...". Lower confidence than the read-side findings, but the asymmetric divergence + history-rewind semantics (rawSetReferencevs ancestry-checked replay) are now baked into hot paths (condense, finalize turns, attribution, fetch, attach, summary).cmd/entire/cli/review_context.go:101—reviewCommittedCheckpointContextno longer callsSyncCommittedReadRef. In v1.1 mode after any out-of-band v1 update, the review context (used byentire reviewto surface prior reviews to a new review session) reads a stale v1.1 mirror and drops the very prior-review history that a new review session relies on to avoid re-reviewing the same code.
Common shape: the PR consolidates mirror writes onto entire-internal write and fetch paths, but the read side now strictly requires the v1.1 mirror to be current. Any external git operation that updates v1 without going through an entire-internal write/fetch (plain git fetch ... refs/heads/entire/checkpoints/v1:refs/heads/entire/checkpoints/v1, git pull with a configured v1 refspec, CI tooling, EnsureMetadataBranch itself) leaves the v1.1 mirror stale, and the new code has no read-time resync. Fresh-clone v1.1 scenarios are the most clearly broken: there is no documented sequence of git/entire commands that creates the v1.1 mirror without first making a write.
1mo ago·4.7s
Angle B complete. Awaiting C and E.
Compiled findings below.
ANGLE C cross-file trace — CANDIDATE findings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 31,\
"summary": "MirrorCommittedMetadataRef now force-sets the mirror to primary's hash (repo.Storer.SetReference). The pre-PR hook-side mirror used SafelyAdvanceLocalRef, which refused to rewind. All hook/condensation/finalize callers were switched to MirrorCommittedMetadataRefBestEffort, which delegates to this force-setting implementation, silently losing the no-rewind safeguard.",\
"failure_scenario": "If the v1 branch is ever rewound (external git surgery, a bug in SafelyAdvanceLocalRef on v1, or an admin amending the orphan branch), the next strategy write/fetch quietly drags the v1.1 mirror backwards too, instead of refusing as before. Reads against the mirror then return stale results that the old safeguard would have flagged. No test exists for the rewind-resistance behavior that was previously asserted indirectly."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/checkpoint/committed.go",\
"line": 1789,\
"summary": "getSessionsBranchTree only falls back to origin/entire/checkpoints/v1 when the read ref equals the v1 default. Under checkpoints_version=1.1, the read ref is the local-only v1.1 mirror, so no remote-tracking fallback applies — and the read-time SyncCommittedReadRef that previously seeded the mirror from origin/v1 on a fresh clone was removed in this PR.",\
"failure_scenario": "User runs `entire explain <id>` on a fresh clone with v1.1 enabled before any strategy operation has fetched checkpoints. NewCommittedReadStore binds to the v1.1 ref; getSessionsBranchTree errors out without falling back to origin/entire/checkpoints/v1. ListCommitted swallows the error and returns empty, so the explain flow does retry via matchCheckpointPrefixWithRemoteFallback → getMetadataTree → FetchMetadataBranch (which now seeds the mirror); but other v1.1 read entry points without that retry (e.g. headCheckpointFlags, dispatch.enumerateRepoCandidates, reviewCommittedCheckpointContext) silently return empty/no-checkpoint instead of the data sitting on origin/v1."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/head_checkpoint_flags.go",\
"line": 55,\
"summary": "headCheckpointFlags now uses NewCommittedReadStore (bound to the v1.1 mirror under opt-in) with no read-time mirror sync. The PR's documented behavior is 'reads use the ref as-is', but the v1 source of truth can advance without our code mirroring it — for example after a manual `git fetch origin entire/checkpoints/v1:entire/checkpoints/v1` (which is exactly the command suggestCheckpointFetchCommand prints).",\
"failure_scenario": "Colleague pushes a checkpoint with HasReview=true. User pulls via the documented `git fetch origin entire/checkpoints/v1:entire/checkpoints/v1`. This advances local v1 but never touches the v1.1 mirror. `entire status` then reads the stale v1.1 mirror via headCheckpointFlags and reports the HEAD checkpoint as having no review, hiding the review state from the user. Same hazard applies to dispatch/mode_local.go's enumerateRepoCandidates and review_context.go's reviewCommittedCheckpointContext."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 121,\
"summary": "FetchMetadataBranch re-opens the repo *after* PromoteTmpRefSafely to call MirrorCommittedMetadataRefBestEffort. If OpenRepository fails, the function returns nil (mirror skipped, only a warning) even though primary was just advanced. The previous git_operations.go-side FetchMetadataBranch hooks the same mirror call off an already-open repo handle, so it cannot hit this seam.",\
"failure_scenario": "Transient repo-open failure (lock contention from a concurrent git command, permission flap on .git, alternates resolution glitch) between the primary advance and the mirror update silently leaves the v1.1 mirror behind. Subsequent reads on this process or others using v1.1 read stale data until the next mirror-updating operation. Because the function still returns nil, the caller sees 'fetch succeeded' and does not retry."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/git_operations.go",\
"line": 432,\
"summary": "fetchMetadataFromOrigin returns an error when refs.Primary.IsBranch() is false. This is called by both FetchMetadataBranch and FetchMetadataTreeOnly. In every caller (resume.go:404,669, attach.go via getMetadataTree → refreshCheckpointRefs, git_operations.go:542 fallback, fetch_no_config_pollution_test.go), the new error path is treated as a generic fetch failure with no special diagnostic for the misconfigured topology.",\
"failure_scenario": "A future rollout flips ResolveCommittedRefs so Primary becomes a non-branch ref (e.g. refs/entire/checkpoints/v1.1). Every code path that calls FetchMetadataBranch / FetchMetadataTreeOnly will start returning 'primary metadata ref ... is not a branch'. Resume/attach silently fall through to next fallback, then to 'checkpoint not found locally' — operators get no signal that the topology change broke the fetch path. Worth flagging the error string with a guard for the future topology to keep the diagnostic actionable."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/push_common.go",\
"line": 384,\
"summary": "In fetchAndRebaseSessionsCommon, ReconcileDisconnectedMetadataBranch can advance the local v1 branch (cherry-pick reset on line 198/182 of metadata_reconcile.go). If the subsequent repo.Reference call (line 389) or getMergeBase (line 411) fails, the function returns an error and mirrorSyncedMetadataBranch is never called even though the local primary was advanced.",\
"failure_scenario": "Disconnected-metadata reconciliation cherry-picks local commits onto remote and advances local v1 to the new tip. Then the second repo.Reference / getMergeBase fails (extremely rare but possible under .git lock contention or transient go-git/cli IO errors). Function returns an error; the next push retries fetch+rebase, finds local already up-to-date, takes the fast-path mirror call. Mirror gap is self-healing on retry, but during the gap any v1.1 read sees data older than v1."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch gates on `branchName != refs.Primary.Short()`, but PrePush in manual_commit_push.go:35 hardcodes paths.MetadataBranchName as the push branch name rather than resolving from CommittedRefs. Today both equal entire/checkpoints/v1, so the gate matches. If a future topology change ever passes a different primary branch name through ResolveCommittedRefs while pushBranchIfNeeded continues to hardcode v1, the mirror call is silently skipped after every successful push.",\
"failure_scenario": "Future migration sets refs.Primary to refs/heads/entire/checkpoints/v2 (or similar) via committedRefsFor. pushBranchIfNeeded still pushes the hardcoded paths.MetadataBranchName ('entire/checkpoints/v1'), and the gate in mirrorSyncedMetadataBranch returns early because branchName ('v1') != refs.Primary.Short() ('v2'). Pushes succeed but the mirror is never advanced via the push path."\
},\
{\
"file": "/Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/cleanup.go",\
"line": 172,\
"summary": "Cleanup uses checkpoint.NewGitStore(repo).ListCommitted to decide which session state files are orphaned. The PR switched other production read sites (strategy.ListCheckpoints, headCheckpointFlags, dispatch enumerateRepoCandidates) to NewCommittedReadStore but left cleanup on the raw v1-only store. Under v1.1, the rest of the system reads v1.1; cleanup reads v1 — an inconsistency that wasn't present before (because the old SyncCommittedReadRef path kept v1.1 ≡ v1 most of the time).",\
"failure_scenario": "Today no bug: cleanup reads v1 (source of truth), so it sees more or equal sessions vs v1.1 readers, and won't wrongly delete a session-state whose checkpoint is recorded on v1. But the inconsistency is fragile: any future change that makes v1 a 'mirror' of a different primary (the comment in committed_refs.go contemplates 'a future rollout phase can flip the topology') would invert the assumption and make cleanup wrongly mark sessions orphaned. Worth aligning with the other read sites to keep the invariant in one place."\
}\
]
Key facts the caller may want:
- No remaining production callers of
checkpoint.SyncCommittedReadRef(removed cleanly). - All four advance-paths in
fetchAndRebaseSessionsCommoncallmirrorSyncedMetadataBranch; error returns correctly skip it. The one gap is post-ReconcileDisconnectedMetadataBranch(finding 6). MirrorCommittedMetadataRefBestEffort(vs the strict variant) is used at every hook/condensation/finalize site;MirrorCommittedMetadataRef(strict) is used atattach.go:321andexplain.go:927where mirror failure must propagate. The refs are taken fromopts.committedRefs(ctx)/ResolveCommittedRefs(ctx)at each site (not recomputed inconsistently).- Production
NewGitStorecallers that read committed metadata and were NOT switched:cmd/entire/cli/strategy/cleanup.go:172(finding 8) andcmd/entire/cli/checkpoint/committed.go:1349(LookupSessionLog— dead code, no callers).attach.go:430,explain.go:641,681,2109,rewind.go:744,manual_commit_hooks.go:1064,2773,2889,manual_commit.go:54are all writes or shadow-branch/temporary-checkpoint reads where v1 is the correct ref. - Working tree has uncommitted local changes in
cmd/entire/cli/strategy/metadata_reconcile.goandmetadata_reconcile_test.gothat addMirrorCommittedMetadataRefBestEffortcalls to the two reconciliation advance paths. They are not part of HEAD vs origin/main, but if intended for this PR they would close finding 6.
1mo ago·8.5s
Angle C complete. Note: Angle C mentions uncommitted changes in metadata_reconcile.go — but initial git status was clean. I'll verify after Angle E returns.
Now let me also check resume.go for cleanliness — is the v1.1 bypass behavior intentional?
The architecture per PR description:
- Read:
refs/entire/checkpoints/v1.1(when v1.1) or same as Primary (when v1) - Mirror:
refs/entire/checkpoints/v1.1when configured; empty otherwise — what writes mirror to - Reads RESOLVE against
Readref as-is — no fetch fallback.
So in v1.1 mode, the user IS expected to use entire explain or entire status to recover. The bypass at resume.go:606 is partially consistent with the architecture (v1.1 is local-only). However, the bypass uses checks like committedReadRef != v1 branch to detect "this is v1.1 mode" — that's fragile. If v1.1 was Primary in future, that comparison would silently take a wrong path.
Now let me return the findings as JSON:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[\
{\
"file": "cmd/entire/cli/strategy/cleanup.go",\
"line": 172,\
"summary": "ListOrphanedSessionStates uses NewGitStore (read default v1) instead of NewCommittedReadStore for a committed read",\
"failure_scenario": "In v1.1 mode the architectural rule is that committed reads consult the topology's Read ref. This call site bypasses NewCommittedReadStore and unconditionally reads from the v1 branch via NewGitStore.ListCommitted. With read-time sync removed, if a flow elsewhere mirrors but does not advance v1 (today none, but a future Primary=v1.1 rollout flip would invert ordering), cleanup would see a different checkpoint set than every other read site (resume, explain, dispatch, status). Practically today reads from v1 are usually equal to v1.1, but the inconsistency violates the PR's stated invariant 'every committed read uses NewCommittedReadStore' and makes a future topology change a silent-orphan-detection bug."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 384,\
"summary": "ReconcileDisconnectedMetadataBranch can advance local v1 before later steps fail, leaving the v1.1 mirror stale",\
"failure_scenario": "In fetchAndRebaseSessionsCommon, ReconcileDisconnectedMetadataBranch may cherry-pick local commits onto remote tip and SetReference the local v1 branch (metadata_reconcile.go:198) BEFORE any mirrorSyncedMetadataBranch call. If a subsequent step errors out — repo.Reference for localRef or fetchedRef, getRepoPath, getMergeBase, collectCommitsSince, loadShallowHashes, cherryPickOnto, or the final SetReference — the function returns with local v1 advanced from A→B but the v1.1 mirror still pointing at A. With read-time sync removed, subsequent v1.1 reads silently miss the reconciled checkpoints until the next successful write/fetch. The previous SyncCommittedReadRef at read time would have masked this; now it persists until something else mirrors."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 606,\
"summary": "checkRemoteMetadata short-circuits all remote-fetch fallback when committed read ref is not the v1 branch (i.e. v1.1 mode)",\
"failure_scenario": "When v1.1 is enabled and the local v1.1 ref is missing or behind, resume's checkRemoteMetadata immediately tells the user 'This ref is local-only. Try: entire explain' and never attempts to fetch checkpoint_remote, never calls promoteRemoteTrackingMetadataBranch, and never calls FetchMetadataBranch. The user must manually run another command. Worse, this check compares against a hardcoded v1 branch name; if topology flips so that Primary=v1.1, the comparison stops matching and the recovery path is permanently disabled. Read-time sync removal means resume no longer self-heals via the previous SyncCommittedReadRef gate."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 193,\
"summary": "promoteRemoteTrackingMetadataBranch gated on store.CommittedReadRef() equaling the v1 branch; in v1.1 mode the bootstrap never runs",\
"failure_scenario": "On a fresh clone or any state where local v1 is missing but refs/remotes/origin/entire/checkpoints/v1 exists, resume normally promotes the remote-tracking branch into local v1 via promoteRemoteTrackingMetadataBranch. In v1.1 mode store.CommittedReadRef() returns the local-only custom ref, so the equality check is false and promotion is skipped. Local v1 (the Primary) is never seeded from origin, so the v1.1 mirror is never created (it depends on v1 existing), so the read at line 218 falls into the bypass at line 606 and bails. A clean v1.1 clone cannot resume without the user first running a manual git fetch."\
},\
{\
"file": "cmd/entire/cli/strategy/manual_commit_condensation.go",\
"line": 71,\
"summary": "getCheckpointLog uses getCheckpointStore (v1 write store) for a committed read instead of getCommittedReadStore",\
"failure_scenario": "getCheckpointLog reads ReadCommittedCheckpoint and ReadLatestSessionContent through a store bound to the default v1 branch. Today it's reachable only from GetCheckpointLog, which has no production callers, but the helper is exported on the strategy and exists alongside an identical-shape read path that uses getCommittedReadStore. If a future caller wires GetCheckpointLog into a user-facing command (it's already in the Strategy package as a public method), it would silently read from a different ref than every other committed-read code path in v1.1 mode."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 43,\
"summary": "MirrorCommittedMetadataRefBestEffort re-resolves CommittedRefs from disk independently of caller, allowing topology drift across a single operation",\
"failure_scenario": "Several call sites do `refs := ResolveCommittedRefs(ctx); if refs.HasMirror() { MirrorCommittedMetadataRef(ctx, repo, refs) }` (good — single resolution), but mirrorSyncedMetadataBranch in push_common.go and other best-effort sites resolve refs once for a gate check and then call MirrorCommittedMetadataRefBestEffort which loads settings AGAIN. In fetchAndRebaseSessionsCommon (concurrent push + settings edit), if the user toggles checkpoints_version while a long fetch+rebase runs, the gate observed mirror-enabled while the best-effort call observes mirror-disabled (or vice versa). The local v1 ref ends up advanced; the v1.1 ref is left in an inconsistent state. Equivalent races exist around fetchMetadataFromOrigin and FetchMetadataBranch."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch silently no-ops when branchName != refs.Primary.Short(), tying mirroring to the literal v1 branch name",\
"failure_scenario": "mirrorSyncedMetadataBranch returns early unless the caller's branchName string matches refs.Primary.Short(). Callers always pass paths.MetadataBranchName ('entire/checkpoints/v1'). If the topology evolves (per PR description: 'A future rollout phase can flip the topology (v1.1 as Primary)'), refs.Primary.Short() becomes a non-branch ref name or a different short name, the gate stops matching, and mirroring silently skips. The error 'primary metadata ref is not a branch' would only fire deeper inside MirrorCommittedMetadataRef, never logged here because the gate short-circuits. There's no fallback or warning — the mirror just stops happening for every push+rebase path."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 178,\
"summary": "fetchMetadataBranchIfMissing returns early when refs.Primary exists locally without ever populating the v1.1 mirror",\
"failure_scenario": "fetchMetadataBranchIfMissing is called from resolvePushSettings on every push (when checkpoint_remote is configured). It checks 'if refs.Primary exists locally, return nil (skip fetch)'. If a user has v1 locally but recently enabled checkpoints_version=1.1 in settings (so v1.1 mirror is missing or stale), this fast path returns without calling FetchMetadataBranch — and so MirrorCommittedMetadataRefBestEffort never runs. Without read-time sync, the v1.1 mirror stays empty/stale until some other write happens. The mismatch survives even after subsequent pushes."\
}\
]
Returning my findings:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[\
{\
"file": "cmd/entire/cli/strategy/cleanup.go",\
"line": 172,\
"summary": "ListOrphanedSessionStates reads committed checkpoints via NewGitStore instead of NewCommittedReadStore",\
"failure_scenario": "In v1.1 mode every other read site (resume, explain, dispatch, status, head_checkpoint_flags) routes through NewCommittedReadStore, but cleanup unconditionally instantiates NewGitStore(repo) and calls ListCommitted, which resolves against the default v1 branch ref. Today v1 and v1.1 track each other (v1.1 is a mirror), so results coincide. But the PR's stated invariant is 'every committed read uses the ref-aware factory'. The drift becomes a real bug if (a) the topology flips so v1.1 is Primary in the future, or (b) a write path is added that targets v1.1 without v1 (unlikely today but the architecture allows it). Cleanup would then miss sessions that have checkpoints in v1.1 and wrongly classify them as orphaned, deleting the session state file."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 384,\
"summary": "ReconcileDisconnectedMetadataBranch advances local v1 before subsequent error paths, leaving the v1.1 mirror stale",\
"failure_scenario": "In fetchAndRebaseSessionsCommon, ReconcileDisconnectedMetadataBranch may cherry-pick local commits and SetReference the local v1 ref (metadata_reconcile.go:198) BEFORE any mirrorSyncedMetadataBranch call. If a later step errors out (repo.Reference, getRepoPath, getMergeBase, collectCommitsSince, loadShallowHashes, cherryPickOnto, or the final SetReference), the function returns with local v1 advanced from A to B but the v1.1 mirror still pointing at A. With read-time sync removed (the prior SyncCommittedReadRef was deleted in this PR), subsequent v1.1 reads silently miss the reconciled checkpoints until another successful write/fetch happens to mirror. The fix is to mirror immediately after reconciliation succeeds, before the subsequent fast-forward/rebase code can fail."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 606,\
"summary": "checkRemoteMetadata short-circuits all remote-fetch fallback when committed read ref is not the v1 branch",\
"failure_scenario": "When v1.1 is enabled and the local v1.1 ref is missing or behind, resume's checkRemoteMetadata hits the bypass at line 606 (committedReadRef != v1 branch), prints 'This ref is local-only. Try: entire explain', and skips ALL recovery: never tries checkpoint_remote fetch (line 632 unreachable), never calls promoteRemoteTrackingMetadataBranch (line 659 unreachable), never falls back to FetchMetadataBranch (line 669 unreachable). The user has to manually run a different command to populate the mirror. With read-time sync removed, this is a regression in v1.1 ergonomics: previously SyncCommittedReadRef would advance the mirror from origin's remote-tracking ref on demand."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 193,\
"summary": "promoteRemoteTrackingMetadataBranch is gated on store.CommittedReadRef() == v1 branch and is skipped in v1.1 mode",\
"failure_scenario": "On a fresh clone where local v1 is missing but refs/remotes/origin/entire/checkpoints/v1 exists from `git clone`, resume usually self-heals by promoting the remote-tracking branch into local v1. In v1.1 mode store.CommittedReadRef() returns the local-only custom ref, the equality check is false, and promotion is skipped. Then local v1 (Primary) is never seeded from origin, the v1.1 mirror is never created (it requires v1 to exist), and the read at line 218 returns ErrCheckpointNotFound. The flow falls through to checkRemoteMetadata which hits the bypass in finding #3. Net effect: a fresh v1.1 clone cannot resume without the user manually running `git fetch origin entire/checkpoints/v1:entire/checkpoints/v1`."\
},\
{\
"file": "cmd/entire/cli/strategy/manual_commit_condensation.go",\
"line": 71,\
"summary": "getCheckpointLog reads committed metadata via getCheckpointStore (v1 write store) instead of getCommittedReadStore",\
"failure_scenario": "getCheckpointLog calls ReadCommittedCheckpoint and ReadLatestSessionContent through a store bound to the default v1 branch. It is reachable from GetCheckpointLog (manual_commit_logs.go:104), which is unused in production today but is exported on the strategy. Anything that wires GetCheckpointLog through the Strategy interface gets v1-direct reads in v1.1 mode, inconsistent with every other committed read. Lower severity than the others because no production caller, but it is a live mismatched site that contradicts the diff's principle 'committed reads go through NewCommittedReadStore'."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 43,\
"summary": "MirrorCommittedMetadataRefBestEffort re-loads settings independently of the caller, allowing topology drift mid-operation",\
"failure_scenario": "Several callers resolve refs once for a gate check then invoke MirrorCommittedMetadataRefBestEffort which calls ResolveCommittedRefs(ctx) again and reads settings from disk. In a single fetchAndRebaseSessionsCommon run with a multi-minute push budget, settings.json could be edited concurrently (CI scripts, an `entire configure` invocation, or the auto-mode toggle) so the gate sees mirror-enabled and the best-effort call sees mirror-disabled (or vice versa). Local v1 ends up advanced; v1.1 ends up in an inconsistent state. The non-best-effort path in attach.go and explain.go passes pre-resolved refs through, but the best-effort path resolves twice. The fix is to accept refs as an explicit parameter for the best-effort variant too, or to cache the resolution per call site."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch silently no-ops when branchName does not match refs.Primary.Short()",\
"failure_scenario": "mirrorSyncedMetadataBranch returns early unless the caller-supplied branchName string matches refs.Primary.Short(). Callers pass paths.MetadataBranchName, so today the gate always matches. The PR description states 'A future rollout phase can flip the topology (v1.1 as Primary) by changing ResolveCommittedRefs.' On that day refs.Primary.Short() becomes a non-branch ref short name (or different), the gate silently stops matching, and the mirror never advances for any push+rebase. There is no log, warning, or fallback — push+rebase keeps succeeding and reads start lagging silently. Comparing against refs.Mirror or just unconditionally calling MirrorCommittedMetadataRefBestEffort (which has its own no-op guards) would be safer."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 178,\
"summary": "fetchMetadataBranchIfMissing fast-paths out when refs.Primary exists locally and never seeds the v1.1 mirror",\
"failure_scenario": "fetchMetadataBranchIfMissing runs from resolvePushSettings on every push that has a configured checkpoint_remote. It returns early when refs.Primary exists locally, skipping FetchMetadataBranch and therefore MirrorCommittedMetadataRefBestEffort. A user who has v1 locally and then opts into checkpoints_version=1.1 in settings has no v1.1 mirror until some other write triggers one. With read-time sync removed there is no recovery — subsequent pushes that take the fast path never bootstrap the mirror. The fix is to call MirrorCommittedMetadataRefBestEffort when the fast-path returns, or to compare both primary and mirror existence."\
}\
]
This is my final candidate set. Returning to the caller.
Findings as JSON (8 candidates from ANGLE E — wrapper/proxy correctness + ref-topology consistency):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[\
{\
"file": "cmd/entire/cli/strategy/cleanup.go",\
"line": 172,\
"summary": "ListOrphanedSessionStates reads committed checkpoints via NewGitStore instead of NewCommittedReadStore",\
"failure_scenario": "In v1.1 mode every other committed-read site (resume, explain, dispatch, status, head_checkpoint_flags) routes through NewCommittedReadStore, but cleanup.go:172 unconditionally instantiates NewGitStore(repo) and calls ListCommitted, which resolves against the default v1 branch ref. Today v1 and v1.1 track each other so results coincide. But the PR's stated invariant is 'every committed read uses the ref-aware factory'. The drift becomes a real bug if the topology flips so v1.1 is Primary in the future, or a write path lands on v1.1 without v1. Cleanup would then miss sessions that have checkpoints in v1.1 and wrongly classify them as orphaned, deleting the session state file."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 384,\
"summary": "ReconcileDisconnectedMetadataBranch advances local v1 before subsequent error paths, leaving the v1.1 mirror stale",\
"failure_scenario": "ReconcileDisconnectedMetadataBranch may cherry-pick local commits and SetReference the local v1 ref (metadata_reconcile.go:198) BEFORE any mirrorSyncedMetadataBranch call. If a later step errors out (repo.Reference for localRef/fetchedRef, getRepoPath, getMergeBase, collectCommitsSince, loadShallowHashes, cherryPickOnto, or the final SetReference), the function returns with local v1 advanced from A to B but the v1.1 mirror still pointing at A. With read-time sync removed in this PR, subsequent v1.1 reads silently miss the reconciled checkpoints until another successful write/fetch happens to mirror. The fix is to mirror immediately after reconciliation succeeds, before the fast-forward/rebase code can fail."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 606,\
"summary": "checkRemoteMetadata short-circuits all remote-fetch fallback when committed read ref is not the v1 branch",\
"failure_scenario": "When v1.1 is enabled and the local v1.1 ref is missing or behind, checkRemoteMetadata hits the bypass at line 606 (committedReadRef != v1 branch), prints 'This ref is local-only. Try: entire explain', and skips ALL recovery: checkpoint_remote fetch (line 632), promoteRemoteTrackingMetadataBranch (659), and FetchMetadataBranch (669) are unreachable. The user must manually run another command to populate the mirror. With read-time sync removed, this is a regression in v1.1 ergonomics — previously SyncCommittedReadRef would advance the mirror from origin's remote-tracking ref on demand."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 193,\
"summary": "promoteRemoteTrackingMetadataBranch is gated on CommittedReadRef() equaling v1 branch and is skipped in v1.1 mode",\
"failure_scenario": "On a fresh clone where local v1 is missing but refs/remotes/origin/entire/checkpoints/v1 exists from `git clone`, resume normally self-heals by promoting the remote-tracking branch into local v1. In v1.1 mode store.CommittedReadRef() returns the local-only custom ref, the equality check is false, and promotion is skipped. Local v1 (Primary) is never seeded from origin, the v1.1 mirror is never created (it depends on v1), and the read at line 218 returns ErrCheckpointNotFound and then falls through to the checkRemoteMetadata bypass. Net effect: a fresh v1.1 clone cannot resume without the user manually running `git fetch origin entire/checkpoints/v1:entire/checkpoints/v1`."\
},\
{\
"file": "cmd/entire/cli/strategy/manual_commit_condensation.go",\
"line": 71,\
"summary": "getCheckpointLog reads committed metadata via getCheckpointStore (v1 write store) instead of getCommittedReadStore",\
"failure_scenario": "getCheckpointLog calls ReadCommittedCheckpoint and ReadLatestSessionContent through a store bound to the default v1 branch. It is reachable from GetCheckpointLog (manual_commit_logs.go:104), which is unused in production today but is exported on the strategy. Anything that wires GetCheckpointLog through the Strategy interface would get v1-direct reads in v1.1 mode, inconsistent with every other committed read. Lower severity than the rest because no production caller, but it is a live mismatched site that contradicts the diff's principle."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 43,\
"summary": "MirrorCommittedMetadataRefBestEffort re-loads settings independently of caller, allowing topology drift mid-operation",\
"failure_scenario": "Several callers resolve refs once for a gate check then invoke MirrorCommittedMetadataRefBestEffort, which calls ResolveCommittedRefs(ctx) again and reads settings from disk. In a single fetchAndRebaseSessionsCommon run with a multi-minute push budget, settings.json could be edited concurrently (CI script, `entire configure`, auto-mode toggle) so the gate sees mirror-enabled and the best-effort call sees mirror-disabled (or vice versa). Local v1 ends up advanced; v1.1 ends up inconsistent. attach.go and explain.go pass pre-resolved refs through MirrorCommittedMetadataRef (non-best-effort), but push_common.go's mirrorSyncedMetadataBranch resolves twice and so does git_operations.go:475 (fetchMetadataFromOrigin)."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch silently no-ops when branchName != refs.Primary.Short(), tying mirroring to the literal v1 branch name",\
"failure_scenario": "mirrorSyncedMetadataBranch returns early unless the caller-supplied branchName matches refs.Primary.Short(). Callers pass paths.MetadataBranchName, so today the gate always matches. The PR description states 'A future rollout phase can flip the topology (v1.1 as Primary) by changing ResolveCommittedRefs.' On that day refs.Primary.Short() changes, the gate silently stops matching, and the mirror never advances for any push+rebase. No log, warning, or fallback — push+rebase keeps succeeding and reads start lagging silently. Comparing against refs.Mirror or unconditionally calling MirrorCommittedMetadataRefBestEffort (which has its own no-op guards) would be safer."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 178,\
"summary": "fetchMetadataBranchIfMissing fast-paths out when refs.Primary exists locally and never seeds the v1.1 mirror",\
"failure_scenario": "fetchMetadataBranchIfMissing runs from resolvePushSettings on every push with a configured checkpoint_remote. It returns early when refs.Primary exists locally, skipping FetchMetadataBranch and therefore MirrorCommittedMetadataRefBestEffort. A user who has v1 locally and then opts into checkpoints_version=1.1 in settings has no v1.1 mirror until some other write triggers one. With read-time sync removed there is no recovery — subsequent pushes that take this fast path never bootstrap the mirror. The fix is to call MirrorCommittedMetadataRefBestEffort when the fast-path returns, or to compare both primary and mirror existence."\
}\
]
Key absolute paths inspected:
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/checkpoint/store.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/checkpoint/committed_refs.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/v1_custom_ref_mirror.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/push_common.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/checkpoint_remote.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/cleanup.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/manual_commit_condensation.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/manual_commit_hooks.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/strategy/metadata_reconcile.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/resume.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/attach.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/explain.go
- /Users/pfleidi/entire/cli/.worktrees/fix/checkpoints-v1.1-advance-after-sync/cmd/entire/cli/git_operations.go
All production NewGitStore call sites in committed-write or committed-read paths verified. Writes consistently pair with a mirror call. The findings are concentrated in the fetch+reconcile rebase path and in the v1.1-mode resume bootstrap, where the removal of read-time sync exposes pre-existing topology-coupling assumptions in resume.go.
1mo ago·19m·26 calls
Here are the verified findings, ranked most-severe first.
Workspace note: the worktree is currently in a merge state from a concurrent git merge origin/main you ran during the review (commit 5c0219a7af mirror reconciled metadata refs was added — it closes the gap in ReconcileDisconnectedMetadataBranch). cmd/entire/cli/dispatch/mode_local.go shows UU (merge conflict). Findings below reflect HEAD (a56d43642d) including that commit; review scope is git diff origin/main...HEAD.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
[\
{\
"file": "cmd/entire/cli/strategy/common.go",\
"line": 456,\
"summary": "EnsureMetadataBranch (called by `entire enable`/EnsureSetup) creates or advances local entire/checkpoints/v1 from origin's remote-tracking ref but never mirrors to refs/entire/checkpoints/v1.1; combined with the removal of read-time sync, every NewCommittedReadStore consumer silently returns empty/false in v1.1 mode on a fresh clone.",\
"failure_scenario": "Fresh clone of a repo that uses checkpoints_version=1.1. refs/remotes/origin/entire/checkpoints/v1 is present after clone; refs/entire/checkpoints/v1.1 is not. User runs `entire enable` (creates local v1 from origin — no mirror), then `entire list` returns empty (ListCommitted silently turns missing-ref into []), `entire status` reports no review/investigate flags (headCheckpointFlags wraps the error to false), `entire dispatch` returns no candidates, `entire review` drops prior-review context. `entire explain <id>` self-heals via matchCheckpointPrefixWithRemoteFallback → getMetadataTree → FetchMetadataBranch; no other read entry point does."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 193,\
"summary": "resume's promoteRemoteTrackingMetadataBranch is gated on `store.CommittedReadRef() == v1 branch`, so in v1.1 mode the local v1 is never auto-promoted from origin and the mirror is never bootstrapped from origin's tracking ref.",\
"failure_scenario": "Fresh clone, v1.1 mode, user runs `entire resume <id>`. Line 193 gate is false, promotion skipped; line 218 store.Read returns ErrCheckpointNotFound; line 230 falls into checkRemoteMetadata. checkRemoteMetadata at line 606 (committedReadRef != v1 branch) bypasses ALL recovery (checkpoint_remote fetch, promoteRemoteTrackingMetadataBranch, FetchMetadataBranch) and prints only 'This ref is local-only. Try: entire explain <id>'. User must run `entire explain` to populate the mirror, then re-run `entire resume`. Two-step manual workaround for what was a one-command flow under v1."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 700,\
"summary": "The documented recovery hint `git fetch origin entire/checkpoints/v1:entire/checkpoints/v1` (printed by checkRemoteMetadata) advances local v1 but does not touch refs/entire/checkpoints/v1.1; with read-time sync gone, the user's reads still see stale data after following the hint.",\
"failure_scenario": "v1.1 mode. User hits the v1-branch fallback path in checkRemoteMetadata, sees 'git fetch origin entire/checkpoints/v1:entire/checkpoints/v1' and runs it. Local v1 advances; v1.1 mirror stays at the old hash. Subsequent `entire status` / `entire rewind <new-id>` / `entire list` / `entire review` see stale data. The hint is in the canonical error message yet leaves the user in a broken state."\
},\
{\
"file": "cmd/entire/cli/strategy/cleanup.go",\
"line": 333,\
"summary": "DeleteOrphanedCheckpoints commits a tombstone to entire/checkpoints/v1 and SetReferences the local ref forward without calling MirrorCommittedMetadataRefBestEffort.",\
"failure_scenario": "v1.1 mode, user runs `entire clean`. v1 advances to the cleanup commit; v1.1 mirror still points at the pre-cleanup tip. `entire list` / `entire status` / `entire explain` keep showing the removed checkpoints until some other v1 write or fetch happens to mirror."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 178,\
"summary": "fetchMetadataBranchIfMissing returns early as soon as refs.Primary exists locally, skipping FetchMetadataBranch and therefore the new MirrorCommittedMetadataRefBestEffort call — first v1.1 opt-in on an existing repo never seeds the mirror via the push path.",\
"failure_scenario": "User has v1 branch already populated, flips checkpoints_version to '1.1' in settings, then pushes. fetchMetadataBranchIfMissing's existence check passes; no fetch; no mirror. Until a condense/finalize/attribution hook writes v1 (which then mirrors), every v1.1 read returns empty. Reads after opt-in but before the first write all silently fail."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 122,\
"summary": "FetchMetadataBranch returns nil after PromoteTmpRefSafely succeeded if the subsequent OpenRepository fails; mirror is skipped but caller sees success.",\
"failure_scenario": "Fetch and PromoteTmpRefSafely succeed (primary advanced on disk). OpenRepository then fails (lock contention from a concurrent git process, transient permission flap, stale alternates). Function logs a Warn and returns nil; callers (resume.checkRemoteMetadata, explain rescue paths) treat 'fetch succeeded' as a clean state and the v1.1 mirror is silently behind primary. Next v1.1 read misses data that's already on disk in v1."\
},\
{\
"file": "cmd/entire/cli/git_operations.go",\
"line": 475,\
"summary": "MirrorCommittedMetadataRefBestEffort runs under the same 2-minute WithTimeout context as the fetch, and ResolveCommittedRefs→settings.Load can silently fall back to a v1-only topology when ctx is near or past its deadline.",\
"failure_scenario": "fetchMetadataFromOrigin takes ~1m58s for a large fetch. Mirror call inherits the soon-to-expire ctx. settings.Load's WorktreeRoot path runs `git rev-parse --git-common-dir` via exec.CommandContext; on deadline expiry it returns an error, MirrorsToV1CustomRef swallows it as 'not enabled', HasMirror=false, mirror is silently skipped. v1 advances on disk; v1.1 stays stale until another fetch happens to complete inside its own budget."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 49,\
"summary": "MirrorCommittedMetadataRefBestEffort matches errors.Is(err, plumbing.ErrReferenceNotFound) against the chained error returned by MirrorCommittedMetadataRef, which wraps both 'primary missing' AND 'set mirror ref %s to %s' with %w; a SetReference NotFound failure is misclassified as 'primary missing' and logged at Debug instead of Warn.",\
"failure_scenario": "If repo.Storer.SetReference returns plumbing.ErrReferenceNotFound (e.g., refs/entire occupied as a file blocking refs/entire/checkpoints/v1.1, a backing-storage glitch, or a transient packed-refs race), the wrapped error chain still matches ErrReferenceNotFound. BestEffort logs 'committed-ref mirror skipped: primary metadata ref unavailable' at Debug and returns. A genuine mirror write failure is silently demoted to a Debug log and operators get no signal."\
},\
{\
"file": "CLAUDE.md",\
"line": 430,\
"summary": "New documentation says the v1.1 mirror is updated 'after active v1 write/fetch paths', and docs/architecture/sessions-and-checkpoints.md repeats it; EnsureMetadataBranch (the v1 write/setup path used by `entire enable`) does not mirror, so the docs overstate coverage.",\
"failure_scenario": "Reader of the new architecture docs (or a future agent following them as ground truth) assumes the mirror tracks every v1 write. Then `entire enable` on a fresh v1.1 clone leaves the mirror unset, leading to the symptoms in finding #1 — but the documentation implies that's impossible."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch silently no-ops when branchName != refs.Primary.Short() with no log or warning, and the comparison is short-circuited entirely when refs.Primary is not a branch.",\
"failure_scenario": "Today refs.Primary is the v1 branch and callers always pass paths.MetadataBranchName, so the gate matches. The PR explicitly contemplates 'a future rollout phase can flip the topology (v1.1 as Primary)'. On that day refs.Primary.Short() changes (or stops being a branch), the gate silently stops matching, and every push+rebase succeeds while never mirroring. The Primary check failure mode in MirrorCommittedMetadataRef never fires because the gate short-circuits earlier."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 43,\
"summary": "MirrorCommittedMetadataRefBestEffort re-loads settings via ResolveCommittedRefs(ctx) independently of the caller, so gate-vs-mirror calls can observe different topologies under a concurrent settings edit.",\
"failure_scenario": "Long-running fetchAndRebaseSessionsCommon enters mirrorSyncedMetadataBranch with mirror-enabled topology. User (or a CI script, or another `entire configure` invocation) flips checkpoints_version mid-run. MirrorCommittedMetadataRefBestEffort's second ResolveCommittedRefs sees the new topology; either the mirror runs against an unintended ref or is silently skipped. The non-best-effort variant in attach.go / explain.go accepts pre-resolved refs and avoids this; the BestEffort path doesn't."\
},\
{\
"file": "cmd/entire/cli/strategy/cleanup.go",\
"line": 172,\
"summary": "ListOrphanedSessionStates uses NewGitStore(repo).ListCommitted (default v1 ref) for a committed read while every other production read site now uses NewCommittedReadStore; the PR's stated invariant 'every committed read uses the ref-aware factory' is broken here.",\
"failure_scenario": "Today v1 == v1.1 in normal operation so cleanup sees the same checkpoints. If the topology ever flips so v1.1 is the Primary, cleanup would read the (now-mirror) v1 ref while every other read site uses v1.1 — cleanup would wrongly mark sessions whose checkpoints live only on v1.1 as orphaned and delete their state files. Forward-compat hazard pre-baked into a destructive command."\
},\
{\
"file": "cmd/entire/cli/strategy/manual_commit_condensation.go",\
"line": 71,\
"summary": "getCheckpointLog reads ReadCommittedCheckpoint and ReadLatestSessionContent via getCheckpointStore (default-v1 write store) instead of getCommittedReadStore — inconsistent with the PR's read-store invariant.",\
"failure_scenario": "Reachable via GetCheckpointLog (manual_commit_logs.go), which is exported on the Strategy interface and has no production callers today. Any future wiring of GetCheckpointLog into a user-facing command would silently read from v1 in v1.1 mode while every other reader uses v1.1. Same forward-compat shape as cleanup.go:172."\
}\
]
Summary
13 findings ranked by severity. The dominant cluster is v1.1 read-side staleness on fresh clones, post-opt-in, and after external git fetch — caused by removing read-time sync without seeding the v1.1 mirror from the bootstrap paths (EnsureMetadataBranch, fetchMetadataBranchIfMissing, DeleteOrphanedCheckpoints, promoteRemoteTrackingMetadataBranch). The single user-facing recovery hint (git fetch entire/checkpoints/v1:entire/checkpoints/v1) is itself broken for v1.1 mode. Findings 7–13 are narrower (ctx expiry, error misclassification, future topology hazards, doc/test gaps).
Workspace note again: please resolve the cmd/entire/cli/dispatch/mode_local.go merge conflict left by the in-progress git merge origin/main.
Can you re-check which findings are still applicable since some files were changed in the middle?
Otherwise, what you call read-staleness is the intention behind this change: This PR introduces v1.1 progression after pulling v1 from the remote and the removal of sync calls are intended to make missed code paths visible rather than hiding them behind a bunch of sync calls.
Are there any other findings that remain when taking the goals of this change into account?
1mo ago·3m·8 calls
Re-verified against current HEAD (a56d43642d). The branch state didn't shift much since my last check — the new merge from origin/main was resolved but no new functional changes landed. Findings still verify against the current source.
Filtering through your stated intent — "mirror advances after entire-managed v1 writes/fetches; missing paths should be visible, not hidden" — the read-staleness findings (#3, #5, #11–13) drop out as accepted. What remains are entire-managed v1 writes that don't mirror plus silent failures inside the mirror code itself — both of which run directly against the stated goal.
Findings that remain under the PR intent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[\
{\
"file": "cmd/entire/cli/strategy/common.go",\
"line": 456,\
"summary": "EnsureMetadataBranch (called from EnsureSetup / `entire enable`) creates or advances the local entire/checkpoints/v1 ref from origin's remote-tracking branch and never mirrors — an entire-managed v1 write path missing the mirror call.",\
"failure_scenario": "Fresh v1.1 clone, `entire enable`. EnsureMetadataBranch hits the 'local branch doesn't exist — create from remote' path (line ~500), SetReferences the local v1, prints '✓ Created local branch entire/checkpoints/v1 from origin', and returns. No mirror. Until a write hook runs, every NewCommittedReadStore consumer (list/status/dispatch/rewind/review) returns empty. Under your intent this is exactly a 'missed code path' that should mirror, not stay silent."\
},\
{\
"file": "cmd/entire/cli/resume.go",\
"line": 714,\
"summary": "promoteRemoteTrackingMetadataBranch SafelyAdvanceLocalRefs the local v1 ref from origin's remote-tracking branch and never mirrors. Compounded by the caller gate at resume.go:193 that skips promotion entirely when the read ref is not v1 — so in v1.1 mode resume never even attempts to promote v1 from origin.",\
"failure_scenario": "Two coupled gaps: (a) promoteRemoteTrackingMetadataBranch advances v1 and never calls MirrorCommittedMetadataRefBestEffort; (b) the caller at line 193 only invokes it when `store.CommittedReadRef() == v1 branch`, i.e., not in v1.1 mode. Net: in v1.1 mode, resume neither advances v1 from origin nor mirrors. If the gate is removed (or the v1-mode call path runs), the promotion still leaves the mirror behind."\
},\
{\
"file": "cmd/entire/cli/strategy/cleanup.go",\
"line": 333,\
"summary": "DeleteOrphanedCheckpoints commits a cleanup tree to entire/checkpoints/v1, SetReferences the local v1 ref forward, and returns without mirroring.",\
"failure_scenario": "`entire clean` in v1.1 mode advances v1; the mirror stays at the pre-cleanup tip. All v1.1 readers continue surfacing the just-deleted checkpoints until another v1 write triggers the mirror. Same shape as findings #1 and #2: an entire-managed v1 write that fails to call MirrorCommittedMetadataRefBestEffort."\
},\
{\
"file": "cmd/entire/cli/strategy/checkpoint_remote.go",\
"line": 122,\
"summary": "FetchMetadataBranch returns nil success when OpenRepository fails after PromoteTmpRefSafely advanced primary; only a Warn is logged. The mirror is skipped, but the caller sees a clean fetch.",\
"failure_scenario": "Primary advanced on disk; OpenRepository then fails (lock contention from a parallel git process, permission flap, alternates glitch). The function logs a Warn and returns nil. Caller treats the fetch as successful, but the mirror is not updated. Under your intent this should surface as an error (or at minimum the caller should be able to tell the mirror was skipped) rather than silently swallow."\
},\
{\
"file": "cmd/entire/cli/strategy/v1_custom_ref_mirror.go",\
"line": 50,\
"summary": "MirrorCommittedMetadataRefBestEffort uses errors.Is(err, plumbing.ErrReferenceNotFound) to detect 'primary missing', but MirrorCommittedMetadataRef wraps both the primary-read error AND the SetReference error with %w. A SetReference NotFound is misclassified as 'primary missing' and logged at Debug instead of Warn.",\
"failure_scenario": "repo.Storer.SetReference returns ErrReferenceNotFound (refs/entire occupied as a file, transient packed-refs race, backing-storage bug). MirrorCommittedMetadataRef wraps it as `set mirror ref %s to %s: %w`. The BestEffort wrapper's errors.Is matches the wrapped chain, prints 'committed-ref mirror skipped: primary metadata ref unavailable' at Debug, and returns. A real mirror write failure is silently demoted from Warn to Debug — the exact opposite of 'make missed paths visible'."\
},\
{\
"file": "cmd/entire/cli/git_operations.go",\
"line": 475,\
"summary": "MirrorCommittedMetadataRefBestEffort runs under the 2-minute WithTimeout context of the surrounding fetch; near the deadline ResolveCommittedRefs→settings.Load (which invokes `git rev-parse --git-common-dir` via exec.CommandContext through paths.WorktreeRoot) can fail, MirrorsToV1CustomRef swallows that as 'not enabled', and the mirror is skipped silently after a successful v1 advance.",\
"failure_scenario": "Slow network fetch consumes most of the 2-minute budget. The post-fetch mirror call inherits the soon-to-expire ctx. settings.Load's WorktreeRoot resolution fails on context deadline, MirrorsToV1CustomRef returns false, HasMirror is false, no mirror, no log. Under your intent the missed mirror should be loud (Warn or error), not invisible — separating mirror ctx from the fetch budget would fix it."\
},\
{\
"file": "cmd/entire/cli/strategy/push_common.go",\
"line": 478,\
"summary": "mirrorSyncedMetadataBranch silently no-ops when branchName != refs.Primary.Short() (or refs.Primary is not a branch) with no log or warning.",\
"failure_scenario": "Today refs.Primary is the v1 branch and callers pass paths.MetadataBranchName, so the gate always matches. Any future divergence (topology flip, or a caller passing a non-v1 branch name to fetchAndRebaseSessionsCommon) will silently stop mirroring on every push, with nothing in the logs to surface it. Same anti-intent shape as the other silent skips."\
},\
{\
"file": "CLAUDE.md",\
"line": 430,\
"summary": "New CLAUDE.md bullet and docs/architecture/sessions-and-checkpoints.md both state that the v1.1 mirror is advanced 'after active v1 write/fetch paths', overstating coverage given findings #1–#3 (EnsureMetadataBranch, promoteRemoteTrackingMetadataBranch, DeleteOrphanedCheckpoints don't mirror).",\
"failure_scenario": "Reader of the docs (or a future agent treating them as ground truth) infers the mirror tracks every entire-managed v1 write. The actual implementation has at least three v1 writers that don't, plus two silent-skip paths. The doc invariant is what the PR intends to converge on — but at the current HEAD it's aspirational rather than descriptive."\
}\
]
Dropped from earlier list under your intent
- Stale v1.1 reads after
git fetch entire/checkpoints/v1:entire/checkpoints/v1(was #3): external git op; missing-path exposure is intended. fetchMetadataBranchIfMissingfast-paths out without mirror (was #5): no fetch happens by design; mirror gap closes when the user-initiated v1 write fires through a hook. Mostly subsumed by #1 ifentire enablemirrors.- BestEffort re-resolves CommittedRefs (was #11): perf/concurrency only, doesn't fight the intent.
cleanup.go:172usesNewGitStorefor committed read (was #12) andgetCheckpointLoguses write store (was #13): forward-compat hazards on a topology flip, no current user impact.- Force-set rewrites mirror without rewind check: tests assert this is intentional.
Suggested ordering for fixes
- Cluster #1, #2, #3 (entire-managed v1 writes that don't mirror) — directly close the missed paths.
- #5 (misclassification) and #4 (silent nil return) — small mirror-code hygiene; align logging with intent.
- #6 (ctx propagation) and #7 (silent branch-name skip) — defense in depth against silent skips.
- #8 (docs) — keep CLAUDE.md/sessions-and-checkpoints.md in sync once the above land.
Fix them one by one and stop in between to allow me to review
1mo ago·7m·19 calls
Test passes (all 5 EnsureMetadataBranch subtests, including the new one). The pre-existing lint diagnostics flagged are in unrelated functions (lines 247/1126/1522/1534, not the lines I touched).
Fix 1 of 8 — EnsureMetadataBranch now mirrors after v1 writes
Files changed
cmd/entire/cli/strategy/common.go— addedMirrorCommittedMetadataRefBestEffort(context.Background(), repo)after each of the three SetReference paths that advance the local v1 branch:empty-orphan → remote tip (~line 478)
- local-missing → create-from-remote (~line 504)
- no-remote → create empty orphan (~line 563)
cmd/entire/cli/strategy/common_test.go— addedTestEnsureMetadataBranch_MirrorsV11WhenSeedingFromRemote(not parallel, usest.Chdirsosettings.Loadpicks up the v1.1 opt-in).
Decisions
- Used
context.Background()rather than threading a newctxparameter. Rationale: the function already usescontext.Background()internally (existing Debug call),EnsureMetadataBranchis part ofentire enablesetup where caller cancellation isn't load-bearing, and changing the signature would touch ~9 test sites + the one production caller for no behavioral gain. - Mirror call placed after SetReference but before the stdout/stderr print so a mirror failure can't desync without at least a Warn log preceding the "Created/Updated" message.
- Mirror call added on the orphan-creation path too, even though the orphan tree is empty — keeps the invariant clean ("any v1 write mirrors") rather than having a quiet exception.
Verification: go test -run TestEnsureMetadataBranch -count=1 ./cmd/entire/cli/strategy/ → ok. Failing test reproduced first, then passes after the fix.
Ready for review. Reply when you'd like me to move on to finding #2 (promoteRemoteTrackingMetadataBranch + the v1-only gate in resume.go).
Any idea why we're using context.Background() in this context?
1mo ago·20.5s
Honest answer: no good principled reason. I picked it to avoid widening the signature change, and rationalized it by pointing at the existing context.Background() Debug log at line 472 — but that line is itself a pre-existing wart, not a pattern to follow. Justifying a new wart by an old one is weak.
Threading ctx properly is the right call:
EnsureSetup(the one production caller, common.go:79) already hasctx— trivial to pass through.MirrorCommittedMetadataRefBestEffort→ResolveCommittedRefs→settings.Loadis where the ctx actually does work (cancellation, deadlines, future trace correlation). Background severs all of that.- Test sites that need updating: ~9 callers across
common_test.goandmetadata_reconcile_test.go, each getscontext.Background()ort.Context(). Mechanical.
Want me to redo it with a ctx context.Context parameter on EnsureMetadataBranch? I'd also clean up the existing context.Background() Debug log on the same pass so the wart goes away rather than getting duplicated.
How many changes would it be to thread through the correct context object?
1mo ago·24.1s·2 calls
Counting:
Strictly required (16 edits):
- 1 signature change at
common.go:456 - 1 production caller at
common.go:79(EnsureSetupalready hasctx) - 14 test call sites:
resume_test.go(2),metadata_reconcile_test.go(4),common_test.go(8 — includes the one I just added)
Each test site is the same mechanical edit: EnsureMetadataBranch(repo) → EnsureMetadataBranch(ctx, repo) or EnsureMetadataBranch(t.Context(), repo).
Optional cleanup in the same pass (2 more edits):
common.go:487— pre-existingcontext.Background()in a Debug logcommon.go:548— pre-existingcontext.Background()passed tocheckpoint.SignCommitBestEffort
Both are inside EnsureMetadataBranch; with ctx available, swap them too so the wart is fully gone rather than half-fixed.
Total: ~16 mechanical edits, or 18 with the cleanup. No call-site logic changes — every test already has either a context.Background() or t.Context() they can hand over.
Want me to proceed with threading ctx (including the pre-existing cleanup)?
Okay, do it
1mo ago·2m·18 calls
All green. Summary of the ctx-threading pass:
Fix 1 (revised) — EnsureMetadataBranch now takes ctx
Files changed (4)
cmd/entire/cli/strategy/common.go- Signature:
EnsureMetadataBranch(ctx context.Context, repo *git.Repository) error - Caller in
EnsureSetup(line 79) now passesctx - Inside the function, 5
context.Background()uses replaced with the passedctx:
- Signature:
3 new
MirrorCommittedMetadataRefBestEffortcalls- 1 pre-existing
logging.Debug(cleanup of the wart I'd cited earlier) - 1 pre-existing
checkpoint.SignCommitBestEffort(same cleanup)
- 1 pre-existing
cmd/entire/cli/strategy/common_test.go— 8 callers →t.Context()cmd/entire/cli/strategy/metadata_reconcile_test.go— 4 callers →t.Context()cmd/entire/cli/resume_test.go— 2 callers →t.Context()
Verification
go build ./...— cleango test -run TestEnsureMetadataBranch ./cmd/entire/cli/strategy/— okgo test -run TestReconcile ./cmd/entire/cli/strategy/— okgo test -run TestResume ./cmd/entire/cli/— ok
Lint diagnostics emitted by the harness are all pre-existing and in unrelated files (explain_test.go, search_tui.go, activity_render.go, plus earlier ones at common.go:247/1126/1522/1534) — none in the lines I touched.
Ready for review. Reply when you'd like me to proceed to finding #2 (promoteRemoteTrackingMetadataBranch doesn't mirror + the v1-only gate at resume.go:193).
Commit and continue
1mo ago·12m·24 calls
All resume tests pass.
Fix 2 of 8 — promoteRemoteTrackingMetadataBranch mirrors + v1-only gate removed
Files changed (2)
cmd/entire/cli/resume.gopromoteRemoteTrackingMetadataBranch(line ~714): after a successfulSafelyAdvanceLocalRef, callsstrategy.MirrorCommittedMetadataRefBestEffort(ctx, repo). Also added an earlyreturnon theSafelyAdvanceLocalReferror so we don't mirror a ref that didn't advance.resumeFromCurrentBranch(line 193): removed theif store.CommittedReadRef() == v1 branch { promote }gate; promote always fires now. Added a one-line comment explaining why (v1 is source of truth, promote mirrors when v1.1 is configured).
cmd/entire/cli/resume_test.go- New test
TestPromoteRemoteTrackingMetadataBranch_MirrorsV11(not parallel,t.Chdir): seedsrefs/remotes/origin/entire/checkpoints/v1, deletes local v1 and the mirror, calls promote, asserts bothrefs/heads/entire/checkpoints/v1andrefs/entire/checkpoints/v1.1end up at the origin hash. - Added
assert+requireimports.
- New test
Decisions
- The existing
TestResumeFromCurrentBranch_V11DoesNotSeedFromV1still passes unchanged. Its scenario sets up local v1 with metadata but noorigin/entire/checkpoints/v1remote-tracking ref, so the now-always-invoked promote no-ops and the test's assertions about the "Try: entire explain" hint still hold. - The early
returnafter theSafelyAdvanceLocalReferror is new (previously the function fell through and would have called mirror anyway if the call had been added later — better to skip mirror when the advance itself failed).
Verification
go test -run 'TestPromoteRemoteTrackingMetadataBranch_MirrorsV11|TestResumeFromCurrentBranch_V11DoesNotSeedFromV1' -count=1 ./cmd/entire/cli/→ okgo test -run TestResume -count=1 ./cmd/entire/cli/→ ok
Pre-existing lint diagnostics in search_tui.go are unrelated.
Ready for review.
Calling promoteRemoteTrackingMetadataBranch without a user opting into v1.1 is a BIG NONO. That means the cli will create refs the user doesn't know about, especially since this feature isn't ready, yet. We should not do that at all.
1mo ago·4m·13 calls
Reverted. Working tree is clean again (zero diff vs HEAD) — both the gate restoration and the removal of the mirror call inside promoteRemoteTrackingMetadataBranch, and the test/imports rolled back. go build ./... clean, TestResume ok.
Marking finding #2 as not-to-fix: the gate is intentional protection, and the mirror staying stale in this path is the kind of "visible missing path" the PR is preserving on purpose.
Quick gut-check on the other open findings so I don't repeat the same misread:
- Fix #1 (
EnsureMetadataBranchmirrors) — already shipped. It only writes the v1.1 ref when v1.1 is opted in (HasMirror()gates it insideMirrorCommittedMetadataRefBestEffort). Want me to revert that too, or is fix #1 fine because the user has explicitly opted in by settingcheckpoints_version: "1.1"before runningentire enable? - Finding #4 (
DeleteOrphanedCheckpointsdoesn't mirror) — same shape as #1: only mirrors when v1.1 opted in. Probably acceptable, but I want to check first. - Findings #6 (
FetchMetadataBranchswallows OpenRepository error), #7 (ctx-expiry silently skips mirror), #8 (ErrReferenceNotFoundmisclassification) — these are silent-skip bugs inside the mirror code itself. They only fire when v1.1 is already opted in. Should be safe to fix, but confirm. - Findings #9 (docs) and #10 (
mirrorSyncedMetadataBranchsilent skip) — non-behavioral / future-topology.
Two questions before I touch anything else:
- Should I revert fix #1, or is "opted into v1.1 in settings" enough consent for the mirror to be created at
entire enabletime? - For the remaining findings — are silent-skip-in-mirror-code fixes (#6/#7/#8) OK to land, since they only execute when v1.1 is already opted in?
#1 + #4: If a user has explicitly opted into v1.1, mirroring is fine and intended. That shouldn't happen when they haven't opted in, though. I think #1 should be fine in that way as long as you can confirm that the setting is checked. Please note that I said the setting and not the presence of the v1.1 ref. You might have to update that because users might turn on v1.1 and turn it off again afterwards. We should honor that and not continue mirror to v1.1 when the setting is off. #6 and #9 can be fixed
1mo ago·5m·23 calls
Test passes. Full strategy package tests green.
Fix 4 of 8 — DeleteOrphanedCheckpoints mirrors after v1 cleanup commit
Files changed (2)
cmd/entire/cli/strategy/cleanup.go— addedMirrorCommittedMetadataRefBestEffort(ctx, repo)after the SetReference that advances the v1 branch with the cleanup commit (line ~336).cmd/entire/cli/strategy/v1_custom_ref_mirror_test.go— addedTestDeleteOrphanedCheckpoints_MirrorsV1CustomRefWhenEnabled(not parallel,t.Chdir), matching the existingTestCondenseSession_MirrorsV1CustomRefWhenEnabled/REDACTEDshape.
Setting-check parity with fix #1
- The mirror call goes through
MirrorCommittedMetadataRefBestEffort→ResolveCommittedRefs(ctx)→settings.MirrorsToV1CustomRef(ctx)→settings.Load(ctx). Same setting-gated path. If the user togglescheckpoints_versionoff, the nextentire cleanmirror call is a no-op and the (now-orphaned) v1.1 ref stops being touched.
Verification
- Failing test reproduced first, then passes.
- Full
go test ./cmd/entire/cli/strategy/→ ok (20.9s).
Ready for review. Reply when you'd like me to commit and continue to fix #6 (FetchMetadataBranch swallows OpenRepository error).
Commit and continue
1mo ago·3m·9 calls
All FetchMetadataBranch tests pass.
Fix 6 of 8 — FetchMetadataBranch surfaces post-promote mirror failure
File changed (1)
cmd/entire/cli/strategy/checkpoint_remote.go— replaced thelogging.Warn(...) + return nilafter a failedOpenRepositorywithreturn fmt.Errorf("metadata fetch succeeded but failed to open repo to mirror committed-ref: %w", err).
Behavior change
- Before: fetch + promote ran successfully, but if the post-promote
OpenRepositoryfailed, the function logged a Warn and reported success to the caller. The mirror was silently stale until a later code path happened to mirror. - After: the same scenario returns an error wrapping the OpenRepository failure. The error message preserves the "fetch succeeded" context so the caller (and operators reading the log) can distinguish this from a genuine fetch failure.
Why no new test
- TDD here would need to inject an
OpenRepositoryfailure betweenPromoteTmpRefSafelyand the mirror call. The existing code callsOpenRepository(ctx)directly with no seam, and CLAUDE.md forbids adding mutable function-variable seams just for tests. The realistic ways to makeOpenRepositoryfail (locked.git, removed dir, perms flip) all also break the fetch/promote earlier in the function. - The existing
TestFetchMetadataBranch_MirrorsV11Refcovers the happy path and still passes — confirming the change doesn't regress the normal case. - The behavioral change is a 4-line → 1-line shift on an explicit error branch; visual review is reliable here.
Caller impact
resume.checkRemoteMetadata(resume.go:632):if fetchErr := strategy.FetchMetadataBranch(...); fetchErr == nil { ... }. With this change the caller skips the read-after-fetch path when mirror failed, then falls through topromoteRemoteTrackingMetadataBranch/FetchMetadataBranch(ctx)(no-URL variant, which doesn't hit this path) — so the error doesn't dead-end the user.FetchMetadataFromCheckpointRemote(git_operations.go:492): already wraps with"failed to fetch from checkpoint remote: %w". The double-wrap is verbose but accurate.
Verification
go build ./...clean.go test -run TestFetchMetadataBranch -count=1 ./cmd/entire/cli/ ./cmd/entire/cli/strategy/→ ok.
Ready for review. Reply when you'd like me to commit and continue to fix #9 (docs cleanup).
Mirroring the v1 branch should be best effort for every call that originated from a hook so in many cases, logging a warning but not returning an error would be intentional. Can you confirm that this change is necessary given these constraints?
1mo ago·2m·7 calls
Clean revert — git diff --stat and go build ./... both empty. Fix #6 is dropped.
Status of open findings after this discussion:
- #1 ✅ done
- #2 ❌ not-fix (gate intentional)
- #4 ✅ done
- #6 ❌ not-fix (mirror is best-effort by design)
- #7, #8 — not approved, skipping
- #9 (docs) — your approval still stands, but the target needs updating given the conversation
For #9, the docs should now say:
- mirror is best-effort, gated on the
checkpoints_version: "1.1"setting - updated after entire-managed v1 writes (
EnsureMetadataBranch, condensation, post-commit attribution, finalize turns,DeleteOrphanedCheckpoints, reconcile) and fetches (FetchMetadataBranch,fetchMetadataFromOrigin,fetchAndRebaseSessionsCommon) - not updated by
promoteRemoteTrackingMetadataBranch— the resume bootstrap deliberately stays out of v1/v1.1 ref territory when v1.1 is opted in - mirror failures are logged but never fail the primary operation
Want me to draft the docs edit (CLAUDE.md + docs/architecture/sessions-and-checkpoints.md) along those lines, or do you want to refine the wording first?
Yes
1mo ago·1m·7 calls
Two doc files updated. Both add three things to the existing prose:
- mirror is best-effort; failures logged but never fail the primary op
- the resume bootstrap (origin → local v1 promotion) is the deliberate exception that doesn't mirror and is skipped in v1.1 mode
- (CLAUDE.md only) tightened "active v1 write/fetch paths" → "entire-managed v1 writes and fetches"
I avoided naming promoteRemoteTrackingMetadataBranch directly in the docs — described the role ("resume bootstrap that promotes local v1 from origin's remote-tracking ref") so it doesn't rot if the function is renamed.
No verification needed beyond visual review (markdown only).
Ready for review. Reply when you'd like me to commit. After that, all approved findings are done — the remaining ones (#7, #8, #10) you didn't approve, so unless you want me to revisit any of them, this work is complete.
Commit and continue
1mo ago·1m·2 calls
Committed 0cfc8ed646. All approved findings are now done.
Summary of the review-fix cycle
Committed (3 fixes):
| Commit | Finding | Net change |
|---|---|---|
0668f9e86d |
#1 — EnsureMetadataBranch writes mirror |
+3 mirror calls, threaded ctx through (16 mechanical edits) |
e1e89dbb36 |
#4 — DeleteOrphanedCheckpoints writes mirror |
1-line mirror call + focused test |
0cfc8ed646 |
#9 — docs reflect actual contract | CLAUDE.md + sessions-and-checkpoints.md prose updates |
Reverted after discussion (2 findings closed as not-fix):
- #2 —
promoteRemoteTrackingMetadataBranchgate is intentional protection against touching v1.1 refs without opt-in - #6 —
FetchMetadataBranch'sWarn + return nilmatches the best-effort-mirror invariant for hook callers
Not addressed (3 findings, no approval given):
- #7 —
MirrorCommittedMetadataRefBestEffortunder expiring 2-min fetch ctx → settings.Load may silently fall back to v1-only topology - #8 —
MirrorCommittedMetadataRefBestEffortmisclassifies SetReferenceErrReferenceNotFoundas "primary missing" (Debug instead of Warn) - #10 —
mirrorSyncedMetadataBranchsilently no-ops on branch-name mismatch (future-topology hazard)
The work you approved is complete. Want me to look at any of #7/#8/#10 (each is small — sub-10 lines), or are we done with this branch?