Repository navigation
CONTRACT: fix(ui-server): bound a UI sync's launch and record its outcome in Activity (#4257) - #4258
Conversation
…come in Activity (#4257) A probe or launch that never settled held the brain's admission entry until restart, so every later Sync got 409 with nothing running. The start is now bounded (refused as `launch_timeout`, a late launch is killed), output pipes held open past the process's exit get a short grace, the 409 names how long the hold has lasted (`heldMs`), and each UI sync is an Activity run with its exit status and last error lines plus a `ui sync failed` log line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head c7af79a against base bd751d4. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4258,
"head": "c7af79a0068a296bb0332cc76cbd5d8f5cd9cff9",
"base": "bd751d43435bbffa919d987323d17098eb5f7166",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/tests/host-version-requirements.test.ts:122-133: issue #4257 Verification wants an integration test through the fixture corpus, each new test shown failing first. This app-level ui-sync run/log assertion uses an empty temp brain, not packages/core/fixtures/corpus/, and per the PR body was never run locally (no native worker boundary): no failing-first receipt, never seen passing, so the app wiring is unproven."
}
]
} |
…ivity wiring to show the app test fails (#4257) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ord the contract entry (#4257) Restores the wiring the previous commit removed as a mutation (its hosted run failed APP_UI_SYNC_RUN as expected), and adds the authoritative contract entry for the additive sync fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head c7af79a against base bd751d4. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4258,
"head": "c7af79a0068a296bb0332cc76cbd5d8f5cd9cff9",
"base": "bd751d43435bbffa919d987323d17098eb5f7166",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/tests/host-version-requirements.test.ts:122-133: issue #4257 Verification wants an integration test through the fixture corpus, each new test shown failing first. This app-level ui-sync run/log assertion uses an empty temp brain, not packages/core/fixtures/corpus/, and per the PR body was never run locally (no native worker boundary): no failing-first receipt, never seen passing, so the app wiring is unproven.",
"disposition": "fixed",
"commit": "5867f40ae3d34b59c3dce7eb4a0e101f478ec6e1"
}
]
} |
Independent reviewReviewed head 12829ec against base bd751d4. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4258,
"head": "12829ec10820712ad72773913f99616e610ee290",
"base": "bd751d43435bbffa919d987323d17098eb5f7166",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/routes/brain.ts:233-259: the 120 s bound only covers boundary.launch, but on a hosted install launch (host-boundary.ts:676-725) returns as soon as runMirrorSync starts. Its mirror lock, native startup view and origin probe (sync-mirror.ts:151-166) stay unbounded, so if one never settles proc.exited never resolves and the brain stays held with a 409 until restart, the #4257 case."
}
]
} |
…starts (#4257) A hosted sync's launch returns before its mirror lock, native startup view and origin probe, so the launch bound ended too early. The boundary now reports the start through onExecute (after the origin probe for a mirror sync), the route bounds until that start, and a returned launch that never starts is killed at the bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 12829ec against base bd751d4. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 01b630b against base bd751d4. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4258,
"head": "01b630b4dac07fafb48f3038485b8b5b27920cda",
"base": "bd751d43435bbffa919d987323d17098eb5f7166",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/routes/brain.ts:313: the 10 s output grace does not release a non-hosted UI sync. `await reader.cancel()` reaches credentialOutput's cancel() (host-boundary.ts:333-337), which reads on to EOF; sync's writer-gate hold wraps stdout that way (host-boundary.ts:342-347). A descendant holding stdout keeps the 409. The held-pipe test's fake stream cancels at once, so it cannot fail."
}
]
} |
…ts output cancel (#4257) The host boundary's admission-retaining stream drains to EOF on cancel, so awaiting it held the reservation while a descendant kept the pipe open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 01b630b against base bd751d4. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head d6cced9 against base bd751d4. Reviewer: agent. No findings. |
…es nothing (#4257) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 7a8cc53 against base bd751d4. Reviewer: agent. 3 findings: 0 fixed, 0 filed, 0 rejected, 3 without a disposition. |
…d idle; pin the start report (#4257) A slow reader draining a hosted sync's buffered output lost its last lines when the grace ran on wall-clock time after exit. The grace now counts only time every unfinished pipe spends blocked on a read. Tests now pin that a started sync outlives the launch bound and that the hosted start is reported before the worker runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head 7a8cc53 against base bd751d4. Reviewer: agent. 3 findings: 3 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head f0bcdc5 against base bd751d4. Reviewer: agent. 1 finding: 0 fixed, 0 filed, 0 rejected, 1 without a disposition. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4258,
"head": "f0bcdc5db569528cf6462f1935d896729d7830eb",
"base": "bd751d43435bbffa919d987323d17098eb5f7166",
"reviewer": "agent",
"outcome": "findings",
"findings": [
{
"summary": "packages/ui-server/src/routes/brain.ts:326-328: the output grace counts idle time from when the pending read began (drainLines sets waiting at :81), not from exit. A sync silent for 10 s or more before it writes its final lines and exits has a read idle since before exit, so if exit is seen before that last chunk is read, check() finishes at once and cancels the readers: the error lines are dropped from the stream, Activity reason and log line."
}
]
} |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Independent reviewReviewed head f0bcdc5 against base bd751d4. Reviewer: agent. 1 finding: 1 fixed, 0 filed, 0 rejected, 0 without a disposition. |
Independent reviewReviewed head 0686c84 against base bd751d4. Reviewer: agent. No findings. {
"version": 1,
"kind": "brain-review-receipt",
"pr": 4258,
"head": "0686c841fce4fd0abfe23faf3e2063860f5d508c",
"base": "bd751d43435bbffa919d987323d17098eb5f7166",
"reviewer": "agent",
"outcome": "no-findings",
"findings": []
} |
Closes #4257
What changes
POST /api/brain/sync(packages/ui-server/src/routes/brain.ts):boundary.launchand, on a hosted install, the mirror lock, startup view and origin probe share one 120 s bound and one abort signal.launchreports the real start through the existingonExecutehook. For a mirror sync (runMirrorSync) that happens after the origin probe, just before the first worker. Past the bound the stream ends with{ type: "done", success: false, reason: "launch_timeout" }and the admission entry is cleared. A launch that returned but never started, or that settles later, has its process killed.syncingRootsis now aMapof root to admission time. The 409 body is{ error, heldMs }and the message gives the hold in seconds.cron,jobName: "ui-sync", attributed to the requesting principal). Its terminal outcome carries the exit status and the last 5 non-empty output lines, and itsjob_outputevent holds the combined output tail. A failure also logsui sync failedon thebrainlogger. Recording fails open.Contract: additive (
heldMs,reason: "launch_timeout", theui-syncrun). It is documented indocs/http-api.md, and the commit is prefixedCONTRACT:. The changeset is a ui-server minor.Out of scope, as the issue says: why the observed launch stalled, and the tier A refusal itself (#4256).
Validation
packages/ui-server/tests/sync-launch-bound.test.ts(new) covers a launch that never settles, a late launch that gets killed, a hosted launch that returns but never starts its first worker, a held output pipe, the 409heldMs, and a reader-disconnected failure recorded in Activity and the log.tests/sync-mirror.test.tsadds a native test: the real hosted sync launch reports its start once, afterlaunchreturned and before the worker ran.tests/host-version-requirements.test.tsnow also asserts, throughcreateAppwith the Odysseus fixture corpus as the brain, that a refused UI sync writes theui-syncActivity run and theui sync failedlog line. This proves the app wiring.bd751d434, with the new test file against the unchanged route, the four original cases failed on their named assertions:STALLED_STREAM_ENDS, the late-killdoneframe missing,heldMsundefined, andUI_SYNC_RUN_RECORDEDnull.5867f40aeremovedactivity: activity.storefromapp.ts. Heavy feedback run 44736962153 failed exactlyAPP_UI_SYNC_RUN(unit (2) and determinism (1)), and nothing else in those categories failed. The next commit,12829ec10, restored it.LATE_PROCESS_KILLED.HELD_PIPE_STREAM_ENDS.PRESTART_STREAM_ENDS.PRESTART_KILLED.HELD_PIPE_STREAM_ENDS.clearTimeoutonce the sync has started failsSTARTED_SYNC_NOT_KILLED.SLOW_READER_GETS_FINAL_LINE.SILENT_SYNC_FINAL_LINE_KEPT.START_REPORTED_BEFORE_WORKER_RUNS).bun run typecheckpasses.sync-reservation,sync-mirror,host-version-requirements) need user namespaces, which this host lacks. They fail here on unchanged main too, so hosted heavy feedback and CI are their proof.Collisions
bun scripts/collisions.ts --json --pr 4258at heada111ec0bddeb536b42ba27e50650cbfab6c1706c: closure-only overlaps with #3056, #3059, #3069, #3581, #4151, #4234 and #4262, through shared affected test closures. No path collisions.Refreshed by merging
origin/main(d88c227c6). Main touched none of this PR's files, so thecheck:prreceipt below is from the last real change,0686c841f.{"version":1,"kind":"brain-check-pr-receipt","head":"0686c841fce4fd0abfe23faf3e2063860f5d508c","base":"origin/main","mode":"focused","startedAt":"2026-11-20T14:10:53.922Z","finishedAt":"2026-11-20T14:11:39.303Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13021.033517999998},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":137.09244000000035},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":78.80242899999939},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":19.794215000001714},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":32106.876057999998}]}🤖 Generated with Claude Code