Repository navigation
Description
Part of #4426. Found in the first independent review of PR #4490, which fixes #4486 and #4487.
Blocked by #4487
(The retry this issue builds on exists only in PR #4490. Implementing it before that PR merges would rewrite the same function twice.)
Context
hasBrainAlias (packages/ui-server/src/brain/operational-state.ts:40-105 on main 356fa7d, unchanged at PR #4490's head c1f7103a1: collect, :51-67, and walk, :80-97) lists each directory once. A rename from a directory not yet listed into one already listed raises no error. The retry in operationalStateRefusal (PR #4490 head c1f7103a1, operational-state.ts:166-180) then never runs, and the inode appears in neither listing, so the check can return "no alias" while one exists. The walk is the same on main, which has no retry at all.
Prior art in the tree: scanForOutsideLinks (packages/ui-sdk/src/server/worker-sandbox.ts:295-305, with scanOnce at :307) records each directory's identity and change/modification stamps before listing it and compares them after the walk. A changed stamp repeats the walk; after three tries the result is unverified.
Scope
Accept a negative result only from a stable view of both walks (the private-state collect walk and the brain walk).
Exclusions: trees above the entry/depth bounds (#4499); the recorded diagnostic (#4495); which call sites run the check.
Acceptance criteria
- A negative result is accepted only if every visited directory's identity and change stamp are unchanged at the end of the walk, or the walk compares stable snapshots. A changed stamp counts as an incomplete scan and goes through the existing bounded retry, ending in
private_state_unverifiedif it never settles. - A deterministic test (injected hook or controlled fixture, no timing sleep) renames an aliased entry from an unlisted directory into a listed one with no error raised, and still gets
private_state_in_brain. It fails on the code before the fix. - A stable tree with no alias still verifies on the first attempt (no added retries on an unchanged tree).
Verification
bun run test on the targeted test file, with a failing-first receipt and a mutation receipt (drop the stamp comparison and watch the named test fail) in the PR.
Contract impact
None. The verdicts and reasons are unchanged; a churning tree can now report private_state_unverified where it previously reported a false negative.
2026-11-23 triage at main 356fa7d: citations re-pointed at main and PR #4490's current head c1f7103a1; declared the dependency on #4487; added exclusions, a no-regression criterion, verification and contract impact.
Activity
schlessera commentedon Nov 23, 2026
Unblocked: #4487 is closed, so
scripts/sync-project.tsis removing theblockedlabel.