Skip to content

ui-server: a deferred scope refusal answers the relay before its egress record commits #4401

Open

Description

@schlessera

Part of #4278. Deferred from the first review of PR #4395 (#4292).

Context

  • On a deferred scope refusal, the relay calls denied("deferred_observation_refused") (packages/ui-sdk/src/server/inference-relay.ts:216-221).
  • finish submits the egress_connection record through track() without awaiting it (packages/ui-server/src/brain/turn-egress.ts:140-150).
  • The scope pause is already durable, but a crash in that window leaves a paid request with no connection record.
  • deferred-freeze.test.ts:219 checks only the scope row.

Scope

On the deferred-refusal path only, wait for the turn's pending egress records before answering. Other denials are unchanged.

Acceptance criteria

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: p3Someday. Needs a driving use case before it starts.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 21, 2026
  2. schlessera commented on Nov 21, 2026

    @schlessera
    OwnerAuthor

    Added from the second review of PR #4395 (same theme): a deferred scope refusal can be left unpersisted, or recorded under the wrong reason.

    • The confirmed deferred hold waits for scope writes through settled() (packages/ui-server/src/brain/turn-scope.ts:272-274), whose tails swallow results (:42-47). save returns false when nothing was stored (:66-68), and nothing acts on that.
    • The relay finishes the egress record as upstream_unreachable before the answer gate (packages/ui-sdk/src/server/inference-relay.ts:225-229), so the gate's deferred_observation_refused finish (:131-133) is a no-op. The cancelled and credential exits have the same order.

    Additional acceptance criteria:

    • A cap pause whose save matches no row stops the turn as unrecorded, with a test.
    • An upstream failure during a capped deferred observation records deferred_observation_refused, with a test.
    • Every exit that finishes before the gate is checked for the same order.
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: p3Someday. Needs a driving use case before it starts.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