Skip to content

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

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t55-test-members-eventlog-wiring
Oct 17, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t55-test-members-eventlog-wiring

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring four test files of about 2,700 lines each down to at most 1,600 lines, so none of them exceeds the 2,000-line cap, without changing a single test.

test/test_members_eventlog_wiring.py (2,693 lines), test/test_split_credential_boundary.py (2,713), test/test_compaction_stop_declined.py (2,691) and test/test_chat_slot_switch_atomicity.py (2,686) are each well past the size the line-cap campaign allows. 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 four files break it today, and each new test makes the eventual split larger and harder to review. Splitting by behaviour now gives each file room to grow and makes each topic findable by file name.

Not a goal

  • Changing, renaming, fixing, de-flaking or re-parametrizing any test. Every test body moves with an identical AST.
  • Changing production code. This PR touches only tests, test helpers, two test-path list rows and one comment.
  • Fixing the pre-existing timing shapes and the order-dependent drop-counter assertions that move with their tests (they are marked, not rewritten).
  • Splitting any file outside these four.

What changed (motivation → approach → change)

Each file splits along its own test classes and section banners, grouped by the behaviour under test. The original path keeps its header and one contiguous run of its own tests. Helpers and fixtures that more than one resulting file uses move to a non-test *_helpers.py module, 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.

Origin (lines) Stays in the original New parts (lines)
test_members_eventlog_wiring.py (2693 → 1258) the /api/members projections with the lazy config reconcile, and the roster and per-member projections routes as pure reads _startup_reconcile (700): the startup reconcile sweep; _live_writers (321): the activity round trip, the agent PUT hook, member-created slot events, the subscribe baseline; _append_ordering (434): one ordered worker, the shutdown drain, the patrol frame published after its append
test_split_credential_boundary.py (2713 → 980) the enumeration of delivery paths and the splitter core, through the dashboard legs _sealed_seams (495): seams under a delivered message; _channel_delivery (556): each channel's own send path; _readings (347): the grade by every reading and the last resort's tags; _rotation_and_tally (407): Discord's rotation, the delivery tallies, the table-aware split, the stable streaming cut
test_compaction_stop_declined.py (2691 → 1335) the in-place /compact arm, the dashboard Stop, the queue a forced Stop carries to the successor _surfaces (564): Slack !stop, the shared channel stop, the interrupt route, the spec-builder Pause; _escalation (404): marker and parked-queue bounds, the notices, arming only after delivery; _claude_and_restart (336): the Claude arm and the uncompactable restart
test_chat_slot_switch_atomicity.py (2686 → 1262) the private member switch and the model and workspace switch locking _linked_session (855): switches on a linked channel or cron session; _alias_and_bulk (615): alias slots on one session, the project set, the bulk model switch

Helper modules: members_eventlog_wiring_helpers.py (61 lines), split_credential_boundary_helpers.py (58), compaction_stop_declined_helpers.py (158), chat_slot_switch_atomicity_helpers.py (61). Three are under 150 lines because each holds only what several files share; copying it into each part would duplicate code.

Glue, the only new text:

  • Each original's module docstring gains a paragraph naming where the rest went (the members original's first paragraph names the roster half it keeps). Each new file has a docstring and an import header.
  • Autouse fixtures (_fresh_eventlog, _clear_channel_decline_markers) are imported into every file by name, so each test keeps its BASE autouse set. No fixture is renamed.
  • split_credential_boundary_helpers.SRC is imported by name into the original, so test_handlers_messaging_composition_contract.py's monkeypatch.setattr(guard, "SRC", ...) still rebinds the global TestTheDashboardHandlerLegsOffloadTheSplitter reads; that class stays in the original. The two patch sites test_session_allocation_bindings.py reads from test_compaction_stop_declined.py's text also stay.
  • Own-line # flake-ok: comments sit above the pre-existing timing and rendezvous shapes that move, with an own-line # nosemgrep: directly above each site the repo's semgrep rules report on the new path (listed under Move audit).

Rows and citations: the four rows in .github/file-line-cap-baseline.txt are deleted (each file is now under the cap). test/wait_discipline_baseline.txt re-keys two rows to the parts that hold the counted waits, test_chat_slot_switch_atomicity_alias_and_bulk.py and test_members_eventlog_wiring_append_ordering.py (count unchanged, 1 each). In test/test_slack_events_coverage.py, the comment on the _event re-export names compaction_stop_declined_helpers, which now imports it.

Backwards compatibility

Compatible: test-only change. Every collected test keeps its class, name, parameters, markers and fixtures (both multisets are identical before and after). The names other test modules read from an original stay there: test/test_handlers_messaging_composition_contract.py imports test_split_credential_boundary and calls TestTheDashboardHandlerLegsOffloadTheSplitter with SRC patched; test/test_session_allocation_bindings.py reads record_session_started and wake_other_drains in test_compaction_stop_declined.py. Both pass unmodified. No production module, import path, patch target or CLI changes.

Removes nothing: every test, fixture and helper still exists, moved with an identical AST.

Tests

No test was added or rewritten. These proofs show the move lost nothing:

Check Result
pytest --collect-only at BASE vs HEAD over the 4 originals and 12 new test files 469 = 469; the (class, name, params) multiset is identical
markers and fixture closure (autouse included) per collected test, BASE vs HEAD identical for all 469
bin/verify_test_split.py (every BASE top-level unit unchanged at HEAD, by ast.dump) 206/206
the 16 split test files at -n 3 464 passed, 5 skipped (BASE: 464 passed, 5 skipped)
the 16 split files + the two importers + test_slack_events_coverage*.py + 110 tests that scan the test tree (ratchets, facade guards, leaf/surface selectors, source pins) at -n 3 11,695 passed, 36 skipped, 1 failed: see the ordering note below
the 30-file related set in pytest's own (codepoint) file order at -n 3 (splits, importers, test_slack_events_coverage*.py, test_chat_slot_project.py, the ratchets and selectors) 1,333 passed, 5 skipped
the four test_compaction_stop_declined*.py files at -n0, codepoint order 98 passed
test/test_flake_pattern_ratchet.py (-n0, against the merge-base) 58 passed
semgrep 1.78 with the CI configs and --baseline-commit <BASE> 0 findings over the 23 changed files; no parse errors
profile backend floor (black, isort, flake8, mypy, subprocess-encoding, comment history, brand, agent-sdk, sync-io, harness parity, feature map, line cap, docs-lint, testpaths, …) 46/46 exit 0 (the frontend scoped-vitest gate is not run: no website/ file changes)

Ordering note: two tests assert an absolute value of a module-wide drop counter that no fixture resets (test_the_parked_queue_is_count_bounded_and_the_overflow_is_logged, kept, and test_decline_markers_are_count_bounded_and_the_overflow_is_counted, moved), so each passes only when no test before it on the worker overflowed that bound. Both fail the same way at BASE when a later bound test is run first. In pytest's own file order the original still runs before its parts, so these tests keep their BASE order; the one failure above came from a locale-sorted (en_US) file list that collected _escalation first. The moved assertion carries a # flake-ok:.

scripts/local-gate.py --base <BASE> --dry-run: backend related set 24 test files (17 in the diff, 7 referencing a changed file), all run above; frontend 367 cross-surface files, joined only because .github/ changed; no file under website/ changes, so CI owns that set.

Move audit

test/test_members_eventlog_wiring.py: 2693 -> 1258 lines; moved 99.52% (python-ast)
   changed: Expr [Expr] 12 lines    (module docstring: names the roster half it keeps and where the rest went)
test/test_split_credential_boundary.py: 2713 -> 980 lines; moved 99.68% (python-ast)
   changed: Expr [Expr] 8 lines    (module docstring: one paragraph naming where the rest went)
test/test_compaction_stop_declined.py: 2691 -> 1335 lines; moved 99.16% (python-ast)
   changed: Expr [Expr] 20 lines    (module docstring: one paragraph naming where the rest went)
test/test_chat_slot_switch_atomicity.py: 2686 -> 1262 lines; moved 99.55% (python-ast)
   changed: Expr [Expr] 11 lines    (module docstring: one paragraph naming where the rest went)

Every test function and class moved with an identical AST; the only changed units are the four module docstrings. git diff BASE...HEAD is 595,240 bytes.

Moved timing and rendezvous shapes (51 # flake-ok: and 15 # nosemgrep: lines), each with an own-line marker in its new file:

  • # flake-ok: + # nosemgrep: kirocrew.test-sleep-as-barrier on the 14 moved sleeps semgrep reports on the new path: 12 in the slot-switch parts (a 50 ms sleep that lets the racing request reach the held lock), the _claimant hold in _claude_and_restart, and the stubbed slow append in _append_ordering.
  • # flake-ok: + # nosemgrep: kirocrew.test-autouse-shared-monkeypatch on _fresh_eventlog in members_eventlog_wiring_helpers.py (no test that imports it calls monkeypatch.undo()).
  • # flake-ok: alone on the shapes the AI review rule reads but semgrep does not report: unbounded awaits of request tasks and events, lock and semaphore acquires, the _settle() yield barrier, the 0.05 s, 0.2 s and 0.5 s budgets three tests let run out on purpose, the real-clock escalation-window reads, and the absolute drop-counter read.

Credential-shaped literals that move: KEY = "AKIAIOSFODNN7EXAMPLE" (AWS's documented example id) into the split-credential helpers; the hyphenated wJalrXUtnFEMI-K7MDENG-bPxRfiCYEXAMPLEKEY and the SecretAccessKey lookalike tag into _sealed_seams and _readings, byte-identical to lines merged in #14314. The two token=AKIAIOSFODNN7EXAMPLE URL literals stay in test_members_eventlog_wiring.py.

Diff alignment (L36): each original keeps one contiguous run of its BASE code after its header. For every changed tracked file, git diff BASE -- <file> and git diff --minimal BASE -- <file> add the same lines (blank lines counted): members 11/11, split-credential 19/19, compaction 21/21, slot-switch 7/7, slack-events comment 1/1, wait-discipline 2/2, line-cap 0/0.

Logger names (L25): no new module defines a logger; the moved caplog assertions key on production loggers (kiro_crew.eventlog_hooks, kiro_crew.session_lifecycle), so nothing changes.

CI path references

None: no workflow filter, explicit file list, AUTOSDE.yaml glob or sensitive-change glob names these four files.

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

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 17644c5eb87c61fed20ab6a08b36dfee4e134f60 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 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 17644c5eb87c61fed20ab6a08b36dfee4e134f60 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 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 17644c5

Description read

[DESCRIPTION-READ] 59f2178ce37e18470d6bffb4afcaa4b086beb0e68a3b20f24ea4c499f1a84e0f

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 17644c5

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

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

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 17644c5

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

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 16, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 16, 2026 16: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 16, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-t55-test-members-eventlog-wiring branch from d77c4bb to 9fcc477 Compare October 16, 2026 17:12
@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 labels Oct 16, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Verify the two drop-counter tests in CI's sharded run: verified, no code change

Both passed in CI's sharded run at d77c4bb: every Backend Tests (3.12, 1-8) and Backend Tests (Windows) (1-8) shard is green.
Their order is the BASE order: pytest collects test_compaction_stop_declined.py before every test_compaction_stop_declined_*.py part (codepoint sort), so on any worker each counter assertion still runs before the tests that advance that counter.
The reliance on a module counter no fixture resets is pre-existing (it reds at BASE when a later bound test runs first) and is tracked on #20383 for the de-flake pass; the moved assertion carries a flake-ok, and this split keeps behaviour as it is.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • The broad run's one order-dependent failure also fails at BASE in the same order: verified, no new flake

Same order, same failure: running the 19 tests that _escalation now holds and then test_the_parked_queue_is_count_bounded_and_the_overflow_is_logged fails at BASE (the unsplit file, node ids in that order) and at this head (_escalation.py then that node id), both with assert '2 dropped so far' in '... 5 dropped so far ...', and both pass 23 others.
The locale-sorted (en_US) file list in the broad local run collected _escalation first, which is that order; pytest's own codepoint order collects test_compaction_stop_declined.py first, as CI does, and all 16 Linux and Windows backend shards passed at d77c4bb.
The unreset module counter is pre-existing and tracked on #20383; this split keeps behaviour as it is.

@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 16, 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.

Approved by a maintainer. The triage automation held this on a size, path or category rule only; every review lane is clean.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 16, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-t55-test-members-eventlog-wiring branch from 9fcc477 to 92ea595 Compare October 16, 2026 20:55
@github-actions github-actions Bot added readiness: checking Automated validation is still running 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 labels Oct 16, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 16, 2026
test_members_eventlog_wiring.py, test_split_credential_boundary.py,
test_compaction_stop_declined.py and test_chat_slot_switch_atomicity.py
were each over 2,680 lines. Each keeps its header and one contiguous run
of its own tests, and the rest move verbatim into sibling parts named by
behaviour, with the shared fixtures and builders in a *_helpers.py
module per file. Every remainder and part is at most 1,335 lines; the
collected tests are identical (469).

Own-line flake-ok and nosemgrep markers sit above the pre-existing
timing and rendezvous shapes the moved code carries. The four line-cap
rows leave the baseline, the two wait-discipline rows follow their sites
into the parts that hold them, and a comment in
test_slack_events_coverage.py names the helper module that imports
_event from it.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-t55-test-members-eventlog-wiring branch from 92ea595 to 17644c5 Compare October 16, 2026 23:55
@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 16, 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.

Approved by a maintainer. The triage automation held this on a size, path, category or move-check rule only; every review lane is clean.

@bolichen97
bolichen97 merged commit d39f206 into main Oct 17, 2026
103 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-t55-test-members-eventlog-wiring branch October 17, 2026 01:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 17, 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