Skip to content

fix(chat): relay remote crew approvals and approval mode to the peer - #16509

Closed
iamwhatever wants to merge 1 commit into
mainfrom
fix/remote-crew-approvals-takeover
Closed

iamwhatever wants to merge 1 commit into
mainfrom
fix/remote-crew-approvals-takeover

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Takes over #10638 by @ashvinnihalani, redone on current main. Thank you, Ashvin: the commit carries your Co-authored-by trailer.

Problem / Motivation

Goal: A chat whose turns run on a connected crew lets the user answer that crew's tool approvals and change its approval mode, YOLO included.

In a chat made with "New chat on crew", the peer gateway runs the tools, but this gateway shows the chat. A peer permission request reached this side as a transcript row with no answerable card, so the peer waited until its approval or turn timeout. Picking Normal, Reads, Trust or YOLO changed only this gateway, so the peer kept asking (#10618).

Why it matters

Remote crew chats stall at every gated tool in an interactive mode, and the approval picker shows a mode the machine running the tools never got.

Not a goal

  • Resume-attach for a relayed turn after a gateway restart.
  • Queued follow-ups, regenerate, rewind or continue on a remote-bound chat (still refused with 409).
  • Changing how the peer itself decides or governs approvals.

What changed (motivation → approach → change)

Symptom: no card, and the mode stays local. Cause: the card is projected from slot._approval_futures, which a relayed turn never filled; the approve and mode routes acted only on local state.

Approach: the peer stays the owner. This side forwards, and changes local state only after the peer accepts.

  • remote_relay._apply_row gives each pending peer permission row a placeholder future, so the existing card renders and is answerable.
  • api_chat_slot_approve on a remote-bound slot forwards the action (and a trust pattern) to the peer slot's /approve. The peer validates trust grants against its own row and governs yolo by its own policy. A refusal returns 502 and keeps the card retryable.
  • The peer's relay drain (chat_utils._build_stream_chunk, relay mode only) sends a permission row's own mid as request_mid; the mirrored row keeps it as peer_request_mid. A peer row without it (an older peer) gets no card and stays a plain transcript line. Allow / Reject / Reject once are forwarded with origin=native and that request_mid, so the peer's own instance check refuses a stale decision for a request that reuses the id; locally only the clicked instance is settled.
  • On a remote-bound chat the composer card's Allow / Reject / Reject once go to the slot route with the row they showed (origin=native, request_mid; website/src/components/chat-input/approval.ts), so a stale card can never decide a later request reusing the id. The generic /api/approvals/{id} route never decides a remote card.
  • The peer's mirrored approval_resolved frame retires the card (peer timeout or peer-side click). When the peer's turn ends, any leftover is recorded as rejected; when the stream is cut or cancelled, the placeholder is only dropped, since the peer may still be waiting.
  • A slot-scoped /api/chat/mode on a remote-bound slot, yolo included, is applied on the peer's slot and writes no mode state here. This gateway's process-wide YOLO override is never armed or ended for it.
  • A remote yolo arms the PEER's process-wide override, exactly as picking YOLO on the peer's own dashboard does: every session on that peer is auto-approved until it expires. Only this gateway's dashboard owner can send it, over the owner's own instance tunnel, and the peer's approval_modes policy decides whether it may arm.
  • Known gap: this gateway cannot verify the peer's resulting mode (a slot-scoped Trust leaves the peer's YOLO armed; a grant can expire there), so a remote-bound chat's picker shows the interactive floor rather than claim a looser mode it cannot prove.
  • ApprovalCoordinator.resolve, the all-sessions Trust / Reads grants and the trust sweep skip remote-bound slots, so nothing settles a card the peer still waits on.
  • Both new peer calls go through deny_non_owner_remote_operation and are pinned in the existing _PEER_SINKS guard.

Versus #10638: its rollback-token protocol, two-gateway YOLO coupling and id-ambiguity changes are left out. All four GPT-lane blockers on #10638 sat in that mechanism. Here a refused peer call changes nothing on either side, so nothing needs rolling back.

Backwards compatibility

Compatible: local slots take exactly the old paths; only executor == "remote" slots branch.

Reader: src/kiro_crew/dashboard/interaction_coordinator.py:ApprovalCoordinator.resolve -- entry: chat (Slack card clicks via state.resolve_approval) -- remote-bound slots are skipped; local slots unchanged; test_a_bare_id_resolver_cannot_settle_the_card
Reader: src/kiro_crew/dashboard/chat_handlers.py:api_chat_mode -- entry: chat -- a remote-bound slot no longer arms this gateway's YOLO; the peer's is armed instead; test_yolo_arms_the_peer_and_never_this_gateway

Tests

New test/test_remote_crew_approvals.py: card appears for a pending peer row and not for a resolved one; peer approval_resolved and turn end retire it; bare-id resolver cannot settle it; Allow / Reject once / Trust / YOLO / scoped-pattern decisions are forwarded and widen nothing locally; peer refusal keeps the card; half-bound slot gets 409 before the peer; Normal / Reads / Trust / YOLO modes forward to the peer; refusal changes nothing; all-sessions trust leaves the peer card pending; exact peer routes and bodies.

test/test_remote_crew_execution.py: _PEER_SINKS now includes the two new sinks.

New cases also cover: a truncated turn records no rejection; a forwarded mode writes no local mode state; a request reusing the id mid-forward stays pending; a row without the peer instance is not forwarded; a row built by the real drain carries its mid through the real reader.

Local at -n 2: test_remote_crew_approvals.py, test_remote_crew_execution.py, test_chat_slot_facade_contract.py, test_dashboard_approval.py, test_chat_mode_security.py, test_error_code_contract.py: 493 passed; ChatInput.approval.test.tsx remote-card case passes (3 pre-existing failures in that file reproduce on main locally).

Manual verification

Not run over a live hub → peer tunnel. Both handlers and the relay boundary are driven directly in tests.

Screenshots / video

Why no screenshot: the only frontend change, website/src/components/chat-input/approval.ts, changes which route a remote-bound chat's card click is sent to (slot route with origin=native and request_mid); nothing it renders changes, and the card itself is the existing one projected from the slot.

Related Issues

Fixes #10618. Supersedes #10638 (to be closed once this merges). #14279 (approval sound for an unanswerable relayed card) is not folded in: the card is now answerable, so the sound is correct.

Pattern harvest

Rule candidate: review-prompt
Pattern: a relayed control plane forwards to the execution owner first and mutates UI-owner state only after it accepts, so no rollback path is needed.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested a review from a team as a code owner October 3, 2026 12:01
@iamwhatever
iamwhatever requested a review from buluoray October 3, 2026 12:01
@iamwhatever iamwhatever mentioned this pull request Oct 3, 2026
5 tasks done
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of d93d857f7a2e16e8f36fe30b60ea8f28cea7466e — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check before merge: no live hub-to-peer run was done. Confirm the peer's real /approve accepts the forwarded origin=native and request_mid body.

What this change ships

Inventory (9 items) — 9 justified

Intent: a user chatting on a connected crew can answer that crew's tool approvals and set its approval mode from this dashboard. FIX (#10618; it closes the "KNOWN GAP" the base relay_remote_turn docstring deferred).

  1. A peer's pending tool request now shows as an answerable approval card in a remote crew chat — justified
  2. Allow, Reject and Trust clicks on that card go to the peer; nothing is widened on this side — justified
  3. The peer's relay stream now tags each permission row with that row's own id (request_mid), so a decision is bound to that row — justified
  4. Picking Normal, Reads, Trust or YOLO in a remote chat now applies on the peer, and YOLO arms the peer's process-wide override — justified
  5. A remote chat's mode picker shows the interactive floor (the strictest mode) instead of the mode just picked — justified
  6. All-sessions Trust and Reads, the trust sweep, and the generic or Slack resolver now skip remote-bound chats — justified
  7. A peer-side decision or peer timeout retires the card here; a finished peer turn records leftover cards as rejected — justified
  8. A cut or cancelled stream only drops the card and records no decision — justified
  9. The two new peer calls go through the owner gate and are pinned in _PEER_SINKS — justified

[FIRST-PRINCIPLES-REVIEWED] d93d857

Description read

[DESCRIPTION-READ] e2aadbc24e09924772e70d5d15255d06e79d0eb200dfb194dc402ae9cee1ac01

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

Design-level review of d93d857f7a2e16e8f36fe30b60ea8f28cea7466e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

After a remote YOLO the picker still shows the interactive floor while the peer auto-approves every session; the hub user can't see that YOLO is armed.

Watch

  • The picker hides an armed peer YOLO. The description says "a remote yolo arms the PEER's process-wide override… every session on that peer is auto-approved". _apply_remote_mode also "writes no mode state here, so the picker shows the interactive floor". So after a successful YOLO pick, the hub shows a tighter mode than the peer is running. Picking Normal is the only off-switch on the peer: a slot-scoped normal calls deactivate. If the picker treats choosing its current selection as a no-op, the user can't send that Normal to disarm the peer from here. Showing a tighter mode than the real one is the unsafe way to be wrong. The reason given ("cannot prove") doesn't fit YOLO: the peer just accepted the pick with 2xx.
    Clears when: a remote-bound slot's picker shows the peer-accepted YOLO (or a distinct "peer YOLO armed" state) until a forwarded Normal succeeds, or a test shows that selecting Normal on a remote slot whose picker already shows Normal still forwards to the peer.

  • The description doesn't match the diff. "Screenshots / video: N/A — no frontend change in this diff" is false. website/src/components/chat-input/approval.ts now sends remote-card clicks to a different route with origin=native and request_mid. Nothing new renders, so this isn't an evidence block, but the stated rationale is wrong.
    Clears when: the description names the approval.ts routing change and why it needs no rendered evidence.

[DESIGN-REVIEWED] d93d857

Description read

[DESCRIPTION-READ] 3ba6ad4ae551fb62fcc1f7829ad1b5d4e75cec5a8097a38c4fe97563e83a057d

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed d93d857f7a2e16e8f36fe30b60ea8f28cea7466e — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] d93d857

Verdict parsed from the review's SHA-scoped output markers for commit d93d857f7a2e16e8f36fe30b60ea8f28cea7466e.

False positive or not applicable? A repository writer can comment:
/ai-review override fable d93d857f7a2e16e8f36fe30b60ea8f28cea7466e: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of d93d857f7a2e16e8f36fe30b60ea8f28cea7466e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d93d857

False positive or not applicable? A repository writer can comment:
/ai-review override gpt d93d857f7a2e16e8f36fe30b60ea8f28cea7466e: <one-sentence reason>

@iamwhatever
iamwhatever force-pushed the fix/remote-crew-approvals-takeover branch from 84cfbfa to 2709d6d Compare October 3, 2026 12:19
@iamwhatever
iamwhatever requested a review from a team October 3, 2026 12:19
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: the picker shows the peer's YOLO for a remote chat span=bac3377f3ed2

A forwarded yolo (mode route or card action) sets a per-slot _remote_yolo, projected as remote_yolo; any other forwarded mode clears it.
slotApprovalMode.ts returns yolo when slot.remote_yolo is set, so sseYolo's gateway-wide false no longer decides that chat's picker.
Pinned by test_yolo_arms_the_peer_and_never_this_gateway (set, then cleared by Normal) and slotApprovalMode.test.ts. Fixed in 2709d6d.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: a remote YOLO's peer-wide reach is now stated span=86ed8f4cdcf7

#10618 asks for YOLO to apply on the executing gateway, and the peer has no per-slot YOLO: its override is process-wide on the peer, same as picking YOLO on the peer's own dashboard.
The PR description, forward_peer_mode's docstring and session.md now say a remote YOLO auto-approves every session on that peer until it expires. The peer's own approval_modes policy still governs it.
Clears via the first branch of the item's Clears-when. Fixed in 2709d6d.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: a cut or cancelled relay records no rejection span=e1c585cfae0d

_retire_relayed_approvals now takes turn_finished=saw_terminator. Only after the peer's terminator is a leftover card marked rejected.
On truncation, error or cancellation it only drops the placeholder future: the row stays unresolved and no approval_resolved is broadcast.
Pinned by test_a_truncated_turn_records_no_rejection_the_peer_never_got. Fixed in 2709d6d.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🔴 BLOCK

UX-level review of d93d857f7a2e16e8f36fe30b60ea8f28cea7466e — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: BLOCK

cannot evaluate: missing screenshots of the approval card in a remote crew chat, and of the mode picker after Trust or YOLO is picked there.

Blockers

The picker contradicts the user's choice. On a remote chat, picking Trust or YOLO forwards the mode to the peer, but this gateway saves no mode state. _apply_remote_mode says it this way: "the picker shows the interactive floor rather than claim a looser mode". The PR text calls this a "Known gap". So a user who just picked YOLO sees the lowest interactive mode, assumes the click failed, and picks it again. Each extra YOLO pick re-arms the process-wide override on the peer. This happens on every remote mode change and confuses the user every time. Fix: show the mode the peer accepted, marked as set on that crew (for example "YOLO · on crew"), and not the floor.

Evidence gaps

  • Approval card on a remote chat: the backend now creates this card, and approval.ts sends its Allow / Reject / Reject once clicks to the peer's slot route. No screenshot shows it. The description says "N/A — no frontend change", but website/src/components/chat-input/approval.ts changed. The blind-read report says "BLIND READ NOT PERFORMED". To close: attach a screenshot of the card pending in a remote crew chat.
  • Peer refusal (502): the card is supposed to stay open so the user can retry. No screenshot shows what the user sees. To close: attach a screenshot of the card after a refused click.
  • Mode picker on a remote chat after Trust or YOLO: no screenshot. To close: attach a screenshot of the picker right after the pick.

[UX-REVIEWED] d93d857

Description read

[DESCRIPTION-READ] 4d0acce0b37f4470a3df0330ce286f0638cffee6903b166f97145030b4437c9f

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@iamwhatever
iamwhatever force-pushed the fix/remote-crew-approvals-takeover branch from 2709d6d to 799788a Compare October 3, 2026 12:27
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: card Allow/Reject reach the peer span=b3098f366144

api_approval_resolve (handlers/sessions.py) now sends an id held only by a remote-bound slot to _approve_on_peer, the same forward the slot /approve route uses.
So the card's Allow, Reject and Reject once reach the peer and settle the card only after the peer accepts; no 404 or false 'expired' notice.
Pinned by test_the_cards_allow_and_reject_buttons_reach_the_peer (all three actions). Fixed in 799788a.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: no false 'expired' notice on a remote card span=62fa88f67e32

api_approval_resolve (handlers/sessions.py) now sends an id held only by a remote-bound slot to _approve_on_peer, the same forward the slot /approve route uses.
So the card's Allow, Reject and Reject once reach the peer and settle the card only after the peer accepts; no 404 or false 'expired' notice.
Pinned by test_the_cards_allow_and_reject_buttons_reach_the_peer (all three actions). Fixed in 799788a.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: the Normal-mode main path forwards span=1b74605200bb

api_approval_resolve (handlers/sessions.py) now sends an id held only by a remote-bound slot to _approve_on_peer, the same forward the slot /approve route uses.
So the card's Allow, Reject and Reject once reach the peer and settle the card only after the peer accepts; no 404 or false 'expired' notice.
Pinned by test_the_cards_allow_and_reject_buttons_reach_the_peer (all three actions). Fixed in 799788a.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: /api/approvals forwards for remote slots span=dc0913312bc3

api_approval_resolve (handlers/sessions.py) now sends an id held only by a remote-bound slot to _approve_on_peer, the same forward the slot /approve route uses.
So the card's Allow, Reject and Reject once reach the peer and settle the card only after the peer accepts; no 404 or false 'expired' notice.
Pinned by test_the_cards_allow_and_reject_buttons_reach_the_peer (all three actions). Fixed in 799788a.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: the YOLO confirmation already says all sessions span=db770a08ebae

The existing YOLO confirmation reads 'All tools will get auto-approved across all sessions.', which is exactly true of the peer a remote chat is bound to.
The chat already names its crew in the header chip (RemoteCrewChip), so the 'which machine' is on screen when YOLO is picked.
A new label or confirmation variant is new UI and i18n surface beyond the Goal.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: card error copy is shared, not new here span=abeff9008cf9

The 502 body carries the peer's own error string, redacted and clamped by _post_to_peer, so it is available to the client.
The card's 'could not submit that decision' notice is the existing shared failure path for every approval route, local ones included; changing what it renders is new card UI beyond this PR's Goal.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: a remote YOLO arms the peer as the Goal asks span=fca7fddcea40

#10618 and the frozen Goal ask for YOLO to apply on the gateway that runs the tools, and the peer has no per-slot YOLO: its override is process-wide, exactly as when YOLO is picked on the peer's own dashboard.
The caller is gated to the dashboard owner (deny_non_owner_remote_operation), the peer is the owner's own connected crew reached on the owner's tunnel credential, and the peer still applies its own approval_modes policy. No other human's authority is borrowed.
The peer-wide reach is stated in the PR description, forward_peer_mode's docstring and session.md.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: the slot-scoped forward is the peer's own mode route span=7b3c2abdbc78

#10618 and the frozen Goal ask for YOLO to apply on the gateway that runs the tools, and the peer has no per-slot YOLO: its override is process-wide, exactly as when YOLO is picked on the peer's own dashboard.
The caller is gated to the dashboard owner (deny_non_owner_remote_operation), the peer is the owner's own connected crew reached on the owner's tunnel credential, and the peer still applies its own approval_modes policy. No other human's authority is borrowed.
The peer-wide reach is stated in the PR description, forward_peer_mode's docstring and session.md.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: the peer's YOLO is global by its own design span=872cfbab4cc5

#10618 and the frozen Goal ask for YOLO to apply on the gateway that runs the tools, and the peer has no per-slot YOLO: its override is process-wide, exactly as when YOLO is picked on the peer's own dashboard.
The caller is gated to the dashboard owner (deny_non_owner_remote_operation), the peer is the owner's own connected crew reached on the owner's tunnel credential, and the peer still applies its own approval_modes policy. No other human's authority is borrowed.
The peer-wide reach is stated in the PR description, forward_peer_mode's docstring and session.md.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: only the owner can arm their own crew span=95bdf6134dbf

#10618 and the frozen Goal ask for YOLO to apply on the gateway that runs the tools, and the peer has no per-slot YOLO: its override is process-wide, exactly as when YOLO is picked on the peer's own dashboard.
The caller is gated to the dashboard owner (deny_non_owner_remote_operation), the peer is the owner's own connected crew reached on the owner's tunnel credential, and the peer still applies its own approval_modes policy. No other human's authority is borrowed.
The peer-wide reach is stated in the PR description, forward_peer_mode's docstring and session.md.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: no second human's boundary is crossed span=ad08cb427a7e

#10618 and the frozen Goal ask for YOLO to apply on the gateway that runs the tools, and the peer has no per-slot YOLO: its override is process-wide, exactly as when YOLO is picked on the peer's own dashboard.
The caller is gated to the dashboard owner (deny_non_owner_remote_operation), the peer is the owner's own connected crew reached on the owner's tunnel credential, and the peer still applies its own approval_modes policy. No other human's authority is borrowed.
The peer-wide reach is stated in the PR description, forward_peer_mode's docstring and session.md.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: a peer row without its instance renders no card span=b5ee76c66496

_register_relayed_permission now registers a placeholder only when the mirrored row carries peer_request_mid; otherwise the row stays a plain transcript line and no card offers a decision that would 404.
Pinned by test_a_row_without_the_peer_instance_is_not_forwarded (no pending future, pending_approval_info is None, direct call 404s without reaching the peer). Fixed in 0e2fc09.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: who may arm the peer's YOLO remotely is now named span=3a3a4defe16b

session.md and the description now state it: only this gateway's dashboard owner (deny_non_owner_remote_operation), over the owner's own instance tunnel, and the peer's approval_modes policy decides whether YOLO may arm at all.
Clears via the item's first branch. Fixed in 0e2fc09.

@iamwhatever
iamwhatever force-pushed the fix/remote-crew-approvals-takeover branch from 0e2fc09 to cfe35b4 Compare October 3, 2026 13:47
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: a shared id refuses instead of deciding the local card span=c98cc8045fd5

_remote_approval_owner now reports ambiguity whenever a remote-bound slot and any other pending holder (state-level or another slot) share the id; api_approval_resolve returns 409 approval_id_ambiguous and decides nothing.
Pinned by test_an_id_shared_with_a_local_card_decides_neither (local future untouched, peer not called, remote card still pending). Fixed in cfe35b4.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: all-session Trust / Reads skip remote-bound slots span=942b5045759b

The unscoped trust and trust_reads branches of api_chat_mode now skip executor == "remote" slots, so a remote chat never shows a Trust its peer did not receive; the spec's 'interactive floor' sentence holds.
Pinned by test_an_all_sessions_trust_leaves_the_peers_card_pending (now also asserts _trust stays False). Fixed in cfe35b4.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: hidden remote YOLO grant span=f6b1b0981200

Same open maintainer ruling as the earlier needs-a-decision records: accept the floor display as shipped (recommended), add a 'YOLO on peer' picker state, or refuse remote yolo.
This gateway cannot read the peer's resulting mode, so an exact display needs new peer state; the floor never claims a looser mode than this side can prove.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: live hub-to-peer run before merge span=47898ac0b56b

The request_mid handshake is now tested with the peer's real drain feeding the real relay reader (TestThePeerWireNamesTheRowInstance), and the peer's origin=native check is main's existing tested branch.
A live run needs two connected gateways, which this worker cannot stand up. Maintainer: accept the wire-level tests, or run Allow / YOLO / Normal across a real tunnel before merge.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: peer /approve native body, live span=58de44f2349e

Maintainer ruling pending with the user: whether a live two-gateway run is required before merge. This worker cannot stand up two connected gateways.
What the tests already pin against real code: the peer's real _build_stream_chunk drain feeding the real _apply_row reader carries request_mid; the peer's /approve strict-native branch and /api/chat/mode slot handling are main's existing handlers, unchanged here, and the forwarded bodies are asserted exactly.
Options: (a) accept the wire-level tests; (b) a maintainer runs Allow / Reject once / YOLO-then-Normal across a real tunnel and records it in the description.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: relay drain request_mid, live span=e57250d313f3

Maintainer ruling pending with the user: whether a live two-gateway run is required before merge. This worker cannot stand up two connected gateways.
What the tests already pin against real code: the peer's real _build_stream_chunk drain feeding the real _apply_row reader carries request_mid; the peer's /approve strict-native branch and /api/chat/mode slot handling are main's existing handlers, unchanged here, and the forwarded bodies are asserted exactly.
Options: (a) accept the wire-level tests; (b) a maintainer runs Allow / Reject once / YOLO-then-Normal across a real tunnel and records it in the description.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: peer approval_resolved mirror, live span=dc9e0d701fa9

Maintainer ruling pending with the user: whether a live two-gateway run is required before merge. This worker cannot stand up two connected gateways.
What the tests already pin against real code: the peer's real _build_stream_chunk drain feeding the real _apply_row reader carries request_mid; the peer's /approve strict-native branch and /api/chat/mode slot handling are main's existing handlers, unchanged here, and the forwarded bodies are asserted exactly.
Options: (a) accept the wire-level tests; (b) a maintainer runs Allow / Reject once / YOLO-then-Normal across a real tunnel and records it in the description.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: peer /api/chat/mode slot handling, live span=13be9f548de9

Maintainer ruling pending with the user: whether a live two-gateway run is required before merge. This worker cannot stand up two connected gateways.
What the tests already pin against real code: the peer's real _build_stream_chunk drain feeding the real _apply_row reader carries request_mid; the peer's /approve strict-native branch and /api/chat/mode slot handling are main's existing handlers, unchanged here, and the forwarded bodies are asserted exactly.
Options: (a) accept the wire-level tests; (b) a maintainer runs Allow / Reject once / YOLO-then-Normal across a real tunnel and records it in the description.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: remote YOLO hidden by the floor display span=10724495f6f4

Maintainer ruling pending with the user. The gap is already named in the description under What changed as 'Known gap'.
Options: (a) accept the floor display (recommended); (b) show the mode from the peer's 2xx; (c) refuse remote yolo.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: the peer's policy governs the peer's YOLO span=d085816e0bea

A remote card's yolo arms the PEER's override, never this gateway's; the peer's api_chat_slot_approve runs its own yolo_policy_permits() and refuses under its ceiling, which this side returns as 502.
This gateway's approval_modes ceiling governs what this gateway auto-approves, and that stays untouched. Applying the hub's policy to the peer would be a new cross-gateway governance rule, beyond this Goal.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: running on cancellation is intended span=e1c585cfae0d

On cancellation turn_finished is False, so _retire_relayed_approvals only drops the placeholder future: the row stays unresolved and no rejection is broadcast, which is what the earlier round asked for (test_a_truncated_turn_records_no_rejection_the_peer_never_got).
The 'On CANCELLATION none of this runs' sentence describes the marker clear, save and chat_done inside if not cancelled:, which still do not run. Scope is frozen to blocking defects, so the comment is left as is.

A remote-bound chat showed the peer's permission requests with no way to
answer them, and approval-mode changes stayed on this gateway, so the peer
waited until its approval or turn timeout.

Each pending peer permission row now gets a local placeholder future so the
card is projected and answerable. The decision is forwarded to the peer slot's
approve route and the card is retired only after the peer accepts; the peer's
own approval_resolved frame or the end of the relayed turn retires it
otherwise. A slot-scoped mode change, yolo included, is applied on the peer
first and only mirrored locally; this gateway's YOLO override is untouched.
Resolvers that never reach the peer skip remote-bound slots.

Fixes #10618

Co-authored-by: Ashvin Nihalani <ashvin.nihalani@gmail.com>
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@iamwhatever
iamwhatever force-pushed the fix/remote-crew-approvals-takeover branch from cfe35b4 to d93d857 Compare October 3, 2026 14:13
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: a remote card click is bound to its slot and row; no bare-id remote decision span=2ba85e28e288

The bare /api/approvals/{id} forward for remote slots is removed (handlers/sessions.py is back to main), so a bare id never decides a remote card.
On a remote-bound chat the composer card sends the slot route with origin=native and the row's request_mid; the hub's existing strict-native check refuses a click whose row is no longer the live instance, then _approve_on_peer forwards that row's peer request_mid.
Pinned by test_a_stale_card_click_never_reaches_a_newer_request, test_a_bare_id_never_decides_a_remote_card, test_a_card_click_bound_to_its_row_reaches_the_peer, and the ChatInput remote-card vitest case. Fixed in d93d857.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: picker hides an armed peer YOLO span=a1edd149fdf9

Maintainer ruling pending with the user (remote YOLO display). Options: (a) accept the floor display as shipped; (b) show a peer-confirmed YOLO / Trust state; (c) refuse remote yolo and Trust.
Every pick in the picker is forwarded regardless of what it shows, so Normal on a remote chat always reaches the peer and ends its grant. Scope is frozen, so no picker change is made before the ruling.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: the description names the approval.ts routing change span=6b359cee6a0b

The Screenshots section now names website/src/components/chat-input/approval.ts and says it only changes which route a remote card click goes to, with nothing rendered changing, under the no-visual-delta waiver and its justification line. Description-only edit, no push.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • needs-a-decision: picker shows the floor after a remote pick span=2774b506d795

Maintainer ruling pending with the user (remote YOLO display). Options: (a) accept the floor display as shipped; (b) show a peer-confirmed YOLO / Trust state; (c) refuse remote yolo and Trust.
Every pick in the picker is forwarded regardless of what it shows, so Normal on a remote chat always reaches the peer and ends its grant. Scope is frozen, so no picker change is made before the ruling.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Closing this PR as superseded by the remote-crew sidebar RFC (#16489, docs/request-for-change/rfc-remote-crew-sidebar.md). Its migration wave 1 freezes new relay mirrors and closes the #10618 approval mirror as superseded. Wave 3 replaces it: a crew session opens as a window onto the peer's own slot, and Approve calls the peer's POST /api/chat/slots/{slot}/approve directly, so there is no local copy of the peer's approval to keep in sync.

The branch fix/remote-crew-approvals-takeover is kept for reference.

Three real bugs came up while driving this PR. Wave 3 should keep the same checks:

  1. Card buttons 404 on a remote slot. The composer card's Allow / Reject / Reject once go through POST /api/approvals/{id}/{action}, not the slot route. If the generic resolver doesn't hold the remote approval, the card says "expired" while the peer keeps waiting. In wave 3, every approval button on a crew window must reach the peer's slot route.
  2. request_mid lost on the relay wire. In relay mode, chat_utils._build_stream_chunk sends a permission row's parsed cls as meta, so the row's own meta.mid never reaches the reader. Any decision that has to be tied to one peer row needs that row's mid sent explicitly.
  3. A bare approval id can decide the wrong request. Request ids are only unique per connection, and an expired request's id can be reused. A bare-id decision, or one that names the slot but not the row, can then approve a request the user never saw. Decisions must carry origin=native plus the row's request_mid, so the peer's own strict-native check refuses stale clicks.

Thanks again, @ashvinnihalani. Your design and the bugs it surfaced feed straight into wave 3.

@iamwhatever iamwhatever closed this Oct 3, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 3, 2026
@bolichen97
bolichen97 deleted the fix/remote-crew-approvals-takeover branch November 6, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote-bound chat does not relay tool approvals or YOLO to the executing peer

1 participant