Skip to content

feat(cli): cited-source --strict, --strict-cited-source-stale, schema migrate --list (#249)#251

Merged
avrabe merged 1 commit intomainfrom
feat/issue-249-cli-symmetries
May 1, 2026
Merged

feat(cli): cited-source --strict, --strict-cited-source-stale, schema migrate --list (#249)#251
avrabe merged 1 commit intomainfrom
feat/issue-249-cli-symmetries

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 30, 2026

Closes #249.

Three CLI asymmetries from issue #249 that hurt platform-engineering
workflows. Each is a single-flag addition that preserves existing
behavior and ships a clean read-only audit gate or discovery surface.

B7 — rivet check sources --strict

Read-only audit gate. Walks every artifact with a cited-source,
classifies each one (match / drift / missing-hash / read-error /
shape-error / stale), and exits 1 on anything other than match. Never
mutates any YAML — audit and fix are separate invocations. Mutually
exclusive with --update.

This addresses the "run-then-git diff --exit-code" pattern that CI
gates were forced into in 0.7.0.

B8 — rivet validate --strict-cited-source-stale

Promotes the previously-Info cited-source-stale diagnostic to Error
when set. The stale verdict now fires for last-checked that is
missing, unparseable, or older than 30 days (30d is a global default;
per-schema thresholds remain a deferred feature per issue text).

Defaults are unchanged: without the flag, cited-source-stale is
still Info and validate still exits 0 on stale-only projects.

New chrono-free helpers in rivet-core/src/cited_source.rs:

  • parse_iso8601_utc(&str) -> Option<i64>
  • classify_staleness(...) -> StaleStatus
  • classify_staleness_now(...) (system clock wrapper)

B9 — rivet schema migrate --list

Enumerates every available migration recipe (built-in + project-local
YAML under <schemas-dir>/migrations/). Project-local recipes shadow
built-ins of the same name. Text and JSON output (--format json).
Mutually exclusive with <target> and the action flags. Always exits
0 — discovery, not action.

New helper in rivet-core/src/migrate.rs:

  • list_recipes(schemas_dir) -> (Vec<RecipeEntry>, Vec<warnings>)
  • RecipeEntry / RecipeOrigin (built-in | project-local)

Test plan

  • cargo fmt --all
  • cargo clippy --workspace -- -D warnings clean
  • cargo test -p rivet-core (892+ tests) passes
  • cargo test -p rivet-cli (108+ tests) passes
  • B7 integration test: clean fixture exit 0; off-disk edit exit 1 with no YAML mutation; --update --apply restores 0
  • B7 clap mutex test: --strict --update rejected
  • B8 integration test: default validate exits 0 on stale; --strict-cited-source-stale exits 1
  • B8 unit tests: ISO-8601 parser, staleness classifier, severity promotion
  • B9 integration test: --list text mode prints dev-to-aspice with built-in origin
  • B9 integration test: --list --format json parses; recipes[] contains dev-to-aspice
  • B9 integration test: project-local recipe under schemas/migrations/ appears with project-local origin
  • B9 clap mutex test: --list --apply <target> rejected

Docs

  • rivet docs schema-cited-sources — new --strict and
    --strict-cited-source-stale flags, audit-gate pattern.
  • rivet docs schema-migrate — new --list mode (text + JSON
    examples).

Notes

  • last-checked semantics changed: it's now both a stamp AND a
    freshness signal. The 30d default is hard-coded; a per-schema
    threshold can land as a separate feature without breaking this
    PR's API.
  • validate_cited_sources gained a strict_stale: bool parameter
    (was 4-arg, now 5-arg). All call sites updated.

🤖 Generated with Claude Code

… migrate --list (#249)

Three platform-engineering CLI symmetries from issue #249:

B7 — `rivet check sources --strict` is a read-only audit gate. Walks
every artifact with a `cited-source`, classifies each as match / drift
/ missing-hash / read-error / shape-error / stale, and exits non-zero
on anything other than match. Mutually exclusive with --update so
audit and fix are never the same invocation. Never modifies any YAML.

B8 — `rivet validate --strict-cited-source-stale` promotes the
previously-Info `cited-source-stale` diagnostic to Error. The stale
verdict now fires for missing, unparseable, OR older-than-30-days
last-checked timestamps (30d is a hard-coded default; per-schema
thresholds remain a follow-up). New helpers:
  - cited_source::parse_iso8601_utc — chrono-free ISO-8601 parsing
  - cited_source::classify_staleness — fresh / missing / old / unparseable

B9 — `rivet schema migrate --list` enumerates every available recipe
(built-in + project-local YAML under <schemas-dir>/migrations/).
Project-local recipes shadow built-ins of the same name. Text and
JSON output. Mutually exclusive with target + action flags. New
`migrate::list_recipes` helper + `RecipeEntry` / `RecipeOrigin` types.

Tests:
- B7: integration test asserts clean fixture exits 0; off-disk edit
  exits 1 without mutating the YAML; --update --apply restores 0.
- B7: clap mutex test for --strict + --update.
- B8: unit tests cover the staleness classifier and severity
  promotion; integration test asserts default exit 0 + strict exit 1.
- B9: unit tests cover built-in / project-local / shadow precedence;
  integration tests cover text + JSON output + clap mutex with --apply.

Docs (rivet docs schema-cited-sources, rivet docs schema-migrate)
updated with the new flags + the audit-gate pattern.

Implements: REQ-007, REQ-004
Verifies: REQ-007, REQ-004
Refs: #249

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rivet Criterion Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: ee68921 Previous: b7a17be Ratio
store_insert/10000 14717203 ns/iter (± 1703331) 10641021 ns/iter (± 264093) 1.38

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link
Copy Markdown

📐 Rivet artifact delta

No artifact changes in this PR. Code-only changes (renderer, CLI wiring, tests) don't touch the artifact graph.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 91.96429% with 27 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/cited_source.rs 92.30% 18 Missing ⚠️
rivet-core/src/migrate.rs 91.17% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit 4c8e7e9 into main May 1, 2026
25 of 40 checks passed
@avrabe avrabe deleted the feat/issue-249-cli-symmetries branch May 1, 2026 12:44
avrabe added a commit that referenced this pull request May 2, 2026
* chore(release): v0.8.0 — dogfood follow-ups

Workspace, vscode-rivet, and npm root package versions bumped to 0.8.0.
Platform packages stay on the release-npm.yml override path.

What's in 0.8.0:

- fix(docs): stale literals + extend rivet docs check (#252, closes
  #247). Six embedded-doc literals fixed, plus three new invariants
  (EmbeddedVersionLiterals, EmbeddedFlagReferences,
  EmbeddedTodoMarkers) to prevent the class of drift from re-shipping.
- feat(docs-check): tighten --coverage rule 4 + --warn-only (#250,
  closes #248). Rule 4 now requires child name to appear in parent
  body (catches false-positives on lsp + batch). New three-mode
  semantics: default silent / --warn-only with annotations / --strict
  fail.
- feat(cli): cited-source --strict, --strict-cited-source-stale,
  schema migrate --list (#251, closes #249). Read-only audit gate
  for cited-source drift; promotable stale severity; recipe discovery.

Trace: skip

* ci: ignore RUSTSEC-2026-0114 (wasmtime 42.x table-allocation panic)

New wasmtime advisory published 2026-04-30, blocking 0.8.0 CI.
Rivet's wasmtime usage is behind an optional wasm feature gate and
doesn't allocate large wasmtime tables, so the panic case isn't
reachable. Follow-up issue will track upgrading to wasmtime >=43.0.2.

Trace: skip
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.

validate: cited-source — add --strict on rivet check sources, promotable cited-source-stale severity, --list for migrate recipes

1 participant