perf(fold): run the whole-tree checks once, on the tip #263

Merged
claudiomaradonna merged 3 commits from windmill-implement/261-4123 into main 2026-11-28 10:13:49 +01:00
Collaborator

Why

fold-branch folds a branch's fixups into the commits they correct
before a push, pull request, or merge, and runs the every-commit checks
of the Quality gates at each replayed commit. Issue #261 reports that a
small edit on a branch of several commits can wait a long time for that
fold. The reason is in the check list: three of this source's four
every-commit checks — bash tests/verify-agent-config.sh,
.agents/hooks/shellcheck.sh repo, and prettier --check '**/*.md' —
read the whole tree rather than the commit's own diff, so each costs the
same whatever the commit changes. Measured on main, that is 24s, 8.7s,
and 1.0s, about 34s per replayed commit, so the wait followed the
branch's commit count rather than the size of the edit. A fold leaves the
tree exactly as the tip's, so those three prove at each commit only what
they prove at the tip, where verify-execution already runs them.

Closes #261

What changed

The fold now runs its every-commit checks at two points. The --exec of
step 2's rebase carries only the checks that read the replayed commit's
own diff — here git diff --check HEAD^ — so a commit that brings a
whitespace error into its own diff still stops the fold, as before. A new
step 4 runs the rest once, on the folded tip, before the skill's Done is
met. A fold of several commits now pays one whole-tree run instead of one
per commit, and the fold's own Done counts that run, so a fold that
skipped it is not done.

docs/MAINTENANCE.md's fold paragraph now names the two groups, each in
its own block, and is where the new test reads them from, so the document
and the skill cannot drift apart in a way that silently loses a check.
recovery.md's second case is named for the run whose check failed, its
third for the step whose checks it answers, and step 4 answers its own
failing check in place: the fold left the tree as it was, so the branch
holds the failure, and no push, pull request, or merge follows it.

Two things are unchanged and worth stating, since a reviewer might
otherwise read the change as a weakening of the gate: the whole-tree
verdict for the state a remote is asked to land is still enforced, once
on the folded tip and again in verify-execution's final run, and
.forgejo/workflows/maintenance.yml still runs every check of the Checks
section on every pull request. AGENTS.md is untouched.

How to verify

From a fresh checkout of this branch, with the tests run as a non-root
user from the repository root:

bash tests/agent-config/real-source.sh

All 12 pass. Two of them are new, and both fail on the main branch's
code, which is what a feature's regression test must do; the pin added
before the code passes on both. To see the failure, build a worktree of
the base and run the branch's test file against it:

git worktree add --detach /tmp/fold-base d7893e2
cp tests/agent-config/real-source.sh tests/agent-config/lib.sh \
  /tmp/fold-base/tests/agent-config/
( cd /tmp/fold-base && bash tests/agent-config/real-source.sh )

There the two new tests fail: "docs/MAINTENANCE.md holds the fold's
checks in the group of each point it runs them at", and "the fold of
fold-branch runs its whole-tree checks once, on the folded tip, and not
at each replayed commit", which folds a fixture branch whose base tracks
a file no commit of the branch touches and asserts that the fold
finishes on the branch while the tip's run reports the breakage. The pin,
"the fold of fold-branch stops at a replayed commit whose own diff is not
whitespace-clean", passes there and here.

The change's own fold exercised the rule it changes: its --exec ran
git diff --check HEAD^ at three replayed commits in 0.043s, then step 4
ran the whole-tree group once on the folded tip in 39.8s, where the rule
it replaces paid about 34s three times.

Checks run on the tip, all passing with a clean working tree:
bash tests/verify-agent-config.sh (361 tests),
bash tests/check-work-folder.sh (46 tests),
.agents/hooks/shellcheck.sh repo (51 files clean),
prettier --check '**/*.md', scripts/verify-agent-config.sh, and
git diff --check main. bash .agents/scripts/check-work-folder.sh --verified on the work folder prints nothing.

Considerations

An intermediate commit that breaks a whole-tree check and is fixed before
the tip now folds without a word, so git bisect across a branch's
commits can stop at a state that fails them. That is the cost of the
change, accepted for the report it answers: the state a remote is asked
to land, the tip, keeps every check, and CI keeps running all of them on
every pull request.

The per-commit run of the whole-tree checks is what a later edit could
drop by mistake, so it is pinned rather than trusted: the new test
extracts the skill's <whole-tree checks> command and the two groups from
docs/MAINTENANCE.md and runs both, so dropping step 4 or moving a
whole-tree check back into --exec fails the suite.

Left out of scope, as the work file records: making
tests/verify-agent-config.sh itself quicker, and scoping Prettier and
ShellCheck to the files a commit changes, which needs a file-list mode
neither has and would still leave the dominant cost reading the whole
configuration.

## Why `fold-branch` folds a branch's fixups into the commits they correct before a push, pull request, or merge, and runs the every-commit checks of the Quality gates at each replayed commit. Issue #261 reports that a small edit on a branch of several commits can wait a long time for that fold. The reason is in the check list: three of this source's four every-commit checks — `bash tests/verify-agent-config.sh`, `.agents/hooks/shellcheck.sh repo`, and `prettier --check '**/*.md'` — read the whole tree rather than the commit's own diff, so each costs the same whatever the commit changes. Measured on `main`, that is 24s, 8.7s, and 1.0s, about 34s per replayed commit, so the wait followed the branch's commit count rather than the size of the edit. A fold leaves the tree exactly as the tip's, so those three prove at each commit only what they prove at the tip, where `verify-execution` already runs them. Closes #261 ## What changed The fold now runs its every-commit checks at two points. The `--exec` of step 2's rebase carries only the checks that read the replayed commit's own diff — here `git diff --check HEAD^` — so a commit that brings a whitespace error into its own diff still stops the fold, as before. A new step 4 runs the rest once, on the folded tip, before the skill's Done is met. A fold of several commits now pays one whole-tree run instead of one per commit, and the fold's own `Done` counts that run, so a fold that skipped it is not done. `docs/MAINTENANCE.md`'s fold paragraph now names the two groups, each in its own block, and is where the new test reads them from, so the document and the skill cannot drift apart in a way that silently loses a check. `recovery.md`'s second case is named for the run whose check failed, its third for the step whose checks it answers, and step 4 answers its own failing check in place: the fold left the tree as it was, so the branch holds the failure, and no push, pull request, or merge follows it. Two things are unchanged and worth stating, since a reviewer might otherwise read the change as a weakening of the gate: the whole-tree verdict for the state a remote is asked to land is still enforced, once on the folded tip and again in `verify-execution`'s final run, and `.forgejo/workflows/maintenance.yml` still runs every check of the Checks section on every pull request. `AGENTS.md` is untouched. ## How to verify From a fresh checkout of this branch, with the tests run as a non-root user from the repository root: ```bash bash tests/agent-config/real-source.sh ``` All 12 pass. Two of them are new, and both fail on the main branch's code, which is what a feature's regression test must do; the pin added before the code passes on both. To see the failure, build a worktree of the base and run the branch's test file against it: ```bash git worktree add --detach /tmp/fold-base d7893e2 cp tests/agent-config/real-source.sh tests/agent-config/lib.sh \ /tmp/fold-base/tests/agent-config/ ( cd /tmp/fold-base && bash tests/agent-config/real-source.sh ) ``` There the two new tests fail: "docs/MAINTENANCE.md holds the fold's checks in the group of each point it runs them at", and "the fold of fold-branch runs its whole-tree checks once, on the folded tip, and not at each replayed commit", which folds a fixture branch whose base tracks a file no commit of the branch touches and asserts that the fold finishes on the branch while the tip's run reports the breakage. The pin, "the fold of fold-branch stops at a replayed commit whose own diff is not whitespace-clean", passes there and here. The change's own fold exercised the rule it changes: its `--exec` ran `git diff --check HEAD^` at three replayed commits in 0.043s, then step 4 ran the whole-tree group once on the folded tip in 39.8s, where the rule it replaces paid about 34s three times. Checks run on the tip, all passing with a clean working tree: `bash tests/verify-agent-config.sh` (361 tests), `bash tests/check-work-folder.sh` (46 tests), `.agents/hooks/shellcheck.sh repo` (51 files clean), `prettier --check '**/*.md'`, `scripts/verify-agent-config.sh`, and `git diff --check main`. `bash .agents/scripts/check-work-folder.sh --verified` on the work folder prints nothing. ## Considerations An intermediate commit that breaks a whole-tree check and is fixed before the tip now folds without a word, so `git bisect` across a branch's commits can stop at a state that fails them. That is the cost of the change, accepted for the report it answers: the state a remote is asked to land, the tip, keeps every check, and CI keeps running all of them on every pull request. The per-commit run of the whole-tree checks is what a later edit could drop by mistake, so it is pinned rather than trusted: the new test extracts the skill's `<whole-tree checks>` command and the two groups from `docs/MAINTENANCE.md` and runs both, so dropping step 4 or moving a whole-tree check back into `--exec` fails the suite. Left out of scope, as the work file records: making `tests/verify-agent-config.sh` itself quicker, and scoping Prettier and ShellCheck to the files a commit changes, which needs a file-list mode neither has and would still leave the dominant cost reading the whole configuration.
The fold's every-commit checks move in two commits: the whole-tree
ones go to the folded tip, and the check of the commit's own diff
stays at each replayed commit. Land the pin of what stays first, so
its pass on the main branch's code is its own.

The test folds a fixture branch whose fixup brings a trailing
whitespace, with the real `git diff --check HEAD^` in the skill's
check placeholder, and asserts the rebase stops at that commit, the
case recovery.md tells the reader to handle. The helper takes the two
check groups the next commit adds, substituting the current
placeholder name too so the pin still runs on the main branch's text.
A small edit on a branch of several commits waited through one
whole-tree run per replayed commit, though a fold leaves the tree as
the tip's: three of the four every-commit checks of docs/MAINTENANCE.md
read the whole tree, and each cost about the same at every commit as at
the tip, where verify-execution already runs them.

Step 2 now carries only the checks that read the replayed commit's own
diff, and a new step 4 runs the rest once on the folded tip, counted in
the skill's Done so a fold that skipped them is not done. A fold is now
one per-commit run plus one tip run, whatever the commit count.

The MAINTENANCE paragraph names the two groups, which is where the new
test in real-source.sh reads them from, so the file and the skill cannot
drift apart. Step 4 answers its own failing check, since a fold that
left the tree unchanged brings the failure rather than meeting it.
docs(workflows): tell the fold's readers where each check runs
All checks were successful
Maintenance / checks (pull_request) Successful in 7m24s
Maintenance / checks (push) Successful in 7m53s
a399533a00
The two pages that point at the skill said its every-commit checks run
on each commit, which the skill no longer does. Each says now, in its
one line, which checks run at each replayed commit and which run once
on the folded tip.
First-time contributor

Review ready: a399533a00

Review ready: a399533a0088afaa278985b5604476bb3fc88f0b
aramaki approved these changes 2026-11-28 01:18:19 +01:00
aramaki left a comment

Review: approved

Reviewed a399533a0088: 0 blocking and 1 minor findings.

Reproduced

  • bash tests/agent-config/real-source.sh on the tip: all 12 pass.
  • The branch's test file on base d7893e2: the two new regression tests fail, the whitespace pin passes there and on the tip, as required.
  • On the tip: 361 agent-config tests, 46 work-folder tests, shellcheck repo (51 clean), prettier, scripts/verify-agent-config.sh, and git diff --check origin/main all pass; tree clean.
  • Skill step 4, MAINTENANCE.md's two groups, recovery.md, and the two workflow pages agree; no stale 'fast checks' wording for the fold remains.

Questions and details

  • MAINTENANCE.md asks the maintainer to run the behavioral evals before merging a change to a skill; should this fold-branch change get an evals run before merge?
## Review: approved Reviewed `a399533a0088`: 0 blocking and 1 minor findings. **Reproduced** - bash tests/agent-config/real-source.sh on the tip: all 12 pass. - The branch's test file on base d7893e2: the two new regression tests fail, the whitespace pin passes there and on the tip, as required. - On the tip: 361 agent-config tests, 46 work-folder tests, shellcheck repo (51 clean), prettier, scripts/verify-agent-config.sh, and git diff --check origin/main all pass; tree clean. - Skill step 4, MAINTENANCE.md's two groups, recovery.md, and the two workflow pages agree; no stale 'fast checks' wording for the fold remains. **Questions and details** - MAINTENANCE.md asks the maintainer to run the behavioral evals before merging a change to a skill; should this fold-branch change get an evals run before merge?
@ -227,0 +234,4 @@
# its settings
local dir="$workdir/fold-exec" cmd
cmd=${1//<main branch>/main}
cmd=${cmd//<fast checks>/"${2:-true}"}
First-time contributor

Minor: The substitution is a no-op on the tip; it existed so the suite ran at the pin commit. Keep it with a comment, or drop it.

**Minor:** The <fast checks> substitution is a no-op on the tip; it existed so the suite ran at the pin commit. Keep it with a comment, or drop it.
Sign in to join this conversation.
No description provided.