Repository navigation
Description
Context
The UI's Sync button can get stuck reporting "already running" until the server
restarts, and the reason a sync failed is never recorded on the server.
POST /brain/sync (packages/ui-server/src/routes/brain.ts:113-231) marks the
brain in the in-memory syncingRoots set (:118-121) and only clears it in the
finally of the SSE callback (:229). If anything before the sync process exits
never settles (the probeBrainCliVersion call at :150, boundary.launch at
:155-162, or waiting on its output), the set keeps the entry forever. Every
later request then gets 409 A sync is already running, with no process running.
Observed on a hosted install at main bd751d434. One Sync tap returned 200 and
opened the stream. The phone reported "Network error" almost immediately, and
all later taps got 409. The container had no brain sync, git or worker
process. The maintenance-temp ledger had earlier refused a cron job with
Maintenance temporary storage is busy … (held by: git). Only restarting the
server process cleared the 409.
Separately, the route sends the sync's progress and failure text only to the
SSE client (:163-226). The server log records just the request line, and a UI
sync writes no run row (scheduled syncs do, under cron_runs). When the
client disconnects, which is exactly when the user cannot see the result, the
failure text is lost. In this case the real failure was
maintenance output cannot change protected input context/policies/governance.md
(#4256). It could only be found by replaying the request through the
server.
Scope
- Bound the time between accepting a sync and its process starting. If launch or
the CLI probe does not settle, refuse with a named reason and clear the
syncingRootsentry. - Record each UI sync's outcome and its final error lines where the owner can see
them after a disconnect (an Activity run, like the scheduled sync), and log the
failure line on the server. - The 409 says how long the running sync has held the brain, so a stale hold is
visible.
Out of scope
- Why the launch stalled in the observed case (the maintenance-temp reservation
or writer gate). File that separately if the bounded launch shows a cause. - Changing what sync does, its merge strategy or the hosted-agent rule.
- The tier A policy refusal itself (ui-server: a hosted brain has no supported way to change its governance policy; an upstream policy commit blocks every sync #4256).
Acceptance criteria
- A test whose
boundary.launchnever settles shows today's permanent 409. After
the change, the request ends with a named refusal and the next request is
accepted. - A UI sync whose client disconnects mid-stream records its exit status and
last error lines in Activity, and logs the failure line. A test asserts both. - A test asserts that a 409 names how long the current hold has lasted.
Verification
Unit tests on the route with a stubbed boundary, plus one integration test
through the fixture corpus. Each new test is shown failing on the tree before the
change.
Contract impact
Additive: a new refusal reason, the 409 body field, and a sync run kind in
Activity, if the last is exposed through the HTTP API.
Activity
schlessera commentedon Nov 20, 2026
Triage (maintainer, 2026-11-20): priority p1. The stuck 409 leaves hosted sync unusable until a restart. The scope and acceptance criteria are complete as written, so this is agent-ready.
schlessera commentedon Nov 20, 2026
Claimed for implementation. Claim token:
claim-a038321e. Branch:fix/4257-bounded-sync-launch.No path collisions; closure-only reports from open drafts touching ui-server.
test(ui-server): MUTATION, reverted next commit: drop the UI sync Act…
CONTRACT: fix(ui-server): restore the UI sync Activity wiring and rec…
CONTRACT: fix(ui-server): bound a hosted sync until its first worker …
fix(ui-server): release a UI sync's reservation without waiting for i…
test(ui-server): the hosted start-report test runs a worker that writ…
fix(ui-server): count the output grace only while a pipe sits open an…
fix(ui-server): count a pipe's idle grace from the sync's exit (#4257)
CONTRACT: fix(ui-server): bound a UI sync's launch and record its out…
schlessera commentedon Nov 20, 2026
Delivered by #4258, squash
cb4236234c1cce1f45d034e9eb34d15eda41f934, milestone 0.45.0.reason: "launch_timeout", the brain is released, and a late or unstarted launch is killed. A started sync is never bounded.heldMsand names the hold in seconds.jobName: "ui-sync") with its exit status and last error lines. A failure logsui sync failed.