From 0520923786a1bd35deae84e26e798e850d26c074 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 10 Nov 2026 17:23:20 +0100 Subject: [PATCH] fix(ci): test-health keeps unfinished files in the rotation and small packages share a batch A finding deferred for budget or proof used to mark its file audited for the whole re-audit window, so the slowest, flakiest files dropped out of the rotation with their prepared fixes stranded on one machine (#3852). A deferred finding now says why (`deferredFor`); a file whose latest audit deferred work for budget or proof is `unfinished`, stays eligible ahead of never-audited files, and its next brief lists those findings. `record cluster --wip` stores an unproven test-only fix on the ledger ref under wip/, size-capped, and the brief copies it into the next run. The report counts unfinished files and deferrals by reason, and the skill lets a run prove a written fix past its budget, up to a cap. Packages with at most `smallPackageFiles` test files now share one group, `small` (#3854). A run, a batch and a push shard stay inside one group, while a cluster still stays inside one package. A batch record from before groups reads as its package's group, and a package that is small now continues that batch as the small group's. Closes #3852 Closes #3854 Co-Authored-By: Claude Opus 5.5 --- .agents/skills/test-health-push/SKILL.md | 13 +- .agents/skills/test-health/SKILL.md | 51 +++-- .../test-health/references/failure-issues.md | 4 +- .../skills/test-health/references/landing.md | 20 +- .../test-health/references/worksheet.md | 35 +++- docs/decisions/test-health.md | 23 ++- scripts/skill-tests/test-health-batch.test.ts | 9 +- scripts/skill-tests/test-health-cli.test.ts | 174 ++++++++++++++++-- .../skill-tests/test-health-ledger.test.ts | 17 ++ .../skill-tests/test-health-select.test.ts | 151 +++++++++++++-- .../skill-tests/test-health-worksheet.test.ts | 15 +- scripts/test-health.ts | 120 ++++++++---- scripts/test-health/batch.ts | 23 ++- scripts/test-health/catalog.ts | 14 ++ scripts/test-health/config.json | 3 + scripts/test-health/config.ts | 11 +- scripts/test-health/ledger.ts | 77 ++++++-- scripts/test-health/report.ts | 16 +- scripts/test-health/select.ts | 118 ++++++++---- scripts/test-health/worksheet.ts | 11 +- 20 files changed, 746 insertions(+), 159 deletions(-) diff --git a/.agents/skills/test-health-push/SKILL.md b/.agents/skills/test-health-push/SKILL.md index 7d8327d84d..02222624af 100644 --- a/.agents/skills/test-health-push/SKILL.md +++ b/.agents/skills/test-health-push/SKILL.md @@ -52,8 +52,10 @@ Call it `EPIC` below: `origin/epic/-test-health`. TH shards --profile push --base EPIC --count --tag e --out ``` -Each shard is a list of files inside one package, weighted by cost, so every -package with work gets at least one and the count is a target. Shards are +Each shard is a list of files inside one group, weighted by cost, so every +group with work gets at least one and the count is a target. A group is a large +package, or `small`: the packages with few test files share shards and batches +rather than each opening a pull request of its own. Shards are disjoint by construction, and the ledger's claims keep two workers on one shard from colliding. @@ -70,8 +72,8 @@ own worktree. A worker's whole brief is: Do not give a worker any audit guidance of your own. The `push` profile in `scripts/test-health/config.json` already changes what scale requires: no file -budget per run, longer claims, and a batch that is ripe only when its shard is -exhausted. +budget per run, longer claims, and a batch that is ripe only when its group +has nothing left to audit. When a worker finishes, start the next shard. A worker that stops early leaves its claims to expire; start its shard again and the new worker continues the @@ -144,7 +146,8 @@ squashes. runs get; say so, and do not claim more. - Close the epic when its pull request has merged and main's own run is green. The recurring run continues from the ledger: everything audited here is - already marked, so it picks up only new, changed and dropped files. + already marked, so it picks up only new, changed, dropped and unfinished + files. ## When to stop early diff --git a/.agents/skills/test-health/SKILL.md b/.agents/skills/test-health/SKILL.md index f7ddf9c795..87432d5351 100644 --- a/.agents/skills/test-health/SKILL.md +++ b/.agents/skills/test-health/SKILL.md @@ -6,8 +6,10 @@ description: Audit a batch of brain-kit's automated tests in depth and fix the w # Keep the tests healthy One invocation is **one run**. A run audits a few clusters of related tests -inside one package, commits each proven fix to that package's batch branch, -lands the batch when it is ripe, and records what it did. Coverage of the whole +inside one group, commits each proven fix to that group's batch branch, lands +the batch when it is ripe, and records what it did. A group is a package of its +own, or `small`: the packages with few test files, which share one batch. A +cluster always stays inside one package. Coverage of the whole suite comes from running this again and again: the planner picks different files every time and reaches all of them eventually. @@ -45,7 +47,7 @@ start: a run reads a great deal, and most of it can be avoided. - `capabilities.browserRunner: false`: add `--bun-only` to `plan`. - `capabilities.mayLand: false`: audit, but skip step 6. 2. **Plan.** `TH plan`. It claims the files it gives you. Note `runId`, - `runDir`, `package`, `batch` and `clusters`. + `runDir`, `group`, `batch` and `clusters`, each with its `package`. - `throttled` is set: too much is waiting to land. Go to step 6, then record the run with `--outcome throttled`. - `clusters` is empty: go to step 6, then record `--outcome nothing-to-do`. @@ -69,6 +71,21 @@ start: a run reads a great deal, and most of it can be avoided. budget you were given is spent (45 minutes if none was given). A cluster you did not finish is simply not recorded; its claim expires. + **Proof outlasts the budget.** A fix you have already written is proven even + when that runs past the budget, by up to `proofOverrunMinutes` in + `scripts/test-health/config.json`, before you take any new cluster. When a + brief lists findings deferred by an earlier audit, resume them first: apply + the prepared patch it names (`git apply `) and run its proof before + anything else in that cluster. If the proof still cannot finish, keep the + fix for the next run instead of losing it: + + ```sh + git diff -- > /wip-.patch && git checkout -- + ``` + + defer the finding with `deferredFor: "proof"`, and pass + `--wip /wip-.patch` to `record cluster`. + 1. `TH brief --run --cluster ` (Markdown). Read every member file completely, and the source it exercises. Read context files only to judge overlap. @@ -88,7 +105,8 @@ start: a run reads a great deal, and most of it can be avoided. `TH validate /cluster-.json --run ` until it is `ok`. A problem it reports is a missing proof, not a formatting chore. 7. If you changed anything, commit exactly this cluster's files, with the - trailer from the brief as the last line of the message: + trailer from the brief as the last line of the message and the cluster's + package from the brief in the subject: ```sh git add @@ -96,7 +114,8 @@ start: a run reads a great deal, and most of it can be avoided. ``` 8. `TH record cluster --run --cluster --worksheet /cluster-.json`, - adding `--commit HEAD` when you committed. + adding `--commit HEAD` when you committed and `--wip ` when you + kept an unproven fix. 5. **Push** the batch branch: `git push -u origin `. Do not open a pull request here. @@ -109,8 +128,8 @@ start: a run reads a great deal, and most of it can be avoided. read that smell's rule in the authoring guide. If the rule would not have prevented what you saw, sharpen it or add the example, in the batch. If the smell is mechanical, file an issue proposing a lint check. -9. Report in a few lines: package, clusters audited, findings by status, what - landed, and anything a human must decide. +9. Report in a few lines: group and packages, clusters audited, findings by + status, what landed, and anything a human must decide. | Order | Lens | Reference | | --- | --- | --- | @@ -133,8 +152,15 @@ test and agree something is wrong. | The signal is fine in context (the weak matcher is the whole claim, the timer is a failure cap) | `none` | `accepted`, with the reason in the note | | You can fix it inside this cluster's member files, and can produce the proof the reference names | the fixing action | `fixed` | | The fix needs product code, a timeout or deadline, shard or selection rules, a workflow, or a test file outside this cluster | `file-issue` | `filed`, with the issue number | -| The file is context (another package), or you ran out of budget, or the proof would not come out | the action you would take | `deferred` | -| An open issue on the file is assigned to someone | comment your evidence on the issue | `deferred` | +| You ran out of budget before writing the fix | the action you would take | `deferred`, `deferredFor: "budget"` | +| The fix is written, but its proof would not come out within the overrun | the action you would take | `deferred`, `deferredFor: "proof"`, with the fix kept through `--wip` | +| The file is context (another package) | the action you would take | `deferred`, `deferredFor: "context"` | +| An open issue on the file is assigned to someone | comment your evidence on the issue | `deferred`, `deferredFor: "assigned"` | +| An open failure issue did not reproduce | comment what you ran on the issue | `deferred`, `deferredFor: "unreproduced"` | + +`budget` and `proof` leave the work unfinished: the file stays in the +rotation (in the worst-first queue it ranks ahead of a never-audited file with +the same score), and the next run's brief lists these findings and the patch. Every other reason marks the file audited. When two actions fit, take the smaller one. Strengthening an assertion beats rewriting a test; rewriting beats removing it. @@ -198,7 +224,7 @@ TH signals TH measure [--runs ] [--shuffle] [--together] [--stress] --out TH mutate --test [--name ""] --expect "" --from-worktree --out TH validate --run -TH record cluster --run --cluster --worksheet [--commit ] +TH record cluster --run --cluster --worksheet [--commit ] [--wip ] TH record run --run --outcome completed|throttled|blocked|nothing-to-do|failed --agent