Skip to content

fix(config): migrate [ci] platform into a [forge] table that lacks it - #4061

Merged
max-sixty merged 2 commits into
mainfrom
nightly/clean-34446121464-ci-forge
Sep 10, 2026
Merged

max-sixty merged 2 commits into
mainfrom
nightly/clean-34446121464-ci-forge

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

migrate_ci_doc stood down whenever a forge key existed at all. But a [forge] table that only sets hostname has the platform slot free — there is nothing unsafe there to guard against, and the rule reports nothing when it makes no change, so the deprecated [ci] platform was left in place, no deprecation warning fired, and wt config update didn't move it either.

That is the config a GitHub Enterprise or self-hosted GitLab user arrives at by the obvious route: [ci] platform predates the [forge] rename, and [forge] hostname gets added later when an SSH host alias breaks pr: resolution. From then on the deprecated key is pinned silently. Nothing is broken today — ProjectConfig::forge_platform falls back to ci.platform — but the deprecation messaging is the only thing standing between that user and a config that stops working when [ci] is finally removed, and it never reached them.

The guard now keys on the destination key rather than on forge existing: an occupied platform, or a forge that isn't a table (forge = "x", an inline table), still stands down and leaves the document byte-identical. A free platform slot in an existing [forge] takes the migrated entry, key decor and all.

One wrinkle worth flagging: when the migration empties [ci] and creates [forge] itself, [ci]'s decor — the comment above its header — moves to the new table. Inserting into an existing [forge] has nowhere to put that comment, since [forge] is wherever the user wrote it, possibly far away. So an emptied [ci] is removed only when its own decor is blank; a commented one stays behind as an empty section. That contributes no config and raises no warning, and it keeps the user's prose where they put it. test_ci_migration_keeps_commented_ci_when_forge_exists pins that shape.

The framework invariant holds either way — test_warning_fires_iff_update_changes gains the newly-migrating cases in its rewritten list (with and without the comment) and the inline-table suppression in untouched. All four new or extended tests fail against the pre-fix guard.

Verification
cargo test --lib config::deprecation   # 165 passed
cargo fmt --check                      # clean
cargo clippy --lib --all-features      # clean
cargo test --lib                       # 1523 passed, 1 failed

The one cargo test --lib failure is copy::tests::test_copy_dir_recursive_does_not_count_a_non_regular_file, which binds a Unix domain socket; the CI agent sandbox blocks socket(AF_UNIX, …), so it fails there regardless of this change. ci is green on main at 0683ad8.

…s it

`migrate_ci_doc` suppressed the `[ci]` → `[forge]` migration whenever a
`forge` key existed at all. A `[forge]` table that only sets `hostname` has
the `platform` slot free, so there was nothing unsafe to guard against — the
deprecated key was simply left in place, and because the rule reports nothing
when it makes no change, no deprecation warning fired and `wt config update`
did not fix it either.

That is the shape a GitHub Enterprise or self-hosted GitLab user lands in:
`[ci] platform` predates `[forge]`, and adding `[forge] hostname` for an SSH
host alias silently pins the deprecated key forever. `forge_platform()` still
falls back to `ci.platform`, so behavior was correct — but the messaging that
protects the user when `[ci]` is finally removed never reached them.

The guard now keys on the destination *key* rather than the presence of
`forge`: an occupied `platform`, or a `forge` that is not a table, still
suppresses. An emptied `[ci]` whose decor carries a comment stays as an empty
section, since an existing `[forge]` is wherever the user wrote it and has no
home for that prose; an empty section contributes no config and raises no
warning, so the update stays idempotent.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Sep 10, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Self-review, so no verdict — one finding.

The DEPRECATION_RULES docstring now describes only one of the two branches. Its paragraph beginning "The [ci] → [forge] rule is order-independent" gives the mechanism as "[forge] takes over [ci]'s explicit document position" — which after this change is the ForgeSlot::Absent path only. In FreeSlot the destination keeps the position it was parsed at and [ci]'s position is discarded entirely. The conclusion still holds, because a parsed [forge] has an explicit position of its own, but the reason is what a future rule author reaches for when reasoning about where a migrated table lands, and CLAUDE.md under Code Quality asks that these specs be kept current ("complex systems … get a module-level spec docstring … keep it current"). Suggested replacement for that paragraph:

/// The `[ci]` → `[forge]` rule is order-independent: `[forge]` renders at an
/// explicit document position either way — the one it was parsed at, or
/// `[ci]`'s when the rule creates the table (see [`migrate_ci_doc`]) — so its
/// rendered placement doesn't depend on which tables other rules re-append.

…ES spec

The order-independence paragraph gave the mechanism as `[forge]` taking over `[ci]`'s position, which is only the branch that creates the table. When the rule inserts into an existing `[forge]`, the destination keeps the position it was parsed at and `[ci]`'s is discarded. The conclusion is unchanged — a parsed `[forge]` has an explicit position of its own — but the reason is what a future rule author reads.
@max-sixty
max-sixty merged commit 3d1b5d5 into main Sep 10, 2026
37 checks passed
@max-sixty
max-sixty deleted the nightly/clean-34446121464-ci-forge branch September 10, 2026 11:33
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.78.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

- **Hook scripts read renamed context keys**: the JSON piped to every hook drops `worktree`, `repo_root`, `main_worktree`, and `main_worktree_path` in favour of `worktree_path`, `repo_path`, `repo`, and `primary_worktree_path`. Config templates migrate on load, so hooks written with the old names keep working; scripts reading the JSON, `--execute` templates, and `--var` overrides need updating. (Breaking.) ([#4080](max-sixty/worktrunk#4080))

- **`wt config plugins pi` installs for Pi; oh-my-pi moves to `wt config plugins omp`**: `pi install` wrote an oh-my-pi hook, which Pi never loads; Pi users re-run it to get a Pi extension. Existing oh-my-pi hooks keep working, listed as outdated until `wt config plugins omp install`. (Breaking: scripts that run `wt config plugins pi` for oh-my-pi need `omp`.) [Docs](https://worktrunk.dev/claude-code/#oh-my-pi) ([#4135](max-sixty/worktrunk#4135), thanks @ashebanow)

- **Interactive prompts no longer open with a blank line**: `wt config shell install`, `wt config plugins claude install`, and the commit-message setup offer in `wt merge` began with one. ([#4059](max-sixty/worktrunk#4059))

- **`wt config show` gives a single `wt config shell install` hint**: an outdated wrapper, a fish wrapper at the deprecated `conf.d` path, and missing fish completions each printed their own hint. The zsh `compinit` snippet is now syntax-highlighted. ([#4059](max-sixty/worktrunk#4059))

- **`wt config update --output <path>` confirms the write**: it now prints `✓ Wrote user config migration @ ~/migrated.toml` where it printed nothing. `--output=-` stays silent. ([#4053](max-sixty/worktrunk#4053))

### Fixed

- **Removal no longer discards untracked files hidden by `status.showUntrackedFiles = no`**: under that setting, a worktree holding only untracked files looked clean, so `wt remove`, `wt merge`, and `wt step prune` removed it without `--force`. Safety checks now always count untracked files, and auto-staging warnings list every file they stage. ([#4111](max-sixty/worktrunk#4111), thanks @Duang777)

- **`wt remove` and `wt merge` check the right worktree under an inherited `GIT_DIR`**: run from a `!wt` git alias or a git hook, which pass `GIT_DIR` down, `wt remove` could delete a dirty worktree without `--force`, and `wt merge` could refuse a clean merge. Both now check the worktree they act on. ([#4082](max-sixty/worktrunk#4082), thanks @Duang777)

- **`wt merge` no longer deletes a worktree locked with `git worktree lock`**: the merge completes and prints `Worktree preserved (locked)`. Every Worktrunk removal refuses a locked worktree, even with `--force`; run `git worktree unlock <path>` first. ([#4073](max-sixty/worktrunk#4073), thanks @Duang777)

- **`wt config update` no longer overwrites a config edited while its prompt is open**: it wrote the pre-prompt snapshot over the newer file and reported success. It now fails with the path and leaves the newer file; re-running previews the current contents. ([#4127](max-sixty/worktrunk#4127), thanks @zach-hammad-vs for reporting)

- **`wt step prune` no longer deletes a branch created minutes ago from an older commit**: `--min-age` aged a branch without a worktree by its commit's date, so a new branch off a day-old commit was pruned on the next run. Age now comes from the branch's oldest reflog entry. ([#4077](max-sixty/worktrunk#4077))

- **A comment or blank line above an inline config section no longer breaks the config**: a save or migration that rewrote `commit = { … }` as `[commit]` put that line inside the brackets. `wt switch`, `wt merge`, `wt remove`, and several `wt step` commands then failed with `Failed to load config`; `wt list` warned and ran without the config. Saves also dropped unrecognized keys from inline sections. ([#4120](max-sixty/worktrunk#4120), thanks @zach-hammad-vs for reporting)

- **Config saves keep the trailing comment on a value they rewrite**: a save such as answering the commit-generation offer dropped the comment after each value it rewrote, including one after an inline section's closing brace. ([#4138](max-sixty/worktrunk#4138))

- **Ignored project-config keys warn from every worktree**: an unknown key in `.config/wt.toml`, or one that belongs in user config such as `[merge]`, warned only in the main worktree, so `wt merge` from a linked worktree ignored it silently. ([#4145](max-sixty/worktrunk#4145), thanks @ee-prog for reporting)

- **`wt merge` skips `post-commit` when it removes that hook's worktree**: before, the hook ran in the primary worktree when the removed one sat inside the repository, and otherwise didn't run. The merge now prints `▲ Skipped post-commit`; move work that must finish there to `pre-remove`. ([#4049](max-sixty/worktrunk#4049))

- **`wt switch` recovers from a removed worktree in a bare repository**: `wt switch` and the picker surfaced git's raw `fatal: Unable to read current working directory` instead, and the removed-directory message lacked `wt switch ^`. ([#4067](max-sixty/worktrunk#4067))

- **`wt config shell install fish` puts the wrapper where fish reads it under a custom `$XDG_CONFIG_HOME`**: the wrapper always went to `~/.config/fish/functions/`, so install reported success while `wt switch` changed no directory. On Windows, the fish completion moves from `%APPDATA%\fish\completions` to the wrapper's directory. ([#4107](max-sixty/worktrunk#4107))

- **`wt config shell install zsh` honours `$ZDOTDIR` only when it is absolute**: an empty or relative value resolved against the current directory, so install appended to a `.zshrc` under the current directory and reported success while the file zsh reads went untouched. A non-absolute value now falls back to `$HOME`. ([#4085](max-sixty/worktrunk#4085))

- **`wt config shell install` for Nushell no longer deletes a `wt.nu` under the current directory**: an empty or relative `$XDG_CONFIG_HOME` resolved against it, so install removed a `nushell/vendor/autoload/wt.nu` beneath it unread, as a stale wrapper. It now falls back to `~/.config`, which also fixes unread `tea` logins that let `wt switch pr:<n>` treat a Gitea host as GitHub. ([#4104](max-sixty/worktrunk#4104))

- **`wt switch --create` names the branch a failed worktree add leaves behind**: `git worktree add -b` writes the branch ref before populating the worktree, so a failure in between left the branch with no worktree, and the next attempt reported a name collision. The error now says how to delete or reuse it. ([#4109](max-sixty/worktrunk#4109), thanks @technicalpickles for reporting)

- **`wt config shell install` no longer tells an already-wrapped shell to restart**: reinstalling from a shell with the wrapper loaded, such as after a version bump, printed `↳ Restart shell to activate shell integration`. ([#4059](max-sixty/worktrunk#4059))

- **`wt config shell install` migrates a deprecated `conf.d` fish wrapper when `~/.config/fish/functions` is missing**: before, only `wt config shell install fish` migrated it. `wt config show` now reports that wrapper even when fish isn't on `PATH`. ([#4059](max-sixty/worktrunk#4059))

- **Plugin status and uninstall checks ask the agent CLIs**: `wt config show` could list an installed Claude Code plugin or Gemini CLI extension as not installed, and `wt config plugins claude|codex uninstall` could report success over a marketplace still configured. A repeat Claude uninstall now runs both removals instead of stopping at `Plugin not installed`. ([#4048](max-sixty/worktrunk#4048), [#4054](max-sixty/worktrunk#4054))

- **`wt config plugins opencode install` no longer writes the plugin into the current directory**: with `OPENCODE_CONFIG_DIR` set but empty, it wrote `plugins/worktrunk.ts` there, typically inside a repository, reporting success though OpenCode never saw it. An empty value now counts as unset. ([#4084](max-sixty/worktrunk#4084))

- **The OpenCode plugin clears its activity marker when OpenCode 1 disposes it**: only explicit session deletion cleared it, so a finished session kept its `💬` and `wt list` showed it as active until `wt config state marker clear` was run by hand. ([#4129](max-sixty/worktrunk#4129), thanks @drewdas for reporting)

- **`wt config update` migrates `[ci] platform` into a `[forge]` section that only sets `hostname`**: that config, common with GitHub Enterprise and self-hosted GitLab, kept the deprecated key with no deprecation warning. ([#4061](max-sixty/worktrunk#4061))

- **Deprecated keys in an inline `[projects]` entry now migrate**: `"example.com/org/repo" = { merge = { no-ff = true } }` skipped the migration the section form got, so the per-project setting was ignored. ([#4122](max-sixty/worktrunk#4122), thanks @zach-hammad-vs for reporting)

- **A deprecated config section the migration can't rewrite now warns**: `select = "not a table"`, or a `[select]` whose `[switch.picker]` destination is already set, was ignored without a message. It now reports `unknown field select (will be ignored)`. ([#4121](max-sixty/worktrunk#4121), thanks @zach-hammad-vs for reporting)

- **`wt config update` no longer changes what a template renders**: it could rename `{{ repo_root }}` inside a quoted s

See merge request: Harmonybrew/homebrew-core!20435
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants