Skip to content

refactor(subagent): bind SubagentManager methods from subagent_parts - #21278

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g07-subagent-p2
Oct 17, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g07-subagent-p2

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring src/kiro_crew/subagent.py under the 2,000-line cap by moving SubagentManager, SubagentInfo and the delivery contract into focused kiro_crew.subagent_parts modules, with no change in behaviour.

This is the second of two PRs (the first, #20401, moved the module-level helpers). After it, subagent.py was still 4,697 lines, almost all of it the SubagentManager class (about 4,000 lines). The campaign in #20192 caps hand-written files at 2,000 lines, and a class that size cannot be cut by moving whole definitions.

Why it matters

SubagentManager is where every subagent change lands. One 4,000-line class is read in fragments by people and review lanes alike, and edits to unrelated parts of it conflict. Each responsibility of the manager now has one module, so new code has an obvious home and subagent.py stays a small facade.

Not a goal

  • No behaviour change: method bodies move verbatim; no logic, wording, logging or error text changes.
  • No change to subagent_manager/ coordinators or their bind_component_globals mechanism.
  • No new public API: every name stays importable and patchable at kiro_crew.subagent, and every SubagentManager.<name> member stays the same kind with the same signature.
  • Not the consolidation of the facade-package compose() copies (tracked in refactor: share one compose() helper across facade packages #20421).

What changed (motivation → approach → change)

subagent.py drops from 4,704 to 709 lines; no file in the family is over 1,100 lines.

Owner Lines Owns
manager.py 1,050 SubagentManager: constructor, class attributes, properties, the durable task queue, one binding per other method
admission_surface.py 850 the spawn entry: admission (sync and async) and spawn approval, startup population, the run-id draw, the memory-pressure hold, the queue drain
run_record.py 703 SubagentInfo and the scope fields it carries
terminal_surface.py 429 terminal reports: finalize claim, slot release, forced reaps, tombstones, panel-dismissal settling, the wave and batch digest
monitor_surface.py 335 the orphan and stall watch, the reaper loop, cost sampling, the dependency coordinator, the task-queue pump
run_surface.py 332 the run loop glue: _run, _run_inner, the provider seam, queue-depth and pending-work queries, the off-loop writers
delivery.py 334 callback contracts, delivery-routing fields, delivery_is_parked, the teardown gate's ids
continuation_surface.py 321 continuable conversations, successor claims, steering and follow-ups
cancellation_surface.py 282 the intentional-cancel chokepoint, queued-run stops, parent-end teardown and its fence
config_surface.py 248 live configuration: sizing re-reads, turn limit, effective cap

The class is split by binding, not by mixins or forwarding stubs. Each *_surface module holds methods as plain functions taking self, and manager.py binds them as class attributes (spawn = _admission_surface.spawn). The class attribute IS the moved function, so MagicMock(spec=SubagentManager), autospec, inspect.signature, and SubagentManager.<name> patches see exactly what the one-module class had. The shared kiro_crew._facade_compose.compose() (called with host=SubagentManager) runs every moved function on subagent.py's globals, so the ~1,500 kiro_crew.subagent.<name> patch targets keep reaching moved code.

Two ACP names the moved code needs reach it through kiro_crew.agent_sdk.drivers instead of a new ACP import: acp_vocab re-exports InFlightToolTracker, and drivers/acp.py gains a provider_label wrapper. subagent.py's agent-sdk boundary edge count drops from 7 to 6.

Backwards compatibility

Compatible: every name kiro_crew.subagent bound at the base still resolves there to the same object (test_campaign_facades_base_public_names.py), every SubagentManager member keeps its kind and signature (test_subagent_parts_composition_contract.py inventory of the 213 base members), and every kiro_crew.subagent.<name> patch still reaches the moved code.

Reader: src/kiro_crew/subagent_manager/cancellation.py:delivery_is_parked -- subagent -- imports it from kiro_crew.subagent, which re-exports the same object; test_session.py

The security posture panel names subagent_parts/run_output.py instead of subagent.py for the "Subagent results" sink (see Registries below).

SubagentManager.__module__ is now kiro_crew.subagent_parts.manager and SubagentInfo.__module__ is kiro_crew.subagent_parts.run_record; nothing reads them (pickle, copyreg, shelve, repr and error-text greps: no hits). SpawnApprovalUnreachable keeps kiro_crew.subagent, because a traceback, a log line and a pickle name an exception by its module. Bound methods keep their SubagentManager.<name> qualname.

Tests

  • test/test_subagent_parts_composition_contract.py (extended): the 213 base SubagentManager members keep their kind, coroutine-ness and signature (the binding's self annotation left out), each bound member IS its owner's function, no bound function needs the class body (zero-argument super(), __class__, a name-mangled attribute; with self-tests), the host module may import only its collaborators, bound functions keep their SubagentManager.<name> qualname, every class an owner defines reports its owner module except the one named exemption, and SpawnApprovalUnreachable reports kiro_crew.subagent and resolves there.
  • test/test_subagent_parts_provider_label.py (new): the SDK provider_label wrapper and SubagentManager._provider_label_of answer exactly what kiro_crew.providers.acp.provider_label answers for every provider kind (an AcpProvider per backend before and after its startup swap, a bare AcpSessionProvider, a spec'd mock, a non-ACP object) and every label the helper can return; the standalone ClaudeCodeProvider sentinel still wins.
  • test/test_subagent_parts_config_surface.py (new): a reload that cannot size the cap keeps the cap in force, a limit that does not parse keeps the limit in force, and a broken cap-raise hook does not block the raise.
  • Determinism: the new tests use monkeypatch and caplog; no clock, sleep, port or order assertion. Each passed 5 runs at -n0 and one at -n 3.

Local runs on this head (Python 3.12, -n 3):

Set Result
the 358 test files that import, patch or read the subagent family, plus the 66 test files main changed after #20401 merged 27,212 passed, 22 skipped, 0 failed
the 275 other whole-tree scanning test files (source_corpus, rglob and os.walk users, test_transcript_derivation_seam.py, test_link_screen_hold_pin.py) 20,221 passed, 125 skipped, 5 xfailed
mypy src/kiro_crew no issues in 2,691 files
per-file line coverage of every subagent_parts owner (CI's --cov=kiro_crew) 93.4% to 100%

scripts/local-gate.py --dry-run selects 2,261 backend and 894 frontend test files, so the sets above stand in for it; CI runs the full suite.

Manual verification

  • The split is generated by the same recipe from main's one-module subagent.py; re-running it reproduces every generated file and the contract test byte-for-byte.
  • Installed-mode smoke: a wheel built from this head, installed into a scratch venv, imports kiro_crew.subagent and every kiro_crew.subagent_parts module.

Related Issues

Part of #20192

Move audit

move_audit.py --origin src/kiro_crew/subagent.py against main reports most class members as changed, because a bound method gains a self: SubagentManager annotation, loses @staticmethod (the class binds staticmethod(owner.f) instead) and dedents its docstring. A normalized-AST supplement (strip exactly those three edits, inspect.cleandoc docstrings) compares the rest:

src/kiro_crew/subagent.py: 4704 -> 709 lines; moved 37.29% (python-ast)
normalized: changed units: 196; normalized-equal: 191 (2101 lines); still changed: 2; not a function: 3

The two that still differ are the planned edits: the _audit_ids docstring now names where the helper is bound, and _provider_label_of imports provider_label from kiro_crew.agent_sdk.drivers.acp instead of the providers layer. The three non-function units are the binding tuple, the compose call, and SpawnApprovalUnreachable, whose class body gains __module__ = "kiro_crew.subagent" and a comment saying why. The only other added code in manager.py is the 17 class-level field annotations (see Composition mechanism). git diff and git diff --minimal add the same lines in every changed file.

Composition mechanism

The shared kiro_crew._facade_compose.compose, called with host=SubagentManager, runs every moved function on subagent.py's globals and gives each bound method its SubagentManager.<name> qualname back. The class body stays in manager.py with its constructor, class attributes, properties and the durable task queue it opens and closes, and declares the 17 instance fields mypy reports [has-type] for in a surface module (_admission: SpawnAdmissionCoordinator, ...): a surface imports manager.py only for type checking, so mypy checks it before it infers them from __init__; every other method is a binding grouped under one comment per surface. Each surface's docstring lists the manager fields it reads and writes. An owner that calls os, time, subprocess or socket imports it as import <module> under TYPE_CHECKING, so scripts/check_sync_io_in_async.py still sees moved coroutines (a planted time.sleep(1) in one is flagged).

Moved classes report their owner module as __module__ (SubagentManager, SubagentInfo, the callback Protocols, _AgingIdSet, _BareStateView); no reader exists (pickle, copyreg, shelve, repr, error-text greps). The moved exception SpawnApprovalUnreachable sets __module__ = "kiro_crew.subagent", which the contract test pins.

Logger (L25): owners define no logger and log through the facade's kiro_crew.subagent logger.

Source-reading tests re-pointed

Path or row changes only, assertions unchanged; each proved by a mutation in the new home that turns the test red:

  • test/test_subagent_scale.py: the draw-count scan reads the facade joined with subagent_parts/*.py, and the _mint_agent_id check reads inspect.getsource(SubagentManager._mint_agent_id) (the method moves to admission_surface.py, where a text slice keyed on method indentation would run past it). Mutation: move the draw into a helper right after the method; the text slice stays green, the test goes red.
  • test/test_agent_sdk_capabilities.py: _COMPOSED_OWNERS gains "subagent.py": "subagent_parts", so the harness-identity ratchet reads the 16 owner modules.
  • test/test_ws_event_scoping_frames.py: the _fire_event scan reads subagent_parts/*.py too (_fire_event moves to run_surface.py).

One integration fix beyond a path change, granted for this PR because the split is what breaks it:

  • test/test_taskq_bridge_bindings.py _manager_methods(): reads SubagentManager's methods from the class (vars(SubagentManager): functions, static and class methods, properties) instead of parsing class SubagentManager in subagent.py for its defs. The class now binds most methods from its owners as attributes, so def parsing no longer sees them, and pointing it at manager.py would count every bound method call as a field. The derived set equals the one main's subagent.py gives (207 = 207), and the assertions are unchanged. Mutations: dropping one name from taskq_bridge_reads' Reads: line turns the test red (1 failed); a helper that sees no methods turns it red (3 failed).

Registries, docs and CI path references

  • test/campaign_facade_inventories/kiro_crew.subagent.json: 13 rebound rows for the names this PR moves (SubagentManager, SubagentInfo, the delivery contract); base_public_names unchanged (check_inventory.py: 225 of 225).
  • .github/agent-sdk-boundary-baseline.txt: subagent.py 7 -> 6 (the providers import _provider_label_of needed now goes through kiro_crew.agent_sdk.drivers.acp.provider_label; InFlightToolTracker is re-exported by kiro_crew.agent_sdk.drivers.acp_vocab).
  • .github/file-line-cap-baseline.txt: the subagent.py row is deleted (709 lines).
  • src/kiro_crew/security_posture.py: the "Subagent results" _REDACTION_SINKS row names subagent_parts/run_output.py, the module that redacts subagent results, because subagent.py keeps no redactor call. This is the one visible change: the security posture panel names that module for this sink. run_output.py moves from NON_EGRESS_REDACTION_MODULES to the sink row. The admission, continuation, monitor and terminal surfaces join NON_EGRESS_REDACTION_MODULES (moved redactor calls, no new transport). Proof: strip run_output.py of every redact spelling and TestRedactionSinkRegistry stays green with the row at subagent.py; with the row at run_output.py, 2 of 5 fail.
  • docs/system-specs/modules/subagent.md § Composition: the full owner table, the binding rule, where new methods go, and which moved classes report which __module__.
  • Prose citations that named subagent.py as the home of a moved method now name its surface: resource-protection.md, context-management.md, config.md, learn-cron-dashboard.md, four RFCs and one RFC plan, injected-messages.md, a comment in subagent_manager/admission/pump.py, docstrings in test/test_agent_refactor_contracts.py and test/test_cron_gateway_integration.py, the mcp_gateway/backend_liveness.py cite in run_limits.py, and two security_posture.py comments that name the subagent sink.
  • No workflow file changes.

Risks

  • Two comments outside this PR still name subagent.py as the home of moved code: "the off-loop twin in subagent.py" in slack/gateway_runtime/cron_fire.py, and the one in dashboard/handlers/files.py. Both files belong to other live splits, so the corrected paths are relayed to them and change after this PR merges.

References not edited

Two test comments still name slack/gateway.py for code the gateway split moved; they sit in files outside this PR's claim. Follow-up: #21320.

  • test/test_subagent_coverage.py:1621: slack/gateway.py -> slack/gateway_runtime/runtime_charge.py
  • test/test_subagent_undelivered_notice_restart.py:116: "gateway.py _subagent_done" -> gateway_runtime/subagent_wiring.py

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 October 16, 2026 15:23
@bolichen97
bolichen97 requested a review from CrysisDeu October 16, 2026 15:23
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 7e0e096

  • What rule changed: No rule changed. In security_posture.py, the "Subagent results" row of _REDACTION_SINKS now names subagent_parts/run_output.py instead of subagent.py. That owner holds the results redaction (_redact, _redact_and_truncate, the bounded completion text), and after this PR subagent.py holds no redactor call. run_output.py leaves NON_EGRESS_REDACTION_MODULES, because a module is either a sink or non-egress. The admission, continuation, monitor and terminal surfaces join NON_EGRESS_REDACTION_MODULES: their redactor calls moved verbatim from the class body, and they add no transport or audience.

  • Before -> after (what was allowed/blocked, now): Nothing newly allowed or blocked: the redaction calls are byte-identical (move audit) and still run on subagent.py's globals. The visible change is that the security posture panel names subagent_parts/run_output.py as the module that redacts subagent results.

  • Worst case if wrong (breaks commands / leaks secret / locks user out): The panel would name the wrong module for this sink. No command breaks and no secret leaks.

  • Evidence checked (which sandbox result proves it): Not a sandbox change. test_security_posture.py::TestRedactionSinkRegistry reads the named module's text for a redactor. Mutation: remove every redact spelling from run_output.py, keeping the module importable. With the row at subagent.py all 5 tests stayed green (the facade's re-export imports still spell redact). With the row at run_output.py, 2 of 5 fail. The omission guard (TestOmissionDetection) goes red on an unregistered redactor call planted in a surface.

  • No regression:

    • Tools still work (which tools/commands were run, result): The 358 test files that import, patch or read the subagent family (spawn, run, terminal reports, redacted output) passed, 27,853 tests, 0 failed, plus 275 whole-tree scanning test files (20,977 passed).
    • Backward compatible (old config / old data / old callers still work, how checked): Every kiro_crew.subagent name and patch target still resolves to the same object (test_campaign_facades_base_public_names.py, test_subagent_parts_composition_contract.py); no config or data format changes.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_subagent_parts_composition_contract.py, test_campaign_facades_base_public_names.py and the 358-file subagent family set, green on this commit's content.
  • How to undo: Revert this one commit; the registry rows go with the code they classify.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture.py

  • @bolichen97 posted a complete reasoning template for 5af2122.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 5af2122fff811e0bef47224ab336902a55b737de touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 5af2122fff811e0bef47224ab336902a55b737de — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

One thing to check: the posture panel's "Subagent results" sink now names subagent_parts/run_output.py. Confirm every result-redaction call reaches the parent through that module.

What this change ships

Inventory (8 items) — 8 justified

Intent: bring subagent.py under the 2,000-line cap by moving SubagentManager, SubagentInfo and the delivery contract into subagent_parts owners, with no change in behaviour. This is a refactor; it neither fixes a defect nor adds a feature.

  1. subagent.py shrinks to a 709-line facade, and its file-line-cap baseline row is deleted — justified
  2. SubagentManager methods are bound as class attributes from nine *_surface and owner modules — justified
  3. SubagentManager.__module__ and SubagentInfo.__module__ now report their owner modules — justified
  4. The agent SDK gains a provider_label delegating wrapper, so the moved code adds no new boundary edge — justified
  5. acp_vocab re-exports InFlightToolTracker for the SubagentInfo field default — justified
  6. The security posture panel's "Subagent results" sink path is relabelled to run_output.py — justified
  7. Path references are updated in RFC, spec and architecture docs, with no change in what they decide — justified
  8. Contract tests pin member kinds and signatures, the provider_label tests pin parity, and new config-surface tests are added — justified

[FIRST-PRINCIPLES-REVIEWED] 5af2122

Description read

[DESCRIPTION-READ] ace8a717ae5338da26934a66f0d812e7ec423aaec7e45ab75640af74084a8f67

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 Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 5af2122fff811e0bef47224ab336902a55b737de — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that every bound SubagentManager method reads subagent.py's globals at runtime, so kiro_crew.subagent.<name> patches still reach the moved code.

[DESIGN-REVIEWED] 5af2122

Description read

[DESCRIPTION-READ] 645e9b64619e8c86c5b6183e0eb952d70fbcf8e6ef053f95b5951b5d84f234a5

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 Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5af2122fff811e0bef47224ab336902a55b737de — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5af2122

Verdict parsed from the review's SHA-scoped output markers for commit 5af2122fff811e0bef47224ab336902a55b737de.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 5af2122fff811e0bef47224ab336902a55b737de: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 5af2122fff811e0bef47224ab336902a55b737de and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5af2122

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5af2122fff811e0bef47224ab336902a55b737de: <one-sentence reason>

@bolichen97
bolichen97 enabled auto-merge (squash) October 16, 2026 15:35
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Subagent results sink row names the module that redacts: confirmed

Disposition: confirmed, no change. subagent_parts/run_output.py defines the family's result and task-text redactors: _redact (exfiltration-URL then credential scan), _redact_and_truncate and _done_result, which redacts and bounds the result the subagent_done event carries. Every call site resolves them from kiro_crew.subagent's globals, for example subagent_manager/terminal.py ("result": _done_result(info.result), "task": _redact(info.task)), and subagent.py now holds no redactor call, so the row moved with the code (rule L55).
The parent-context injection runs its own pass in slack/gateway.py _subagent_done (redact_exfiltration_urls then redact_credentials on the detail, task and title), which the gateway's sink row covers.
Pinned: test_security_posture.py::TestRedactionSinkRegistry reads the named module; stripping run_output.py's redaction fails 2 of its 5 tests with the row at run_output.py and passed vacuously with the row at subagent.py.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Subagent results sink row names the module that redacts: confirmed

Disposition: confirmed, no change. subagent_parts/run_output.py defines the family's result and task-text redactors: _redact (exfiltration-URL then credential scan), _redact_and_truncate and _done_result, which redacts and bounds the result the subagent_done event carries. Every call site resolves them from kiro_crew.subagent's globals, for example subagent_manager/terminal.py ("result": _done_result(info.result), "task": _redact(info.task)), and subagent.py now holds no redactor call, so the row moved with the code (rule L55).
The parent-context injection runs its own pass in slack/gateway.py _subagent_done (redact_exfiltration_urls then redact_credentials on the detail, task and title), which the gateway's sink row covers.
Pinned: test_security_posture.py::TestRedactionSinkRegistry reads the named module; stripping run_output.py's redaction fails 2 of its 5 tests with the row at run_output.py and passed vacuously with the row at subagent.py.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 16, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-g07-subagent-p2 branch from 7e0e096 to 6ea18bb Compare October 16, 2026 17:20
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6ea18bb

  • What rule changed: No rule changed. In security_posture.py, the "Subagent results" row of _REDACTION_SINKS now names subagent_parts/run_output.py instead of subagent.py. That owner holds the results redaction (_redact, _redact_and_truncate, the bounded completion text), and after this PR subagent.py holds no redactor call. run_output.py leaves NON_EGRESS_REDACTION_MODULES, because a module is either a sink or non-egress. The admission, continuation, monitor and terminal surfaces join NON_EGRESS_REDACTION_MODULES: their redactor calls moved verbatim from the class body, and they add no transport or audience.

  • Before -> after (what was allowed/blocked, now): Nothing newly allowed or blocked: the redaction calls are byte-identical (move audit) and still run on subagent.py's globals. The visible change is that the security posture panel names subagent_parts/run_output.py as the module that redacts subagent results.

  • Worst case if wrong (breaks commands / leaks secret / locks user out): The panel would name the wrong module for this sink. No command breaks and no secret leaks.

  • Evidence checked (which sandbox result proves it): Not a sandbox change. test_security_posture.py::TestRedactionSinkRegistry reads the named module's text for a redactor. Mutation: remove every redact spelling from run_output.py, keeping the module importable. With the row at subagent.py all 5 tests stayed green (the facade's re-export imports still spell redact). With the row at run_output.py, 2 of 5 fail. The omission guard (TestOmissionDetection) goes red on an unregistered redactor call planted in a surface.

  • No regression:

    • Tools still work (which tools/commands were run, result): The 358 test files that import, patch or read the subagent family (spawn, run, terminal reports, redacted output) passed, 27,869 tests, 0 failed, plus 275 whole-tree scanning test files (20,612 passed).
    • Backward compatible (old config / old data / old callers still work, how checked): Every kiro_crew.subagent name and patch target still resolves to the same object (test_campaign_facades_base_public_names.py, test_subagent_parts_composition_contract.py); no config or data format changes.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_subagent_parts_composition_contract.py, test_campaign_facades_base_public_names.py and the 358-file subagent family set, green on this commit's content.
  • How to undo: Revert this one commit; the registry rows go with the code they classify.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision labels Oct 16, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Subagent results sink row names the module that redacts: confirmed

Disposition: confirmed, no change. subagent_parts/run_output.py defines the family's result and task-text redactors: _redact (exfiltration-URL then credential scan), _redact_and_truncate and _done_result, which redacts and bounds the result the subagent_done event carries. Every call site resolves them from kiro_crew.subagent's globals, for example subagent_manager/terminal.py ("result": _done_result(info.result), "task": _redact(info.task)), and subagent.py now holds no redactor call, so the row moved with the code (rule L55).
The parent-context injection runs its own pass in slack/gateway.py _subagent_done (redact_exfiltration_urls then redact_credentials on the detail, task and title), which the gateway's sink row covers.
Pinned: test_security_posture.py::TestRedactionSinkRegistry reads the named module; stripping run_output.py's redaction fails 2 of its 5 tests with the row at run_output.py and passed vacuously with the row at subagent.py.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 16, 2026
subagent.py is still 4,697 lines after its module-level helpers moved
out, almost all of it the SubagentManager class. This second step moves
the class, SubagentInfo and the delivery contract into subagent_parts,
leaving subagent.py a 709-line facade under the 2,000-line cap.

The class is split by binding: each *_surface module holds methods as
functions taking self, and manager.py binds them as class attributes,
so the attribute is the moved function and mocks, autospec, signatures
and SubagentManager patches see what the one-module class had. compose
keeps every moved function on subagent.py's globals, so each
kiro_crew.subagent.<name> patch still reaches it. Two ACP names reach
the moved code through kiro_crew.agent_sdk.drivers, lowering the
facade's agent-sdk boundary count from 7 to 6.

The security posture "Subagent results" sink row now names
subagent_parts/run_output.py, the module that redacts subagent
results, since subagent.py keeps no redactor call.
@bolichen97
bolichen97 force-pushed the refactor/linecap-g07-subagent-p2 branch from 6ea18bb to 5af2122 Compare October 16, 2026 22:42
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 5af2122

  • What rule changed: No rule changed. In security_posture.py, the "Subagent results" row of _REDACTION_SINKS now names subagent_parts/run_output.py instead of subagent.py. That owner holds the results redaction (_redact, _redact_and_truncate, the bounded completion text), and after this PR subagent.py holds no redactor call. run_output.py leaves NON_EGRESS_REDACTION_MODULES, because a module is either a sink or non-egress. The admission, continuation, monitor and terminal surfaces join NON_EGRESS_REDACTION_MODULES: their redactor calls moved verbatim from the class body, and they add no transport or audience.

  • Before -> after (what was allowed/blocked, now): Nothing newly allowed or blocked: the redaction calls are byte-identical (move audit) and still run on subagent.py's globals. The visible change is that the security posture panel names subagent_parts/run_output.py as the module that redacts subagent results.

  • Worst case if wrong (breaks commands / leaks secret / locks user out): The panel would name the wrong module for this sink. No command breaks and no secret leaks.

  • Evidence checked (which sandbox result proves it): Not a sandbox change. test_security_posture.py::TestRedactionSinkRegistry reads the named module's text for a redactor. Mutation: remove every redact spelling from run_output.py, keeping the module importable. With the row at subagent.py all 5 tests stayed green (the facade's re-export imports still spell redact). With the row at run_output.py, 2 of 5 fail. The omission guard (TestOmissionDetection) goes red on an unregistered redactor call planted in a surface.

  • No regression:

    • Tools still work (which tools/commands were run, result): The 358 test files that import, patch or read the subagent family (spawn, run, terminal reports, redacted output) passed, 27,212 tests, 0 failed, plus 275 whole-tree scanning test files (20,221 passed).
    • Backward compatible (old config / old data / old callers still work, how checked): Every kiro_crew.subagent name and patch target still resolves to the same object (test_campaign_facades_base_public_names.py, test_subagent_parts_composition_contract.py); no config or data format changes.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_subagent_parts_composition_contract.py, test_campaign_facades_base_public_names.py and the 358-file subagent family set, green on this commit's content.
  • How to undo: Revert this one commit; the registry rows go with the code they classify.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 16, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Subagent results sink row names the module that redacts: confirmed

Disposition: confirmed, no change. subagent_parts/run_output.py defines the family's result and task-text redactors: _redact (exfiltration-URL then credential scan), _redact_and_truncate and _done_result, which redacts and bounds the result the subagent_done event carries. Every call site resolves them from kiro_crew.subagent's globals, for example subagent_manager/terminal.py ("result": _done_result(info.result), "task": _redact(info.task)), and subagent.py now holds no redactor call, so the row moved with the code (rule L55).
The parent-context injection runs its own pass in slack/gateway.py _subagent_done (redact_exfiltration_urls then redact_credentials on the detail, task and title), which the gateway's sink row covers.
Pinned: test_security_posture.py::TestRedactionSinkRegistry reads the named module; stripping run_output.py's redaction fails 2 of its 5 tests with the row at run_output.py and passed vacuously with the row at subagent.py.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Bound SubagentManager methods read subagent.py's globals: confirmed

Disposition: confirmed, no change. kiro_crew._facade_compose.compose(globals(), owners, host=SubagentManager) at the foot of subagent.py rebuilds every function the 16 subagent_parts owners define, including each surface function the class binds, with subagent.py's globals, and swaps those rebuilt functions onto SubagentManager.
Pinned in test/test_subagent_parts_composition_contract.py: test_every_owner_function_runs_on_the_facade_globals (every owner function's __globals__ is the facade's), test_every_bound_member_is_its_owner_function (each class attribute IS that rebuilt function), test_every_global_an_owner_function_reads_is_bound_on_the_facade (bytecode sweep), test_every_name_the_tests_patch_on_the_facade_reaches_every_owner_reader (patch targets derived from the test trees) and test_a_patch_of_the_facade_reaches_an_owner_function (an executed patch).

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 16, 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 by a maintainer. The triage automation held this on a size, path, category or move-check rule only; every review lane is clean.

@bolichen97
bolichen97 merged commit ac63bc1 into main Oct 17, 2026
107 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-g07-subagent-p2 branch October 17, 2026 01:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 17, 2026
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.

2 participants