Repository navigation
feat(init): insert the shellcheck-composite-actions hook into preserved configs from 1.17.0 - #1726
Merged
Merged
Conversation
The composite-action shellcheck hook (#1704, scaffolded by #1718) reaches new scaffolds only: a preserved .pre-commit-config.yaml never receives template evolution (#878), so every existing consumer leaves .github/actions/*/action.yml run bodies unlinted. Case 2 of #1654 is the seam that fixes it, and it needs one row in inserted_hook_blocks(). The row's version is 1.17.0. dev already holds two feat commits since 1.16.0 (#1718 and #1724) and no breaking change, so the next train is 1.17.0 by construction; the only rename still possible is upward, and an upward rename is harmless for this row (every consumer's pin is below 1.17.0 at adoption, and nobody can sit exactly at 1.17.0). A DOWNWARD rename is the one that would hurt — it re-adds a hook a consumer deleted, the #1651 defect — and a feat on dev rules that out. #1723's Phase 1 prerequisite covers the re-check either way. Two fields, not three: the hook belongs to no feature group, so the row omits the group and `read -r ver hook feat` leaves feat empty. The row must also come AFTER the actionlint one, because the insert anchors on the previous hook in template order: a pre-1.16.0 tree receives actionlint first and anchors this block on what that row just inserted, in a single pass. The three boundary tests (pin at 1.17.0, pin at 1.17.1, hook already present) pass vacuously until the row exists; they are the guard against the row being set too low later. Refs: #1717
…ed configs from 1.17.0 One row in inserted_hook_blocks(), so Case 2 of #1654 carries #1704's hook into the preserved .pre-commit-config.yaml of every consumer whose tree predates it. Until now the hook reached new scaffolds only (#1718), leaving every existing repo's .github/actions/*/action.yml run bodies unlinted — actionlint refuses a composite action outright and has no composite mode. The row is two fields wide: the hook belongs to no feature group, and `read -r ver hook feat` leaves feat empty, which the gate reads as "never opted out". It sits AFTER the actionlint row because the insert anchors on the hook the template places before this one, so a pre-1.16.0 tree gains actionlint and then anchors this block on it within the same pass. 1.17.0 is the version by construction: dev already holds two feat commits since 1.16.0 (#1718, #1724) and no breaking change, so the next train is a minor. The only rename still available is upward, and an upward rename leaves the row harmless — every consumer's pin is below 1.17.0 at adoption and nobody can be pinned exactly at 1.17.0. A downward rename is the direction that would re-add a hook a consumer deleted (the #1651 defect); it would have to edit this row on the release branch, which #1723's Phase 1 prerequisite now makes a checked step. Refs: #1717
A pin at the actionlint release must see no insert of any hook, so the assertion covers every row rather than only actionlint's. Refs: #1717
This was referenced Sep 25, 2026
[CHORE] Insert the shellcheck-composite-actions hook into existing consumer configs on upgrade
#1717
Closed
c-vigo
added a commit
that referenced
this pull request
Sep 25, 2026
…ecessor (#1728) ## Description Two defects in how a new scaffolded hook reaches a consumer's preserved `.pre-commit-config.yaml`, both exposed by the `1.17.0 shellcheck-composite-actions` row from #1726. **A disabled anchor blocked the hook after it.** The insert anchored on the single hook the template places immediately before the new one. For the composite hook that is `actionlint`, so a consumer pinned below 1.17.0 with `DEVKIT_FEATURES_DISABLED=actionlint` had no anchor and was skipped with a warning on every upgrade, forever — while a fresh scaffold with the same opt-out does get the hook, since it sits outside the actionlint sentinels. Now `template_hook_anchors` returns every predecessor nearest-first, the insert walks them and anchors on the first one present in the consumer's file, and the warning fires only when none is. The chosen anchor's range is still whatever `hook_block_range` prefers — the sentinel range where one exists — so an insert after a present `actionlint` still lands after `# <<< devkit:actionlint`, outside what the feature's excision deletes. **The inserted block lost its rationale.** An un-sentinelled template entry was extracted byte-exact from its `- repo:` line, so the consumer's copy carried none of the prose above it. The structural branch of `hook_block_range` now sweeps upward over the contiguous run of whole-line comments, stopping at a blank line, a non-comment line, or either sentinel marker, so it can neither swallow the previous block's text nor half a sentinel pair. Only the range's start moves; the anchor path reads the end. **Why not sentinel-wrap the composite entry instead** (the alternative noted on the issue): sentinels mean feature-gated excision, and the composite hook belongs to no group. Decisively, `hook_block_range` matches sentinel ids by prefix, so a `# >>> devkit:shellcheck-composite-actions` marker would satisfy a lookup for `shellcheck` — breaking the very fallback that anchors on it. Verified against a fixture; recorded in the function's docstring so nobody takes that route later. **Behaviour change to be aware of:** a pin at or below 1.16.0 whose config lacks the actionlint block now gains the composite hook through the `shellcheck` fallback. That is the fix, not a #1651 regression: those pins have never seen the composite hook (its row is 1.17.0); the actionlint row itself still stands down at 1.16.0. Two existing assertions were narrowed to `preserved-hook-insert: actionlint` for that reason, with docstrings saying why. ## Type of Change - [ ] `feat` -- New feature - [x] `fix` -- Bug fix - [x] `docs` -- Documentation only - [ ] `chore` -- Maintenance task (deps, config, etc.) - [ ] `refactor` -- Code restructuring (no behavior change) - [x] `test` -- Adding or updating tests - [ ] `ci` -- CI/CD pipeline changes - [ ] `build` -- Build system or dependency changes - [ ] `revert` -- Reverts a previous commit - [ ] `style` -- Code style (formatting, whitespace) ### Modifiers - [ ] Breaking change (`!`) -- This change breaks backward compatibility ## Changes Made `assets/init-workspace.sh` - `template_hook_anchor` → `template_hook_anchors` (all predecessors, nearest first); `insert_missing_hook_blocks` walks them and anchors on the first present, warning only when none is - `hook_block_range` structural branch sweeps the comment run above the `- repo:` line (three stop conditions); the docstring records the sentinel prefix-match trap and why an ungrouped hook stays un-sentinelled `tests/test_scaffold_preserved_hooks.py` - `test_a_disabled_anchor_does_not_block_the_hook_after_it` (pin 1.16.0 + actionlint disabled ⇒ `[shellcheck, shellcheck-composite-actions, typos]`, no warning), `test_the_walk_stops_at_the_nearest_present_predecessor` (after the actionlint sentinel end), a seed lacking every predecessor still warns and writes nothing, `test_the_inserted_block_carries_the_template_comment_above_it`, and `test_the_folded_block_carries_the_template_comment` (the retired-block fold shares the extractor; the consumer's own comment survives above the template's). Each RED before its fix `docs/MIGRATION.md`, `CHANGELOG.md` (+ generated mirror) - Consumer prose: the block lands after the nearest predecessor the file still carries, and an opt-out no longer withholds the hooks behind it; `### Fixed` entry with three sub-bullets (anchor walk, comment run, fold side effect). The `inserted_hook_blocks()` row-order comment is corrected: order is position, not delivery (review finding) ## Changelog Entry ### Fixed - **Preserved-config hook inserts survive a disabled anchor and keep their rationale** ([#1725](#1725)) - A new scaffolded hook was inserted into a preserved `.pre-commit-config.yaml` after the single hook the template places immediately before it, so a consumer pinned below 1.17.0 with `DEVKIT_FEATURES_DISABLED=actionlint` had no anchor for `shellcheck-composite-actions` and lost the hook to a warning on every upgrade, forever — while a *fresh* scaffold with the same opt-out does ship it. The insert now walks every predecessor the template declares, nearest first, and anchors on the first one the file carries (here `shellcheck`); the warning is reached only when the file carries not one of them. A present anchor still wins, and still contributes its **sentinel** range where it has one, so an insert after a bracketed block lands past its closing sentinel rather than inside the range a feature excision deletes - An un-sentinelled template entry was extracted from its `- repo:` line down, so the prose above it — why the hook exists, what it deliberately does not cover — stayed in the template and the consumer's copy arrived as an unexplained `entry:`. The structural extraction now takes the run of whole-line comments directly above the entry too, stopping at a blank line, a non-comment line or a `# >>> devkit:` / `# <<< devkit:` sentinel, so no copy can swallow the previous block's text or half a sentinel pair - The retired-block **fold** reads the same extraction, so a replacement block now arrives with the template's rationale as well — which is what you want when a hook's form changed under you. Your own comment above the retired block is yours and is untouched, so an adoption PR shows the two comment blocks stacked ## Testing - [x] Tests pass locally (`just test`) - [x] Manual testing performed (describe below) ### Manual Testing Details - End-to-end with the real script: `DEVKIT_VERSION=1.16.0`, `DEVKIT_FEATURES_DISABLED=actionlint`, config = template minus the actionlint sentinel block and the composite block → `Inserted the 'shellcheck-composite-actions' hook after 'shellcheck' …`, the block lands with its template comment right after `shellcheck`, nothing on stderr about anchors, YAML parses with the template's hook order; `--preview` reports the planned insert and writes nothing - `uv run pytest tests/test_scaffold_preserved_hooks.py tests/test_flake_hooks.py -q` → 110 passed (32 + 78); whole Python suite minus image/integration → 1301 passed, 1 skipped - `bats -j 4 --filter '1660|1651|preserved|hook|1717|1725' tests/bats/init-workspace.bats` → 48 ok; the one failure is the known environmental one (the #1660 opt-out test shells out to a bare `python3` without PyYAML in the plain `nix develop` shell; green in CI) - `shellcheck -x` clean; `prek run --all-files` → 55 hooks passed ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly (edit `docs/templates/`, then run `just docs`) - [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and pasted the entry above) - [x] My changes generate no new warnings or errors - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published ## Additional Notes Side effect, pinned by its own test and recorded in the changelog: the retired-block fold (Case 1) shares the extractor, so a folded replacement block now also carries the template's rationale comment, stacked under the consumer's own. The sentinel prefix match itself is left as-is and documented; hardening it to an exact-id match is #1727. Refs: #1725
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#1718 added the scaffolded
shellcheck-composite-actionshook, but a consumer with a preserved.pre-commit-config.yamlonly receives a new hook through theinserted_hook_blocks()table inassets/init-workspace.sh, keyed on the first release that ships it. #1723 already put the re-check of that table on the Phase 1 prerequisites; this adds the row itself.Why the version can be fixed now.
devholds twofeatcommits since 1.16.0 (#1718 and #1724) and no breaking change, so the next train is1.17.0by construction, and it is planned for Monday 2026-09-28. The only rename possible from here is upward, and an upward rename leaves a1.17.0row harmless: every consumer's pin is still below it at adoption, and nobody can ever sit exactly at1.17.0. The #1651 defect (re-adding a hook a consumer deleted) needs the row to be below the real first release, which would require a downward rename that afeatondevrules out unless both are pulled — the case the #1723 prerequisite now catches on the release branch.Mechanism, verified rather than assumed. Rows are
<first release> <hook> [feature group];insert_missing_hook_blocksreadsread -r ver hook feat, so the two-field row is legal and the empty group never gates. The block comes from the rendered template structurally (the- repo:entry holding- id: shellcheck-composite-actions); the anchor derived from the template isactionlint, so the row must follow the actionlint row: a pre-1.16.0 tree gains actionlint first and the composite block right after it, in one pass.End-to-end, with the real script: a temp workspace at
DEVKIT_VERSION=1.16.0whose config lacks the composite block gains exactly that block after the actionlint sentinel end, nothing else changes, and a second run is byte-identical. Output:Inserted the 'shellcheck-composite-actions' hook after 'actionlint' (shipped since 1.17.0, this tree predates it at 1.16.0, #1654).Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentation onlychore-- Maintenance task (deps, config, etc.)refactor-- Code restructuring (no behavior change)test-- Adding or updating testsci-- CI/CD pipeline changesbuild-- Build system or dependency changesrevert-- Reverts a previous commitstyle-- Code style (formatting, whitespace)Modifiers
!) -- This change breaks backward compatibilityChanges Made
assets/init-workspace.shinserted_hook_blocks():'1.17.0 shellcheck-composite-actions'after the actionlint row, with a comment carrying the version rationale and the ordering constrainttests/test_scaffold_preserved_hooks.pyCOMPOSITE_SINCE/COMPOSITE_HOOK; the table test asserts the quoted two-field row and that it follows the actionlint row;_composite_seed()builds the 1.16.0 shape; a 1.16.0 pin gains exactly the block (no consumer line removed, every added line the template's own), 1.17.0 and 1.17.1 pins are left alone, an existing hook is never duplicated, a pre-1.16.0 tree gains both blocks in template order[shellcheck, actionlint, shellcheck-composite-actions, typos],--previewreports the planned insert. RED before the row: 5 failed / 22 passed. Two existing assertions were scoped frompreserved-hook-insert:topreserved-hook-insert: actionlintwhere an older pin now legitimately gains the composite hook; the at-release pin test stays unscoped (review finding)Changelog Entry
No changelog needed — the issue says so; the consumer-visible feature is #1718's entry, this is its delivery path for preserved configs.
Testing
just test)Manual Testing Details
uv run pytest tests/test_scaffold_preserved_hooks.py tests/test_flake_hooks.py -q→ 105 passedbats -j 4 --filter '1660|1651|preserved|hook' tests/bats/init-workspace.bats→ 48 ok; the one failure is the pre-existing environmental one (the test shells out to a barepython3that lacks PyYAML in the plainnix developshell; green in CI)shellcheck -xclean;prek run --all-files→ 55 hooks passedChecklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
Found while verifying, not fixed here: a consumer pinned below 1.17.0 with
DEVKIT_FEATURES_DISABLED=actionlinthas no actionlint block to anchor on, so the composite insert is skipped with a warning (exit 0, no partial write). Safe, but the message reads as a defect to that consumer; a fallback anchor would be the fix. No known consumer is in that state. Filed separately: #1725.Refs: #1717