Repository navigation
fix(ui-server): hold conversation intake writes across a journal observation or scope pause (#2869) - #4041
Merged
Conversation
…rvation or scope pause (#2869) A turn's inbox_add checked the turn's strict authority at entry and again before the receipt commit, with unguarded staging writes in between. An observation or scope pause that began while it staged let those writes run through the hold, then refused a still-valid turn and removed the staging during the hold. Every intake write now runs through one write boundary: staging, publication and the receipt commit wait out a hold, bounded by one deadline shared across the intake, and run in the tick their final check passes. The check renews the turn, principal, origin thread and the provider masks over the staging directory. Revocation, replacement and cancellation refuse at once. Compensation never writes during a hold: inline removal skips, and the intake that owns the arrival removes it after the hold, off the reply's path, or leaves its cleanup receipt queued for reconciliation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Collisions at head |
This was referenced Nov 15, 2026
schlessera
marked this pull request as ready for review
November 16, 2026 04:29
…ing it (#2869) The gated partial creation judged the partial directory both before and inside its change, so the guard saw the first change twice and share-staging-protection's in-order guard test failed. The check inside the change already runs before the staging root opens, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Collisions at head |
schlessera
marked this pull request as draft
November 16, 2026 06:06
schlessera
marked this pull request as ready for review
November 16, 2026 06:06
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2869
What changed
A conversation turn's
inbox_addnow treats a journal observation or a scope pause that begins after its entry check as a hold, not as revocation. Before, it checked the turn at entry and again just before the receipt commit, and its staging writes ran unchecked in between. A hold that began while it staged let those writes run through the hold. The final check then refused a still-valid turn with "Inbox principal or turn is no longer authorized" and removed the staged files during the hold. Now every intake write goes through one write boundary (writeBoundary,packages/ui-server/src/inbox/intake.ts): partial creation, each file andmeta.jsonwrite, publication, theprepare/accept/replayreceipt writes, and the reconciliation removals. Each one waits out a hold outside any transaction or lock, with one 60-second deadline shared across the whole intake. It then runs in the same tick as its final check, so a hold that begins after that check cannot overlap it. One item is accepted after the hold ends.Why this shape
This follows the maintainer's option A on the issue: guard the whole intake lifecycle rather than relax
isCurrent.stageShareAttakes an optionalStagingWriteGateand, when one is given, writes each file synchronously (writeExclusiveSync). An async write in flight could otherwise straddle a hold that begins mid-write. The share, person and CLI routes pass no gate and keep their existing async path unchanged.authorizereportsAuthorityHeldonly when the principal row is still usable and the bridge's ownhold.active()says authority stands (packages/ui-server/src/inbox/bridge-tools.ts). Revocation, turn replacement and cancellation keep refusing at once.requalifyhook, the provider masks over the staging directory. That mask check was entry-only; it is now shared byguardMaskedRecordsandopenInboxinpackages/ui-server/src/ws/bridge-capabilities/activity.ts. Theaccepttransaction still refuses a receipt that reconciliation took meanwhile.journal.isHeld() || scopePaused(), independent of turn authority) under the same deadline, and keeps the receipt inactiveuntil it settles. When it cannot run (bound passed or turn cancelled), itscleanupreceipt stays queued for reconciliation.close()now waits for these owned cleanups. A committed receipt is never compensated.The boundary is recorded in
docs/decisions/governed-writable-workers.md, next to the #2853 paragraph. While there, I repaired citations into the touched files that had drifted, in that record and in three plans.Proof
New tests run real intake, real descriptor-anchored staging on a temporary brain, and a real UI database.
inbox-intake-holds.test.tscovers a journal hold and a scope pause raised at the staging, publication and receipt checks, and a hold raised in the macrotask after entry. It also covers the shared deadline and timeout, revocation and turn replacement during a hold, cancellation, a stale mask premise, a receipt reconciled during the wait, concurrent duplicates with one winner, and a loser whose cleanup meets a hold.ws-inbox-intake-hold.test.tsdrives the liveWsHostbridge for both hold kinds. It also asserts that the brain lock stays acquirable during the wait, so Continue/Stop and journal completion are not blocked.Failing first (new tests against
origin/main'spackages/ui-server/src): 0 pass, 17 fail. The receipt-check cases and both live-bridge cases fail with the issue's exact refusal,Inbox principal or turn is no longer authorized. The staging and publication cases fail atINTAKE_HOLD_RAISED_AT_STAGINGand…_AT_PUBLICATION, because main runs no check at those points.Mutations (each restored; tree verified clean afterwards):
INTAKE_HOLD_RAISED_AT_PUBLICATION(no check runs there).{}instead of the shared budget): fails atINTAKE_HOLDS_SHARE_ONE_DEADLINE.requalifyremoved): fails atINTAKE_REQUALIFIES_AFTER_HOLD, because the stale premise was admitted.cleanupruns the removal directly): fails atINTAKE_COMPENSATION_WAITS_FOR_HOLD.accept: both receipt cases fail atINTAKE_HOLD_WAITS_RATHER_THAN_REFUSING.openInboxwithoutholds: both live-bridge cases fail withInbox principal or turn is no longer authorized.Regression found by candidate confirmation, fixed in
6e96b392e. Unit shard 3 atfd7cf1a97failedshare-staging-protection.test.ts›the guard judges every change staging makes, as it lands, in orderatEVERY_STAGING_CHANGE_JUDGED. The gated partial creation judged the partial directory twice: once before the gate and again inside it. The check now runs once, inside the change and before the staging root opens, as on main. My earlier local list named a nonexistentshare-staging.test.ts, which is how this test was missed. Rerun at the fix: every ui-server test importingshare/staging,share/staging-fsorinbox/intake(22 files) gives 328 pass, 3 fail. All three also fail withpackages/ui-server/srcatorigin/main: the twoprovider-mask-bridgecases below, andhttp-internal-mounts.test.ts›retired POST /api/brain/whatsup ….NODE_OPTIONS=--max-old-space-size=8192 bun run typecheckis clean.Environment-only failures:
provider-mask-bridge.test.tsfails bothbrain_read_base and applications refuse a masked provider folder …cases (eventprofilestrictvsgoverned). The same two fail withpackages/ui-server/srcchecked out atorigin/main.Collisions (
bun scripts/collisions.ts --json --pr <this PR>): recorded in a comment below.{"version":1,"kind":"brain-check-pr-receipt","head":"e19c95f5b3d0c604855f0636bf7b0b526110c151","base":"origin/main","mode":"focused","startedAt":"2026-11-16T06:03:11.849Z","finishedAt":"2026-11-16T06:04:20.146Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12894.564102999999},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":105.18085100000098},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":69.79219399999783},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":17.867044999999052},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":55192.526629}]}Proportionate containment
The guard changed is intake's refusal when a turn's authority is held mid-write.
cleanupreceipt ininbox_intake_receipts.INTAKE_DUPLICATES_NOTHING_ACCEPTED_UNDER_HOLD/INTAKE_COMMITTED_WINNER_NEVER_CLEANED(one intake's held cleanup never touches the committed winner), andWS_INBOX_HOLD_LEAVES_BRAIN_LOCK_FREE(a waiting intake leaves the brain lock usable).Checklist
0.45.0.@schlessera/brain-ui-serverpatch).IntakeHoldsis an internal export of an unexported module path.docs/reflect the change.Anything left open
Nothing for this issue. The share, person and CLI intake routes are outside a turn and were out of scope; their staging behaviour is unchanged.
🤖 Generated with Claude Code