Skip to content

test: split four oversized test files under the 2,000-line cap - #21916

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t73-test-slack-gateway-cron-exec-coverage
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t73-test-slack-gateway-cron-exec-coverage

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring four oversized test files under the 2,000-line cap by moving their tests, unchanged, into sibling files named for the behaviour they cover.

test/test_host_isolation_floor.py (2,458 lines), test/test_slack_gateway_cron_exec_coverage.py (2,367),
test/test_cloud_source.py (2,288) and test/test_dashboard_templates.py (2,286) are over the 2,000-line cap and
listed in .github/file-line-cap-baseline.txt.

Why it matters

Files this long are hard to review and to navigate, and the cap only holds if baselined files shrink. Leaving them
over the cap keeps four rows in the baseline, and every new test in these areas lands in an oversized file.

Not a goal

  • Changing, renaming or rewriting any test, fixture or helper body (the move is verbatim).
  • Touching product behaviour: the only edits outside the four test families are three one-line citations.
  • Widening any guard to cover the new files (the slack module's own encoding scan keeps scanning its own module).

What changed (motivation → approach → change)

Each file is split along its own seams (Test classes and section banners). Tests move byte for byte; the builders,
doubles and constants that two or more files of a family read move to one *_helpers.py per family, which each
file imports explicitly. Every file ends at or below 1,600 lines.

Origin (lines) Stays (lines) New files (lines)
test_slack_gateway_cron_exec_coverage.py (2,367): command and script arms, claim-time vetting, script-result delivery 1,149 _message_arm.py (310): the LLM arm's denial, _init_cron wiring, alias resolution; _delivery.py (774): where cron results, alerts and task-runner notices go; slack_gateway_cron_exec_coverage_helpers.py (223)
test_cloud_source.py (2,288): repo root, tarball contents, checksum pin, bucket, boundaries, upload 1,181 test_cloud_source_staging.py (1,133): the staging directory and its ancestor walk, Windows arm included
test_dashboard_templates.py (2,286): the invariants, host caps, registry and scaffold 1,438 test_dashboard_templates_readers.py (872): the page and contract readers; dashboard_templates_helpers.py (31)
test_host_isolation_floor.py (2,458): the guard, path pins and ratchet, telemetry, temp, cwd and test loop 1,496 _restores.py (580): the between-test restores; _worker_budget.py (418); host_isolation_floor_helpers.py (33)

The four line-cap rows go. Three citations name the file that now holds the cited test: conftest.py
(TestInheritedShellEnvironmentIsScrubbed), docs/system-specs/common/testing-conventions.md (the hooks
dispatcher restore) and test/test_ci_failure_annotations.py (the conftest-by-path idiom). The two small helpers
modules hold only what two or more files of their family share; the cloud family needs none.

Backwards compatibility

Compatible: no product code changes, and no test file imports from the four origins. Every test keeps its name,
parameters and markers.

Removes nothing: tests move between files and none is dropped (583 collected before and after).

Move audit

move_audit.py --base 330812e688 (every unit not listed moved unchanged):

test/test_slack_gateway_cron_exec_coverage.py: 2367 -> 1149 lines; moved 98.63% (python-ast)
   changed: Expr [Expr] 30 lines
test/test_cloud_source.py: 2288 -> 1181 lines; moved 99.95% (python-ast)
   changed: Expr [Expr] 1 lines
test/test_dashboard_templates.py: 2286 -> 1438 lines; moved 99.39% (python-ast)
   changed: Expr [Expr] 12 lines
test/test_host_isolation_floor.py: 2458 -> 1496 lines; moved 98.9% (python-ast)
   changed: Expr [Expr] 25 lines

The changed Expr units are the module docstrings (one appended paragraph each naming the sibling files). The
other non-move edits:

  • an own-line # nosemgrep: kirocrew.test-autouse-shared-monkeypatch marker on each of the two class-level autouse
    fixtures that move (TestTheLogQueueListenerIsRestored, TestTheWorkerBudgetIsMemoryBounded), silencing
    their pre-existing finding at its new path;
  • one comment in the moved TestTheWorkerBudgetIsMemoryBounded ("this file's own ratchet" becomes
    "test_host_isolation_floor.py's ratchet"; the ratchet stays there). The AST is unchanged.

Default and --minimal diffs add the same lines for every file but one: the slack remainder's import header
re-shows one blank line under the default diff (20/1,238 vs 19/1,237). The line is a blank in import glue, so it
carries no gate token.

Tests

Proof that nothing was lost (BASE vs HEAD, -n0):

  • collected (class, name, params) multiset: 583 at BASE, 583 at HEAD, equal (91+107+265+120 -> 43+10+38,
    55+52, 136+129, 79+22+19);
  • markers per test (iter_markers): 583, equal;
  • --fixtures-per-test: equal except for the 41 host tests that moved. They no longer request the module autouse
    _record_own_basetemp, and that is the only difference. The fixture only records pytest's basetemp in a
    global that _inside_a_guarded_root reads, and none of the moved tests calls that guard. It stays with
    TestTheGuardItself, which patches that global through sys.modules[__name__].

Local gates at HEAD:

  • floor, -n 3, on base 9d088c85ad (same split patch): 586 files (the split files, the 556 leaf_test_scope corpus gates, the 52 tests that read the
    root conftest, and the related set without the conftest.py token): 39,025 passed, 136 skipped, 5 xfailed,
    1 failed. The one failure was test_history_bindings.py::test_the_member_set_is_the_frozen_inventory on the
    older base, fixed upstream by test(history): list the members #21108 added in the frozen inventory #21792; it passes on this base (212 passed);
  • at this head (main 330812e688, which adds three TestTheTempResidueReport tests to the host remainder): the
    10 split files plus test_ci_failure_annotations, test_history_bindings, test_file_line_cap,
    test_wait_discipline_ratchet, test_windows_gap_list, test_codebuild_gap_list, test_ci_file_shards,
    test_host_service_guard and the flake ratchet at -n0: 1,137 passed, 2 skipped;
  • a shuffled -n0 pass over the 580 split-file ids of the earlier base: 578 passed, 2 skipped;
  • isort (the CI command), black, flake8, the black / subprocess-encoding / agent-sdk ratchets, comment-history,
    brand, harness parity, docs lint, check_file_line_cap.py (0 failures), and semgrep with the CI configs and
    --baseline-commit (0 findings; --disable-nosem shows only the pre-existing marked sites).

scripts/local-gate.py --dry-run selects 557 backend and 374 frontend files (the conftest.py citation makes most
of the suite "related"), so it was not run whole; the floor above ran instead and CI runs the full matrix.

The encoding scan test_no_text_io_here_relies_on_the_platform_default_encoding reads its own module. Every
text-I/O call it examined at BASE (8) is still in that module; the moved slack code makes none.

Determinism: the moved tests are not rewritten, and none of them carries a sleep, clock or unbounded-wait shape.

Manual verification

N/A — a pure test move: the collection, fixture and marker proofs and the test runs above cover it.

CI path references

None: no workflow path filter, explicit file list, AUTOSDE.yaml glob or sensitive-change glob names these files.
test_dashboard_templates_readers.py reads the website binder, so ci-surface-tests.py adds it to the backend
tests a frontend diff runs; test_host_isolation_floor_worker_budget.py reads test/conftest.py, so it becomes a
leaf_test_scope corpus gate. No logger is created in any moved or new module (L25).

Related Issues

Part of #20192

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

test_slack_gateway_cron_exec_coverage.py, test_cloud_source.py,
test_dashboard_templates.py and test_host_isolation_floor.py were each
over the cap. Each keeps its path and the tests of its core topic; the
rest moves verbatim into sibling test_<stem>_<topic>.py files, with the
pieces two or more files read in a <stem>_helpers.py module.

- slack: the message arm (_message_arm) and where cron results, alerts
  and task-runner notices go (_delivery) move out; the command and
  script arms and claim-time vetting stay.
- cloud: the tarball staging directory and its ancestor walk, Windows
  arm included, move to _staging.
- dashboard templates: the page and contract readers move to _readers;
  the invariants, registry and scaffold stay.
- host isolation floor: the between-test restores move to _restores and
  the worker budget to _worker_budget; the path pins, telemetry, temp
  and working-directory guards stay.

The same 580 tests are collected with the same markers. The 41 moved
host tests no longer get the module autouse fixture _record_own_basetemp,
which only sets the guard's basetemp for _inside_a_guarded_root; none of
them calls it. The four line-cap baseline rows go, and three citations
of moved tests point at their new files.

Part of #20192
@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 18, 2026 14:13
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f1b22d0492b2731456f57891745a586e50a79694 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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision f1b22d0492b2731456f57891745a586e50a79694 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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Please check that CI collects 583 tests across the ten split files, matching the base count.

[DESIGN-REVIEWED] f1b22d0

Description read

[DESCRIPTION-READ] 4fa430f8f169ec8ef3b7333306a74b2e1eb341333b5ab75ef5d2c765011a48f2

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f1b22d0

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

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f1b22d0

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

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

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design PASS punchline: CI collects 583 tests across the ten split files

Checked before publish: pytest --collect-only -qq -n0 over the four origins at BASE and the ten split files at HEAD gives 583 = 583, and the (class, name, params) multisets are equal.
Per file: 91+107+265+120 at BASE. At HEAD: 43+10+38, 55+52, 136+129, 79+22+19.
Markers per test are equal (583). Fixtures-per-test is equal, except that the 41 moved host tests no longer request the inert module autouse _record_own_basetemp.
CI collects the same files on its own shards, because every new file is test/test_*.py under testpaths; the Testpaths Coverage Gate is green.

@bolichen97
bolichen97 enabled auto-merge (squash) October 18, 2026 14:35
@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 docstring path updates and line-cap baseline removals. 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/system-specs/common/testing-conventions.md.

@bolichen97
bolichen97 merged commit 8520c49 into main Oct 18, 2026
106 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-t73-test-slack-gateway-cron-exec-coverage branch October 18, 2026 16:07
@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