feat(config): declare version guards with required_runok_version#299
Merged
feat(config): declare version guards with required_runok_version#299
required_runok_version#299Conversation
Any config or preset file can now declare a semver requirement that the running runok must satisfy to load it. The check runs per file so that every file in the extends chain, including transitively extended presets, is validated independently. Loading fails with an error that names the exact source file and the constraint, rather than silently ignoring newer schema fields. `runok update-presets` now honors the field when picking upgrade tags: candidate tags are inspected from newest to oldest, and the newest candidate whose preset tree (including transitive `extends`) satisfies the current runok binary is adopted. This lets preset repositories ship schema-incompatible changes under newer tags without breaking users on older runok. Nightly builds are modeled as strictly greater than every release so that `">=X.Y.Z"` constraints always pass; upper-bounded ranges still reject nightly intentionally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Apply the `required_runok_version` check to both the automatic TTL refresh path (`handle_stale_cache`) and the manual `update-presets` path via a shared `git show`-based inspector. The cache working tree is only advanced to a new revision after the revision (and every same-repo `extends` child) has been validated, so concurrent runok processes never observe a preset revision that is too new for the running binary. `update-presets` now surfaces a warning listing the candidate tags it skipped because of `required_runok_version`, so users know when upgrading runok would unlock newer preset versions. The automatic refresh path stays silent to keep normal operations quiet. Also make `PresetCache::write_metadata` atomic (tempfile + rename) so a concurrent reader never sees a half-written `metadata.json`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #299 +/- ##
==========================================
- Coverage 89.55% 89.13% -0.43%
==========================================
Files 52 53 +1
Lines 11015 11538 +523
==========================================
+ Hits 9865 10284 +419
- Misses 1150 1254 +104
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
intent(update-presets): satisfy the "no embedded \n in test string literals" rule in CLAUDE.md that asks for `indoc!`/`formatdoc!` instead of raw `format!` with escaped newlines
intent(extends): give preset authors a single place that explains when to set `required_runok_version`, how `update-presets` selects compatible tags, and why automatic refresh stays silent on incompatible revisions. The schema page previously held all of this, but preset authors reading the `extends` guide had no pointer to the behavior they care about decision(extends): keep `schema.md` as the terse field reference and move the authoring guidance + `update-presets` / auto-refresh interaction into `extends.md`, cross-linked from both directions
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.
Why
runok update-presetsalways jumps to the newest tag regardless of whether it is compatible with the current runok binary, leaving users on older runok without a way to notice that their presets have outgrown their runokWhat
required_runok_versionfield in every config and preset file so authors can declare "this file needs runok X or newer" with a semver requirement such as">=0.3.0"or">=0.3, <0.5"extendsis validated independentlyrunok update-presetswalk candidate tags from newest to oldest and adopt the newest one whose entire preset tree satisfies the current runok. Rejected candidates are surfaced in a warning so users know that upgrading runok would unlock newer preset versionsX.Y.Z-nightly+<sha>) as "latest" so any">=X.Y.Z"requirement passes automatically