Repository navigation
test: split four oversized test files by the behaviour they cover - #21397
Conversation
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 689d4d6 Description read[DESCRIPTION-READ] d446acd1309d38c501ed98ade70813068e3f42214727855c3633208d1cc0aa47 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: |
test_subagent_coverage.py, test_voice_reply.py, test_trusted_apps_api.py and test_onboarding_import_coverage.py were each over 3,100 lines, past the 2,000-line cap. Each keeps a contiguous run of its classes and hands the rest to topic parts named after the behaviour under test; helpers more than one part uses move to a non-test *_helpers.py module that every part imports by name. Every test moves with an identical AST: the collected (class, name, params) multiset, the markers and the fixtures of all 950 tests are the same before and after. The glue is the module docstrings, three fixtures re-declared with name= so a parameter never shadows an import, and own-line flake-ok / nosemgrep comments above pre-existing timing shapes and semgrep findings that move to a new path. The four line-cap baseline rows go, the one wait-discipline row follows its wait to test_subagent_coverage_live_runs.py, and one docstring in test_monitor_arming_preference.py names the membership pin's new file. Part of #20192
83da349 to
689d4d6
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by a maintainer. The triage automation held this on a size, path, category or move-check rule only; every review lane is clean.
Problem / Motivation
Goal: Bring
test_subagent_coverage.py,test_voice_reply.py,test_trusted_apps_api.pyandtest_onboarding_import_coverage.pyfrom over 3,100 lines each to at most 1,600, without changing a single test.Each of the four files is more than half again over the 2,000-line cap the line-cap campaign enforces (3,158 / 3,145 / 3,141 / 3,135 lines). A file that large is slow to navigate and review, and every test added to it makes the eventual split bigger.
Why it matters
The maintainers' rule is that no hand-written file may exceed 2,000 lines, and all four break it. Their topics are already separate (a subagent's bookkeeping vs what happens when it finishes vs steering a live run; text preparation vs each TTS provider's synthesis vs the pipeline around it; the trust endpoints vs registry grants vs a withdrawal that fails part-way; parsers vs writers vs per-source readers), so a reader looking for one topic scrolls past the others. Splitting along those seams makes each topic findable by file name and leaves each file room to grow.
Not a goal
What changed (motivation → approach → change)
Each file keeps one contiguous run of its own classes and hands the rest to topic parts, along its existing section banners. Helpers more than one part uses move to a non-test
*_helpers.pymodule that every part imports by name; a helper only one part uses moves with that part. A recipe tool did the move from BASE, so it can be re-run after a rebase instead of hand-merged.test_subagent_coverage.py(3,158 → 1,225)_completion(1,424): the injection-failure notice, continuable conversations, wave and batch bookkeeping with the done-but-unreported hold, digest holds, announce;_live_runs(557): session sharing, intentional cancel, steer and follow-up, the reaper's clockstest_voice_reply.py(3,145 → 944)_synthesis(1,464):_synthesize_system/_piper/_polly, including temp-file ownership under cancellation;_pipeline(758): the dispatcher, Slack upload, end-to-end and streaming replies, text-type detection,stitch_mp3scleanuptest_trusted_apps_api.py(3,141 → 1,570)_registry(409): sections 5-6, registry-name grants and what the snapshot reports;_withdrawal(1,041): uninstall, overlay-owned grants, failed teardowns, the blanket switch, the lifecycle locktest_onboarding_import_coverage.py(3,135 → 1,087)_writers(967): every writer's conflict / rollback branch and theapply_importfailure paths;_sources(1,112): SQLite sidecars, Codex, Hermes, Lineage, OpenClaw, root discovery, skill packagingHelper modules (below 150 lines because they hold only what two or more parts share):
subagent_coverage_helpers.py(41),voice_reply_helpers.py(154),trusted_apps_api_helpers.py(131),onboarding_import_coverage_helpers.py(50).Glue, the only lines whose AST or comments change:
@pytest.fixture(name="x") def x_fixture(...), bodies unchanged, so a parameter never shadows an import:home,mock_sel,_polly_consented. The autouse_no_argv_prefixerskeeps its name and is imported into every voice module;pytestmark = usefixtures("isolate_mcp_host_paths")and the three-line_api()are copied into both onboarding parts._api()returns thekiro_crew.onboarding_importfacade and is a per-file facade accessor, kept verbatim in each part the guard scans:test_onboarding_import_refactor_contract.pyresolves, file by file, which local names hold the facade before it reads that file's patches.# nosemgrep: <rule> -- <reason>directly above it (between decorator and def for the autouse fixtures), code unchanged. The moved timing shapes (zero-delay yields, a 20 ms finisher delay, three cancelled hour-long placeholder sleeps, one bounded 10 ms poll, awaits of in-memory or cancelled tasks, threekiro_crew.subagent.time.monotonicpatches) each get an own-line# flake-ok: <reason>.test_voice_reply.pyandtest_trusted_apps_api.pystay in.github/black-baseline.txtand are not reformatted.Rows and citations:
.github/file-line-cap-baseline.txtdeletes the four rows.test/wait_discipline_baseline.txtmoves thetest_subagent_coverage.pyrow totest_subagent_coverage_live_runs.py, which holds its one wait (count unchanged). Onetest/test_monitor_arming_preference.pydocstring namestest_trusted_apps_api_withdrawal.pyas the home of the_EDITABLE_CONFIGmembership pin.Backwards compatibility
Compatible: test-only change. Every collected test keeps its class, name and parameters (the multiset is identical before and after). No other test module imports from these four files. No production module, import path, patch target or CLI changes.
Removes nothing: every test, fixture and helper still exists, moved with an identical AST apart from the glue listed above.
Tests
No test was added or rewritten. These checks show the move lost nothing:
pytest --collect-onlyat BASE (4 origins) vs HEAD (4 originals + 8 parts)(class, name, params)multiset is identicalpytest --fixtures-per-test -v(private and autouse fixtures included), BASE vs HEADiter_markers(), BASE vs HEAD)-n 3and-n0scripts/leaf_test_scope.pyderives (522 tree-scanning test files) plus the 13 changed test files,-n 3 --dist loadgroupsource_corpus/repo_files()(80 files, includingtest_onboarding_import_refactor_contract.py) plus the 13 changed test files,-n 3 --dist loadgrouptest_flake_pattern_ratchet.py(-n0, against the merge-base),test_wait_discipline_ratchet.py,test_file_line_cap.py,test_subagent_spawn_host_pin.py--baseline-commit <BASE> --error, over the 19 changed files--disable-nosemexactly the 9 marked findingsisort/flake8/black --checkon the changed files;check_comment_history.py,check_brand_name.py,check_black_formatting.py,check_subprocess_encoding.py,check_file_line_cap.py,docs_lint.py,check_cwd_relative_repo_reads.py,check_harness_parity.py,check_feature_map.pytest_subagent_coverage_live_runs.py: 0 -> 1,1 -> 0 test_subagent_coverage.py); the HEAD row passesscripts/local-gate.py --base <BASE> --dry-runselects 17 backend files (all included above) and 367 cross-surface vitest specs; no website file reads these test files, so the vitest run is left to CI.Move audit
Every changed unit is glue: three fixtures re-declared with
name=and the four module docstrings. Every test function and class moved with an identical AST.git diff origin/main...HEADis 687,008 bytes.Diff alignment:
git diff BASE -- <file>andgit diff --minimal BASE -- <file>add the same lines for every original (--numstat):test_subagent_coverage.py8/1941,test_voice_reply.py11/2212,test_trusted_apps_api.py10/1581,test_onboarding_import_coverage.py7/2055, on both (docstring and import glue only).Moved semgrep sites, each with an own-line marker:
kirocrew.test-sleep-as-barrier×4 (_live_runs),kirocrew.test-autouse-shared-monkeypatch×4 (voice_reply_helpers.py,_synthesis×2,_pipeline),python.lang.security.audit.insecure-file-permissions×1 (voice_reply_helpers.py, the fake binary'schmod 0o755).Logger names: no new module defines a logger.
Content scan: the moved literals the internal scan could read are
AKIAIOSFODNN7EXAMPLE(the documented example key) and"HOME": "/home/x"(the same literal merged #12647 added).CI path references
None: no workflow filter, explicit file list,
AUTOSDE.yamlglob or sensitive-change glob names these files.Manual verification
N/A: unit coverage is sufficient. This is a test-only move; the collected-test multiset and a full run of every moved test show 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: ...)