Skip to content

test: split four oversized test files under the line cap - #21912

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t74-test-issue-radar-crew-routes
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t74-test-issue-radar-crew-routes

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring four test files that are over the 2,000-line cap down below 1,600 lines each, without changing a single test.

test/test_issue_radar_crew_routes.py (2,374 lines), test/test_mcp_gateway_rewriter_fingerprint.py (2,272),
test/test_chat_mode_security.py (2,269) and test/test_handlers_messaging_coverage.py (2,288) are each over the
repository's 2,000-line cap for hand-written files and are listed in .github/file-line-cap-baseline.txt.

Why it matters

A file over the cap must not grow: scripts/check_file_line_cap.py reports every change that takes one past its
baseline row, and AGENTS.md sends new code to a new module, so a feature PR that touches one of these suites either splits
it first or puts its tests somewhere less obvious. Each file is also too long to read as one subject. Part of the
campaign that brings every hand-written file under the cap.

Not a goal

  • Changing, renaming, re-parametrizing or de-flaking any test. Tests move with an unchanged AST (the issue-radar units
    are black-formatted in their new files), and pre-existing flaky shapes keep their behaviour (tracked separately, see
    Related Issues).
  • Reformatting kept code: the remainder of test_issue_radar_crew_routes.py stays as it is (it is in the black
    baseline).
  • Splitting any other file.

What changed (motivation → approach → change)

Each file is split between existing test units (at class and section boundaries where the file has them) into topic
files beside it, and the helpers that more than one of the resulting files reads go to a test/<stem>_helpers.py
module. The original path keeps one contiguous run of its own tests and still binds every name its importers read; the
two doc sentences whose cited behaviour moved are re-pointed (below).

Original (lines before -> after) Stays at the original path New files
test_issue_radar_crew_routes.py (2,374 -> 908) gates, GET /crews, create and names, crew read/update/retire, agent identity, the empty-queue sweep, agent-reachable routes test_issue_radar_crew_routes_work.py (798: PUT /crew/work, the skip index, one crew-log entry per write), test_issue_radar_crew_routes_controls.py (708: pause, stop, auto-approval withdrawal, settings, the absent human-wait endpoints, the issue comment, non-finite numbers), issue_radar_crew_routes_helpers.py (296: _CrewRouteCase, the slot, session and state fakes, the request builder)
test_mcp_gateway_rewriter_fingerprint.py (2,272 -> 1,196) the signature pin, the ambient-read tripwire, the invalidation tests, and the prune, not-cached and keep cases for a failed agent read or overlay write test_mcp_gateway_rewriter_fingerprint_keep.py (998: the keep on a settings read fault and its refusals, the content that stays cacheable, the legacy settings overlay, the fingerprint file, the transient-keep retention windows), mcp_gateway_rewriter_fingerprint_helpers.py (148: _CMD, _mk_tree, _rewrite, the fixtures)
test_chat_mode_security.py (2,269 -> 1,016) the app mode and approval routes, api_chat_mode's slot-scope contract test_chat_mode_security_send.py (1,203: an app's send onto a user slot), chat_mode_security_helpers.py (114: the app-token middleware and the app it mounts, the fixtures, _app_client, the app-control target table)
test_handlers_messaging_coverage.py (2,288 -> 1,145) the subagent lifecycle routes test_handlers_messaging_coverage_channels.py (1,111: the notification, Slack proxy, Teams and channel-config routes, the env writer, the token validators, the small helpers, the module guards), handlers_messaging_coverage_helpers.py (91: the request double, _run, _payload, _state)

Three helpers modules are under 150 lines; each exists because two files of its family read the same helpers, and a
*_helpers.py module lets both import them without either test file depending on the other (the test/*_helpers.py
convention).

The only lines that are not moved code: one closing paragraph in each remainder's docstring naming the new files; the
new files' docstrings; each file's import block, which imports the shared names from its helpers module (four of those
imports carry # noqa: F401 -- fixtures are requested by name); two helpers fixtures registered by name (@pytest.fixture(name="state") def state_fixture,
@pytest.fixture(name="rewrite_counter") def rewrite_counter_fixture, the test/meetings_helpers.py convention, so no
test parameter shadows an import); own-line markers on five moved shapes (below); and one comment in
_CrewRouteCase.setUp that said its patch isolates "every write in the module" and, in the helpers module, says it keeps
"every request's store writes in self.root" (comment only).

Backwards compatibility

Compatible: test-only. Every test keeps its name, class, parameters, markers and fixtures; the collected (class, name,
parameters) multiset is identical, and only the file part of a moved test's node id changes.

Removes nothing: no product code changes, and every name other test files import from these modules stays importable
from the original path. test_cli_spawn_run_agent_crew.py and test_crew_routing_and_delegation.py
(importorskip("test_handlers_messaging_coverage"): _mgr, _info, _Req, _state, _run, mod) and
test_subagent_continuable_template.py (_Req, _state) run unchanged and are not skipped.

Tests

No test is added or changed. Proof that nothing was lost, BASE 5699d4b00b against this head, collected with -n0:

BASE HEAD
collected node ids (4 origins vs 9 files) 692 692
(class, name, params) multiset equal equal
--fixtures-per-test (name, sorted fixtures) multiset 676 entries 676, equal
markers per test (iter_markers) 692 692, equal

Per file at HEAD: test_chat_mode_security.py 140 + _send 86; test_handlers_messaging_coverage.py 121 + _channels
145; test_issue_radar_crew_routes.py 57 + _work 31 + _controls 34; test_mcp_gateway_rewriter_fingerprint.py 48 +
_keep 30.

Move audit

bin/move_audit.py (AST), per origin; every changed unit is a module docstring or a fixture registered by name:

test/test_issue_radar_crew_routes.py: 2374 -> 908 lines; moved 98.35% (python-ast)
   changed: Expr [Expr] 36 lines
test/test_mcp_gateway_rewriter_fingerprint.py: 2272 -> 1196 lines; moved 98.99% (python-ast)
   changed: rewrite_counter [FunctionDef] 11 lines
   changed: Expr [Expr] 9 lines
test/test_chat_mode_security.py: 2269 -> 1016 lines; moved 98.46% (python-ast)
   changed: Expr [Expr] 20 lines
   changed: state [FunctionDef] 7 lines
test/test_handlers_messaging_coverage.py: 2288 -> 1145 lines; moved 99.34% (python-ast)
   changed: Expr [Expr] 14 lines

The moved units of test_issue_radar_crew_routes.py are black-formatted in their new homes (the new files are not in the
black baseline); their AST is unchanged.

Default diff and --minimal add the same lines in every file:

File default +/- --minimal +/-
.github/file-line-cap-baseline.txt 0/4 0/4
docs/architecture/app-platform-trust-model.md 1/1 1/1
docs/system-specs/modules/app-kit-platform.md 1/1 1/1
test/chat_mode_security_helpers.py 114/0 114/0
test/handlers_messaging_coverage_helpers.py 91/0 91/0
test/issue_radar_crew_routes_helpers.py 296/0 296/0
test/mcp_gateway_rewriter_fingerprint_helpers.py 148/0 148/0
test/test_chat_mode_security.py 14/1267 14/1267
test/test_chat_mode_security_send.py 1203/0 1203/0
test/test_handlers_messaging_coverage.py 13/1156 13/1156
test/test_handlers_messaging_coverage_channels.py 1111/0 1111/0
test/test_issue_radar_crew_routes.py 16/1482 16/1482
test/test_issue_radar_crew_routes_controls.py 708/0 708/0
test/test_issue_radar_crew_routes_work.py 798/0 798/0
test/test_mcp_gateway_rewriter_fingerprint.py 14/1090 14/1090
test/test_mcp_gateway_rewriter_fingerprint_keep.py 998/0 998/0
test/wait_discipline_baseline.txt 1/1 1/1

Pre-existing shapes moved with a marker

Moved verbatim, each with an own-line marker so the diff-scoped scans do not report the moved line as new code:

  • issue_radar_crew_routes_helpers._tick: time.sleep(0.004) that lets the crew log's millisecond clock move between
    two stamps (# flake-ok:, worded like the merged issue_radar_crew_store_helpers._tick marker).
  • mcp_gateway_rewriter_fingerprint_helpers._forward_declared_env_on and chat_mode_security_helpers._hermetic_home:
    module autouse fixtures on the shared monkeypatch (# nosemgrep: kirocrew.test-autouse-shared-monkeypatch, between
    the decorator and the def; no test of either family calls monkeypatch.undo()).
  • test_chat_mode_security_send.py, the two "slot closes / is relinked during the read" tests: resp = await send
    awaits the request task without a timeout after release.set() (# flake-ok:).

Rows, lists and citations

  • .github/file-line-cap-baseline.txt: the four targets' rows deleted.
  • test/wait_discipline_baseline.txt: 3 test_chat_mode_security.py -> 3 test_chat_mode_security_send.py (all three
    short waits move to the send part).
  • Citation edits: docs/architecture/app-platform-trust-model.md:128 "pinned by test_chat_mode_security" ->
    test_chat_mode_security_send; docs/system-specs/modules/app-kit-platform.md:1828 "test_chat_mode_security pins
    this" -> test_chat_mode_security_send. The behaviours those sentences name are tested in the send part.
  • Checked and left as is: mcp-gateway-daemon-lifecycle.md:160 (the ambient-read tripwire stays in
    test_mcp_gateway_rewriter_fingerprint.py), test_issue_radar_crew_mcp_tools.py:49 (TestAgentIdentityIsTheSession
    stays), test_issue_radar_crew_fabric.py:29 (names the routes-test pattern), and conftest.py:1237, an observed env
    leak between test_handlers_messaging_coverage.py and test_review_fixes.py; the credential-writing tests it refers
    to now live in test_handlers_messaging_coverage_channels.py.
  • .github/black-baseline.txt keeps test/test_issue_radar_crew_routes.py: the remainder is still not black-clean.
  • No logger, workflow path filter, expected-failure, symlink or collect-ignore list and no conftest module set names a
    target. CI path references: none.

Manual verification

N/A — test-only move; the local gate below runs the moved tests and every scanner that reads the test tree.

Local gate at this head (CI runs the full matrix):

  • The 9 split files plus the 3 importers, -n0, one process: 789 passed, 4 skipped (the Windows-only casing test,
    as at BASE: 688 passed, 4 skipped over the 4 origins).
  • The same 692 node ids shuffled (seed 20261017), -n0: 688 passed, 4 skipped.
  • The backend related set (local-gate.py --dry-run: 17 files; frontend 374 cross-surface files, not run: no file
    under website/ changes), every corpus gate leaf_test_scope.corpus_gates() reads (555 files), every
    source_corpus / repo_files( scanner (89) and the facade, patch-census and list guards: 603 files, -n 3, at the
    pre-rebase head: 41,200 passed, 132 skipped, 5 xfailed, 1 failed (test_history_bindings.py::test_the_member_set_is_the_frozen_inventory,
    the main red fixed by test(history): list the members #21108 added in the frozen inventory #21792, which this head is rebased onto). At this head (after the rebase and a
    docstring-only rewording): the 555 corpus gates, -n 3: 37,890 passed, 128 skipped, 5 xfailed; the scanners, the
    related set and the guards (113 files, -n 3): 8,022 passed, 21 skipped.
  • test_flake_pattern_ratchet.py -n0: 58 passed. mypy src/kiro_crew: no issues in 2,950 files.
  • isort (the CI command), black, flake8, the black/subprocess-encoding/agent-sdk/memory-seam/cwd-read ratchets,
    comment-history and brand against the merge-base, docs-lint, the line cap, testpaths, feature map, harness parity,
    focus cue, woke over the added lines, and the CI semgrep command with --baseline-commit (0 findings; with
    --disable-nosem exactly the two autouse sites): all clean.
  • Diff: 474,564 bytes (head 41f44925b9 on main a9898a0e21; the proofs above compare BASE 5699d4b00b, and no split file changed between the two).

Related Issues

Part of #20192

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

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

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 41f44925b9332dd45d25e29687657501d197622f 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 18, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 41f44925b9332dd45d25e29687657501d197622f ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Advisory — does not block merge.

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

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that the three importorskip("test_handlers_messaging_coverage") consumers actually collect and run at HEAD, not skip.

[DESIGN-REVIEWED] 41f4492

Description read

[DESCRIPTION-READ] da5603448db911526c4a359d5e39a890fa1cd9e82284b8016fe28cfc4a156de0

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 41f44925b9332dd45d25e29687657501d197622f — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 41f4492

Verdict parsed from the review's SHA-scoped output markers for commit 41f44925b9332dd45d25e29687657501d197622f.

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

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 41f44925b9332dd45d25e29687657501d197622f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 41f4492

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 18, 2026 14:05
@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 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.

Tier 1 auto-approve: test (17 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: moves tests out of four oversized test files into sibling modules and shared helpers; every removed test function is re-added, plus path-reference updates and baseline file edits. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/architecture/app-platform-trust-model.md, docs/system-specs/modules/app-kit-platform.md.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 18, 2026
Split test_issue_radar_crew_routes.py, test_mcp_gateway_rewriter_fingerprint.py,
test_chat_mode_security.py and test_handlers_messaging_coverage.py between
their test units into topic files beside them, with the helpers that more
than one file reads in a test/<stem>_helpers.py module. Every test moves with
an unchanged AST; the collected (class, name, params) multiset, the fixtures
per test and the markers are identical. Each original keeps one contiguous
run of its own tests and every name its importers read.

The four line-cap rows go, the chat mode wait-discipline row follows its
three waits to the send part, and two doc sentences name the send part that
now pins the behaviour they describe.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-t74-test-issue-radar-crew-routes branch from c27871a to 41f4492 Compare October 18, 2026 16:57
@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: 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 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.

Tier 1 auto-approve: test (17 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 four oversized test files into topic siblings plus shared helper modules, drops their line-cap baseline rows and updates the test-name references; no source file changes. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/architecture/app-platform-trust-model.md, docs/system-specs/modules/app-kit-platform.md.

@bolichen97
bolichen97 merged commit b26871d into main Oct 18, 2026
108 of 115 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-t74-test-issue-radar-crew-routes branch October 18, 2026 18:04
@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