Skip to content

ui-server: a UI sync whose launch never settles holds "already running" until restart, and its failure is never recorded #4257

Closed

Description

@schlessera

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
    syncingRoots entry.
  • 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

Acceptance criteria

  • A test whose boundary.launch never 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

  1. added
    type: fix
    area: ui-server
    priority: p1
    agent-ready
    on Nov 20, 2026
  2. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    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.

  3. self-assigned this
    on Nov 20, 2026
  4. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    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.

  5. added this to the 0.45.0 milestone on Nov 20, 2026
  6. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Delivered by #4258, squash cb4236234c1cce1f45d034e9eb34d15eda41f934, milestone 0.45.0.

    • A UI sync's start is bounded at 120 s: the CLI probe, the writer gate, the launch and, on a hosted install, the mirror lock, startup view and origin probe. Past the bound it ends with reason: "launch_timeout", the brain is released, and a late or unstarted launch is killed. A started sync is never bounded.
    • Once the process exits, output pipes that stay open and idle are released after 10 s, counted from the exit. A slow reader still gets every line.
    • A 409 carries heldMs and names the hold in seconds.
    • Each UI sync is an Activity run (jobName: "ui-sync") with its exit status and last error lines. A failure logs ui sync failed.
    • The tests carry failing-first and mutation receipts, plus a hosted mutation of the app wiring. Seven fresh-context reviews are recorded on the PR. Automatic main proof for the squash was pending at merge.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: ui-serverpriority: p1type: fix

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions