Skip to content

fix(ci): test-health keeps unfinished files in the rotation and small packages share a batch - #3856

Merged
schlessera merged 7 commits into
mainfrom
fix/3852-test-health-unfinished-and-groups
Nov 11, 2026
Merged

schlessera merged 7 commits into
mainfrom
fix/3852-test-health-unfinished-and-groups

Conversation

@schlessera

@schlessera schlessera commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Closes #3852
Closes #3854

What changed

#3852. A deferred finding now says why, in deferredFor (budget, proof, assigned, unreproduced or context), and validate refuses a deferred finding without one. A file whose latest audit deferred work on that file for budget or proof is unfinished, not fresh. It stays eligible in both queues, and in the hot queue it ranks ahead of a never-audited file with the same score. A record from before this change, with no deferredFor, counts as budget unless its smell is unreproduced. record cluster --wip <patch> stores an unproven test-only fix on the ledger ref as wip/<runId>-<n>.patch. The size is capped by wipMaxBytes, and git apply --numstat parses the patch, so every path Git would apply must pass the batch gate's path rule. The next brief for the file lists the earlier deferred findings and copies the patch into its run directory. report counts unfinished files and deferrals by reason. The skill lets a run prove a fix it has already written past its time budget, up to proofOverrunMinutes, before it takes a new cluster.

#3854. A package with at most smallPackageFiles test files (default 25, counted over the profile's tiers) belongs to the shared group small. Every other package is a group of its own. A run, a batch and a push shard stay inside one group, while a cluster still stays inside one package. The plan and the brief name the group and each cluster's package. batch status counts what is left in the group. A batch record from before groups names only its package and reads as that package's group, and a package that is small now continues that batch as the small group's. The decision record, both skills, landing.md and failure-issues.md describe the change.

Why this shape

  • Both issues change planRun, and ci: small packages share one test-health batch instead of landing one pull request each #3854 says to land them one after the other. One pull request does that and pays one hosted closure.
  • Sweep order. An unfinished file keeps its normal place in the sweep queue: never-audited files first, then the oldest audit. It does not jump the queue. Review showed that unconditional precedence would let a file deferred again and again take every run, sweep runs included, so the long tail would never be reached. The issue asks only for eligibility in both queues, plus precedence at an equal score in the hot queue.
  • Patch attached to the file it resumes. A prepared patch belongs to the unfinished files of its record as well as to the files it touches, so a fix that changes only a shared helper is still found from the deferred test file.
  • The name small is reserved. A package literally named small is refused with a clear message rather than silently merged into the shared group.
  • Shards resolve their group at plan time. A shard written before groups, or one used under --bun-only, still plans its files.
  • Tests pin the threshold. Io.config lets the CLI test fixture set its own threshold, so the existing tests exercise one large and one small package.

Proof

Failing first. The new tests were copied into a worktree at origin/main (7f1c158, before this change), and each targeted test failed on an assertion, not on module load:

Test Failed at
select: a sweep of the small group takes clusters from several packages packages set has 1 package, not 3
select: a file whose audit deferred a finding for budget is planned again toContain(bow.test.ts)
select: a record shaped like th-20261110115220-5ecaed#0 states read fresh, fresh, fresh, not unfinished, fresh, fresh
cli: a second plan continues the open small batch [group, package, batch]
cli: a batch opened before groups is continued [group, batch.id, isNew]
cli: record cluster --wip stores the patch, the brief resumes from it toMatchObject({ wip })
cli: the report counts unfinished files [unfinished, auditedCurrent, byDeferredFor]

The select file imports the new groupsOf, which main lacks, so that one import was stubbed to let the file load. The stub throws only in the shards describe, which these tests do not use.

Mutations. 16 mutations, each one killed by its named test on an assertion line, with the tree restored clean after each:

Guard Mutation Test that failed
unfinished state ? "fresh" : "fresh" deferred for budget is planned again
legacy deferral default ?? "unreproduced" th-20261110115220-5ecaed#0 replay
cluster stays in its package drop the package check sweep of the small group
shards by group group = package small packages share a shard
legacy batch resolves its group batch.group === group batch opened before groups
deferred needs a reason check off a deferred finding says why
wip is test code only check off a patch that touches anything but test code
remaining counts the group package equality small group unfinished while any package has work
hot tie: unfinished first drop the tie-break ranks ahead of a never-audited file
brief lists deferred empty list brief resumes from the patch
every patch record checked check the first record only the mixed traditional-diff patch is refused
shard group resolved no resolveGroup a shard written before groups
helper-only patch attached files-touched only patch that changes only a helper
sweep keeps its order unfinished first in the sweep sweep keeps its oldest-audit order
reserved group name check off a package named like the shared group
small batch waits for its group exhausted = true small batch ripens only once every package is done

Live checks, dry runs against the real ledger at the first head (052092378) with nothing claimed or written:

  • TH plan --dry-run --package ui-react --mode hot: cluster 0's seed is packages/ui-react/tests/browser/hygiene-review.layout.tsx, and stats.unfinished is 1.
  • TH plan --dry-run --mode sweep continues the open ui-react batch, as a run always does, so it shows no small packages while that batch is open. The grouping was checked through the push path instead. TH shards --profile push --count 24 gives one small shard of 100 files across 12 small packages, where before each would have had its own shard. TH plan --dry-run --profile push --shard <small shard> plans 45 clusters from all 12 packages, in group small.

Suites. bun run test:skills: 262 pass, 0 fail. bun run lint is clean. The whole-repo tsc --noEmit ran out of memory locally, so a scoped tsc over scripts/test-health* and its tests was run instead, and was clean before the test call sites were updated. The tests then exercise every call site.

Base refresh. Main gained #3735 (ui-react/ui-sdk/ui-server, no file in common), merged in at c0d45d9ed; check:pr rerun on that head, receipt below.

Review. An independent gpt-6-astra review raised 7 findings. All were checked and fixed in this head, and each fix has a test and a mutation above. The fixes are the traditional-diff --wip bypass, shard group resolution, helper-only patches, sweep starvation, the reserved name small, a weak ripeness test, and the proof-overrun rule missing from the worksheet reference. A further wording fix in the push skill says a batch ripens when its group, not its shard, is exhausted.

bun run check:pr --base origin/main
{"version":1,"kind":"brain-check-pr-receipt","head":"dcb137c392fd6a740ecee0a6733ab2fec5667021","base":"origin/main","mode":"focused","startedAt":"2026-11-11T03:03:50.438Z","finishedAt":"2026-11-11T03:05:14.596Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":10334.362367000002},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":132.26624999999876},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":97.13472700000057},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":16.897360999999364},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":73492.598489}]}

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see. (Repository tooling only; check:pr asked for none.)
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved. (Nothing moved: the plan's JSON is read only by the skills.)
  • Docs under docs/ reflect the change, or nothing documented moved.
  • A fail-closed guard added or changed answers the proportionate-containment checklist in this body, or no guard changed. (The --wip refusal stops one record cluster call, records nothing, and names the offending path. The reserved-name refusal stops planning only, names the package and the fix, and touches no state.)
  • Provider history stays append-only (docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.

Anything left open

Nothing. The test-health push stays paused: the maintainer asked for only these two issues in this session.

🤖 Generated with Claude Code

… 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 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 10, 2026
@schlessera schlessera added type: fix Something is broken and must behave the way it is documented. area: ci CI workflows, the gates they run, release scripts, packaging. labels Nov 10, 2026
@schlessera

Copy link
Copy Markdown
Owner Author

Collisions at head 052092378 (bun scripts/collisions.ts --json --pr 3856): no path collision. 19 proof-closure overlaps with open pull requests that share root tooling (#3054, #3056, #3059, #3069, #3116, #3393, #3437, #3464, #3581, #3622, #3662, #3726 and others), as expected for scripts/ changes.

@schlessera

Copy link
Copy Markdown
Owner Author

Implementation is complete in #3856 (head 1fdfc6e49, which merged main at b77987afb) and the pull request is ready. It has not merged yet. Main went red at b77987afb (#3805; incident #3884, whose fix #3899 is in the integration lane now). One candidate confirmation on this head was cancelled by that red-main gate before its proof ran. Two earlier attempts were refused before acquiring a lease: the lane was busy, and the pull request's base had gone stale.

Done so far:

  • bun run test:skills: 262 pass. bun run lint is clean. A check:pr receipt for the current head is in the PR body.
  • Failing-first receipts on the pre-change tree for every planner and CLI test the acceptance criteria name.
  • 16 mutations, each killed by its named test.
  • An independent review (gpt-6-astra); all seven of its findings are fixed with tests.
  • Live dry runs against the ledger. hygiene-review.layout.tsx is the first seed of plan --package ui-react --mode hot. A push shard set puts 12 small packages in one small shard.

To resume, once bun scripts/integrate.ts main-status --json reports "red": false:

  1. Merge origin/main into the branch.
  2. Rerun bun run check:pr --base origin/main and replace the PR body's receipt.
  3. Push.
  4. Run bun scripts/integrate.ts confirm 3856 --issues schlessera/brain-kit#3852,schlessera/brain-kit#3854.

The milestone is 0.45.0 on the pull request and on both issues.

@schlessera
schlessera marked this pull request as draft November 10, 2026 22:44
@schlessera
schlessera marked this pull request as ready for review November 10, 2026 22:44
@schlessera
schlessera marked this pull request as draft November 11, 2026 03:06
@schlessera
schlessera marked this pull request as ready for review November 11, 2026 03:06
@schlessera
schlessera merged commit 567576f into main Nov 11, 2026
39 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, the gates they run, release scripts, packaging. type: fix Something is broken and must behave the way it is documented.

Projects

None yet

1 participant