Skip to content

feat(config): add codename template filter - #2641

Merged
max-sixty merged 7 commits into
max-sixty:mainfrom
endigma:endigma/codename-filter
May 9, 2026
Merged

max-sixty merged 7 commits into
max-sixty:mainfrom
endigma:endigma/codename-filter

Conversation

@endigma

@endigma endigma commented May 7, 2026

Copy link
Copy Markdown
Contributor
  • Adds a codename(n) filter for generating friendly names deterministically
  • Has a few tests, and documents possible issues with collisions, along with recommendations to avoid them

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abf463d495

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/expansion.rs Resolved
@endigma
endigma force-pushed the endigma/codename-filter branch from abf463d to aa97250 Compare May 7, 2026 12:41
@endigma
endigma force-pushed the endigma/codename-filter branch from aa97250 to d4c5df8 Compare May 7, 2026 12:45

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small consistency suggestions on the new docs entries — every other bullet in the "Available template variables" list uses — as the separator, but the new codename(2) line uses :. Easier to keep them parallel. Same in the doc comment in expansion.rs.

Otherwise the change looks solid: SHA-256 with explicit u64::to_le_bytes for cross-arch stability is a nice touch, and the test_codename_outputs_are_stable pin test (with the prominent "do not silence me" comment) does exactly what's needed once users adopt this in their worktree-path.

One minor observation, not blocking: there are 6 words that appear in both CODENAME_ADJECTIVES and CODENAME_NOUNS (cedar, dawn, hazel, hollow, maple, marble). It is therefore possible — though rare — for codename(2) to render something like maple-maple. If you'd rather avoid that, you could either drop the overlapping entries from one list or special-case "adjective == noun" in codename(). Up to you; locking the wordlists in via the pin test is a good place to make that call before the first release that ships the filter.

Comment thread dev/config.example.toml Resolved
Comment thread src/cli/mod.rs Resolved
Comment thread src/config/expansion.rs Resolved
endigma and others added 3 commits May 7, 2026 13:52
Co-authored-by: Worktrunk Bot <[email protected]>
Co-authored-by: Worktrunk Bot <[email protected]>
Co-authored-by: Worktrunk Bot <[email protected]>
worktrunk-bot
worktrunk-bot previously approved these changes May 7, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing on test (linux), test (macos), and code-coverage — the snapshots and synced docs need to be regenerated after the : → — edit in src/cli/mod.rs.

Failing tests:

  • integration_tests::help::test_help::case_05 (snapshot help_config_long)
  • integration_tests::help::test_help::case_18 (snapshot help_config_create)
  • integration_tests::readme_sync::test_docs_are_in_sync — docs/content/config.md and skills/worktrunk/reference/config.md are out of sync

Per CLAUDE.md, after editing after_long_help:

cargo insta test --accept -- --test integration "test_help"
cargo test --test integration test_docs_are_in_sync

Sorry for not flagging this when I suggested the change — happy to push a fix commit if that's easier than running it locally.

@worktrunk-bot
worktrunk-bot dismissed their stale review May 7, 2026 13:03

CI failed - snapshots and synced docs need regeneration after the suggested edit

The codename template filter bullet in src/cli/mod.rs and
dev/config.example.toml uses an em-dash like the surrounding bullets,
but the generated docs and help snapshots still had the original colon.
@max-sixty

Copy link
Copy Markdown
Owner

great idea @endigma ! thank you!

couple of questions:

  • when do you see using this vs the branch name itself? I could see it being helpful if someone thought "I don't know what I'm going to do so I just want a name". but at the moment I think we still need a name?
  • rather than suggesting to "pair with hash", should we just massively increase the number of adjectives & nouns, so it's difficult to get a conflict? IIUC codename(3) with a big enough sample is all atoms in the solar system or similar... (@worktrunk-bot is there a rust dependency that has lots of words? otherwise we could just write them out ourselves)

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

On the wordlist question — petname (allenap/rust-petname, Apache-2.0, currently 3.0.0) is the closest fit and ships three curated lists; names (fnichol/names, MIT) is similar in size to petname's medium. Both expose the lists as plain &[&str]-like data, and petname can be pulled in without rand (default-features = false, then enable just default-words), so we'd skip the RNG and keep our SHA-256 indexing.

Concrete sizes (verified against each repo's data files)
Source Adjectives Nouns codename(2) combos
current in-tree 174 177 ~30.8k
petname small 449 449 ~201k
petname medium 1,198 1,052 ~1.26M
petname large 36,577 5,899 ~216M
names 1,124 981 ~1.10M

petname's large is a generated dictionary dump — first ten adjectives are abactinal, abaised, abandonable, abandoned, abasic, abatable, abaxial, abbatial, abdicable, abdicative — so it's effectively unusable for a human-readable codename. medium is the realistic ceiling for a curated feel.

The catch with using a crate directly: codename is a deterministic filter, so the same input must always pick the same word. Today the in-tree test_codename_outputs_are_stable pin test enforces that against our own arrays. A third-party wordlist breaks that contract — any reorder, addition, or removal upstream silently shifts every existing user's worktree-path. The mitigations are either to vendor the list into our tree (include_str! from a snapshotted file) or to hard-pin =X.Y.Z and never bump. Both reduce to "we own a copy", at which point a third-party crate isn't really pulling weight over the hand-curated lists.

So I'd lean toward your "write them out ourselves" instinct, just at a larger size. The headroom is non-linear: bumping each list to ~500 (roughly 3× the current count, well within hand-curation) gives ~250k combos for codename(2) and ~125M for codename(3). Even today's 174/177 gives ~5.4M combos for codename(3) — for 100 worktrees in a single repo, birthday-paradox collision odds are ~0.1%. So if the docs treat codename(3) as the recommended default for standalone-name use cases, the "pair with | hash" caveat for codename(2) becomes a niche tip rather than a required pattern.

One small thing worth keeping regardless of list size: the 6-word adjective/noun overlap I flagged earlier (cedar, dawn, hazel, hollow, maple, marble) — at any list size, it's worth either stripping the overlaps from one side or detecting adjective == noun in codename() to avoid maple-maple style outputs.

@max-sixty

Copy link
Copy Markdown
Owner

One small thing worth keeping regardless of list size: the 6-word adjective/noun overlap I flagged earlier (cedar, dawn, hazel, hollow, maple, marble) — at any list size, it's worth either stripping the overlaps from one side or detecting adjective == noun in codename() to avoid maple-maple style outputs.

(this is fine as-is, fwiw)

I'll let @endigma decide on the questions above

max-sixty pushed a commit to max-sixty/tend that referenced this pull request May 8, 2026
…licates (#395)

## Outcome evidence

`tend-review` run
[25499066953](https://github.com/max-sixty/worktrunk/actions/runs/25499066953)
on worktrunk PR
[#2641](max-sixty/worktrunk#2641) posted **two
`APPROVED` reviews 4 seconds apart** from a single completed session —
review
[4244431335](max-sixty/worktrunk#2641 (review))
at 13:35:57Z and
[4244431873](max-sixty/worktrunk#2641 (review))
at 13:36:01Z, both empty-body, both on the same head SHA `55ef4fba`.
Only one `tend-review` run touched this SHA, so this is not the
documented concurrency-cancel `Non-issue` (no SIGTERM'd siblings here).

Decision chain in session log
`bcfcce99-ae59-4201-a411-fe82f2b074bc.jsonl`:

1. **13:35:55Z** — bot ran a guarded combined script: `read
CURRENT_HEAD/PR_STATE`, HEAD-match check, OPEN-state check,
`ALREADY_POSTED` check, then `gh pr review 2641 --approve -b ""` as the
script's last command. The first `APPROVED` posted at 13:35:57Z.
Tool-result showed only the prelude's `echo` lines (`CURRENT_HEAD=…
PR_STATE=OPEN ALREADY_POSTED=`); the approve itself produces no stdout
on success.
2. **13:36:00Z** (5s later) — bot issued a bare standalone `gh pr review
2641 --approve -b ""` with no preceding text. The second `APPROVED`
posted at 13:36:01Z.
3. **13:36:04Z** — bot queried `reviews[-1]`, saw the latest entry was
`APPROVED`, and wrote "Approval posted on HEAD" (singular) to the
conversation log, never noticing the duplicate.

The prelude's silence was indistinguishable from "approve didn't fire",
so the model retried "to be sure".

## Root cause

The `### 5. Submit` recipe in
`plugins/tend-ci-runner/skills/review/SKILL.md` shows `gh pr review
--approve -b ""` with no positive confirmation. `gh pr review --approve`
is silent on success, so combining it into a guarded script (where the
only stdout is the prelude's `echo`) leaves the model with no visible
success signal. The retry follows.

## Fix

Append `&& echo "✓ approved"` to the recipe so the tool-result shows
explicit confirmation, and add one sentence explaining why future
maintainers should not strip the echo as cosmetic noise. One-line code
change, one sentence of explanation.

## Gate assessment

Evidence: https://gist.github.com/9675d1510da32c68a68c1d45137b21e0
(current month) plus prior month's gist
`44ab1483b29406255dd36141650c894d`.

Three cumulative occurrences of single-session duplicate-review-POST
across the past two months, all from `tend-review` sessions, all on
`worktrunk`:

| Date | Run | PR | Review type | Notes |
|---|---|---|---|---|
| 2026-04-29 |
[25089599666](https://github.com/max-sixty/worktrunk/actions/runs/25089599666)
| [#2454](max-sixty/worktrunk#2454) (Dependabot)
| 2 × `APPROVED`, empty-body | Same combined-script-then-bare-retry
shape; explicitly proposed `&& echo` as the fix |
| 2026-05-06 |
[25454510442](https://github.com/max-sixty/worktrunk/actions/runs/25454510442)
| [#1320](max-sixty/worktrunk#1320) | 2 ×
`COMMENTED`, byte-identical 2476-byte bodies | Different verb path (`gh
api .../reviews POST`) but same single-session-duplicate-POST signature
|
| 2026-05-07 |
[25499066953](https://github.com/max-sixty/worktrunk/actions/runs/25499066953)
| [#2641](max-sixty/worktrunk#2641) | 2 ×
`APPROVED`, empty-body | This run; recipe-level `--approve` shape,
identical to the April 29 case |

- **Classification**: stochastic (model has decision points; not every
replay would retry). Restricted to the recipe-level `--approve` shape: 2
cumulative occurrences (April 29, today). Across the broader
single-session-duplicate-POST family: 3 occurrences.
- **Gate 1 (Confidence)**: stochastic with 3 cumulative occurrences ≥
High threshold (2-3). For the narrower `--approve`-only shape, 2
occurrences also meets the High threshold.
- **Gate 2 (Magnitude)**: targeted recipe fix (one line of code, one
sentence of explanation) — Normal evidence bar, met by Gate 1 outcome.
- **Both gates pass**, with the April 29 entry's own forward statement:
"if a second occurrence appears … warrant a PR even at the stochastic
tier (and 2 would also satisfy the 'High' 2-3 threshold)."

## Why now

The April 29 entry recorded the exact same root cause and the exact same
fix this PR applies, and put the bot on a watch-list pending a second
occurrence. Today's run on PR #2641 is that second `--approve`
occurrence (third cumulative across all single-session duplicate review
shapes). The watch-list has tripped.

## Why not broader

Scope is constrained to the `--approve` recipe because that is where the
evidence concentrates and where the call site is unambiguous. The
COMMENTED API path (`gh api .../reviews POST`) returns JSON on success,
so the silent-success-retry mechanism does not apply directly there; if
its single occurrence recurs, a follow-up PR can address that path. Same
for `gh api .../dismissals -X PUT` — referenced in the new explanatory
sentence as guidance, not modified directly. Smallest change that
addresses the observed pattern.

---------

Co-authored-by: tend-agent <[email protected]>
Co-authored-by: Claude Opus 4.7 <[email protected]>
@endigma

endigma commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@max-sixty its so the directory name isn't the branch name, which can be really annoying and long for some branch naming conventions (e.g. ticket number + full sanitized title) and also my prompt already writes the branch name

@max-sixty

Copy link
Copy Markdown
Owner

@max-sixty its so the directory name isn't the branch name, which can be really annoying and long for some branch naming conventions (e.g. ticket number + full sanitized title) and also my prompt already writes the branch name

ah that makes sense. that's a clever approach


I think let's try using petname and make a note to avoid upgrading if the words change. we can always vendor it if they decide to change their words. then we can drop the hash

@worktrunk-bot could you make this change, and @endigma can say if they would prefer not to

Replaces the in-tree adjective/noun arrays (174/177, ~30k codename(2)
combos) with petname::Petnames::medium() (1198/1052, ~1.26M combos), so
`{{ branch | codename(2) }}` rarely collides on its own. Drops the
recommendation to pair codename with `| hash` from the worktree-path docs
and examples, per discussion in max-sixty#2641.

petname is pinned `=3.0.0` because a version bump that adds, removes, or
reorders words would silently change every existing user's
codename-derived `worktree-path` and orphan their on-disk worktrees.
test_codename_outputs_are_stable continues to pin the on-disk contract;
its expected values are updated for the new wordlists.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Done in 9fc5243. Switched to petname::Petnames::medium() (1198 adjectives + 1052 nouns → ~1.26M codename(2) combos, ~1.5B for codename(3)) and dropped the | hash pairing from the docs and examples — codename(2) now stands alone as a worktree leaf.

The petname dep is pinned =3.0.0 with a comment explaining that any bump can silently shift every existing user's worktree path; test_codename_outputs_are_stable still pins the on-disk contract (its expected values are updated for the new wordlists). The crate is added with default-features = false, features = ["default-words"] so we pull in only the static wordlists, not the random-name generator. As a side effect, feature/73 and feature/149 no longer collide.

@endigma — happy to revert if you'd rather keep the in-tree lists; the change is contained.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

test (macos) failed on integration_tests::step_alias::test_step_alias_binds_referenced_var — looks like a transient flake unrelated to this change. The failure is Os { code: 2, kind: NotFound } at insta-cmd-0.6.0/src/spawn.rs:103 (the self.output().unwrap() path), so the spawned child binary couldn't be found. No codename/petname code path is exercised by the failing test, the same test passed on test (linux), and main is green on the same SHA family.

Leaving the approval in place per the running-tend self-dismiss policy. The required test (linux|macos|windows) jobs all need to clear, so once benchmarks finishes the failed macos job can be rerun directly.

@endigma

endigma commented May 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Bigger wordlist is good in my book, I was probably going to run codename(2) with no hash anyway lol

In the unlikely event of a collision, does everything error out clean so the user could just pick an ever so slightly different branch name?

@worktrunk-bot can you answer this?

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Yep, clean error and safe to retry.

The collision check runs in the planning phase, before git worktree add is invoked — validate_worktree_creation in src/commands/worktree/switch.rs:520-558 calls repo.worktree_at_path(path)? and returns GitError::WorktreePathOccupied if anything is already there. Nothing is mutated when this fires: no half-created worktree, no branch created, no config touched.

The user-facing message (from src/git/error.rs:617-630, 913-927) is:

Cannot switch to <branch> — there's a worktree at the expected path <path> on branch <occupant>
hint: To switch the worktree at <path> to <branch>, run cd <path> && git switch <branch>

So if feature/foo and feature/bar happened to hash to the same codename(2), wt switch --create feature/bar errors out cleanly and you can immediately retry as feature/bar2 (or whatever) — the new name re-runs the template and almost certainly lands on a different codename. Worth noting the hint is tuned for the "same branch you wanted, just sitting at that path already" case rather than the codename-collision case, but the title makes the situation clear either way.

@endigma

endigma commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

Cool bot, does this need anything else to be merged @max-sixty ?

@max-sixty
max-sixty merged commit ecdb7bf into max-sixty:main May 9, 2026
33 checks passed
@endigma
endigma deleted the endigma/codename-filter branch May 9, 2026 17:55
@max-sixty max-sixty mentioned this pull request May 10, 2026
3 tasks done
max-sixty added a commit that referenced this pull request May 10, 2026
Bump worktrunk to **0.49.0** — minor bump (semver-checks reports a
breaking change in `GitError::UncommittedChanges`, which gained a
`dirty_files: Vec<String>` field).

## Highlights

**Improved**
- New `codename(n)` template filter — deterministic friendly worktree
names from a ~1.26M-combo pool (`{{ branch | codename(2) }}` →
`malleable-opah`).
[#2641](#2641), thanks
@endigma
- Picker preview disk cache for Log / BranchDiff / UpstreamDiff, with
background refresh for stale Log decorations.
[#2628](#2628),
[#2646](#2646)
- Picker shares one `default_branch_sha` lookup across BranchDiff items
instead of forking N rev-parse subprocesses.
[#2658](#2658)
- "X has uncommitted changes" errors now list the dirty files inline.
[#2653](#2653)

**Fixed**
- `wt switch` integrates with `cd` aliases like zoxide (uses `builtin
cd`). [#2644](#2644), thanks
@xkumiyu for reporting
- Empty hook tables no longer panic during `wt switch --create`.
[#2635](#2635), thanks @topit
for reporting
- `Repository::current_worktree()` and five sibling helpers no longer
silently leak the process CWD when called via `Repository::at(p)`.
[#2652](#2652)
- `WorkingTree::is_linked` tolerates non-git CWDs (e.g. Nix sandbox).
[#2625](#2625), thanks
@DArtagan for reporting
- Picker no longer overlays `collect` warnings on the active TUI; clears
its frame on exit in inline mode.
[#2627](#2627),
[#2626](#2626)
- Failed `git log` no longer poisons the picker's preview disk cache.
[#2651](#2651)
- `wt step prune` says "removing branch" for branch-only candidates.
[#2619](#2619)
- Claude Code Windows integration uses a `wt.sh` wrapper to avoid
colliding with Windows Terminal's `wt.exe`.
[#1754](#1754), thanks
@lucaspimentel

**Documentation**
- cmux workspace integration recipe.
[#1907](#1907), thanks
@alvistar

See
[CHANGELOG.md](https://github.com/max-sixty/worktrunk/blob/release/CHANGELOG.md)
for the full list including internal CI / test-isolation changes.

## Test plan

- [x] `cargo run -- hook pre-merge --yes` (tests + lints clean)
- [x] `cargo semver-checks check-release -p worktrunk` (one breaking
change confirmed → minor bump)
- [x] CHANGELOG entries verified by subagent against actual diffs

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

3 participants