Skip to content

test: split four 3,500-line test files into topic parts - #21225

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t19-test-aws-control-app
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t19-test-aws-control-app

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring test_aws_control_app.py, test_webex_dispatch.py, test_agent_panel_routes.py and test_acp_deepseek_backend.py under the 2,000-line cap by moving their tests, unchanged, into topic files.

Each of these four test files was 3,486 to 3,587 lines long, well past the cap the repository now
enforces on hand-written files (scripts/check_file_line_cap.py). All four sat in
.github/file-line-cap-baseline.txt, and test_agent_panel_routes.py had already grown past its row.

Why it matters

A test file this long is hard to review and hard to own: one change touches a file thousands of lines
long, review lanes read huge diffs, and a new test has no obvious home. The cap only holds if the files
already over it are split, and every week they stay over, feature PRs keep adding to them.

Not a goal

  • Changing, renaming, re-parametrizing or de-flaking any test. Every test moves verbatim.
  • Changing any product code. The one src/ edit is a comment that names where a moved test lives.
  • Splitting any other oversized file.

What changed (motivation → approach → change)

Each file is over the cap, so each keeps its first sections and its other sections move, byte for byte,
into sibling test_<stem>_<topic>.py files named for what they test. The module-level fakes, builders
and fixtures that more than one file reads move to a <stem>_helpers.py module, which each file imports
by name. The split is a recipe that reads each file at the base commit, so it can be re-run after a
rebase rather than hand-merged.

File (lines before → after) New files (lines)
test/test_aws_control_app.py (3,522 → 1,390) aws_control_app_helpers.py (101), test_aws_control_app_shares.py (278), test_aws_control_app_hardening.py (1,137), test_aws_control_app_profiles.py (698)
test/test_webex_dispatch.py (3,521 → 1,459) webex_dispatch_helpers.py (398), test_webex_dispatch_commands.py (614), test_webex_dispatch_cards.py (451), test_webex_dispatch_spaces.py (291), test_webex_dispatch_queue.py (450)
test/test_agent_panel_routes.py (3,587 → 774) agent_panel_routes_helpers.py (281), test_agent_panel_routes_allocation.py (881), test_agent_panel_routes_publish_order.py (310), test_agent_panel_routes_dashboard.py (973), test_agent_panel_routes_page.py (508)
test/test_acp_deepseek_backend.py (3,486 → 1,149) acp_deepseek_backend_helpers.py (171), test_acp_deepseek_backend_enforcement.py (680), test_acp_deepseek_backend_session.py (299), test_acp_deepseek_backend_effort.py (505), test_acp_deepseek_backend_vault.py (793)

aws_control_app_helpers.py is under 150 lines because it is only the shared request builders, the
guarded-surface patches and the autouse snapshot reset that four files import. The four rows leave the
line-cap baseline, and the node ids, spec citations and comments that name a moved test follow it.

Backwards compatibility

Compatible: only test files move, and no other test imports any of the four.

Removes nothing: every test, fixture and helper still exists and runs; node-id lists and citations that
named a moved test now name its new file.

Tests

No test is added or changed; the proof is that the same tests run with the same fixtures.

  • Collected tests, pytest --co -qq over the 4 originals at the base and the 19 files at the head: 651
    and 651
    ; the multiset of (class, test name, params) is identical.
  • pytest --fixtures-per-test: for all 651 tests the ordered fixture list is identical at the base and
    at the head (autouse fixtures included).
  • All 19 files: 651 passed (-n 3). The related set plus every test that scans the test tree or reads
    source_corpus (126 files): 12,787 passed, 24 skipped, 0 failed. test_flake_pattern_ratchet.py
    (-n0): 58 passed.
  • scripts/local-gate.py --base <base> --dry-run: backend related 41 files (run, all green); frontend
    related 367 files (cross-surface set only: this diff changes no website/ file).
  • flake8, isort --check, black --check on every changed file; mypy src/kiro_crew; the
    comment-history, brand, harness-parity, line-cap, black, subprocess-encoding, feature-map, testpaths
    and docs-lint gates; semgrep (p/python, p/typescript, p/security-audit, p/secrets,
    p/owasp-top-ten, semgrep/, --baseline-commit <base>): all clean.

Move audit

test/test_aws_control_app.py: 3522 -> 1390 lines; moved 100.0% (python-ast)
test/test_webex_dispatch.py: 3521 -> 1459 lines; moved 100.0% (python-ast)
test/test_agent_panel_routes.py: 3587 -> 774 lines; moved 98.55% (python-ast)
   changed: _Sessions [ClassDef] 39 lines
   changed: vetted [FunctionDef] 8 lines
test/test_acp_deepseek_backend.py: 3486 -> 1149 lines; moved 99.57% (python-ast)
   changed: Expr [Expr] 13 lines
  • vetted: the fixture is re-declared @pytest.fixture(name="vetted") def vetted_fixture(...) in
    agent_panel_routes_helpers.py (the test/meetings_helpers.py convention), so the test parameter
    vetted does not shadow an import. The body is unchanged.
  • _Sessions: one docstring sentence said "the real allocation tests below"; in the helpers module
    it names test_agent_panel_routes_allocation.py, where those tests now are.
  • Expr: test_acp_deepseek_backend.py's module docstring gains one sentence naming where the moved
    pins live.

Every other unit is AST-identical. Comment lines added inside moved units:

  • three own-line # nosemgrep: kirocrew.test-autouse-shared-monkeypatch markers on the moved autouse
    fixtures (TestShares._isolated_store, _crew_log_on, _pinned_kiro_cli_version); no test that
    sees them calls monkeypatch.undo();
  • own-line # flake-ok: markers on the timing shapes that moved: _spin's bounded poll (2), the
    eight assert (await task)[0] awaits in TestApprovalCardPress and TestGroupSpaceRouting, and
    TestRound36Hardening's UTC wall-clock read.

Diff alignment

For every changed file, git diff and git diff --minimal add the same lines (blank lines counted):
test_aws_control_app.py 8/8, test_webex_dispatch.py 14/14, test_agent_panel_routes.py 11/11,
test_acp_deepseek_backend.py 7/7, and equal for every other file. git diff <base>...HEAD is about 871 KB (under the 900 KB cap).

Path references

  • .github/file-line-cap-baseline.txt: the four targets' rows are deleted.
  • test/requires-real-symlinks.txt: the two TestRound17Hardening / TestRound18Hardening node ids
    now name test/test_aws_control_app_hardening.py.
  • docs/system-specs/modules/aws-control.md: TestProfileUnregister and TestBootstrapReauthorizes
    cite test_aws_control_app_profiles.py; TestRound17Hardening cites test_aws_control_app_hardening.py.
  • Citation-only edits: test/test_aws_control_backup.py (module docstring),
    test/test_aws_control_routes.py (module docstring and a section comment), test/test_member_dashboard_routes.py (two
    docstrings), src/kiro_crew/dashboard/server_runtime/mcp_routes.py (one comment).
  • test/test_acp_deepseek_backend_effort.py:260 (a moved comment): agent_sdk/backends.py -> agent_sdk/backends_models.py, where refactor: split agent_sdk/backends.py into vocabulary owner modules #21616 moved the effort-level table it names.

CI path references

None: no workflow path filter or explicit file list names any of the four files.

Manual verification

N/A — test-only move; the collected-test and fixture comparisons above are the verification.

Related Issues

Part of #20192

Follow-up: #20383 (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 16, 2026 12:47
@bolichen97
bolichen97 requested a review from buluoray October 16, 2026 12:47
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 662bcd25b5161770017bb6b87c310cd2e92f249e 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 added the readiness: checking Automated validation is still running label Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 662bcd25b5161770017bb6b87c310cd2e92f249e — 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 (5 items) — 5 justified

Intent: bring four test files of about 3,500 lines each under the 2,000-line cap, moving every test unchanged. This is a FIX for .github/file-line-cap-baseline.txt overruns that AGENTS.md says to resolve.

  1. Four oversized test files are split into 15 topic files; the patch adds and removes the same number of def test_ lines (346 each) — justified
  2. Fakes, builders and fixtures used by more than one part move into four <stem>_helpers.py modules, matching the existing test/meetings_helpers.py convention — justified
  3. Four rows are deleted from the line-cap baseline, which only shrinks — justified
  4. The spec's test citations in aws-control.md and the two node ids in requires-real-symlinks.txt now name the new files — justified
  5. Comments and docstrings that name a moved test now name its new home: one comment in mcp_routes.py and docstrings in three test files. The mcp_routes.py comment's target, test_agent_panel_routes_allocation.py, does contain the deferred-route pins — justified

[FIRST-PRINCIPLES-REVIEWED] 662bcd2

Description read

[DESCRIPTION-READ] c151c86c2bb4dc81dcbba5a9a133fc6d6f093562b3c452487f545d1a0faa2f56

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 662bcd2

Description read

[DESCRIPTION-READ] 9ae8cbc890c15cb2be6f33db0687d2b895963398cc484a8b004f49bb8c780258

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 662bcd25b5161770017bb6b87c310cd2e92f249e — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 662bcd2

Verdict parsed from the review's SHA-scoped output markers for commit 662bcd25b5161770017bb6b87c310cd2e92f249e.

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

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 662bcd25b5161770017bb6b87c310cd2e92f249e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 662bcd2

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 16, 2026 13:05
@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 16, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-t19-test-aws-control-app branch from cde6a0e to 1ac51e3 Compare October 16, 2026 17:51
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention labels Oct 16, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-t19-test-aws-control-app branch from 1ac51e3 to 1fcc24c Compare October 17, 2026 05:48
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main ac63bc1411 (the PR had a merge conflict). Main changed test/test_agent_panel_routes.py in #20974 ("a crewmate's own page goes live on apply"), inside tests this PR moves, so those edits were ported to the tests' new homes byte for byte:

  • test_a_live_package_checks_the_write_against_its_own_model (replacing test_a_live_package_is_refused_while_the_display_still_reads_the_template) is now in test/test_agent_panel_routes_dashboard.py.
  • The _page_store stub change and the apply-route tests (test_apply_with_no_template_and_no_saved_page_is_a_refusal) are now in test/test_agent_panel_routes_page.py.

The four remainders and every other part are unchanged. The collected tests (651) and each test's fixture list still match main's originals. CI is re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 17, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-t19-test-aws-control-app branch from 1fcc24c to 0f08581 Compare October 17, 2026 12:21
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. #21458 deleted line-cap baseline rows next to this PR's four deletions, and #21077 edited test/test_aws_control_routes.py and docs/system-specs/modules/aws-control.md, two files this PR re-points citations in. The only conflict was .github/file-line-cap-baseline.txt: main's rows are kept and this PR's four rows stay removed. Every line #21077 added to those two files is still present. The rest of the patch is identical to the previous head. CI is re-running.

@github-actions github-actions Bot added 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 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 17, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-t19-test-aws-control-app branch from 0f08581 to 026e9a4 Compare October 17, 2026 17:55
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. #21604, #21487 and later merges deleted line-cap baseline rows next to this PR's four deletions, and that was the only conflict: main's rows are kept and this PR's four rows stay removed. One citation changed: the moved comment above _DEEPSEEK_LEVELS in test/test_acp_deepseek_backend_effort.py now names agent_sdk/backends_models.py, where #21616 moved the effort table. The rest of the patch is identical to the previous head. CI is re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 17, 2026
test_aws_control_app.py, test_webex_dispatch.py, test_agent_panel_routes.py
and test_acp_deepseek_backend.py were each over 3,400 lines, past the
2,000-line cap for hand-written files. Each now keeps its first sections
and moves the rest, verbatim, into sibling test_<stem>_<topic>.py files;
the module-level fakes, builders and fixtures more than one file reads
move to a <stem>_helpers.py module that every part imports by name.

The collected tests are the same 651 (class, name, params), each test
sees the same fixtures in the same order, and the four rows leave
.github/file-line-cap-baseline.txt. Node ids, a spec citation and test
docstrings that name a moved test follow it to its new file.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-t19-test-aws-control-app branch from 026e9a4 to 662bcd2 Compare October 18, 2026 07:40
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. #21191 ("stop resolving project-report for an unadopted crewmate") edited _shaped_dashboard in test/test_agent_panel_routes.py, a helper this PR moves to test/test_agent_panel_routes_dashboard.py. The edit is ported there byte for byte: the lines it changed match the dashboard part's diff exactly, and every other file is unchanged from the previous head. The 651 collected tests and each test's ordered fixture list still match main's originals. CI is re-running.

@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: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 18, 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.

Every review lane on the head is clean (only runner notices and PR Scope size warnings); held by the triage cron on size or path rules alone. Approved on the watch holder's request.

@bolichen97
bolichen97 merged commit 1016b01 into main Oct 18, 2026
106 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-t19-test-aws-control-app branch October 18, 2026 09:08
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 18, 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