Skip to content

tools: wait for stopped batch fixture writers before cleanup - #280

Closed
Burntgogi wants to merge 1 commit into
midagedev:mainfrom
Burntgogi:fix/batch-fixture-quiescence
Closed

Burntgogi wants to merge 1 commit into
midagedev:mainfrom
Burntgogi:fix/batch-fixture-quiescence

Conversation

@Burntgogi

Copy link
Copy Markdown
Contributor

What and why

Closes #264. End and observe stopped self-test lanes/items before their fixture tree can be removed. Seven existing ad-hoc TERM loops now use one fixture-only teardown; registered fake box calls still use the existing reap helper. Production timeout/signal handling is unchanged and remains separate from #201.

Release notes: Fixed — gate-batch self-tests wait for stopped fixture writers instead of racing directory removal after reporting successful cases.

Code shape

  • No second copy. One self-test teardown for the seven equivalent stop loops.
  • Model code holds only architecture facts. No model code changes.
  • Dead code is gone. Remove the replaced fire-and-forget loops.
  • No silent failure. Bound teardown and name surviving writers; do not ignore cleanup failures or loosen count-line parsing.
  • Comments state what is true now. Existing local-check documentation is updated.
  • No relaxed gate. No numeric pin, tolerance or lint changed; the hang assertion remains.
  • cargo fmt / cargo clippy: no Rust changes; whole-tree formatting is covered by integrated T0 below.

Duplication removed: the registered lane/item TERM loops in tools/gate-batch.sh's self-test. PID arguments are checked against this fixture's path before signalling, and zombies count as no longer able to write. TERM gets 50 ticks before KILL, followed by bounded observation.

What I ran

Base 2b43ceb; independent branch fix/batch-fixture-quiescence, head 72f0c8b.

Strengthened the real part-2 fixture: its hung mutant's lane handles TERM by waiting until the parent has stopped, then delaying its final write. The new contract requires both the final-write marker and the lane's absence before cleanup. With only this regression added:

LC_ALL=C bash tools/gate-batch.sh --self-test --part 2

7 of 8 ok, exit 1: the lane still writes or has not finished its handler. After the fix, the actual complete CLI self-test:

LC_ALL=C bash tools/gate-batch.sh --self-test

640 of 640 ok, exit 0, including part 2 8/8 and all migrated teardown callers.

This deterministically exercises the suspected race mechanism; it does not identify which process wrote during the original CI failure. No real GPU or remote batch ran. No output/count parser was weakened.

bash tools/affected-gates.sh origin/main..fix/batch-fixture-quiescence --no-box: five gate recipes selected, plus always-static checks; local-check documentation unmapped. This is static reach, not evidence that those GPU/model gates ran or that PTX narrowing was established.

Integrated verification

LC_ALL=C bash tools/contrib-check.sh --tier t0 at combined validation commit 1d0ef55f (all four independent fixes):

DONE tier=t0 total=83 red=0 wall=295s

Formatting, all T0 host/tool units and every included check script passed, including the complete check-recipes block. This is one combined run, not four separate full T0 runs. It does not establish GPU, model-oracle, PTX or whole-workspace strict Clippy evidence.

Fixes midagedev#264. Share the self-test lane teardown, observe registered writers through TERM and bounded KILL, and retain cleanup failures. A delayed last-write regression fails 7/8 before the fix; the full runner passes 640/640 afterward. Production timeout and signal handling is unchanged.
@github-actions github-actions Bot added documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 15, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MUST_FIX: The lane-skip self-test can report success after fixture teardown fails.

Must fix

1. Propagate the teardown error from lskip_case

tools/gate-batch.sh:1689 A writer surviving the bound makes stop_lanes return 70 at line 1304. Both callers capture lskip_case through $(...) at lines 1695 and 1701, where Bash clears errexit by default. Execution continues to the final printf, which returns success. With batch rc=0 and one skip, the caller receives 0 1 and passes its assertions despite failed teardown. The EXIT trap then removes the fixture.

Propagating the error here keeps the self-test from approving failed cleanup. Replace the call with:

    stop_lanes "$t/target/c-$tag" || return $?

Checked

Duplicates: 1 new function checked; it reuses call_alive and reap_calls; no duplicate owner found.

Complexity: no Rust functions changed.

Silent failure: all 7 teardown call sites traced. The other 6 preserve errors under set -e.

Tests: bash -n passed. A probe using the actual caller tail injected teardown rc=70: the original returned success with 0 1; the suggested guard returned 70. The delayed-writer assertion checks both the final-write marker and the lane's termination; removing the wait permits it to fail.

Gates: no existing assertion or threshold was relaxed. The PR body reports FAIL-first results for the delayed-writer assertion.

Escapes: C1 status masking applies. C2–C4 did not match.

Notes

dryer and crapper did not run because no Rust file changed.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Comment thread tools/gate-batch.sh
for f in "$t/target/c-$tag"/lane-*.pid "$t/target/c-$tag"/lane-*.child; do
if [ -f "$f" ]; then kill -TERM "$(cat "$f")" 2> /dev/null || true; fi
done
stop_lanes "$t/target/c-$tag"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Propagate teardown failure: command substitution clears errexit by default, so the final printf otherwise turns status 70 into success.

Suggested change
stop_lanes "$t/target/c-$tag"
stop_lanes "$t/target/c-$tag" || return $?

@juliankang4

Copy link
Copy Markdown
Collaborator

Burntgogi님, 고맙습니다. 이 PR의 수정은 #338로 이어받아 main에 들어갔습니다(bf83ac8f). Burntgogi님의 커밋은 author와 내용을 그대로 두었기 때문에 main 기록에 Burntgogi님의 기여로 남습니다. 저는 리뷰가 지적한 부분만 그 위에 이어서 고쳤습니다. 수정이 main에 들어갔으니 이 PR은 닫겠습니다.

(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools: gate-batch self-test part 2 can fail after all its cases pass, when its temporary tree is removed while a stopped lane still writes

2 participants