Skip to content

refactor(perf): canonicalize wt-perf prune-fixture layering + completion config - #3548

Merged
max-sixty merged 2 commits into
mainfrom
wt-perf-fixture-consolidation
Jul 24, 2026
Merged

max-sixty merged 2 commits into
mainfrom
wt-perf-fixture-consolidation

Conversation

@max-sixty

@max-sixty max-sixty commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

What

Three behavior-preserving canonicalizations of the wt-perf benchmark fixtures, from a design pass on "why does prune need its own generator, and can the fixtures consolidate?"

  1. Share the prune-population layer. create_prune_repo_at (synthetic) and create_prune_real_repo_at (rust-scale) both layered the same two populations onto their base repo — add_diverged_backdrop (the scanned-but-never-removed backdrop) + add_squash_merged (the removable candidates). Extracted into add_prune_populations, so the base repo (synthetic create_repo_at vs. rust clone) is now the only thing the two fixtures differ in, spelled out once instead of twice.

  2. Canonicalize completion.rs onto RepoConfig::branches. Its two inline RepoConfig literals were exactly RepoConfig::branches(50, 0) (one with worktrees overridden), so they now use the canonical preset via struct-update instead of respelling all seven fields.

  3. Document the fixture → bench mapping. benches/CLAUDE.md listed the wt-perf setup handles in one section and the bench groups in another with nothing connecting them, so a bench and its fixture (full and mixed) read as overlapping names for the same thing. Added a mapping table and the rule behind it.

Why this is the whole safe consolidation

The design question was whether prune could drop its bespoke generator for a "standard one with different params" — ideally one diverse repo serving prune and the other benches. The answer is that prune's generator is already a thin composition (create_repo_at + two additive layers), and it can't fold into the shared mixed/full fixture without breaking three prune-specific invariants: a known/cleanly-separated candidate count (the destructive live path re-creates exactly the consumed candidates), untracked-only dirt (the git reset --mixed index-heal depends on it — mixed's staged-dirt states violate it), and a provably-unintegrated backdrop. And benchmark fixtures optimize for attribution, not realism: the uniform single-axis fixtures (worktree_scaling, etc.) exist precisely because the diverse full fixture can't localize a regression, so diversifying them would lose that.

On the full/mixed naming specifically: they can't be canonicalized to one name, because fixtures and benches are many-to-one — RepoConfig::typical alone backs five bench groups (skeleton, worktree_scaling, first_output, picker_preview, remove_e2e), two of which sit in the same file measuring different things. full/mixed only looks 1:1 by coincidence. Renaming also isn't free: .github/scripts/criterion-to-jsonl.py keys each time-series row by the criterion output path (<group>/<id>) for the daily gist append, so a rename orphans that series. Documented rather than renamed.

Proposed follow-up (not in this PR)

The one remaining real duplication is two implementations of "two-sided-diverged population forked across history depth": add_diverged_backdrop (plumbing-based, scales to rust) vs. the diverged branch states inside create_mixed_repo (checkout-based, synthetic-only). They can't naively merge — the checkout path would make prune-real take minutes per branch — but a shared plumbing primitive could back both. That rewrites a carefully-tuned fixture feeding the full bench with no shape-assertion test to catch drift, so I'd land a fixture-shape test first (count refs by state + assert integration status). Happy to do it if wanted.

Verification

fmt --check clean; clippy -p wt-perf --all-targets and clippy --bench completion clean; pre-commit clean on the doc; cargo test -p wt-perf passes (incl. the prune-fixture tests squash_merged_fixture_is_content_integrated / prune_fixture_state_classifies_lifecycle, which exercise create_prune_repo_at → add_prune_populations); all benches build. Table contents verified against the code by grep.

This was written by Claude Code on behalf of Maximilian Roos

🤖 Generated with Claude Code

…tion config

The synthetic and rust-scale prune fixtures (`create_prune_repo_at`,
`create_prune_real_repo_at`) both layered the same two populations onto their
base repo — `add_diverged_backdrop` for the scanned-but-never-removed backdrop
and `add_squash_merged` for the removable candidates. Extract that into
`add_prune_populations` so the two fixtures share one layering and can't drift;
the base repo (synthetic `create_repo_at` vs. rust clone) stays the only thing
they differ in.

`completion.rs`'s two inline `RepoConfig` literals were exactly
`RepoConfig::branches(50, 0)` (one with `worktrees` overridden), so point them
at the canonical preset via struct-update instead of respelling every field.

Behavior-preserving: fmt/clippy clean, wt-perf fixture tests and all bench
builds pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
`benches/CLAUDE.md` listed the `wt-perf setup` fixture handles in one section
and the bench groups in another, with nothing connecting them — so a bench and
its fixture (`full` and `mixed`) read as overlapping names for one thing.

Add a mapping table plus the rule that makes it make sense: bench groups are
named for what they measure, fixtures for the repo shape, and the relationship
is many-to-one (`RepoConfig::typical` alone backs five groups), so the two names
structurally cannot match. Also record that renaming a bench group orphans its
time series, since criterion-to-jsonl.py keys gist rows by `<group>/<id>`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@max-sixty
max-sixty marked this pull request as ready for review July 24, 2026 01:31
@max-sixty
max-sixty merged commit 166e119 into main Jul 24, 2026
39 checks passed
@max-sixty
max-sixty deleted the wt-perf-fixture-consolidation branch July 24, 2026 01:40
@worktrunk-bot worktrunk-bot mentioned this pull request Jul 24, 2026
max-sixty added a commit that referenced this pull request Jul 25, 2026
…ive (#3584)

Follow-up to #3548, which consolidated the `wt-perf` prune fixtures but
left the branch *builders* diverged.

## The refactor

Three generators had each grown their own way to create a fixture
branch. `add_history_spread_branches` pointed a ref at an old commit,
`add_diverged_backdrop` hand-rolled ~45 lines of index plumbing, and
`create_mixed_repo_at` used `checkout -b` plus a return-to-main for two
of its four states.

They are the same operation. A branch's state is entirely the pair
**(fork point, own-commit count)**: zero commits at an old fork is
"behind" and at the tip is "identical"; a positive count from the tip is
"ahead" and from anywhere else is two-sided "diverged".
`add_branch_with_commits` takes that pair, and the mixed fixture's
four-state rotation collapses to a table:

```rust
let (fork, commits) = match i % 4 {
    0 => (checkpoint, 0),                // behind
    1 => (base_tip.as_str(), 1 + i % 3), // ahead
    2 => (checkpoint, 1 + i % 3),        // diverged
    _ => (base_tip.as_str(), 0),         // identical to the tip
};
```

The checkout path is what actually mattered. `git checkout` of an old
fork point on rust-lang/rust rewrites the whole tree (minutes per
branch), which is why `add_diverged_backdrop` grew plumbing in the first
place. Routing the mixed fixture through the same primitive removes the
last checkout from fixture construction, so the main worktree is never
touched and the fixture is no longer structurally barred from a
rust-scale repo.

The win is structural. Fixture build time is unchanged: `mixed-8-8` runs
3.25/3.28/3.71s after against 3.33/3.55/3.91s before, and `mixed-24-120`
14.9/15.7s against 15.5/23.5s. That is parity within noise, and the
before-side spread swamps the difference.

## The guards

These generators had nothing pinning their output. The benchmarks
measure one wall-clock number, so a generator change that collapsed
(say) "diverged" into "ahead" would keep every bench green while
silently measuring a different repo. Three tests now assert the shapes
directly, via `merge-base --is-ancestor` exit codes and porcelain
status:

- the `full` fixture's documented `index % 4` rotation of branch and
worktree states
- the same fixture's zero-dimension contract (`mixed-W-0` /
`mixed-0-B`), which holds only because `0..0` never enters the loop that
divides by `branches`
- `add_diverged_backdrop`'s own wiring: every member unintegrated, fork
depths fanning across history, worktrees dirty only via untracked
scratch, and populations that don't follow each other

Each was mutation-tested rather than trusted for being green. A clamped
divisor gives `left: 1, right: 0`, and a fork spread collapsed onto the
tip gives `fork depths must fan out across history: [0, 0, 0, 0]`.

## One thing to look at

Writing the guards turned up a docstring overclaim in two places.
`history_spread_shas` samples newest-first, so index 0 is the default
branch's own tip. That makes `add_diverged_backdrop`'s "the default
branch has advanced past every fork" and `add_history_spread_branches`'s
"behind-only" both false as written. The first is true in its only
caller, where `add_squash_merged` advances the default branch on the
very next line.

I corrected the docstrings rather than the sampling, and pinned the
behavior with `assert_eq!(depths[0], 0, "the newest sample is main's own
tip")`. Changing the sampling would shift the workload of every prune
and `list` benchmark that uses the spread, moving Criterion's historical
series with no rename to signal it, in exchange for one branch out of 24
to 120 gaining fork depth. Happy to flip it if you'd rather; it is
documented and asserted either way.

## Verification

`hook pre-merge` green (4542 tests), and `cargo bench --bench list full`
runs end to end against the rebuilt fixture. Shape verified at benchmark
scale rather than only at the test's `N = 8`: a real `mixed-24-120`
holds the rotation through `br-0118`. The refactor is content-identical
for the backdrop (same blob content, filenames, commit messages,
plumbing sequence) and structurally identical for the mixed fixture
(same fork points and commit counts, since `0..=(i%3)` and `1 + i%3`
agree).

> _This was written by Claude Code on behalf of max_
max-sixty pushed a commit to max-sixty/tend that referenced this pull request Jul 25, 2026
…#787)

## What

Adds a bullet to the `review-reviewers` skill's **Non-issues** list:
`tend-review` staying silent on a **draft** PR with no actionable
findings is expected skill-designed behavior, not a silent omission —
the sibling of the already-documented self-authored-PR case.

## Why

GitHub's `state` field reports draft PRs as `OPEN`, so the survey step's
negative signal "bot posted no review despite a `tend-review` run
completing on an open PR" fires on drafts. The bundled `review` skill's
draft-mode explicitly runs a lighter COMMENT-only review and authorizes
"Stay silent if there's nothing actionable; don't post a 'looks fine'
comment" (GitHub also blocks APPROVE on drafts). So a silent tend-review
on a clean draft is correct — but without this in the durable Non-issues
list, each analysis run re-derives it via an expensive escalation to
session logs.

## Evidence

Recurring across analysis runs, and structural (draft PR + nothing
actionable → always silent):

- **This run**
([29954129033](https://github.com/max-sixty/tend/actions/runs/29954129033)):
two `tend-review` runs on max-sixty/worktrunk PRs
[#3547](max-sixty/worktrunk#3547) and
[#3548](max-sixty/worktrunk#3548) — both `draft:
true`, human-authored (max-sixty), zero reviews/comments posted. The
survey subagent flagged them as "concerning: no review on open
human-authored PR"; I escalated to a session-log investigation, which
confirmed the bot correctly detected draft status and applied draft-mode
silence in every case. The escalation was only necessary because the
pattern wasn't codified.
- **Prior run** (recorded in the evidence gist): already tracked a
counter "tend-review correct silent exit (draft-nothing-actionable): +2"
and verified the same outcome against `review/SKILL.md` — i.e. the
pattern was observed and re-derived a window earlier too.

This is an **invisible, recurring failure mode**: the wasted session-log
escalation never surfaces as a CI failure, so without codification it
keeps costing tokens every window a draft PR is open and gets pushed to.

## Gate assessment

- **Gate 1 (confidence)**: structural; observed across 2+ analysis runs
(prior +2, this run 2 more). Passes.
- **Gate 2 (magnitude)**: one bullet added to an existing enumerated
list, mirroring the adjacent self-authored bullet — targeted, no
structural change. Passes.

Evidence log: https://gist.github.com/b923bbc52f3c6606931d59abdae616a3

The target-repo bot behavior this window was otherwise all-clear: three
`tend-review` runs correct (draft/re-review), three `tend-notifications`
benign, one `tend-ci-fix` skip. No human pushback, no corruption. This
PR improves the *analysis* skill, not the target bot.

Co-authored-by: tend-agent <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

2 participants