Skip to content

feat: advance a pinned devkit flake input on upgrade and gate scaffold/toolchain skew in CI - #1768

Merged
c-vigo merged 5 commits into
devfrom
feature/1752-flake-pin-advance
Sep 29, 2026
Merged

c-vigo merged 5 commits into
devfrom
feature/1752-flake-pin-advance

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Description

In direnv/both mode the scaffold and the toolchain are versioned twice: .vig-os
DEVKIT_VERSION drives the scaffold, the devkit flake input's ref drives the dev shell. An
upgrade only moved the first, so a pinned consumer ran the previous release's tools against
the new scaffold — surfacing as prepare-changelog seed: invalid choice mid-release
(vig-os/scitadel#225) and as shellcheck-composite-actions: Failed to spawn on the
adoption PR itself (vig-os/tessera#445, #1756). The installer's flake-bump: skipped
line was the only signal, and no gate could see it: flake.nix is a PRESERVE_FILE.

This PR closes the gap on both axes:

  • DEVKIT_FLAKE_PIN_ADVANCE (.vig-os, true | false | empty; empty = today). With
    true, install.sh --force rewrites a pinned RELEASE ref (?ref=X or /X, form
    preserved) to the new DEVKIT_VERSION and runs nix flake update <input> in the same
    step. Atomic: if the lock update fails, or nix is absent, flake.nix and flake.lock
    are left byte-identical. Non-release pins (main, rev=<sha>, refs/tags/X) are never
    touched. Every outcome prints exactly one flake-bump: line; the adoption PR body already
    carries it, and the knob-off line now names the key.
  • CI gate. The scaffolded ci.yml gains a Check flake pin lockstep step in the
    resolve-toolchain job (which now sparse-checks-out flake.nix). A pinned release ref
    that differs from DEVKIT_VERSION fails the job with an actionable ::error::; floating
    inputs, non-release pins (warning only), bare and devcontainer modes are never gated.
    It is deliberately independent of DEVKIT_DRIFT_CHECK.

devkit-upgrade.yml needs no change: it installs nix, commits with git add -A, and lifts
the flake-bump: line into the PR body already.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • 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/workspace/.vig-os — new DEVKIT_FLAKE_PIN_ADVANCE key (ships empty) with its
    contract comment, next to the other devkit-upgrade runtime knobs.
  • assets/init-workspace.sh — read, ""|true|false value guard (aborts loudly on a typo,
    also under --preview), write-back for a non-empty value; cross-reference comment on the
    lagging-pin WARNING regex.
  • install.sh — the pinned branch of the flake-bump block: knob + new-version read,
    release-shape guards, advance_pinned_input (line-targeted sed on the detected input
    line, verification of that line, backup + restore of both flake files, one mktemp -d
    under $TMPDIR, never in the project), advance_flake_lock shared with the floating
    branch; broad detector regex hoisted into DEVKIT_INPUT_RE. Floating-path messages are
    byte-identical to before.
  • assets/workspace/.github/workflows/ci.yml — flake.nix in the resolve-toolchain
    sparse checkout; new Check flake pin lockstep step (env-routed, skipped under a
    workflow_dispatch image-tag override, regex byte-identical to the scaffold's
    WARNING regex).
  • Tests — tests/bats/install.bats (+12 cases: both pin forms, renamed input, doc-comment
    and sibling untouched, already-aligned, non-release pins, non-release DEVKIT_VERSION,
    nix failure restores both files, no nix, unusable TMPDIR, one-line-per-run; outer-gate
    tests now refute any flake-bump: line), tests/bats/init-workspace.bats (round-trip
    and invalid-value rows), tests/test_vig_os_manifest.py (MANIFEST_KEYS row), new
    tests/test_flake_pin_lockstep.py (17 tests: sparse checkout, step placement, if,
    env routing, regex lockstep, executed gate body across every mode/pin case).
  • Docs — docs/MIGRATION.md (manifest table row, Updating, rewritten lockstep section
    with the CI gate, first-adoption remedy and rollout caveats), docs/DOWNSTREAM_RELEASE.md
    (+ synced copy), plugins/devkit/skills/upgrade/SKILL.md, CHANGELOG.md (+ synced copy).

Changelog Entry

Added

  • DEVKIT_FLAKE_PIN_ADVANCE: advance a pinned devkit flake input on upgrade
    (#1752, #1756)
    • New .vig-os key DEVKIT_FLAKE_PIN_ADVANCE. With true, an
      install.sh --force upgrade in direnv or both mode rewrites a pinned
      release ref (?ref=X or /X, form kept) to the new DEVKIT_VERSION and
      runs nix flake update <input> in the same step. If the lock update fails,
      flake.nix and flake.lock are both restored. Empty or false (default)
      leaves a pin untouched, and the flake-bump: line now names the key
    • The scaffolded ci.yml fails its resolve-toolchain job when a pinned
      release ref differs from DEVKIT_VERSION, so an adoption PR can no longer
      wire hooks the pinned toolchain cannot run. Floating inputs, non-release
      pins, bare and devcontainer modes are not gated
    • Pinned consumers: the adoption PR that ships this gate is red once. Fix it
      in one commit on that branch (bump the pin, nix flake update <input>, set
      the key) and merge it before the next weekly upgrade run replaces the
      branch; see docs/MIGRATION.md

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • just precommit (all hooks, all files): green, exit 0.
  • bats tests/bats/install.bats: 107/107. bats -j $(nproc) tests/bats/init-workspace.bats:
    308/308 (includes the per-mode actionlint of the rendered ci.yml). Full just test-bats:
    622/622.
  • uv run pytest over test_flake_pin_lockstep.py test_vig_os_manifest.py test_declared_languages.py test_ci_runner.py test_scaffold_drift.py test_workflow_summary_gate.py test_workflow_zizmor_baseline.py test_workflow_devkit_upgrade.py:
    254 passed. just lint: clean. actionlint and zizmor --offline on the scaffolded
    ci.yml: no findings beyond dev's baseline.
  • TDD: each test: commit was run RED against the preceding tree (10 bats + 1 pytest + 2
    bats rows failing; 17 pytest failing), then GREEN after its feat: commit. The gate tests
    were additionally checked against nine mutated copies of ci.yml (step removed, body
    replaced by exit 0, if removed, flake.nix dropped from the sparse list, mode check
    removed, || true removed, …) — every mutant is caught.
  • test_image.py / test_integration.py not run locally (need the fresh image; CI covers).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

  • Rollout. Pinned consumers today: h5v, revkit, tessera (all at 1.17.0/1.17.0), scitadel
    (main still 1.6.0). Their adoption PR to the release that ships this is red at the new
    gate once, by design (its scaffold predates the opt-in). Remedy is one commit on the
    adoption branch — bump the pin, nix flake update <input>, set the knob — merged before
    the next Monday 06:00 UTC devkit-upgrade run, which force-updates that branch. Pre-setting
    the knob on the default branch ahead of the adoption is safe only for
    DEVKIT_DRIFT_CHECK=false consumers: the scaffold-drift job re-scaffolds at the current
    version, which drops the unknown key.
  • devkit-upgrade PR bumps .vig-os + .pre-commit-config.yaml but not the consumer's flake vigos input — new hooks fail to spawn #1756 stays open until that first red→green adoption is observed live; the remedy is
    posted there.
  • Out of scope, noted: commit-action's inverse skew (DEVKIT_VERSION=1.12.0 with a
    floating input — a consumer chore, devkit-staleness covers it); a --no-write-lock-file
    on devkit-upgrade.yml's nix develop -c git commit (pre-existing floating-path hazard,
    not triggered by this PR's atomic advance); Proposal B (advance when the pin equals the
    outgoing version) — deliberately not done, a pin held at the outgoing version is not proof
    of intent.

Refs: #1752, #1756

Closes #1752

…input advance

RED: the template must ship the knob empty, round-trip it across --force and
refuse an unknown value; install.sh must advance a pinned release ref (both
forms, form preserved, atomic with the lock) only under the knob, and report
exactly one flake-bump: line per outcome. Regression pins (floating advance
under the knob, no flake-bump: line outside the outer gate) already pass.

Refs: #1752, #1756
… DEVKIT_FLAKE_PIN_ADVANCE

A pinned devkit input was never advanced, so a pinned consumer's adoption
moved DEVKIT_VERSION while its dev shell kept the previous release's
toolchain. With DEVKIT_FLAKE_PIN_ADVANCE=true, an install.sh --force upgrade
rewrites a release pin (?ref=X or /X, form preserved) to the new
DEVKIT_VERSION and locks it with nix flake update, restoring both files on
failure. Empty or false keeps today's skip, now naming the knob. The scaffold
guards the value and writes it back across upgrades.

Refs: #1752, #1756
RED: ci.yml's resolve-toolchain job must fetch flake.nix and fail, right
after the declared-languages gate, when a pinned devkit release ref differs
from .vig-os DEVKIT_VERSION in direnv/both mode; floating inputs, non-release
pins, an empty version, bare and devcontainer modes never fail it, and the
step is skipped when a dispatch overrides the image tag.

Refs: #1752, #1756
…s DEVKIT_VERSION

A new resolve-toolchain step compares a pinned devkit release ref in
flake.nix with .vig-os DEVKIT_VERSION for direnv/both consumers and fails on
skew, so the toolchain jobs are skipped and the summary gate reports it. The
error names the one-commit remedy and DEVKIT_FLAKE_PIN_ADVANCE. The sparse
checkout fetches flake.nix; the parse regex is shared byte-for-byte with the
scaffold's lagging-pin warning.

Refs: #1752, #1756
…_VERSION gate

MIGRATION.md gains the manifest-key row, an Updating note and a rewritten
lockstep section (the knob, the atomic advance, the CI gate, the one-commit
first-adoption remedy, the Monday-cron clobber and the drift-off pre-set
caveat). DOWNSTREAM_RELEASE.md, the upgrade skill and the changelog follow.

Refs: #1752, #1756
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.

1 participant