Repository navigation
Description
Context
scanOnce in packages/ui-sdk/src/server/worker-sandbox.ts:307 records directory inode, mtimeNs and ctimeNs (line 319), then the stamp loop at :360-366 treats unchanged values as proof that no entry moved during the walk. A fast rename can retain both directory timestamps. A policy hardlink moved from an unvisited child into the already-listed workspaces root is then counted nowhere, and resolveWorkspacesMount at :502 incorrectly returns writable. Since PR #4444 (main a3395c4b2) the alias scan runs only when the session opted in to code changes (codeChanges = true); default turns get workspaces read-only without scanning, which narrows but does not remove the exposure.
The existing test at packages/ui-sdk/tests/worker-sandbox.test.ts:231, “an alias moved during the walk is still found,” detected this during PR #4314's full unit selection. At filing, both the test and production file were byte-identical to origin/main 7e861bdb3. PR #4444 has since changed both files (the code-changes opt-in and a readOnlyPath field in the refusal), but not the stamp comparison, so the defect is unchanged at a3395c4b2; the test now calls resolveWorkspacesMount(f.brain, undefined, true) and expects readOnlyPath.
On origin/main 7e861bdb3, using its own test preload in a separate Ubuntu 24.04 VM checkout, the unchanged test failed 87 of 100 repetitions. A second diagnostic run sampled the directory metadata immediately around the injected rename: 85 of 100 observations retained both mtimeNs and ctimeNs, and those same 85 scans returned writable and failed MOVED_ALIAS. No native runtime or provider was used by this filtered predicate test.
Out of scope
No #4314 native test isolation changes, workflow budget changes, default workspace policy redesign, or new filesystem extension interface. This issue is filed without a milestone as a separately reproduced main failure.
Scope
Repair the existing alias walk's detection of entry changes when timestamp equality is insufficient. Restrict the uncertain workspace mount read-only, using the current refusal path. Preserve contained hardlink and ordinary writable-area behavior.
Acceptance criteria
- The moved-alias case refuses the workspace even when directory mtimeNs and ctimeNs remain unchanged across the rename.
- Add deterministic proof of that timestamp-equality case; do not stabilize the test with a sleep that hides the production race.
- Preserve the existing wholly contained-hardlink positive and the byte-name, symlink-swap and outside-link negatives.
- Mutating away the new change detection makes the named case fail with MOVED_ALIAS, rather than a module-load or setup failure.
Verification
Baseline reproduction: bun run test packages/ui-sdk/tests/worker-sandbox.test.ts -t 'an alias moved during the walk' --rerun-each 100 at the main commit above, with main's own preload. The repro depends on the kernel's timestamp granularity (it was observed on an Ubuntu 24.04 VM); a kernel with fine-grained directory timestamps may not reproduce it, which is why the fix needs a deterministic proof that does not rely on the race. Run the whole worker-sandbox file and appropriate checks after the fix. Preserve the workflow gates and budgets.
Contract impact
No CLI/MCP/schema contract change expected. This repairs the existing workspace integrity guarantee.
2026-11-23 triage at main a3395c4: re-verified the stamp comparison is unchanged after PR #4444 and refreshed drifted citations by anchor. Priority set from p1 to p2: no milestone or schedule commits this, and the exposure needs a code-changes session, a pre-existing hardlink to a file outside workspaces and a rename inside one timestamp tick. A bounded local rerun was not possible in the triage checkout (dependencies not installed), so the VM evidence above stands as the reproduction.
Activity
schlessera commentedon Nov 23, 2026
Triage changed the priority from p1 to p2.
priority: p1means scheduled into the current or next milestone, and this issue has no milestone. Since PR #4444, the alias scan only runs for sessions that opt in to code changes. The race also needs a hardlink to a file outside workspaces that already exists and a rename inside one timestamp tick. It stayssecurityandagent-ready. If a maintainer schedules it into a milestone, raise it back to p1.