Repository navigation
feat(setup): preflight guard for scaffold upgrades and --preview diff report - #903
Merged
Merged
Conversation
Refuse upgrades on main/dev/release/* or detached HEAD and on a dirty tree; offer chore/devkit-upgrade-<version> on a protected branch; add --skip-preflight bypass. --smoke-test, --preview, and fresh installs are exempt. Refs: #886
Extends the --force conflict report with mode-aware filtering, an ADDED listing, and the mode-prune DELETED listing, then exits 0 before any mutation. install.sh forwards the flag and skips post-init in preview. Refs: #886
MIGRATION.md updating section, install.sh/devc-upgrade help surfaces, and the changelog entry (with the sync-manifest mirror). Refs: #886
…eflight-guard # Conflicts: # CHANGELOG.md # assets/workspace/.devcontainer/CHANGELOG.md
Merged
12 of 13 tasks
c-vigo
added a commit
that referenced
this pull request
Jul 7, 2026
…ntity and bare mode (#911) ## Description Promotes `.vig-os` from a single-purpose version pin into the project's declarative manifest and adds the new `bare` delivery mode. - **Manifest**: `DEVKIT_MODE`, `DEVKIT_PROJECT`, `DEVKIT_ORG`, `DEVKIT_REPO` (plus reserved `DEVKIT_MODULES`, #884) are persisted alongside `DEVCONTAINER_VERSION` — flat `KEY=VALUE` format unchanged, `DEVCONTAINER_VERSION` not renamed (#781 owns that). - **Precedence**: explicit flag/env > `.vig-os` > prompt/default, in both `init-workspace.sh` and `install.sh`; resolved values are written back on every (re)scaffold, so a manifest-bearing repo upgrades with `--force` and **no mode/identity flags** while keeping its shape and names. - **Legacy inference**: version-only manifests get their mode inferred conservatively from the tree shape on upgrade (wider mode on ambiguity — the #859 combination resolves to `both` — inference printed, interactive runs confirm, persisted afterwards; never reshapes on inference alone). - **No implicit mode switches**: an explicit `--mode` contradicting the persisted `DEVKIT_MODE` refuses in both scripts, pointing at `--preview` (#886) and the deliberate DEVKIT_MODE-edit-on-a-clean-branch flow. `--preview` and `--smoke-test` are exempt. - **`bare` mode**: standards-only scaffold (justfiles, `.pre-commit-config.yaml`, `.github/` CI, `pyproject.toml`, `.vig-os`); prunes `.devcontainer/`, `flake.nix`, `.envrc` behind the #738/#859 pre-existence guards; ships a host-native `ci.yml` (`assets/workspace-bare/` overlay): no resolve-image step, no container jobs — pinned `astral-sh/setup-uv` plus `uv tool install rust-just prek` drive the same `just sync|precommit|test` contract. The root justfile's `import?` semantics keep the graph loading without `.devcontainer/` (proven by bats). - **Preview UX**: a populated pre-existing `.devcontainer/` now appears as an explicit PRESERVED line in direnv/bare reports (previously silently absent). Closes #885 ## Type of Change - [x] `feat` -- New feature ### Modifiers - [ ] Breaking change (`!`) -- backward compatible (`semver:minor`); all existing `.vig-os` parsers are byte-for-byte unaffected (regression-tested). ## Changes Made - `assets/workspace/.vig-os`: manifest template with the new key set and cross-references (#883/#884/#781 noted in comments). - `assets/init-workspace.sh`: tolerant manifest reader + write-back; flag/env > manifest > prompt precedence for SHORT_NAME/ORG_NAME/GITHUB_REPOSITORY/MODE; mode-mismatch refusal; conservative legacy inference; `bare` mode (rsync exclusion, prune with guards, host-native ci.yml overlay, report/DELETED integration); `DEVKIT_MODULES` round-trip across the managed-file overwrite. - `install.sh`: reads the same keys host-side (mode/name/org/repo defaults), refuses conflicting `--mode` before pulling the image, accepts/forwards `--mode bare`, skips the host user-conf step for bare, bare-aware next-steps hint. - `assets/workspace-bare/.github/workflows/ci.yml`: host-native CI template (SHA-pinned actions; yamllint-clean via the hook suite). - `docs/MIGRATION.md`: four delivery modes + a `.vig-os` project manifest section (keys, precedence, inference, mode-switch policy, future flags note for #883). - Tests: 19 new bats cases in `init-workspace.bats` (manifest matrix across modes × fresh/legacy/manifest-bearing, refusal/preview, inference incl. the #859 ambiguity, bare shape + CI-contract resolution), 9 in `install.bats`, new `manifest-parsers.bats` + `tests/test_resolve_image_manifest.py` (parser tolerance, byte-identical outputs). ## Changelog Entry ### Added - **`.vig-os` project manifest and new `bare` delivery mode** ([#885](#885)) - `.vig-os` now persists the delivery mode and identity (`DEVKIT_MODE`, `DEVKIT_PROJECT`, `DEVKIT_ORG`, `DEVKIT_REPO`, reserved `DEVKIT_MODULES`) alongside the version pin — flat `KEY=VALUE` format unchanged, existing parsers byte-for-byte unaffected. Precedence flag/env > `.vig-os` > prompt/default, with resolved values written back, so manifest-bearing repos upgrade with `--force` and no mode/identity flags while keeping shape and names. - Legacy (version-only) consumers get their mode inferred conservatively from the tree shape on upgrade (wider mode on ambiguity, inference printed and persisted, never reshaping); an explicit `--mode` contradicting the persisted `DEVKIT_MODE` refuses, pointing at `--preview` and the preflight-guard flow. - New `bare` mode ships the standards layer only (justfiles, hooks config, `.github/` CI, `pyproject.toml`, `.vig-os`), prunes `.devcontainer/`/`flake.nix`/`.envrc` behind the #738/#859 pre-existence guards, and scaffolds a host-native `ci.yml` (no image resolution, no container jobs — `setup-uv` on the runner drives the same `just sync|precommit|test` contract). (mirrored in `assets/workspace/.devcontainer/CHANGELOG.md`) ## Testing - [x] Tests pass locally (`just test-bats`: 100/100 init-workspace, 87/87 install, 4/4 manifest-parsers; `uv run pytest tests/test_resolve_image_manifest.py`: 2 passed) - [x] Manual testing performed (describe below) ### Manual Testing Details - TDD: each sub-feature landed as a RED bats commit (verified failing) followed by its GREEN implementation commit. - Full hook suite green locally: `just precommit` (prek run --all-files) exits 0 — includes yamllint (strict) over the new host-native ci.yml, shellcheck over both scripts, and check-action-pins. - The 9 `githooks.bats` failures observed in a nix dev-shell are pre-existing and environmental (`IN_NIX_SHELL` set); all 12 pass with `env -u IN_NIX_SHELL`. No `.githooks` files are touched by this PR. ## 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 - [x] I have updated the documentation accordingly - [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 (#886/PR #903 and #884/#897 are already on dev; #877 landed as upgrade-time repair — bare viability is proven via `import?` + justfile.project, see bats) ## Review follow-up Addresses the review on the torn-manifest window plus the nits, belt and braces: - **Torn-state fix (defect):** the template `.vig-os` now ships `DEVKIT_MODE=` (empty = unset to every parser), and `init-workspace.sh` persists the resolved `DEVKIT_MODE`/`DEVKIT_PROJECT`/`DEVKIT_ORG` immediately after the template rsync — before any abort-capable step (notably `resolve_github_repository`). An upgrade aborted inside the window (e.g. `--no-prompts` on a legacy tree with a non-github origin) can no longer persist `DEVKIT_MODE=both` in a direnv-shaped repo, so the next `--force` run infers/refuses as if the torn run never happened. `DEVKIT_REPO` stays in the late write-back (only known after origin resolution); `DEVKIT_PROJECT`/`ORG`/`REPO` already shipped empty in the template, so empty-as-unset covers them. Reproduced RED with a new end-to-end bats test (abort, assert manifest not poisoned, re-run, assert `.devcontainer/` is NOT re-added), then GREEN. - **Pinned bare CI tools (nit):** the bare `ci.yml` now installs `rust-just==1.51.0` and `prek==0.3.11` — the versions the flake toolchain ships — with a comment noting the Renovate/manual bump path. - **MIGRATION.md (nit):** explicitly flags that `SHORT_NAME`/`ORG_NAME` env vars now suppress the interactive prompts (precedence flag/env > manifest > prompt). Verification: init-workspace 102/102, install 87/87, manifest-parsers 4/4 (193/193 in one run); `just precommit` exits 0 (52 hooks passed).
8 tasks
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
Adds the upgrade preflight guard and diff preview specified in #886:
install.sh --force(the upgrade path) now requires a dedicated working branch with a clean tree, so every scaffold upgrade lands as a single reviewable, revertible diff; a new--previewmode prints the full file report without touching the tree.Closes #886
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
install.sh— host-side preflight guard on the--forcepath only (the host is the only place git state is reliable; a worktree's gitdir is not mounted into the container):main,dev,release/*(prefix), and detachedHEAD;git status --porcelainmust be empty; gitignored clutter passes);chore/devkit-upgrade-<version>; non-interactively it refuses with that command as the hint;--skip-preflightflag bypasses, printed in every refusal;--smoke-test(the downstream release gate runsinstall.sh --version <tag> --smoke-test --force --docker .headless — verified against devcontainer-smoke-testrepository-dispatch.yml),--preview(report-only), and fresh installs (no--force);--dry-runthe guard still evaluates but never mutates (accepting the branch offer only reports what it would do).assets/init-workspace.sh—--previewmode: rides the existing conflict-report machinery (now mode-aware: direnv-mode.devcontainer/and devcontainer-mode stub filters), extended with an ADDED listing and the mode-prune DELETED listing (.devcontainer/justfile.baseon upgrades, the direnv-mode.devcontainer/prune), then exits 0 before any mutation.install.shforwards the flag and skips all post-init (user conf, git setup) in preview. Kept cleanly callable for feat(workspace): persist delivery mode, identity, and modules in .vig-os — declarative manifest with a new "bare" mode #885's destructive mode switches.devc-upgraderecipe: surfaces the guard and the new flags in its help/output text (no logic change).docs/MIGRATION.mdgains an "Upgrade preflight guard and preview" section;install.sh --helpdocuments--skip-preflightand the--previewvs--dry-rundistinction.Changelog Entry
Added
install.sh --forceupgrades now refuse onmain/dev/release/*/detached HEAD and on a dirty tree, so every upgrade lands as a reviewable, revertible diff on a dedicated branch; on a protected branch with a clean tree the installer offers to create and switch tochore/devkit-upgrade-<version>, and non-git directories get a warn-and-confirm path. A single--skip-preflightflag bypasses the guard;--smoke-testruns and fresh installs are exempt.--previewmode prints the add/overwrite/preserve/delete file report (including mode-prune deletions such as the retired.devcontainer/justfile.base) and exits without changing any files — unlike--dry-run, which only prints the container command.Testing
just test)Manual Testing Details
TDD (RED commit first, then implementation):
tests/bats/install.bats: 78/78 — protected branches (main/dev/release/*prefix), detached HEAD, dirty tree (tracked + untracked-unignored), gitignored-only clutter passes, git-worktree fixture (.gitfile) both refusing and passing,--skip-preflight,--smoke-testexemption, non-git warn/confirm/decline, dry-run branch offer never mutates, fresh-install exemption,--previewforwarding + guard exemption, help text.tests/bats/init-workspace.bats: 81/81 —--previewexits 0 with the report, leaves the tree byte-identical (diff -ragainst a pre-copy), lists.devcontainer/justfile.baseand the direnv-mode.devcontainer/prune as DELETED without deleting, works without--forceon a populated tree, lists ADDED files without scaffolding them.uv run pytest: 820 passed; the twotests/test_image.pyfailures are stale-local-image artifacts (one also fails on the dev base commit; the other is the manifest sha check against a local image that predates this branch's changelog/justfile.devc edits — CI rebuilds the image from the branch).just precommit→ exit 0.Checklist
docs/templates/, then runjust docs)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
podman run … init-workspace.sh --forceinvocations bypass the host guard.nix-image.ymlCI scaffold check runsinit-workspace.shdirectly against a fresh temp dir — host guard not in its path, unaffected.Refs: #886