Skip to content

refactor(dashboard): move the rest of the chat stream and its end into phases - #22682

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g01-chat-runner-p9
Oct 23, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g01-chat-runner-p9

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Move the rest of the dashboard chat turn's stream loop and the steps after it out of _run_chat into phase functions in the chat_turn owners, so chat_runner.py sheds another 2,800 lines with no change to what a turn does.

src/kiro_crew/dashboard/chat_runner.py is about 7,400 lines after the previous PR of this series, and most of it is still _run_chat. The campaign rule is that no hand-written file goes over 2,000 lines. What is left in _run_chat's try is the stream loop's remaining arms (steer, compaction, clear, agent switch, MCP, todo, sub-agent, and the stream's terminal) and the chain of steps that runs once the stream ends (stop recovery, the /compact answer, the answer settle, the turn-ending chain, the post-turn persist, the context usage, the Stop hook).

Why it matters

The runner cannot reach the cap while _run_chat holds those arms and steps. After this PR, _run_chat keeps only the text and thinking arms, the except arms and the finally, which the last PRs of this series move.

Not a goal

  • No change to what a turn does: each moved range's statements move verbatim; only their reach to the turn's state is re-plumbed.
  • The text and thinking stream arms, the except arms and the finally stay in _run_chat; later PRs of the series move them.
  • No new feature, guard or behaviour.

What changed (motivation → approach → change)

The remaining stream arms and the steps after the stream loop become phases: coroutines that take the turn (and, for a stream arm, the event), which _run_chat awaits where the statements ran. A phase reads the turn's values at its entry, copies each value it stores back onto the turn, and returns a _Flow member where the statements returned, broke or continued; its return type names exactly the flows its call site dispatches.

Phases Owner What they do
_on_steer_consumed; _on_compaction_status, _on_clear_status, _on_agent_switched, _on_todo_update steer_queue; session_events (new) a steer the session took, and what the session reports about itself mid-turn, its todo list included
the three _on_mcp_* arms; _on_subagent_list, _on_subagent_activity mcp_session; native_cards the stream's MCP arms; the session's native sub-agents
_on_complete, _turn_context_usage turn_stats the stream's terminal (usage row, turn metric, stop reason); the context usage and landed verdict
_turn_stop_recovery, _turn_persist_and_settle stop_recovery (new) the stop reasons the turn retries on its own; the end of a turn that reached the post-loop chain (footer, files, marker, save, the landed turn's retry budgets, consolidation)
_turn_compact_command slash_commands a /compact whose compaction status did not arrive during the stream
_turn_settle_answer segment_flush the terminal directive, the final segment, the refusal-fallback hop, the post-compaction continuation and the empty-response ladder
_turn_ending_chain turn_ending (new) the if/elif chain that decides how the turn ends: the leaked tool-call notice, the L1 infrastructure retry, the promise-only and false-blocker recoveries
_turn_stop_hook turn_spec_hooks the Stop hook, the continuations it and a tool refusal queue, the reply's linked-Slack and cross-surface legs

Fifteen _ChatTurn fields that never carry a value from one function to another are pruned: their turn.x = x copies go and the turn.x reads that the same function's own store dominates become bare (74 sites, table under Claim). The "Dashboard final message" redaction sink stays on dashboard/chat_runner.py: the pass it describes is _flush_segment -> _redact_segment (segment_flush) plus _persist_partial_reply (turn_reply_seams) for an interrupted reply, both on the runner's globals, while _turn_stop_hook's pass only builds the Stop hook's input after the reply is saved. Guards that read a moved construct by path read its new home, and moved comments, owner docstrings, the spec and the docs that placed these steps in _run_chat name the phase and its owner file.

Backwards compatibility

Compatible: every name chat_runner bound at the base is still bound, as the same object (the base-names contract test), and every patch target still reaches the code it reached: the phases run on the runner's globals through compose, as the other owners do.

Removes nothing: the PR moves statements of _run_chat into new private functions and drops per-turn fields no function reads; no public function, route, key or record is removed or renamed.

Tests

  • Phase fidelity: _run_chat at the head, with each of its 28 phase calls replaced by the phase's body and only the phase plumbing undone (entry aliases, copies and reloads, turn.x for x, the _Flow exits and their dispatch, the bare declarations), is the same syntax tree as _run_chat at the base with its ten earlier phases inlined. Its self-test turns red on each of five planted changes. The scratch twin of the reload rule finds no read that sees a value a phase replaced.
  • Return types and the await-free pins: each phase's annotation names exactly the flows _run_chat dispatches after its call, which mypy checks. The nine phases cut from blocks that never awaited (_on_mcp_server_initialized, _on_mcp_server_init_failure, _on_todo_update, _on_subagent_list, _on_subagent_activity, _on_compaction_status, _on_clear_status, _on_steer_consumed, _turn_context_usage) join the contract's _AWAIT_FREE_PHASES; an await added to any of them turns its node red.
  • Collected nodes over the 18 changed test files: 765 at the base, 775 at the head. The ten added are the nine await-free pins and one row of the turn-duration table, which is one row per persist site (chat_runner.py 2 -> chat_runner.py 1 + turn_stats.py 1). Each changed test file passes 5 runs at -n0 and one at -n 3; the flake-pattern ratchet passes.
  • Every guard that reads a construct by path has a mutation of that construct, in the file that holds it now, that turns it red: 249 mutants, every one killed. That is the earlier PRs' 216 re-aimed at where their constructs live, 28 for this PR's rows and pins (the config-dir guard, the non-egress rows, the redact floor, the owner set, the homes rows, the census, the await-free pins, the attribution flag's reach into the except arms), and 5 for the two dual-form re-keys, each form on its own. Nine controls stay green, among them the bare form of each dual-form re-key.
  • 905 test files that import, patch or read chat_runner, chat_turn or a moved name, plus the guards that scan them: 46,252 passed, 87 skipped, 5 xfailed, 0 failed (-n 3 --dist loadgroup); the 201 test files that read source text plus the changed tests: 10,372 passed, 5 skipped. The 8 cases of test_chat_runner_redact_across_tool_boundary.py that failed on main (main is red: test_chat_runner_redact_across_tool_boundary fails 8 cases since #22914 #23200) failed the same way, with the same messages, until fix(test): expect the whole reply on the linked-channel mirror #23201 fixed the test; on main with fix(test): expect the whole reply on the linked-channel mirror #23201 plus this patch, the file passes 47/47. CI runs the full suite.
  • Per-file coverage of each owner this PR adds or extends, over the 905 test files above: session_events 86%, stop_recovery 95%, turn_ending 81%, steer_queue 96%, mcp_session 92%, native_cards 98%, turn_stats 98%, slash_commands 98%, segment_flush 96%, turn_spec_hooks 92%; each clears the 80% floor on its own.
  • mypy over src/kiro_crew: clean. semgrep 1.78 (CI configs, baseline at the base): 0 findings over the 37 changed Python files. black, isort, flake8, comment-history, brand, docs-lint, feature-map, harness-parity, agent-sdk boundary, subprocess-encoding, sync-io, memory-store, loop-lock and line-cap gates: clean. Installed-mode smoke: a wheel built from the head imports the runner and the new owners from the installed copy under an isolated HOME, and the phases and _Flow resolve on chat_runner.

Manual verification

N/A — a structural move; the turn-level characterization suite, the phase-fidelity check, the reload rule and the mutation-proven guards are the verification.

Related Issues

Part of #20192

Follow-up: #21320 (the website comment cites listed under Claim).

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

Move audit

src/kiro_crew/dashboard/chat_runner.py: 7504 -> 4640 lines; moved 6.32% (python-ast)
   changed: _run_chat [AsyncFunctionDef] 6003 lines

_run_chat is the one changed unit: eighteen ranges leave it for phases, and the phase-fidelity check shows the rest of its body and every phase unchanged apart from the plumbing. Owners: session_events 396 (new), stop_recovery 552 (new), turn_ending 584 (new), steer_queue 649 -> 680, mcp_session 646 -> 711, native_cards 374 -> 434, turn_stats 347 -> 948, slash_commands 736 -> 874, segment_flush 836 -> 1,393, turn_spec_hooks 387 -> 746, turn_locals 359 -> 350. The cut carries #21266's crewmate DM reply notification (post_turn_reply) into _turn_persist_and_settle, and #20867's post-compaction continuation into its phases with the rest of their ranges: _compaction_text_offset's store in the compaction-status arm into _on_compaction_status, and _continuation_answer_text / _branch_answer_text into _turn_settle_answer, which reads the offset at entry (the field crosses into both phases, so _ChatTurn declares it); #22592's composed redact(...) calls move with the agent-switch, native sub-agent, /compact and refusal-card ranges. #23050's whole-reply Slack mirror moves with the persist range (turn._reply_mids_snapshot, into _turn_persist_and_settle) and the Stop-hook range (the _turn_full_reply_text gate, the final-segment OPTIONS and the warning, into _turn_stop_hook); its _turn_full_reply_text helper stays in the runner. #23111's whole-reply leg to a linked non-Slack channel (_cross_surface_reply_text(_turn_reply_segments(turn), ...)) moves with the Stop-hook range into _turn_stop_hook; _turn_reply_segments stays in the runner. #22914's single redaction window moves with its arms: _drop_wire_tail(turn) in the compaction-status, clear and agent-switch arms (session_events) and the /compact purge (slash_commands), and the held-run settle at the head of _turn_settle_answer.

L36: git diff --numstat with the default algorithm equals --minimal for all 54 files (chat_runner.py 93/2957, session_events.py 396/0, stop_recovery.py 552/0, turn_ending.py 584/0, turn_stats.py 603/2, segment_flush.py 558/1, turn_spec_hooks.py 360/1, security_posture.py 7/5, and the cite edits).

Claim

L30 (equal-strength re-keys, Master grant for this PR), each with a mutation red at the head:

  1. test/metrics/test_context_trace.py: the closer-reading unpack is taken from the function that builds the closer payload.
  2. test/test_file_change_snapshots.py: the clear arm is inspect.getsource(_on_clear_status); the import names _on_clear_status for _run_chat.
  3. test/test_post_compaction_continuation.py: the answer chain head at either indentation (phase or loop).
  4. test/test_recovery_l1_chat_runner.py: the clear window starts at async def _on_clear_status(; the history-debt predicate accepts not (?:turn\.)?_had_empty_response_verdict. Each form is proven on its own: a wrong verdict name in the turn. form and in the bare form both turn it red, and the bare form of the right name passes.
  5. test/test_reinjection_gate.py: the runner is read with its chat_turn owners as one module.
  6. test/test_runtime_death_is_a_process_event.py: the chat_turn owners count and clear as the runner's turn runtime.
  7. test/test_steer_requeue.py: the arm calls _on_steer_consumed, and the settle sits in that phase's head, measured past the phase's entry reads (x = turn.x), which are plumbing.
  8. test/test_turn_duration_recorded.py: the EVENT_COMPLETE persist row moves to chat_turn/turn_stats.py (chat_runner.py 2 -> 1).
  9. test/test_wake_judge_feedback_service.py: the nudge gate accepts turn._turn_landed (a flag a phase sets) as well as the bare name. Each form is proven on its own: a wrong flag in the turn. form and in the bare form both turn it red, so does dropping the flag, and the bare form of the right flag passes.

L29 (Master grant, comment-only cites, no AST change):

  • test/test_dashboard_chat_compaction.py:206: """"The deferred-compaction wait at the end of _run_chat is a kiro-cli-only protocol step. claude-agent-acp performs /compact synchronously inside session/prompt and never emits _kiro.dev/compaction/status, so the handler must skip wait_for_compaction for that backend or it sits blocked for 30 minutes and finally surfaces "Compaction timed out."" -> """"The deferred-compaction wait in _turn_compact_command (slash_commands) is a kiro-cli-only protocol step. claude-agent-acp performs /compact synchronously inside session/prompt and never emits _kiro.dev/compaction/status, so the handler must skip wait_for_compaction for that backend or it sits blocked for 30 minutes and finally surfaces "Compaction timed out.""
  • test/test_dashboard_chat_compaction.py:255: "patched at module scope: capabilities_of serves three call sites in # _run_chat and patching it would answer for all three." -> "patched at module scope: capabilities_of serves several call sites in the turn # (_on_complete, _turn_compact_command), and patching it would answer for all."
  • test/test_dashboard_chat_token_usage.py:20: "persist_token_record is called from _run_chat." -> "persist_token_record is called from _on_complete (chat_turn/turn_stats.py)."
  • test/test_acp_usage_cost.py:375: "The chat-runner persist gate (chat_runner.py) drops an all-zero row, so # the claude seam must produce a nonzero field for the row to be written." -> "The chat-runner persist gate (_on_complete in chat_turn/turn_stats.py) drops an # all-zero row, so the claude seam must produce a nonzero field for the row to be written."
  • test/test_fallback_row_attribution_8560.py:235: "It deliberately survives a landed turn (_run_chat's usage row --" -> "It deliberately survives a landed turn (_on_complete's usage row in turn_stats --"
  • test/test_slack_mirror_full_reply_23022.py:5: "The reply-publication block in chat_runner.py must" -> "The reply-publication block (_turn_stop_hook) must"
  • src/kiro_crew/dashboard/state_parts/slot_ladder.py:323: "dying mid-write still sees it), settled by _run_chat when the # consumed echo arrives (matched against the echo's snapshot text)," -> "dying mid-write still sees it), settled by _on_steer_consumed (steer_queue) # when the consumed echo arrives (matched against the echo's snapshot text),"

Docs cites that placed a moved step in _run_chat (SD27, Master review F1), each naming the phase and its owner file:

  • docs/system-specs/modules/session.md:5318: "Every recovery wait in _run_chat" -> "Every recovery wait of a dashboard turn", and the L1 gateway-capacity row names _turn_ending_chain.
  • docs/architecture/design-notes/session-slack-linking.md:134: the dashboard-to-Slack steps name _turn_open and _turn_dispatch_gates (steps 1-2), _on_tool_call (3), _turn_stop_hook (4) and _run_chat's finally (5).
  • docs/system-specs/modules/acp-client.md:2105 and :2274: the tool-stall continue-nudge and continuation -> _turn_stop_recovery (chat_turn/stop_recovery.py).
  • docs/system-specs/modules/slack-gateway.md:1191: "_run_chat() mirrors" -> "the dashboard turn (_run_chat() and its phases) mirrors".
  • The other docs edits (learn-cron-dashboard owner rows and paragraphs, metrics, subagent, platform-context, turn-stats-footer, agent-host-contract, feature-map README, the three RFCs and the tool-stall design note) re-point a cite the same way.

Rows for moved code (L4, Master grant): security_posture.py NON_EGRESS_REDACTION_MODULES +session_events, +slash_commands (its reason comment, still seven lines, names the agent-switch name and the /compact summary and failure-reason redactions); test_security_posture.py log-site census (chat_runner.py row gone, session_events.py 2); test_core_path_redact_before_bound.py floor (20 -> 22); test_no_config_dir_in_async.py (+turn_ending, +segment_flush, +session_events, +steer_queue, +stop_recovery, +turn_stats); the composition contract's owner set, homes and _AWAIT_FREE_PHASES; .github/docs-lint-baseline.txt (two line-ref rows deleted: the RFC cites are symbols now).

The final-message sink is not re-keyed (Master ruling): the sink text is "Full-text redaction pass over the assembled assistant turn before it is finalized", and that pass is _flush_segment -> _redact_segment in chat_turn/segment_flush.py, with _persist_partial_reply in chat_turn/turn_reply_seams.py for an interrupted reply. Both run on the runner's globals, so the row keeps its base key dashboard/chat_runner.py. The full-text pass in _turn_stop_hook only builds the Stop hook's input after the reply is saved; turn_spec_hooks stays in NON_EGRESS_REDACTION_MODULES as at the base.

Pruned _ChatTurn fields (Master ruling): a field that never carries a value from one function to another loses its turn.x = x copies, and each turn.x read the same function's own store dominates becomes the bare name; the stale-read check stays at 0. Eleven of them came from the previous PR's cut; the first four in the table are made by this cut's own stage and pruned with it, so the except arms read the bare names as at the base.

Field Sites (74 in all)
_own_fault _run_chat 3 copies, _run_chat 6 reads, _turn_stop_recovery 1 copy
_death_attempts _run_chat 1 copy, _run_chat 3 reads, _turn_stop_recovery 1 copy
_tcid _on_tool_result 1 copy, _run_chat 2 copies
_open_construct _on_permission_request 1 copy, _on_tool_call 1 copy, _run_chat 1 copy, _run_chat 2 reads
_requeue_text _run_chat 3 copies, _run_chat 3 reads, _turn_stop_recovery 1 copy
_requeue_payload _run_chat 3 copies, _run_chat 3 reads, _turn_stop_recovery 1 copy
m _on_tool_call_update 1 copy, _on_tool_result 1 copy, _run_chat 1 copy, _run_chat 5 reads
_row _on_tool_result 1 copy, _run_chat 1 copy, _run_chat 3 reads
cmd _on_permission_request 1 copy
approval_sent _on_permission_request 7 copies
validated_tool _on_permission_request 5 copies
_parsed_input _on_permission_request 6 copies
pre_hook_results _on_permission_request 3 copies
_wt_key _on_tool_call 1 copy
_held _on_tool_call_update 1 copy

References not edited (cost, L50; website/** is outside this PR, follow-up #21320): two comment cites in the frontend place the /compact failure row in chat_runner. Its new home is _turn_compact_command in src/kiro_crew/dashboard/chat_turn/slash_commands.py:

  • website/src/pages/chat/CompactionCard.tsx:69, website/src/test/CompactionCard.test.tsx:55.

Baselined growth (L56 addendum 1, 1b): src/kiro_crew/security_posture.py (line-cap baseline row) grows by the two NON_EGRESS_REDACTION_MODULES rows.

Logger: moved code keeps the runner's logger; the phases run on the runner's globals, so logger is kiro_crew.dashboard.chat_runner's (L25).

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 06ad7a9
  • What rule changed: no rule. security_posture.py's NON_EGRESS_REDACTION_MODULES gains dashboard/chat_turn/session_events.py and dashboard/chat_turn/slash_commands.py, and its reason comment names what they hold in the same seven lines. The redactor calls of _run_chat's agent-switch arm (the switched agent's name, _on_agent_switched) and of its /compact answer (the compaction summary and failure reason, _turn_compact_command) moved there verbatim as phases. The "Dashboard final message" sink keeps its base key dashboard/chat_runner.py: the pass it names is _flush_segment and _persist_partial_reply, which run on the runner's globals.
  • Before -> after (what was allowed/blocked, now): before, those statements ran inside _run_chat in chat_runner.py; after, the same statements in the same order run in the phases on the runner's globals (compose), awaited by _run_chat where they ran. Nothing is allowed or blocked differently, and no sink, egress path or classification changes; the file grows only by the two rows.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the posture drift guard would miscount a redactor site and fail its test; the redaction itself is the moved code, unchanged, so the agent-switch row and the /compact summary are scrubbed exactly as they were.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted is green on this head and turns red when either row is removed (mutants PR9-non-egress-session-events, -slash-commands). The redact-before-bound floor turns red when session_events stops redacting, and the log-site census turns red when its gate-side site goes. The phase-fidelity audit shows _run_chat, with every phase put back inline, identical to the base after undoing only the phase plumbing.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 902 test files that import, patch or read chat_runner, chat_turn or a moved name passed (46,188 passed, 0 failed); the 191 source-reading and changed test files passed (10,979 passed); mypy over src/kiro_crew/ clean.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or caller changes; every chat_runner.<name> still resolves to the same object (test_chat_runner_base_surface.py) and the registry only gains rows.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py, test_no_config_dir_in_async.py, the runner composition contract and turn plumbing tests.
  • How to undo: revert this PR's single commit; the statements return to _run_chat with the registry rows removed in the same revert.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 21, 2026 06:38
@bolichen97
bolichen97 requested a review from CrysisDeu October 21, 2026 06:38
@github-actions

github-actions Bot commented Oct 21, 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 480bf3a.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 480bf3a73e6ac3c38c32097f889d06d2d90fa091 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

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

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 480bf3a73e6ac3c38c32097f889d06d2d90fa091 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. This is a verbatim move into phases, following the earlier PRs of the series. The private _ChatTurn fields it drops have no readers left in src/ or test/.

Notes

  • The description is cut off at 8,000 bytes, but its ## Backwards compatibility section ends before the cut and is judged on its text. I grepped the tree for turn.<field> reads of the eleven removed _ChatTurn fields and found none.

[DESIGN-REVIEWED] 480bf3a

Description read

[DESCRIPTION-READ] 6115492bbe5d7df8471857fee0e0e9f8c02f7f5cd482a59856f491055a1e388c

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 480bf3a73e6ac3c38c32097f889d06d2d90fa091 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks: this is a behaviour-neutral split that the documented 2,000-line file cap requires. Every item either moves code to a new module or follows a moved construct to its new path.

What this change ships

Inventory (6 items) — 6 justified

Intent: shrink chat_runner.py toward the 2,000-line cap by moving _run_chat's remaining stream arms and its after-stream steps into chat_turn phase owners, with no change to what a turn does. This is a refactor, neither a fix nor an addition.

  1. The steer, compaction, clear, agent-switch, todo, MCP and sub-agent stream arms, and the stream's terminal, now run as phases in chat_turn owners — justified
  2. The after-stream chain (stop recovery, /compact, answer settle, turn ending, persist, context usage, Stop hook) now runs as phases — justified
  3. Three new owner modules hold them (session_events, stop_recovery, turn_ending) — justified
  4. Fifteen _ChatTurn fields that no other function reads are removed — justified
  5. Guards, the security-posture rows, specs, RFC text and docs that cite a moved construct now point at its new home — justified
  6. Nine phases join the existing _AWAIT_FREE_PHASES contract, and the turn-duration table gets one row per persist site — justified

[FIRST-PRINCIPLES-REVIEWED] 480bf3a

Description read

[DESCRIPTION-READ] 838f9b53454207d7e45b745d8f4ab78a11759de578f539a897a219c1e1b9bdb1

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 480bf3a73e6ac3c38c32097f889d06d2d90fa091 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 480bf3a

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

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 480bf3a73e6ac3c38c32097f889d06d2d90fa091 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 480bf3a

Verdict parsed from the review's SHA-scoped output markers for commit 480bf3a73e6ac3c38c32097f889d06d2d90fa091.

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

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Verbatim structural move along the existing phase seam (Design PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. The phase-fidelity audit backs the "verbatim" reading: _run_chat at this head, with every phase inlined and only the plumbing undone, is the same syntax tree as at the base. The 250 mutants pin each moved construct at its new home.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Behaviour-preserving move required by the line cap (First Principles PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. No default, capability or user-visible behaviour changes. The except arms, the text and thinking arms and the finally stay in _run_chat for the series' remaining PRs, as the Not-a-goal section says.

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

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 5fed709
  • What rule changed: no rule. security_posture.py's NON_EGRESS_REDACTION_MODULES gains dashboard/chat_turn/session_events.py and dashboard/chat_turn/slash_commands.py, and its reason comment names what they hold in the same seven lines. The redactor calls of _run_chat's agent-switch arm (the switched agent's name, _on_agent_switched) and of its /compact answer (the compaction summary and failure reason, _turn_compact_command) moved there verbatim as phases. The "Dashboard final message" sink keeps its base key dashboard/chat_runner.py: the pass it names is _flush_segment and _persist_partial_reply, which run on the runner's globals.
  • Before -> after (what was allowed/blocked, now): before, those statements ran inside _run_chat in chat_runner.py; after, the same statements in the same order run in the phases on the runner's globals (compose), awaited by _run_chat where they ran. Nothing is allowed or blocked differently, and no sink, egress path or classification changes; the file grows only by the two rows.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the posture drift guard would miscount a redactor site and fail its test; the redaction itself is the moved code, unchanged, so the agent-switch row and the /compact summary are scrubbed exactly as they were.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted is green on this head and turns red when either row is removed (mutants PR9-non-egress-session-events, -slash-commands). The redact-before-bound floor turns red when session_events stops redacting, and the log-site census turns red when its gate-side site goes. The phase-fidelity audit shows _run_chat, with every phase put back inline, identical to the base after undoing only the phase plumbing.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 905 test files that import, patch or read chat_runner, chat_turn or a moved name passed (46,252 passed, 0 failed); the 194 source-reading and changed test files passed (11,018 passed); mypy over src/kiro_crew/ clean.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or caller changes; every chat_runner.<name> still resolves to the same object (test_chat_runner_base_surface.py) and the registry only gains rows.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py, test_no_config_dir_in_async.py, the runner composition contract and turn plumbing tests.
  • How to undo: revert this PR's single commit; the statements return to _run_chat with the registry rows removed in the same revert.

@bolichen97
bolichen97 force-pushed the refactor/linecap-g01-chat-runner-p9 branch from 06ad7a9 to 5fed709 Compare October 21, 2026 09:05
@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 21, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Verbatim move along the series' phase seam; no reader of the pruned fields (Design PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. The stale-read check finds 0 bare reads of a phase-written name. The fifteen pruned fields have no turn.<name> left anywhere (prune_fields.py asserts it). With every phase inlined, _run_chat is the same syntax tree as at the base.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Structural move the line cap requires; changed pins re-aimed, none reversed (First Principles PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. Each re-aimed pin has a mutation, in the file that now holds its construct, that turns it red. The dual-form re-keys are proven per form, each with a green control.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 21, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Hold at 5fed709: the branch conflicts with main.

On this head the move looks faithful. The removed statements reappear in the phases apart from the plumbing and the 15 pruned fields, and none of those fields has a reader. The owners run on the runner's globals through compose. The security_posture change only adds rows (security_posture.py#L2351). Every AI lane passes and CI is green. A rebase is a new head and needs a new review; this is not a pre-approval of it.

— crew-pr-reviewer (r117)

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 34c6577
  • What rule changed: no rule. security_posture.py's NON_EGRESS_REDACTION_MODULES gains dashboard/chat_turn/session_events.py and dashboard/chat_turn/slash_commands.py, and its reason comment names what they hold in the same seven lines. The redactor calls of _run_chat's agent-switch arm (the switched agent's name, _on_agent_switched) and of its /compact answer (the compaction summary and failure reason, _turn_compact_command) moved there verbatim as phases. The "Dashboard final message" sink keeps its base key dashboard/chat_runner.py: the pass it names is _flush_segment and _persist_partial_reply, which run on the runner's globals.
  • Before -> after (what was allowed/blocked, now): before, those statements ran inside _run_chat in chat_runner.py; after, the same statements in the same order run in the phases on the runner's globals (compose), awaited by _run_chat where they ran. Nothing is allowed or blocked differently, and no sink, egress path or classification changes; the file grows only by the two rows.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the posture drift guard would miscount a redactor site and fail its test; the redaction itself is the moved code, unchanged, so the agent-switch row and the /compact summary are scrubbed exactly as they were.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted is green on this head and turns red when either row is removed (mutants PR9-non-egress-session-events, -slash-commands). The redact-before-bound floor turns red when session_events stops redacting, and the log-site census turns red when its gate-side site goes. The phase-fidelity audit shows _run_chat, with every phase put back inline, identical to the base after undoing only the phase plumbing.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 905 test files that import, patch or read chat_runner, chat_turn or a moved name passed (46,252 passed, 0 failed); the 194 source-reading and changed test files passed (11,018 passed); mypy over src/kiro_crew/ clean.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or caller changes; every chat_runner.<name> still resolves to the same object (test_chat_runner_base_surface.py) and the registry only gains rows.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py, test_no_config_dir_in_async.py, the runner composition contract and turn plumbing tests.
  • How to undo: revert this PR's single commit; the statements return to _run_chat with the registry rows removed in the same revert.

@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 22, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Statement-for-statement move into the chat_turn phase owners; pruned fields unread (Design PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. This head carries the re-cut with #23050's whole-reply Slack mirror ported into _turn_persist_and_settle and _turn_stop_hook. With every phase inlined, _run_chat matches the base apart from the plumbing.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Verbatim move required by the line cap; guards re-pointed, none reversed (First Principles PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. Each re-pointed guard has a mutation in its construct's new home that turns it red.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 22, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: bbd0747
  • What rule changed: no rule. security_posture.py's NON_EGRESS_REDACTION_MODULES gains dashboard/chat_turn/session_events.py and dashboard/chat_turn/slash_commands.py, and its reason comment names what they hold in the same seven lines. The redactor calls of _run_chat's agent-switch arm (the switched agent's name, _on_agent_switched) and of its /compact answer (the compaction summary and failure reason, _turn_compact_command) moved there verbatim as phases. The "Dashboard final message" sink keeps its base key dashboard/chat_runner.py: the pass it names is _flush_segment and _persist_partial_reply, which run on the runner's globals.
  • Before -> after (what was allowed/blocked, now): before, those statements ran inside _run_chat in chat_runner.py; after, the same statements in the same order run in the phases on the runner's globals (compose), awaited by _run_chat where they ran. Nothing is allowed or blocked differently, and no sink, egress path or classification changes; the file grows only by the two rows.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the posture drift guard would miscount a redactor site and fail its test; the redaction itself is the moved code, unchanged, so the agent-switch row and the /compact summary are scrubbed exactly as they were.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted is green on this head and turns red when either row is removed (mutants PR9-non-egress-session-events, -slash-commands). The redact-before-bound floor turns red when session_events stops redacting, and the log-site census turns red when its gate-side site goes. The phase-fidelity audit shows _run_chat, with every phase put back inline, identical to the base after undoing only the phase plumbing.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 905 test files that import, patch or read chat_runner, chat_turn or a moved name passed (46,252 passed, 0 failed); the 194 source-reading and changed test files passed (11,018 passed); mypy over src/kiro_crew/ clean.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or caller changes; every chat_runner.<name> still resolves to the same object (test_chat_runner_base_surface.py) and the registry only gains rows.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py, test_no_config_dir_in_async.py, the runner composition contract and turn plumbing tests.
  • How to undo: revert this PR's single commit; the statements return to _run_chat with the registry rows removed in the same revert.

@bolichen97
bolichen97 force-pushed the refactor/linecap-g01-chat-runner-p9 branch from fb8b9ed to bbd0747 Compare October 22, 2026 17:59
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 22, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Statement-preserving structural move; no new surface; pruned fields unread (Design PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. This head adds #23111's whole-reply channel-neutral leg to _turn_stop_hook with the rest of its range. Its helpers stay in the runner, unchanged from main.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Code move required by the line cap; rewritten test lines re-point, none pins the opposite (First Principles PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. Each rewritten pin has a mutation in its construct's new home that turns it red, and the dual-form re-keys each have a green control.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 22, 2026
…o phases

The stream loop's remaining arms and the steps after the loop become
phases that _run_chat awaits where the statements ran: the steer,
session-event, MCP, todo and sub-agent arms and the stream's terminal
(_on_*), then the stop recovery, the /compact answer, the answer
settle, the turn-ending chain, the post-turn persist, the context usage
and the Stop hook (_turn_*), each in the chat_turn owner of its
responsibility; session_events, stop_recovery and turn_ending are new.
A phase's return type names exactly the flows its call site dispatches.
The statements move unchanged apart from that plumbing.

Fifteen per-turn fields that never carry a value from one function to
another are pruned: their copies go and the reads their own function's
store dominates are bare again.

The guards that read a moved construct by path read its new home, the
await-free phases join the contract's pins, and moved comments, owner
docstrings, the spec and the docs that placed these steps in
chat_runner.py name the phase and its owner file. The final-message
redaction sink stays on the runner, whose globals the passes it names
run on.

Part of #20192
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 480bf3a
  • What rule changed: no rule. security_posture.py's NON_EGRESS_REDACTION_MODULES gains dashboard/chat_turn/session_events.py and dashboard/chat_turn/slash_commands.py, and its reason comment names what they hold in the same seven lines. The redactor calls of _run_chat's agent-switch arm (the switched agent's name, _on_agent_switched) and of its /compact answer (the compaction summary and failure reason, _turn_compact_command) moved there verbatim as phases. The "Dashboard final message" sink keeps its base key dashboard/chat_runner.py: the pass it names is _flush_segment and _persist_partial_reply, which run on the runner's globals.
  • Before -> after (what was allowed/blocked, now): before, those statements ran inside _run_chat in chat_runner.py; after, the same statements in the same order run in the phases on the runner's globals (compose), awaited by _run_chat where they ran. Nothing is allowed or blocked differently, and no sink, egress path or classification changes; the file grows only by the two rows.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the posture drift guard would miscount a redactor site and fail its test; the redaction itself is the moved code, unchanged, so the agent-switch row and the /compact summary are scrubbed exactly as they were.
  • Evidence checked (which sandbox result proves it): test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted is green on this head and turns red when either row is removed (mutants PR9-non-egress-session-events, -slash-commands). The redact-before-bound floor turns red when session_events stops redacting, and the log-site census turns red when its gate-side site goes. The phase-fidelity audit shows _run_chat, with every phase put back inline, identical to the base after undoing only the phase plumbing.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 905 test files that import, patch or read chat_runner, chat_turn or a moved name passed (46,252 passed, 0 failed); the 194 source-reading and changed test files passed (11,018 passed); mypy over src/kiro_crew/ clean.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or caller changes; every chat_runner.<name> still resolves to the same object (test_chat_runner_base_surface.py) and the registry only gains rows.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py, test_no_config_dir_in_async.py, the runner composition contract and turn plumbing tests.
  • How to undo: revert this PR's single commit; the statements return to _run_chat with the registry rows removed in the same revert.

@bolichen97
bolichen97 force-pushed the refactor/linecap-g01-chat-runner-p9 branch from bbd0747 to 480bf3a Compare October 22, 2026 22:21
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Oct 22, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Verbatim move into phases; dropped _ChatTurn fields have no readers (Design PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. This head ports #22914's held-run redaction window into its new homes: the moved compaction, clear and agent-switch arms, and _turn_settle_answer, which now opens at the held-run flush. The new _held_runs field stays on _ChatTurn.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Behaviour-neutral split required by the line cap; every item follows a moved construct (First Principles PASS punchline)

Outcome: acknowledged; no change. The punchline asks nothing. With every phase inlined, _run_chat at this head matches the base apart from the phase plumbing, and each re-pointed guard has a mutation in its construct's new home that turns it red.

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by Crew Captain on head 480bf3a: Design and First Principles PASS on this head, UX skipped, all checks green, no merge conflict.

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.

3 participants