Skip to content

v1.92.59.0 test:health and factory scorecard: leave reused main pushes out of free-suite flake counts (#3725) - #3822

Merged
capy-ai[bot] merged 3 commits into
mainfrom
capy/gsta156-flake-window
Nov 2, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
capy/gsta156-flake-window

Conversation

@garrytan

@garrytan garrytan commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3822,
  "head": "0687ba1dd59cb8e60bb74461d5292e54ba1faad0",
  "version": "1.92.39.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 57,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "a6ea2fd0e4174dc17b8806b5681e091b5a97e81b",
  "product_patch_id": "92160d92034c2990a5dd291f1b89a0e7eda52f4c",
  "gstack_version": "1.92.39.0",
  "review_depth": {
    "depth": "standard",
    "class": "code",
    "runtime_lines": 115,
    "rules": "97c1e5fe49607f73",
    "base": "a563f476793b61edbb064b853d52cb125a1996c4",
    "registry": "a563f476793b61edbb064b853d52cb125a1996c4",
    "gate_scan": {
      "tagged": 0,
      "head": "0687ba1dd59cb8e60bb74461d5292e54ba1faad0"
    },
    "reasons": [
      "runtime=115"
    ],
    "risk": []
  },
  "pregate": "requires-remote cleared @a6ea2fd0e417 (7 checks, current for 0687ba1dd59c)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41375365684",
    "pregate.json/remote_gate: remote-gate tree=a6ea2fd0e417 tests=3420"
  ],
  "issues": {
    "fixes": [
      3725
    ],
    "refs": [
      3709
    ],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CONTRIBUTING.md (132 docs files) against the 9 committed files"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 0,
    "fixed": 0,
    "scope": "frozen",
    "dispatches": {
      "specialist": 4
    }
  },
  "review_targeted": {
    "classes": [
      "gate"
    ],
    "rules": "baeb8f7ef7da92d0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "92160d92034c2990a5dd291f1b89a0e7eda52f4c",
    "status": "done",
    "findings": 2,
    "raised_by": "targeted"
  },
  "carry": {
    "from": "a8725c81d90e7f1c343a1a7465b607abaa997d39",
    "reason": "base merge + test-only change + release metadata",
    "product_patch_id": "92160d92034c2990a5dd291f1b89a0e7eda52f4c",
    "changed_paths": [
      "product:.github/workflows/free-durations-record.yml",
      "product:.github/workflows/windows-free-tests.yml",
      "product:.github/workflows/windows-setup-e2e.yml",
      "product:.github/workflows/windows-smoke.yml",
      "product:.gstack/pregate.json",
      "product:.gstack/ship-policy.json",
      "product:AGENTS.md",
      "metadata:CHANGELOG.md",
      "product:CONTRIBUTING.md",
      "product:README.md",
      "product:TODOS.md",
      "metadata:VERSION",
      "metadata:agents-digest/gstack-AGENTS.md",
      "product:autoplan/DRIVER.md",
      "product:autoplan/SKILL.md",
      "product:autoplan/bin/guard-journal.ts",
      "product:autoplan/bin/phase-publication-hook.ts",
      "product:autoplan/sections/ceo-only.md",
      "product:autoplan/sections/ceo-only.md.tmpl",
      "product:autoplan/sections/manifest.json",
      "product:bin/gstack-autoplan",
      "product:bin/gstack-autoplan-snapshot.ts",
      "product:bin/gstack-brain-sync",
      "product:bin/gstack-ceo-mode-handoff",
      "product:bin/gstack-developer-profile",
      "product:bin/gstack-doctor",
      "product:bin/gstack-doctor-components.sh",
      "product:bin/gstack-eval-plan",
      "product:bin/gstack-jsonl-merge",
      "product:bin/gstack-outside-voice",
      "product:bin/gstack-review-plan",
      "product:bin/gstack-review-scope",
      "product:bin/gstack-ship-receipt",
      "product:capy/skill/gstack/SKILL.md",
      "product:docs/TESTING_INTERNALS.md",
      "product:docs/agent-ready-errors.md",
      "product:docs/autoplan-guard-troubleshooting.md",
      "product:docs/captain.md",
      "product:docs/gbrain-sync-errors.md",
      "product:docs/gbrain-sync.md",
      "product:docs/pregate.md",
      "product:docs/review-policy.md",
      "product:docs/ship-budget.md",
      "product:docs/ship-policy.md",
      "product:docs/skills.md",
      "product:docs/support-tiers.md",
      "product:docs/troubleshooting.md",
      "product:docs/unattended.md",
      "product:eval-plan/SKILL.md",
      "product:eval-plan/SKILL.md.tmpl"
    ],
    "merge_commits": 1,
    "range_diff": "1:  a8725c81d = 1:  a8725c81d test:health and factory scorecard: leave reused main pushes out of free-suite flake counts (#3725)",
    "covers": [
      "pre-landing review",
      "adversarial review",
      "gate integrity",
      "documentation audit"
    ],
    "reruns": [
      "CI at head (gstack-ship-queue ready requires it); test and helper code changed since the reviewed head runs there unreviewed"
    ],
    "ancestry": "linear",
    "trees": [
      "b1a46eafac5948c81cc0b06c9e9c3c7768118275"
    ]
  }
}

Fixes #3725

What changed

Flake window before and after: reused main pushes no longer dilute a 10% flaky file to 4.4%

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%
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ bun test test/test-health-report.test.ts   # this branch
-$ bun test test/test-health-report.test.ts   # code at main 77fe28c39
 reused main pushes stay out of the flake window (#3725)
+  window: 2 flaky of 20 main runs that ran shards (30 reused left out)
+  test/a.test.ts rate 0.1  failing: true   <- 10%, over the 5% bar
+  detail: flaky in 2/20 main runs (10.0% > 5%); 30 reused main push(es) left out
+(pass)  test:health --enforce flags the file again
-  window: 2 flaky of 45 main runs (15 ran shards + 30 reused, no ledger)
-  test/a.test.ts rate 0.0444  failing: false   <- 4.4%, under the 5% bar
-  runs: 45  skipped: (none)
-(fail)  test:health --enforce would pass a file flaky in 10% of real runs
 

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 --enforce stops 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:health and the factory scorecard now leave those pushes out of their counts, so a flaky file is measured against runs that actually ran tests.

Summary

reuseChecker in scripts/lib/ci-history.ts is 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 its reuse job is green it's left out. readCiFlakeLedgers then fills the window with older runs, so it still holds 20 runs that ran their shards. readFreeRetries drops 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 reuse job counts exactly as before.

Blast radius

The change touches only two metrics readers: test:health (the weekly flaky-file check, --enforce) and gstack-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>/jobs through the existing injected GhClient (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.

(fail) W7a flake ledger reader > reused main pushes that ran no shards stay out of the window and its denominator; the window refills with older runs that ran shards (#3725)
-       "failing": true,
+       "failing": false,
-       "rate": 0.1,
+       "rate": 0.044444444444444446,
-   "runs": 20,
-   "skipped": 30,
+   "runs": 45,
(fail) W7a flake ledger reader > the reuse check spends at most 40 job listings; past the cap or on a failed listing a run counts as before, and the report says so
-   "skipped": 40,
(fail) factory-scorecard: recorded window > free runs that ran no shards (reused main pushes) stay out of the free-retry count and its denominator (#3725)
  expect(card.freeRuns).toEqual(clean.freeRuns)
+     "id": 8005,
+     "id": 8004,
# bun's summary on 77fe28c39: 42 passed, 3 failed

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-plan and free-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

  • untagged test/test-health-report.test.ts: fixtures for the existing widening test now give real runs a free-result-* artifact (kept: real runs always upload one; the assertions are unchanged and pass on the old code).
  • untagged test/test-health-report.test.ts: the collectHealth fixture gives run 61 a free-result-1 artifact (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

  • The reuse job is green on every main push, not only on reuse (testing and targeted readers, INFORMATIONAL; /ship's frozen policy put it in fix scope). ci-tree-reuse.ts find exits 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 whose free-plan job 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 is free-plan concluding skipped. Not fixed here because that needs a second review round, which R51 reserves for blocking findings. It's a candidate follow-up.
  • Past the 40-lookup cap, runs count as before (targeted reader, INFORMATIONAL). A capped or failed lookup counts the run as a zero-flake run, so dilution can come back once more than 40 runs with no artifacts sit in the window. The report says so, and flakeCheck still 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-window against base 77fe28c (nothing staged, unstaged or untracked), plus a repo-wide search for test:health and 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 matches scripts/lib/ci-history.ts: the reuse job, the no-artifact rule, the 40-lookup cap (REUSE_LOOKUPS_MAX) and the counted-as-before note. The pregate.md#ci-reuse link resolves.
  • docs/recommended-harness.md: Current. The Flaky events row matches readFreeRetries in lib/factory-scorecard.ts.
  • CONTRIBUTING.md: Current. The weekly test health description still holds.
  • AGENTS.md: Current. The test:health command line is unchanged.
  • docs/pregate.md: Current. Its CI reuse anchor is the link target.

Coverage debt: reuseChecker and REUSE_LOOKUPS_MAX are 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 failed
  • Failing-first: the same new tests against main 77fe28c's product code: 3 failed and 42 passed (3 failed, 42 passed; above)
  • bun run typecheck: 0 errors; bun run typecheck:test: 814 known diagnostics, none new
  • test/module-size-ratchet.test.ts, test/spawnsync-timeout-tripwire.test.ts, test/test-health-workflow.test.ts, test/bun-entry-isolation.test.ts: 23 passed
  • test/changelog-fragments.test.ts, test/version-gate-fragments.test.ts, test/ci-history-read.test.ts: 34 passed
  • Remote pregate on Ubicloud at the PR head (see receipt)

…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>
@trunk-io

trunk-io Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

😎 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
@github-actions github-actions Bot changed the title test:health and factory scorecard: leave reused main pushes out of free-suite flake counts (#3725) v1.92.59.0 test:health and factory scorecard: leave reused main pushes out of free-suite flake counts (#3725) Nov 2, 2026
@capy-ai
capy-ai Bot merged commit d7154db into main Nov 2, 2026
55 checks passed
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.

test:health flake rate counts reused main pushes that ran no shards (after #3709)

1 participant