Repository navigation
Description
Current state
Managed-volume turn-tree placement is delivered through merged #4050, squash 8e35d4c792c833e5f3ae0727dadad0cde6e35b16 (0.45.0), an ancestor of inspected main 3b104890f8. The recorded hosted heavy-feedback run 43800954882 at 24787de0 passed every category, including separate-UID isolation; this triage checked delivery/source, rather than independently rerunning those jobs. The only remaining handoff is the native --apply-timing allocation/growth/admission measurement below. Preserve all original acceptance criteria and their attributed receipts.
Context
The earlier #2848 temporary-directory tree held a complete document/index copy per concurrent turn. #2891 delivered pooling; it is a completed predecessor, not an active blocker. Historical branch measurements were 43 ms for 2,000 notes and 202 ms for 10,000 notes. They remain the comparison baseline, not a new measurement of main.
The selected implementation uses createTurnDataTree (packages/ui-server/src/brain/turn-data-tree.ts:409) and the manager's prepareTurnTree (packages/ui-sdk/src/server/native-brain-manager.ts:785) and releaseTurnTree (same file:825). The manager retains protected control ancestors, finite-capacity/reserve admission and live-reader-aware cleanup. The tree is outside live-brain/checkpoint inputs; placement does not expand worker authority or change tree contents.
Maintainer decision and scope (2026-10-25)
Option A selected: the native manager provisions a protected server-owned area on the existing managed Btrfs volume for turn data trees, outside the live brain and checkpoint inputs. Place qualified trees there so their document/index seed can reflink the startup view.
- Keep the managed store and private control ancestors root-owned/protected. Only the authenticated application server owns mutable tree contents; workers receive only their own read-only tree mount. Governed peers, unrelated workers and other server principals cannot mutate or inspect another turn's tree. Specify and verify the separate-UID ownership/mode/traversal arrangement before use; do not make the store or live brain a writable placement bypass.
- Trees, changed copy-on-write extents, filesystem overhead and outstanding allocations consume the existing finite managed-volume capacity. Account actual filesystem allocation and shared extents without double-counting them as separate physical copies or treating reflinks as zero-cost forever. Do not change logical retained-history charges. Preserve existing admission/reservation rules and emergency recovery reserve; normal tree creation/growth cannot consume that reserve or enlarge the configured limit.
- Record durable tree ownership and reader/lifecycle evidence. The owner removes its tree only after all workers/readers have released it; crash recovery reclaims only proven abandoned owned trees, never a live tree or arbitrary path. Observe filesystem reclamation before reusing released capacity. Keep cleanup outside the app event loop, cancellable/bounded and recoverable under existing native-manager rules.
- Preserve the current data-tree contents, binary/Markdown provenance rules, provider isolation, frozen configuration and per-turn read-only behavior. No extra cross-turn data reuse or new storage seam is selected.
- Use qualified reflink placement; prove physical sharing on the native filesystem and do not silently substitute an unbounded full-copy fallback. Reconcile any existing supported non-native placement without removing a public guarantee incidentally.
- Record ownership, placement, allocation and recovery rules in docs/decisions/native-brain-storage.md and the applicable governed-worker decision record. Implementation names/modes are concrete design under these rules, not a new public configuration choice.
Out of scope
- What the tree holds and the provenance rule (ui-sdk: a strict worker never sees its own turn's host applications or their index update #2848, ui-server: a provider-restricted turn's own applications never reach its private search index #2846).
- The pooled copy itself (ui-server: a strict turn's data tree copies the whole startup view at every admission #2891).
Acceptance criteria
- A native tree is placed outside the live brain under the protected server-owned managed-volume area. Separate-UID workers read only their own tree, cannot mutate it or reach peer trees, and governed peers cannot alter it or cause it to enter later brain checkpoints.
- A native allocation receipt (btrfs filesystem du or equivalent) proves real document/index reflink sharing and allocation far below a plain copy; admission is not slower than the existing ui-server: a strict turn's data tree copies the whole startup view at every admission #2891 pool under the same fixture/load. Record changed-extent growth as well as unchanged seed cost.
- Concurrent-tree admission and copy-on-write growth respect the existing hard volume bound and protected emergency reserve, using actual physical allocation evidence. Near-capacity operation refuses safely without larger limits, double-counted shared extents or zero-cost assumptions.
- Normal release and crash/restart recovery retain trees with live owners/readers and reclaim only proven abandoned managed trees. Late cleanup/cancellation cannot delete a reused or foreign tree; reclaimed capacity is credited only after observed filesystem reclamation.
- The native --apply-timing and prove-worker-identity.ts separate-UID cells pass, along with existing data-tree provenance/provider tests. Record focused failing-first and restored mutations for isolation, live-reader cleanup refusal and capacity/reserve enforcement.
- Update the native storage/governed-worker records and any affected manager readiness contract/API report; no data-tree content or source-of-truth semantics change.
Verification
bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timing, bun scripts/prove-worker-identity.ts, bun run test packages/ui-server/tests/turn-data-tree.test.ts.
Contract impact
Placement/ownership behavior is approved without removing any supported interface. If manager ready facts expose the new area, make that an additive readiness fact with contract label, CONTRACT: commit, same-commit authoritative package documentation/API report and minor changeset. Preserve existing ready fields and storage limits; no field removal/retyping or unsupported authority grant is approved. Keep private paths as opaque operational facts, not public deployment details.
Human verification remaining (2026-11-16)
Implemented in #4050 (Refs, not closing). Its hosted heavy feedback (run 43800954882 at 24787de0) passed every category. That covers prove-worker-identity.ts, where the separate-UID worker reads its own managed tree, gets EROFS writing it, cannot read a peer tree or list the manager's trees/ area, and the manager removes the tree after the turn. It also covers every prove-native-host.ts cell and the full unit suite, including the manager capacity, reserve, reader-refusal and reclamation tests with their mutation receipts.
Remaining action: acceptance criteria 2 and 5 need the opt-in --apply-timing measurement, which hosted CI never runs. On a native host with root, a free loop device and Btrfs, run:
bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timingCompletion evidence: post its apply-timing.json allocations (every seeded tree's exclusive bytes below a tenth of its total, which the run asserts), the close-time growth, and the seeds milliseconds compared with the #2891 pool (43 ms and 202 ms). Then remove needs: human and close the issue if they hold.
2026-11-16 triage: Removed the satisfied #2891 blocker declaration and obsolete pre-ruling alternatives, folded merged #4050 into the active specification, and retained the exact native measurement handoff. Added contract for the delivered additive native-manager surface. Assignment and 0.45.0 attribution are preserved; no native measurement is claimed.
Activity
schlessera commentedon Oct 25, 2026
2026-10-25 triage at main
541b8d98328a760290ac6dd4a7f065af76153408: Completed the managed-placement ruling with concrete authority/capacity/reserve/recovery alternatives and an explicitly unapproved recommendation; preserve needs: decision. Corrected the pool to open-branch evidence and retained #2891 as its actual baseline prerequisite. p2 records wanted unscheduled work; no manager path or accounting policy is approved.schlessera commentedon Oct 25, 2026
Decision (maintainer, 2026-10-25): Option A. Provision a protected server-owned turn-tree area on the existing managed Btrfs volume, outside live brain/checkpoint inputs; each worker gets only its own read-only tree and peers cannot reach or mutate it. Use real reflink allocation evidence, charge changed extents/overhead within the existing finite volume, preserve emergency recovery reserve and existing logical history charges, and refuse unsafe admission without increasing limits. Track ownership/readers and reclaim only proven abandoned owned trees after crash; observe freed capacity before reuse. Preserve data/provenance/provider/frozen-view rules. The body now specifies the selected ownership/capacity/recovery policy and native proof; priority p2 records wanted unscheduled follow-up.
schlessera commentedon Oct 25, 2026
Unblocked: #2891 is closed, so
scripts/sync-project.tsis removing theblockedlabel.schlessera commentedon Nov 8, 2026
Measured evidence from #3513 (PR #3676, case 19 of the reference pool proof; hosted heavy feedback run 42475041809 at
59caf001, kernel 7.0.0-1017-azure, btrfs-progs 6.6.3). The proof copied an 8 MiB checkout three ways:cp --reflink=alwayson the pool: 0 exclusive bytes, 140 ms.--reflink=never: 8,388,608 exclusive bytes, 251 ms.EXDEV(Invalid cross-device link), and the automatic fallback allocated 8,400,896 bytes.createTurnDataTree(packages/ui-server/src/brain/turn-data-tree.ts:315) copies withCOPYFILE_FICLONEintomkdtempSync(join(tmpdir(), "brain-turn-data-")), which is that cross-filesystem case: every byte is allocated. The copy is bounded only by theCOPY_ENTRIES/COPY_DEPTHlimits (turn-data-tree.ts:91), with no byte budget or capacity admission. This is the copy-budget gap #3513 asked to identify. It is recorded here instead of in a duplicate issue, because this issue's placement and capacity criteria already own it.schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-2bce33f1. Branch:refactor/2911-managed-turn-trees.path collision with draft #3806 (native manager files)
test(ui-server): a view no manager acquired keeps the temporary tree (#…
test(native-proof): a governed provider-index turn has no mounted tre…
schlessera commentedon Nov 16, 2026
2026-11-16: #4050 implements the managed-volume placement. Its hosted heavy feedback (run 43800954882) passed every category, including the separate-UID isolation checks. Acceptance criteria 2 and 5 still need one native-host run of
bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timing, which hosted CI does not run. #4050 therefore usesRefs #2911, and this issue carriesneeds: humanwith the exact command and completion evidence in the body.CONTRACT: feat(ui-sdk,ui-server): place a turn's data tree on the man…
schlessera commentedon Nov 16, 2026
Native
--apply-timingrun (2026-11-16)bun scripts/prove-native-host.ts --backend=pi --app-uid=1000 --apply-timingran on main at3b104890f, which contains #4050's squash8e35d4c79.scripts/ci-runtime-setup.sh --native). It is not a hosted runner. The VM is deleted after the runs.native hosted pi uid 1000 …, 1 pass, 96 expects), and the loop cleanup receipt is clean (mounted:false, attached:false, backingExists:false, errors:[]).0.88before and1.06after (1-minute average).allocations(btrfs filesystem duof the turn's managed tree):data: 32,768,000 bytes, fully shared at both stages.index: 120.7 MB, with 32 KiB exclusive at seed and 616 KiB at close.seeds: one seed, 54.5 ms (mounted:true, masked:false). The #2891 pool baseline for 2,000 notes is 43 ms (historical branch measurement, different host).Apply medians: write 4.9 ms (p95 9.9), edit 5.2 ms (p95 6.9). In-worker
brain_searchsaw the edited notes.Assessment:
needs: humanstays for now.schlessera commentedon Nov 16, 2026
Four more runs of the same cell on the same VM and commit (
3b104890f), all exit 0:The allocation criterion holds. Admission is consistently above the historical #2891 pool figure of 43 ms for 2,000 notes. That figure was measured on a different host, so the same-load comparison the criterion asks for has not been made yet.
needs: humanstays until the maintainer decides.schlessera commentedon Nov 16, 2026
Maintainer decision (2026-11-16): accepted. Every native criterion holds:
--apply-timingcell, which passed 5 of 5;The admission median of 54.5 ms, about 11 ms over the #2891 pool's cross-host 43 ms, is accepted as meeting "not slower than the pool". No same-host pool baseline was run. Delivered by #4050 (
8e35d4c79, 0.45.0).