Skip to content

ui-server: a turn stays busy until its queued index update has settled #4303

Open

Description

@schlessera

Blocked by #4281

Context

Part of #4278.

When a turn's host applications queued an index update, the turn settles that update before it closes (await held.settleIndex?.(), packages/ui-server/src/ws/session-run/turn.ts:103 and :126; the settler, packages/ui-server/src/ws/bridge.ts:196). Only afterwards do egress settlement, the final journal observation and the idle status follow. Until idle the session is busy and the next message waits.

The answer is already complete at that point. Whether the wait matters is not known: the closing bracket on a hosted install is 1.30 s at the median and 2.71 s at p90, with a 4.6 s p90 on a wider cohort, and nothing separates the index part from the rest. On a local fixture, publishing a changed index database of about 100 MB takes about 0.6 s. The joined projection in #4278 therefore credits this change nothing.

#4281 adds the missing clock. This issue acts on what it shows.

Scope

  • Read the index-settle step from hosted lifecycle records once ui-server: the end of a turn is one unattributed bracket, and its end stamp precedes the idle status #4281 has shipped: how often an update is pending at turn end, and how long it takes.
  • If it is material: let the turn report idle once its receipts, egress records and final observation have settled, while the index update completes afterwards. Conditions:
    • the pending update survives a restart, or is recoverable by a bounded reconcile;
    • a later tool that reads the index still waits for the generation that contains its own session's writes, or fails with a scoped "index not current" result. It never silently reads a stale index (the tree and index batch barriers at packages/ui-server/src/ws/bridge.ts:183-196);
    • a failed update is recorded and retried, and is visible to the owner.
  • If it is not material: record the numbers here and close as a documented no.

Out of scope

Acceptance criteria

  • The issue records the measured frequency and duration of a pending index update at turn end, from lifecycle records.
  • If changed: with a fixture that delays the index update by a known time, idle is emitted without waiting for it, and a search issued by the next turn waits for the update and returns the new content.
  • If changed: a server restart between idle and the update's completion leaves the update pending and it completes after the restart, by a test.
  • If changed: a failed update produces a recorded, retried outcome and a scoped refusal for a read that depends on it.
  • A test covering any change fails on the tree before the change and passes after.

Verification

bun run test packages/ui-server/tests
bun run typecheck
bun run lint

Contract impact

  • This touches the integration contract, unless the application outcome's index field changes meaning (docs/integration-contract.md, the application index outcome). Check before coding.
  • This changes a published package's behaviour, so it needs a changeset.

2026-11-20 triage at main 63bb400b3. The current end-of-turn wrapper catches the settler rejection (packages/ui-server/src/ws/session-run/backend-entry.ts:129), while the batch tracks outcomes and subsequent reads use a barrier. #4281 must supply the hosted closing-clock evidence. If the outcome or its documented timing changes, update the contract before shipping that branch.

Activity

  1. added
    type: feat
    area: ui-server
    blocked
    on Nov 20, 2026
  2. added
    agent-ready
    priority: p2
    needs: release
    and removed
    agent-ready
    on Nov 20, 2026
  3. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    2026-11-23 triage at main a3395c4b2: removed agent-ready. It predates the later needs: release, and the two contradict each other. The first scope step reads the index-settle span from hosted lifecycle records, and those exist only once the #4281 closing-phase clock ships in a published release and runs on a hosted install. That clock reached main through #4444 (squash a3395c4b2, via #4322). #4281 itself stays open for a named remaining gap, so blocked stays too.

    What completes needs: release: a published @schlessera/brain-ui-server version that contains a3395c4b2 (check npm latest), plus hosted lifecycle records produced by that version. When that holds and #4281 is closed, remove needs: release and blocked and restore agent-ready. The brief is otherwise complete.

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

    area: ui-serverblockedneeds: releasepriority: p2type: feat

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions