Repository navigation
Description
Description
The scaffold's knob renders mutate .pre-commit-config.yaml in place, and that
file is preserved across upgrades (assets/init-workspace.sh:107, #878 — the
consumer owns its hook excludes). Each render early-returns when its manifest key
is empty:
render_commit_types() {
[[ -z "$MANIFEST_COMMIT_TYPES" ]] && return 0So the file is a persistent accumulator of past renders, and an empty key means
"don't touch it", not "restore the default". A consumer who sets a knob, then
clears it to go back to the default, keeps the previous render locally forever
— while CI, which re-derives from .vig-os on every run with no memory, resolves
the default. Local and CI then disagree about the same gate.
Affects the three renders that write a value into the preserved config:
render_commit_types (#1431), render_branch_types (#1432), and
render_refs_policy (#1282/#1633).
Steps to Reproduce
- Scaffold a workspace.
- Set
DEVKIT_COMMIT_TYPES=feat,fix,recordin.vig-os, run the upgrade.
.pre-commit-config.yamlnow carries"--types", "feat,fix,record". - Clear the key back to
DEVKIT_COMMIT_TYPES=— which the manifest comment
documents as "the stock 11 types" — and run the upgrade again. grep -- --types .pre-commit-config.yaml.
Expected Behavior
The hook arg returns to the stock 11 types, matching what resolve-toolchain
emits for the same manifest.
Actual Behavior
The hook arg is still feat,fix,record. record(...): … passes the local
commit-msg hook and fails CI's validate-commit-range. The same holds for
DEVKIT_BRANCH_TYPES (branch guard) and DEVKIT_REFS_OPTIONAL_TYPES /
DEVKIT_REFS_POLICY (Refs exemption).
Nothing catches it: the scaffold-drift gate (#1295) re-runs the scaffold and
git diffs, so it hits the same empty-key early return, reproduces the stale
file byte-identically, and sees no drift. It detects hand-edits and stale pins,
not a render that was never applied. The upgrade's preserved-file diff against
the template makes it visible, if noticed.
Environment
Any consumer on any delivery mode; reproduced against dev.
Possible Solution
Make the three renders unconditional and idempotent: always write the
resolved value (which for an unset knob is a no-op write of identical bytes, so a
default scaffold stays byte-identical). Two things that makes load-bearing:
- A symlink guard is required.
[[ -f "$pc" ]]is true for symlinks, and in
flake-hooks mode.pre-commit-config.yamlis a gitignored/nix/store
symlink that materializes on shell entry (feat(workspace): generate .pre-commit-config.yaml from the flake (git-hooks.nix) — composable base hooks, consumer-extensible in the project flake #883/direnv-mode scaffold ships hand-managed pre-commit config whose pymarkdown hook cannot run on host runners #1167,:1415). GNUsed -i
replaces a symlink with a regular file, which would silently shadow the
flake-generated config with a frozen copy — turning a staleness bug into a
broken opt-in. Every render needs[[ -L "$pc" ]] && return 0before the sed. render_branch_typesneeds a generic anchor. It is anchored on the
literal STOCK alternation ((feature|bugfix|hotfix|release|docs|test|refactor)/[0-9]),
so once a custom set has been rendered the anchor no longer matches and the
stock set can never be restored. It must match whatever alternation currently
occupies that slot, the way the[^"]*value anchors in the other two renders
already do.
Out of scope: render_workflow_model's gitflow → trunk transform has the same
one-way shape (switching back cannot restore the dropped (?!dev$) clause), but
it is a set of prose/marker substitutions rather than a single value slot, so it
wants separate treatment.
Additional Context
Found while reviewing #1633. That PR's first version gated render_refs_policy
on the resolved value rather than the key, which extended the same failure to a
key that was set to a valid value; it was reverted to a key-shaped gate so
refs behaves exactly like its two siblings, and the remaining gap was left for
this issue rather than fixed as a drive-by across three renderers.
Activity
test: pin knob renders as idempotent and symlink-safe
fix(workspace): render knobs unconditionally and refuse symlinks
fix(workspace): render knobs unconditionally and refuse symlinks (#1641)
c-vigo commentedon Sep 17, 2026
Shipped to
devin #1641 (merge commit 4914a5f), all 12 checks green.The three knob renders —
render_commit_types,render_branch_typesandrender_refs_policy— are now unconditional and idempotent: the resolved valueis written on every run. An unset knob rewrites exactly what the template already
ships, so a default scaffold stays byte-identical and the drift baseline is
untouched; a cleared knob now gets the default back instead of stranding the
previous render in the preserved config.
Two things the fix needed beyond dropping the early return:
render_branch_typesneeded a generic anchor. It was anchored on theliteral stock alternation, which by construction stops matching the moment a
custom set has been rendered — so making it unconditional alone would have
fixed nothing there, since the stock set could never be written back. The
anchor is now the
(?!^(prefix plus the)/[0-9]suffix, which together pinexactly that one alternation: the
(chore)/[a-z0-9]clause has the wrongsuffix and the
renovate/worktreeclauses have no inner group. Verified toround-trip byte-identically (stock → custom → stock reproduces the template
line exactly) before being trusted.
precommit_render_targetresolver, refusing symlinks, which is whatmakes the rest safe.
render_workflow_model's.pre-commit-config.yamlblockwas carrying the same latent hazard and now goes through it too.
Verified with five bats cases committed failing first (
b4963195) — and thesymlink case failed after a successful upgrade, i.e. because the symlink was
genuinely replaced by a regular file, not because the scaffold errored. Full
bats tests/bats/init-workspace.bats266 passed / 0 failed, deliberatelyincluding the #1255 flake-hooks fixtures and the trunk-render composition tests
since this touches shared machinery;
pytest1071 passed / 1 skipped;prek run --all-filesgreen with no reformats.Left out, as flagged in the issue:
render_workflow_model'sgitflow → trunktransform has the same one-way shape — switching a consumer back cannot restore
the dropped
(?!dev$)clause or the prose substitutions. It is a set of anchoredsubstitutions across many files rather than a single value slot, so it needs its
own design rather than this pattern. It does get the symlink guard, since that
hazard is identical.
Closing as done. It reaches consumers with the next release train.
fix(workspace): render the branch guard from the workflow model both …
chore: release 1.15.0 (#1644)
feat(workspace): ship the actionlint hook and its label config to con…
feat: give every Refs-optional commit type an issue-less branch form (#…
feat(hooks): one branch-name rule via vig-utils validate-branch-name (#…