Repository navigation
test: split three oversized test files by behaviour under test - #22279
Conversation
test_github_pull_request_monitor.py (4437 lines), test_job_sdk.py (4408) and test_hooks.py (4443) are each over the 2,000-line cap. Each keeps a contiguous prefix of its tests (1320, 1549 and 1509 lines) and the rest moves, byte for byte, into sibling files named for the behaviour under test; support units two files share move to github_pull_request_monitor_helpers.py and job_sdk_helpers.py. The three line-cap baseline rows go, the two Windows strict-xfail TestSafeReadFile node ids follow their tests, and the specs and comments that name where a moved test lives are re-pointed. Two moved docstrings change wording only: one drops a phrase the comment-history gate refuses, one drops positional references the move made false. Part of #20192
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that CI collects the same 726 tests across the 12 split files that the three originals had at BASE. What this change shipsInventory (8 items) — 8 justifiedIntent: bring three test files down under the 2,000-line cap that AGENTS.md mandates, without changing any test. FIX (an invariant violation).
[FIRST-PRINCIPLES-REVIEWED] 5c9a434 Description read[DESCRIPTION-READ] f9abc52e44ff68b6bdc578697593d199f981a6a1aaf402b690bee7330420f752 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that every remaining [DESIGN-REVIEWED] 5c9a434 Description read[DESCRIPTION-READ] 0a23e9c94ff762a47d8b7230fa0cb9895b1cb85c793244f1c6d2409f3f8e43b4 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Sensitive change review
|
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS TIGHTENING: none -- this diff makes no guard stricter. The only change under ADJUDICATED: 8 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: Candidates cover posix (6 rows) and windows (2 rows); none are tagged [SCOPE-REVIEWED] 5c9a434 |
|
|
Problem / Motivation
Goal: Bring three test files of 4,408 to 4,443 lines each down to at most 1,549 lines, so none of them exceeds the 2,000-line cap, without changing a single test.
test/test_github_pull_request_monitor.py(4437 lines),test/test_job_sdk.py(4408) andtest/test_hooks.py(4443) are each more than twice the 2,000-line cap thatscripts/check_file_line_cap.pyenforces, and each is listed in.github/file-line-cap-baseline.txt. A file that large is hard to navigate and review, and every PR that adds a test to one pushes it further past the cap.Why it matters
The maintainers' rule is that no hand-written file may exceed 2,000 lines. These three files break it today, and each new test makes the eventual split larger and harder to review. Splitting by the behaviour under test gives each file room to grow and makes each topic findable by file name.
Not a goal
What changed (motivation → approach → change)
Each file splits along its own test classes, test names and section banners, grouped by the behaviour under test. Each original keeps its module docstring, the imports its remaining code uses and a contiguous run of its first tests, so the moved tests leave the original as one contiguous deletion. Helpers and fixtures that more than one file of a family uses move to a non-test
*_helpers.pymodule, and every file imports them by name. A recipe tool did the move, reading each file at BASE, so it can be re-run after a rebase instead of hand-merged.test_github_pull_request_monitor.py(4437 → 1320)_readiness(816): the classification matrix, review-thread evidence, head revisions, terminal lifecycles;_errors_and_shadow(750): provider failure categories, the separate primary and check reads, the shadow probe's persistence;_batched_reads(1368): batched reads, the plural probe boundary, the REST fallback on a GraphQL rate limit, the comment digesttest_job_sdk.py(4408 → 1549)remove_all_asyncand its disable trace, the process-wide registry_invariants(1295): the async twins and the defensive invariants;_returns(1339): what a runner hands back, the interruption fields, malformed and unreadable records;_params(321): thestartparams channeltest_hooks.py(4443 → 1509)hook_gate_kwargsand its package scan, the raw-command gate, the shell-title tiers_shell_command(621):AcpEvent.shell_command, the hooks config,safe_read_file;_trusted_identity(1430): the spawn rung, the read-only proofs, governance under a trusted identity;_path_tier(961): the app-own MCP server auto-approve and the path tierHelper modules:
github_pull_request_monitor_helpers.py(354 lines) andjob_sdk_helpers.py(64; it holds only thesdkfixture and the two bounded waits, the units two or more job SDK files share). The hooks family needs none: every reader of its support units stays in the original.Glue, the only lines whose AST or comments change:
sdkfixture, which tests request by parameter, is re-declared@pytest.fixture(name="sdk") def sdk_fixture(thetest/meetings_helpers.pyconvention), so a parameter never shadows an import. Every job SDK file imports it with# noqa: F401, so each test keeps its BASE fixture set.TestSanitizeInvariant's class docstring reads "Four rounds of review each found" instead of "Four review rounds each found", because the comment-history gate refuses that phrase on an added line._probe_one's docstring, now in the helpers module, reads "The tests calling it are about" and "every caller's assertion" instead of "These tests are about" and "every assertion below". The banner above_MODE_BITS_BITEintest_job_sdk_returns.pyreads# Helpersinstead of# Helpers / fixtures(comment only).# nosemgrep:/# flake-ok:comments sit above the moved semgrep sites, sleeps and unbounded waits (listed under Move audit).Rows and citations:
.github/file-line-cap-baseline.txtare deleted (each file is under the cap at HEAD).test/windows-expected-failures.txt: the twoTestSafeReadFilenode ids nametest/test_hooks_shell_command.py, where those tests live.src/kiro_crew/hooks.py:843(comment)test/test_hooks.py->test/test_hooks_trusted_identity.py(test_host_read_only_builtins_map_only_to_read_scopes)docs/system-specs/modules/side.md:866test/test_hooks.py->test/test_hooks_trusted_identity.py(TestClassifierOnlyHostTrustedProof)docs/system-specs/modules/security.md:2195test_hooks.py::TestMutatingKindBeatsTheTitle->test_hooks_trusted_identity.py::TestMutatingKindBeatsTheTitle(re-wrapped over the same four lines)docs/system-specs/modules/security.md:1199"the identity-title cases intest/test_hooks.py" -> "... intest/test_hooks_path_tier.py"docs/system-specs/modules/app-kit-platform.md:3947test_job_sdk.pyreads the text between them; its two one-site counts ->test_job_sdk_returns.pyreads the text and holds the message-table count,test_job_sdk_invariants.pyholds the interruption-fields count (paragraph re-wrapped, one line longer)test/test_hooks_coverage.py:610(docstring)test_hooks.py test_allows_benign_symlink->test_hooks_shell_command.py test_allows_benign_symlinkBackwards compatibility
Compatible: test-only change. Every collected test keeps its class, name, parameters and markers (the multiset is identical before and after). No test module imports from these three originals; no production module, import path, patch target or CLI changes. The one production-file edit is a comment in
src/kiro_crew/hooks.py.Removes nothing: every test, fixture and helper still exists; each moved unit keeps an identical AST except the
sdkfixture (re-declared withname=, body unchanged) and the two docstrings named above.Tests
No test was added or rewritten. These proofs show the move lost nothing:
pytest --collect-onlyat BASE (3 originals) vs HEAD (12 test files)(class, name, params)multiset is identicalpytest --fixtures-per-testat BASE vs HEAD-n0-n 3-n0in three seeded shuffled orderstest_job_sdk_facade.py,test_hooks_composition_contract.py,test_hooks_handler_facade.py,test_windows_gap_list.py,test_hooks_coverage.py(re-pointed docstring), plustest_flake_pattern_ratchet.py,test_wait_discipline_ratchet.py,test_file_line_cap.py,test_source_pin_budget.py,-n0hooks.py(61 files), every corpus gatescripts/leaf_test_scope.pyderives (640), everysource_corpus/repo_files(scanner (142), the 53 test files that read ahooks.pyby path, plus the ratchets: 743 files,-n 3test_name_grant_facade[helper-binding],test_acp_frame_replaylive header,test_backend_cards_advertisedallowlist counts); twotest_installer_distro.pysignal tests time out under that load and pass at-n0(the whole file: 119 passed with the three above)--baseline-commitBASE over the 16 changed.pyfiles--disable-nosemover the new files exactly the 5 marked sites.woke.ymlover the added linesscripts/local-gate.py --base <BASE> --dry-run: backend related set 652 test files (13 in the diff, 46 name-matched, 593 referencing a changed file, nearly all through the barehookstoken of the comment edit insrc/kiro_crew/hooks.py; 61 without that file); frontend 1272 (this PR changes no frontend file). The 743-file run above replaces the whole local gate.Move audit
Every test function and class moved with an identical AST except
TestSanitizeInvariant, whose class docstring changes by one phrase.verify_test_split.py:rename-okfor the fixture; the only leftovers are_probe_oneandTestSanitizeInvariant(the two docstring edits).git diff BASE...HEADis about 828 KB.Moved semgrep sites, each with an own-line
# nosemgrep:directly above the site (and a# flake-ok:above that for a sleep): twotest-bare-monkeypatch-undosites (TestClaimAndWriteFailurePaths,TestThreadStartFailure) and threetest-sleep-as-barriersites (TestDisableIsTerminalForTheSDK's refused 30 s runner,TestStoppingWorkTheRunnerHandedBack's cancelled 3 s coroutine and its 50 ms pause). Pre-emptive own-line# flake-ok:markers sit above the 14 moved timing shapes: runners parked on their cancel event, the racing starts' barrier waits, the 30 s and 3 s sleeps and the 50 ms pause, five pool joins after the release, an await of a cancelled task, and a loop-tick floor. The test GitHub pull-request monitor and hooks families move no timing shape or semgrep site. Kept in the job SDK original: theTestRemoveAllsleep and every other site before the cut.AKIAIOSFODNN7EXAMPLE, AWS's documented example id, moves bare in the job SDK parts.Moved findings and their markers (BASE site = the line in the original):
test/test_job_sdk_invariants.py:466monkeypatch.undo()test/test_job_sdk.py:2016test/test_job_sdk_invariants.py:827sdk.register("work", lambda h: time.sleep(30))test/test_job_sdk.py:2374test/test_job_sdk_invariants.py:1289monkeypatch.undo()test/test_job_sdk.py:4108test/test_job_sdk_returns.py:1300await asyncio.sleep(3)test/test_job_sdk.py:3947test/test_job_sdk_returns.py:1310await asyncio.sleep(0.05)test/test_job_sdk.py:3955test/test_job_sdk_invariants.py:90h.cancelled.wait()test/test_job_sdk.py:1643test/test_job_sdk_invariants.py:384gate.wait()test/test_job_sdk.py:1936test/test_job_sdk_invariants.py:393gate.wait()test/test_job_sdk.py:1944test/test_job_sdk_invariants.py:576h.cancelled.wait()test/test_job_sdk.py:2125test/test_job_sdk_invariants.py:826sdk.register("work", lambda h: time.sleep(30))test/test_job_sdk.py:2374test/test_job_sdk_invariants.py:1266assert ticks > 5, ...test/test_job_sdk.py:4086test/test_job_sdk_returns.py:708pool.shutdown(wait=True)test/test_job_sdk.py:3361test/test_job_sdk_returns.py:1145pool.shutdown(wait=True)test/test_job_sdk.py:3797test/test_job_sdk_returns.py:1184pool.shutdown(wait=True)test/test_job_sdk.py:3835test/test_job_sdk_returns.py:1227pool.shutdown(wait=True)test/test_job_sdk.py:3877test/test_job_sdk_returns.py:1281pool.shutdown(wait=True)test/test_job_sdk.py:3930test/test_job_sdk_returns.py:1299await asyncio.sleep(3)test/test_job_sdk.py:3947test/test_job_sdk_returns.py:1309await asyncio.sleep(0.05)test/test_job_sdk.py:3955test/test_job_sdk_returns.py:1313return await tasktest/test_job_sdk.py:3957Diff alignment (L36): for every changed file,
git diff BASE -- <file>andgit diff --minimal BASE -- <file>give the same added/deleted counts: monitor 23/3140, job SDK 12/2871, hooks 14/2948, line-cap baseline 0/3, windows-expected-failures 2/2,app-kit-platform.md7/6,security.md5/5,side.md1/1,hooks.py1/1,test_hooks_coverage.py1/1, and each new file only added lines.Logger names (L25): no new module defines a logger; the job SDK parts keep reading
job_sdk.logger.nameand the literal"kiro_crew.apps.job_sdk", unchanged.CI path references
None: no workflow filter, explicit file list,
AUTOSDE.yamlglob or sensitive-change glob names these three files. The comment edit insrc/kiro_crew/hooks.pyfalls under the sensitive-change globs and the macOS on-demanddarwinfilter; the author's Sensitive change review comment covers it.Manual verification
N/A: unit coverage is sufficient. This is a test-only move, and the collected-test multiset plus the full run of every moved test prove it.
Related Issues
Part of #20192
Follow-up: #20383 (pre-existing shapes moved verbatim; de-flake there)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)