Repository navigation
Description
Prerequisite delivered: #2853 is closed; current main includes the hold-aware bridge entry wait. This issue covers intake writes after that entry wait.
Context
Found while fixing #2853. A conversation turn's inbox_add stages the shared files into the brain before it checks the turn again: ingest checks isCurrent at entry (authorize(principal, isCurrent);, packages/ui-server/src/inbox/intake.ts:88), stages and publishes the files (const result = await stageShareAt, packages/ui-server/src/inbox/intake.ts:106), then checks again inside the commit transaction (authorize(principal, isCurrent); // revocation may occur during decoding or staging, packages/ui-server/src/inbox/intake.ts:112).
For an interactive turn, isCurrent is the bridge's strict check, which is false while a journal observation holds or the turn's scope is paused (isCurrent: () => !signal.aborted && isAuthorized(), packages/ui-server/src/ws/bridge.ts, in createBridge). So:
- an observation or pause that begins during staging makes the final check refuse "Inbox principal or turn is no longer authorized" for a still-valid principal, and the intake compensates by cleaning up the staged files, which is itself a brain write during the hold;
- the staging writes themselves are not gated on a hold at all; only the entry wait (the bridge's wrapped
inboxAddwaits for holds before it starts, on the ui-server: a host write overlapping a journal observation is refused as authority_revoked #2853 implementation branch) keeps them out of one.
#2853 proposes making application, mask and policy routes wait for a hold instead of refusing, but deliberately kept intake's strict check: relaxing it would let staged files be accepted after a write that overlapped a hold, without adding the missing guard.
Maintainer decision and scope (2026-10-25)
Option A (original option 1) selected: guard the complete conversation-intake write lifecycle, including staging, publication, reconciliation and compensation, with bounded hold-aware rechecks. A journal observation or scope pause is temporary unavailability, not revocation. Preserve immediate refusal for real principal/turn revocation and cancellation.
- Coordinate every authoritative staging/publication/compensation write with the journal/scope write boundary so a hold beginning during an asynchronous staging phase cannot overlap a write. A single check before awaiting staging is insufficient. Do not merely weaken isCurrent to accept publication after unguarded writes.
- Wait outside transactions and any brain/journal lock needed for observation or Continue/Stop, with the existing bounded hold-wait policy and cancellation. Revalidate current turn, principal, provider masks, receipt ownership and any publication premise after waiting, immediately before committing. Repeated holds share the original bounded wait deadline; no indefinite retry loop.
- A hold at the final commit check returns to a safe wait/recheck boundary without discarding valid authority, duplicating intake, publishing twice or treating an uncommitted receipt as accepted. The DB transaction never awaits.
- Failed/cancelled/revoked intake never revives the turn or publishes a queue claim. Cleanup is an explicitly owned host compensation effect under the same hold-safe write coordination. If compensation cannot run safely within the bound, retain its durable cleanup receipt and ownership for reconciliation; do not write through a hold or discard recovery evidence. Committed receipts are never compensated.
- Preserve existing deduplication, staged-byte provenance, provider isolation and atomic receipt/item publication. No external-staging redesign is selected. Record this boundary in the applicable journal/intake decision record.
Out of scope
- The application, mask and policy routes (ui-server: a host write overlapping a journal observation is refused as authority_revoked #2853).
- Revocation semantics for a principal that really lost authority.
Acceptance criteria
- Deterministic tests raise a journal hold and a scope pause after entry but during staging, before publication, at the final receipt check and during compensation. Valid intake waits/rechecks and produces one accepted item after release; no authoritative write overlaps the hold.
- Continue/Stop and journal completion remain actionable during the wait: no waiting transaction or lock blocks them. Repeated holds retain one finite deadline, and timeout/cancellation terminate without an accepted queue claim.
- Actual revocation or turn replacement during the wait still refuses; renewed provider-mask/ownership checks prevent stale admission. A mutation removing the late guard or accepting stale authority fails the relevant test.
- Partial failure and concurrent duplicate intake preserve one winner; losing/uncommitted staging cleans only through owned hold-safe compensation, or remains durably queued for cleanup. A committed winner is never cleaned, and provenance remains tied to the actual staged bytes.
- Real intake/staging integration tests prove the write boundary and rollback behavior, not only an authorization predicate. Run the existing inbox provenance/dedup/reconciliation suites and record focused failing-first/restored mutation proof.
Verification
bun run test packages/ui-server.
Contract impact
None expected.
Source reconciliation (2026-10-25): #2853 is now closed and its bridge afterHolds entry wait is present on fetched main. Intake still checks strict isCurrent after asynchronous stageShareAt and its writes/compensation need this separate full-lifecycle guard. Reconcile exact current anchors before implementing; the earlier branch-only statement is historical.
2026-10-25 triage at main 827861e1fa71cd4a26b52f1ef0f96b849381acdf: Exposed the unresolved architecture/policy question with options, consequences and an explicitly unapproved recommendation; retain the open implementation prerequisite and distinguish branch evidence from current main. No ruling or runtime proof is invented.
2026-10-25 maintainer ruling: selected A, bounded hold-aware coordination across all intake writes and compensation with genuine revocation preserved. Completed prerequisite #2853 is historical context, not an active blocker; implementation/proof remain open.
Activity
schlessera commentedon Oct 25, 2026
2026-10-25 triage at main
827861e1fa71cd4a26b52f1ef0f96b849381acdf: Exposed the unresolved architecture/policy question with options, consequences and an explicitly unapproved recommendation; retain the open implementation prerequisite and distinguish branch evidence from current main. No ruling or runtime proof is invented.fix(ui-server): wait out a journal observation or scope pause instead…
schlessera commentedon Oct 25, 2026
Unblocked: #2853 is closed, so
scripts/sync-project.tsis removing theblockedlabel.schlessera commentedon Oct 25, 2026
Decision (maintainer, 2026-10-25): A (original option 1). Guard the full conversation-intake write lifecycle, including staging, publication and compensation. Temporary journal/scope holds use bounded cancellable waits outside transactions and locks needed for Continue/Stop, followed by fresh authority/mask/ownership checks. No write may overlap a hold; real revocation still refuses. Preserve single-winner deduplication, provenance and committed receipts. If cleanup cannot safely proceed, retain durable owned compensation for reconciliation rather than writing through a hold or losing recovery state. The body now specifies the chosen boundary and tests; #2853 is verified delivered on current main, not an active blocker.
schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-93043236. Branch:fix/2869-intake-hold-aware-writes.path collision with #4028 on packages/ui-server/src/ws/bridge.ts; closure-only reports otherwise
fix(ui-server): judge the partial staging directory once before creat…
fix(ui-server): hold conversation intake writes across a journal obse…
schlessera commentedon Nov 16, 2026
Merged in #4041 as
c07f5f626through the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.