ADR-0026: Configs and baselines move forward between versions with one command
Status: Accepted Date: 2026-09-30
Context
The config and the baseline are committed, and both are public API (ADR-0011). A setting is deprecated with a warning for at least one minor release and removed only in a major (ADR-0011). A project on an older major needs a way to its successor's config that does not mean reading a changelog key by key.
What exists to build on:
- The config has no version marker. JSON's
$schemanames the release line in its URL (…/php-mutation-gate/v0.1/resources/mutation-gate.schema.json, ADR-0002). The baseline has"format": 1(ADR-0003). - Every format reads into one form. Each config file, in any of the four formats, is read through the same definition (ADR-0002), and an unknown key is an error that names the nearest known key (ADR-0002).
- The formats differ in what a rewrite keeps.
config:show --format=…writes any format from the effective config, and writes no comments.- php-parser's format-preserving printer keeps a PHP file's layout and comments, and edits only the nodes that change.
symfony/yamlandnette/neonparse into plain PHP values, which hold no comments, so a file they write back has none.
- The ledger needs no migration. A ledger of another format is not read, and the verdict warns so, which costs a run and never a verdict (ADR-0007).
Decision
A file's version is known by what it holds.
- Every key the gate has ever renamed or removed stays known to the definition, with the version that changed it.
- A file that holds one is read as that version's file. The error for it
names the change and the command, in the form
<old key>became<new key>in : runvendor/bin/mutation-gate migrate, the gate named as it was started (ADR-0022). - No file carries a version key.
This amends ADR-0002.
A migration is data: typed steps in
Core.- The steps are
Rename(from, to),Move(from, to),MapValue(key, old, new),Split(from, {part => to})andRemove(key, because), each tied to the version that made it.Renamegives a key another name under the same parent, where it stands.Movetakes a key and its value anywhere else.Splitmoves each named part of the object atfromto a key of its own. A part it does not name stays underfrom. A scalar cannot be split, so afromthat holds one is left for a hand edit.
- Each step may also name the builder spelling it retires and, for a
rename or a move, the one that replaces it, such as
Reach::everythingbecomingReach::allwith the same arguments. A PHP config is changed through these spellings alone. - The steps apply to the JSON form every format reads into (ADR-0002), before the definition reads it, so one step serves the JSON, YAML and NEON formats.
- A step that still applies once every step has run, such as a rename whose new key is already written, is left for a hand edit.
- Each step has a fixture per format, and a test that the migrated file reads with no problem.
- The steps are
The file is written back keeping what its format can keep.
- PHP: php-parser's format-preserving printer edits only the builder
calls a step touches, and keeps every comment and the layout.
- It finds a step's calls by the spelling the step retires, anywhere
in the file, so a call held in a variable is found too. A rename or a move gives the call
the new spelling and keeps its arguments. A removal takes the call out
of the chain, or out of
with(). - A call it cannot rewrite is never guessed at, and is listed with its
line for a hand edit. Such calls are a
MapValuecall whose argument is not a literal, aSplitcall, and, wherever a step names a spelling, awith()argument that is not a builder call, since nothing short of running it says which keys it writes.
- It finds a step's calls by the spelling the step retires, anywhere
in the file, so a call held in a variable is found too. A rename or a move gives the call
the new spelling and keeps its arguments. A removal takes the call out
of the chain, or out of
- JSON: each step is a key-level text edit, through a JSON tokenizer
in
Corethat keeps the file's whitespace and key order. JSON holds no comments. A$schemathat names this package's published schema of another release line is rewritten to the current line's, on every JSON migration. A$schemathat names a local path, such as the oneinitwrites intovendor, is left as it is. - YAML and NEON: the file is written again from its migrated form.
The diff says that its comments are not kept, and
--writesays so again, and then writes it.
The PHP config is parsed, never included, so migrating it runs none of it. This needs
nikic/php-parserinrequire, as ADR-0021 puts it. A PHP config that cannot load because it calls a spelling a step retired fails with that step's error.- PHP: php-parser's format-preserving printer edits only the builder
calls a step touches, and keeps every comment and the layout.
The baseline migrates too. A change of the baseline's
formatis migrated by the same command and the same kind of step. The ledger is not migrated (ADR-0007).mutation-gate migrate [--config=<path>] [--write]shows before it writes.- It prints a unified diff of every file it would change, and writes only
with
--write, asbaseline --writedoes (ADR-0003). - Exit 0 when every file is current or has been written.
- Exit 1 when a migration is pending and
--writewas not given, so CI can check that nothing is behind, and when a hand edit is left, with--writeor without it. - Exit 2 when the named file is not a config the gate can read.
- It writes only the config and the baseline, and nothing else.
The command is public API. This amends ADR-0002 and ADR-0011.
- It prints a unified diff of every file it would change, and writes only
with
The machinery is tested with synthetic old keys. Its steps, the format-preserving PHP edit and the command are part of the first release, which has no older version to migrate from, and are tested with keys made up for the tests.
Alternatives considered
| Option | Why it lost |
|---|---|
A version key in every config, written by init | A key every file must carry, which a hand edit forgets to bump. The keys that make a file old already say how old it is. |
| A PHP class per version, with free code | Flexible, untestable in general, and it grows without limit. Typed steps are data. |
Always writing the file again through config:show's writer | One writer, and every comment and custom line of a PHP config, the canonical format, lost. |
| The config only | The first change of the baseline's format would need a second tool. |
| Writing without being asked | A migration is a change to a committed file, and a reviewer should see its diff first. |
Consequences
Moving to a new major is one command, whose diff a reviewer reads before it is written.
A PHP config keeps its comments and layout through a migration. YAML and NEON say beforehand that theirs do not.
CI can check that a project's config is current from the exit code.