Repository navigation
Description
Context
Found while auditing the staging no-follow boundary for #2907. That change moves staging, intake compensation and reconciliation, inbox cleanup and the TTL prune onto descriptors opened without following links (openStagingRoot, packages/ui-server/src/share/staging-fs.ts). The operator restore of an inbox snapshot still writes into the staging directory by pathname, after a one-time link check:
- The restore checks the staging root and
.brain-uiwithrealpathonce (async function stagingRoot,packages/ui-server/src/inbox/snapshot.ts:235). Then it creates directories, removes leftover temporaries and publishes files by joined paths (await mkdir(root, { recursive: true, mode: 0o700 });,packages/ui-server/src/inbox/snapshot.ts:384;await rm(join(path, name));,packages/ui-server/src/inbox/snapshot.ts:397;try { await publish(path, bytes, false); },packages/ui-server/src/inbox/snapshot.ts:404). - Each per-directory check (
realpath(path) !== path) is followed by separate pathname system calls. A link swapped in between them is followed. That is the same check-then-act class ui-server: inbox intake reconciliation and staging follow links where cleanup and prune refuse them #2907 closes for intake.
This restore runs from the operator's recovery command, not from an intake route, so it was outside #2907's staging/intake scope.
Scope
Move the restore's staging mutations (directory creation, temporary reaping, file publication and the parent directory sync) onto the descriptor-anchored, no-follow helpers from #2907, or an equivalent O_NOFOLLOW chain. A link that appears on the way, at check time or in between, must refuse the restore rather than be followed. Keep the existing refusal codes (inbox_staging_symlink, inbox_restore_staging_changed).
Out of scope
- The snapshot's destination file and database paths (
writeInboxSnapshot), which have their own protection. - Intake, cleanup and prune, already covered by ui-server: inbox intake reconciliation and staging follow links where cleanup and prune refuse them #2907.
Acceptance criteria
- A real-filesystem restore where
.brain-ui/inbox, or one restored arrival directory, is swapped for a link while the restore runs refuses with the existing code. The link's target keeps its bytes and gains no new entries. - The existing snapshot/restore tests keep their assertions, including resumable restore and the no-clobber publication.
- Each repaired boundary has a failing-first receipt and a restored-mutation receipt.
Verification
packages/ui-server/tests/inbox-snapshot.test.ts and related restore tests, then bun run check:pr --base origin/main.
Contract impact
None expected: the restore's refusal envelopes stay the same.
Activity
schlessera commentedon Nov 3, 2026
Triage 2026-11-03: p1 (same check-then-act link-following class as p0 #2907, reached only from the operator's restore command), milestone 0.45.0. The scope reuses the no-follow helpers that #2907 introduces in PR #3477, so this waits for that merge.
Blocked by #2907
schlessera commentedon Nov 3, 2026
Blocker #2907 closed: #3477 merged to main as
23dae2625with the no-follow staging helpers. Removingblocked.schlessera commentedon Nov 3, 2026
Claimed (token
claim-3476-t3-277f), branchfix/3476-inbox-restore-staging-fsfroma272a790b. Collision check on the cited files: nopathcollisions; only test-closure overlaps (several open PRs whose affected tests includeinbox-snapshot.test.ts).schlessera commentedon Nov 3, 2026
Draft PR #3500 (head
ec2bd96d2): the restore's staging now goes through the #2907 no-follow descriptors, with failing-first and mutation receipts in the PR body. The local preflight passed. Hosted proof, confirmation and merge have not run yet. The assignment stays while the PR is live.fix(ui-server): inbox snapshot restore stages through no-follow descr…