Skip to content

ui-server: a refused finish record leaves the turn open until restart and stops other turns #4448

Open

Description

@schlessera

Part of #4426 (follow-ups from #4278). Deferred from the review of PR #4447. The first point is also on main.

Context

In finish (packages/ui-server/src/brain/turn-journal.ts:1014-1049), the single finish-record write (:1036-1042) can be refused by capacity or a pinned WAL. Two things follow:

  • The rejection leaves held() with completed=false (:501-513). The scope observer then SIGKILLs every held turn's workers and stops those turns (packages/ui-server/src/brain/turn-scope.ts:289-298), although the shared final observation succeeded.
  • The turn is already out of active, so a retried finish returns at once, and ended_at stays NULL until restart recovery. Until then collectOne (:657) never collects the turn, and the worker scrub skips with journal_busy (packages/ui-server/src/brain/journal-scrub.ts:30).

The regression test a refused finish write removes the ended turn before the next note observation counts scrubObjects calls, so it passes while the scrub is skipped.

Scope

Finish-record refusal handling in turn-journal.ts, and its tests. No change to the scope observer's handling of a failed observation.

Acceptance criteria

  • A refused finish record after a successful final observation resumes other turns' held workers; a failed observation still stops them.
  • The ended turn's terminal record is retried without a restart (on next admission, a finish retry or idle maintenance), and ended_at is set once storage admits it.
  • After the retry, idle scrub returns a non-skipped result and the turn's objects are collectable.
  • The regression test asserts the scrub result, not the call count.
  • Mutation receipts for both the resume and the retry.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: fixSomething is broken and must behave the way it is documented.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions