Repository navigation
fix(pull): key a checkout by its canonical path, so a differently spelled HOME finds its record (#1743) - #1792
Closed
Walternater wants to merge 1 commit into
Closed
Walternater wants to merge 1 commit into
Walternater wants to merge 1 commit into
Conversation
…lled HOME finds its record (Tencent#1743) `checkoutKey` hashed the path it was given, so one directory spelled with a trailing separator or a `.` segment hashed to a different entry in `state.lastPullByWorkspace`. The pull under the second spelling then misses the record the first one wrote, runs a full sync instead of the unchanged fast path, and the entry holding `delivered` — the proof a copy teamai wrote is teamai's — is superseded. Resolve the path before hashing it. `path.resolve` is pure, so a home that is a symlink keeps its key. Co-Authored-By: Claude Code <noreply@anthropic.com>
Collaborator
Author
|
Closing this: #1780 ( Two things this branch did that #1780 rightly left out, so it is not a smaller alternative worth merging:
I had not fetched |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
checkoutKey(src/pull.ts) hashes the string it is given. The same directory spelled with a trailing separator, or with a.segment, hashes differently, so it gets a different entry instate.lastPullByWorkspace:So a command launched with the other spelling reads nothing the last pull wrote. The user-scope record holds
rev,targets,delivered— the path and hash of every copy teamai wrote, which is what proves a delivered file is teamai's —places,sessionToolHomesandselection. A pull that misses it runs a full sync instead of the unchanged fast path.#1743 is the report of what that costs in a flow where the re-delivery does not heal it: a copy teamai delivered is then read as the member's own, because the record that proves otherwise is not found. The triage split the issue into this record-key part and the ownership-proof part; the proof itself was fixed in #1764. This PR is the key.
Change
One line: hashing the resolved path instead of the given one.
path.resolveis pure — norealpath, so a home that is a symlink keeps its key and no one's record moves unexpectedly.Real CLI, after
npm run buildSandbox: an isolated
HOME, a local team repo holding one skillledger, user scope,enabledAgents: [claude].mainSynced 1 skills (all updated)baafd25220df— pull A's record is goneAlready synced at 5acfd7a, skipping91515ad30210— the key pull A wroteAnd a single pull each way, on the same directory:
HOMEspellingmain/tmp/t1743-fixed/home91515ad3021091515ad30210/tmp/t1743-fixed/home/baafd25220df91515ad30210What a key holds, from the same sandbox:
That map is the proof a delivered copy is teamai's. A command that computes the other key finds no record at all.
Tests
New
src/__tests__/checkout-key.test.tsstates the property: one directory, one key, however its path is spelled (trailing separator,.segment,..segment). It fails onmain:npx vitest run— the 10 files that readcheckoutKeyand pull state: 587 passed.npm run typecheckandnpm run lintpass.Limitations
state.json; it names no live checkout with aroot, and user-scope records never had one, so nothing drops it and nothing else reads it.Part of #1743.
🤖 Generated with Claude Code