Repository navigation
refactor(acp): move the rest of AcpRuntime into owner modules - #22358
Conversation
Sensitive change review
|
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is the second half of a split that #22085 started, it moves code without changing behaviour, and the class keeps its facade Notes
[DESIGN-REVIEWED] 995577b Description read[DESCRIPTION-READ] 070eaef99a4bd52ba9def10f88c1c55f3168633624da16b84a6bb1f176ac954d 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. This is a mandated pure move: AGENTS.md's 2,000-line cap requires splitting What this change shipsInventory (7 items) — 7 justifiedIntent: bring
[FIRST-PRINCIPLES-REVIEWED] 995577b Description read[DESCRIPTION-READ] c19d2e28d1e8bef0aef2f996c1b654fc2d709217138f9d7cbe0527251e988f17 That sha256 names the PR description this verdict read. Recompute it with |
Human judgment recorded@bolichen97 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
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: |
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at 77c9706, for one tracking gap only.
The move is faithful. An AST comparison of the base AcpRuntime with the owner modules finds every one of its 100 members either unchanged in the class or AST-identical in an owner (after the self: AcpRuntime annotation, docstring dedent and the staticmethod re-binding), and the class body gains only __module__ and four TYPE_CHECKING annotations. The security_posture.py change is a re-key: the 14 redactor calls in base runtime.py now sit in exactly the four owners that replace its NON_EGRESS_REDACTION_MODULES row, with no row dropped (security_posture.py#L2189). All lanes are clear (I confirmed the GPT override against run 39355915509's log, which printed No findings. for this head) and checks are green.
To clear: the body defers two stale cites to #21320, format.ts#L276 and capture-sage-cause-translator.mjs#L24, but #21320's citation table does not list them. Please add both rows there (should say acp/runtime_reader_loop.py, moved by #22358). #22257 already covers the _own_methods follow-up.
— crew-pr-reviewer (r114)
|
@iamwhatever thanks for the review (crew-pr-reviewer r114 at 77c9706). Both deferred cites are now rows on #21320: #21320 (comment). They are |
|
@iamwhatever follow-up to the r114 ask: both rows are now in the citation table itself in the body of #21320 (#21320), not only in a comment:
Head is still [operator: bolichen97] |
77c9706 to
aaf283b
Compare
aaf283b to
fbf6b4e
Compare
Sensitive change review
|
|
@iamwhatever rebased onto current main; could you re-review when you have a moment?
[operator: bolichen97] |
Sensitive change review
|
fbf6b4e to
601dfe0
Compare
AcpRuntime's session registry, mode activation, stdin wire, liveness, host requests, frame accounting and stdout reader move into seven more acp/runtime_* owner modules, and the class statement itself moves to acp/runtime_class.py. The class still binds every member by name and keeps its constructor, properties and constants, and acp/runtime.py re-exports it with its __module__ unchanged, so every import path, patch through kiro_crew.acp.runtime and unbound call reaches the same code. runtime.py drops to 595 lines, under the line cap. Part of #20192
Sensitive change review
|
601dfe0 to
995577b
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
APPROVE at 995577b.
The r114 tracking gap is closed: #21320's citation table now lists format.ts:276 and capture-sage-cause-translator.mjs:24 with acp/runtime_reader_loop.py, and #22257 tracks the shared _own_methods helper.
The rebased move is still faithful. An AST comparison with merge base 0b89e0c finds all 121 definitions from base runtime.py unchanged at this head (after the self: AcpRuntime annotation, docstring dedent and staticmethod re-binding), and every moved AcpRuntime member is bound by its own name to the function its owner defines. That includes the #22625 secret-store answer and the credential callback in runtime_host_requests.py. The security_posture.py change is a re-key: base runtime.py's redactor calls sit in exactly the four owners that replace its row. Every AI lane passes on this head and all checks are green.
— crew-pr-reviewer (r117)
Problem / Motivation
Goal: Bring
src/kiro_crew/acp/runtime.pyunder the 2,000-line cap with no behaviour change: the second of two PRs, moving the rest ofAcpRuntime's behaviour and the class statement into owner modules the class binds by name.After #22085,
acp/runtime.pyis still 5,195 lines, almost all of it theAcpRuntimeclass: the session registry, mode activation, the stdin wire, liveness and death attribution, the host requests, frame accounting and the stdout reader. It still has a row in.github/file-line-cap-baseline.txt, and it still changes every few days.Why it matters
The 2,000-line cap is the repository's rule (AGENTS.md,
scripts/check_file_line_cap.py). Until the rest of the class moves, every runtime change still lands in a 5,000-line file that holds seven unrelated responsibilities, and the file keeps its line-cap baseline row.Not a goal
AcpRuntime's public or private surface, its constructor, its properties or its class constants.acp/runtime.pyare not edited (listed below; follow-up docs: fix comment citations left pointing at files the line-cap splits moved #21320).What changed (motivation → approach → change)
runtime.pystays over the cap because the class holds the rest of the runtime. This PR finishes the split #22085 started, the same way (binding, KC28 L33): each remaining member's body becomes a module-level function in an owner module, withselfas its first parameter, and the class binds it by name. The class statement itself, with its constructor, properties, constants and binding block, moves verbatim toacp/runtime_class.py, andacp/runtime.pyre-exports it. The class keepskiro_crew.acp.runtimeas its__module__, so reprs, error text and every import path read as before. A patch throughkiro_crew.acp.runtimestill reaches every owner that reads the name (kiro_crew._facade_mirror).acp/runtime_session_registry.pyacp/runtime_mode_activation.pysession/set_mode, skill-view aliases, the projection generation, the spawn-agent checksacp/runtime_wire.py_send_and_awaitacp/runtime_liveness.pyacp/runtime_host_requests.py_kiro/secret/*)acp/runtime_frame_accounting.pyacp/runtime_reader_loop.pyacp/runtime_class.py_own_methodsruntime.pydrops from 5,255 to 595 lines, so its line-cap baseline row goes. Tests and registries that name where moved code lives now name its owner, and the owning spec (acp-client.md) lists every owner.Backwards compatibility
Compatible: every name
kiro_crew.acp.runtimebound before stays bound to the same object (test_every_base_import_stays_bound_on_the_facadeandtest/campaign_facade_inventories/kiro_crew.acp.runtime.jsonpin it);AcpRuntimeis the same class object with the same__module__, members, kinds, coroutine-ness and signatures (the member inventory pins it); a write through the facade reaches every owner that reads the name.Removes nothing: no public module-level function leaves a product file (the take-away check finds no shape), and every moved member stays bound on the class under its own name.
Tests
test/test_runtime_bindings.pycovers all 13 owners and the class home: every member bound from its owner with the BASE__qualname__, no owner keeps an unboundselffunction, the member inventory, owner layering, owner docstrings, logger names, moved exceptions keeping the facade__module__(AcpRuntimeStdinStalledjoins the list), patch reach through the mirror, the import check, and and the class-home pins: the class keeps the facade as its__module__and pickle lookup path (module + qualname resolves to the class home's object),typing.get_type_hints(AcpRuntime) == {}and every member's hints resolve (the fields a moved member assigns first are declared underif TYPE_CHECKING:), the constructor keeps its main type hints, and a facade patch reaches the class-resident constructor. Each has a mutation that turns it red.test/test_runtime_bindings.py(387 tests) passed 5 runs at-n0and one at-n 3; it sleeps on nothing and orders nothing it did not define.Manual verification
N/A — a pure move: the existing runtime suite drives every moved body, and the binding guards pin the contract.
Move audit
src/kiro_crew/acp/runtime.py: 5255 -> 595 lines; moved 23.64% (python-ast)(move_audit.py, raw: it counts every moved member as changed because its first parameter gains the type-checkerself: AcpRuntimeannotation and black re-indents its docstring).inspect.cleandoc, theselfannotation and a dropped@staticmethodundone): 219 units, 216 moved unchanged, 3 changed, all glue:_MEMBER_OWNERSand_RUNTIME_OWNERSgain the new owners (the class home last), and the class'sif TYPE_CHECKING:field block gains four declarations.__module__ = "kiro_crew.acp.runtime"line with its comment after the docstring; four more declarations, in the class'sif TYPE_CHECKING:block, of fields a moved member assigns first (_skill_projection_issued,_skill_projection_lock_obj,_skill_projection_unadopted,_stdin_lock);# ── AcpRuntime ──,Awaited-request error formatting,Unroutable-frame drop accounting,Reader Task,Protocol Interface,Skill-view projection,Session Management,Internal Helpers);__init__'s "a buffer that has dropped the evidence",_answer_unroutable_permission's "the redaction patterns cannot match it";AcpRuntimefromacp/runtime_class.py; a stray comment about re-exports stays in the facade above theacp.clientre-export it sat next to;from kiro_crew.acp import kas_secret_storage, runtime_process_treeas two lines, because the new owner aliases (runtime_frame_accounting as _rt_frames, ...) sort between the two names; both stay bound on the facade.Diff layout (L36)
Every changed file adds the same lines under git's default diff and
--minimal(runtime.py: +75/-4735 both). Total diff 621,650 bytes.CI path references
None: no workflow path filter or explicit file list names
runtime.pyoracp/**.Logger names
Owners log under
logging.getLogger("kiro_crew.acp.runtime"), the literal name, as in #22085; the facade keepslogging.getLogger(__name__), the same logger object.Known limits
_reader_loop.<locals>...), a moved function's__code__.co_qualnameis its owner-level name, and a log record carries the owner inmodule,filenameandpathname;record.namestayskiro_crew.acp.runtime. Nothing in the tree reads these.inspect.getsource(AcpRuntime)raisesOSErroron Python 3.12: it looks the class up through its__module__, the facade, which no longer holds the class statement. Read a member's source, oracp/runtime_class.py; the two whole-class source pins were re-pointed in refactor(acp): bind AcpRuntime spawn, kill and session-start owners #22085, and the owning spec says the same.pickle.dumps(AcpRuntime.is_alive)) fails: pickle looks a function up by__module__and__qualname__, which name the owner module and the class.pickle.dumps(AcpRuntime.spawn)already failed the same way on main, and nothing pickles a member.Upstream changes carried into the owners (L16)
#22625 (
c90720cb6c) and #22592 (eac5cf92ab) editedruntime.pycode this PR moves; the split recipe re-runs on main and takes every body from it, so each piece lands in its owner unchanged apart from the dedent:runtime.pyfrom kiro_crew.acp import kas_secret_storage, ...runtime_class.py,runtime_host_requests.pyandruntime_reader_loop.pyimport it for the code that reads it_MCP_SECRET_REFUSED = -32000runtime_host_requests.py, beside_MCP_URL_NOT_OPENED; the facade re-exports itself._mcp_secret_server = Nonein__init__runtime_class.py(AcpRuntime.__init__)_reader_loop: secret frames are never recorded; the_kiro/secret/*answer branchruntime_reader_loop.py(_reader_loop), in main's branch order_answer_secret_requestruntime_host_requests.py, bound by name like the other members; the guard's member inventory gains its rowredact(...)call (_sanitize_progress_name,redacted_stderr_tail, two death and debug tails, a failed MCP server's error)runtime_session_registry.py,runtime_liveness.py,runtime_reader_loop.py; the two owners that no longer call the raw passes drop that import, and the facade keeps both namesThe host-requests owner's docstring and its
acp-client.mdrow name the secret store. Every non-blank line #22625 and #22592 added to the runtime family is present at this head (dedent aside).Edits outside the claim (granted)
src/kiro_crew/security_posture.pyNON_EGRESS_REDACTION_MODULES(L55: the rows follow the redactor calls):acp/runtime.pybecomesacp/runtime_frame_accounting.py,acp/runtime_host_requests.py(keeping its comment),acp/runtime_liveness.py,acp/runtime_session_registry.py, the four owners that now holdruntime.py's redactor calls. No_REDACTION_SINKSrow namedruntime.py. Mutation: removing the redactor call fromruntime_frame_accounting.pyturnstest_allowlist_has_no_stale_entriesred..github/file-line-cap-baseline.txt: theacp/runtime.pyrow deleted by hand (L45).test/campaign_facade_inventories/kiro_crew.acp.runtime.json(this facade's own inventory from refactor(acp): bind AcpRuntime spawn, kill and session-start owners #22085):AcpRuntimeandAcpRuntimeStdinStalledjoin its rebound map with their new homes.Baselined growth (L56 addendum 1b)
src/kiro_crew/security_posture.py: main row 3181, the file goes 3,511 -> 3,514 lines (three exact-path rows the redactor drift guard requires, no added comment).Source pins re-pointed (L30 / L40(8)); every assertion unchanged
test_acp_frame_record.py (the reader-loop record pin reads the runtime family, as the client's already did), test_worker_agent_load_bracket.py (the handshake-driving spawner list:
runtime_spawn_launch.pyalone for the runtime), test_pid_reader_ratchet.py (_KNOWN_SITE_FILES: the seven owners that holdruntime.py's pid-reader sites; totals unchanged), test_agent_admission_paths_ratchet.py (_activate_mode_bracketedkeyed by its owner), test_deny_bounded_write.py (SITES: each log-site needle under the owner that holds it, the facade row kept empty), test_harness_parity.py (_RUNTIME_PATH_MODULES+ the eight new modules). Each has a mutation that breaks the construct in its new home and turns the pin red.Citations edited (L29, SD27)
docs/system-specs/modules/acp-client.md:75: "AcpRuntimestays in its module;AcpSessionHandle's class home is below" -> "The class homes ofAcpRuntimeandAcpSessionHandleare below"docs/system-specs/modules/acp-client.md:158: "_MirroredSessionMcpkeeps its owner's, which nothing reads." -> "_MirroredSessionMcpand_PendingRequestskeep their owner's, which nothing reads.", plus where the class statement is and whyinspect.getsource(AcpRuntime)does not find itdocs/system-specs/modules/acp-client.md:171: where newAcpRuntimebehaviour goes joins this paragraph, from the sentence after the owner table that placed the rest inacp/runtime.py(removed);:182-189: the eight new owner rowsdocs/architecture/resource-protection.md:591:acp/runtime.py->acp/runtime_spawn_launch.pydocs/guides/remote-and-mobile.md:31:acp/runtime.py->acp/runtime_liveness.pydocs/request-for-change/rfc-overload-resilience.md:87(E9):acp/runtime.py_session_start_stalledL3034 ->acp/runtime_session_registry.py_session_start_stalleddocs/system-specs/common/error-handling.md:290:acp/runtime.py->acp/runtime_liveness.pydocs/system-specs/modules/agent-host-contract.md:100:acp/runtime.py->acp/runtime_mode_activation.pydocs/system-specs/modules/harness-parity.md:258:acp/runtime.py->acp/runtime_reader_loop.pydocs/system-specs/modules/metrics.md:383:acp/runtime.py::_audit_denied_off_loop->acp/runtime_host_requests.py::...;:384acp/runtime.py->acp/runtime_reader_loop.py;:385acp/runtime.py::_note_dropped_frame->acp/runtime_frame_accounting.py::...;:386acp/runtime.py::_activate_mode_bracketed->acp/runtime_mode_activation.py::...src/kiro_crew/acp/client_spawn_env.py:836:acp.runtime._own_stub_session->AcpRuntime._own_stub_sessionsrc/kiro_crew/agent_sdk/backends_mcp.py:290:acp/runtime.py->acp/runtime_class.pysrc/kiro_crew/dashboard/handlers/usage.py:126:runtime.py:273->AcpRuntime._agent;:127:runtime.py:280->AcpRuntime._modelsrc/kiro_crew/kiro_prerequisite_agent_specs.py:195:acp/runtime.py->acp/runtime_reader_loop.pysrc/kiro_crew/metrics/events.py:78:acp/runtime.py::_activate_mode_bracketed->acp/runtime_mode_activation.py::...src/kiro_crew/session_pid_tracking.py:784:acp/runtime.py->acp/runtime_liveness.pytest/test_usage.py:1580:runtime.py:273->AcpRuntime._agentapps/builtins/aws_controlcites ofacp/runtime.py:1321(andruntime.py:1251), which point at code that moved toacp/launch.pylong before this split;code-style.md's exception cite, still true.References not edited (cost)
website/scripts/capture-sage-cause-translator.mjs:24andwebsite/src/apps/code-review-sage/lib/format.ts:276nameacp/runtime.pyfor the missing-agent-spec message, which is built inacp/runtime_reader_loop.py(_format_runtime_rpc_error). Both rows are tracked on docs: fix comment citations left pointing at files the line-cap splits moved #21320 (docs: fix comment citations left pointing at files the line-cap splits moved #21320 (comment)).Gates run locally
kiro_crew.acp.runtime/AcpRuntime, the tree-scan fences, the mirror and facade guards),-n 3: 18,152 passed, 48 skipped, 0 failed.mypy src/kiro_crew(fresh cache): no issues in 3,449 files. black / isort / flake8 on every changed file, comment-history, brand, harness parity, cross-platform scan, model-id rule, line cap (0 failures), subprocess-encoding, black gate, woke, take-away, docs_lint, flake-pattern ratchet, campaign inventory check: all pass. semgrep 1.78 with the CI configs and--baseline-commit: 0 findings, no parse error.Related Issues
Part of #20192
Follow-up: #21320
Follow-up: #22257 (the shared _own_methods helper)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.