Skip to content

Deprecate table form for pre-* hooks - #2135

Merged
max-sixty merged 1 commit into
mainfrom
deprecate-pre-hook-table-form
Apr 12, 2026
Merged

max-sixty merged 1 commit into
mainfrom
deprecate-pre-hook-table-form

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Multi-entry table form for pre-* hooks currently runs serially, while the same form for post-* hooks runs concurrently. The parser produces HookStep::Concurrent either way, but the foreground executor flattens steps and runs them serially. To unify the semantics — table form will run concurrently for all hook types in a future version — this deprecates the current form for pre-* hooks and auto-migrates it to pipeline form, which is explicitly serial.

Implementation

Follows the existing deprecation recipe in src/config/deprecation.rs:

  • Detection and migration for top-level hooks (user/project config) and per-project overrides ([projects."id".pre-*]).
  • Warning: matches the terse {old} → {new} pattern of existing deprecations ([merge] no-ff → ff, post-create → pre-start, etc.).
  • Auto-migration at load time: table form rewrites to pipeline of inline tables so current behavior (serial) is preserved until users run wt config update.

Docs

Replaces the transitional "concurrent for post-, sequential for pre-" framing with a neutral three-form description (string / table / pipeline), plus a note recommending pipeline form for pre-* hooks to avoid the upcoming behavior change.

Tests

  • snapshot_migrate_pre_hook_table_form — TOML migration diff
  • test_config_show_displays_pre_hook_table_form_deprecation — full user-facing wt config show output, covering the "Project config" label and multi-hook list form
  • Unit tests for detection/migration of top-level and per-project variants
  • Existing integration test fixtures migrated to canonical pipeline form

This was written by Claude Code on behalf of max-sixty

Multi-entry table form for pre-* hooks currently runs serially while the
same form for post-* hooks runs concurrently. To unify the semantics — table
form will run concurrently for all hook types in a future version — detect
and auto-migrate the deprecated form to pipeline form, which is explicitly
serial.

Adds detection, auto-migration, warning, and `.new` file generation following
the existing deprecation recipe in src/config/deprecation.rs. Updates docs to
describe the three hook forms (string / table / pipeline) neutrally, with a
note recommending pipeline form for pre-* hooks. Migrates existing test
fixtures to canonical pipeline form.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 37fb27b into main Apr 12, 2026
24 checks passed
@max-sixty
max-sixty deleted the deprecate-pre-hook-table-form branch April 12, 2026 22:55
max-sixty added a commit that referenced this pull request Apr 12, 2026
Hooks are `#[serde(flatten)]` into UserConfig and ProjectConfig, so
`[hooks]` and `[projects."id".hooks]` are never real configs — serde
rejects `hooks` as an unknown key. Mirror the simplification PR #2135
applied to `find_pre_hook_table_form_from_doc`: two branches only, top
level and per-project subtree directly.

Co-Authored-By: Claude <[email protected]>
max-sixty added a commit that referenced this pull request Apr 12, 2026
Hooks are `#[serde(flatten)]` into `UserConfig` and `ProjectConfig`, so
`[hooks]` and `[projects."id".hooks]` are never real configs — serde
rejects `hooks` as an unknown key. The `find_post_create_from_doc` and
`migrate_post_create_doc` helpers each checked those subtrees anyway.

Mirrors the simplification #2135 applied to
`find_pre_hook_table_form_from_doc`: two branches only — top level and
per-project subtree directly. Unit tests that exercised the dead formats
are retargeted to the real flattened layout (`[projects."id"]` with
`post-create` at the project level).

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request Jun 12, 2026
…rial path (#3052)

## 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` (#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 #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_

---------

Co-authored-by: Claude Fable 5 <[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