Skip to content

ui-server: interactive requests emit before duplicate-id admission #724

Closed

Description

@schlessera

Context

During #584 review, askUser and askUserList were found to send their request frame and waiting status before checking whether the request id belongs to another pending ask. The collision rejects the backend promise only after clients have already been sent a card. See askUser at packages/ui-server/src/ws/bridge.ts:227-255 and askUserList at :257-287, in PR #721, head f0178d72. Source audit also found emit-before-admission in requestPermission (:129-219), getLocation (:300-324) and requestMask (:325-348); generated ids make the latter collision path less ordinary, but they share the ordering. This ordering predates #584 for ordinary/list collisions; the new rank method checks and registers before emitting.

Out of scope

Do not redesign the ask protocols, change tool payloads, or change ordinary valid requests.

Scope

Check ask collision admission before a request becomes visible, across the shared cancellation id space; audit the adjacent interactive methods identified above for the same failure shape. The current-source WsHost/dispatch reproduction below confirms the rejected cross-kind asks become visible. Preserve existing admission predicates and valid request behavior while moving refused-request visibility after admission; audit the adjacent methods for that same ordering.

Acceptance criteria

  • A duplicate id across pending ask kinds rejects without emitting a second request or waiting status.
  • The original request remains pending and can be answered or cancelled normally.
  • Cover each ask entry point in a runtime host/socket test, and mutate the emission order to prove the test observes the unwanted card.

Verification

Use the existing fake backend/client host tests; record both emitted frames and the original pending promise. Tests remain keyless and network independent.

Contract impact

None intended: duplicate requests are already rejected, and valid frames and payloads stay unchanged.

Current-source runtime reproduction — 2026-10-01

Main 35fb78d40542426b9bac4a1c3a2a32cf43803837, Bun 1.3.14, using the production WsHost and WebSocket connection/dispatch handlers, the existing in-memory test catalog and a scripted backend/client. No TCP or provider call was needed.

The backend opened a rank request with id same, then attempted either an ordinary ask or a list ask using that pending id. Both duplicate promises rejected with Duplicate ask-user request id, but the client had already received the second request frame and its waiting status. Each “no additional frame” assertion failed: expected 0 frames, received 2. The original rank remained pending and its normal client response subsequently resolved to the submitted non-empty id order. A duplicate rank control rejected with no additional frame and passed. These were behavioral failures after successful host setup.

Fresh source review at main cac8d11b731509cad372345763313e54d4e3c53c locates askUser (packages/ui-server/src/ws/bridge.ts:228-258), askUserList (:259-291), askUserRank (:292-302), askUserForm (:304-314), requestPermission (:130-223), getLocation (:315-339) and requestMask (:340-364). Rank and form already admit/register before emission. collidesAcrossTurns (packages/ui-server/src/ws/turns.ts:411-426) checks another turn; do not silently broaden same-turn/id policy as part of the emission-order correction. Exercise the existing rejected-collision paths in the runtime matrix and preserve original promise/answer/cancellation behavior.

The reproduction gap is resolved for ordinary/list cross-kind emission. Existing acceptance criteria own the adjacent-method audit and mutation proof during implementation. Wanted, unscheduled correction is p2.

2026-10-01 triage: reproduced ordinary/list duplicate emission through the real WsHost/dispatch handlers with a pending rank ask. Both duplicates rejected but emitted two unwanted frames; the original still answered normally. The rank duplicate control emitted nothing and passed. Updated the body to separate emission ordering from changes to existing admission predicates. Priority p2; the reported reproduction gap is resolved.

2026-10-01 readiness review: verified the ordering against main cac8d11b and refreshed the method pointers after conditional-form work. No additional design or policy ruling is needed; retain all existing collision predicates.

2026-10-01 completion: PR #768 merged as 6280c38ef5a1474721709299fad19fd44d90fdad, verified on main. All three criteria are met: 39 runtime connection/parser/dispatch scenarios cover identity, absence of duplicate frames, original answer/cancellation and pre-emission registration; seven independent restored mutations fail the intended no-additional-frame assertion. Current-head CI passes 8,176 unit/integration tests (45 existing skips), 1,703 browser tests and every type/build/package/contract gate. The concurrent #767 base change contains only core test-calendar fixtures and CONTRIBUTING; all server implementation/tests remain identical to the tested merge and the squash tree matches the computed combined merge.

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.
    needs: reproBlocked on a reproduction.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    and removed
    needs: reproBlocked on a reproduction.
    on Sep 30, 2026
  2. schlessera commented on Oct 1, 2026

    @schlessera
    OwnerAuthor

    2026-10-01 triage: reproduced ordinary/list duplicate emission through the real WsHost/dispatch handlers with a pending rank ask. Both duplicates rejected but emitted two unwanted frames; the original still answered normally. The rank duplicate control emitted nothing and passed. Updated the body to separate emission ordering from changes to existing admission predicates. Priority p2; the reported reproduction gap is resolved.

  3. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Oct 1, 2026
  4. self-assigned this
    on Oct 1, 2026
  5. schlessera commented on Oct 1, 2026

    @schlessera
    OwnerAuthor

    Claiming #724 for admission-before-emission, with valid request policy unchanged. Claim token 724-01a0f278; intended branch fix/724-interactive-admission-01a0f278. I will verify source pointers, exercise the real host/dispatch paths and record restored emission-order mutations before current-head CI and merge.

  6. schlessera commented on Oct 1, 2026

    @schlessera
    OwnerAuthor

    2026-10-01 readiness review: verified #724 against main cac8d11b731509cad372345763313e54d4e3c53c and parent #734. Refreshed the method pointers after conditional-form work. Ordinary/list asks, permissions, locations and masks still emitted before existing admission checks; rank/form already register first. The fix preserves those predicates, remembered grants and disconnect policy. Runtime tests will observe both the unwanted frames and the original pending promise. No additional design or policy ruling is needed.

  7. schlessera commented on Oct 1, 2026

    @schlessera
    OwnerAuthor

    2026-10-01 — Completed in PR #768, squash 6280c38ef5a1474721709299fad19fd44d90fdad, verified on main. Duplicate interactive requests now pass existing admission rules and register before any card/waiting frame; the original remains answerable or cancellable. Collision/permission/disconnect policy and wire schemas are preserved.

    All 39 new runtime connection/parser/dispatch scenarios pass. The final harness fails behaviorally on the old implementation (16 pass / 23 fail); seven independent restored emission-order mutations fail precisely at the no-additional-frame assertion. Local affected checks pass 1,497 tests plus strict typecheck, lint and all workspace builds. Current-head CI passes 8,176 tests, 45 existing skips, zero failures and 1,703 browser tests, with all ten jobs and the contract gate green. The tested synthetic merge names head 1a1ade90 and base f19da8b0. Concurrent PR #767 adds only core test-calendar fixtures and CONTRIBUTING; the squash tree matches the computed combined merge, and the server implementation/tests and owned docs equal the tested merge. Patch changeset and source citation repairs are included.

    Nothing remains for #724. Parent #734 stays open for the explicitly required #584/#585 device and live-agent receipts.

  8. added this to the 0.40.0 milestone on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions