Skip to content

fix(agent-runtime): collapse dot and duplicate segments in path-lock keys - #1935

Merged
vastsa merged 3 commits into
vastsa:mainfrom
xpeng5278-web:fix/lock-path-segments
Oct 28, 2026
Merged

vastsa merged 3 commits into
vastsa:mainfrom
xpeng5278-web:fix/lock-path-segments

Conversation

@xpeng5278-web

Copy link
Copy Markdown
Contributor

Fixes #1934

What

normalizeLockPath now splits the path on /, drops . and empty segments, and lets .. pop the previous segment (a leading .. that has nothing to pop stays, so ../x.ts is not eaten). A leading / and a Windows drive prefix are kept, and the result is still lowercased. For delegate keys (${worktreeKey}\0${path} from pathLockKey) 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) on src/a.ts vs src/./a.ts / src//a.ts / src/foo/../a.ts did 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 unmodified main and pass with this change.
  • packages/agent-runtime: full vitest 106 files / 1496 tests pass; tsc --noEmit clean; pnpm lint:biome and scripts/check-architecture.mjs pass.

Scope

path-lock.ts and its test only. Still lexical and synchronous; no realpath, no change in runtime.ts.

xpeng5278-web and others added 2 commits October 27, 2026 09:28
…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.
@vastsa
vastsa merged commit 2bee857 into vastsa:main Oct 28, 2026
2 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 09b8e0c9 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Path lock treats ./, //, and .. spellings of one file as different paths, so same-file Write/Edit/Read overlap

2 participants