Skip to content

feat(hooks)!: table-form pre-* hooks run concurrently — remove the serial path - #3052

Merged
max-sixty merged 4 commits into
mainfrom
remove-serial-hook-path
Jun 12, 2026
Merged

max-sixty merged 4 commits into
mainfrom
remove-serial-hook-path

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Lands the cutover announced in v0.37.0 (#2135): a multi-entry table hook now runs its commands concurrently for every hook type. [pre-merge] with several keys behaves like [post-start] with several keys and like a single [[pre-merge]] block — one execution semantic for Concurrent steps.

The serial behavior was not implemented where one might expect. The executor's serial branch (ForegroundStep.concurrent / SourcedStep.is_pipeline / CommandConfig::is_pipeline()) was mostly dead: the deprecation shipped with a load-time TOML migration that rewrote multi-entry pre-* tables into serial pipeline form in memory on every config load, so affected configs never reached the executor as Concurrent steps. Removing that migration (now a DEPRECATION_RULES row, after #3045) is the actual behavior change; the executor flags come out with it.

Why no replacement runtime warning

Affected configs have printed a warning on every wt invocation for twenty minor releases (v0.37.0, April 12 → v0.57.0), with wt config update offering a one-command migration that preserved serial behavior explicitly ("migrate now to keep the current serial behavior once the table form is repurposed"). A post-cutover warning has no coherent shape: table form is now legitimate concurrent config, so it would nag users who want exactly that behavior with no way to silence it, and the wt config update rewrite would no longer be behavior-preserving.

Parse normalization

A one-entry top-level table previously parsed as a Concurrent group of one; with the serial branch gone it would have picked up name │ output prefixes. One-entry maps now parse as Single(named) everywhere, matching one-entry maps inside pipeline lists (removing the documented dict-at-top vs dict-in-list asymmetry), and a new Serialize arm keeps one-step named configs round-tripping as named tables. Single-entry table hooks render exactly as before.

Behavior changes

  1. Multi-entry table-form pre- hooks: serial → concurrent.* The announced change.
  2. wt hook <post-type> foreground runs of multi-entry table hooks: serial → concurrent. Previously an undocumented inconsistency — the same config already ran concurrently via the background path.
  3. Single-entry table aliases ([aliases.x] with one key): prefixed-stderr → stdout passthrough. Now matches the string and [[aliases.x]] spellings, and makes wt <alias> | … work for this spelling too.

(2) and (3) were never deprecation-warned; all three belong in the release notes.

Tests

  • test_pre_merge_deprecated_table_runs_serially → rewritten as test_pre_merge_table_form_runs_concurrently; the single-[[pre-merge]]-block test is deleted (both forms now parse identically, so it duplicated the rewritten test).
  • Fixtures that genuinely need serial ordering (>/>> chains, the signal-abort "second must not run" assertion) converted to pipeline form.
  • test_user_hooks_preserve_toml_order (Hooks are run out of order? #737) and test_post_start_named_commands keep table form and pin ordering via WORKTRUNK_TEST_SERIAL_CONCURRENT=1, so insertion order is still asserted through the real concurrent input ordering.
  • New: one-entry-table parse/round-trip unit test; test_alias_single_entry_table_writes_to_stdout pinning change (3).
  • Regenerated snapshots drop a stale RUST_LOG: warn env line (the harness stopped setting it in fix(log): honor RUST_LOG at -v and -vv, not just -v 0 #2901).

Known follow-up

Concurrent-group announcements expose a pre-existing ANSI dim-bleed: format_bash_with_gutter output ends without closing the dim attribute, so back-to-back ◎ Running … lines render dim (visible today on pipeline-form hooks and --execute verbose). Now that this rendering is the table-form default it's worth fixing, but the fix lives in the gutter formatter and churns every bash-gutter snapshot — separate PR.

This was written by Claude Code on behalf of max

max-sixty and others added 2 commits June 11, 2026 20:26
…rial path

Lands the cutover announced in v0.37.0 (#2135): a multi-entry table hook
now runs its commands concurrently for every hook type. Removes the
machinery that kept pre-* tables serial:

- the load-time TOML migration, detection, and per-load warning for
  PreHookTableForm in src/config/deprecation.rs
- ForegroundStep.concurrent, SourcedStep.is_pipeline, and the serial
  branch in execute_pipeline_foreground
- CommandConfig's pipeline flag and is_pipeline()

One-entry maps now parse as Single(named) everywhere (previously only
inside pipeline lists), so single-entry table hooks keep their
unprefixed output; a Serialize arm keeps them round-tripping as named
tables. Side effect: single-entry table aliases now match the string
and [[block]] spellings (stdout passthrough, no prefix).

Also: wt hook <post-type> foreground runs of table hooks are now
concurrent (previously an undocumented serial inconsistency with the
background path); the background runner's Single arm reports failures
by command name, matching the concurrent arm; the SKILL.md conversion
recipe uses [[pre-start]] blocks for dependent steps.

Tests pinning the serial semantics were rewritten (concurrency
assertion), converted to pipeline-form fixtures (where serial ordering
is the point), or pinned via WORKTRUNK_TEST_SERIAL_CONCURRENT=1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	src/config/deprecation.rs
max-sixty and others added 2 commits June 11, 2026 21:15
# Conflicts:
#	src/config/deprecation.rs
… gap

The if-let/else panic arm in test_deserialize_named_table_single_entry
can never execute when the test passes, so codecov/patch flagged it as
an uncovered patch line. A matches! guard asserts the same shape and
fields without a separate unreachable branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 22768d4 into main Jun 12, 2026
34 checks passed
@max-sixty
max-sixty deleted the remove-serial-hook-path branch June 12, 2026 04:31
max-sixty added a commit that referenced this pull request Jun 12, 2026
Follow-up to #3051, fixing its two reported edge cases at the framework
level. Each `DEPRECATION_RULES` row carried two hand-written functions —
a `DetectFn` driving warnings and a `MigrateFn` driving rewrites — that
had to implement the same predicate independently. Auditing all rules
found they had drifted in at least six places, not just the two #3051
reported: `[ci] platform = ""` was structurally migrated on load without
ever warning; a scalar `forge = "x"` was silently overwritten by the
migrated `[forge]` table; `ff` + `no-ff` together silently dropped
`no-ff` with no warning; a multi-entry `[pre-create]` table was
pipeline-migrated with no warning (detection only looked at canonical
hook names); `[select]`'s `timeout-ms` was dropped on load with only the
generic `[select]` warning; and an empty `approved-commands = []` was
removed whenever a sibling project's non-empty array fired the update
gate, despite the documented contract that it "must survive the rewrite
untouched".

A rule is now one function that rewrites and returns the
`DeprecationKind`s for exactly what it changed. A non-empty return is
the "document changed" signal, so the warning, the rewrite, and the `wt
config update` diff are all driven by the same value and cannot drift.
Mechanics:

- `DeprecationRule` is now an enum: `Structural`/`UpdateOnly` carry
`fn(&mut DocumentMut) -> Deprecations`; `Silent` carries `fn(&mut
DocumentMut) -> bool` — no channel for a kind, so "no warning" is
structural rather than conventional.
- Detection runs every rule against a scratch clone of the document,
progressively, so a rule reports a pattern in its post-migration shape
(e.g. `timeout-ms` under `[select]` is reported after the `[select]`
rule moves it under `[switch.picker]`). The invariant — a warning fires
exactly when `wt config update` would change the file — is pinned by a
new `test_warning_fires_iff_update_changes` battery, and the
kitchen-sink snapshot now asserts the update silences every warning.
- The load path applies `Structural`+`Silent` rules;
`compute_migrated_content` applies all rules; the old `UpdateOnly`
detection-gate (and its "re-runs detection on the partially migrated
document" footgun) is deleted.
- Configs that can't be rewritten safely (malformed values, occupied
destination keys) are left untouched and unwarned — serde's type or
unknown-field error is the messaging. Empty deprecated sections are
likewise left alone, matching what detection already promised.

Deliberate behavior changes, each pinned by a test: `ff` + `no-ff` now
warns and removes `no-ff` (was silent); scalar `forge` suppresses the
`[ci]` migration (was overwritten); `[ci]` with an empty/non-string
`platform` is untouched (was silently migrated); `[select]` +
`timeout-ms` emits both warnings; empty `approved-commands = []` always
survives; empty `[select]`/`[commit-generation]` sections are no longer
silently rewritten on load.

The mid-flight merge of main brought in #3052, which deleted the
`PreHookTableForm` rule entirely (table-form hooks now run
concurrently). The conflict resolution keeps that deletion and applies
the refactor to the eight surviving rules; it also drops a stale "Must
precede the pre-hook table-form rule" comment #3052 left behind, and
retains `table_like_len` (deleted as unused on main, needed here by
`is_nonempty_table_like`).

Trade-offs accepted: the "non-empty return ⟺ changed" contract is
documented on the type, not enforced by it — the test battery is the
feedback loop; empty deprecated sections now get no messaging at all and
are never cleaned (consistent with detection's old contract, but a
permanent silent husk); detection clones the document once per config
load (negligible for KB-scale TOML).

Testing: the invariant battery covers 17 edge configs across both
directions; review iterated to "Clean design, zero critical issues".
Full suite (158 deprecation, 1246 lib, 1804 integration) and `wt hook
pre-merge` pass. Net −60 lines.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@max-sixty max-sixty mentioned this pull request Jun 13, 2026
max-sixty added a commit that referenced this pull request Jun 13, 2026
Release v0.58.0.

Highlights since v0.57.0:

- **Table-form `pre-*` hooks run concurrently** (#3052) — completes the
cut-over announced in v0.37.0. Breaking for configs relying on serial
ordering; pipeline form (`[[pre-merge]]`) stays serial.
- **CI column shows the PR/MR number and review state** (#3041, #3044) —
`wt list --full` and the statusline show the open PR/MR reference
colored by CI status, with review state folded in.
- **Hooks/aliases share one lazy template model** (#3042, #3047) —
templates render per-step; `{{ vars.* }}` reads fresh.
- **`wt config state cache`** (#3027) — consolidates regenerable caches;
`state clear` now confirms first.
- Statusline rate-limit display, `/wt-switch-create` optional branch
name, plugin worktree-hook hardening, and a batch of config-deprecation
and snapshot-determinism fixes.

Full notes in `CHANGELOG.md`.

The release tag is pushed to the squash-merge commit after this lands;
`release.yaml` then publishes to crates.io, Homebrew, and winget.

> _This was written by Claude Code on behalf of max_
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.58.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Release Notes

### Improved

- **Table-form `pre-*` hooks run concurrently**: A multi-entry table hook (`[pre-merge]` with several keys) now runs its commands concurrently, completing the cut-over announced in v0.37.0: every hook type has one execution semantic, where table form is concurrent and pipeline form (`[[pre-merge]]` blocks) is serial. Configs that need ordering should use pipeline form; affected configs have warned on every invocation since v0.37.0, with `wt config update` offering a serial-preserving migration. Two adjacent inconsistencies are also gone: `wt hook <post-type>` foreground runs of multi-entry table hooks now run concurrently like their background counterpart, and single-entry table aliases write to stdout like the other alias spellings, so `wt <alias> | …` works for that spelling too. (Breaking: multi-entry table-form `pre-*` hooks no longer run serially) ([#3052](max-sixty/worktrunk#3052))

- **CI column shows the PR/MR number and review state**: The CI column in `wt list --full` and the statusline shows the branch's open PR/MR reference (`#3041` on GitHub/Gitea/Azure DevOps, `!3041` on GitLab) instead of a plain dot: colored by CI status, hyperlinked to the PR, dimmed when stale or draft. Review state folds into the color, with magenta for changes requested and cyan for awaiting review. `wt list --format=json` gains `ci.number` and `ci.review_state`. ([#3041](max-sixty/worktrunk#3041), [#3044](max-sixty/worktrunk#3044))

- **Hook and alias templates render when each step runs**: Templates are syntax-checked before the first step runs and rendered as each step executes, so `{{ vars.* }}` always reads fresh values and hooks and aliases share one expansion model. Two consequences: a pipeline step with an undefined variable fails when that step is reached (earlier steps run first), and a template error in a background hook surfaces in the hook log rather than failing the foreground command. The background runner also labels template errors the way the foreground does. ([#3042](max-sixty/worktrunk#3042), [#3047](max-sixty/worktrunk#3047))

- **`wt config state cache`**: The regenerable caches (CI status, branch summaries, git-command caches, hints, the `wt switch -` target) are consolidated under `wt config state cache`; `cache clear` drops them all without prompting, since everything regenerates. `wt config state clear`, which also wipes hand-authored markers and vars, now asks for confirmation; `--yes` skips, and non-interactive runs without `--yes` cancel. The `ci-status`, `hints`, and `previous-branch` subcommands are deprecated but still work. ([#3027](max-sixty/worktrunk#3027))

- **Statusline rate-limit segment**: Above 90% of the binding window the segment shows the used percentage (`95%(8:30am–1:30pm)`) instead of the pace ratio; near the cap, what's left matters more than the rate. The pace form drops the word "pace" (`2.9×(Tue–Tue 5pm)`), and `-vv` logs each window's inputs and selection to `.git/wt/logs/trace.log` so the binding-window choice can be reconstructed. ([#3057](max-sixty/worktrunk#3057), [#3053](max-sixty/worktrunk#3053), [#3029](max-sixty/worktrunk#3029))

- **`/wt-switch-create` branch name is optional**: The Claude Code plugin command picks a branch name from the task when none is given, and the skill's workflow is one route (create, then enter) with an error-driven fallback instead of three guarded paths. Worktrees created mid-session persist after the session ends. ([#3058](max-sixty/worktrunk#3058))

### Fixed

- **Plugin worktree hooks fail before side effects**: The Claude Code plugin's `WorktreeCreate`/`WorktreeRemove` hooks validate the payload before running `wt`; a malformed payload previously created a branch named `null` or could remove the wrong worktree. `wt remove`'s help now documents that the positional argument accepts a worktree path as well as a branch name. ([#3058](max-sixty/worktrunk#3058), [#3060](max-sixty/worktrunk#3060))

- **Waiting-for-input marker covers questions, permission prompts, and turn end**: The Claude Code plugin sets the 💬 marker on `AskUserQuestion`, permission requests, and turn end. Previously only the `Notification` event set it, which never fires for the built-in question picker (and on some platforms not for permission prompts), so the marker stayed 🤖 while Claude waited. Part of [#2916](max-sixty/worktrunk#2916). ([#3023](max-sixty/worktrunk#3023), thanks @Ismael for reporting)

- **`wt list --help` no longer panics when piped**: With no detectable terminal width (output piped, `COLUMNS` unset), `wt list --help` panicked with a capacity overflow, and the post-commit diffstat truncated filenames to ~10 characters. Both now handle unknown width. ([#3040](max-sixty/worktrunk#3040))

- **Deprecation warnings match `wt config update`**: A config deprecation warning now fires exactly when `wt config update` would change the file. The old detection and migration logic had drifted in several places: `ff` and `no-ff` together silently dropped `no-ff`, a scalar `forge` key was overwritten by the `[ci]` migration, an empty `[ci] platform` migrated without warning, and an empty `approved-commands = []` could be removed by an unrelated update. ([#3055](max-sixty/worktrunk#3055))

- **Migrated `[forge]` keeps `[ci]`'s spot**: The `[ci]` → `[forge]` migration rendered the new section at the end of the file and could drop comments above `[ci]`; it now takes over `[ci]`'s position, comments included, so `wt config show` and `wt config update` diffs stay minimal. ([#3051](max-sixty/worktrunk#3051))

- **`wt config state get` is read-only**: The aggregate dump resolved (and re-cached) the default branch, so running it right after `clear` silently repopulated the cache, and on a cold clone it could hit the network. It now reports the cached value or `(none)`. `wt config state default-branch get` still resolves and caches. ([#3024](max-sixty/worktrunk#3024))

### Documentation

- **Reading vs resolving cached state**: `wt config state default-branch get` resolves and caches; the aggregate `wt config state get` only reports the cache. The help text and module docs now state the split. ([#3028](max-sixty/worktrunk#3028))

### Internal

- `wt switch`/`wt remove` orchestration moved from `main.rs` to their command modules, and the hook execution call chain lost two delegation layers. ([#3049](max-sixty/worktrunk#3049), [#3036](max-sixty/worktrunk#3036))

- Config deprecations are driven by a single rule table; each rule is one function that migrates and reports what it changed. ([#3045](max-sixty/worktrunk#3045), [#3055](max-sixty/worktrunk#3055))

- `terminal_width()` returns `Option<usize>` instead of a `usize::MAX` sentinel, making the no-width case a compile-time concern. ([#3043](max-sixty/worktrunk#3043))

- Snapshot tests regenerate identically across machines: host-specific paths are guarded, host-dependent env-block markers are normalized, and help snapshots share one settings builder. ([#3009](max-sixty/worktrunk#3009), [#3026](max-sixty/worktrunk#3026), [#3037](max-sixty/worktrunk#3037), [#3061](max-sixty/worktrunk#3061))

- Nightly CI runs lib tests across the full feature powerset. ([#3059](max-sixty/worktrunk#3059))

- MSRV bumped from 1.94 to 1.95. ([#2948](max-sixty/worktrunk#2948))

## Install worktrunk 0.58.0

### Install prebuilt binaries via shell script

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-installer.sh | sh && wt config shell install
```

### Install prebuilt binaries via powershell script

```sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-installer.ps1 | iex"; git-wt config shell install
```

### Install prebuilt binaries via Homebrew

```sh
brew install worktrunk && wt config shell install
```

## Download worktrunk 0.58.0

|  File  | Platform | Checksum |
|--------|----------|----------|
| [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) |
| [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.58.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) |

See merge request: Harmonybrew/homebrew-core!11501
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