Repository navigation
v1.91.372.0 feat(flaky): gstack-flaky reruns a failed test command once and ledgers the flake (GSTA-158 P1) - #3612
Merged
Merged
Conversation
|
😎 This pull request was merged. |
…gers the flake (GSTA-158) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…closed duplicates and nonzero reruns Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan
force-pushed
the
gsta158-flaky-run
branch
from
October 29, 2026 16:24
f0ace59 to
fb30855
Compare
gstack-flaky never greens an incomplete run: a targeted rerun needs the runner's summary proving the first run complete, otherwise (and always for generic runners) the rerun repeats the whole command. A rerun clears a test only when it exits 0 and the test passes once on its first attempt. Killed runners exit 3 (FLAKY_COMMAND_KILLED) and signals are forwarded. The first report is restored at --junit with reruns kept beside it; ids are redacted at every output; the ledger gets its own GSTACK_FLAKE_LEDGER_JUNIT; fixtures are registered in FREE_FIXTURES. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A cancel forwarded to a runner that traps the signal now counts as killed for every later attempt, so a cancelled job is never rerun or greened. A whole-command rerun clears nothing when its report has a failed test, misses a first-run test, or its runner counted failures outside the report. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… the run A coverage threshold or a fail-on-flaky policy fails a run for a reason a narrowed rerun cannot reproduce, so either forces a whole-command rerun. --junit refuses an existing file that is not a JUnit report instead of deleting it. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…t-in A rerun counts only on the runner's own full green verdict: exit 0, no failed or missing test, nothing counted outside the report. That covers every way a run can fail, which a narrowed rerun cannot (a coverage threshold with an lcov reporter, a fail-on-flaky policy, a test never reached). --rerun-scope test reruns the failed test alone, with its preconditions documented and the complete-run checks kept as a safety net. An unreadable existing --junit file is a usage error, not a crash. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…158) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
3 tasks done
…ntry moves to changelog.d Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan
added a commit
that referenced
this pull request
Oct 31, 2026
…; retarget to main Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A test that fails once and passes on its rerun:
bun testalone exits 1 and the job is red. Undergstack-flaky runthe rerun's full green verdict keeps the job green, and the flake goes on the ledger.Text before/after
Before (
bun test … flaky.test.ts):(fail) flips once, exit 1.After (
gstack-flaky run --runner bun --junit r.xml -- bun test …):exit 0.
Why
Garry's standing rule is "you can just run the failed test again and note that it is flaky". gstack's own free suite already does that per file, but other repositories had nothing. Truther's last five attempt-1 reds each failed one Playwright test, three of them
cover-focus.spec.ts:144, and each cost a manual rerun of the whole job. Now a wrapped CI step reruns once, stays green only on the runner's own full green verdict, and leaves a ledger line for the daily flaky-fix pass.Blast radius
The change adds a new bin, two new library modules, docs and tests. Nothing existing imports
lib/flaky-run.tsorlib/junit.ts, and the only edit to an existing gate file is one fixture-map row intest/helpers/free-fixtures-data.ts(file read; the remote pregate ran 3270 selected tests with 0 failed at tree 832e118cb442). The free suite's file-level retry and itsGSTACK_FLAKE_LEDGERare untouched, and the new ledger has its own path.Approvals
Source: gstack-approvals record for gsta158-flaky-run (display only; not an approval citation).
Plan narrowed in the safe direction (GStack Minder, 2026-10-29). The approved plan reran only the failed test. Review found that a narrowed rerun cannot see every reason a run fails: with bun 1.4.4, a coverage threshold set in
bunfig.tomlwith an lcov reporter turned a real red green. GStack Minder approved making the whole-command rerun the default for every runner, counting a rerun only on the runner's full green verdict, and keeping the targeted rerun as opt-in--rerun-scope testwith its preconditions documented. The generic--rerun-argtemplates from the plan were dropped. GStack Minder granted two rule-23 fix-check exceptions for this (on a4ea2f3 and on 12d5967), each one reviewer on the touched hunks.Summary
CI jobs that fail on a one-off flake can now wrap their test step in
gstack-flaky run --junit <file.xml> -- <command>. It reads the runner's JUnit report, and when at most three tests failed and the runner made no retries of its own, it runs the command once more. A test that failed and then passes is a flaky pass, so the job stays green with an Actions warning, a step-summary row and a redacted ledger line. Anything the rerun cannot prove stays red: a missing, stale or malformed report, a crash, a cancelled job (latched, nothing rerun), failures the runner counts outside its JUnit, a coverage threshold, or a test the first run never reached. Playwright,bun test, jest, vitest and pytest are supported, andgstack-flaky idsprints a report's test ids.Test Coverage
Coverage audit (Step 7, at 0f8442c; the later commits added the default-scope, coverage and EACCES cases, taking
test/flaky-run.test.tsfrom 38 to 41 tests):Tests: 1534 → 1534 (+0 new) test files counted at 0f8442c;
test/flaky-run.test.tsis new on this branch.Coverage: 83% value-weighted (83% including 0 weakly covered paths)
Tests ran: remote_gate 3270
Pre-Landing Review
Pass 1 found 8 blocking findings and pass 2 found 2; all were fixed (a44dda6, 0f8442c). The final native adversarial pass found a CRITICAL false green (bun coverage threshold under a targeted rerun), fixed in a4ea2f3 and then by the whole-command default in 12d5967. Fix-check 3 on 12d5967 found nothing at the blocking floor in the default rerun-verdict logic.
REVIEW_LOOP: passes=2 blocking_found=11 deferred=0 noted=6 fixed=26 scope=frozen fix_checks=3 dispatches=14
Gate edits: 1 listed (
test/helpers/free-fixtures-data.ts: registerstest/fixtures/junit/**totest/flaky-run.test.ts), kept; no assertion, threshold or skip changed.Outside review: openai/gpt-6.1-sol adversarial pass ran (logged d5be5d78); its findings were folded into pass 2.
Base merge (2026-10-31). Merged main a305302 under GStack Minder's rule 19 grant. Every added line in the product files is byte-identical to the reviewed head c668d58; the CHANGELOG entry moved to
changelog.d/gsta158-flaky-run.md(main now uses fragments).gstack-ship-receipt carryrefused (RECEIPT_CARRY_PRODUCT_CHANGED) only because the context around thedocs/standalone-binaries.mdrow changed on main, so the receipt was rewritten at this head with the same review loop (CREW rule 30b).Review notes
Informational, not looped (CREW rule 30a):
lib/flaky-run.ts:316(inside the default logic, verdict correct): when a whole-command rerun fails because of a different test, the originally failed test is ledgered asrerun-failwithattempts=[fail,pass], and the test that failed in the rerun gets no ledger line. The run is red either way, but the daily pass sees the wrong id.bin/gstack-flaky:103: a--junitpath whose parent directory is unreadable or is a file throws EACCES/ENOTDIR and exits 1 with a stack trace instead of usage exit 2. Fails closed.test/flaky-run.test.ts:213: three tests written for the targeted path now run the default whole-command path. The opt-in scope's rerun-missing, non-zero-exit and retried cases have no test, and the title at 213 still says targeted.rerun-failand exits 1 rather thanFLAKY_COMMAND_KILLEDexit 3 (still red).test-results/and the HTML report;--junitand<name>.rerun-<n>.xmlare the record (documented).--rerun-scope testwith Playwright widens selection to every test matching the grep title in that file and project.Exploratory QA
Rerun at the final code (c668d58) on a bun fixture with the default scope. A flaky test gives
verdict=pass, exit 0 and oneflaky-passledger line. An always-red test givesrerun-fail, exit 1. A file that fails to load beside a flaky test givesFLAKY_UNREPORTED_FAILURES, nothing rerun, exit 1. Earlier at 12d5967: a Playwright 1.64.1 flaky run with the default scope passes, and bun withcoverageThreshold = 0.9, an lcov reporter and a flaky test stays red (verdict=fail, exit 1) by default.Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped.
Plan Completion
Plan /home/user/.capy/work/gstack/GSTA-158/plan-v2.md (P1 only): the implementation, docs and test items are DONE or CHANGED as approved above. The two handoff notes it named (Truther, gbrain) are now written in the crew drive. The quarantine registry (P2) and the Ubicloud reattach (P3, #3615) are separate PRs.
Documentation
Status: updated. One factual table row added; no blockers.
Scope: base 319ef50 to head 12d5967 (6 commits, 11 files) plus unstaged CHANGELOG.md. The change adds bin/gstack-flaky with lib/flaky-run.ts and lib/junit.ts, JUnit fixtures and tests. docs/flaky.md and the docs/TESTING_INTERNALS.md#flake-ledger paragraph were checked against the code. README.md, AGENTS.md, CONTRIBUTING.md, CLAUDE.md and docs/troubleshooting.md were searched for bin lists and flaky handling.
Documentation health:
gstack-flakyrow to the standalone CLI table, linking to docs/flaky.md)Coverage debt:
gstack-flakyhas reference (docs/standalone-binaries.md, docs/flaky.md) and how-to (docs/flaky.md GitHub Actions setup) coverage. It has no tutorial or explanation. docs/captain.md and docs/recommended-harness.md describe the daily flaky pass without pointing at the JUnit ledger (flake-ledger-junit.jsonl);/document-generatecould fill these gaps.Diagram drift: none; no diagrams reference the changed modules.
Test plan
gstack-pregate --stage tests --remote --spend-cap 2 --timeout 2700 --allow-repo-commands: remote_gate cleared at tree 832e118cb442, 3270 selected tests, 0 failed, $0.04; macOS and Windows lanes cleared from CI runs 41201778330 and 41201778301bun test test/flaky-run.test.tsplus the free-fixtures, module-size, bun-entry-isolation, spawnsync-timeout and state-root guards: 98 pass, 0 fail (with the changelog-fragments and version-gate-fragments tests)bun run typecheck: clean;bun run gen:skill-docs: no diff