Skip to content

test: split test_dashboard_chat.py, part 4 of 6 - #20696

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t01-test-dashboard-chat-p4
Oct 15, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t01-test-dashboard-chat-p4

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Move the fourth region of test/test_dashboard_chat.py into topic test files, every test unchanged, as part 4 of the 6-PR series that brings the file under the 2,000-line cap.

After parts 1-3 (#20268, #20596, #20626), test/test_dashboard_chat.py still holds 7,900 lines, almost four times the 2,000-line cap the line-cap campaign sets for hand-written files (#20192). Every chat feature PR edits the same file, so its PRs conflict with each other and nobody can find the tests for one behaviour.

Why it matters

A test nobody can find gets duplicated or goes stale. One topic per file lets a chat PR touch only the files for the behaviour it changes, and keeps each file small enough for a reviewer to read in one pass.

Not a goal

  • Changing any test: names, parametrization, markers, bodies and assertions move as they are.
  • The rest of the file. PRs 5 and 6 move the TestRunChatTransientRetry topic classes, then BASE lines 24195-26845. Each PR is published after the one before it merges.
  • Changing any production code: the one src/ line touched is a comment.

What changed (motivation → approach → change)

Same recipe as parts 1-3: split by behaviour under test along the file's own classes and section banners, so git's default diff shows the move as deletions (this one: 239 KB). test_dashboard_chat.py goes from 7,900 to 5,365 lines.

This PR deletes lines 66-2668 of this PR's base test_dashboard_chat.py (the series base's TestAcpProcessDiedRecovery requeue tests and lines 19620-21612), except two kept tests at 184-231 and 431-451:

File Classes
test/test_dashboard_chat_provider_recovery.py (extended) TestAcpProcessDiedRecoveryRequeue: TestAcpProcessDiedRecovery's requeue, retry-budget, stop and counter tests
test/test_dashboard_chat_empty_response.py (new) TestEmptyResponseRetry (harness and first-retry tests), TestProductiveTurnNeverReplaysVerbatim, TestEmptyTurnDiagnostics
test/test_dashboard_chat_empty_response_ladder.py (new) TestEmptyResponseRetryLadder
test/test_dashboard_chat_prompt_prep.py (extended) TestExpandDollarSkills

TestAcpProcessDiedRecovery and TestEmptyResponseRetry are each larger than one class may be, so their later groups become topic classes. The topic classes reuse the source class's helpers through an underscore-aliased import (from test_dashboard_chat import TestAcpProcessDiedRecovery as _AcpDiedSuite and from test_dashboard_chat_empty_response import TestEmptyResponseRetry as _EmptyRetrySuite) and _x = _Suite._x lines that keep each member's runtime kind; the alias keeps pytest from collecting the borrowed class twice. TestAcpProcessDiedRecovery keeps its helpers and its two partial-text redaction tests in test_dashboard_chat.py, because their fake-key fixtures must not become added lines.

Backwards compatibility

Compatible: test-only, plus one comment. test_dashboard_chat.py keeps every name another test file imports from it (_provider_mock, TestRunChatTransientRetry, TestRunChatModelFallback). Node ids of moved tests change, because the file is part of the id; no expected-failure, symlink or collect-ignore list names any of them.

Removes nothing: every test moves, the 918 collected tests are the same set, and no production code changes.

Tests

  • Collection proof: pytest --co over test_dashboard_chat.py at the series base (30bb0b3) and over it plus the 28 sibling test files at this head gives the same multiset of (class, test, parameters): 918 and 918, with each topic class mapped back to its source class. 43 node ids change class name under the <Class><Topic> rule: TestAcpProcessDiedRecovery -> TestAcpProcessDiedRecoveryRequeue (22) and TestEmptyResponseRetry -> TestEmptyResponseRetryLadder (21); every other moved test keeps its class.
  • Move audit: see below. Test bodies are AST-identical; the flake-pattern ratchet passes at -n0.
  • The 29 files, the three importers and the guards that scan them (test_source_pin_budget.py, test_flake_pattern_ratchet.py, test_wait_discipline_ratchet.py, test_ci_surface_tests.py, test_leaf_test_scope.py): 1,213 passed at -n 3. Each new or extended file also passes alone at -n0.
  • CI's semgrep command (p/python p/typescript p/security-audit p/secrets p/owasp-top-ten semgrep/ --baseline-commit) over the changed files: clean. flake8, isort and black: clean on every touched file. mypy is not re-run: the only src/ change is a comment.

Move audit

test/test_dashboard_chat.py: 7900 -> 5365 lines; moved 97.31% (python-ast)
   changed: TestProductiveTurnNeverReplaysVerbatim [ClassDef] 193 lines
   changed: Expr [Expr] 7 lines

The changed units: the module docstring, which says what the file still holds, and one docstring sentence in TestProductiveTurnNeverReplaysVerbatim. It said the ladder tests sit "beside them"; it now names the class they live in, TestEmptyResponseRetryLadder.

git diff and git diff --minimal add the same lines for every changed file (test/test_dashboard_chat.py: 4 added, 2,539 deleted both ways), so no kept line shows as added.

Justified edits and citations

File Edit Why
test/test_dashboard_chat_empty_response.py TestProductiveTurnNeverReplaysVerbatim docstring: "the ladder tests beside them" -> "the ladder tests in TestEmptyResponseRetryLadder" the ladder tests now live in another class and file
test/test_dashboard_chat_provider_recovery.py an own-line # flake-ok: <reason> above the moved asyncio.wait(...) rendezvous in TestAcpProcessDiedRecoveryRequeue.test_output_reports_irreversible_consumption_before_turn_end the rendezvous has no bound and is pre-existing; flake-ok is the exemption the tests-are-deterministic review rule lists, and the test body stays AST-identical. De-flaking it is #20377
src/kiro_crew/dashboard/chat_utils.py the _STOP_END_TURN comment names test_dashboard_chat_empty_response.py as the file that pins the mirrored stop reasons TestEmptyTurnDiagnostics, which holds that pin, moved
.github/file-line-cap-baseline.txt test/test_dashboard_chat.py row lowered from 7900 to 5365 the file shrinks but stays over the cap until part 6

TestEmptyTurnDiagnostics moves with its "/home/someone/secret.txt" test literal verbatim: the same placeholder shape has passed internal-content-scan on merged PRs.

CI path references

None: no workflow path filter or explicit file list names test/test_dashboard_chat.py.

Manual verification

N/A — test-only move; the collection proof and the test runs above cover it.

Related Issues

Part of #20192

Follow-up: #20377 (pre-existing shapes moved verbatim; de-flake there)

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
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 15, 2026 07:21
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 392e127686c698c054598af2ba71a3de2c9200c5 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that the _x = _Suite._x aliases keep staticmethod and classmethod helpers bound the same way, so moved tests call them exactly as before.

[DESIGN-REVIEWED] 392e127

Description read

[DESCRIPTION-READ] 56dffa5c9421c124dfef191055cece27daac3b89697b0de2a6954c9ef5260ce4

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 392e127686c698c054598af2ba71a3de2c9200c5 — 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

Verify that CI collects the same 918 tests. The aliased _AcpDiedSuite/_EmptyRetrySuite imports are the only new coupling between test files.

What this change ships

Inventory (6 items) — 6 justified

Intent: shrink test_dashboard_chat.py toward the 2,000-line cap by moving tests into topic files, without changing any test. This is a FIX for the file-size cap mandated by AGENTS.md (#20192).

  1. Process-died requeue, retry-budget, stop and counter tests now live in test_dashboard_chat_provider_recovery.py — justified
  2. Empty-response retry, productive-turn and diagnostics tests now live in the new test_dashboard_chat_empty_response.py — justified
  3. Empty-response ladder tests now live in the new test_dashboard_chat_empty_response_ladder.py, under a topic class — justified
  4. TestExpandDollarSkills now lives in test_dashboard_chat_prompt_prep.py — justified
  5. Line-cap baseline row lowered from 7900 to 5365, and the chat_utils.py comment points at the pin's new file — justified
  6. A # flake-ok comment above the moved unbounded asyncio.wait rendezvous, which the ratchet requires, with the de-flake left to test(dashboard): chat tests use fixed sleeps as ordering barriers #20377 — justified

[FIRST-PRINCIPLES-REVIEWED] 392e127

Description read

[DESCRIPTION-READ] b81f1aea6d20c89c108bb322397e9a460cc73938f46f2f3ae05cd1a3bea5cc6e

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 392e127686c698c054598af2ba71a3de2c9200c5 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 392e127

Verdict parsed from the review's SHA-scoped output markers for commit 392e127686c698c054598af2ba71a3de2c9200c5.

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 15, 2026 07:35
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 392e127686c698c054598af2ba71a3de2c9200c5 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 392e127

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 15, 2026
TestAcpProcessDiedRecovery's requeue, retry-budget, stop and counter
tests become TestAcpProcessDiedRecoveryRequeue in
test_dashboard_chat_provider_recovery.py, which reuses the class's
helpers through an underscore-aliased import. Its two partial-text
redaction tests stay in test_dashboard_chat.py with the helpers: their
fake-key fixtures must not become added lines.

BASE lines 19620-21612 move as well: TestEmptyResponseRetry with
TestProductiveTurnNeverReplaysVerbatim and TestEmptyTurnDiagnostics to
test_dashboard_chat_empty_response.py, the ladder tests as
TestEmptyResponseRetryLadder to
test_dashboard_chat_empty_response_ladder.py, and TestExpandDollarSkills
to test_dashboard_chat_prompt_prep.py.

Test bodies move unchanged except TestProductiveTurnNeverReplaysVerbatim's
docstring, which names the ladder class it no longer sits beside. The
collected tests are the same set, and chat_utils.py's comment names the
new home of the stop-reason pin.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-t01-test-dashboard-chat-p4 branch from b12c7e0 to 392e127 Compare October 15, 2026 08:05
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: own-line flake-ok marker on a moved line; AST unchanged

  • span=fa9baaf5e82c Bound the self-unblocking consumption rendezvous

Rebutted as a defect of this PR: the unbounded asyncio.wait(..., FIRST_COMPLETED) rendezvous is pre-existing. It moved verbatim from test/test_dashboard_chat.py (series base 30bb0b3, line 19511).
This PR's goal is a byte-identical move of every test (move audit: every test unit AST-identical), so rewriting the moved test here would break that proof.
In 392e127 the line carries an own-line # flake-ok: <reason>, the tests-are-deterministic rule's own listed exemption. The test body is unchanged.
The de-flake (bound the wait, release the stream and await both tasks in finally) is tracked on #20377, which lists this site.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: the _AcpDiedSuite / _EmptyRetrySuite imports after parts 5 and 6

Checked against the built parts 5 and 6: neither moves the borrowed classes. TestAcpProcessDiedRecovery stays in test/test_dashboard_chat.py with its helpers and the two redaction tests, through the end of the series.
TestEmptyResponseRetry stays in test/test_dashboard_chat_empty_response.py; parts 5 and 6 move only TestRunChatTransientRetry topics and the region after 24195.
So from test_dashboard_chat import TestAcpProcessDiedRecovery as _AcpDiedSuite and from test_dashboard_chat_empty_response import TestEmptyResponseRetry as _EmptyRetrySuite keep resolving. Each part's collection proof, 918 = 918, would fail at import if one did not.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@bolichen97

bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the _x = _Suite._x aliases keep each helper's binding

Checked by loading both classes: the 5 borrowed helpers are 3 plain functions and 2 staticmethods, and there are no classmethods. Each alias has the same runtime kind as its source member, wrapping the same function object.
A plain-function helper is copied as _x = _Suite._x: class access returns the bare function, so it binds as a method on the topic class exactly as on the source. A staticmethod is copied as _x = staticmethod(_Suite._x).
So every moved test calls self._x(...) the same way it did at the base. The 43 moved tests in the two topic classes pass in their new files, run alone and in the full set.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: CI collects the same 918 tests; the aliased imports are the new coupling

Collection proof at this head: pytest --co over test_dashboard_chat.py at the series base (30bb0b3) and over it plus the 28 sibling files gives the same (class, test, parameters) multiset, 918 = 918. Each topic class maps back to its source class.
The _AcpDiedSuite / _EmptyRetrySuite names start with _, so pytest never collects the borrowed class a second time; TestRunChatModelFallback already reuses another class's helpers the same way.
The borrowed classes stay where they are through parts 5 and 6, so the coupling does not move. If an import broke, collection would fail outright, not lose tests silently.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 15, 2026

@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.

Tier 1 auto-approve: test (7 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: splits test_dashboard_chat.py into four files; the only non-test edits are a comment pointer and the line-cap baseline.

@bolichen97
bolichen97 merged commit 5b7b29f into main Oct 15, 2026
103 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-t01-test-dashboard-chat-p4 branch October 15, 2026 10:33
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 15, 2026
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.

2 participants