Repository navigation
fix(write): advance the cached branch after publishing - #33
Conversation
A publish pushed to origin but left the repository cache's remote-tracking ref and fetch record unchanged, so a sync on the same machine within the 60-second fetch window resolved the pre-publish commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yuezengwu
left a comment
There was a problem hiding this comment.
Reviewed exact head 65609201e8198ba4dcd38c21f09ffce900bb65a2 on current main 32f0c180ef1c297f025a6645cee017d2e4d67330. After a successful nonforce push, the shared repository-cache lock and compare-and-swap update preserve branch identity while making the published commit visible inside the fetch window. A mismatched or raced ref is left intact and only its freshness record is evicted, so the next sync fetches; unrelated ref records and failed write sessions are preserved. The existing cached-object repository is shared with the publishing worktree, so the published commit is available to update-ref.
Independent validation: pnpm check, pnpm typecheck, the complete test suite, and pnpm check:package all pass, including two projects sharing the cache and the mismatched-ref fallback. No remaining code finding. No live remote write, global skill installation, release tag or npm publication was performed; current CI and repository merge gates still apply.
Problem
In 1.1.0,
write finish --publishpushes to origin but leaves the repository cache'srefs/remotes/origin/<ref>and its fetch record unchanged. Asyncon the same machine within the 60-second fetch window then reuses the cached ref and returns the pre-publish snapshot. An agent, or another project on the same cache, cannot read a write it just published. This breaks OpenTag's Context Tree integration tests when it is bumped to 1.1.0.Fix
recordPublished(src/sources/resolve.ts) runs after a successful push. Under the repository cache lock it movesrefs/remotes/origin/<ref>from the session's base commit to the published commit withgit update-ref <ref> <new> <old>, then records a fetch for that ref. The push proves the remote held that commit at that moment.syncfetches.docs/specification.mddescribes this under write completion.Tests
In
tests/fetch-freshness.test.ts:syncboth inside the window. Both resolve the published commit and its file, with no extra fetch. This test fails without the fix.syncfetches.Validation
pnpm checkpnpm typecheckpnpm testpnpm check:packageAfter merge: release 1.1.1, then bump OpenTag and First Tree (first-tree-ai/first-tree#2431) to 1.1.1.
🤖 Generated with Claude Code