Skip to content

refactor(dashboard): split state.py helpers and _ChatSlot into owners - #20507

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g04-state
Oct 16, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g04-state

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring dashboard/state.py under the 2,000-line cap in two steps; this first step moves its module helpers and the _ChatSlot class into dashboard/state_parts/ owners while every import path, patch target and behaviour stays the same.

src/kiro_crew/dashboard/state.py is 11,326 lines: about 3,200 lines of module helpers, _ChatSlot (3,250 lines, of which __init__ alone is 1,305) and DashboardState (4,845 lines). The campaign rule is that no hand-written file exceeds 2,000 lines, and a file this size takes about 40 commits a week, so every feature PR that touches it pays for its size in review and in merge conflicts.

Why it matters

A reader looking for "how a slot's todo list works" or "where recovery prompts are built" has to search one 11k-line file whose two classes are each larger than most modules in the repo. The split gives each responsibility one file named for it, and a place for new code to go, without asking any caller or test to change.

Not a goal

  • DashboardState stays in state.py in this PR; it moves in the follow-up (Part of refactor: cap every hand-written source and test file at 2,000 lines #20192), which brings state.py to about 550 lines.
  • No behaviour change, no new feature, no fix: a real defect found while moving code is reported separately, not fixed here.
  • No change to who owns slot state: _ChatSlot keeps every field on itself (learn-cron-dashboard, "canonical owners of their mutable containers").
  • No CI workflow, gate or baseline is relaxed.

What changed (motivation → approach → change)

state.py stays the import path and the patch surface. The code it held moves to the new package dashboard/state_parts/, which the facade imports eagerly and composes with kiro_crew._facade_mirror (the campaign's shared mechanism), so a monkeypatch.setattr or mock.patch of kiro_crew.dashboard.state.<name> reaches every owner that reads the name, as it did in the one-module file.

_ChatSlot is split by binding, not inheritance. state_parts/chat_slot.py keeps the class with its __slots__, one typed declaration per field, the constructor and the properties, and binds each method as a one-line class attribute (set_todo = _slot_todo.set_todo). The method's body moves unchanged into the collaborator that owns its responsibility, as a function whose first parameter is self. The class attribute IS that function, so its signature, source, coroutine kind and identity are what MagicMock(spec=...), autospec, inspect.getsource and patch.object see. Each collaborator also owns the defaults (and their comments) of the fields it drives, in init_<x>_fields, which the constructor calls in the order those fields were first set.

What stays in state.py is one unbroken run of its original lines: the import block and DashboardState. Five definitions the class needs in this module move, verbatim, to just after it: _build_info and set_build_info (the constructor reads the global the setter rebinds), request_slot_origin (a source pin counts its text in this file), _DEFAULT_PORT and _SSE_INTERVAL_SECS. The re-exports and the mirror follow. The three names DashboardState reads while its class statement runs are imported just above the logger.

Owner (dashboard/state_parts/) Responsibility Lines
transcript_rows.py role sets, row ids and counts, quiet-end / stop / interrupted predicates, the chat_message frame and note, append_and_surface 602
injected_turns.py cron, subagent and monitor prefixes, every *_RECOVERY_PREFIX, recovery deciders and prompt builders 551
notification_log.py the durable notification log and its IO pool 362
source_links.py source-link chip budgets, public-repo status gate and audit, the slot's derivation and dismissal 431
slot_sidebar.py folder, pin, tags, colour, theme fields; the process tags revision 229
slot_todo.py the todo list, overrides and sync prompts 486
slot_session.py identity, relay binding, model and effort verdicts, crew-log predecessor latch, memory, channel link, title, MCP report 644
slot_turns.py close fence, note buffers, prompt queue and delivery ledger, running task, approvals and trust 697
slot_ladder.py recovery-ladder, model-fallback, steer, synthesis and wait-tool fields the chat runner keeps on the slot 491
slot_transcript.py append, update_message, disk-window bookkeeping, the lazy window, to_dict 604
chat_slot.py the _ChatSlot class 1,050
dashboard_services.py the coordinator factories and lazy accessors DashboardState reaches its coordinators through 129
session_events.py compact, recycle, unbind and stuck-turn notices; the crew-log class recording 204
status_payload.py the served bundle cache and index, uptime, governance status 32
slot_directory.py slot keys, the live and per-creator caps, SlotOrigin, the native-subagent output tail, genuine Slack links 204
sidebar_stores.py the folder repository, the folder-tree guard, the durable tag snapshot 42
slots_frame.py the slots frame and note and their pacing, channel-link labels and nonces, lineage parents 535
slots_push.py slot patch fields, the dynamic card store, the broadcast clock, the deferred-flush delay 47

state.py: 11,343 → 5,376 lines.

Four owners are under 150 lines here: dashboard_services.py, status_payload.py, sidebar_stores.py and slots_push.py. Each holds the module helpers of one DashboardState responsibility, and the follow-up moves that responsibility's DashboardState members into the same file (665, 298, 767 and 936 lines there).

Move audit

move_audit.py: src/kiro_crew/dashboard/state.py: 11343 -> 5376 lines; units 508, moved 444, changed 64 (moved_pct 74.5)
replumb_audit.py: identical 644, replumbed 302, changed 0, imports 61

Of the 64 units move_audit.py lists as changed, 63 are _ChatSlot members. replumb_audit.py shows each equals its BASE unit once the recipe's allowed transforms are undone, and nothing else differs:

  • the self: _ChatSlot annotation on a moved method, so mypy checks its body as it did. own_methods removes the annotation from the runtime object.
  • black re-indenting a docstring that is now one level shallower.
  • @staticmethod on _todo_text_line, which becomes the binding staticmethod(...).
  • __init__ split into init_<x>_fields calls. Every statement is verbatim. Each field annotation moves, with its BASE text, to a class-body declaration.

The 64th is _SERVED_INDEX, which resolves Path(__file__) one .parent further because its owner is one directory deeper; the path it names is the same (test_state_parts_facade::test_the_served_index_is_the_path_the_one_module_file_resolved).

Other justified edits:

  • Three comment/docstring rewordings into present tense, for the comment-history gate: the _PROMPT_ROLES comment, the _fallback_slot_model comment, and update_message's first docstring line.
  • _ChatSlot.durable_queue_entries and durable_queue_view stay in the class. As module functions they would call themselves: each body calls the slot_queue_repository function of the same name.
  • state.py's import block: nine stdlib and typing imports that nothing reads any more (no importer, no patch target, and not the facade's own code) are dropped: five whole lines go and three lines lose names. datetime stays bound, because windows_sim.colliding_clock patches it through the facade. The BASE imports of project names that the facade binds only for importers and patches (the facade contract keeps every BASE public name bound) are named in _BOUND_FOR_IMPORTERS rather than marked # noqa; a marker would edit every one of those kept lines. One TYPE_CHECKING import it no longer reads gets # noqa: F401, like its siblings.

Diff alignment (L36): git diff and git diff --minimal against the base give the same + and - counts for each of the 74 changed files (state.py: +362 / -6,329), so the diff gates judge the same lines the minimal diff shows.

Docs and citations

  • learn-cron-dashboard.md gains the owner map: what lives where, and where new code goes. injected-messages.md, code-style.md, session.md, decisions.md, app-notifications.md, app-kit-platform.md and two design notes name the owner file for the constructs they cite.
  • Prose citations re-pointed to the new home (L29), path or name only:
    • backend comments: channel_slots.py, chat_api/resume.py, chat_api/slot_detail.py, chat_persistence.py, chat_slack.py, chat_todo.py, slot_persistence/write_guards.py, apps/builtins/ops_mission_control/backend/http_routes/board.py and apps/builtins/aws_control/crew/runtime/container/front/transcript.py;
    • test docstrings: test_dashboard_updates_coverage.py, test_gateway_appkit_endpoints.py, test_last_message_preview_skips_stop_event.py, test_promise_only_recovery.py;
    • frontend comments: RecoveryCard.tsx, SessionPulseSurveyCard.tsx, SessionSourceChips.tsx, unreadOnAttention.ts, store/chat/selectors.ts, scripts/capture-sidebar-chip-budget.mjs, and four vitest files in website/src/test/ (ChatSidebar.sourceChipExpand.test.tsx, RecoveryCard.test.tsx, chatSlice.continuable.test.ts, toolBlockedCard.test.ts);
    • builtin_skills/team-lead/SKILL.md and six RFCs.
    • one moved comment: the cron-wrapper format comment, now in state_parts/injected_turns.py, names transcriptRendering.tsx (render). That file holds the cron-wrapper strip; the comment named ChatPage.tsx.
    • Two citations sit on single very long lines: the compaction row of docs/feature-map/README.md and the state.py bullet of learn-cron-dashboard.md. They are re-pointed in the follow-up, which rewrites that bullet anyway, so this diff stays under the review lanes' size cap; the owner map above that bullet already says where _ChatSlot lives.
  • RFC line citations into state.py (:668, :1459 twice, :3200) are cited by symbol; their four .github/docs-lint-baseline.txt line-ref rows are deleted by hand, and docs-lint passes.
  • website/scripts/capture-compacting-stop.mjs reads the three notices it quotes from state_parts/session_events.py, their owner. Its own extraction code, run against that file, yields the same three texts it extracted from BASE state.py.
  • .github/file-line-cap-baseline.txt: state.py's row is lowered to 5,376 (scripts/check_file_line_cap.py passes).

Backwards compatibility

Compatible: every module-level name state.py bound still resolves through it, to the same object (frozen in test/test_state_parts_facade.py and test/campaign_facade_inventories/kiro_crew.dashboard.state.json). _ChatSlot keeps every member with the same kind, coroutine-ness and signature, __qualname__ (_ChatSlot.append) and identity with its body. Its fresh-instance defaults are unchanged too. Only __module__ of _ChatSlot, of its moved methods and of the moved module functions now names the owner module.

Logger names (L25): every owner logs through logging.getLogger("kiro_crew.dashboard.state"), the BASE logger object, so caplog captures by that name and patch("kiro_crew.dashboard.state.logger") keep working.

Each public module-level function that moved is re-exported by the facade:
Reader: src/kiro_crew/dashboard/chat_regenerate.py:append_and_surface -- chat -- kiro_crew.dashboard.state.append_and_surface is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_runner.py:build_infra_retry_prompt -- chat -- kiro_crew.dashboard.state.build_infra_retry_prompt is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_runner.py:build_refusal_recovery_prompt -- chat -- kiro_crew.dashboard.state.build_refusal_recovery_prompt is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_runner.py:build_stale_recovery_prompt -- chat -- kiro_crew.dashboard.state.build_stale_recovery_prompt is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_runner.py:build_tool_stall_recovery_prompt -- chat -- kiro_crew.dashboard.state.build_tool_stall_recovery_prompt is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_handlers.py:chat_message_frame -- chat -- kiro_crew.dashboard.state.chat_message_frame is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/state.py:chat_message_note -- chat -- kiro_crew.dashboard.state.chat_message_note is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_handlers.py:context_entry_expired -- chat -- kiro_crew.dashboard.state.context_entry_expired is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/channel_slots.py:durable_row_count -- chat -- kiro_crew.dashboard.state.durable_row_count is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/state.py:ensure_tags_revision_epoch -- crew page -- kiro_crew.dashboard.state.ensure_tags_revision_epoch is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/state_parts/injected_turns.py:extract_log_redirect_target -- chat -- kiro_crew.dashboard.state.extract_log_redirect_target is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_persistence.py:is_quiet_end_row -- chat -- kiro_crew.dashboard.state.is_quiet_end_row is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_api/resume.py:is_stop_event_row -- chat -- kiro_crew.dashboard.state.is_stop_event_row is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_handlers.py:is_turn_interrupted -- chat -- kiro_crew.dashboard.state.is_turn_interrupted is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_api/resume.py:load_window_off_loop -- chat -- kiro_crew.dashboard.state.load_window_off_loop is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_tags.py:mint_tags_revision -- crew page -- kiro_crew.dashboard.state.mint_tags_revision is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_api/slot_detail.py:parse_cls_meta -- chat -- kiro_crew.dashboard.state.parse_cls_meta is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_runner.py:parse_hook_continuations -- chat -- kiro_crew.dashboard.state.parse_hook_continuations is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/channel_slots.py:row_mid -- chat -- kiro_crew.dashboard.state.row_mid is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/chat_runner.py:should_queue_hook_continuation -- chat -- kiro_crew.dashboard.state.should_queue_hook_continuation is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/agent_sdk/backends.py:should_queue_refusal_recovery -- chat -- kiro_crew.dashboard.state.should_queue_refusal_recovery is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/state.py:sweep_expired_notifications -- crew page -- kiro_crew.dashboard.state.sweep_expired_notifications is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/channel_slots.py:note_crew_log_class -- chat -- kiro_crew.dashboard.state.note_crew_log_class is the moved function itself, re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/state.py:DashboardState.native_subagent_snapshots -- subagent -- reads native_subagent_output_tail as a facade global, the moved function re-exported (test_state_parts_facade::test_a_moved_name_is_the_object_its_owner_holds)
Reader: src/kiro_crew/dashboard/state.py:DashboardState -- chat -- the stuck-turn watchdog reads stuck_turn_notice as a facade global, the moved function re-exported (test_stuck_turn_watchdog)

CI path references

N/A — no workflow path filter or file list names dashboard/state.py.

Tests

  • test/test_state_parts_facade.py (new, 19 tests) pins:
    • every BASE module name resolves through the facade to the owner's object, and the nine dropped stdlib and typing imports are not bound;
    • the mirror forwards no name (reads go to sys.modules first, the default);
    • the global-rebound globals (_TAGS_REVISION_*, _notification_io_pool, the lineage seed flags) have one holder and read live;
    • _ChatSlot's member inventory (kind, coroutine, async-gen, signature) equals BASE;
    • each bound member is its collaborator's function, reads as a method, and uses no zero-arg super(), __class__ or name-mangled attribute, with a self-test;
    • a fresh slot has BASE's default in every field;
    • the constructor runs the field groups in BASE order;
    • only the facade imports an owner, with a self-test;
    • _SERVED_INDEX names the same file it did;
    • typing.get_type_hints resolves every member as it did, except the named ones (enqueue_or_run_prompt, which names DashboardState, and the class-body field declarations);
    • the absence and count halves two live scopes' source pins read in state.py (test_slack_options_lifecycle, test_ws_event_scoping) hold over state.py joined with every owner.
  • The shared test/test_facade_mirror_guards.py discovers kiro_crew.dashboard.state and holds the family-wide checks for it: one object per name, no owner importing the facade, and every patched name reaching its readers. Each was shown red on a planted defect in this family.
  • Path, row and join re-points in source pins (L30, L40). Assertions are unchanged, and each was mutation-proved against the new home:
    • test_recovery_card_prefixes.py and test_recovery_marker_parity.py read state.py joined with every state_parts/ owner;
    • test_orphaned_approval_card.py::test_every_call_site_flags_dirty and all three test_serving_loop_unified.py ratchets add the state_parts/ owners to the files they scan;
    • the test_options_cap_contract.py allowed row is now dashboard/state_parts/slot_transcript.py;
    • the three test_slot_running_readers.py keys are now state_parts/chat_slot.py;
    • the test_security_posture.py census row is now dashboard/state_parts/slot_turns.py.
  • test_poisoned_escalation.py (upstream pin, integration-owner grant): its constructor exemption is re-keyed to state_parts/chat_slot.py, plus the collaborator that sets the cells' defaults (slot_ladder.init_ladder_fields), because the cells' defaults moved with init_ladder_fields. Assertions are unchanged; a stray write in slot_ladder.py or slots_push.py still fails it.
  • Registry rows: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains the six owners that call a redactor, in the "owner-driven components extracted from dashboard/state.py" block; they add no egress path.
  • test/campaign_facade_inventories/kiro_crew.dashboard.state.json freezes the facade's BASE public names and the module that holds each rebound one; test_campaign_facades_base_public_names.py loads it.
  • Determinism: the new tests use no clock, no sleep and no ports, and they patch only inside MonkeyPatch.context. They pass 5 runs at -n0 and one at -n 3.
  • Local floor (local-gate.py --dry-run selects about 2,800 backend and 1,500 frontend files, over the campaign's ~600 cap, so the floor ran instead): the 487 test files that import, patch or read dashboard.state, DashboardState or _ChatSlot, plus the mirror, registry and ratchet guards: 26,724 passed, 30 skipped, 4 xfailed at -n 3. test_flake_pattern_ratchet.py passes at -n0.

Manual verification

N/A. Unit coverage is sufficient for a structural move with no runtime surface change. Imports were checked in a scratch wheel install under env -i.

Screenshots / video

Why no screenshot: the only frontend edits are comments that name the file a mirrored backend constant now lives in; nothing renders differently.

Related Issues

Part of #20192

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

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head commit: 93b3ea9

  • What rule changed: none. src/kiro_crew/security_posture.py gains six rows in NON_EGRESS_REDACTION_MODULES, the paths of the dashboard/state_parts/ owners that now hold redactor calls moved verbatim out of dashboard/state.py.
  • Before -> after: before, those redactor calls lived in dashboard/state.py under its existing classification; after, the same calls live in state_parts/dashboard_services.py, notification_log.py, slot_transcript.py, slot_turns.py, slots_frame.py and transcript_rows.py, listed beside the other owners extracted from dashboard/state.py.
  • Worst case if wrong: a real output boundary among those six owners would go uncounted on the security posture panel; no redaction is removed or bypassed, because the call sites are byte-identical to BASE and still run.
  • Evidence checked: test/test_security_posture.py (sink-or-allowlisted omission check, log-site census) passes; the move audit shows the redactor call sites moved unchanged; no new egress path (no new network, file or log writer) exists in the owners.
  • No regression:
    • Tools still work: unchanged; every redactor still runs at the same call sites with the same arguments, proven by the 26,664-test local floor.
    • Backward compatible: yes, every module-level name and patch target of dashboard/state.py still resolves to the same object through the facade.
    • Existing tests: test_security_posture.py, test_state_parts_facade.py and the full dashboard floor pass unmodified apart from the granted path rows.
  • How to undo: revert this commit; the six registry rows and the owner modules go together, and dashboard/state.py returns to the single-module file.

@github-actions

github-actions Bot commented Oct 14, 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 6cc9f23.

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

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing to check.

[UX-REVIEWED] 6cc9f23

Description read

[DESCRIPTION-READ] 84df4dfe2f8c903138f9a6072ede725aa8b4029a9b47479491264db439cf06b6

That sha256 names everything this verdict read: the PR description, plus the 3 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 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 6cc9f232e7ee74c1a9a167783ee9521a1b204218 — 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

Nothing to check.

What this change ships

Inventory (8 items) — 8 justified

Intent: shrink dashboard/state.py (11,343 lines) toward the 2,000-line cap so contributors work in files named for each responsibility, with no change in behaviour. This is an ADDITION (a refactor) with no fix in it.

  1. Module helpers move out of state.py into 13 state_parts/ owner modules; state.py stays the import and patch path through the existing kiro_crew/_facade_mirror.py (30 importers) — justified
  2. _ChatSlot moves to state_parts/chat_slot.py, with its method bodies bound in from 10 collaborator modules; __init__ is split into init_<x>_fields calls — justified
  3. _SERVED_INDEX adds one .parent because its file is one directory deeper; the path it resolves to is the same and a test pins it — justified
  4. Nine unused stdlib/typing imports are dropped; kept names are listed in _BOUND_FOR_IMPORTERS, which follows the precedent at history_consolidation.py:1130 — justified
  5. The state.py row in the file-line-cap baseline shrinks from 11318 to 5385, and three stale docs-lint line-refs are removed — justified
  6. Six new owners are added to NON_EGRESS_REDACTION_MODULES in security_posture.py, so the modules that took over the redaction code stay registered — justified
  7. Path references in code comments, specs, RFC text, a skill and frontend comments are repointed to the new owners — justified
  8. Existing source-scanning tests are widened to read state_parts/*.py, and a new facade test joins the 25 existing test_*facade*.py files; no pin is reversed — justified

[FIRST-PRINCIPLES-REVIEWED] 6cc9f23

Description read

[DESCRIPTION-READ] b0cbb7df7f16012d723cb9305e479d9538a92e166993b71f847b8551370c4f13

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 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that the full backend suite is green, not just local-gate's diff-related subset: the patch targets that still work depend entirely on _facade_mirror reaching every new owner.

[DESIGN-REVIEWED] 6cc9f23

Description read

[DESCRIPTION-READ] 752fd79b7ba3650dd9d4702b7bbf697741bc09f4714547388d316b6d0af5105a

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 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 6cc9f232e7ee74c1a9a167783ee9521a1b204218 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6cc9f23

Verdict parsed from the review's SHA-scoped output markers for commit 6cc9f232e7ee74c1a9a167783ee9521a1b204218.

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

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 6cc9f232e7ee74c1a9a167783ee9521a1b204218 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6cc9f23

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

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: the facade mirror carries every mock.patch("kiro_crew.dashboard.state.<name>") target to every holder (answered, no code change)

Checked, not assumed. test/test_state_parts_facade.py::test_every_name_the_tests_patch_through_the_facade_reaches_every_holder derives every name the test trees patch through kiro_crew.dashboard.state (setattr, mock.patch strings, patch.object), patches each one on the facade, and asserts every owner that binds the name sees the patched object. Its self-test proves the scan can fail.
S04's test_facade_mirror_guards.py checks the same facade from the other side: no unrouted patch, three executed round trips, and no owner reading an indexed name it does not hold.
Owners read moved names as their own module globals, which the mirror writes on every holder. The 26,664-test local floor (every file that imports, patches or reads dashboard.state) passes unmodified.

@bolichen97
bolichen97 enabled auto-merge (squash) October 14, 2026 23:05
@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 14, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head commit: 0f98bc9

  • What rule changed: none. src/kiro_crew/security_posture.py gains six rows in NON_EGRESS_REDACTION_MODULES, the paths of the dashboard/state_parts/ owners that now hold redactor calls moved verbatim out of dashboard/state.py.
  • Before -> after: before, those redactor calls lived in dashboard/state.py under its existing classification; after, the same calls live in state_parts/dashboard_services.py, notification_log.py, slot_transcript.py, slot_turns.py, slots_frame.py and transcript_rows.py, listed beside the other owners extracted from dashboard/state.py.
  • Worst case if wrong: a real output boundary among those six owners would go uncounted on the security posture panel; no redaction is removed or bypassed, because the call sites are byte-identical to BASE and still run.
  • Evidence checked: test/test_security_posture.py (sink-or-allowlisted omission check, log-site census) passes; the move audit shows the redactor call sites moved unchanged; no new egress path (no new network, file or log writer) exists in the owners.
  • No regression:
    • Tools still work: unchanged; every redactor still runs at the same call sites with the same arguments, proven by the 26,664-test local floor.
    • Backward compatible: yes, every module-level name and patch target of dashboard/state.py still resolves to the same object through the facade.
    • Existing tests: test_security_posture.py, test_state_parts_facade.py and the full dashboard floor pass unmodified apart from the granted path rows.
  • How to undo: revert this commit; the six registry rows and the owner modules go together, and dashboard/state.py returns to the single-module file.

@bolichen97
bolichen97 force-pushed the refactor/linecap-g04-state branch from 93b3ea9 to 0f98bc9 Compare October 15, 2026 00:40
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision 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 readiness: checking Automated validation is still running labels Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: patching kiro_crew.dashboard.state.<name> still reaches every state_parts/ owner that reads it (answered, no code change)

test/test_state_parts_facade.py::test_every_name_the_tests_patch_through_the_facade_reaches_every_holder derives the names from the test trees: every monkeypatch.setattr and mock.patch target spelled through kiro_crew.dashboard.state, by string, by module alias or by patch.object. It patches each name on the facade and asserts that every owner binding the name sees the patched object; a self-test proves the scan can fail.
S04's test_facade_mirror_guards.py checks the same facade from the other side: no unrouted patch, and no owner reading an indexed name it does not hold.
The local floor of every test file that imports, patches or reads dashboard.state passes unmodified.

@bolichen97
bolichen97 force-pushed the refactor/linecap-g04-state branch from 0f98bc9 to 06400e4 Compare October 15, 2026 02:14
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=42d9df97159f _BOUND_FOR_IMPORTERS binds names nothing reads (fixed in 06400e4 for the stdlib names; rebutted for the project names)

Fixed: the facade drops the nine stdlib and typing BASE imports that no importer, patch target or facade code reads: concurrent.futures, math, re, traceback, dataclass, timezone, Coroutine, NamedTuple, TypeVar. test_state_parts_facade pins them as unbound.
annotations (a __future__ import) and Iterator (read by a string annotation) leave the tuple, because they are not unused.
datetime stays bound: test/windows_sim.colliding_clock patches kiro_crew.dashboard.state.datetime through an f-string target, which the zero count missed. Dropping it turned 6 tests red in test_transcript_row_ordering.py.
Kept: the remaining entries are BASE public project names. The campaign facade contract keeps every BASE public name bound to the same object, consumers or not, and test_campaign_facades_base_public_names.py and test_state_parts_facade.py pin that. The tuple only marks those bindings used without editing the kept import lines.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head commit: 06400e4

  • What rule changed: none. src/kiro_crew/security_posture.py gains six rows in NON_EGRESS_REDACTION_MODULES, the paths of the dashboard/state_parts/ owners that now hold redactor calls moved verbatim out of dashboard/state.py.
  • Before -> after: before, those redactor calls lived in dashboard/state.py under its existing classification; after, the same calls live in state_parts/dashboard_services.py, notification_log.py, slot_transcript.py, slot_turns.py, slots_frame.py and transcript_rows.py, listed beside the other owners extracted from dashboard/state.py.
  • Worst case if wrong: a real output boundary among those six owners would go uncounted on the security posture panel; no redaction is removed or bypassed, because the call sites are byte-identical to BASE and still run.
  • Evidence checked: test/test_security_posture.py (sink-or-allowlisted omission check, log-site census) passes; the move audit shows the redactor call sites moved unchanged; no new egress path (no new network, file or log writer) exists in the owners.
  • No regression:
    • Tools still work: unchanged; every redactor still runs at the same call sites with the same arguments, proven by the 26,664-test local floor.
    • Backward compatible: yes, every module-level name and patch target of dashboard/state.py still resolves to the same object through the facade.
    • Existing tests: test_security_posture.py, test_state_parts_facade.py and the full dashboard floor pass unmodified apart from the granted path rows.
  • How to undo: revert this commit; the six registry rows and the owner modules go together, and dashboard/state.py returns to the single-module file.

@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 readiness: checking Automated validation is still running labels Oct 15, 2026
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 16, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Head e102da1135 is the campaign's re-cut of this PR on main 74a249d48a, byte for byte: the same tree and parent as the reviewed commit 3e8396ae95, so no further push was needed. It supersedes 84ace980c1.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 16, 2026
@bolichen97

bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the "Dashboard slot snapshot" posture row still names dashboard/state.py while _redact / to_dict live in state_parts/slot_transcript.py (rebutted, no code change)

_REDACTION_SINKS names logical egress paths, not call sites. The module docstring says so: sinks are "named rather than counted straight from call sites, because a raw grep count would count ... every refactor". The slot payload still leaves through dashboard/state.py: DashboardState builds it with slot.to_dict(...) and sends it with _send_ws_all.
The module that now holds the calls is classified: dashboard/state_parts/slot_transcript.py is in NON_EGRESS_REDACTION_MODULES, in the existing block for owner-driven components extracted from dashboard/state.py. That block's comment states the rule this follows: such owners "do not introduce new logical egress paths", and re-pointing the rows "would make a behavior-preserving decomposition change the public posture items and count". interaction_coordinator.py and slot_projection.py were extracted the same way.
The drift guard test_every_redactor_call_site_is_a_registered_sink_or_allowlisted passes, so no redactor call site is unclassified, and the panel's items and count are unchanged, as a structural split should leave them.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at e102da1 for maintainer review. No defect found.

The split reads as a mechanical move. The new owner lines are field annotations, method bindings, init__fields calls and docstrings. This matches the independent AST audit in #20507 (review). Every review lane on this head is PASS, the Design punchline has a disposition, and all checks are green.

Why it is held: the PR edits src/kiro_crew/security_posture.py (

"dashboard/state_parts/dashboard_services.py",
"dashboard/state_parts/notification_log.py",
"dashboard/state_parts/slot_transcript.py",
"dashboard/state_parts/slot_turns.py",
"dashboard/state_parts/slots_frame.py",
"dashboard/state_parts/transcript_rows.py",
). It also moves the slot's approval, trust-scope and credential-evidence code and the slot payload redaction into dashboard/state_parts/. Those changes need a human maintainer's sign-off.

— crew-pr-reviewer (r107)

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 16, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-g04-state branch from e102da1 to d12393d Compare October 16, 2026 18:29
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto main 780af13e7e (the PR had gone CONFLICTING). Head e102da1135 -> d12393d34, still one commit. No source conflicts: src/kiro_crew/dashboard/state.py and state_parts/ were untouched on main since 74a249d48a.

Six text conflicts, all path references, resolved by keeping main's new split-module names and this PR's state_parts/ owners:

  • .github/file-line-cap-baseline.txt: state.py row at this PR's 5376; main already dropped the token_auth.py row.
  • rfc-resumable-subagent-sessions.md, rfc-session-address-model.md: _normalize_slot_key -> state_parts/slot_directory.py; main's chat_utils_slots.py kept.
  • rfc-webhook-subscriptions.md: main's token_auth_paths.py kept; queue_append -> state_parts/slot_turns.py.
  • injected-messages.md: state_parts/injected_turns.py / state_parts/slot_todo.py; main's chat_utils_turn_recovery.py kept.
  • app-kit-platform.md: SlotOrigin -> state_parts/slot_directory.py; main's token_auth_app_scope.py kept.

Local: every kiro_crew.dashboard.* module imports; 57 related test files 3175 passed; isort, flake8, mypy (2691 files), docs-lint clean.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head commit: d12393d

  • What rule changed: none. src/kiro_crew/security_posture.py gains six rows in NON_EGRESS_REDACTION_MODULES, the paths of the dashboard/state_parts/ owners that now hold redactor calls moved verbatim out of dashboard/state.py.
  • Before -> after: before, those redactor calls lived in dashboard/state.py under its existing classification; after, the same calls live in state_parts/dashboard_services.py, notification_log.py, slot_transcript.py, slot_turns.py, slots_frame.py and transcript_rows.py, listed beside the other owners extracted from dashboard/state.py.
  • Worst case if wrong: a real output boundary among those six owners would go uncounted on the security posture panel; no redaction is removed or bypassed, because the call sites are byte-identical to BASE and still run.
  • Evidence checked: test/test_security_posture.py (sink-or-allowlisted omission check, log-site census) passes; the move audit shows the redactor call sites moved unchanged; no new egress path (no new network, file or log writer) exists in the owners.
  • No regression:
    • Tools still work: unchanged; every redactor still runs at the same call sites with the same arguments, proven by the 26,664-test local floor.
    • Backward compatible: yes, every module-level name and patch target of dashboard/state.py still resolves to the same object through the facade.
    • Existing tests: test_security_posture.py, test_state_parts_facade.py and the full dashboard floor pass unmodified apart from the granted path rows. On this head (rebased onto main 780af13e7e) the source diff under src/kiro_crew/dashboard/ and security_posture.py is line-for-line identical to e102da1135; only doc path references and the line-cap baseline row changed in the rebase. test_security_posture.py and test_state_parts_facade.py pass locally.
  • How to undo: revert this commit; the six registry rows and the owner modules go together, and dashboard/state.py returns to the single-module file.

@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
bolichen97 force-pushed the refactor/linecap-g04-state branch from d12393d to a7e8613 Compare October 16, 2026 18:52
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=f8b370d96aeb test_state_parts_facade.py restates the shared facade-mirror guards (fixed in a7e8613)

Verified before deleting: test_facade_mirror_guards._FACADES discovers kiro_crew.dashboard.state, and its patch scanner finds the same 34 names the private _patched_names found. The one name only the private regex listed, datetime (via windows_sim.colliding_clock), is covered by the shared unreached_readers bytecode reach proof, which checks every reader whatever the corpus patches.
Deleted the five tests (..._excludes_none, test_no_owner_imports_the_facade + _can_fail, ..._reaches_every_holder + test_the_patch_target_scan_can_fail) and their helpers _patched_names, _corpus_patched_names, _facade_imports and the regex constants. Test-only, no source change.
test_state_parts_facade.py (19 passed), test_facade_mirror_guards.py and test_facade_mirror.py pass locally.
self-added: yes
mechanism: per-facade regex re-implementation of the shared mirror guards, removed

@bolichen97

bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head commit: a7e8613

  • What rule changed: none. src/kiro_crew/security_posture.py gains six rows in NON_EGRESS_REDACTION_MODULES, the paths of the dashboard/state_parts/ owners that now hold redactor calls moved verbatim out of dashboard/state.py.
  • Before -> after: before, those redactor calls lived in dashboard/state.py under its existing classification; after, the same calls live in state_parts/dashboard_services.py, notification_log.py, slot_transcript.py, slot_turns.py, slots_frame.py and transcript_rows.py, listed beside the other owners extracted from dashboard/state.py.
  • Worst case if wrong: a real output boundary among those six owners would go uncounted on the security posture panel; no redaction is removed or bypassed, because the call sites are byte-identical to BASE and still run.
  • Evidence checked: test/test_security_posture.py (sink-or-allowlisted omission check, log-site census) passes; the move audit shows the redactor call sites moved unchanged; no new egress path (no new network, file or log writer) exists in the owners.
  • No regression:
    • Tools still work: unchanged; every redactor still runs at the same call sites with the same arguments, proven by the 26,664-test local floor.
    • Backward compatible: yes, every module-level name and patch target of dashboard/state.py still resolves to the same object through the facade.
    • Existing tests: test_security_posture.py, test_state_parts_facade.py and the full dashboard floor pass unmodified apart from the granted path rows. On this head (rebased onto main 780af13e7e) the source diff under src/kiro_crew/dashboard/ and security_posture.py is line-for-line identical to e102da1135; only doc path references and the line-cap baseline row changed in the rebase, and five duplicate tests left test/test_state_parts_facade.py (the shared facade-mirror guards hold those checks). test_security_posture.py and test_state_parts_facade.py pass locally.
  • How to undo: revert this commit; the six registry rows and the owner modules go together, and dashboard/state.py returns to the single-module file.

dashboard/state.py was 11,318 lines. Its module helpers and the
_ChatSlot class move into dashboard/state_parts/: owners named for one
responsibility each, plus chat_slot.py for the class. state.py stays
the import path and the patch surface; it imports the owners eagerly
and composes them with kiro_crew._facade_mirror, so every module-level
name it bound and every patch target keeps resolving to the same
object.

_ChatSlot is split by binding, not inheritance. The class keeps its
__slots__, one declaration per field, its constructor and properties,
and binds each method to the unchanged function in its collaborator.
Each collaborator also sets the defaults of the fields it drives in
init_<x>_fields, called in the order those fields were first set.

What stays in state.py is one run of its own lines: the import block
and DashboardState, with five definitions the class needs here moved
verbatim to just after it, then the re-exports and the mirror.

state.py: 11,318 -> 5,386 lines. DashboardState moves in a follow-up.

Part of #20192
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head commit: 6cc9f23

  • What rule changed: none. src/kiro_crew/security_posture.py gains six rows in NON_EGRESS_REDACTION_MODULES, the paths of the dashboard/state_parts/ owners that now hold redactor calls moved verbatim out of dashboard/state.py.
  • Before -> after: before, those redactor calls lived in dashboard/state.py under its existing classification; after, the same calls live in state_parts/dashboard_services.py, notification_log.py, slot_transcript.py, slot_turns.py, slots_frame.py and transcript_rows.py, listed beside the other owners extracted from dashboard/state.py.
  • Worst case if wrong: a real output boundary among those six owners would go uncounted on the security posture panel; no redaction is removed or bypassed, because the call sites are byte-identical to BASE and still run.
  • Evidence checked: test/test_security_posture.py (sink-or-allowlisted omission check, log-site census) passes; the move audit shows the redactor call sites moved unchanged; no new egress path (no new network, file or log writer) exists in the owners.
  • No regression:
    • Tools still work: unchanged; every redactor still runs at the same call sites with the same arguments.
    • Backward compatible: yes, every module-level name and patch target of dashboard/state.py still resolves to the same object through the facade.
    • Existing tests: on this head (rebased onto main 2245fd47b3) the only changes against the previous head a7e8613c80 are mechanical carries of main's feat: add return-triggered warm task briefs #20422 (return-triggered warm task briefs): its warm-brief cancellation block in _ChatSlot.append now lives in the moved append in state_parts/slot_transcript.py, byte-identical apart from indentation; the test_slot_running_readers.py enumeration keeps main's two warm_task_brief.py rows beside the moved state_parts/chat_slot.py row; and the dashboard/state.py line-cap baseline row is 5385 to cover main's added DashboardState.__init__ fields. No redactor call or posture row changed. test_security_posture.py, test_state_parts_facade.py, test_slot_running_readers.py and test_warm_task_brief.py pass locally.
  • How to undo: revert this commit; the six registry rows and the owner modules go together, and dashboard/state.py returns to the single-module file.

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.

4 participants