Repository navigation
refactor(dashboard): move DashboardState into state_parts owners - #21647
Conversation
Sensitive change review
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Sensitive Change ReviewSensitive files changed:
|
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify that the posture panel's re-keyed sink rows ( [DESIGN-REVIEWED] 23f119e Description read[DESCRIPTION-READ] de9ebfa8ae4bb2b0a72db40c9f85b6b956c90c1c10b88006ce0f2fc885d73fcb 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 the security-posture panel's two moved sink paths, now What this change shipsInventory (7 items) — 7 justifiedIntent: bring
[FIRST-PRINCIPLES-REVIEWED] 23f119e Description read[DESCRIPTION-READ] d34b93c08431b5b6ee828c977188951a83101f60ee792c4f4828d17ffe7f95ba That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
fec8ad8 to
b2d62fe
Compare
b2d62fe to
94f15c3
Compare
|
|
dashboard/state.py was still 5,385 lines after #20507, almost all of it DashboardState. The class is split the way _ChatSlot was: by binding. state_parts/dashboard_state.py keeps the class shell (docstring, class defaults, __init__, properties) and binds each method from the collaborator that already owns that responsibility's module helpers. Method bodies move unchanged; own_methods restores each binding's __qualname__, so signatures, coroutine kinds and patch.object targets are what the one-module class had. state.py stays the import path and patch surface (5,385 -> 536 lines) and leaves the line-cap baseline. Tests freeze DashboardState's member inventory and type hints as measured on the one-module file, and drive the session recycle and stuck-turn callbacks. The two security-posture sink rows whose redaction moved name their new owners, and comments that cited state.py for moved code name the owner instead. Part of #20192
94f15c3 to
23f119e
Compare
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Every review lane on the head is clean (only runner notices and PR Scope / Opus size warnings); held by the triage cron on a size, path or checklist rule, not a finding. Approved on the watch holder's request.
Problem / Motivation
Goal: Bring
dashboard/state.pyunder the 2,000-line cap: moveDashboardStateintodashboard/state_parts/owners while every import path, patch target and behaviour stays the same.src/kiro_crew/dashboard/state.pyis still 5,469 lines after #20507, almost all of itDashboardState(about 4,940 lines). The campaign rule is that no hand-written file exceeds 2,000 lines, and this file is one of the most-edited in the repo, so every feature PR that touches it pays for its size in review and merge conflicts. #20507 moved the module helpers and_ChatSlot; this PR moves the class that remains.Why it matters
A reader looking for "how slots are pushed to the browser" or "where approvals are resolved" has to search one 4,940-line class. Splitting it by responsibility gives each part a file named for it and a place for new code to go, without asking any caller or test to change, and takes
state.pyoff the line-cap baseline.Not a goal
DashboardStatekeeps every field on itself; collaborators hold behaviour only.What changed (motivation → approach → change)
DashboardStateis split the way #20507 split_ChatSlot: by binding, not inheritance.state_parts/dashboard_state.pykeeps the class with its docstring, class-level defaults,__init__, properties and one binding line per method (notify = _dashboard_services.notify). Each method's body moves, unchanged, into the collaborator that already holds that responsibility's module helpers, as a function whose first parameter isself.own_methodsrestores each bound function's__qualname__(DashboardState.notify), so signatures, coroutine kinds,MagicMock(spec=DashboardState)andpatch.object(DashboardState, ...)see what the one-module class had.state.pykeeps its import block, re-exports every name it bound, and installskiro_crew._facade_mirror, sokiro_crew.dashboard.state.<name>patches still reach every reader.request_slot_origin,set_build_info(with the_build_infoglobal it rebinds),_DEFAULT_PORTand_SSE_INTERVAL_SECSmove with the class.dashboard/state_parts/)DashboardStatemembers addeddashboard_services.pysession_events.pystatus_payload.pystatus_snapshot, served bundle, lesson countslot_directory.pyrequest_slot_originsidebar_stores.pysource_links.pyslots_frame.pyslots_push.py_broadcast, the websocket fan-outdashboard_state.py(new)state.py: 5,486 → 538 lines; its.github/file-line-cap-baseline.txtrow is deleted.Move audit
The 182 changed units are
DashboardStatemembers moved into collaborators.replumb_audit.pycompares every unit of both PRs with the one-module file and finds each equal once the allowed transforms are undone: theself: DashboardStateannotation (dropped at run time byown_methods), one level less indentation, and black re-indenting the docstring. The one unit it lists,_atomic_write_json_strict, is a@staticmethodthat becomes the bindingstaticmethod(...), as_todo_text_linedid in #20507.Other justified edits:
notification_bus,notification_channel_settings,resource_pressure_notifier,file_indexes,_chat_pins_lock,_folders_lock,_folders_generation, and the lazily set_lineage_sent), plus aTYPE_CHECKINGimport ofFileIndexRegistry. Owner functions read these throughself, and mypy cannot type them before it has inferred__init__. They create no class attribute, sogetattr(self, "_lineage_sent", None)still finds none.logging.getLogger(__name__)calls inside moved methods name"kiro_crew.dashboard.state", the BASE logger (L25).acp/client.py::_TOOL_STALL_TIMEOUTnamesacp/client_timeouts.py::_TOOL_STALL_TIMEOUT, where G03's split put it.Diff alignment (L36):
git diffandgit diff --minimalgive the same + and - counts for each of the 79 changed files (state.py: +76 / -5,024).Docs and citations
learn-cron-dashboard.md's owner map lists every owner'sDashboardStateresponsibility, names the two methods the shell keeps (note_crew_log_classand_atomic_write_json) and why, and namestest/test_state_parts_dashboard_state.pyas the member inventory.test/campaign_facade_inventories/kiro_crew.dashboard.state.jsongains the rebound homes ofDashboardState,request_slot_originandset_build_info; no base name changes.state.pyfor code now defined in an owner. Only the cited path or name changes; a line that grew past 100 columns carries its last words to the next line. Mentions ofstate.pyas the import path, the patch surface, an import-time effect or history are left alone.Every re-pointed citation (file:line → new home)
docs/feature-map/README.md:91→state_parts/slot_sidebar.pydocs/feature-map/README.md:118→dashboard/state_parts/transcript_rows.pydocs/feature-map/README.md:142→dashboard/state_parts/slot_directory.py,dashboard/state_parts/dashboard_state.py,dashboard/state_parts/slot_transcript.pydocs/request-for-change/README.md:84→dashboard/state_parts/injected_turns.pydocs/request-for-change/README.md:98→state_parts/slots_frame.pydocs/request-for-change/rfc-channel-plugin-architecture.md:111→dashboard/state_parts/dashboard_state.pydocs/request-for-change/rfc-crewmate-profile-settings.md:38→dashboard/state_parts/chat_slot.pydocs/request-for-change/rfc-everything-is-an-app.md:179→dashboard/state_parts/session_events.pydocs/request-for-change/rfc-issue-radar-crews.md:363→state_parts/chat_slot.pydocs/request-for-change/rfc-local-notification-bus.md:37→dashboard/state_parts/dashboard_services.pydocs/request-for-change/rfc-notification-bridge.md:45→dashboard/state_parts/dashboard_services.pydocs/request-for-change/rfc-session-address-model.md:148→dashboard/state_parts/slot_directory.pydocs/request-for-change/rfc-transcript-section-markers.md:179→dashboard/state_parts/slot_transcript.pydocs/request-for-change/rfc-transcript-section-markers.md:405→dashboard/state_parts/slot_transcript.pydocs/request-for-change/rfc-transcript-section-markers.md:409→dashboard/state_parts/transcript_rows.pydocs/request-for-change/rfc-transcript-section-markers.md:571→dashboard/state_parts/transcript_rows.pydocs/request-for-change/rfc-transcript-section-markers.md:673→dashboard/state_parts/slot_transcript.pydocs/request-for-change/rfc-webhook-subscriptions.md:346→dashboard/state_parts/injected_turns.pydocs/request-for-change/rfc-webhook-subscriptions.md:570→dashboard/state_parts/injected_turns.pydocs/system-specs/modules/app-kit-platform.md:2197→dashboard/state_parts/slots_push.pydocs/system-specs/modules/app-notifications.md:131→dashboard/state_parts/session_events.pydocs/system-specs/modules/knowledge.md:601→dashboard/state_parts/dashboard_state.pysrc/kiro_crew/artifact_store/folders.py:57→dashboard/state_parts/sidebar_stores.pysrc/kiro_crew/context_assembly/session_start.py:252→dashboard/state_parts/slot_transcript.pysrc/kiro_crew/dashboard/chat_api/chat_send.py:107→state_parts/transcript_rows.pysrc/kiro_crew/dashboard/chat_api/chat_send.py:423→state_parts/slot_directory.pysrc/kiro_crew/dashboard/chat_api/slot_create.py:430→state_parts/slot_directory.pysrc/kiro_crew/dashboard/chat_api/slot_detail.py:308→state_parts/slot_transcript.pysrc/kiro_crew/dashboard/chat_api/slot_detail.py:379→state_parts/slot_transcript.pysrc/kiro_crew/dashboard/chat_api/turn_stop.py:246→state_parts/chat_slot.pysrc/kiro_crew/dashboard/chat_fork.py:419→state_parts/slot_directory.pysrc/kiro_crew/dashboard/chat_runner.py:14003→state_parts/slot_ladder.pysrc/kiro_crew/dashboard/chat_turn/file_changes.py:1299→state_parts/transcript_rows.pysrc/kiro_crew/dashboard/chat_utils_injected_rows.py:80→state_parts/injected_turns.pysrc/kiro_crew/dashboard/handlers/updates.py:2650→state_parts/slots_push.pysrc/kiro_crew/dashboard/session_control_parts/session_messaging.py:660→state_parts/dashboard_services.pysrc/kiro_crew/dashboard/session_memory.py:300→state_parts/slot_directory.pysrc/kiro_crew/dashboard/session_pulse_counter.py:14→state_parts/slot_directory.pysrc/kiro_crew/dashboard/ws_event_scope.py:97→state_parts/slots_push.pysrc/kiro_crew/dashboard/ws_event_scope.py:787→state_parts/slots_push.pysrc/kiro_crew/decisions/points/compaction_keep.py:916→dashboard/state_parts/session_events.pysrc/kiro_crew/history_projection.py:1530→state_parts/slot_directory.pysrc/kiro_crew/knowledge/store.py:259→dashboard/state_parts/dashboard_state.pysrc/kiro_crew/messaging/registry.py:8→dashboard/state_parts/dashboard_state.pysrc/kiro_crew/release_channel.py:7→dashboard/state_parts/status_payload.pysrc/kiro_crew/safety_override.py:2037→dashboard/state_parts/status_payload.pysrc/kiro_crew/slack/format.py:30→dashboard/state_parts/slot_transcript.pysrc/kiro_crew/snapshot_merge.py:1085→dashboard/state_parts/notification_log.pytest/test_chat_slack.py:734→state_parts/chat_slot.pytest/test_dashboard_chat_compaction.py:191→state_parts/session_events.pytest/test_dashboard_chat_pagination_suffix.py:92→state_parts/slot_transcript.pytest/test_dashboard_chat_pagination_suffix.py:480→state_parts/transcript_rows.pytest/test_dashboard_chat_pagination_suffix.py:592→state_parts/slot_transcript.pytest/test_dashboard_chat_unflushed_tail.py:346→state_parts/slot_transcript.pytest/test_eventlog_hooks.py:446→state_parts/slot_directory.pytest/test_fargate_launch_engine.py:204→state_parts/dashboard_state.pytest/test_is_interrupted.py:168→state_parts/session_events.pytest/test_members_preview_speech_only.py:373→state_parts/slot_directory.pytest/test_members_preview_speech_only.py:567→state_parts/slot_directory.pytest/test_recovery_marker_parity.py:89→state_parts/injected_turns.pytest/test_redact_meta_snapshot.py:142→state_parts/transcript_rows.pytest/test_session_pulse_session_count.py:85→state_parts/slot_directory.pytest/test_session_transfer.py:2969→state_parts/dashboard_state.pytest/test_state_store_preservation.py:1→state_parts/sidebar_stores.pytest/test_stop_handler_idempotent.py:569→state_parts/chat_slot.pytest/test_subagent_scale.py:1883→state_parts/chat_slot.pytest/test_workflows_service.py:1549→state_parts/chat_slot.pysrc/kiro_crew/security_posture.py:2326→ the owners' sink rows (state_parts/slot_transcript.py,state_parts/session_events.py), line-neutralsrc/kiro_crew/security_posture.py:2361→state_parts/slots_push.py(the WS egress)KC28 G04 CITE). Thechat_runner.pyone (state_parts/slot_ladder.py) is edited here after G01's refactor(dashboard): move the runner's turn helpers into chat_turn #21086 merged, rewrapped line-neutral; thehandlers/artifacts.py:803one (state_parts/slot_directory.py) waits for S39.References not edited (cost)
These comments name
state.pyfor code this PR moves. To keep the frontend lanes out of a backend-only change, they are left as is and re-pointed in Follow-up: #21320.website/scripts/capture-wait-countdown.mjs:484: the owner-websocket frame shape lives indashboard/state_parts/slots_push.py.website/src/app-sdk/index.ts:151:_serialize_for_clientlives indashboard/state_parts/slots_push.py.website/src/apps/crew-companion/sessionWatch.ts:89:broadcast_ws('approval', ...)lives indashboard/state_parts/slots_push.py.website/src/hooks/unreadOnAttention.ts:22:wire_session_recycle_callbacklives indashboard/state_parts/session_events.py.website/src/test/ChatSidebar.connectedChannelGlyph.test.tsx:65: theoriginlink is built indashboard/state_parts/slots_frame.py.Security posture rows (justified visible changes)
The posture panel names the module each redaction sink lives in. Two sinks moved, so their rows name the owner that now holds the call:
dashboard/state.pydashboard/state_parts/slot_transcript.pyredact=_redactinto the slot-payload projection; replacing it with an identity function failstest_preview_text.py(2 credential cases) andtest_coordinator_approval_slot_lane.pydashboard/state.pydashboard/state_parts/session_events.pydisplay_safe(notice)there fails 6 cases oftest_inbound_unbind_notice.pyslot_transcript.pyleavesNON_EGRESS_REDACTION_MODULES, because a module is in one bucket only (test_a_module_cannot_be_in_both_buckets).slot_directory.py, which holds a redactor call this PR moves, joins it beside the other owners. The count of posture items is unchanged.Backwards compatibility
Compatible: every module-level name
state.pybound still resolves through it, to the same object (frozen intest/test_state_parts_facade.pyand the inventory file).DashboardStatekeeps every member with the same kind, coroutine-ness and signature,__qualname__and identity with its body (test/test_state_parts_dashboard_state.py). Only__module__moves.Reader: src/kiro_crew/cli.py:set_build_info -- release -- imports
kiro_crew.dashboard.state.set_build_info, the moved function re-exported; the constructor reads the global it rebinds through the mirror (test_state_parts_facade::test_a_rebound_global_has_exactly_one_holder_and_is_read_live)Reader: src/kiro_crew/dashboard/handlers/members.py:request_slot_origin -- crew page -- imports
kiro_crew.dashboard.state.request_slot_origin, the moved function re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)Reader: src/kiro_crew/dashboard/chat_fork.py:request_slot_origin -- chat -- same re-export (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_api/chat_send.py:request_slot_origin -- chat -- reads it through the chat_handlers facade, which imports it from the state facade (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_api/slot_create.py:request_slot_origin -- chat -- same path as chat_send (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
CI path references
N/A — no workflow path filter or file list names
dashboard/state.py.Tests
test/test_state_parts_dashboard_state.py(new, 5 tests) freezesDashboardState's member inventory (kind, coroutine, async-gen, signature) as measured on the one-module file, checks each bound member is its collaborator's function and reads as a method, checks no bound member depends on the class body it left, and checkstyping.get_type_hintsresolves every member's hints as on the one-module file, except the 8 members it names, whose hints name_ChatSlot, which their collaborator imports only underTYPE_CHECKING, and the 3 that did not resolve on BASE either.test/test_state_parts_session_events.py(new, 4 tests, 5 cases) drives the two callbackswire_session_recycle_callbackregisters on a realDashboardStateand slot: the recycle and stuck-turn notice rows (role, text,meta.kind="compaction",meta.notice), the banner push after a recycle, no notice and nothing logged for a session with no tab or no live slot, and a failing append or banner push logged under the BASE logger instead of raised. It bringsstate_parts/session_events.pyfrom 76.6% to 89.5% line coverage.test/test_state_parts_facade.pyadds_build_info's single holder and namesDashboardState's home.state.py's text for code that moved now readstate.pyjoined with every owner (L30, L40):test_pipeline_board_card_publisher.py,test_stuck_turn_watchdog.py,test_ws_event_scoping_live.py,test_ws_event_scoping_origin.py;test_cron_store_unreadable_boundaries.pyandtest_dashboard_updates_coverage.pyre-key a path row. Assertions are unchanged. Planting one defect in each construct's new owner fails each of the six; the unmutated run passes.--covondashboard.stateandstate_parts): every file is at least 85.2% (sidebar_stores.py);state.py100%. No coverage baseline row is added.dashboard.state,DashboardStateorstate_parts(including the tests feat(sidebar): keep the pinned-session order on the gateway #21346, feat(sidebar): drag any session into a manual order kept on the gateway #21519 and fix(security): redact a streamed link cut inside its query as one link #20805 added), plus the mirror, inventory, posture, line-cap, flake-pattern and ratchet guards, at-n 3: 53,140 passed, 0 failed. mypy oversrc/kiro_crew: clean (2,951 files).Manual verification
N/A. Unit coverage is sufficient for a structural move with no runtime surface change.
Related Issues
Part of #20192
Follow-up: #21320
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)