Repository navigation
refactor(subagent): unchain the approval-outcome ternary - #14654
Conversation
|
Intent: Make the subagent SEL approval-outcome label selection readable by replacing its chained ternary with a guard-first if/elif/else, producing the identical label for every input. |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. Behavior-preserving refactor of a chained ternary into guard-first if/elif/else; the three outcome labels map identically for every input, no surface rendered. [DESIGN-REVIEWED] 7277527 |
Opus 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: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. The three output labels are provably unchanged across all What this change shipsInventory (1 item) — 1 justifiedIntent: Make the subagent approval audit-label selection readable; a pure refactor (neither fix nor capability addition).
[FIRST-PRINCIPLES-REVIEWED] 7277527 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
_approve_and_log picked its SEL outcome label with a chained conditional expression that re-tested `approval_sent is not False` in two arms. Resolve it with a guard-first if/elif/else instead: an approval the transport rejected (approve_tool returned False) is the transport-floor rejection, an approval carrying a metadata reason is auto_approved, anything else is approved. Same three labels for every input; no behaviour change.
ce62bdb to
7277527
Compare
|
Rebased: main moved in test/test_remote_crew_chaining.py since this head went green (631f8e6 -> 6a8cb5e); CI re-running. The prior head's only red was |
Problem / Motivation
Goal: Make the subagent approval audit label readable at a glance, with no behaviour change.
SubagentManager._approve_and_loginsrc/kiro_crew/subagent.pychose its SELoutcomelabel with a chained conditional expression that testedapproval_sent is not Falsetwice. It was the last chained ternary the module-simplification detector found onmain.Why it matters
This label is an audit field. A reader checking which approvals get recorded as
rejected_transport_floorhad to untangle a nesteda if x else b if y else cinside a call's keyword arguments.Not a goal
task_executor.py,eval/runner.py,slack/handler.pyordashboard/handlers/hooks.py. They are not chained, and each lives in another module.approve_tool-returned-Falsepath, which was untested before this PR too.What changed (motivation → approach → change)
The outcome is now picked by a guard-first
if/elif/elsejust above thesel().log_tool_invocation(...)call, and passed in asoutcome=outcome.approval_sentreasonFalserejected_transport_floorauto_approvedapprovedThe one ordering difference:
metadata.get("reason")now runs beforesel()instead of after. Both are side-effect free here (every caller passes a dict literal orNone, andsel()returns the singleton log), so nothing can observe it.Backwards compatibility
Compatible: the same three labels come out for every input. An exhaustive differential over 56
approval_sent×metadatacombinations, includingNone,0,"",{}and falsy reasons, matched in every case.Tests
No test changes. The existing suites that drive this function pass locally:
test_subagent.py,test_subagent_coverage.py(asserts theauto_approved/approvedlabels),test_subagent_startup_pressure.pyandtest_transport_permission_floor.py(pins oneapprove_toolcall in_approve_and_log; unchanged). 503 passed.Gates run on the Python 3.12 CI-parity venv: flake8, isort, mypy,
check_black_formatting.py,check_subprocess_encoding.py,check_brand_name.py,check_harness_parity.py,docs_lint.py --test,docs-lint.sh,check_per_file_coverage.py --testandverify_vendor_manifest.py, all exit 0.scripts/scrub-lint.shis not in the tree; that scan runs in CI only.A five-lens review fleet (AUTOSDE blocking rules, behaviour preservation, import semantics, security keystone, comment accuracy) found no defects. It raised one wording nit: the commit message called
approve_toolreturningFalsea "failed" approval, when the provider contract says the transport rejected it. The commit message was corrected. Nothing was dropped.Backend-only diff: nothing under
website/,.github/orscripts/changes, so CI'schangesjob reportsonly_backend=trueand the frontend suites were not run locally.Manual verification
N/A: unit coverage is sufficient. This is a pure refactor of one expression, and its equivalence was checked by running both forms over every input combination.
Screenshots / video
Why no screenshot: backend-only refactor of one audit-label expression; nothing renders differently.
Related Issues
no linked issue: a readability sweep from the module-simplification campaign, not tracked by an issue.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)