Repository navigation
fix: bind every approval decide to an owner-bound target - #16481
jeeshofone wants to merge 2 commits into
Conversation
7c448fc to
e3169ac
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of 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 ( Notes
[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 |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of 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
[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 |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of 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
What this change shipsInventory (10 items) — 9 justifiedIntent: 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.
[FIRST-PRINCIPLES-REVIEWED] af2f040 Description read[DESCRIPTION-READ] 2b30cbb73540e9b0f435ba33a3c425c85dafc98c7ee40bce31708d98915e754f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed 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
[BLOCK-MERGE] 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 |
e3169ac to
fd5eb9b
Compare
fd5eb9b to
4fc6b82
Compare
4fc6b82 to
90d9864
Compare
|
span=423d177a1d87
|
|
span=28f9672e8f6f
|
|
span=cef335949b9f
|
|
Design notes on fe3dcef, answered on 05030f0.
First-pass check on 05030f0: R1-R8 OK. |
|
UX notes on fe3dcef, answered on 05030f0.
First-pass check on 05030f0: R1-R8 OK. |
|
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.
First-pass check on 05030f0: R1-R8 OK. |
|
CI on
|
|
Lane notes on
This head rebases both commits onto main First-pass check on |
|
Design notes on
This head rebases both commits onto main First-pass check on |
|
UX notes on
|
|
First Principles on
|
|
Design notes on
This head rebases both commits onto main First-pass check on |
|
UX notes on
|
|
Design notes on
This head rebases both commits onto main First-pass check on |
|
UX notes on
|
|
First Principles on
|
|
HOLD at f578ba7. Blockers:
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) |
|
Re r124 HOLD, point 1 (conflict with main). Rebased onto main
The rest of commit 2's range-diff against |
|
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
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 The not-pending check after the owner lookup (L891). Nothing is resolved or granted before the 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
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. |
|
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
|
Moved to #27511: same commits, now on a branch of this repo so CI uses the CodeBuild fleet. Review history stays here. |
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
e69eb7bd2bexactly (same SHA), on maind9a20ee8a7. 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"plusrequest_mid), the coordinator decide pinned to slot and instance,response_idreplay 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_resolvedgainsoriginplusinstanceormid;pending_approval_infogainsrequest_instance; a task gate's record gainsrun_task_idandtask_index(also inGET /api/approvals); the coordinator decide accepts an emptyslot; the strict native approve takes the trust verbs, binding a card's standing grant to itsmid. A not-pending 404 is unchanged in shape. No newdecisionvalue is added.task-gate-<index>-…shape (railBadges.tsreads its prefix).ChatEmbed.tsx, the ops allowlist,kirocrew_client): route unchanged.Reader: website/src/store/chat/messages.ts:resolveByApprovalId -- chat -- removed: every permission row settles through
resolveApprovalRow, whose stale rulechatSlice.activityand the unsafe-key suite pin; an MCP elicitation row (ElicitationCard.tsxand theelicitation_resolvedframe) settles throughresolveElicitationRow, which touches elicitation rows onlyWhat changed (motivation → approach → change)
types/index.chat.ts; helpers intypes/approvalTarget.ts): coordinator = id, slot, instance; native = id, slot, permission-rowmid.api.decideApproval(api/client/approvals.ts, refusals classified inapi/apiError.ts) is the only client decide;approvalBareIdGuard.test.tspins it. Every surface sends it, the collapsed tool group throughdecidePermissionRow.ts. An MCP elicitation row is not an approval: it settles throughresolveElicitationRow(store/chat/messages.ts, called byElicitationCard.tsxandhooks/useWebSocket.ts), which touches elicitation rows only.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'smid, and takes the trust verbs. Native resolution frames, including the bulk Trust sweep, spelloriginandmid(native_resolution_target, used bychat_turn/permission_prompt.pytoo). A row'smidsurvives the slot-detail rebuild and the stream chunk (chat_utils_display._carry_row_mid).api.decideApproval(target, action, responseId)sends main'sresponse_idon both routes, so a retried click replays and a later collaborator's click gets the winner.run_task_id,task_index), because runs overlap task indexes;ProjectDetailPage.tsxmaps its own run's gates by them. The runner keepson_approval(task):task_executor.pysetstask.run_task_id(task_models.py) andservice_boot.pyrecords it.approvalframe; the replaced card retires when its press is refused or the reconnect reconcile no longer lists it.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 byutils/notificationTimestamp.ts.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 inchat-input/approval.ts.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.ErrorNoticeon every surface (ApprovalCard.tsxand the rest; errors-use-error-notice), in the one sentenceapproval_no_longer_pending(everywebsite/src/i18ncatalog). 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
ChatInput.approval(spawn withdrawal, same-id takeover, lost race),UseWebSocketCoverage.approvalReconcile(out-of-order reconnects; a native frame naming onemidsettles only that row),chatSlice.activity,ChatSliceElicitation,decidePermissionRow,approvalBareIdGuard,useAgentSync.approvalTarget, the 500-seednotificationsSliceproperty.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-*.mjsassert 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)