Repository navigation
refactor(acp): move AcpClient session start, turn loop and class home - #20744
Conversation
Sensitive change reviewHead: 20a56c3
|
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that dropping [DESIGN-REVIEWED] de1bddf Description read[DESCRIPTION-READ] 9c41d960470e94d816ce547400ed38fb11f5c04e1a1dee3e48ca4682bc02f243 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 Check that nothing imports What this change shipsInventory (8 items) — 8 justifiedIntent: a maintainer wants
[FIRST-PRINCIPLES-REVIEWED] de1bddf Description read[DESCRIPTION-READ] cf7353528ccb54e82cac4a3e9b01e05ea3c6a29dba7611096623e56694a40978 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: |
|
|
chenmingwei23
left a comment
There was a problem hiding this comment.
Approving: readiness gate passed, no conflicts, checks green.
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by a maintainer after reading the review lanes: every lane is clean on this head, and the automated triage held it only on a size, path, category or doc rule.
66c9390
20a56c3 to
66c9390
Compare
|
Rebased onto main 0694e63, conflicts in |
66c9390 to
1718e81
Compare
|
Refreshed onto main c6d6106; this head supersedes 66c9390 (same tree, rebuilt by the split recipe and re-gated). Upstream changes carried:
The campaign facade inventory ( Local gate at this head: 51 touched test files, 4,810 passed, 0 failed; line cap, docs lint and the diff-scoped gates green. |
|
|
5c5d43b to
d3b3e3c
Compare
|
|
Sensitive change reviewHead: d3b3e3c
|
|
Head d3b3e3c is kept as this PR's head. Two hand rebases outside the campaign moved the branch overnight (1718e81 -> 5c5d43b -> d3b3e3c). Its content matches the reviewed re-cut of this PR on main 7f7c38b: a range-diff shows the same 39 paths and identical hunks, apart from upstream context (main's newer Upstream changes carried at this head:
|
Move the last third of AcpClient's members (the session start and the turn loop) into client_start and client_turn by binding, as in the two earlier parts of this series, and move the class statement itself verbatim to client_class. The class keeps kiro_crew.acp.client as its __module__, and client.py re-exports it, so the import path, pickles, reprs and type hints are unchanged. _resolve_spawn_env stays defined in client.py, which fills the session start's global right after defining it. client.py is the facade only, at 1,184 lines, and leaves the line-cap baseline. Part of #20192
d3b3e3c to
de1bddf
Compare
|
Rebased: conflicts with main again (d3b3e3c -> de1bddf, base 02928b1). Doc rows only: |
Sensitive change reviewHead: de1bddf
|
|
|
|
HOLD at de1bddf. This needs a human reviewer, because the change touches security-registry and sandbox spawn code.
I found no defect. An AST comparison of every function in the old — crew-pr-reviewer (r107) |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by a maintainer. The triage automation held this on a size, path or move-check rule only; every review lane is clean. Any lane note is accepted as follow-up work.
Problem / Motivation
Goal: Move the last third of
AcpClient(the session start, the turn loop and the class statement itself) out ofsrc/kiro_crew/acp/client.py, so the file drops below the 2,000-line cap with no change in behaviour.acp/client.pyis still 4,797 lines after PR 2 of this series (#20598), and the campaign rule (no hand-written file over 2,000 lines, #20192) needs it at or below its 1,200-line target. This is PR 3 of the 3-PR series and uses the same binding split as PR 1 (#20470) and PR 2.Why it matters
A change to how a session starts or how a turn runs today edits a 4,797-line file that also carries the class definition and the compatibility facade, so unrelated work conflicts there. After this PR
client.pyis the facade only (1,184 lines), everyAcpClientresponsibility has one owner module named in the owning spec, and the file comes off the line-cap baseline.Not a goal
AcpClient's surface or identity: every member stays an attribute of the one class,kiro_crew.acp.client.AcpClientis the same class object, and its__module__stayskiro_crew.acp.client.kiro_crew._facade_mirroror to CI logic.What changed (motivation → approach → change)
The class could not stay in
client.pyat the target size, and tests reach into its fields, members and sources everywhere, so the state cannot leave the instance. PR 1 and PR 2 moved two thirds of the members into owner modules bound by name; this PR moves the rest and then moves the class statement itself.client_start.pyinitializehandshake and its params, new, loaded, forked and substituted sessions,ensure_readyclient_turn.py_prompt_loop, dispatching and processing frames,send_message,send_message_stream,stream_eventsclient_class.pyThe class statement moves verbatim and sets
__module__ = "kiro_crew.acp.client", so reprs, pickles andtyping.get_type_hintsstill name the facade;client.pyre-exports it._resolve_spawn_envstays defined inclient.py, where the spawn audit, the subprocess-encoding baseline and the cross-platform gate key it. An owner never imports the facade, soclient_startdeclares the name andclient.pyfills it in right after the definition; a patch throughkiro_crew.acp.clientreaches the spawn through the mirror._retire_liveness_statejoinsclient_lifecycle.py. Docs (theacp-client.mdowner table and class-home paragraph, RFC and spec citations), source-reading tests and registry rows that namedacp/client.pyas the home of moved code now name the owner, andclient.py's line-cap baseline row is gone.Move audit
Raw (
move_audit.py):src/kiro_crew/acp/client.py: 4843 -> 1190 lines; moved 42.01% (python-ast)— the remaining "changed" units differ only by black's docstring re-indent after the dedent, theself: AcpClientannotation and a dropped@staticmethod.Normalized (those three transforms undone, nothing else): 285 units, 282 moved unchanged (4,100 lines), 3 changed (31 lines) —
_CLIENT_OWNERS,_is_kiroand_model_registry_namespace, listed below.Justified edits (not verbatim):
class AcpClientinclient_class.py:__module__ = "kiro_crew.acp.client"(with its one-line comment) after the docstring; the stage-3 binding blocks (two owner headers, 17 bindings,_retire_liveness_statein the lifecycle block); one annotation for type checkers only (_native_skill_projection, underTYPE_CHECKING, so the runtime class is unchanged).client_start.py: the annotation-only_resolve_spawn_envdeclaration in place of a facade import (the facade fills it).client.py:_client_start._resolve_spawn_env = _resolve_spawn_envafter the def;_CLIENT_OWNERS+ the three owners.__init__,_model_registry_namespace,_is_kiro), one "Kiro Crew" spelling in_initialize_session.Prose citations (L29), path only: comments and docstrings in
src/kiro_crew/context.py,src/kiro_crew/providers/acp_runtime_start.py,src/kiro_crew/acp/runtime.py,src/kiro_crew/dashboard/handlers/usage.py(a staleclient.py:1270line citation becomesclient_class.py,__init__),test/test_context.py,test/test_acp_runtime_load_session.pyandtest/test_session_pool.py, the comment insrc/kiro_crew/agent_sdk/backends.pyon the public Claude backend, and the location claims inrfc-agent-started-turns.md,rfc-leaked-runtime-reclaim.md,rfc-mcp-resource-subscriptions.md,harness-parity.md,metrics.md,agent-spec-fields.md,agent-host-contract.md(the_is_clauderecognition, the_is_kiroactivation gate, the protocol-version andsession/loadrows, the bare spawn and the adapter-held resume),sel.md,resource-protection.md(death detection and the init, prompt and read timeouts),kas-nondestructive-session-teardown.md,docs/reference/kiro-cli/steering.mdandsteering-viewer.md, now name the owner that defines the cited code.Diff shape (L36):
git diff --numstatequalsgit diff --minimal --numstatfor every changed file.Backwards compatibility
Compatible: every module path, public and private name,
AcpClientmember, signature, patch target, class identity,__module__and pickle path that worked before still works, andtyping.get_type_hintsstill resolves on every class-resident member (__init__equal to BASE). Two introspection results change, as they did for the members PR 1 and PR 2 bound:typing.get_type_hintson a member bound from an owner raisesNameError, because itsself: AcpClientannotation names a type-checking-only import, andinspect.getsource(AcpClient)raisesOSError, because the class statement now lives in a module other than its__module__. No caller insrc/ortest/uses either; member-levelinspect.getsourcefollows each function's code object and keeps working.Reader: src/kiro_crew/acp/client_start.py:_spawn -- chat -- the extra_hidden_dirs=plan.extra_hidden_dirs forward moved verbatim from client.py; no mask is added (test_acp_launch_goldens::test_the_launch_of_every_known_harness_matches_the_golden)
Logger names (L25): owners call
logging.getLogger("kiro_crew.acp.client"), the same Logger object.Tests
test/test_client_bindings.py: the inventory namesclient_classfor class-resident members; new contract tests: the class keeps the facade as its module, qualname and pickle path, every class-resident member's type hints resolve (__init__equal to BASE), a facade patch ofAcpClientreaches the class-resident statics; the facade fillsclient_start._resolve_spawn_env(identity, a nested read in_spawn, a facade patch reaches_spawn.__globals__), and onlyclient.pyandclient_class.pyimportclient_start, with the package importing the facade first.("acp/client_start.py", "_spawn"), 4 keys), test_worker_agent_load_bracket (+client_start.py;client.pystays listed because the facade still re-exports the gate names the text scan looks for), test_worker_agent_spawn_gate, test_pid_reader_ratchet_KNOWN_SITE_FILES, test_agent_sdk_backend_identity (positive half →client_class.py), test_post_compaction_continuation (reads the joinedacp/client*.pyfamily), test_secc_poc_scratch_owner_symlinkSPAWNERS, test_deny_bounded_writeSITES(the "ACP event" needle →client_turn.py; empty rows forclient_class/client_start), test_security_posture census (acp/client.pyrow removed,acp/client_start.py2), test_core_path_redact_before_bound_SCANNED_MODULES(+ the three owners).src/kiro_crew/security_posture.pyNON_EGRESS_REDACTION_MODULES(−acp/client.py, +client_start,client_turn);.github/file-line-cap-baseline.txt: theclient.pyrow deleted._SCANNED_MODULESrows (a planted log site, a planted slice in each new owner), and the new contract tests (drop__module__, an unresolvable annotation, a static reading a private alias, dropping the facade's fill-in of_resolve_spawn_env, which also failstest_acp_agent_env). The 20th, filling in a different callable, is refused by the facade mirror at import.kiro_crew.acp, the facade and mirror guards, the ratchets that scan acp/),pytest -n 3: 37,060 passed, 79 skipped, 5 xfailed, 0 failed;mypy src/kiro_crewclean; the flake-pattern ratchet green; a wheel built from agit archiveexport imports all 18 client modules, withAcpClientnaming the facade and the filled-in resolver; semgrep (CI configs,--baseline-commit) clean.scripts/local-gate.py --dry-runselects 2,613 backend and 1,745 frontend files, over the campaign's ~600-file cap, so the floor above ran instead; CI runs the full matrix.pytest -n 3: 4,870 passed, 0 failed; mypy and semgrep clean; the 20 mutation proofs re-run with the same results. At this head (main 7f7c38b, which changed only a doc row this PR also cites): the binding, facade-inventory, host-contract and concurrent-steer tests, 569 passed.Manual verification
N/A — a pure move; behaviour is covered by the existing ACP suites, which pass unmodified apart from the listed path re-points.
Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)