Repository navigation
fix(workspace): repair preserved justfile.project with missing base recipes on upgrade - #891
Conversation
RED for #877: a preserved pre-0.4.0 justfile.project never receives the relocated base recipes (lint/format/precommit/test/test-cov/sync/update), so the shipped ci.yml fails with missing-recipe errors. Also cover stale .devcontainer/justfile.base removal, the direnv-mode #738 boundary, and the root-justfile import block verification. Refs: #877
…ecipes on upgrade 0.4.0 relocated the base recipes into justfile.project, which is preserved on upgrade, so 0.3.x consumers never received them and the shipped ci.yml failed with missing-recipe errors. The upgrade now appends any CI-contract recipe (lint/format/precommit/test/test-cov/ sync/update) that does not resolve in the import graph, sourcing the blocks from the template (SSoT); customized consumer recipes always win and re-runs are no-ops. Also removes the retired .devcontainer/justfile.base where the scaffold manages .devcontainer/ (never in direnv mode, #738) and warns when the managed root justfile lacks the scaffold import block. Refs: #877
MIGRATION.md 0.3.x checklist gains the base-recipe relocation/repair step; CHANGELOG Unreleased/Fixed entry for the stranded recipes (the .devcontainer mirror is hook-synced). Refs: #877
A syntax error in the preserved justfile.project makes every recipe probe fail, so the repair appends all template recipes on each --force run, duplicating them and hard-breaking just once the consumer fixes the original error. Refs: #877
…not parse A syntax error in the preserved justfile.project made every `just --show` probe fail, so all seven template recipes were appended on each --force run — duplicating recipes the consumer already defined and hard-failing just with 'recipe redefined' once the original error was fixed. Gate the repair on `just --list` parsing the workspace graph, warn loudly and skip otherwise. Also guard against a missing `just` binary and an empty template extraction. Refs: #877
|
Independent review (pre-push): ran Non-blocking notes: template-recipe drift is pinned by the CI alignment test; the parse gate also covers the missing- |
…ade (#895) ## Description Closes #878 The scaffold upgrade (`init-workspace.sh --force`) replaced the consumer's `.pre-commit-config.yaml` wholesale — it was not in `PRESERVE_FILES` — silently dropping repo-specific configuration: the global `exclude:` block (hyrr: physics data tables, generated schemas, jupytext pairs — post-upgrade the hook suite "fixed" ~45 files it must never touch) and per-hook `exclude:` keys (hyrr: the `detect-private-key` exclusion for a file carrying PEM marker literals → false positive). ## Design decision Chosen: **preserve-with-managed-warning**, the first option listed on the issue and the one consistent with the #877 precedent (#891): the consumer owns the file. `.pre-commit-config.yaml` joins `PRESERVE_FILES`, and the upgrade adds two non-fatal guards: - **Diff hint** — when the preserved file differs from the incoming template, the installer prints a unified diff so template hook-stack evolution stays visible and consumers fold it in deliberately (nothing is lost silently in either direction: the consumer file is kept verbatim, the template delta is printed in full). A stock consumer whose file matches the template gets no noise. - **Parse gate** — the preserved config is checked with `prek validate-config` (prek ships in `devTools`, so it is on PATH in the image and the dev-shell); a config the runner cannot load breaks every commit in the new image, so the installer warns loudly, pointing at the exact command. Same philosophy as the #877 `just --list` parse gate: probe with the real tool, warn, never fail the scaffold. No `.bak-upgrade` backup file is needed: under preserve, the consumer's data is never touched, and the diff output carries the template side. Why not **replace-but-carry-over** (rewrite from template, re-apply consumer `exclude:`/`files:` keys): - **No YAML parser is guaranteed at init-workspace runtime.** The image `pythonEnv` is python3.14 + vig-utils (rich) + pip-licenses — no PyYAML; `devTools` carries no `yq`. A structured merge would need a new image dependency for one upgrade step, and a regex/awk-based merge would risk corrupting exactly the file it must protect (block scalars, nested hook maps). - **Key-level carry-over still loses data silently.** Real consumers customize more than excludes — they add whole hooks and repos (jupytext, schema checks). Carrying over only `exclude:`/`files:` keys would drop those just as silently as today's wholesale replacement. - **It reverses the 0.4.0 ownership direction.** The `justfile.project` precedent (#877/#891) deliberately made these team-owned, customizable files; the hook config is the same class — the issue exists precisely because repos must customize it. ### Implications for #881 and template-driven hook evolution A pure preserve means hook-stack evolution (runner migrations, compat fixes like `default_language_version: python3.14` #803 or `typos --force-exclude` #859, new hooks) no longer arrives automatically — a consumer upgrading from a pre-prek scaffold keeps a pre-prek-era config. This PR mitigates that with the always-printed template diff plus the MIGRATION.md step, and the design keeps the #881 path open rather than harder: the new post-scaffold guard block is the natural hook point for future surgical repairs on the preserved file (#877-style), e.g. an upgrade-time scan/rewrite of retired `pre-commit` invocations in preserved files, or a targeted key repair once a YAML-capable tool is in the toolchain. Config-side, prek is a drop-in reader of `.pre-commit-config.yaml`, so preserved configs keep loading; the `pre-commit` *binary* references that #881 covers live in `justfile.project`/`.githooks`, which were already preserved before this PR — #881's scope is unchanged. ## Changes Made - `assets/init-workspace.sh`: - `.pre-commit-config.yaml` added to `PRESERVE_FILES` (with the #878 rationale comment, mirroring the neighboring entries). - `PRECOMMIT_CONFIG_PREEXISTED` recorded pre-scaffold (same pattern as `JUSTFILE_PROJECT_PREEXISTED`). - Post-scaffold guard: prints the consumer-vs-template unified diff when they differ, then warns (non-fatally) if `prek validate-config` rejects the preserved file; silent for stock consumers; `prek` absence is tolerated. - `tests/bats/init-workspace.bats`: four new end-to-end tests (customizations survive verbatim; diff hint printed with template content visible; no hint when the file matches the template; invalid preserved config warns and stays preserved). TDD: RED committed first, then GREEN. - `docs/MIGRATION.md`: new step 2 in the 0.3.x upgrade checklist describing the preservation, the diff review, and the `prek validate-config` check. - `CHANGELOG.md` (+ hook-synced `.devcontainer` mirror): Unreleased/Fixed entry. ## Type of Change - [x] `fix` -- Bug fix ### Modifiers - [ ] Breaking change (`!`) ## Changelog Entry ### Fixed - **Scaffold upgrade replaces `.pre-commit-config.yaml`, silently clobbering repo-specific hook config** ([#878](#878)) - The upgrade overwrote the consumer's `.pre-commit-config.yaml` wholesale, dropping the repo-specific global `exclude:` block and per-hook `exclude:` keys — the hook suite then rewrote data files it must never touch and false-flagged PEM marker literals. The file is now preserved on upgrade (like `justfile.project`, [#877](#877)). - Because template hook-stack evolution no longer arrives automatically, `init-workspace --force` prints a diff of the preserved file against the incoming template so consumers can fold changes in deliberately, and warns (non-fatally) when the preserved config does not parse under `prek validate-config` — a config the runner cannot load breaks every commit in the new image. ## Testing - [x] Tests pass locally: `bats tests/bats/init-workspace.bats` (72 ok), full hook suite green (`just precommit`) - [x] Manual testing performed (describe below) ### Manual Testing Details Ran `init-workspace.sh --force` against a temp workspace carrying a hyrr-shaped `.pre-commit-config.yaml` (global `exclude: ^data/stopping/|\.dat$` + `detect-private-key` per-hook exclude): the consumer file survived verbatim, the installer printed the "yours was kept" banner with the full unified diff against the template, and the scaffold completed successfully. A second run on a stock (template-identical) workspace printed no warning. ## 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 - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published
Description
Closes #877
The 0.4.0 scaffold retired
.devcontainer/justfile.baseand relocated the base recipes (lint,format,precommit,test,test-cov,sync,update) intojustfile.project— a PRESERVE_FILES entry. Upgrading 0.3.x consumers therefore kept their oldjustfile.projectand never received the recipes, while the shippedci.ymlcallsjust sync/just precommit/just test, so in-container CI failed withjustfile does not contain recipe 'sync'(observed on hyrr and talys during 0.4.0 field validation).Design decision
Chosen: option (b) from the issue — upgrade-time repair of the preserved
justfile.project.init-workspace --forcenow probes each CI-contract recipe withjust --showagainst the assembled import graph and appends only the missing ones, sourcing the recipe blocks verbatim from the templatejustfile.project(which stays the SSoT) under a clearly marked, review-me banner.Why not the alternatives:
justfile.devcor a resurrected base file):justfile.devclives under.devcontainer/, which adirenv-mode workspace does not have — the recipes would vanish there. Any managed root-level file would also collide (just duplicate-recipe parse error) with fresh 0.4.0 scaffolds and consumers that already migrated the recipes into theirjustfile.project, and it would reverse the deliberate 0.4.0 decision that teams own and customize these recipes (the field complaint aboutsyncsemantics shows they need to).Properties of the repair: customized consumer recipes always win (only unresolved names are appended), re-running the upgrade is a no-op, and fresh scaffolds are untouched (they get the template file wholesale).
Changes Made
assets/init-workspace.sh:CI_CONTRACT_RECIPESlist +extract_template_recipe()(awk block extraction from the templatejustfile.project).justfile.projectunder a marked banner..devcontainer/justfile.baseon upgrade — only where the scaffold manages.devcontainer/(never indirenvmode, respecting the [BUG] install.sh --mode direnv --force overwrites populated consumer files (pyproject.toml, .devcontainer/) #738 boundary).justfilelacks the scaffoldimport?block (talys field case: recipes present but unreachable).tests/bats/init-workspace.bats: five new tests (repair delivers all seven recipes; customized recipes win + idempotency; stalejustfile.baseremoved;direnv-mode pre-existing.devcontainer/untouched; import-block verification present). TDD: RED committed first, then GREEN.docs/MIGRATION.md: new step 1 in the 0.3.x upgrade checklist describing the relocation, the automatic repair, and the root-justfile import check.CHANGELOG.md(+ hook-synced.devcontainermirror): Unreleased/Fixed entry.Type of Change
fix-- Bug fixModifiers
!)Changelog Entry
Fixed
justfile.project(#877)lint/format/precommit/test/test-cov/sync/updateintojustfile.project, which is preserved on upgrade — 0.3.x consumers never received them and the shippedci.ymlfailed withjustfile does not contain recipe 'sync'.init-workspace --forcenow appends the missing base recipes from the template into the preserved file (customized recipes always win; idempotent)..devcontainer/justfile.baseis removed on upgrade where the scaffold manages.devcontainer/(never indirenvmode, #738), and the installer warns if the rootjustfilelacks the scaffoldimport?block.Testing
bats tests/bats/init-workspace.bats tests/bats/install.bats(123 ok),uv run pytest tests/test_install_script.py(23 passed)Manual Testing Details
Ran
init-workspace.sh --forceagainst a temp workspace carrying a pre-0.4.0justfile.project(ownprojectvar +inforecipe, no base recipes): consumer content preserved, all seven recipes appended under the marked banner,just --listparses and resolves the full layered graph; second run appended nothing.Checklist
CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Out of scope / follow-up
The template
syncrecipe's semantics change (plainuv sync→uv sync --all-extras --all-groups), noted at the end of #877, is deliberately untouched here; the repair appends the current template recipe as-is. It likely deserves its own issue (it breaks repos that quarantine platform-limited deps in optional extras, e.g. hyrr'sgeometryextra).