Repository navigation
refactor(dashboard): split session_transfer and handlers_instances - #21111
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 Check that classifying [DESIGN-REVIEWED] 4c70200 Description read[DESCRIPTION-READ] 2edeeb85a2ae49e84eb91cfc6252fe8f0d07c32cf7eb5985fc4b8e6c3e731d19 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 one thing before merge: the move audit was run against base What this change shipsInventory (8 items) — 8 justifiedIntent: get two dashboard modules under the 2,000-line cap with no change in behaviour (ADDITION of module structure, refactor framing).
[FIRST-PRINCIPLES-REVIEWED] 4c70200 Description read[DESCRIPTION-READ] 3930d2136155cb4469d3bdee9f2516182a3cdf06f541ff478f4bfd509dbd4a4e 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: |
|
|
Sensitive change review
|
b0da9b2 to
7c89656
Compare
|
Rebased onto main to clear the |
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at 7c89656.
The move itself looks sound. I parsed both originals at the merge base and all eight head modules without running them: all 105 function and method bodies are AST-identical. The module-level changes are only facade glue: the mirror install, literal logger names equal to the old name, and module pins on the seven exception classes. The AI lanes have no findings, and the install-owner egress question is answered with evidence.
One thing to fix: Not a goal and Tests say test_import_never_reads_the_whole_body_into_memory is vacuous at BASE and that a follow-up was filed, but no issue is linked and I could not find one (test_session_transfer.py#L3769). Please open one issue for it, or fix it here, and link it in the description.
This PR also changes src/kiro_crew/security_posture.py and moves the Instances owner gate, peer proxy and inbound redaction code, so a human reviewer needs to sign off after that.
— crew-pr-reviewer (r107)
|
|
Sensitive change review
|
|
@iamwhatever this is another rebase with no content change: the PR conflicted with main's |
819a885 to
5090fba
Compare
|
|
Sensitive change review
|
5090fba to
2f7103d
Compare
|
@iamwhatever this is another rebase with no content change: the PR conflicted with main's |
Sensitive change review
|
|
@iamwhatever this is another rebase with no content change: the PR conflicted with main's |
session_transfer.py (3,095 lines) and handlers_instances.py (2,868) were over the 2,000-line cap. Whole top-level definitions move, verbatim, into sibling owner modules; each original path stays the import path and the patch surface as a _facade_mirror facade, so a monkeypatch or mock.patch through it still reaches every owner that reads the name. session_transfer.py keeps the sending side's bundle assembly, where the outbound redaction runs. Its owners: session_transfer_staging (bundle format, staging dirs, bundle files), session_transfer_layers (Layer A and B reads, Layer B writes on arrival), session_transfer_intake (admitting and parsing an arriving body) and session_transfer_install (validating and installing it). handlers_instances.py keeps the registry, connection, remote-update, search and send routes. Its owners: handlers_instances_gate (owner gate, audit, registry access, chain policy) and handlers_instances_peer (the routes that read a peer, and the proxy to it). Path-keyed rows follow the code: the receive-side scrub is listed as non-egress, the peer live-session sink names the peer owner, the baseline-redactor census, error-code rows and line-cap rows move, and the instances spec and feature map name the owners. Source-reading tests that scanned one file now scan the facade and its owners. Part of #20192
Sensitive change review
|
|
@iamwhatever this is another rebase with no content change: the PR conflicted with main's |
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
Approve at 4c70200.
The split is a faithful move. I parsed the merge-base session_transfer.py and handlers_instances.py and the eight head modules without running them: 160 of 161 top-level units are AST-identical, and every name a moved unit reads resolves in its owner to the same import as at the base. The one changed unit is logger, which each owner binds by the original module's literal name, so log names do not change.
The security_posture.py edits only follow the moved code. The Peer live-session list sink now names handlers_instances_peer.py, where that route and its redactor calls now live. The new NON_EGRESS_REDACTION_MODULES row classifies the receive-side owner, while the outbound Session transfer bundle sink stays on session_transfer.py. No row is dropped and no redactor call changed.
The vacuous body-buffering guard is tracked in #21314, which describes the fix. All AI lanes are clean or answered on this head, and every check is green.
Reviewed head: 4c70200
— crew-pr-reviewer (r111)
Problem / Motivation
Goal: Bring
dashboard/session_transfer.py(3,095 lines) anddashboard/handlers_instances.py(2,871 lines) under the 2,000-line cap with no behaviour change, so new session-transfer and Instances work lands in small modules that each own one responsibility.Both files were over the repository's 2,000-line cap (
.github/file-line-cap-baseline.txt). Part of the line-cap campaign.Part of #20192
Why it matters
A file this size is where every new transfer or Instances feature lands, so it keeps growing, review diffs get harder to read, and the cap baseline cannot shrink. Splitting by responsibility tells the next contributor where their change goes.
Not a goal
dashboard/server.py, the scope's third file. It follows as a separate stacked PR, because moving its entrypoints needs a restructure of its composition-contract test.What changed (motivation → approach → change)
Whole top-level definitions move verbatim into sibling owner modules. Each original path stays the import path and the patch surface as a
kiro_crew._facade_mirrorfacade, somonkeypatch.setattr(session_transfer, …)ormock.patch("…handlers_instances.X")still reaches every owner that reads the name, as it did in the one-module file.session_transfer.py(739)session_transfer_staging(307) bundle format, staging dirs, bundle files ·session_transfer_layers(435) Layer A/B reads, Layer B writes on arrival ·session_transfer_intake(834) admitting and parsing an arriving body ·session_transfer_install(1123) validating and installing ithandlers_instances.py(1527)handlers_instances_gate(317) owner gate, audit, registry access, chain policy ·handlers_instances_peer(1209) the routes that read a peer, and the proxyRows keyed by path follow the code: in
security_posture.pythe receive-side scrub is listed inNON_EGRESS_REDACTION_MODULES(inbound sanitisation;session_transfer.pystays the registered "Session transfer bundle" sink), the "Peer live-session list" sink names the peer owner, and the baseline-redactor census row,error-code-baseline.jsonrows (totals unchanged) and the two.github/file-line-cap-baseline.txtrows move or go. The instances spec, the module index and the feature map name the owners.Backwards compatibility
Compatible: every BASE name stays reachable at its original path (
test/campaign_facade_inventories/kiro_crew.dashboard.{session_transfer,handlers_instances}.jsonfreezes them); the moved functions are the same objects.Reader: src/kiro_crew/dashboard/routes/chat.py:session_transfer.api_chat_slot_import -- chat -- served by the facade; test_session_transfer.py drives
POST /api/chat/slots/importthrough itReader: src/kiro_crew/dashboard/session_export.py:write_bundle_file -- chat --
from kiro_crew.dashboard.session_transfer import write_bundle_fileresolves through the facade; test_session_export.pyReader: src/kiro_crew/dashboard/session_export.py:release_bundle_files -- chat -- bound on the facade (imported from its staging owner); test_session_export.py
Reader: src/kiro_crew/dashboard/handlers_instances.py:local_instance_label -- crew page -- imported from the session_transfer facade; test_session_transfer.py send tests
Reader: src/kiro_crew/dashboard/session_transfer_staging.py:write_bundle_json -- chat -- called by write_bundle_file in the same owner; test_session_transfer.py
Reader: src/kiro_crew/dashboard/routes/connections.py:handlers_instances.api_instances_capabilities -- crew page -- route registered by facade attribute; test_remote_crew_capabilities.py
Reader: src/kiro_crew/dashboard/routes/connections.py:handlers_instances.api_instances_approval_state -- crew page -- same registration; test_remote_crew_capabilities.py
Reader: src/kiro_crew/dashboard/routes/connections.py:handlers_instances.api_instances_versions -- crew page -- same registration; test_instances_remote_update.py
Reader: src/kiro_crew/dashboard/routes/connections.py:handlers_instances.api_instances_chat_slots -- crew page -- same registration, identity pinned by test_remote_crew_peer_slots.py
Reader: src/kiro_crew/dashboard/routes/connections.py:handlers_instances.api_instances_proxy -- crew page -- same registration, identity pinned by test_remote_crew_peer_slots.py
Reader: src/kiro_crew/dashboard/handlers_instances_peer.py:read_peer_slots -- crew page -- called by api_instances_chat_slots in the same owner; test_remote_crew_peer_slots.py
Reader: src/kiro_crew/dashboard/handlers_crew_turn.py:ProxyReplyUnredactable -- crew page -- module-level import from the facade still binds the same class; test_crew_turn_proxy.py
Move audit
move_audit.py --base 27ab9383e2 --head HEAD:src/kiro_crew/dashboard/session_transfer.py: 3098 -> 739 lines; moved 100.0% (python-ast)(97/97 units, 0 changed)src/kiro_crew/dashboard/handlers_instances.py: 2871 -> 1527 lines; moved 100.0% (python-ast)(68/68 units, 0 changed)Glue only: owner imports, the mirror install and its
TYPE_CHECKINGmanifest,# noqa: F401on project imports the facade's own code no longer reads, and stdlib/third-party imports it no longer reads deleted (owners bind them; the mirror serves them). One kept line edited: each facade bindsloggerby its literal dotted name, the same object its owners bind (L25: log names unchanged; the mirror's one-object rule also holds underpython -m).Also moved: the facade header's note on why
chat_handlersis imported function-locally now sits insession_transfer_install, beside the code it governs; the facade keeps a two-line pointer.Comment-only edits in moved code (comments only, so the move audit still matches every unit), where the prose named the module it moved out of: the proxy's audit note (
handlers_instances_peer) namesapi_instances_search_sessionsin the facade and_auditinhandlers_instances_gate, and the owner-gate note (handlers_instances_gate) names the routes "ofhandlers_instances". Docstrings are left byte-identical, since they are part of each unit's AST:api_chat_slot_import's "see the module docstring" (session_transfer_install.py:337) and the refusal helper's "local to this module" still read as they did in the one-module file.Class names: the seven moved exception classes (
_DiskFull,_UploadsBusy,_ExpansionBusy,_NeverFits,_MemoryWaitTimedOutinsession_transfer_intake;PeerSlotsUnavailable,ProxyReplyUnredactableinhandlers_instances_peer) keep their facade's__module__, set after each owner's body, because a raised class renders asmodule.qualnamein a traceback. The four other moved classes (TransferBundle,LayerBEvents,_PrefixPublication,PeerSlots) keep the owner's__module__: a search ofsrc/andtest/finds no reader of their module name (no response body, SEL record, log capture, pickle or__module__-based selection).L36:
git diffandgit diff --minimaladd and delete the same lines in every file (session_transfer.py +145/-2504 both, handlers_instances.py +89/-1433 both).Docs citations (L29)
docs/request-for-change/rfc-remote-crew-sidebar.md(4 path cites),rfc-conductor-remote-dispatch.md(api_instances_proxy) andrfc-outbound-instance-transport.md(api_instances_proxy,read_peer_slots) ->handlers_instances_peer.py.docs/request-for-change/plans/2026-09-23-outbound-instance-transport.md(the PATCH immutability set) ->handlers_instances_gate.py.docs/request-for-change/rfc-arrival-provenance-filing.mdstatus line anddocs/request-for-change/README.md(arrival filing) ->session_transfer_install.py.docs/system-specs/modules/instances.md,docs/system-specs/modules/README.md,docs/feature-map/README.md(4 rows): the owners named where code now lives.docs/feature-map/README.md, the Project AWS profile row: the match and spawn injection now citessession_allocation.pyandsession_allocation_parts/, where that code lives on main.Tests
test_r6_owner_gate_regression.py::test_every_instances_route_runs_the_guard: counts routes of the facade and the peer owner against their_guardsites (19 == 19, as at BASE).test_apps_instances_loop_offload.py::test_no_direct_registry_call_in_instances_handler_async_frames: scans the facade, the gate owner (_chain_refusal) and the peer owner.test_r6_owner_gate_regression.py_GATED_MODULESlists the peer owner, so_walkselects the same 74 routes as at BASE (dumped at both commits).test_transcript_derivation_seam.py_PUBLISH_MODULESlists the two handlers_instances owners.test_session_transfer.py::test_staging_helpers_sweep_orphans_on_first_use: its private module copy is the staging owner, where the helpers live.test_session_transfer.py::test_importer_never_answers_404_or_405: reads the facade and all four owners.test_transcript_derivation_seam.py::…::test_the_known_derivers_do_not_use_plain_reads: the four owners join the deriver set.test_session_transfer.py::test_import_never_reads_the_whole_body_into_memory: path joined to its new homes; vacuous at BASE, because it matches onlyast.FunctionDefand the three handlers are async; tracked in test(session_transfer): the whole-body buffering guard never inspects the async handlers #21314.test_session_transfer_intake.pyandtest_handlers_instances_peer.pypin the seven exception classes to their facade's__module__(one parametrized assertion each; dropping an assignment turns it red).test_dashboard_server_composition_contract.py::test_the_lazy_imports_stay_inside_the_functions_that_need_them, fixed on main by test: pin the composition contract's lazy-import count at 84 #20930); after the review fold and the rebase onto310ad48b5f, the 51 transfer/instances and guard files plustest_warm_task_brief.py: 2,649 passed;mypy src/kiro_crewclean (2,454 files); flake-pattern ratchet 56 passed; black, isort, flake8, comment-history, brand, harness-parity, subprocess-encoding, agent-sdk, sync-io, memory-seam, feature-map, docs-lint andcheck_file_line_cap.py(0 failures) all pass; semgrep (the CI packs +semgrep/) with--baseline-commitreports 0 new findings; per-owner line coverage on the narrow set 89–100%; an installed wheel imports all eight modules. The two new pin tests passed 5 runs at -n0 and one at -n 3.local-gate.py --dry-runselects 64 backend files (all included) and 366 frontend cross-surface files (not run: nowebsite/change).Manual verification
N/A — a verbatim move; the unit and contract suites above exercise every moved path, and an installed-wheel import smoke loads every new module.
Related Issues
Part of #20192
Follow-up: #21314 (the whole-body buffering guard's AST match never reaches the async handlers; pre-existing at BASE, moved unchanged here)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)