Skip to content

feat(schema): rivet schema migrate Phase 2 — conflict markers + --continue / --skip / --edit#242

Merged
avrabe merged 2 commits intomainfrom
feat/schema-migrate-phase2
Apr 29, 2026
Merged

feat(schema): rivet schema migrate Phase 2 — conflict markers + --continue / --skip / --edit#242
avrabe merged 2 commits intomainfrom
feat/schema-migrate-phase2

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 29, 2026

Phase 2 of issue #236. Phase 1 shipped in 0.6.0 (#240) with the diff engine and mechanical apply. Phase 2 adds the rebase-style conflict-resolution UX.

Summary

  • Conflict markers in YAML: --apply writes <<<<<<< source ... ======= target ... >>>>>>> blocks for FieldValueConflict (e.g. priority: 5 -> enum) and pauses with state CONFLICT.
  • --continue: verifies markers are gone, re-parses the file, marks resolved in manifest.yaml, advances to next conflict or COMPLETE.
  • --skip: rebuilds the file from snapshot for the conflicted artifact, leaves other artifacts in their migrated form, advances.
  • --edit <ID>: re-opens a previously-resolved conflict by re-stamping markers and setting state to CONFLICT.
  • MigrationState::Conflict + current-conflict pointer file (already in Phase 1 storage layout, now wired up).
  • Diff engine: diff_artifacts now emits FieldValueConflict for any source value that violates the target field's allowed_values enum.
  • MigrationConflict doc-check invariant: scans every artifacts/**/*.yaml for leftover markers; fails rivet docs check.
  • --status: reports CONFLICT state with current artifact id, file path, and next-step suggestions.

Phase 2 acceptance criteria (per #236)

  • Conflict markers spliced into YAML on --apply pause
  • --continue checks for residual markers + re-validates YAML + advances state
  • --skip restores artifact from snapshot + advances state
  • --edit <ID> re-opens a resolved conflict
  • State machine extended with CONFLICT
  • current-conflict file wired in
  • MigrationConflict invariant in rivet docs check
  • Conflict harness fixture + skip/edit/continue integration tests
  • rivet docs schema-migrate updated with the conflict-resolution flow

Deferred to Phase 3

  • Dashboard /migrations/<id> view
  • rivet recipes subcommand / recipe distribution
  • Provenance entries on migrated artifacts (post-MVP)

Test plan

  • cargo check -p rivet-cli -p rivet-core clean
  • cargo clippy --workspace -- -D warnings clean (only the pre-existing WASM stub warning)
  • cargo fmt --all --check clean
  • cargo test -p rivet-core --lib migrate — 15/15 unit tests pass (8 inherited + 7 new)
  • cargo test -p rivet-cli --test migrate_integration — 11/11 tests pass (5 inherited + 6 new)
  • cargo test -p rivet-cli — full suite passes
  • rivet docs check clean against the rivet repo
  • Smoke test: synthetic project where priority: 5 targets an enum; --apply pauses with markers, programmatic resolve, --continue reaches COMPLETE.

Files

  • rivet-core/src/migrate.rs — engine: MigrationState::Conflict, ResolutionStatus, conflict-marker writer/scanner, partial apply, restore-from-snapshot.
  • rivet-core/src/doc_check.rsMigrationConflict doc-check invariant.
  • rivet-cli/src/migrate_cmd.rs — new cmd_continue / cmd_skip / cmd_edit; cmd_apply rewritten to pause on conflict.
  • rivet-cli/src/main.rs--continue / --skip / --edit CLI wiring.
  • rivet-cli/src/docs.rs — Phase 2 conflict-resolution flow in the schema-migrate topic.
  • rivet-cli/tests/migrate_integration.rs — 6 new integration tests.

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

📐 Rivet artifact delta

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

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: 83acdc3 Previous: 189f020 Ratio
store_insert/10000 14292983 ns/iter (± 1655015) 10721000 ns/iter (± 239834) 1.33
link_graph_build/10000 37568915 ns/iter (± 5709273) 22364354 ns/iter (± 211537) 1.68

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 78.32031% with 111 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/migrate.rs 86.59% 61 Missing ⚠️
rivet-core/src/doc_check.rs 12.28% 50 Missing ⚠️

📢 Thoughts on this report? Let us know!

avrabe and others added 2 commits April 29, 2026 22:16
Phase 2 of issue #236. Phase 1 (in 0.6.0) shipped the diff engine and
mechanical apply with snapshot/abort. Phase 2 adds the rebase-style
conflict-resolution flow.

Engine (rivet-core/src/migrate.rs):
* `MigrationState::Conflict` joins the existing `Planned / InProgress
  / Complete` states.
* `MigrationManifest.resolutions` tracks per-artifact `pending /
  resolved / skipped` status across `--apply / --continue / --skip /
  --edit`.
* `MigrationLayout::current_conflict_path` writes the artifact id the
  walker paused on; `--status` surfaces it.
* `diff_artifacts` now emits `FieldValueConflict` for any source
  field whose value violates the target field's `allowed_values`
  enum (e.g. `priority: 5` → `[must|should|could|wont]`).
* `apply_to_file_partial` skips conflict-class entries; the `--apply`
  walker uses it so mechanical changes always commit before pausing.
* `write_conflict_markers` splices git-rebase-style `<<<<<<<` /
  `=======` / `>>>>>>>` blocks into the affected field.
  `scan_conflict_markers` is the inverse used by `--continue` and the
  `MigrationConflict` doc-check invariant.
* `restore_artifact_from_snapshot` swaps a single artifact back to
  its pre-migration form for `--skip`.

CLI (rivet-cli/src/migrate_cmd.rs + main.rs):
* `--apply` no longer bails on conflicts — it walks the plan,
  applies every mechanical/decidable change, then writes markers for
  the first conflict and exits non-zero with state CONFLICT.
* `--continue` verifies markers are gone, re-parses the file as
  YAML, marks resolved, advances.
* `--skip` rebuilds the file from the snapshot (mechanical-pass
  applied to other artifacts in the same file) and restores the
  conflicted artifact's pre-migration form.
* `--edit <ID>` re-stamps markers on a previously-resolved or
  skipped conflict.
* `--status` reports CONFLICT state plus the current conflict's id
  and file, with next-step suggestions.

Validation (rivet-core/src/doc_check.rs):
* `MigrationConflict` doc-invariant scans every `*.yaml` /  `*.yml`
  under `<project>/artifacts/` and emits a violation for any line
  that begins with `<<<<<<<` / `=======` / `>>>>>>>`. Prevents
  accidental commits with leftover markers.

Tests (rivet-core/src/migrate.rs + rivet-cli/tests/migrate_integration.rs):
* 7 new unit tests covering enum-mismatch detection, marker round
  trip, scan, restore-from-snapshot, partial-apply, plan lookup, and
  Conflict state roundtrip.
* 6 new integration tests covering the apply-pauses-on-conflict
  flow, --continue success, --continue marker rejection, --skip
  restore, --edit re-open, and the docs-check MigrationConflict
  surface.

Phase 3 (deferred): dashboard `/migrations/<id>` view, `rivet
recipes` subcommand for recipe distribution, provenance entries on
migrated artifacts.

Implements: REQ-007, REQ-010
Implements: REQ-004
Verifies: REQ-007, REQ-010, REQ-004

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

Extend the embedded `rivet docs schema-migrate` topic with:
* Updated quick-start commands (`--continue`, `--skip`, `--edit`)
* CONFLICT state in the state-machine diagram
* Worked example of marker syntax + resolution workflow
* `current-conflict` file in the storage-layout table
* Note on the `MigrationConflict` doc-check invariant
* Refreshed "still deferred" list (dashboard, recipes subcommand).

Refs: FEAT-001
@avrabe avrabe force-pushed the feat/schema-migrate-phase2 branch from 83acdc3 to bc3ba33 Compare April 29, 2026 20:16
@avrabe avrabe merged commit 0371cad into main Apr 29, 2026
24 of 40 checks passed
@avrabe avrabe deleted the feat/schema-migrate-phase2 branch April 29, 2026 21:37
avrabe added a commit that referenced this pull request Apr 30, 2026
…246)

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

What's in 0.7.0:

- feat(schema): rivet schema migrate Phase 2 (#242) — full git-rebase
  conflict-resolution UX. Conflict markers in YAML, --continue,
  --skip, --edit. New MigrationConflict invariant in rivet docs check.
- feat(docs-check): subcommand-coverage gate (#241) — walks the live
  clap CLI tree and asserts each path has an embedded docs topic.
  Default warn-only; --strict makes it enforcing.
- feat(validate): prose-mention-without-typed-link warning (#234,
  closes #207).
- feat(schemas): vv-coverage repo-status type (#232, partial #188).
- feat(mutants): canonical cargo-mutants template (#229, closes #185).
- docs(pre-commit): canonical 21-hook template (#222, closes #186).
- fix(ci): Release workflow now idempotent on existing tag (#244).

Known issue: v0.5.0 / v0.5.1 / v0.6.0 release pages have no binary
assets attached because the workflow's Create Release step failed
on each (race with manual gh release create). The fix in #244 lands
in this release; v0.7.0 onward is unaffected. Older releases need
a manual gh release upload to backfill.

Verified: cargo check, cargo clippy --workspace -- -D warnings,
cargo test -p rivet-cli, rivet docs check (clean), rivet docs check
--coverage reports 48/81 paths covered (warn-only).

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.

1 participant