Repository navigation
Conversation
…handling Addresses review defects and simplifies pinned-session gateway implementation: - Default absent/null replayFrom to ReplayMode::None for both session/new and session/resume in pinned mode (including cold restore over large transcripts). - Isolate orphaned held prompts from the shared 128 active pending cap (bounded separately at 256) and enforce a 32 per-attachment cap after verifying agentkit-acp withdrawal cancels the entire idempotency group. - Truncate _kit_current_turn gracefully when the turn start is evicted, marking result._meta["kit/gateway"].replayTruncated = true. - Reap expired pinned attachments and leaked startup drivers on the actor deadline timer and bound parked cold-startup joiners. - Restrict unsupported-method target declines to -32601 only, buffer winning relayed client replies across child-stdin backpressure, and cancel pending relayed requests on child exit. - Fix session/list cwd filtering and foreign sessionId checks, update docs, deduplicate gateway actor paths, and add regression and real-child integration tests.
… reaping Addresses second review of pinned-session gateway mode: - Budget pending relayed requests and existing queued events/bytes inside _kit_current_turn replay trimming so joining with a full journal and pending relay succeeds. - Record idempotencyKey on Pending and re-parent matching orphaned held session/prompt entries in place without forwarding duplicate attempts to the child. - Run pinned attachment reaping only on the actor deadline timer arm after draining ready commands so a paused process does not reap an attachment with a queued Poll. - Track detached relay targets so a -32601 from the last present target does not prematurely decline a request while another target is mid-reload. - Deduplicate Attachment::poll, resident MCP-server conflict checks, supported ACP method checks, and startup driver/waiter delivery in output(). - Restore default-mode sentence in docs/user/gateway.md verbatim to main and clarify group cancellation, reaper semantics, child PendingPrompts caps, re-parenting, and mid-message truncation in docs/reference/gateway-protocol.md.
…hans, and deflake eviction test Addresses final review items for pinned-session gateway mode: - Deflake pinned_session_new_without_replay_from_defaults_to_none_and_survives_eviction by filling the journal across 6 client-acknowledged 1.6 MiB rounds instead of a single 10 MiB burst that could overflow c1 before polling. - Guard re-parenting against cancelled orphans (both withdrawal_pending and already-enqueued cancellations by clearing idempotency_key on cancel). - Reserve startup headroom for bounded pending relayed requests in start replay so a complete full journal with a pending relay succeeds and replay_unavailable is returned only when the history itself cannot be replayed in full. - Update docs/reference/gateway-protocol.md to document mandatory DELETE on client disconnect (no TCP-drop reaping) and that re-parented retries reuse the original held prompt body.
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Shadow auto-approve: would not auto-approve because issues were found.
This PR changes concurrency-sensitive code such as locks, queues, or retries. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Pinned mode can create a second transcript under the pinned ID and reattach a retry to a cancelled prompt. Relay handling can accept answers after the deadline, discard supported extension replies, commit invalid results, or stop the shared child on writer saturation. Pending relays can also consume the queue headroom needed to deliver a full replay.
Took 26 min
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Default-mode relay IDs can collide across sessions on one connection, routing an answer to the wrong session. Default mode also discards the response route before validation, so a rejected answer prevents the same controller from submitting a correction. Current-turn replay can reject startup when an oversized update precedes an otherwise replayable tail. All seven prior findings remain active.
Took 17 min
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
A child exit can drop a queued relay cancellation. Pinned-session startup can falsely report conflicting owners for a legacy transcript or create a new session in the first approved project when cwd is omitted. Three prior findings remain active: invalid form choices can win relay arbitration, relay IDs can collide across actors on a multiplexed connection, and an oversized interior replay frame can block reconnection.
Took 24 min
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Three new findings: an oversized relay can close the entire HTTP connection, a null relay result is mistaken for a request, and a capable controller cannot enable forms in a resident session started by a headless controller. Four prior findings still apply: oversized interior updates can block current-turn replay, queued relay cancellations can be lost on child exit, a single legacy transcript can be counted as multiple workspace owners, and first pinned startup can choose a workspace without an explicit cwd.
Took 12 min
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would not auto-approve. Auto-approval blocked by 6 unresolved issues from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Default controller replacement drops outstanding agent-to-client requests from the old HTTP connection without cancelling them there. Seven existing findings remain active: replay truncation, child-exit cancellation draining, legacy transcript ownership, implicit workspace selection on first pinned creation, oversized relay frames, null response routing, and form capability after takeover.
Took 17 min
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Oversized live updates can terminate multiplexed HTTP connections, startup relay reservations can hold roughly 64 MiB of copied payload per joining attachment outside its live queue budget, and the protocol reference promises a warning for client-reported errors that the gateway does not log. Two existing findings remain active: a capable controller cannot enable forms on a resident child initialized by a headless client, and a displaced controller does not receive cancellation for its unanswered relays.
Took 11 min
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds a major gateway feature: pinned multi-client sessions, relayed agent-to-client requests, new replay cursors, and SSE keep-alives. It changes session access and the public protocol contract, so it needs human sign-off.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Three existing findings remain valid: oversized live updates can terminate a multiplexed HTTP connection; startup relay copies can retain roughly 64 MiB of serialized payload per joining attachment outside its live queue budget; and the protocol reference incorrectly promises an HTTP warning for non--32601 client error responses. No new findings.
Took 5 min 56 sec
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds pinned-session multi-client mode, relayed agent-to-client requests, new replay cursors, and SSE keep-alives, plus session-ownership changes. This changes the gateway trust boundary and public protocol contract, so it needs human sign-off.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
The new per-frame guard can report an oversized default-mode response as a controller takeover, causing the bundled client to stop instead of recovering. In pinned mode, one oversized update can disconnect every live attachment even when none of their queues is full; the reference does not describe that case.
Took 7 min 16 sec
…-out frame limits
There was a problem hiding this comment.
2 issues found across 6 files (changes from recent commits).
Confidence score: 3/5
- In
src/gateway.rs, the oversized-response fallback can still exceedMAX_HTTP_FRAMEwhen the request ID is unbounded, causingpush_to_attachmentto retire the attachment instead of returning the bounded error. Bound the request ID in the fallback. - In
src/gateway.rs, queue admission can mask an oversized update asqueue_overflowwhen the attachment is full. Check the frame limit before queue admission so callers getframe_too_large.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/gateway.rs">
<violation number="1">
P2: Queue admission runs before frame-size admission, so an oversized update on a full attachment is reported as `queue_overflow` instead of `frame_too_large`. Check the frame limit first to preserve the independent per-frame contract.</violation>
<violation number="2">
P2: The oversized-response fallback copies an unbounded request ID, so it can exceed `MAX_HTTP_FRAME` itself. `push_to_attachment` then retires the attachment instead of returning the documented bounded error; enforce an ID budget before accepting the request or handle this impossible-to-fit response before enqueueing it.</violation>
</file>
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
An oversized live update can still masquerade as a controller takeover when the attachment has little queue headroom. When the gateway does report frame_too_large, the bundled client's full-replay recovery can hit the same frame again and lose the original failure reason.
Took 7 min 57 sec
…frame_too_large recovery cause
There was a problem hiding this comment.
0 issues found across 5 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds pinned-session multi-client mode, relayed agent-to-client requests, new replay cursors, and SSE keep-alives. The gateway trust boundary and public protocol contract are the decisive factors.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds pinned-session multi-client mode, relayed agent-to-client requests, new replay cursors, and SSE keep-alives; the shared trust boundary and new public protocol contract are the decisive factors.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds pinned-session multi-client mode, relayed agent-to-client requests, new replay cursors, and SSE keep-alives; the new shared trust boundary, expanded interactive-request exposure, and public protocol changes are the decisive factors.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds pinned-session multi-client gateway mode, relays agent-to-client requests in both modes, and adds replay cursors/SSE keep-alives plus recovery/error changes; the new shared trust boundary and expanded interactive-request exposure require human sign-off.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would require human review. Adds pinned-session multi-client gateway mode and relays agent-to-client requests in both modes, plus new replay cursors, steer passthrough, and SSE keep-alives; the expanded shared trust boundary and interactive-request exposure need human sign-off.
View guided diff | Turn on auto-fix | Re-trigger cubic
Summary
Adds
kit gateway --pinned-session <id>: one gateway process serves one session to many ACP-over-HTTP clients at the same time. The gateway now also relays agent-to-client requests and supports replay cursors in both modes, so pinned mode differs from the default mode only in what many attachments require.Motivation
A gateway session has one controller: a second attach replaces the first and withdraws its held prompts, and updates reach one client. Hosting one Kit process per conversation needs several clients on one session: a UI, a short-lived deliverer that submits a prompt and leaves, and an operator, with an authenticating proxy in front.
The default mode also refused agent-to-client requests such as
ask_userand offered replay only from the start. Neither limit had a protocol reason. Lifting them for both modes keeps the pinned-only surface small.Impact
Both modes:
elicitation/create) is offered to attached clients whose owninitializedeclaredcapabilities.elicitation.form; permission requests go to every attached client. The first well-formed answer wins and the other clients receive a cancellation. With no eligible client attached, the child gets-32601at once, as before.--client-request-timeout(default5m). Form content is validated by the child, not the gateway.elicitation.formand nothing else. A client that declares{}sees no change and is never sent a request.{"type":"_kit_current_turn"}and{"type":"_kit_message", ...}join{"type":"start"}. A current-turn replay that no longer fits is trimmed and flagged with_meta["kit/gateway"].replayTruncated.kit/subagent/steeris accepted as a session-scoped passthrough.Pinned mode only:
session/newandsession/resumeboth attach to the pinned session; any other session id is rejected.session/closedetaches the caller and does not end the session. The session is bound to the approved project that already holds its transcript.session/updatethrough its own bounded queue; one that overflows is dropped alone. Replies go to the sender.idempotencyKeytakes over the orphaned entry and is not forwarded to the child again. An explicit$/cancel_requestwithdraws every held attempt that shares the key.replayFrommeans no history.elicitation.formis always advertised to the child, because the first client to attach may be a headless one. 32 pending requests per attachment, 128 shared.Technical details
agentkit-acpcancels its whole idempotency group, so pinned mode keeps orphaned prompts and re-parents them on retry instead of withdrawing them.DELETEwhen a client disconnects; the gateway does not detect a dropped connection.replayFromtype now returns-32602, and a response-shaped frame from a client is no longer answered with an error.Not covered
session/forkandsession/deletethrough the gateway. They need coordination with the gateway's session registry.ask_user, and the TUI against a pinned gateway, were not exercised end to end.Last-Event-ID. It needs per-stream event ids and a bounded replay buffer inagentkit-acp-http.