From e4e35467cb8e43830afabfc52d8571c71bcafd14 Mon Sep 17 00:00:00 2001 From: garrytan Date: Tue, 3 Nov 2026 08:43:48 +0000 Subject: [PATCH] gstack-evidence: sum bun --shard processes in a lane's tests_ran; docs: dispatch-carry warning and record-ci recheck order (GBEV-3, GSTA-258 L6 follow-up) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- bin/gstack-evidence | 29 ++++++++++++++++-------- changelog.d/gsta258-l6-carry-followup.md | 6 +++++ docs/pregate.md | 23 +++++++++++++++---- test/evidence.test.ts | 13 +++++++++++ 4 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 changelog.d/gsta258-l6-carry-followup.md diff --git a/bin/gstack-evidence b/bin/gstack-evidence index e3d2bbab1..49af08f54 100755 --- a/bin/gstack-evidence +++ b/bin/gstack-evidence @@ -37,7 +37,9 @@ * the tail is the stdout tail then the stderr tail, so a line's position says * nothing about when it was printed across streams, and bun's own counts (on * stderr) would otherwise outrank a 10k-test run whichever of the two ran - * first. Any summary when it did not speak follows the last-summary-wins rule; + * first. Any summary when it did not speak follows the last-summary-wins rule, + * except that a complete set of `bun test --shard=i/N` processes ending the log + * is summed (GBEV-3); * anything else is "unknown". * Three states, never merged: * a count, 0 (ZERO-RUN, graded like STALE by `check`) and unknown (non-blocking). @@ -169,7 +171,10 @@ const count = (text: string, word: string): number => Number(new RegExp(`(\\d+) /** * Bun: the last "Ran N tests across M files" block; executed = its " N pass" + - * " N fail" lines. Bun always prints that counts block (" 0 pass" / " 0 fail" + * " N fail" lines. When that block ends a `bun test --shard=i/N` process (bun's + * "--shard=i/N: running" line since the previous block), the blocks of the N + * distinct shards that end the log are summed (a sharded runner prints every + * shard, GBEV-3); an incomplete or repeated shard set counts the last block alone. Bun always prints that counts block (" 0 pass" / " 0 fail" * even for an all-skip or empty run), so a terminal line with no " N pass" * above it is a line gstack's quiet shard runner forwarded (it forwards the * terminal line without the " N pass" line), not a bun summary: @@ -186,7 +191,9 @@ async function bunTestsRan(lines: string[]): Promise<{ at: number; ran: number } } catch { warn("shard-engine classifier not importable; using the built-in bun summary parser"); } - for (let i = lines.length - 1; i >= 0; i--) { + const blocks: { at: number; ran: number; shard?: string }[] = []; + let since = 0; + for (let i = 0; i < lines.length; i++) { if (!isTerminal(lines[i])) continue; let pass: number | null = null; let fail = 0; @@ -197,13 +204,17 @@ async function bunTestsRan(lines: string[]): Promise<{ at: number; ran: number } if (p) pass = Number(p[1]); if (f) fail = Number(f[1]); } - if (pass === null) { - if (/^Ran 0 tests? across/.test(lines[i])) return { at: i, ran: 0 }; - continue; - } - return { at: i, ran: pass + fail }; + const shard = lines.slice(since, i).map((l) => /^--shard=(\d+\/\d+): running /.exec(l)?.[1]).findLast(Boolean); + since = i + 1; + if (pass !== null) blocks.push({ at: i, ran: pass + fail, shard }); + else if (/^Ran 0 tests? across/.test(lines[i])) blocks.push({ at: i, ran: 0 }); } - return null; + const last = blocks.at(-1); + if (!last) return null; + const total = Number(last.shard?.split("/")[1] ?? 1); + const set = blocks.slice(-total); + const complete = total > 1 && set.length === total && new Set(set.map((b) => b.shard)).size === total && set.every((b) => b.shard?.endsWith(`/${total}`)); + return { at: last.at, ran: complete ? set.reduce((n, b) => n + b.ran, 0) : last.ran }; } /** diff --git a/changelog.d/gsta258-l6-carry-followup.md b/changelog.d/gsta258-l6-carry-followup.md new file mode 100644 index 000000000..68fdcc712 --- /dev/null +++ b/changelog.d/gsta258-l6-carry-followup.md @@ -0,0 +1,6 @@ +- A lane whose command runs several `bun test --shard=i/N` processes now records the sum of the shards' counts, not the last shard's (GBEV-3, gbrain-evals#317: 3336 recorded against 6,095 run across 2 shards). The sum needs one block from each of the N distinct shards at the end of the log; an incomplete or repeated set records the last summary as before, so a command that runs a suite twice still reports its last run. +- docs/pregate.md#dispatch-carry warns that a `workflow_dispatch` run reports under the same job names on the head commit, so without strict branch protection a green dispatch run can hide a red merge-commit check. It recommends strict protection or distinct job names for dispatch runs, and notes that gstack's own merge trains test the merged tree. +- docs/pregate.md#skipped-files names the order of record-ci's checks after a skipped-file remainder, including the final `tree_changed` recheck. + +### Tests +- `test/evidence.test.ts`: two `--shard=i/2` processes in one log record 6095, and an incomplete or repeated shard set records the last summary. The sum case fails without the change (it recorded 3336). diff --git a/docs/pregate.md b/docs/pregate.md index 32d0976f7..b3e78f48b 100644 --- a/docs/pregate.md +++ b/docs/pregate.md @@ -762,10 +762,12 @@ once: such as `"per_file": "bun test --timeout=30000 {files}"`, the same form as the tests stage's `runner`). That run is recorded under `