Repository navigation
fix(agent-runtime): collapse dot and duplicate segments in path-lock keys - #1935
Merged
Merged
Conversation
…keys normalizeLockPath only stripped one leading ./, so spellings such as src/./a.ts, src//a.ts, and src/foo/../a.ts took different PathMutex keys. Write/Edit and a parallel Read could then overlap on one file, and the edit-recovery budget only holds if same-path attempts stay ordered. Collapse segments lexically. Keep a relative .. and a Windows drive, and do not let .. pop a delegate worktree id out of a worktreeKey\0path key.
Absolute paths cannot climb above their filesystem root. Keep root and drive-root aliases on one mutex key so equivalent writes and reads remain ordered.
This branch was previously deployed
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.
Fixes #1934
What
normalizeLockPathnow splits the path on/, drops.and empty segments, and lets..pop the previous segment (a leading..that has nothing to pop stays, so../x.tsis not eaten). A leading/and a Windows drive prefix are kept, and the result is still lowercased. For delegate keys (${worktreeKey}\0${path}frompathLockKey) only the path half is collapsed, so..cannot pop the worktree id.Why
Different spellings of the same file got different lock keys, so Write/Edit (
run) and Read (read) onsrc/a.tsvssrc/./a.ts/src//a.ts/src/foo/../a.tsdid not queue behind each other.How tested
path-lock.test.ts: segment collapsing (incl. backslashes), a write queued behind another spelling of the same path, a read not overlapping a write of an equivalent path, plus regressions for lowercasing, empty path, leading.., and absolute paths. The 3 new cases fail on unmodifiedmainand pass with this change.packages/agent-runtime: full vitest 106 files / 1496 tests pass;tsc --noEmitclean;pnpm lint:biomeandscripts/check-architecture.mjspass.Scope
path-lock.tsand its test only. Still lexical and synchronous; norealpath, no change inruntime.ts.