Repository navigation
v1.92.59.0 test:health and factory scorecard: leave reused main pushes out of free-suite flake counts (#3725) - #3822
Merged
Merged
Conversation
…ee-suite flake counts (#3725) A main push that reused its merged PR's verified run (#3709) runs no shards and uploads nothing, so both readers counted it as a zero-flake run and diluted real flake rates under the 5% bar. reuseChecker (scripts/lib/ci-history.ts) marks a run with no artifacts and a green reuse job; readCiFlakeLedgers leaves it out and refills the window, readFreeRetries leaves it out of the free-retry count. One capped job listing per artifact-less run (40 per read); past the cap or on a failed listing the run counts as before, with a note. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> # Conflicts: # test/test-health-report.test.ts
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.
Fixes #3725
What changed
Flake window before and after: reused main pushes no longer pull a file that's flaky in 10% of real runs down to 4.4%, under the 5% bar.
Before/after as text: Flake window before and after: reused main pushes no longer dilute a 10% flaky file to 4.4%
Why
The issue (#3725) says "As reuse becomes common, those empty runs fill the window, real flake rates drop below the 5% bar, and
bun run test:health --enforcestops flagging files without any error." Since #3709, a main push that reuses its merged pull request's run finishes green but runs no shards and uploads no flake ledger.test:healthand the factory scorecard now leave those pushes out of their counts, so a flaky file is measured against runs that actually ran tests.Summary
reuseCheckerinscripts/lib/ci-history.tsis the one rule both readers use. A run with any artifact counts and costs no extra call. A run with no artifacts costs one job listing, and when itsreusejob is green it's left out.readCiFlakeLedgersthen fills the window with older runs, so it still holds 20 runs that ran their shards.readFreeRetriesdrops the run from the free-retry count. Both reports say how many runs they left out.I chose to leave these runs out rather than pull the ledgers of the reused PR runs. Leaving them out needs no extra downloads, and it keeps "main runs" meaning runs of main. Missing artifacts alone isn't a safe signal, because before about Sept 25 gstack's clean main runs uploaded nothing (run 35303828208, for example), and the scorecard reads other repositories, whose free workflows may upload nothing either. A run with no
reusejob counts exactly as before.Blast radius
The change touches only two metrics readers:
test:health(the weekly flaky-file check,--enforce) andgstack-factory-scorecard. Neither is a merge check, and they handle no user data, money or secrets. I ran the old and new code over the same fake GitHub data (test/test-health-report.test.ts,test/factory-scorecard.test.ts, 57 tests passed).Network calls (security read): the only new call is a read-only
GET repos/<repo>/actions/runs/<id>/attempts/<n>/jobsthrough the existing injectedGhClient(listRunJobs). It happens only for a run with no artifacts and is capped at 40 per read (REUSE_LOOKUPS_MAX). Past the cap, or when a listing fails, the run counts as it did before, and the report adds "N run(s) with no artifacts not checked for main-push reuse (); counted as before #3725". There are no new spawns, environment reads, workflow edits, permission changes or dependencies.Approvals
No approvals recorded for branch capy/gsta156-flake-window. This is a Captain-directed fix of a diagnosed issue, so it's exempt from the plan step (GStack Minder CREW.md, "Fix-lane exemption").
Test Coverage
All new code paths have test coverage: each of the 3 changed runtime files has a changed test that names it (
Coverage: deterministic).Failing-first proof. I ran the new tests against the code at main 77fe28c (the three product files stashed, this PR's tests and fixtures in place): 3 tests failed and 42 passed.
With the fix, all 57 tests passed. The flake rate is 2/20 (10%, flagged), the same as the rate over real runs alone, and the scorecard's free runs equal the clean fixture's runs exactly.
Fixtures. The existing fixtures modeled real main runs as having no artifacts. Real runs always upload
free-planandfree-result-*now, so I gave those runs one artifact instead of sending them through the lookup path. Their assertions are unchanged and still pass on the old code.Tests ran: focused 57
Pre-Landing Review
There are 2 informational findings and no blocking ones. This is one round with two readers on the final diff: a batched specialist (testing, security and state-machines checklists) and the targeted gate reader that /ship dispatches at every depth. Per R51 and the lane brief (metrics tooling, one round, no second round without a blocking finding), nothing below the floor was looped. Both findings are listed under Review notes.
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=0 fixed=0 scope=frozen
Gate edits: 4 listed, 2 read, 2 findings — 2 kept (reasons below), 0 restored, 0 open
test/test-health-report.test.ts: fixtures for the existing widening test now give real runs afree-result-*artifact (kept: real runs always upload one; the assertions are unchanged and pass on the old code).test/test-health-report.test.ts: the collectHealth fixture gives run 61 afree-result-1artifact (kept: the same reason;toStartWith('50.0% (1/2 main runs')is unchanged).Outside review: not dispatched (R51 lightest depth for metrics tooling; one round).
Review notes
reusejob is green on every main push, not only on reuse (testing and targeted readers, INFORMATIONAL; /ship's frozen policy put it infixscope).ci-tree-reuse.ts findexits 0 on a refusal too. So for runs after v1.92.39.0 ci: main pushes reuse the merged PR's verified run of the same tree; dispatch-ci and --from-run go through the run verifier (GSTA-156 P3b) #3709, the rule in practice is "no unexpired artifacts". A non-reused push whosefree-planjob failed before its upload would also be left out, and labeled a reused push. It ran no shards and holds no ledger, so leaving it out is still correct; only the label is wrong. The tighter marker isfree-planconcludingskipped. Not fixed here because that needs a second review round, which R51 reserves for blocking findings. It's a candidate follow-up.flakeCheckstill passes. The lane brief set this on purpose: extra lookups fail toward today's behavior with a visible note.Eval Results
No prompt-related files changed — evals skipped.
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.
Issues
Fixes #3725
Refs #3709
TODOS
No TODO items completed in this PR.
Documentation
Status: current. The docs already describe the change accurately and need no edits.
Scope: the 9 committed files on
capy/gsta156-flake-windowagainst base 77fe28c (nothing staged, unstaged or untracked), plus a repo-wide search fortest:healthand free-retry docs.Documentation health
docs/TESTING_INTERNALS.md: Current. The branch's new paragraph on leaving reused main pushes out of the flake window matchesscripts/lib/ci-history.ts: thereusejob, the no-artifact rule, the 40-lookup cap (REUSE_LOOKUPS_MAX) and the counted-as-before note. Thepregate.md#ci-reuselink resolves.docs/recommended-harness.md: Current. The Flaky events row matchesreadFreeRetriesinlib/factory-scorecard.ts.CONTRIBUTING.md: Current. The weekly test health description still holds.AGENTS.md: Current. Thetest:healthcommand line is unchanged.docs/pregate.md: Current. Its CI reuse anchor is the link target.Coverage debt:
reuseCheckerandREUSE_LOOKUPS_MAXare internal helpers, and the docs explain the behavior they change; no critical gaps. Diagram drift: none.Test plan
bun test test/test-health-report.test.ts test/factory-scorecard.test.ts test/ci-history-read.test.ts: 57 passed, 0 failedbun run typecheck: 0 errors;bun run typecheck:test: 814 known diagnostics, none newtest/module-size-ratchet.test.ts,test/spawnsync-timeout-tripwire.test.ts,test/test-health-workflow.test.ts,test/bun-entry-isolation.test.ts: 23 passedtest/changelog-fragments.test.ts,test/version-gate-fragments.test.ts,test/ci-history-read.test.ts: 34 passed