Repository navigation
refactor(subagent_manager): unchain the proven spawn depth ternary - #26482
Conversation
The depth a spawning parent proves was one chained conditional expression with three outcomes: the deepest live parent record plus one, two for a sub-agent key with no live record, and one for a root session. Spell it as an if/elif/else so each case reads on its own line. Branch order and the values are unchanged. Two rules in it were unpinned: replacing the no-record child's 2 with 1 or 3, or the max over parent records with min, left every test in the 140 subagent, admission, spawn and overload-glue test files green. Pin both in test_subagent_spawn_depth_cap.py, the max over both registration orders; the pins pass on the parent commit too.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a refactor that changes no behaviour, and its two new tests pin rules nothing tested before. [DESIGN-REVIEWED] a511a31 Description read[DESCRIPTION-READ] cc0a5b61d7023fb7ec999b8b5a01ebbfafdf0dcb04b81a6690be32af873fc401 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 to check. What this change shipsInventory (3 items) — 3 justifiedIntent: make the spawn-depth rule easy to read and pin its two untested rules without changing any recorded depth. This is a refactor, neither a FIX nor an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] a511a31 Description read[DESCRIPTION-READ] 4e00ee4229834a67aff3b057891da811a72224f9bbff136acef01d68e128bf9f 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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: refactor (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: replaces one nested conditional expression for the proven spawn depth with an equivalent if/elif/else and adds tests for both branches; no behaviour change.
Problem / Motivation
Goal: Make the depth a spawning parent proves in
subagent_manager/admission/gate.pyread as three plain cases, and pin the two rules in it no test checked, without changing what depth any spawn records or which spawn the nesting cap refuses.spawn_implworks out a child's lineage depth from its parent in one chained conditional expression:max(_parent_depths) + 1 if _parent_depths else (2 if _is_child else 1). That one line carries three cases: the deepest live parent record plus one, two for asubagent:parent key with no live record, and one for a root session. The result, raised to any depth carried in, is what the nesting cap compares against.Two of its rules are not pinned. Replacing the no-record child's
2with1or3, or themaxover parent records withmin, leaves all 3817 tests in the 140 related test files green.Why it matters
Nothing is broken today. The nested form hides the middle case, the one a reader most needs when a parent's record is gone, inside a parenthesised tail. And because two of its rules are unpinned, a later edit could change the depth a child records, and so where the nesting cap starts refusing, with no test going red.
Not a goal
dashboard/, which are test-pinned or in keystone files.gate.py; ten open PRs touch the file elsewhere.What changed (motivation → approach → change)
No spawn records a different depth and no spawn is refused differently. The one expression becomes an
if/elif/elsein the same branch order with the same values, and two new tests pin the two rules that were unchecked.subagent_manager/admission/gate.py,_proven_depthif _parent_depths:deepest record + 1,elif _is_child:2,else:1. The comment above it is unchanged; it describes the twosubagent:parent cases, and a root session's 1 is theelse.test/test_subagent_spawn_depth_cap.pytest_child_of_a_sub_agent_with_no_live_record_is_depth_two: a spawn fromsubagent:gone01with no live record and no carried depth records depth 2.test_the_deepest_live_parent_record_sets_the_childs_depth, run in both registration orders: with the original run and a running continuation of it at depths 1 and 2, the child records depth 3.Backwards compatibility
Compatible: every input gives the same
_proven_depthas before, so stored depths, SELrejected_depth_capoutcomes and refusal messages are unchanged.Removes nothing: the diff only restructures one assignment and adds tests.
Tests
test/test_subagent_spawn_depth_cap.py, all passing on the parent commit as well.+ 1, a root child at 2, and ignoring live parents. Three survived: the no-record child at 1, the same child at 3, andminformax. With the new tests, the depth-cap file alone kills all six, and two more: the last registered record winning, and the first one winning.test/test_subagent_spawn_depth_cap.py(14 tests): 20 serial repeats, 10 runs at-n 4beside the other threetest_subagent_spawn*files (73 tests), and two shuffled orders of its node ids (seeds 30103, 7741), all green.test_flake_pattern_ratchet.py: 64 passed.gate.pyis a hub file (the related-test runner selects 2440 test files), so the local run covers the 139 files namedtest_subagent*,test_admission*andtest_spawn*, plustest_overload_integration_glue.py: 3820 passed in three of four runs across this branch's rebases, which leave both files unchanged. The fourth had one failure,test_subagent_reap_attribution.py::test_a_deadline_reap_names_the_deadline_not_the_death: its no-ERROR-log assertion caught asyncio's "Task was destroyed but it is pending!" for a pending pump drain task (_drain_queue_async_impl) that was garbage-collected during that test. The test passes 10 of 10 runs alone, on this branch and onmainat81dde23e17; a probe that forces a collection after every depth-cap test finds no leaked task from any of them; and dropped tasks being collected is open issue Dropped asyncio.create_task results can be garbage-collected mid-run #25953. CI runs the full suite.scripts/scrub-lint.shis absent from the tree. Semgrep is not installed here; CI's SAST job runs it. No frontend run: nothing underwebsite/,.github/orscripts/changed.gate.pynot keystone: the nesting cap is a resource limit, and the governance checks it calls live in other files. Two independent adjudicators upheld six of the prose lens's findings, all fixed in this description and the commit message, and one test gap: the parent-record test passed a mutant where the last registered record wins, so it runs in both orders. Both refuted one finding ("no live record" matches the file's existing wording), and they split on whether "two cases" overstated what was unpinned; it says two rules.Manual verification
N/A: the code change restructures one assignment with identical results, and the unit tests above cover every case it has.
Screenshots / video
Why no screenshot: backend-only restructuring of one assignment plus new tests; no page, response or frame changes.
Related Issues
Part of #16523
Overlap: ten open PRs touch
gate.py(#10098, #10171, #11324, #12821, #13109, #15543, #17684, #18165, #22252, #26463); none of their patches touches_proven_depth,_parent_depthsor_is_child. No open PR touchestest/test_subagent_spawn_depth_cap.py.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)