Skip to content

ui-server: the four ask-user kinds apply different duplicate-id rules #2773

Open

Description

@schlessera

Part of #734. Split from #2515, which keeps today's collision behaviour while it encapsulates the coordinator state.

Context

The four ask-user kinds share one id space for cancellation (// Cancellation shares one id space across all four ask kinds., packages/ui-server/src/ws/bridge.ts:505), but each kind checks a new request id against pending ones differently:

  • ask_user and ask_user_list call collidesAcrossTurns on their own map (askUser, packages/ui-server/src/ws/bridge.ts:440-447; askUserList, same file:471-480). That refuses, and logs an ERROR, only when the existing entry belongs to another turn (collidesAcrossTurns, packages/ui-server/src/ws/turns.ts:771-785). A same-turn duplicate of the same kind is accepted and set overwrites the earlier entry, whose promise is then never settled. Against the other three maps they use plain .has(), which refuses any turn's entry without logging.
  • ask_user_rank and ask_user_form use plain .has() across all four maps (askUserRank, packages/ui-server/src/ws/bridge.ts:504-508; askUserForm, same file:516-520). They refuse same-turn and cross-turn duplicates of every kind and log nothing.

Resulting matrix today:

same kind other kind
same turn ask_user/ask_user_list: accepted, earlier entry overwritten. rank/form: refused, no log. refused, no log
other turn ask_user/ask_user_list: refused, ERROR logged. rank/form: refused, no log. refused, no log

#724 delivered admission before emission for these paths; #734's definition of done requires that no duplicate frame settles another request. Which ids are accepted is observable to backends, so the rule is a ruling, not a refactor.

Maintainer decision (2026-10-24)

Option A: refuse every request ID already pending across all four ask-user kinds, whether the same or a different kind, in the same or a different turn. Log one consistent ERROR record for each refused duplicate. Preserve the original pending request, its promise and its answer/cancellation identity; do not overwrite or emit the refused duplicate. The stricter behavior for same-turn retries is explicitly approved as a compatibility restriction.

Scope

Apply option A to all four kinds in one shared admission check with one ERROR log shape, preserving admission before emission and the original request.

Out of scope

Acceptance criteria

  1. Every duplicate cell of the historical matrix above is refused under option A for all four kinds, proven by a table-driven test over the 4 kinds × same/other turn × same/other kind that fails on the current tree for at least one cell.
  2. Each refused duplicate logs one ERROR with the same record shape for every kind.
  3. A refused duplicate leaves the original pending entry untouched; its original promise can still settle from its own answer or cancellation. The duplicate is refused without overwriting or emitting it, proven by a test.
  4. Mutation receipt: revert one kind to its old check and the table test fails on that cell.

Verification

bun run test packages/ui-server, tsc --noEmit, bun run lint, then bun run check:pr --base origin/main.

Contract impact

Option A narrows previously accepted same-turn/same-kind IDs for ask_user and ask_user_list. The maintainer explicitly approves this breaking supported-behavior restriction. Add contract and breaking, document the shared duplicate-ID rule in the chat-UI tools contract in the same CONTRACT: commit, and ship a minor changeset naming the break while pre-1.0. No wire frame/schema change; approval, location and mask collision policies are unchanged.

2026-10-24: filed from #2515's review finding; waits on the ruling in the first comment.

2026-10-24 maintainer ruling: selected A and incorporated uniform pending-ID refusal, consistent ERROR logging, original-request preservation and approved compatibility restriction. The earlier matrix documents the pre-change behavior.

Activity

  1. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Decision needed: which duplicate-id rule do the four ask-user kinds share?

    Today the rule depends on the kind (matrix in the body): ask_user and ask_user_list accept a same-turn duplicate of their own kind and overwrite the earlier entry, leaving its promise unsettled, and log an ERROR only for a cross-turn duplicate of their own kind. ask_user_rank and ask_user_form refuse every duplicate, of any kind and any turn, and log nothing. Cross-kind duplicates are refused silently for all four.

    Options:

    • A. Refuse every pending id, for every kind and turn, and log one ERROR. This is the rank/form rule plus logging. It is the strictest and matches "no duplicate frame may settle another request". A backend that retries ask_user with the same id inside one turn now gets a refusal instead of a silent replacement.
    • B. Allow a same-turn, same-kind reuse to replace the pending request; refuse everything else and log. This is the ask_user rule for all four kinds. The replaced request must then be settled explicitly (for example rejected as superseded), which today it is not.
    • C. Keep the per-kind rules and only unify the logging. No behaviour change; the documented asymmetry stays.

    Recommendation, not a ruling: A, because the overwrite path is the one that can leave a promise unsettled. A documented "no change" (C) is also an acceptable outcome that closes this issue with a docs update.

  2. added
    type: fix
    area: ui-server
    priority: p2
    needs: decision
    on Oct 24, 2026
  3. schlessera commented on Oct 24, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-10-24): Option A. Refuse every ID already pending across all four ask-user kinds, for the same or another kind and the same or another turn. Log one consistent ERROR record per refused duplicate. Preserve the original request and promise; no overwrite or duplicate frame emission. Explicitly approve the stricter same-turn retry behavior as a breaking supported-behavior restriction, with contract documentation and a pre-1.0 minor changeset naming it. The body and acceptance criteria now select this rule; the decision is resolved.

  4. added
    contract
    breaking
    agent-ready
    and removed
    needs: decision
    on Oct 24, 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-readyarea: ui-serverbreakingcontractpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions