Skip to content

test(spec-builder): finish splitting the route tests into behaviour parts - #20546

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t03-test-routes-p2
Oct 15, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-t03-test-routes-p2

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Finish bringing the Spec Builder route tests under the 2,000-line file cap: move the rest of spec_builder/tests/test_routes.py (8,147 lines after #20327) into behaviour-named parts without changing any test, so the file ends as the route contract alone.

#20327 moved the tail of the file into topic parts. What remains in test_routes.py still mixes the route contract with path containment, the index, the STOP sentinel, slot scoping and identity pinning, deletes, handoff, create, egress, git and event-loop guards, and the file is still four times the cap.

Why it matters

Until the remainder moves, test_routes.py stays over the cap and stays the default place a new route test lands. With this PR every route test has one topic home, test_routes.py holds only the contract, and the file leaves the line-cap baseline.

Not a goal

What changed (motivation → approach → change)

The same recipe that produced #20327 runs its second stage on main's tree: every unit after the route-contract prefix (the route set, settings round-trip, create validation and redaction sections) moves to the part that pins its behaviour. What test_routes.py keeps is one contiguous run of the original (only _stage_identity, a duplicate-only helper from the harness section, leaves it, for test_routes_duplicate.py), so git's default diff and --minimal agree on it (8 added lines: the docstring and the import comment).

File After this PR
test_routes.py the route contract, 362 lines
test_routes_paths.py, test_routes_event_loop.py, test_routes_index.py, test_routes_git.py, test_routes_egress.py, test_routes_stop_sentinel.py, test_routes_slot_scoping.py new parts
test_routes_create.py, test_routes_delete.py, test_routes_duplicate.py, test_routes_handoff.py, test_routes_identity_pinning.py, test_routes_nudge_loops.py, test_routes_artifacts.py complete their topic
routes_helpers.py unchanged

The largest file is now test_routes_duplicate.py at 1,473 lines. The few contract-shaped tests that sat outside the kept prefix go to the part whose behaviour they share: .spec-state/settings egress to egress, create pre-checks and the seed prompt to create, the state-guard self-tests to index, the module-scope import guard to paths, the live-running detail to slot scoping.

Path-keyed rows follow their tests:

  • test/requires-real-symlinks.txt re-points the remaining eight node ids.
  • test/test_source_pin_budget.py re-keys its test_routes.py row to test_routes_delete.py, where the one chat_runner source read now lives.
  • docs/system-specs/common/testing-conventions.md cites the tombstone-race test in test_routes_delete.py.
  • .github/file-line-cap-baseline.txt deletes the test_routes.py row.

Backwards compatibility

Compatible: test-only. Every collected test keeps its name, parameters and markers (594 before and after); test_routes.py keeps every name another module imports from it.

Removes nothing: no production code, public function, route or data changes; the moved definitions are private test helpers.

Tests

No test is added or rewritten. Evidence the move is faithful:

Collected multiset. pytest --collect-only -qq over test_routes.py + test_routes_*.py before and after: 594 = 594, identical (name, params) multiset.

Move audit (move_audit.py --origin .../test_routes.py, BASE = this PR's merge-base):

src/kiro_crew/apps/builtins/spec_builder/tests/test_routes.py: 8147 -> 362 lines; moved 99.7% (python-ast)
   changed: Expr [Expr] 21 lines                       <- the module docstring

Runs.

  • spec_builder/tests with the repo guards that read these files (test_spec_builder_routes_coverage.py, test_source_pin_budget.py, test_auto_research_facade.py, test_lazy_data_home_paths.py, test_host_isolation_floor.py, test_mock_pid_gate_wiring.py, test_error_code_contract.py, test_security_posture.py, test_file_line_cap.py) at -n 3: 1,567 passed. Every part also passes run alone at -n0.
  • scripts/local-gate.py: the backend related set (42 files) passed, 5,898 tests. Its cross-surface frontend set did not run on this host (npx returned E401 with no website/node_modules); this PR changes no frontend file, and CI runs that set.
  • test_flake_pattern_ratchet.py (-n0) passes; mypy src/kiro_crew is clean; black, isort and flake8 are clean on the changed files.
  • CI's SAST config (semgrep 1.78, p/python p/typescript p/security-audit p/secrets p/owasp-top-ten semgrep/, --baseline-commit merge-base --error) reports 0 findings.
  • Comment-history, brand and docs_lint.py pass; scripts/check_file_line_cap.py reports 0 failures.
  • Coverage of each new file is 94-100%.

Moved findings. Two more pre-existing sleeps that CI's diff-scoped semgrep reports again in their new file carry an own-line # flake-ok: and # nosemgrep: kirocrew.test-sleep-as-barrier above them, bodies unchanged:

  • test_routes_git.py: the fake git's await asyncio.sleep(3600), which hangs until the test cancels it;
  • test_routes_index.py: the stub's time.sleep(0.05), which widens a read-to-write window on purpose.

The only credential-shaped literal that moves is AWS's documented example key AKIAIOSFODNN7EXAMPLE (8 lines, redaction and egress tests).

Manual verification

N/A — test-only restructuring; the collected-test multiset, the AST move audit and the runs above are the verification.

Related Issues

Part of #20192

Follow-up: #20366 (pre-existing test weaknesses 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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 15, 2026 00:03
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 15, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 15, 2026 00:05
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f77e0c0df028333e897c4a8c4eb0e0b525664f54 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 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] f77e0c0

Description read

[DESCRIPTION-READ] 556e5e8ffed7a66204940336d2d42443a4da6aca0a5eb83d2944f8a3db19b1dd

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision f77e0c0df028333e897c4a8c4eb0e0b525664f54 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 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f77e0c0

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

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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f77e0c0

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

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=5d8d70850f5d Changing "category_turn_description" alters the shipped notification tooltip

rebutted (not in this PR): the PR changes 19 files and none is under website/ (gh api repos/kirodotdev/KiroCrew/pulls/20546/files and git diff --name-only $(git merge-base HEAD origin/main)...HEAD both list no website/ path, and en.manual.json is not among them).
The hunk the finding cites belongs to another change on main, so there is nothing here to remove; the PR stays test-only.

@bolichen97

Copy link
Copy Markdown
Contributor Author

rebutted (the two are deliberate shapes, not barriers): in test_routes_git.py the asyncio.sleep(3600) is the fake git's hang that the test cancels, and in test_routes_index.py the time.sleep(0.05) widens a stub's read-to-write window so an unserialized write would be lost; no assertion waits on either.
Their markers say why they are deliberate, so they are not de-flake work and need no tracking; #20366 covers the barrier sleeps and the guard shapes the first PR moved.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 7) in run 38657808382 went red on attempt 1 only on the repository-root residue guard (C:\Users\alice; 22,701 tests passed), from a test outside this diff; recorded as flaky in #20556. The single rerun (attempt 2) is green, and Coverage Gate with it.

@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 15, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding 4611d06 for human review under the sensitive-files policy. I found no defect.

What I checked: a static comparison of every removed and added line shows that the lines leaving test_routes.py reappear in the parts with no test body changed. The only exceptions are 21 lines: the old docstring, imports and re-pointed path rows. The only new lines are docstrings, section comments, imports, the two flake-ok/nosemgrep markers (

# flake-ok: the fake git hangs here until the test cancels it; nothing waits on it
,
# flake-ok: widens the stub's read-to-write window so a lost write shows; no assertion waits on it
) and the re-pointed path rows. The GPT finding is rightly rebutted: none of the 19 changed files is under website/. The First Principles punchline is answered, and the shard-7 residue red is recorded in #20556 and green on rerun. All lanes are PASS or answered, and CI is green.

Why it is held anyway: the moved files are the identity-pinning, egress/credential-redaction, path-containment, STOP-sentinel, delete and git-audit tests, plus test/requires-real-symlinks.txt. Policy reserves those for a human reviewer. To clear: a maintainer confirms no security test was dropped or weakened in the move. The multiset audit above and your 594 = 594 collection count are the evidence. A new push needs a fresh review.

— crew-pr-reviewer (r102)

…arts

The second of two moves that bring spec_builder/tests/test_routes.py
under the 2,000-line cap. Every test after the route-contract prefix
(the route set, settings round-trip, create validation and redaction
sections) moves, unchanged, into the sibling test_routes_<topic>.py
that pins its behaviour: seven new parts (paths, event loop, index,
git, egress, STOP sentinel, slot scoping) and the rest of the six parts
the first move opened. test_routes.py ends at 362 lines, one contiguous
run of the original, so its line-cap baseline row is deleted.

The collected test multiset is unchanged (594 tests). The remaining
eight symlink-list node ids, the source-pin budget row and the
testing-conventions citation follow their tests to the new files.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-t03-test-routes-p2 branch from 4611d06 to f77e0c0 Compare October 15, 2026 03:47
@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 labels Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Scheduled main refresh: rebased onto 9a77e12 (was fbca1a1); no upstream edit touched the moved tests, shared row files merged as a union, and the commit content is unchanged (range-diff =). CI re-running.

@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 15, 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 after a maintainer read the review lanes on this head: the only note is the diff size of a 1:1 test split.

@bolichen97
bolichen97 merged commit 5c8a356 into main Oct 15, 2026
101 of 102 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-t03-test-routes-p2 branch October 15, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants