Repository navigation
refactor(dashboard): move the runner's turn helpers into chat_turn - #21086
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 7d4b155 Description read[DESCRIPTION-READ] 0f8d307b7ad32340eb166ca4a15e864a13e81ff65969d74cf0ef18dace561307 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 |
Sensitive Change ReviewSensitive files changed:
|
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that What this change shipsInventory (8 items) — 7 justifiedIntent: shrink
[FIRST-PRINCIPLES-REVIEWED] 7d4b155 Description read[DESCRIPTION-READ] 340e603fb288806481045cc4fd1c4ccb4800e2ef14df042f86f2d9c857871f9c That sha256 names the PR description this verdict read. Recompute it with |
Sensitive change review
|
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that any guard outside this patch that reads a moved helper by its runner path, such as a semgrep rule or a doc-lint anchor, was pointed at the helper's new home. [DESIGN-REVIEWED] 7d4b155 Description read[DESCRIPTION-READ] 52869d8ee91ff178ccb76061dae743c320cd00888b0aa753252e447ed943ac1a 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 |
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: |
c9235b8 to
8bbaeed
Compare
|
|
HOLD at 8bbaeed (reserved for a human reviewer, no defect found). This PR moves the account-identity gate into chat_turn/account_identity.py and the segment redaction into chat_turn/segment_flush.py, and it edits What I checked: all 63 top-level units that leave To clear: a maintainer reviews the identity-gate and redaction moves and the registry change. — crew-pr-reviewer (r107) |
8bbaeed to
1647195
Compare
|
|
1647195 to
f9137f3
Compare
|
Rebased: main moved in |
|
|
|
Holding f9137f3.
No defect found. I compared the AST against merge base b6e801b: all 63 units removed from — crew-pr-reviewer (r108) |
Move 63 more top-level helpers of chat_runner.py, whole, into the chat_turn owner of each one's responsibility: six new owners (account_identity, decisions_hooks, segment_flush, session_reset, slash_commands, eager_spawn) and the recipient and prompt_assembly owners. compose binds every moved name on the runner, so chat_runner.<name> still resolves and a patch of it still reaches the moved code. Guards that read a moved construct by path read its new home: the composition contract's owner set, homes map and task-entry homes, the security posture non-egress registry, the transcript seam's plumbing list and the config-dir guard's file list. The table of moved names and the three tests that read it move, unchanged, into test_chat_runner_base_surface.py, so the contract stays under the line cap as the table grows. Part of #20192
f9137f3 to
7d4b155
Compare
|
Rebased: main moved in |
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved on behalf of the maintainer: refactor held by the cron on a feature-map README touch alone. Every review lane is clean on head 7d4b155 (only PR Scope size notes). Code-move verified by lanes.
Problem / Motivation
Goal: Move the next set of the dashboard chat runner's top-level helpers into
chat_turnowners by responsibility, sochat_runner.pysheds another 2,300 lines with no change to what a turn does.src/kiro_crew/dashboard/chat_runner.pyis about 18,500 lines after the previous PR of this series; the campaign rule is that no hand-written file goes over 2,000 lines. The helpers this PR moves (the account-identity gate, the decisions hooks and the Jev model routing, the segment flush, the deferred session reset, the cross-surface legs, the prompt and skill mentions, the local slash-command answers, the eager-spawn backoff) each belong to onechat_turnowner, new or existing.Why it matters
Every dashboard, Slack and channel turn runs through these helpers. Each one that stays in the runner keeps the file far over the cap and keeps unrelated work in one review surface. Moving them as whole definitions, with every guard that reads them by path pointed at their new homes, shrinks the runner while every patch of
chat_runner.<name>keeps reaching the moved code.Not a goal
_run_chatitself; its phases move in later PRs of the series._armed_prefetcheson (the rest of the eager spawn and prefetch, the/workflow,/agentand/goalhandlers) stay for the next PR: moving them in the same diff makes git's default diff show kept code as rewritten._expand_prompt_mention_off_loopstays in the runner:test_prompts.pyreads itsasyncio.to_threadcall in the runner's own text.What changed (motivation → approach → change)
Sixty-three top-level units (2,249 lines) move, whole, into eight owners, six of them new; each owner owns one responsibility, recorded in the composition section of
learn-cron-dashboard.md.composebinds every moved name on the runner, sochat_runner.<name>still resolves and a test's patch of it still reaches the moved code.account_identitydecisions_hookssegment_flush[OPTIONS:]footer audit, the widget registration; a local command's reply persisted through the same redactionsession_resetslash_commandseager_spawnrecipient,prompt_assemblyslash_commands(94 lines) is under 150 lines andeager_spawn(180) just over: the next PR moves the rest of their responsibility into them (the/workflow,/agentand/goalhandlers; the spawn and prefetch entries), which this diff leaves out for the reason above. Until then each one's docstring and spec row name only what it holds.Repository guards that read a moved construct by path read its new home: the composition contract's owner set, homes map and task-entry homes (the pending-reset retry now lives in
session_reset),security_posture's non-egress registry for the four owners that now hold redactor calls, the transcript seam's plumbing list, the config-dir guard's file list, and the frontend pin that reads the Jev routing constant's source (website/src/test/jevRoute.test.tsxreadschat_turn/decisions_hooks.py); the whole-package redact scan'schat_turnfloor (test_core_path_redact_before_bound.py) rises to the 11 owners that call a redactor now. Docs that name the runner as a moved helper's home name its owner, in each citation form (chat_runner.<name>,chat_runner.py::<name>,`chat_runner.py` (`<name>`)). The "Dashboard final message" sink still nameschat_runner.py: the runner runs that pass on an interrupted reply and_flush_segmentruns on the runner's globals, so the posture panel text is unchanged. The table of moved names (_BASE_SURFACE) and the three tests that read it move, unchanged, fromtest_chat_runner_composition_contract.pyto the newtest_chat_runner_base_surface.py, so the contract stays under the line cap as the table grows.Backwards compatibility
Compatible: every name
chat_runnerbound at the base is still bound, as the same object (the base-names contract test); every patch target still reaches the code it reached.Removes nothing: no public def, route, key or file leaves; the moved helpers are private, and each still resolves on
chat_runner.Tests
test_the_owner_set_is_the_package,test_a_moved_name_keeps_its_base_shape_and_owner[...]andtest_the_owners_define_functions_for_the_sweeps_to_checkgo fromtest/test_chat_runner_composition_contract.pytotest/test_chat_runner_base_surface.py. Collected over both files: 302 at the base, 365 at the head. The 63 new nodes aretest_a_moved_name_keeps_its_base_shape_and_owner[...]for this PR's 63_BASE_SURFACErows, andtest_a_task_entry_is_defined_in_its_home_file[_arm_pending_reset_retry-...]names the task entry's new home (dashboard/chat_turn/session_reset.py); every other node keeps its name and parameters.account_identity), plus 10 for this PR: the plumbing read, two non-egress rows, the config-dir guard in a new owner, a slice inside a redactor call insegment_flush, a backend-identity read indecisions_hooks, a moved name's changed signature, a row naming the wrong owner, an owner missing from the contract's owner set, and an owner that stops calling its redactor (the scan's raised floor goes red).chat_runner,chat_turnor a moved name, plus the flake, wait, line-cap, base-names, security-posture and path-inventory guards: 19,835 passed, 0 failed (-n 3 --dist loadgroup).scripts/local-gate.py --dry-runselects 547 backend and 369 frontend files, over the 600-file local budget, so this floor ran instead; CI runs the full suite.account_identity99%,decisions_hooks93%,segment_flush96%,session_reset86%,slash_commands97%,eager_spawn96%).website/src/test/jevRoute.test.tsx(19 tests) passes with vitest, eslint andnpm run typecheck; changing_JEV_ROUTE_AUTO_MODELSindecisions_hooks.pyturns it red.time.sleep(1)in each coroutine owner's first coroutine is reported by the sync-io gate's own scanner (18 of 18).src/kiro_crew: clean. semgrep 1.78 (CI configs, baseline at the base): 0 findings after one own-linenosemgrepon a moved warning that logs the redactor's pattern class, never the value; 0 parse errors. black, isort, flake8, comment-history, brand, docs-lint, agent-sdk, subprocess-encoding and sync-io gates: clean. Installed-mode import of the built wheel (under an isolated HOME): all 25 owners import.Move audit:
chat_runner.py18,687 → 16,372 lines, 143 units; every moved unit is unchanged, and the one changed unit is_arm_queued_delivery_settlement, which stays in the runner: its docstring now namesslack/gateway_runtime/subagent_injection.py, where_defer_queued_deliveryis defined (#21176), and a comment above the recovery-message re-exports nameschat_utils_injected_rowsandchat_utils_turn_recovery(#21094). L36: every file's default and--minimaldiffs add the same lines. Line cap: 0 failures. Thechat_runner.pyrow of.github/file-line-cap-baseline.txtstays as main has it: CI checks the merge with main, which adds runner lines while this PR is open, so a row lowered to this head's count would fail there; the guard notes the shrink, and the series deletes the row in the PR that brings the runner under the cap.Manual verification
N/A — a structural move; the turn-level characterization suite and the mutation-proven guards are the verification.
Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Move audit
The contract's changed units are its row tables (the owner set, the homes map, the task-entry homes) and its docstring line naming the new file;
_BASE_SURFACEmoved totest_chat_runner_base_surface.pywith this PR's 63 rows added. Edits to moved lines: one# nosemgrepline with its reason (the moved warning is new to semgrep because its file is).Follow-ups
_expand_prompt_mention_off_loopmoves toprompt_assemblyoncetest_prompts.py's offload check reads thechat_turnowners with the runner.