Skip to content

fix: record a host spawn-approval decision as the host's - #31954

Merged
bolichen97 merged 1 commit into
mainfrom
fix/16574-spawn-approval-host-by
Nov 7, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/16574-spawn-approval-host-by

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A spawn approval the host answered by itself is recorded in the crew log as the host's decision, not a person's.

The spawn gate writes approval/decided with no by and no cause after every normal return of the spawn approval callback, which by definition means a person answered. That callback often answers alone: when subagent is in hooks.auto_approve_sources, under --approval yolo, under the YOLO override, under slot trust, with no UI at all, and when a Slack prompt's window closes. Each of those shows up in the approvals fold as a person's decision (item 1 of #16574; items 2 and 3 shipped in #30999).

Why it matters

An operator who audits who approved a spawn is told a person decided when nobody was asked. A wrong by is worse than none: it sends the reader to a surface and a person that were never involved.

Not a goal

What changed (motivation → approach → change)

Who answered the spawn prompt approval/decided before after
a person (Slack button, dashboard, channel button) no by no by (unchanged)
auto-approve source, --approval, YOLO override, slot trust, no UI no by by: host
a Slack prompt nobody answered no by, no cause by: host, cause: approval_timeout

Cause. The callback returns a bare bool, so the gate cannot tell its own answer from a person's.

Change. The spawn callback returns a HostSpawnDecision(approved, cause) when the gateway answered alone, and a bare bool still means a person answered. _interactive_approval takes an optional on_host_decision hook that each answer-alone rung calls; only the spawn gate's instance passes it, so tool approvals are unchanged and still return a plain bool. HostSpawnDecision is falsy for a decline, so a plain if cannot read a host no as a yes. HostSpawnDecision sits beside SpawnApprovalUnreachable in subagent_parts/delivery.py and is served from subagent.py, the import path its callers use. The approve/reject outcome is the same on every path. The crew-log-emitter, slack-gateway and subagent specs say which answers are the host's.

Backwards compatibility

Compatible: a person's answer is still a bare bool recorded without by, the new on_host_decision keyword is optional, and no spawn is approved or rejected differently.

Removes nothing: no field, key or path is taken away; host-decided entries only gain by: host and, for an expired Slack prompt, a cause.

Tests

  • test_spawn_approval_crew_log.py::test_an_answer_the_callback_gave_with_nobody_asked_is_the_hosts: a host decline is written by: host with its cause, the spawn is still rejected, and the decision is falsy.
  • test_spawn_approval_no_surface.py::TestHostDecisionsAreReported: the real _interactive_approval reports the auto-approve source, --approval yolo and the YOLO override as host approvals without raising a prompt, and an unanswered Slack prompt as a host decline with approval_timeout.
  • test_gateway_subagent_wiring.py::test_a_spawn_the_gate_answered_with_nobody_asked_returns_a_host_decision: the wiring turns a reported answer into a HostSpawnDecision and leaves a person's answer a bare True.
  • Source and signature pins (test_spawn_approval_delivery.py, test_spawn_approval_no_surface.py, test_gateway_subagent_wiring.py, test_slack_gateway_composition_contract.py) follow the changed callback line and signature.

Proof: not provable -- prove.py timed out

By hand instead: with pump.py put back to origin/main, the crew-log test fails (KeyError: 'by'); with the on_host_decision report removed from _interactive_approval, all four TestHostDecisionsAreReported cases fail.

Determinism: the new and changed tests passed 20 runs at -n0, 10 runs at -n 4 --dist loadgroup beside their own files, and a shuffled order (seed 3217).

Manual verification

N/A — unit coverage sufficient: the change is the value of two crew-log fields, pinned at the gate, at the wiring and on the real approval callback.

Screenshots / video

N/A — no user-visible frontend surface is touched.

Related Issues

Closes #16574

Sibling sweep

Swept: git grep -nE "request_approval(|unpressed_wait_answer(|_on_spawn_approval(" -- src/kiro_crew
Sibling: src/kiro_crew/slack/gateway_runtime/turn_approvals.py -- changed here
Sibling: src/kiro_crew/dashboard/interaction_coordinator.py -- tracked in #31930
Sibling: src/kiro_crew/messaging/spawn_approval_delivery.py -- tracked in #31930
Sibling: src/kiro_crew/subagent_manager/run.py -- not affected -- a running child's tool prompt is recorded by its own writer, not this callback

Pattern harvest

Rule candidate: review-prompt
Pattern: a callback returns a bare bool that merges "a person decided" with "the code decided" while its caller records who decided

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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 7, 2026 00:51
@bolichen97
bolichen97 enabled auto-merge (squash) November 7, 2026 01:13
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/16574-spawn-approval-host-by branch from c6c63cf to 49a3604 Compare November 7, 2026 04:03
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/slack-gateway.md, src/kiro_crew/slack/gateway.py since this head went green (bf007d8 -> 76ec06a); CI re-running.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/subagent.md and the crew log emitter spec since this head went green (76ec06a -> b65af1a); CI re-running.

The one test red on the previous head (test_perf_sampler.py::TestCliSample::test_raising_call_still_emits_the_profile, Backend Tests (3.12, 5)) is unrelated to this change and is recorded in #32181.

[operator: bolichen97]

@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 Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 9147e7d0a34dc68a07f828f8a9efefda06bfef6b touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 9147e7d0a34dc68a07f828f8a9efefda06bfef6b — 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

Nothing blocks. The defect is item 1 of the linked #16574, with a crew-log test that fails on base. The fix is at the cause: the callback's bare bool return. The sibling paths left unfixed are named and deferred to #31930.

What this change ships

Inventory (6 items) — 6 justified

Intent: when the host answered a spawn approval itself, the operator's audit log says so instead of naming a person. This is a FIX.

  1. A spawn approved by an auto-approve source, --approval, the YOLO override, slot trust or no UI is now logged by: host — justified
  2. An unanswered Slack spawn prompt is now logged by: host, cause: approval_timeout — justified
  3. The spawn callback can return HostSpawnDecision, which is falsy on a decline — justified
  4. New optional on_host_decision keyword on _interactive_approval, passed only by the spawn gate — justified
  5. The Slack timeout branch's internal outcome is expired instead of rejected; the card and the result are unchanged — justified
  6. The crew-log-emitter, slack-gateway and subagent specs now say which answers are the host's — justified

[FIRST-PRINCIPLES-REVIEWED] 9147e7d

Description read

[DESCRIPTION-READ] 2530006cdb29bc44532bcc55b3e08e7434e7b7cf95dd5c6122a8e8224089b5d3

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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 9147e7d0a34dc68a07f828f8a9efefda06bfef6b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the host-versus-person split happens where the decision is made, tool approvals are unchanged, and HostSpawnDecision is falsy on a decline.

Notes

  • The callback reports host answers by writing into a side dict (_host_decided.__setitem__), and _spawn_approve pops the entry after the call. If that call raises or is cancelled between the report and the pop, the entry is never removed. Returning the tagged value directly from the spawn-gate instance would drop the shared dict and the step that has to match up the request id.
  • Both channel delivery (deliver_spawn_approval) and a dashboard-only prompt's expiry still come back as a bare bool, so they are still recorded as a person's decision. The only thing that keeps the crew log honest about them is the crew log: a spawn prompt that expires on the dashboard or a chat channel is recorded as a person's decline #31930 follow-up.

[DESIGN-REVIEWED] 9147e7d

Description read

[DESCRIPTION-READ] 3c1c34af067ec6901a7c1607a2120b1177c3d2407d2095d9866a9e290d4ec759

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 Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 9147e7d

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 9147e7d0a34dc68a07f828f8a9efefda06bfef6b false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 9147e7d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 9147e7d0a34dc68a07f828f8a9efefda06bfef6b false-positive: <reason, 20 to 500 characters>

@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 Nov 7, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The red on c17d4eb is main's, not this change's. test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget fails in Backend Tests (3.12, 2) and Backend Tests (Windows) (2) because main's kiro_crew.security package has measured 34,855 lines against a 34,845 budget since #30976 merged. This PR touches no file in that package. Coverage Gate and PR Readiness are red only because those two shards failed.

#32183 raises the budget to main's measured size. This PR waits for it to merge, then rebases onto it and re-runs CI.

The spawn gate wrote approval/decided with no `by` after every normal
return of the spawn approval callback, which reads as a person's
answer. The callback often answers alone: an auto-approve source,
--approval, the YOLO override, slot trust, no UI, or a Slack prompt
whose window closed.

The spawn callback now returns a HostSpawnDecision(approved, cause)
when the gateway answered with nobody asked, learned through a new
optional on_host_decision hook on _interactive_approval that only the
spawn gate passes. A bare bool still means a person answered, so tool
approvals and every approve/reject outcome are unchanged. The gate
records `by: host`, with `cause: approval_timeout` for an expired
Slack prompt.

Closes #16574
@bolichen97
bolichen97 force-pushed the fix/16574-spawn-approval-host-by branch from c17d4eb to 9147e7d Compare November 7, 2026 13:33
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/subagent.md, src/kiro_crew/slack/gateway_runtime/subagent_wiring.py since this head went green (b65af1a -> f58c3cf); CI re-running.

The only red on the previous head, test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget in Backend Tests (3.12, 2) and Backend Tests (Windows) (2), was main's: #32252 raised the package budget to its size on main, and this rebase carries that. The diff of this PR is unchanged; the related tests pass locally on the new base.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: PR Readiness passed on 9147e7d, and all five review lanes (Opus 5.5, GPT 6.1, Design, UX, First Principles) report no blocking finding on this head. No conflict and no open change request.

@bolichen97
bolichen97 merged commit 7cb813b into main Nov 7, 2026
99 checks passed
@bolichen97
bolichen97 deleted the fix/16574-spawn-approval-host-by branch November 7, 2026 19:47
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
bolichen97 added a commit that referenced this pull request Nov 9, 2026
The spawn gate wrote approval/decided with no `by` after every normal
return of the spawn approval callback, which reads as a person's
answer. The callback often answers alone: an auto-approve source,
--approval, the YOLO override, slot trust, no UI, or a Slack prompt
whose window closed.

The spawn callback now returns a HostSpawnDecision(approved, cause)
when the gateway answered with nobody asked, learned through a new
optional on_host_decision hook on _interactive_approval that only the
spawn gate passes. A bare bool still means a person answered, so tool
approvals and every approve/reject outcome are unchanged. The gate
records `by: host`, with `cause: approval_timeout` for an expired
Slack prompt.

Closes #16574

(cherry picked from commit 7cb813b)

Backport note: turn_approvals.py, its composition-contract signature
and the slack-gateway.md list add on_host_decision without the
requester parameter and its card line (feat #31393, not on release), so
the doc entry is numbered 6 on release.
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.

crew log: spawn approval entries can record a host decision as a person, turn 0, and a hook that never ran

2 participants