Repository navigation
refactor(dashboard): move chat runner helpers into chat_turn owners - #20755
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 Nothing to check. [DESIGN-REVIEWED] ba655d1 Description read[DESCRIPTION-READ] 8d5ddf702cdafc253dafab1fb7fefa20874ec34ba2cefd5b7b6a938e3bf69b94 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 The file-wide F401 exemption on the 18k-line What this change shipsInventory (7 items) — 7 justifiedIntent: shrink
[FIRST-PRINCIPLES-REVIEWED] ba655d1 Description read[DESCRIPTION-READ] 1fe5b3b70be695d7c29ec6f37b4067ce4e1853691f92a52f44a3ed9ed2206408 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: |
|
|
Move 82 top-level helpers of chat_runner.py, whole, into the chat_turn owner of each one's responsibility: five new owners (tool_rows, deny_chokepoints, turn_spec_hooks, crew_log_attribution, native_cards) and seven existing ones. compose binds every moved name on the runner, so chat_runner.<name> still resolves and a patch of it still reaches the moved code; names production imports from the runner keep a by-name import there. Guards that read a moved construct by path read its new home: the composition contract's owner set, homes map and the base kind and signature of every moved name, the security posture non-egress registry and log census, the transcript seam's fence, the bounded-steer spelling check, the config-dir guard's file list, the redact-before-bound scan and the two backend-identity ratchets. The runner is exempt from F401 because pyflakes reads only its own text; test_chat_runner_compose_binding.py checks every import, module level or inside a function, is read. Part of #20192
9861992 to
ba655d1
Compare
|
Rebased onto main e660192 (Master refresh; #20764 changed Upstream changes carried: #20764's empty-response ladder edit ( |
Sensitive change review
|
|
chenmingwei23
left a comment
There was a problem hiding this comment.
Approving: readiness gate passed, no conflicts, checks green.
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by a maintainer after reading the review lanes: every lane is clean on this head, and the automated triage held it only on a size, path, category or doc rule.
Problem / Motivation
Goal: Move the dashboard chat runner's top-level helpers into
chat_turn/owners by responsibility, sochat_runner.pysheds about 2,500 lines with no change to what a turn does.src/kiro_crew/dashboard/chat_runner.pyis about 20,900 lines; the campaign rule is that no hand-written file goes over 2,000 lines. About 3,300 of those lines are module-level helpers_run_chatcalls (deny rows, tool rows, native sub-agent cards, crew-log attribution, spec-hook notices, file-change snapshots, the stats footer, recovery cards), each already the responsibility of achat_turn/owner or of a new one. The previous PR madecomposediscover owners and bind their names on the runner, so a helper can now move without a re-export per name.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 the next PRs of the series._RECIPIENT_LOGGED(the account-identity gate, the cross-surface legs, the decisions hooks and the Jev routing) stay for the next PR: moving them in the same diff makes git's default diff show kept code as rewritten.What changed (motivation → approach → change)
Eighty-two top-level units (2,414 lines) move, whole, into twelve owners, five 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; names a production module imports from the runner (turn_stats_meta,refusal_card_text,unavailable_agent_messageand others) keep a by-name import there. The runner is exempt from F401 because pyflakes reads only its own text, andtest_chat_runner_compose_binding.pychecks every runner import is read in the runner or an owner.tool_rowsdeny_chokepoints_reject_attributed), the bounded in-band steerturn_spec_hookscrew_log_attributionnative_cardsturn_context,turn_stats,recovery,acp_recovery,model_fallback,file_changes,mcp_sessionRepository guards that read a moved construct by path read its new home: the composition contract's homes map and owner set,
security_posture's non-egress registry for the owners that now hold redactor calls and the gate-side log census, the transcript seam's publication fence, the bounded-steer spelling check, the config-dir guard's file list, the redact-before-bound scan (it reads thechat_turnpackage whole, with a floor of 7 redacting owners) and the two backend-identity ratchets (they read the runner's owners as part of the runner). The composition contract records each moved name's kind and signature from the base runner, and the import-read check covers imports inside the runner's functions. Docs that named a moved helper's home name its owner, and each extended owner's docstring names what it holds.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.Reader: src/kiro_crew/slack/gateway.py:turn_stats_meta -- cron --
from kiro_crew.dashboard.chat_runner import turn_stats_metaresolves through the runner's re-export ofchat_turn/turn_stats.py(test_cron_turn_stats_footer.py)Reader: src/kiro_crew/dashboard/chat_runner.py:refusal_card_text -- chat -- the runner imports it from
chat_turn/recovery.pyand_run_chatcalls it there (test_acp_structured_refusal.py)Reader: src/kiro_crew/dashboard/chat_runner.py:unavailable_agent_message -- chat -- the runner imports it from
chat_turn/turn_context.py(test_chat_runner_composition_contract.py::test_every_name_the_runner_bound_at_the_base_still_resolves)Tests
chat_runnerorchat_turn, plus the flake, wait, line-cap, base-names, security-posture and path-inventory guards: 19,081 passed (-n 3 --dist loadgroup); 5 more hit the 120 s test timeout under a host load average near 50, and all 12 tests of those 5 groups pass when run on their own.crew_log_attribution91%,deny_chokepoints94%,native_cards99%,tool_rows94%,turn_spec_hooks94%; the extended owners 92% to 100%).time.sleep(1)in each one's first coroutine is reported by the sync-io gate's own scanner (13 of 13).src/kiro_crew: clean. semgrep 1.78 (CI configs, baseline at the base): 0 findings after onenosemgrepon a moved warning that logs only the server's name; 0 parse errors. black, isort, flake8, comment-history, brand, docs-lint, agent-sdk, subprocess-encoding and sync-io gates: clean.Move audit:
chat_runner.py20,966 → 18,473 lines, 224 units, 100% moved, 0 changed. L36: every file's default and--minimaldiffs add the same lines. Line cap: 0 failures;chat_runner.py20,966 → 18,473, and its row in.github/file-line-cap-baseline.txtis lowered to 18,473 by hand.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
Edits to moved lines, each a gate's requirement: two moved comments restated in present tense (comment history), one
# nosemgrepwith its reason (the moved warning is new to semgrep because its file is), and# noqa: F811on two function-local imports in_run_chatwhose module-level twins stay for the owners.Follow-ups
Comments outside this PR's claim that still place a moved helper in
chat_runner.py. The dotted names resolve through the runner, so none of them is a behaviour defect:website/src/pages/chat/ToolCallLine.tsx(two comments),website/src/pages/chat/toolDiff.ts,website/src/test/ToolCallLine.test.tsx:_tool_metais inchat_turn/tool_rows.py.src/kiro_crew/acp/session_handle.py:_native_subagent_syncis inchat_turn/native_cards.py;src/kiro_crew/acp/client.py:_pinned_model_verdictis inchat_turn/model_fallback.py.src/kiro_crew/dashboard/state.py,dashboard/session_control.py,dashboard/handlers/usage.py,dashboard/cron_inject.py,deny_notice.py,security/denied_rules.py,security_posture.py(thedeny_notice.pyrow's comment),messaging/dispatch.py, and the auto_research and spec_builder backends.