Repository navigation
fix: send the approval target from the chat embed and the python client - #39520
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each change carries the row's own target to a route that already accepts it. The real fix, refusing the bare id on the server, is deferred by name to #23636. What this change shipsInventory (8 items) — 8 justifiedIntent: let an app's chat embed and Python-client callers decide the exact approval request the card showed, not whichever request later reuses its id. FIX.
[FIRST-PRINCIPLES-REVIEWED] 101b984 Description read[DESCRIPTION-READ] 9308905321b105c57166e062506114a30b6c47e98dbe0da7afe058f4514eeddf That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: both callers now use the targeted decide form the route already accepts and the dashboard has sent since #27511. No server route changes, and the bare client call is unchanged. Notes
[DESIGN-REVIEWED] 101b984 Description read[DESCRIPTION-READ] eaa0da065667845221d1327401c615bb06ec9dfcf8fac3716e6b99ad4ff1becd 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) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the diff adds no control or string. It changes only the request payload and reuses the existing "no longer pending" notice, which shot-03 shows. Notes
[UX-REVIEWED] 101b984 Description read[DESCRIPTION-READ] c8c50c57dbfef8f4b7dc50042e5b3dab34faf870bcc87c898225f6dfc1b8a112 That sha256 names everything this verdict read: the PR description, plus the 6 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
A request id recurs, so a decide that names only the id resolves
whichever request holds it when the press lands: an embed card left up
for request A decided a later request B that took over A's id. The
dashboard's own controls already send an owner-bound target; the app
chat embed and the Python client were the first-party callers still
sending the bare id.
ChatMessageList now hands its host the pending row's meta beside the
id (and the rows' metas beside a batch's ids). ChatEmbed builds each
decide's native target from that row and posts origin "native" with
request_mid; a row with no native target sends nothing and rolls back
as no longer pending. resolve_approval gains keyword-only request_mid
(slot route, native target) and instance (coordinator target in the
query of /api/approvals/{id}/{action}); both at once, or request_mid
without slot_id, is refused before any request. The bare call is
unchanged, and no server route changes here.
Part of #23636
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25578f1 to
101b984
Compare
|
Rebased: main moved in .github/workflows/ci.yml and the two Windows-red tests' files since this head's CI ran (205d08d -> be1ce64); CI re-running. The reds on 25578f1 were main's, not this diff's (it touches no backend code):
The diff is unchanged (same patch-id); its tests, semgrep and the static checks ran green on the rebased tree. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Reviewed head 101b984. The chat embed and the Python client now send the request target that the decide routes already accept, and no server route changed. I checked that the new fields can only narrow what a caller resolves. The slot route still runs its session control check first, then resolves only a pending request in the addressed slot or one sharing its session whose delivery id matches, and an app token still cannot resolve a background approval through the coordinator form. The embed's approve, reject and trust actions are all accepted in the targeted form, a row without a target rolls back without sending anything, the client contract tests pass on this head, and the frontend suites are green in CI. Nothing blocks.
Problem / Motivation
Goal: The app chat embed (
ChatEmbed) and the Python client (kirocrew_client.resolve_approval) can decide a tool approval by the request the card showed, its owner-bound target, instead of by its request id alone.An app's chat embed posts Approve, Reject and Trust to
POST /api/chat/slots/{slot}/approvewith{action, request_id}only, andresolve_approvalin the Python client has no way to send anything else. A request id recurs, so when request B takes over request A's id, a press on A's card decides B.Why it matters
A request id recurs, so a decide that names only the id resolves whichever request holds that id when the press lands: an embed card left up for request A decides request B once B takes over A's id. The dashboard's own controls already send the target. The embed and the published Python client are the first-party callers still sending the bare id, and the server cannot refuse the bare form from apps and the owner's session (the rest of #23636) until they stop.
Not a goal
What changed (motivation → approach → change)
The embed and the client name a request by its id alone, and the id is not unique over time. The route already takes a targeted form that resolves only the exact pending request (the dashboard has sent it since #27511), so both callers now send that form.
ChatEmbedApprove / Reject / Trust, and a group's Approve all{action, origin: "native", request_id, request_mid}, built from the card row's ownmetawithpermissionRowTarget. A row with no native target (nomid, or a coordinator-injected row) sends nothing and rolls back with the existing "no longer pending" notice.ChatMessageList(app SDK)metaas a third argument toonApprove, and each row'smetabeside its id toonApproveBatch. Optional: a host that ignores it keeps working.resolve_approval(..., request_mid=, instance=)request_mid(withslot_id) sends the native target on the slot route.instancesends?origin=coordinator&slot=&instance=on/api/approvals/{id}/{action}for alist_approvals()record. Both at once, orrequest_midwithoutslot_id, raisesVALIDATION_ERRORbefore any request. Without either, the call is the same bare call as before.The spec (
app-kit-platform.md, "ChatEmbed approvals") anddocs/app-kit/api-reference.mddescribe the targeted forms. The bare-id guard test's header comment says the embed sends the target.Backwards compatibility
Compatible: the bare
resolve_approval(id, action, slot_id)call sends exactly what it sent before, and the new keyword arguments and callback arguments are optional. No server route changes, so every existing caller is answered as it was.Removes nothing: the only behaviour that differs is an embed card whose row carries no request target, which now shows as no longer pending instead of deciding whichever request holds its id.
Tests
ChatEmbed.approvalRollback.test.tsx("ChatEmbed approval target"): single and batch decides postorigin: 'native'+request_midfrom each row; a row with nomidposts nothing and rolls back with the refusal.ChatEmbed.test.tsx: Approve and Trust post the row's target; Trust still sendstrust.ChatMessageList.test.tsx: the batch handler receives each row'smetaaligned with its id.packages/kirocrew-client-py/tests/test_gateway_contract.py:request_midsends the native body on the slot route;instancesends the coordinator query (with a slot, and empty for a slotless record); the three unsendable combinations raise before any request.Proof: not provable -- other: prove.py is INCONCLUSIVE (exit 21) because with client.py reverted the new client tests raise TypeError instead of failing an assertion, and the frontend half is vitest. With the production files reverted, 7 vitest cases and 6 client cases fail; all pass with the fix.
Determinism: the four changed vitest files ran 3x in order and once with
--sequence.shuffle(90/90 each run); the client test file ran 3x (92 passed each; neither pytest-randomly nor pytest-random-order is installed on the test host).Manual verification
Reproduced and smoke-tested on Ubuntu 24.04.5 LTS (x86_64). No live agent turn could be raised inside an app embed there, so the exact code paths were driven instead:
api_chat_slot_approvethrough aiohttpTestClient, app caller): request A under idr1settled, request B under the samer1. The bare body resolves B. A's target gets404 approval_not_pendingand B stays pending; B's target resolves B.ChatEmbed→ChatMessageList→CollapsibleToolGroup), after the fix:Before the fix all three posted
{"action":…,"request_id":"r1"}only. The same run in Chromium (Playwright, route-mocked gateway) gave the same requests.TestServer):Real-machine verification
Machine: EC2 m7i.2xlarge, Ubuntu 24.04.5 LTS x86_64, 8 vCPU / 32 GiB
Before (main c22557c): the three temporary repro scripts above (server through
pytest -n0, embed throughvitest run, client against a recording gateway) -> card A's bare body resolves B (200, B done=True); the embed posts{"action":"approved","request_id":"r1"}for a row carryingmid: "m-A";resolve_approval(..., request_mid="m-A")raisesTypeError.After (head d9fe84917adc, same commands): the embed posts
origin: "native"+request_mid: "m-A", a row with nomidposts nothing, the client sends the native body and the coordinator query, and A's target is404 approval_not_pendingwith B still pending. Head 101b984 is that change rebased onto main be1ce64 with one validation message reworded; on its tree a machine of the same type ran the client suite (92 passed, 3x), the route contract (8 passed), the four changed vitest files (90 passed, 3x in order and shuffled), semgrep on the diff (0 findings), black, flake8, tsc and eslint (all 0).Cleanup: the repro, gates and screenshot machines of the earlier heads terminated;
describe-instancesanddescribe-volumesby their ids return[]. Every machine is SSM only, with no key pair and no inbound rule; the one that ran this head's checks is terminated when idle.Screenshots / video
The embed's pending approval row:
After Approve on a row that carries its target:
After Approve on a row with no target: nothing is sent and the row shows it is no longer pending:
Related Issues
Part of #23636
Sibling sweep
Swept: git grep -nE "/approve['`]|/approve"|request_id: ?(id|approvalId)" -- website/src packages
Sibling: website/src/app-sdk/ChatEmbed.tsx -- changed here
Sibling: packages/kirocrew-client-py/kirocrew_client/client.py -- changed here
Sibling: website/src/apps/mochi/panel/panelBridge.ts:1599 -- tracked in #23636
Sibling: website/src/api/client/chat.ts:350 -- not affected -- the dashboard's callers pass the row target, pinned by approvalBareIdGuard.test.ts
Sibling: website/src/pages/chat/crew-window/CrewChatWindow.tsx:375 -- not affected -- already sends origin native with request_mid
Pattern harvest
Not generalizable: the bare-id decide is closed by the server refusing it (the rest of #23636), not by a rule over callers; the dashboard's own controls already have their guard test.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits