Repository navigation
feat(crew-api): let the owner answer tool approvals without a dashboard - #39962
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: process-lifetime Notes
[DESIGN-REVIEWED] cc6644c Description read[DESCRIPTION-READ] 621829c1a665a99ff6ff9ba6742def7b34aa693564d2b83770c217f359bff19a 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One query filter, Notes
What this change shipsInventory (10 items) — 8 justifiedIntent: the owner of a gateway with no dashboard can see the tool approvals that are waiting and answer allow or deny through the Crew API. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] cc6644c Description read[DESCRIPTION-READ] 40697cf7f06b8b1919520b44a072ba7e362aedffe8d1babc34893587c614bc49 That sha256 names the PR description this verdict read. 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: |
2da4fa7 to
2ce82d1
Compare
|
|
|
2ce82d1 to
09751c2
Compare
|
|
09751c2 to
599abc4
Compare
|
599abc4 to
019d69a
Compare
|
|
resolution: narrowed -- the on-disk approval record leaves this PR
|
019d69a to
e3fdd92
Compare
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. Adds three host-owner-only Crew API routes to list, read and answer tool approvals using in-memory apr_ ids. Access goes through owner_route and then is_host_owner_dashboard_request, the same gate as the grant-request routes. The background-request answer path repeats the dashboard's own slot/instance/open-future check; the chat-prompt path pins the exact future through resolve_on_slot, which also refuses allow on an override card. resolve_pinned_slot_approval is a faithful move and resolve_approval_by_id calls it with the same arguments. Reading what is waiting, recording endings and updating ids run in one step with no await. Pruning removes only ended records. Tests are broad and CI is green. No blocking issues found. Tier: 2, held for a person: design-doc-gate: D. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
e3fdd92 to
0fc8e50
Compare
0fc8e50 to
cc6644c
Compare
|
class: a live registry is read by a caller id before the record is proven to be the request still waiting
|
|
This PR adds a new way to answer tool approvals. The host owner can allow or deny a waiting tool call over the Crew API, with no dashboard. It also amends the accepted Crew API RFC: ids are held in memory only, a cancelled turn reads Review result on head cc6644c: no blocking findings, and PR Readiness is green. The review read the whole diff and followed every answer path. It ran For the security review:
Optional:
|
bolichen97
left a comment
There was a problem hiding this comment.
Maintainer decision on head cc6644c993 (Bolin, via Bolin Review bot): approved. The host owner may answer tool approvals over the Crew API.
On the security question above (can code in the agent's sandbox read a credential that passes the host-owner check): the three new routes go through owner_route → require_owner_dashboard_request and then is_host_owner_dashboard_request, the same gate as the dashboard's own approval routes, and they answer through the same resolvers. So a sandboxed turn that could get past this gate could already answer its own approval through the dashboard routes today; these routes add no new reach for that case. Keeping the owner's credential out of the sandbox stays the boundary, as it is now.
Before the next release, please run one real pending approval through POST /v1/crew/owner/approvals/{id}/decision on a real machine (allow and deny) and note the result on the PR, since this head was not run on one.
AI-assisted, sent by Bolin Review bot
Problem / Motivation
Goal: On a Kiro Crew with no dashboard, the owner of the machine can list the tool approvals that are waiting, read one, and answer it with allow or deny, over the Crew API.
A tool approval is the gateway pausing before a tool call until a person says yes. Today a person answers it on the dashboard: the routes behind the approval card name a request by an id its caller chose, which can repeat, plus the session and the card it was shown on. A gateway that runs without a dashboard has no card, so a turn that asks for an approval waits until it times out.
Why it matters
A Kiro Crew on a server is only useful to an app on that machine if its owner can still say yes or no to a tool call. This is the last approval piece of "a Kiro Crew with no dashboard that an app on the same machine can use".
Not a goal
allow_always. It stays a proposal./v1/crew/approvals), no embed credential, no events.conv_ids, noexpires_at, nofinalfield in the 409 body.What changed (motivation → approach → change)
Goal: one id per approval that an owner without a dashboard can list, read and answer, and that never answers a different request.
Approach: the gateway keeps an approval in memory in two places, under a caller-chosen id that repeats: a background request (a cron job's, a subagent's, a task gate) and a chat turn's own tool prompt. Each already has a name that does not repeat: the record's
instance, and themidof the prompt's row. So the new routes give each request oneapr_id the first time they see it, keep it in memory with that name, and answer through the resolvers the dashboard already uses.The ids live for the life of the gateway process. Every step that reads what is waiting and updates the ids runs on the event loop with no await in it, so two calls cannot interleave. Keeping the ids across a restart is left to a later change.
RFC amendment, proposed. It needs a maintainer to accept it. Merging this PR accepts these changes to
rfc-crew-api.mdandassets/crew-api/crew-owner.yaml:GET /v1/crew/owner/approvals,GET /v1/crew/owner/approvals/{approval_id},POST /v1/crew/owner/approvals/{approval_id}/decision. They are listed under "Routes outside the 59".allowordenyonly.owner_only.apr_id lives for the life of the gateway process; after a restart it is 404. A record that survives a restart is proposed and not in this amendment.conversationis the session's key until the conversation operations exist.expires_atand the 409 body'sfinalare left out.expiredwith reasontimeout, notturn_cancelled; when a Stop rejects a chat turn's own waiting prompt, it readsdenied. Only one of the two approval paths records that a turn was cancelled, and reportingturn_cancelledon both needs a change to the sharedinteraction_coordinator, which a later PR makes.Change:
dashboard/crew_api_approvals.py(new): reads the waiting requests, keeps theapr_ids in memory, and serves the three handlers.dashboard/routes/crew_api.py: the three routes.shared_crew/decisions.py:resolve_pinned_slot_approval, moved out ofresolve_approval_by_idunchanged.test/fixtures/crew_api_owner_openapi.json, the module spec, the feature map, the RFC andcrew-owner.yaml.Behaviour, each with a test:
denyon a chat prompt refuses that one call and the turn goes on.deny;allowis 403approval_requires_dashboard.dashboard/routes/crew_api.py,rfc-crew-api.mdandlearn-cron-dashboard.mdare also changed by the open #39574. This PR does not depend on it. Whichever merges later rebases.Size: 1674 added lines: 705 tests, 475 docs and contract, 494 source.
Backwards compatibility
Compatible: three new routes and one new function; no existing route, body or check changes.
resolve_approval_by_idcalls the moved code with the same arguments.Removes nothing: the diff adds routes, a module and a function, and deletes no route, record, key or function.
Tests
test/test_crew_api_approvals.py, 49 cases:owner_onlyon all three routes, and nothing is answered;limitandafter, reads one, and gets 404 for an unknown id and 400 for a bad query; an elicitation is not listed;allowedordeniedwith nodecided_by;deniedrow naming the owner and the approval; a failed audit write does not change the response;allow_always, an extra field, an empty body and a non-object answer nothing (400); alimitof 5,000 digits is 400, not 500;The checks that decide whether an answer may land, and what proves each one:
decide_approvaltest_a_record_that_is_not_pending_is_refused_before_the_answer_layer_answer, background request: record present, same instance, same slot, future present and opentest_the_answer_layer_refuses_a_background_request_that_is_not_the_one_waiting(5 cases)_answer, chat prompt: slot present, future present and open, same instancetest_the_answer_layer_refuses_a_chat_prompt_that_is_not_the_one_waiting(4 cases)_answertest_an_answer_the_layer_refused_is_409_and_settles_nothingNo check on this path was taken out. The
_answertests call that layer directly, on a record the index has not caught up with, so each check decides alone; over HTTP the record's state would refuse first.Two cases at once, each for both kinds of request:
test_two_answers_at_once_settle_the_request_once);expired(test_an_answer_after_the_turn_ended_runs_nothing).Each of 29 guards was broken in turn (the host-owner check on each route, every check in the table, the 404, the body and
limitchecks, the id cap, the filters, one id per request, the audit rows, the override refusal). 28 made a test fail. The one that did not isslot is Nonein the chat branch of_answer: without it the next term,future is None, refuses the same case, and it stays because the line after readsslot.approval_instance.Determinism: the file passed 3 runs in a row, single process, after the last test was added. It never sleeps and every wait has a bound.
test/test_flake_pattern_ratchet.pypasses.test/test_crew_api_owner.pychecks every Owner route against the contract fixture.The diff-related backend set (260 files) ran on the previous head: 13400 passed, 23 failed, 5 errors. Those 28 node ids, run alone on unmodified main
94b00be731bon the same machine, fail the same way (missingbotocoreandh2, and tests that start a secondpytest).mypy src/kiro_crew/, the CI command, reports 3 errors here, all insrc/kiro_crew/wecom/client.py, which this PR does not touch and which CI does not report; this PR's files are clean. The repository's semgrep rules were run on the first revision only, with semgrep 1.183.0 and not the pinned 1.78.0.Manual verification
See the real-machine run below.
Real-machine verification
The run was on the first revision,
9c9367650da. The head has not been run on a real machine. It differs from that revision: the ids are kept in memory and not on disk, the decision route writes audit rows for its refusals, and a list call skips sessions with nothing waiting. The calls above touch none of that, and the in-process tests cover it.Not verified on a real machine: answering a real pending approval, with allow and with deny. No approval was waiting on that gateway, so the list was empty on both runs. That path and the same-id check are covered by the in-process tests above only.
Related Issues
None. Follows #39564 and #39921.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commitsContribution License Agreement
Contributed under the project's Apache-2.0 license.