Repository navigation
test: split three oversized test files by topic (part 1 of 2) - #20537
Conversation
test_prompts.py (4,858 lines), test_runtime_reconcile.py (4,825) and test_apps_registry_coverage.py (4,797) are each more than twice the 2,000-line cap. Each splits along its own section banners and test classes, by the behaviour under test, into the original path plus topic siblings named test_<stem>_<topic>.py. Helpers and fixtures that several parts share move to a non-test <stem>_helpers.py module that every part imports by name. test_prompts.py keeps discovery and reading (1,397 lines); authoring, the shared link and swap defences, and the caller gates move to _authoring, _link_gates and _caller_gates. test_runtime_reconcile.py keeps the reconciler core and the app backend table (1,357); the pass's inputs and outputs, every sweep's lease gate, and tenancy with its leak scan move to _wiring, _sweep_gates and _tenancy. The tenancy part holds every tenancy claim, so the leak scan over its own source and the positive control at its end keep their reach. test_apps_registry_coverage.py moves its shared fakes and its tail run (install refusals, characterization) to _install and _characterization (3,597 lines left); part 2 moves the front run so TestRunAppBuild is what the original keeps. One PR cannot hold all of it under the review lanes' diff cap. Every test function and class moves with an identical AST except TestRefusalLineVerb, whose one docstring named a neighbour "above" that stays in the original. The collected (class, name, params) multiset is identical (797 tests). Glue: fixtures that tests request by parameter are re-declared pytest.fixture(name=...); pytestmark keep_runtime_ownership_tables is copied into every runtime part; two remainder module docstrings name where the moved topics live, and the runtime remainder's table comment and one helper docstring are reworded to stay true; an own-line nosemgrep marker sits above each of the nine pre-existing semgrep findings that move into a new file. requires-real-symlinks.txt re-points 13 node ids, the wait-discipline row follows its waits, the line-cap baseline drops two rows and lowers one, and test/conftest.py's ownership-table fixture names the tenancy module's leak scan. Part of #20192
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 02c96fa Description read[DESCRIPTION-READ] 64559e5c10a02213dcd43e85d372752acd76192e23881deee5c6c7fe74dc2fde 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 |
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
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: |
Problem / Motivation
Goal: Bring
test/test_prompts.pyandtest/test_runtime_reconcile.pyfrom about 4,800 lines each to at most 1,600, and move the first half oftest/test_apps_registry_coverage.pyout, without changing a single test.test/test_prompts.py(4858 lines),test/test_runtime_reconcile.py(4825) andtest/test_apps_registry_coverage.py(4797) are each more than twice the 2,000-line cap the line-cap campaign enforces. A file that large is hard to navigate and to review, and every test added to one makes the eventual split bigger.Why it matters
The maintainers' rule is that no hand-written file may exceed 2,000 lines. These three files break it, and the files' topics are already separate (discovery vs authoring, the reconciler core vs every sweep's lease gate, the registry's helpers vs its build step), so a reader looking for one topic has to scroll past the others. Splitting along those seams makes each topic findable by file name and gives each file room to grow.
Not a goal
test/test_apps_registry_coverage.py: its front half moves in part 2 of this series (one PR cannot hold all three files under the 900 KB review-diff cap).What changed (motivation → approach → change)
Each file splits along its own section banners and test classes, grouped by the behaviour under test. The original path stays as one of the parts, as one contiguous run of its BASE code. Helpers and fixtures used by more than one part move to a non-test
*_helpers.pymodule that every part imports by name. A recipe tool did the move from BASE, so it can be re-run after a rebase instead of hand-merged.test_prompts.py(4858 → 1397)@mentionexpansion, the read API, the descriptor gate, the_run_chatpaths and off-loop reads_authoring(1322): create, update and delete;_link_gates(1457): the no-link read gate, the uniform link refusal, the pinned directory, the by-name fallback, local scope, ancestor loops, a root swapped after validation;_caller_gates(463): app tokens, the placeholder session key, non-ownerstest_runtime_reconcile.py(4825 → 1357)_wiring(1391): argv condition, kill budget, the cross-gateway pid union, record retraction, the notification memory, the warn-once ledger;_sweep_gates(963): the lease gate on every sweep;_tenancy(919): tenancy, the pinned identity, the barrier, the leak scan and its positive controltest_apps_registry_coverage.py(4797 → 3597)TestRunAppBuild(part 2 moves the front half)_install(556): install refusals and the un-poison routine;_characterization(538): behaviour a move of the registry must not changeHelper modules:
prompts_helpers.py(374 lines),runtime_reconcile_helpers.py(317),apps_registry_coverage_helpers.py(184).Glue, the only lines whose AST or comments change:
@pytest.fixture(name="x") def x_fixture(...)(thetest/meetings_helpers.pyconvention), so a parameter never shadows an import:aim_dir,mock_sel,block_sensitive_reads,block_sensitive_discovery,agent_root,cache_dir,pip_importable,bundled_interpreter. The autouse fixtures (_isolate_home,_no_turn_tail,_explicit_registry_execution_admission) are imported into every part.pytestmark = pytest.mark.keep_runtime_ownership_tablesis copied into every runtime part, so each test keeps its BASE fixture behaviour. Every tenancy claim stays in_tenancywith the leak scan that reads that module's own source, and its positive control is still the module's last test.pytestmarkis reworded to stay true (the positive control it described is in_tenancy).TestRefusalLineVerb's build-pass test namesTestRunAppBuild's root-datatest, which stays in the original, andbundled_interpretersays "each case using it". This is the one test-class AST change.# nosemgrep: <rule> -- <reason>directly above it, code unchanged; the one sleep also gets an own-line# flake-ok: <reason>.Rows and citations:
test/requires-real-symlinks.txtre-points the 13 entries of moved prompt tests.test/wait_discipline_baseline.txtmoves the registry-coverage row totest_apps_registry_coverage_characterization.py, which holds both waits (count unchanged)..github/file-line-cap-baseline.txtdeletes the two finished rows and lowers the registry-coverage row to 3597.test/conftest.py's_reset_runtime_ownership_tablesdocstring namestest_runtime_reconcile_tenancy's leak scan.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 three 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. The two tests named by
test/windows-expected-failures.txtand the readstest/test_source_pin_budget.pybudgets fortest/test_prompts.pystay in that file.Tests
No test was added or rewritten. These checks show the move lost nothing:
pytest --collect-onlyat BASE vs HEAD over the 3 origins + 8 new test files(class, name, params)multiset is identicalpytest --fixtures-per-test, 27 sampled tests across every part, BASE vs HEAD-n 3, HEAD and BASE_run_chatmock skip)test/test_flake_pattern_ratchet.py(-n0, against the merge-base)--baseline-commitBASE, over the 15 changed.pyfiles--disable-nosemover the 11 new files exactly the 9 marked findingsisort/flake8/black --checkover the changed files;scripts/check_file_line_cap.py_tenancyfails the scan (unbound at [91]); dropping one release fails it (5 claims but only 4 releases)scripts/local-gate.py --base <BASE> --dry-runselects 463 backend and 362 frontend test files, becausetest/conftest.pyand.github/changed: over the ~600-file local cap, so the floor above ran instead (CI runs the full suites). The diff touches no frontend file.Move audit
Every changed unit is glue or an L29 prose fix: the eight fixtures re-declared with
name=(bodies unchanged except one phrase ofbundled_interpreter's docstring), the two module docstrings, and one docstring inTestRefusalLineVerb. Comments are not in the AST, so the rewordedpytestmarkcomment intest_runtime_reconcile.pydoes not show here. Every other test function and class moved with an identical AST; the units moved out of the black-baselinedtest_apps_registry_coverage.pyare black-formatted in their new files, AST-identical.git diff origin/main...HEADis 758,125 bytes.Moved semgrep sites, each with an own-line marker (rule, new file):
kirocrew.test-autouse-shared-monkeypatch×6 (prompts_helpers.py×2,test_prompts_link_gates.py,apps_registry_coverage_helpers.py,test_apps_registry_coverage_install.py,test_apps_registry_coverage_characterization.py),kirocrew.test-sleep-as-barrier×1 (test_prompts_authoring.py, alsoflake-ok),kirocrew.test-bare-monkeypatch-undo×1 (test_prompts_link_gates.py),kirocrew.mock-pid-allocatable×1 (apps_registry_coverage_helpers.py). Semgrep cannot parse the keyword-only lambda intest_the_sweep_gate_audits_both_outcomes, as at BASE; it moves totest_runtime_reconcile_sweep_gates.py, and the other runtime parts now parse fully with no finding.Diff alignment: each original keeps one contiguous run of its BASE code after its header, and
git diff BASE -- <file>andgit diff --minimal BASE -- <file>add the same lines (--numstat):test_prompts.py16/16,test_runtime_reconcile.py11/11,test_apps_registry_coverage.py16/16 (import, docstring and comment glue only).Logger names: no new module defines a logger; moved
caplogtests read production loggers.Content scan: the moved literals the internal scan could read are
AKIAIOSFODNN7EXAMPLE(the documented example key),aws_secret_access_key = SHOULD-NOT-APPEAR(a non-secret value, the same shape merged #11227 and #17540 added) and 64-hex cache digests (as in merged #20047). No home path moves in this PR.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: ...)