Skip to content

fix: bind every approval decide to an owner-bound target - #16481

Closed
jeeshofone wants to merge 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/16389-owner-bound-decide
Closed

jeeshofone wants to merge 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/16389-owner-bound-decide

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A dashboard approval control decides only the request it shows, never a different request that took over its id.

Most dashboard decide paths send only the id, and the bare-id route resolves whatever is pending under it. A coordinator id is the caller's and recurs, and a runner's request id can match one. So request A's card, left up after request B took over the id, decides B.

Stacked on #14739. Commit 1 is #14739's commit 1 e69eb7bd2b exactly (same SHA), on main d9a20ee8a7. Commit 1 drops out once #14739 merges. Review commit 2.

What main already has. Main's shared-decisions layer already serves the server half: the strict native approve (origin: "native" plus request_mid), the coordinator decide pinned to slot and instance, response_id replay and the lost-race 409. Commit 2 keeps all of it. It binds the dashboard's own controls to those targets (every surface still sent a bare id), lets the strict native decide reach a slot sharing the session, and names the settled row in every native resolution frame.

Why it matters

A press on the wrong request silently runs a tool or agent the user never approved.

Not a goal

Backwards compatibility

Compatible: server changes are additive. approval_resolved gains origin plus instance or mid; pending_approval_info gains request_instance; a task gate's record gains run_task_id and task_index (also in GET /api/approvals); the coordinator decide accepts an empty slot; the strict native approve takes the trust verbs, binding a card's standing grant to its mid. A not-pending 404 is unchanged in shape. No new decision value is added.

  • Task-gate id keeps main's task-gate-<index>-… shape (railBadges.ts reads its prefix).
  • Bare-id callers (ChatEmbed.tsx, the ops allowlist, kirocrew_client): route unchanged.
  • An older build's approval row (no instance): a press is refused on the client and that exact row retires; the reconcile removes it from this tab only, with no DELETE.

Reader: website/src/store/chat/messages.ts:resolveByApprovalId -- chat -- removed: every permission row settles through resolveApprovalRow, whose stale rule chatSlice.activity and the unsafe-key suite pin; an MCP elicitation row (ElicitationCard.tsx and the elicitation_resolved frame) settles through resolveElicitationRow, which touches elicitation rows only

What changed (motivation → approach → change)

  • Every shown approval carries a typed target (types/index.chat.ts; helpers in types/approvalTarget.ts): coordinator = id, slot, instance; native = id, slot, permission-row mid. api.decideApproval (api/client/approvals.ts, refusals classified in api/apiError.ts) is the only client decide; approvalBareIdGuard.test.ts pins it. Every surface sends it, the collapsed tool group through decidePermissionRow.ts. An MCP elicitation row is not an approval: it settles through resolveElicitationRow (store/chat/messages.ts, called by ElicitationCard.tsx and hooks/useWebSocket.ts), which touches elicitation rows only.
  • Server: main's shared-decisions seams (settled_reply, resolve_slot_approval, lost_race_reply, _sweep_pending_approvals) are unchanged. The strict native approve (slot_approval.py) finds its request on the addressed slot or one sharing its session identity (_strict_native_owner), still requiring the row's mid, and takes the trust verbs. Native resolution frames, including the bulk Trust sweep, spell origin and mid (native_resolution_target, used by chat_turn/permission_prompt.py too). A row's mid survives the slot-detail rebuild and the stream chunk (chat_utils_display._carry_row_mid).
  • Client: api.decideApproval(target, action, responseId) sends main's response_id on both routes, so a retried click replays and a later collaborator's click gets the winner.
  • Task gate records name their run and task (run_task_id, task_index), because runs overlap task indexes; ProjectDetailPage.tsx maps its own run's gates by them. The runner keeps on_approval(task): task_executor.py sets task.run_task_id (task_models.py) and service_boot.py records it.
  • A same-id takeover sends only the replacement's approval frame; the replaced card retires when its press is refused or the reconnect reconcile no longer lists it.
  • Overlapping reconnect reconciles are fenced by a generation (websocket/approvals.ts). A request whose chat row is shown is not adopted again, so a dismissed feed row stays dismissed. The snapshot merge keeps this tab's own rows, ordered by utils/notificationTimestamp.ts.
  • The feed and detail panel (components/notifications/) decide through fix: retire expired approvals from the notifications feed #14739's lifecycle (decideApprovalRow), which sends the row's target; a row that names none settles as refused with nothing sent. The composer decides in chat-input/approval.ts.
  • A spawn press refused as gone, or a spawn card that names no request, takes fix(dashboard): retire a gone spawn approval everywhere #20987's gone verdict (markSubagentApprovalGone), scoped to the card's target, so a refusal for request A never withdraws B under the same id; the spawn inventory settles whether it started.
  • A refused decide renders through ErrorNotice on every surface (ApprovalCard.tsx and the rest; errors-use-error-notice), in the one sentence approval_no_longer_pending (every website/src/i18n catalog). The composer keeps its status row. The approval entry reads "No longer pending". A coordinator approval in the composer offers no Trust (test_trust_patterns.py).

Tests

Proof: not provable -- other: mostly frontend, which prove.py does not run; mutation pins are named per test below

  • Client: ChatInput.approval (spawn withdrawal, same-id takeover, lost race), UseWebSocketCoverage.approvalReconcile (out-of-order reconnects; a native frame naming one mid settles only that row), chatSlice.activity, ChatSliceElicitation, decidePermissionRow, approvalBareIdGuard, useAgentSync.approvalTarget, the 500-seed notificationsSlice property.
  • Server: test_chat_mode_security.py, test_trust_patterns.py (a stale mid grants nothing; a session-sharing owner is reached only by its mid), test_task_gate_record_fields.py, test_coordinator_approval_slot_lane.py, test_permission_row_mid_*, test_dashboard_approval*.py.

Manual verification

website/scripts/capture-*.mjs assert each frame's state before writing it; capture-spawn-approval-gone.mjs (#20987) passes on this head.

Screenshots / video

Under temp-screenshots/notification-approval-refusal/: composer refusals (30, 24, 22, 23), feed, detail and popover rows (01, 05, 09, 24-feed, 25-detail), scene popover (17-scene, 18), chat tool group (25), project gate (26) and approval entry (29).

Related Issues

Closes #16389

Sibling sweep

Swept: git grep -nE "resolveApproval(|approveChatSlot(" -- website/src
Siblings: none -- every dashboard decide goes through api.decideApproval; approvalBareIdGuard.test.ts fails on a new bare-id call

Pattern harvest

Rule candidate: review-prompt
Pattern: when the server already pins a decision to a record identity, every client control must send that identity too; a bare-id client call quietly bypasses the server's pin.

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

@jeeshofone
jeeshofone requested a review from a team October 3, 2026 10:33
@jeeshofone
jeeshofone requested a review from a team as a code owner October 3, 2026 10:33
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 3, 2026
@jeeshofone
jeeshofone force-pushed the fix/16389-owner-bound-decide branch from 7c448fc to e3169ac Compare October 3, 2026 10:39
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of af2f040d23ec911d37ef981cba4393621528ddda via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the client now sends the owner-bound targets the server already checks, the server changes only add fields, and the one removed reader (resolveByApprovalId) is listed.

Notes

  • Approval rows saved before this change carry no mid, so after upgrade they refuse their own presses and close. A user will see a card they never pressed retire as "No longer pending". This is accepted in the description, and reverting the change undoes it.
  • task.run_task_id is changed on the Task object just before on_approval(task). Passing the run ID as an argument would not depend on that order and would not leave the run ID on the task. The PR chose to keep the one-argument callback, which is a reasonable choice.

[DESIGN-REVIEWED] af2f040

Description read

[DESCRIPTION-READ] 2bc2b15a32e3b2755c1a5fbaa32aebb9ec5a14be4dff09df5cbfd8b001481f0e

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 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of af2f040d23ec911d37ef981cba4393621528ddda via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The 26 committed stills cover every refusal state this PR changes, but no first-time user has looked at them, because this fork lane has no blind read. Pushing the branch to the repository gets one.

Notes

  • decided_clear_failed says "Press Dismiss notification on it in the feed", but the feed shows only an unlabelled ✕ (attachment-09, compare the row in attachment-01). Change it to "Press ✕ on it in the feed to try again."
  • approval_no_longer_pending gives three possible causes in one sentence. That's long for the narrow feed row (attachment-01) and the tool-group row (attachment-22), where it wraps to three or four lines. Lead with the result: "The agent is no longer waiting on this approval: it expired, was decided, or was replaced."

[UX-REVIEWED] af2f040

Description read

[DESCRIPTION-READ] 4a57258bffb4e3951b6331f5ca98a99af6e73a14fb7d58d1570ab4068771b09c

That sha256 names everything this verdict read: the PR description, plus the 29 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 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of af2f040d23ec911d37ef981cba4393621528ddda via the fork AI-review pipeline — 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 does not.

First-Principles-Verdict: PASS

Every item in the diff serves the frozen Goal: binding each dashboard decide to the one request it shows. The description declares each server widening the client switch needs.

Notes

  • Item 9 — rides along: "Overlapping reconnect reconciles are fenced by a generation". This is about which rows are visible after a reconnect, not about which request a press decides. No reported defect backs it. Subtraction: defer reconcileGenRef in hooks/websocket/approvals.ts to its own PR if it cannot be tied to a wrong-request decide.

What this change ships

Inventory (10 items) — 9 justified

Intent: a dashboard Approve/Reject/Trust press acts only on the request its card shows, never on a later request that took over its id. FIX.

  1. Every dashboard approval control (composer, feed, detail panel, scene, activity viewer, tool group, transcript, project gate, attention card) sends an owner-bound target instead of a bare id. All 9 base bare-id call sites of resolveApproval( in website/src are converted — justified
  2. Strict native decide now also finds its request on a slot that shares the session, and only by its mid — justified
  3. Strict native decide accepts the trust verbs, so a standing grant is bound to the card's mid — justified
  4. Coordinator decide accepts an empty slot for slotless approvals (cron); owner-only, otherwise 403 — justified
  5. Task-gate records carry run_task_id/task_index. The project page stops reading the index out of the id (ProjectDetailPage.tsx:63), because runs overlap — justified
  6. approval_resolved frames name origin plus instance or mid, and a row's mid survives reload and stream — justified
  7. Composer no longer offers Trust on a coordinator approval; base already refused that with 400 approval_not_slot_owned — justified
  8. The refusal sentence now reads "…expired, was already decided, or was replaced by a newer request" on every surface — justified
  9. Overlapping reconnect reconciles: only the newest applies its answer — rides along
  10. Stale feed rows from an older build, which name no request, retire locally on reconcile — justified

[FIRST-PRINCIPLES-REVIEWED] af2f040

Description read

[DESCRIPTION-READ] 2b30cbb73540e9b0f435ba33a3c425c85dafc98c7ee40bce31708d98915e754f

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

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed f1654305f162e87063f5e41bac37d4efc77ce3f3 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f165430

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — 🔴 changes requested (blocking)

Reviewed af2f040d23ec911d37ef981cba4393621528ddda via the fork AI-review pipeline; updated in place on each push.

Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging.

BLOCKING -- website/src/api/client/approvals.ts:42 -- Coordinator clicks bypass decision attribution and replay

+ new URLSearchParams({ origin: 'coordinator', slot: target.slot, instance: target.instance }), responseId ? { response_id: responseId } : {}).then(j)
Trigger: A user decides a coordinator approval through useToolApproval → api.decideApproval → api_approval_resolve. The coordinator branch calls state.resolve_state_approval directly, without consuming response_id or invoking the shared-decision resolver.
Outcome: ApprovalCoordinator.request cleanup records an Unknown responder with settled_by="host", hiding the human decision from DecisionAttributionList. Retrying the winning response returns 404 rather than replayed success; a competing response receives no winning decision.
Anchor: defect
Fix: Parse response_id before validating the pending target, then resolve through shared_decisions.resolve_state_approval; preserve slot/instance binding for resolution, replay, and conflict responses.

[BLOCK-MERGE] af2f040
[GPT-REVIEWED] af2f040

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — UPHOLD. Harm is MEDIUM: on a common path, a human's decision is recorded as made by an unknown responder, without any error showing. The coordinator branch at src/kiro_crew/dashboard/handlers/sessions_parts/live_turn.py:152-159 calls state.resolve_state_approval directly and never reads response_id. The bare-id branch it replaces for slotless approvals (live_turn.py:177-199) did attribute the decision and replay retries. The diff (patch L4342-4344) removes the bare-id decide, so every dashboard coordinator decide, cron ones included, now goes through the unattributed branch.
The real fix is cheap. shared_decisions.resolve_state_approval already exists (src/kiro_crew/shared_crew/decisions.py:528-561) and handles registry open, responder, replay and 409. The fix is to parse response_id and call it after the slot/instance check. It adds no new state or mechanism.

[ADJUDICATION] af2f040d23ec911d37ef981cba4393621528ddda total=1 uphold=1 downgrade=0
UPHOLD F1 website/src/api/client/approvals.ts:42 reason=harm-warrants-remedy
[GPT-ADJUDICATED] af2f040d23ec911d37ef981cba4393621528ddda

@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
@jeeshofone
jeeshofone force-pushed the fix/16389-owner-bound-decide branch from e3169ac to fd5eb9b Compare October 3, 2026 12:22
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 3, 2026
@jeeshofone
jeeshofone force-pushed the fix/16389-owner-bound-decide branch from fd5eb9b to 4fc6b82 Compare October 3, 2026 13:25
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 3, 2026
@jeeshofone
jeeshofone force-pushed the fix/16389-owner-bound-decide branch from 4fc6b82 to 90d9864 Compare October 3, 2026 16:18
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 3, 2026
@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

span=423d177a1d87

The #14739 content is commit 1: #14739 folded into one commit to stay within the two-commit limit, with a tree equal to #14739's head 89be3381d. So the last commit is this PR's change alone. It leaves this diff when #14739 merges and this PR is rebased onto main, which is the finding's own clear condition. Nothing in this PR's commit edits the feed's retire or Dismiss behaviour beyond sending each row's request target.
First-pass check on fe3dcef: R1-R8 OK.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

span=28f9672e8f6f

Frame 28 is gone. The Subagents card now takes main's gone-spawn states (#20987): it reads "Checking whether it started" and then "No record", and the refusal is reported once, on the surface that sent it.
The approval entry (frame 29) keeps "No longer pending" with the sentence in an ErrorNotice and that surface's hand-off, as errors-use-error-notice requires for a refused request. Rendering it muted without the hand-off is the register change #18203 makes on every surface together.
First-pass check on fe3dcef: R1-R8 OK.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

span=cef335949b9f

The banner reports a press the server refused, so it renders through ErrorNotice as errors-use-error-notice requires, and ErrorNotice has no info style. #18203 moves the project gate to the muted register with the tool group, scene popover and approval entry. Restyling this one banner here would split it from those sibling surfaces.
First-pass check on fe3dcef: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design notes on fe3dcef, answered on 05030f0.

  • Trust verbs on the strict native route: already in docs/system-specs/modules/security.md, in the sentence on the native slot endpoint's origin: native selector. It takes a one-shot or pending-card trust action (trust, trust_reads, trust_command, trust_base, never yolo), so a standing grant is bound to the exact request the card showed. The comment on _STRICT_NATIVE_ACTIONS in slot_approval.py says the same.
  • A card left up after a same-id takeover: agreed. It keeps showing request A until someone presses it (a 404 retires it) or a reconnect reconcile drops it. That is the trade-off the body's "Why not a retirement frame" names, and a retirement frame added later reverses it.

First-pass check on 05030f0: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

UX notes on fe3dcef, answered on 05030f0.

First-pass check on 05030f0: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles item 6 on fe3dcef (Trust withheld on a coordinator approval in the composer), answered on 05030f0: it is part of #16389's fix, not a rider.

  • On main, Trust on a coordinator approval in the composer is sent as api.approveChatSlot(slot, decision, { request_id }): a decide by id alone, which is the defect approvals: a dashboard decide by bare id can resolve a different request under the same id #16389 names.
  • The owner-bound routes leave nowhere to record that grant. The slot route's strict selector takes only a native request: origin: native with a request_mid bound to the runner's own registered future (slot_approval.py). A coordinator request is not one of those futures, even when its row is shown in the chat. The coordinator decide names the request by its instance and takes only approve, reject and reject_once. The one route that would take the grant is the bare-id slot route, which this PR removes from the dashboard client.
  • So the card offers Allow once and Reject, both sent with its coordinator target. A trust verb that still reaches the handler is downgraded to a one-shot allow on that target, the same fail-closed rule the unattended sources already follow.
  • Item 9 (parseTs in utils/notificationTimestamp.ts): the notifications slice orders its rows with the same parser the feed renders them with (notificationsSlice.ts imports it), and notifMeta.tsx re-exports it for the feed's callers.

First-pass check on 05030f0: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

CI on 05030f0d7 had two reds, neither from this diff:

104e55434 rebases both commits onto main 5f77c3f85, so both run again.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Lane notes on 104e55434, answered on be6eace1c.

This head rebases both commits onto main 33cdb8f1e with no code change. git range-diff shows commit 2 unchanged, and commit 1 has the same patch-id as #14739's 5cc82ba24..89be3381d. Commit 1's message changed too: it no longer says its tree equals 89be3381d, which stopped being true when the stack moved onto newer main.

First-pass check on be6eace1c: R1-R8 OK.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Design notes on be6eace1c, answered on e5c655d0d.

  • The spec should say the strict native decide now searches slots that share the session identity: done. docs/system-specs/modules/security.md now says a strict native decide looks for its future as every native decide does, on the addressed slot and then on a slot with the same effective session key. Across those slots the row's request_mid is the only binding, so a missing future, or one whose instance is not that mid, returns 404 / approval_not_pending with no cross-origin fallback.
  • The no-retirement-frame trade-off is not recorded in docs/decisions/: recorded in the spec instead. docs/decisions/ takes only a decision a maintainer made and restated on record (its README, rule 4), and this trade-off is this PR's own design. docs/system-specs/modules/learn-cron-dashboard.md now says no frame retires the card a replacement displaced. It keeps its buttons until a press on it is refused with 404, which withdraws them, or, for a coordinator card, until the reconcile that runs on every socket open no longer lists its instance. The body's "Why not a retirement frame" gives the reason.

This head rebases both commits onto main ea1919e46, which also re-runs the two lanes that stopped on infrastructure on be6eace1c (GPT 6.1's incomplete review and Security Scope's unfinished generate job). Commit 1 is unchanged: git range-diff shows it as =, with the patch-id of #14739's 5cc82ba24..89be3381d.

First-pass check on e5c655d0d: R1-R8 OK.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

UX notes on be6eace1c, answered on e5c655d0d.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

First Principles on be6eace1c, answered on e5c655d0d.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Design notes on e5c655d0d, answered on 298d1de6d.

  • Split the strict native approve's trust verbs and its shared-session owner lookup into their own change: kept here, because both are needed to move every native press onto the target-bound decide. On main the composer sent a Trust press with the request id alone, and the strict path took only approve and reject, so a stale card's Trust press could still decide the request that took over its id (approvals: a dashboard decide by bare id can resolve a different request under the same id #16389). The id-only route also finds a future on a slot that shares the session identity. Without that lookup on the strict path, a composer press that resolves on main would get 404 here. Either way the row's request_mid still binds the decide.
  • Pin the empty-slot coordinator decide's owner-only gate with a test: already pinned. test/test_chat_mode_security.py::test_a_slotless_coordinator_target_is_refused_to_an_internal_caller sends the exact empty-slot target, for approve and reject, as an internal-secret caller, a peer-verified caller with no app claim and a caller with no claim. Each gets 403 / approval_owner_required with the request still pending, and the same callers still decide a slotted record by its exact target. The gate and this test both ship in commit 1, fix: retire expired approvals from the notifications feed #14739's change.

This head rebases both commits onto main 92fb6213d. On e5c655d0d, Frontend Lint & Type Check spent 17.5 of its 20 minutes in actions/checkout and was cancelled, so Coverage Gate failed closed and no test shard ran. The rebase re-runs them. Commit 1 is unchanged: git range-diff shows it as =, with the patch-id of #14739's 5cc82ba24..89be3381d.

First-pass check on 298d1de6d: R1-R8 OK.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

UX notes on e5c655d0d, answered on 298d1de6d.

  • Show task_approval_no_longer_pending as a neutral notice, not a red error (attachment-24): held for Show a gone approval as status, not an error, on every dashboard surface #18203, which lists the project task gate among the surfaces it moves off the error register. The notice is red today because errors-use-error-notice routes a refused press through ErrorNotice, which has no status style.
  • The composer offers Trust on a runner request but not on a coordinator one (attachments 17 and 19): kept. A standing grant is recorded on the slot that raised the request, and a coordinator request parked in a chat was not raised by that chat. On main the server refused that grant (approval_not_slot_owned) or answered the press as a one-shot allow, so the button never recorded a grant there. The composer already withholds Trust from an unattended source's request by the same rule (approvalTrustGrantable). A line saying why Trust is missing would serve both cases, so it is a change of its own, outside this fix.
  • The approval entry's "No longer pending" header repeats the red sentence under it (attachment-25): held for Show a gone approval as status, not an error, on every dashboard surface #18203, which settles the shared approval_no_longer_pending sentence's wording on every surface. Your proposal to keep only its first clause under the header is recorded there.

@jeeshofone

jeeshofone commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Design notes on 298d1de6d, answered on c3935a2a6.

This head rebases both commits onto main 5a4e2ffb4. The only conflict was commit 2's TYPE_CHECKING import list in chat_turn/permission_prompt.py, against #23528, which moved resolve_linked_approval to a module-level import. I kept main's side and commit 2's row_mid, which the runner still binds. Commit 1 is unchanged: git range-diff shows it as =, with the patch-id of #14739's 5cc82ba24..89be3381d.

First-pass check on c3935a2a6: R1-R8 OK.

@jeeshofone

jeeshofone commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

UX notes on 298d1de6d, answered on c3935a2a6.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

First Principles on 298d1de6d, answered on c3935a2a6.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at f578ba7.

Blockers:

  1. The branch conflicts with main (mergeable=CONFLICTING). It needs a rebase.
  2. This changes what an approval decide may grant and which request it resolves. The strict native approve now takes trust verbs, so it can record standing grants (slot_approval.py#L781). Its not-pending check moved after the cross-slot owner lookup (slot_approval.py#L891). A coordinator decide with an empty slot is gated on the owner check (live_turn.py#L155). Approval and trust paths are reserved for human review.
  3. Commit 1 is the still-open fix: retire expired approvals from the notifications feed #14739 folded in. Merge fix: retire expired approvals from the notifications feed #14739 first, or have its owner confirm that it lands through this PR.

All five AI lanes pass on this head, and the earlier notes have replies. The newest run of each check is green. I ran no tests locally.

— crew-pr-reviewer (r124)

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Re r124 HOLD, point 1 (conflict with main). Rebased onto main 33590d6f58, and the branch no longer conflicts. The new head is ca17d320b5.

The rest of commit 2's range-diff against f578ba7479 is context that main moved, the resolveElicitationRow export and its tests, test fixtures updated for #14739's new head, and the security.md sentence described under point 2.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Re r124 HOLD, point 2 (what an approval decide may grant, and which request it resolves).

The set of grants is the one main has. This PR binds each grant to the row the card showed.

What POST /api/chat/slots/{slot}/approve can grant, on main and here:

  • approved, rejected, rejected_once: one decision on one request.
  • trust: auto-approve the rest of that chat session. Granted only when the pending card carries the server's trust_grantable proof.
  • trust_reads: auto-approve read-only shell commands in that slot.
  • trust_command, trust_base: record the exact command, or its base command, as a trusted pattern, optionally for ttl_seconds (1 to 86400). Granted only when the client's pattern equals the command the server derived from the same pending card.
  • yolo: widen every slot. It stays off the strict path because _STRICT_NATIVE_ACTIONS leaves it out, so a strict decide carrying it gets 400 invalid_approval_target before any side effect.

Trust verbs on the strict path (L781). A Trust press now grants only on the request whose card the user saw. On main the composer's Trust sends only request_id, to the bare path, which grants on whatever request holds that id now. So request A's card, left up after request B reused the id, grants trust on B (#16389). Here the same press sends origin: native and the row's request_mid. The grant code and its server-side proofs are unchanged. The strict path adds one condition: the request pending under that id on the owning slot must still carry the row's request_mid. That check runs once, before any verb's own proof checks, so the command-scoped verbs must clear it too. test_a_stale_cards_trust_cannot_grant_the_request_that_replaced_it pins it for trust and trust_reads, and test_strict_native_decide_reaches_the_owner_slot_sharing_the_session pins it for approved and every trust verb, trust_command and trust_base included. test_dashboard_native_instance_proof_fails_closed, already on main, pins that a missing or malformed request_mid is refused.

The not-pending check after the owner lookup (L891). Nothing is resolved or granted before the request_mid matches, and the owner lookup cannot reach another session. Between the lookup and the check there are only refusals (main's elicitation guard and the app session-control check on the owning slot). The strict path now finds the owning slot the way the bare path always has: the addressed slot, else a slot with the same effective_session_key (session sharing, a rehydrated or replaced slot). It then checks the request_mid on that slot. Without this, moving Trust onto the strict path would have broken Trust in the session-sharing case the bare path handled. test_strict_native_decide_reaches_the_owner_slot_sharing_the_session pins that a decide reaches the slot sharing the session and never a slot under another session. test_dashboard_native_stale_row_cannot_resolve_reused_id pins that a stale row cannot resolve a reused id. A strict decide that has both an invalid ttl_seconds and a stale row now gets 400 where it used to get 404.

The empty-slot coordinator decide (live_turn.py#L155). That gate comes from #14739, in commit 1, and it keeps main's rule that only the dashboard owner's browser session may decide a slotless approval (cron, autonudge, task runner). On main a coordinator target must name a slot, so such an approval can be decided only by bare id. The empty-slot target names the request's instance instead. A caller other than that browser session gets 403 approval_owner_required. An app's request goes to the app approval path first, and that path cannot settle a state-level approval. This PR's own commit changes only how the route reads a present but empty slot, and how it compares the record's instance with the instance the target names. test_a_slotless_coordinator_target_is_refused_to_an_internal_caller and test_a_slotless_coordinator_target_settles_only_the_instance_it_names pin it.

docs/system-specs/modules/security.md describes the strict path's owner lookup and request_mid binding, and docs/system-specs/modules/learn-cron-dashboard.md the empty-slot owner rule. Commit 2 now also corrects a security.md sentence that predates this PR and said the strict endpoint "never adopts another slot's future".

No other change in this PR alters what a decide may grant or how the server picks the request it resolves. The PR's other approval changes name the resolved request in the resolution frames, the coordinator records and the dashboard, and grant nothing.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Re r124 HOLD, point 3 (commit 1 is #14739). I am #14739's author, and the landing order is #14739 first.

This PR waits for it. Commit 1 is #14739 folded into one commit (point 1 gives its relation to #14739's head), kept here only so this PR's CI runs on the code its own commit builds on. It is not a second way for #14739 to land. Once #14739 merges, I drop commit 1 on the next rebase, and this PR is left with only its own commit.

The feed and detail panel Approve/Reject buttons sent every rejection
from resolveApproval to the console and left the row in place, so an
approval that had already expired stayed listed with buttons that could
never succeed.

An approval_resolved frame removes the row. A decide this tab sent that
the server refused as no longer pending failed, so it now retires the row in the
notifications slice: the row stays listed without Approve/Reject, keeps
its close X (shown without a hover), and renders through the shared
ErrorNotice the sentence the chat card, tool group, Subagents panel and
command center already show for a refused press. Retiring also marks
the row read in this tab (the server holds no approval note, so nothing
is sent) and drops the critical border and unread dot. A retired row
recedes through its title and controls only; its notice keeps full
contrast, and the row open in the detail panel leaves that sentence to
the panel. The page
feed, the bell popover and the detail panel read the same marks, and
being read, a retired row leaves every unread count. A decision that lands removes the row, as
before. An approval row is this tab's own copy (the server keeps no
approval note), so a landed decision and the row's close X remove it
locally and send no DELETE: there is no request left to fail.

A retryable decide failure keeps Approve/Reject and says why on that
row through the shared ErrorNotice, so no failed action is silent. A retired row's close X stays at
near full strength while its title recedes, and the detail panel offers no read
toggle on a retired row.

A coordinator approval's id is the caller's and recurs, so each feed
row carries the server-issued instance of the request it was raised
for, and every coordinator approval_resolved frame names the instance
it resolved, so an earlier request's retired row under the same id is
not the one removed.

A request that takes over an id ends the one it replaced with no frame,
so the approval frame and the reconnect reconcile remove any live row
under that id bound to another instance, and a row that names its
request (slot and instance) decides with that coordinator target, so
the server refuses a stale instance instead of settling the request that
replaced it.

When the pressed button is withdrawn, keyboard focus moves to the
row's close X (or the detail panel's Close), the one thing left to do
with it, instead of falling to the page body.

A row whose decide is still in flight survives a notifications
snapshot (the reconnect refetch) and a clear-all, with its marks, so a
late refusal still renders on it. A clear-all or the row's close X marks
it dismissed, not ended: the request may still be pending, so the row
leaves once the response settles unless a refusal claims it, and a
retryable failure never shows it as no longer pending. Only a frame ends
the request.
Both go through one list replacement in the slice.

A 5xx or a missing response comes from the layer between the tab and
the decide route, so the row says the decision may not have been
recorded, in the chat approval card's own words, instead of quoting that layer's text; the
route's own 4xx refusals are still quoted. A slotless approval (cron,
autonudge, task runner) is decided with an empty slot and its instance,
and only from the owner's browser session, as before. Only an approval row withdraws the detail panel's
controls for a failed DELETE, since only it carries the notice, and the
open approval row leaves that notice to the panel instead of showing it
twice. The notice names the retry, the row's dismiss control in the feed,
by that control's own accessible name, and the panel has no Dismiss of its
own: a row leaves through its close X in the feed. On a
retired row the notice sits under "no longer pending" and claims no
recorded decision, in the panel, the page feed and the bell popover alike.

Closes kirodotdev#14711
A coordinator approval's id is the caller's and recurs, and a chat
runner's request id can collide with it, so a bare id names no request.
A dashboard card decided by bare id, so request A's card, left up after
request B took the id over, could approve or reject B.

Every approval a client shows carries a typed target (ApprovalTarget,
declared in website/src/types/index.chat.ts and built and matched by
website/src/types/approvalTarget.ts): a coordinator target is the id,
the owning slot and the server-issued instance; a native target is the
id, the slot and the permission row's mid. Every dashboard decide path
sends it through api.decideApproval (chat card, composer bar, spawn
cards, notifications feed, bell popover, detail panel, command center,
project task gates, scene view), and every retire and adopt matches on
it, so the two registries never settle each other's rows.
approvalBareIdGuard.test.ts fails if a bare-id client decide comes back.

Server side, the decide route (sessions_parts/live_turn.py) checks a
coordinator target's slot and instance against the record and resolves
only that state-level future. The strict native slot approve requires
the owner slot's live request to carry the row's mid and accepts the
pending-card trust verbs, so a stale card cannot grant trust on the
request that replaced it. Every approval_resolved frame names its
origin, and a runner's frame carries the row's mid
(native_resolution_target, also used by chat_turn/permission_prompt.py).
A permission row's mid survives the slot-detail rebuild and the stream
chunk (chat_utils_display._carry_row_mid).

Task gates name their run: up to three runs execute at once and their
task indexes overlap, so a gate's record carries run_task_id and
task_index, listed by GET /api/approvals, and the project page maps only
its own run's gates by them. on_approval(task) keeps its one-argument
contract; the executor sets task.run_task_id before the call.

A spawn press refused as gone, or one on a spawn card that names no
request, goes through markSubagentApprovalGone scoped to the request
the card was raised for, so a refusal for request A never withdraws B
under the same id; the spawn inventory settles whether the spawn
started. A refused decide renders
the approval_no_longer_pending sentence through ErrorNotice on every
surface except the composer bar, which keeps its status row. The
id-wide resolveByApprovalId reducer is removed; its stale rule lives on
resolveApprovalRow.

Fixes kirodotdev#16389
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Moved to #27511: same commits, now on a branch of this repo so CI uses the CodeBuild fleet. Review history stays here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

approvals: a dashboard decide by bare id can resolve a different request under the same id

2 participants