Skip to content

refactor(testing): drop a dead teardown operand and an unread field - #24016

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/simplify-testing
Oct 25, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/simplify-testing

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Remove a dead operand from the test harness's teardown verdict and an unread field from its fake aiohttp response, pin that verdict with a test, and correct the comments this description lists in those two files, without changing what either does.

src/kiro_crew/testing/ runs real gateways and fake channel wires for the suite. Two of its files carry state that never matters and comments that contradict the code:

  • _terminate_process_group ends with return escaped_ended and not root_already_exited. Every path where the root had already exited returns before that line, so not root_already_exited is always true there, yet reads as if a crashed root could reach the last verdict.
  • No test checked that verdict's False: replacing the line with return True red only 20 test_spawn_audit.py tree scans, which red the same way on an unmodified copy.
  • _FakeResponseCM.__init__ stores the canned response as self._resp. Nothing reads it, while the class docstring says it supplies only the attributes aiohttp's borrowed methods read.
  • That docstring's list of attributes, and the same list in testing-conventions.md, leaves out three the borrowed methods do read: headers, _in_context and _resolve_charset.
  • A comment credits the escaped descendants' safety to a created_after filter this POSIX path never applies; a comment below it in the same function says so.
  • The _StdoutPump docstring says the queue stops the reader reading ahead without bound; the queue is unbounded and takes every chunk until the reader is handed off after READY.
  • The cold-import comment explains the diagnostic by an earlier stderr-only message, and three more comments narrate earlier designs ("the old selector poll", "the previous deque", "the original except OSError").

Why it matters

Nothing is broken. That verdict decides whether the harness deletes a test gateway's HOME while a child it saved may still be writing there, so the line should read as what decides it, and a test should fail if it stops deciding it. A comment that names the wrong guard sends the next reader to the wrong function.

Not a goal

What changed (motivation → approach → change)

The teardown verdict now returns the escaped-descendant answer directly, the fake stops storing a field nobody reads, and each comment listed above is restated to match the code beside it, or deleted.

Where Before After
_terminate_process_group, last line escaped_ended = _end_escaped_descendants(escaped), then return escaped_ended and not root_already_exited return _end_escaped_descendants(escaped)
_FakeResponseCM.__init__ self._resp = resp removed
_FakeResponseCM docstring, testing-conventions.md attribute list missing three names the list with them
comments in harness.py the claims above created_after sentence, read-ahead clause, selector and deque asides deleted; cold-import and unknown-group comments restated
test/test_harness.py none one parametrized test of the last verdict

Why the operand is dead: root_already_exited is assigned once, and both of its exits (the Windows branch and the POSIX return False) come before the last line. _end_escaped_descendants returns only True or False, so x and True is x.

Backwards compatibility

Compatible: neither code change does anything at runtime, since the dropped operand is always true where it was read and nothing read the dropped field.

Removes nothing: _resp is private, with no reader in src/, test/, docs/ or the aiohttp 3.14.3 methods the fake borrows; take_away_check.py finds no take-away shape.

Tests

  • Added. TestTeardownDoesNotTrustTheRootsExit::test_a_live_roots_verdict_waits_on_its_escaped_descendants, cases [True] and [False]. It stages a live root whose saved child sits in another process group and checks that the child reaches _end_escaped_descendants with its recorded token and that the verdict is that function's answer. It passes against main's harness.py, so it pins existing behaviour; with main's last line replaced by return True, only [False] reds.
  • Determinism. The two new ids: 20 runs at -n0. test_harness.py: 10 runs at -n 4 --dist loadgroup --max-worker-restart=2, and its 85 ids shuffled (seed 25102) at -n0. All green; the flake-pattern ratchet is green.
  • Related tests (Python 3.12). 28 files: the 26 outside test/e2e/ that name kiro_crew.testing.harness, fake_channel_wire or from kiro_crew.testing import, plus test_spawn_audit.py and test_internal_python_isolation.py, which read harness.py by path. 707 passed, 25 skipped.
  • Static gates (Python 3.12). All 33 checks exit 0, among them flake8, isort, mypy, black-formatting, comment-history, brand, harness-parity, line-cap, the docs lint, the flake-pattern ratchet and the vendor manifest.
  • Pre-PR review. Seven read-only reviewers (repo rules, behaviour, bindings and imports, security, claims, and local Opus and GPT lane mirrors, the GPT one on a Claude model), two adjudicators on every finding, then a final verifier.
    • Code: no defect found in any lens. The behaviour lens ran base and head _terminate_process_group over 139,968 stubbed inputs: identical verdicts and call logs whenever _end_escaped_descendants returns a bool, which it always does. The security lens found no control changed shape and no touched file keystone.
    • Wording: two Medium, fixed. Five lenses found that the first replacement for the created_after sentence promised a token-pinned kill the POSIX path does not perform, and that the commit message repeated it. Both adjudicators upheld both and ruled to delete the sentence and the commit message's claim.
    • One Low, filed rather than fixed: two older harness.py comments make the same claim. Both adjudicators ruled to leave them as the rule POSIX harness teardown SIGKILLs a saved descendant without re-checking its creation token #24013's fix should meet, and to file that gap publicly.
    • Four Low and a nit, fixed: the read-ahead clause, the cold-import comment, the new test's docstring and assert message, and two sentences of this text. Both adjudicators upheld each.
  • Not run locally. scripts/scrub-lint.sh is absent from the checkout. The frontend did not run, as nothing under website/, .github/ or scripts/ changed.

Manual verification

N/A: neither code change does anything at runtime, and the related tests run both files.

Screenshots / video

Why no screenshot: backend-only change to test-harness internals, their comments and one spec paragraph; no page, card or string changes.

Related Issues

Part of #16523

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

`_terminate_process_group` ended with `escaped_ended and not
root_already_exited`, but every path where the root had already exited
returns earlier, so the second operand is always true there. It now
returns `_end_escaped_descendants(escaped)` directly.
`_FakeResponseCM.__init__` stored the canned `WireResponse` as `_resp`,
which neither the class nor the aiohttp methods it borrows ever read.

No test checked that last line's False answer: with main's line
replaced by `return True`, the only related reds were
test_spawn_audit.py's tree scans, which red the same way on an
unmodified copy. A parametrized test in test_harness.py now pins it for
a live root whose saved child sits in another process group. It passes
against the code before this change.

Comments in the same two files: a sentence crediting the escaped
descendants' safety to a `created_after` filter this POSIX path never
applies is removed; the queue rationale drops a clause saying the
unbounded queue bounds read-ahead, and its "old selector poll" aside;
the cold-import note names `cold_hint` and the liveness state rather
than an earlier message; the `TAIL_CHUNKS` and unknown-group comments
stop narrating earlier designs; and the fake's list of attributes the
borrowed methods read gains `headers`, `_in_context` and
`_resolve_charset`.
testing-conventions.md repeats that list and is corrected with it.

On POSIX the teardown's SIGKILL of a saved descendant does not re-check
its creation token, though two comments in harness.py say it does.
That is #24013 and is not changed here.
@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 25, 2026 13:44
@bolichen97
bolichen97 requested a review from CrysisDeu October 25, 2026 13:45
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 8b76aa3e81f67769bf7e5cbe12b816cc9cafe424 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 8b76aa3e81f67769bf7e5cbe12b816cc9cafe424 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this only touches test-harness internals. The dropped operand is always true where it was read, the dropped field has no reader, and the new test pins the verdict.

[DESIGN-REVIEWED] 8b76aa3

Description read

[DESCRIPTION-READ] 62641516fc4465c99f426975bdaa51c5bbbe61ea88499edfaa66f8180a7dc474

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

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8b76aa3e81f67769bf7e5cbe12b816cc9cafe424 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: both code edits change no behaviour (the base shows root_already_exited exiting at lines 857–867, before the last line), and every other item is a comment fix or a pin of existing behaviour.

What this change ships

Inventory (5 items) — 5 justified

Intent: make the test harness's teardown verdict and fake aiohttp response read as what they actually do, and pin that verdict with a test. This is a FIX (dead code and false comments).

  1. Teardown's last verdict returns the escaped-descendant answer directly, dropping an operand that is always true — justified
  2. The fake response stops storing the canned response nobody reads (_resp, 0 readers under src/kiro_crew/testing) — justified
  3. The fake's docstring and the testing-conventions.md attribute list now name headers, _in_context and _resolve_charset — justified
  4. The harness.py comments that named the wrong guard or described earlier designs are deleted or restated — justified
  5. A new parametrized test checks that a live root's verdict follows _end_escaped_descendants — justified

[FIRST-PRINCIPLES-REVIEWED] 8b76aa3

Description read

[DESCRIPTION-READ] 07b78fbf22c1f7dd1e2fa485003d9078f03c70ff25cca137dfd0fd468dfec21b

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 8b76aa3

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 8b76aa3e81f67769bf7e5cbe12b816cc9cafe424 false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8b76aa3

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8b76aa3e81f67769bf7e5cbe12b816cc9cafe424 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 enabled auto-merge (squash) October 25, 2026 13:58
@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 25, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Answers for head 8b76aa3e81f6, all lanes green on round one:

@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: refactor (4 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: drops an operand that is always true on the POSIX teardown path (the root-already-exited case returns earlier) and an unread field in the test harness, trims stale comments, and adds a test for the escaped-descendant verdict. 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 09816d2 into main Oct 25, 2026
106 checks passed
@bolichen97
bolichen97 deleted the refactor/simplify-testing branch October 25, 2026 15:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 25, 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