Skip to content

feat(validate): retain base-fields + enforce status enum when declared (REQ-135)#370

Merged
avrabe merged 1 commit into
mainfrom
feat/req-135-base-fields-status-enum
May 31, 2026
Merged

feat(validate): retain base-fields + enforce status enum when declared (REQ-135)#370
avrabe merged 1 commit into
mainfrom
feat/req-135-base-fields-status-enum

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 31, 2026

The mechanism half of the status-enum cluster (#352/#354/#355/#353), root-caused last iteration.

Root cause

The merged Schema struct dropped base-fields entirely — parsed onto SchemaFile, never retained by Schema::merge, read nowhere. So status (a base field, stored as top-level artifact.status) could never be enum-validated, regardless of any declared allowed-values.

Fix (non-breaking)

  • Schema now carries base_fields, unioned by name in merge.
  • validate checks artifact.status against the status base-field's allowed-values when declared (rule status-allowed-values), on both the salsa and --direct paths.
  • remediation adds a status-allowed-values arm ("set to one of […]" / "widen the schema").

Inert when no values are declared (today's common.yaml) — verified rivet's own validate is unchanged (PASS, same warning count). Declaring the canonical lifecycle set activates enforcement.

Verified

2 regression tests; end-to-end on a fixture — a typo'd implmented flags with the full remediation block, a valid approved passes.

Still your call (separate, deliberate)

The canonical cross-project status set to declare in common.yaml — it's shared by downstream projects using varied statuses, so this PR ships the safe mechanism ahead of that decision. Once you confirm the set, activation is a one-line schema edit (+ reconciling rivet's 4 drift statuses).

REQ-135 (mechanism implemented; canonical-set declaration + modify rejection + schema show listing remain).

🤖 Generated with Claude Code

…lared (REQ-135)

Root cause of the status-enum cluster (#352/#354/#355/#353), verified: the
merged `Schema` struct dropped `base-fields` entirely — parsed onto
`SchemaFile`, never retained by `Schema::merge`, read nowhere. So `status` (a
base field, stored top-level as `artifact.status`) could never be enum-validated
regardless of any declared `allowed-values`.

- `Schema` now carries `base_fields`, unioned by name in `merge`.
- `validate` checks `artifact.status` against the `status` base-field's
  `allowed-values` when declared (rule `status-allowed-values`), on both the
  salsa and `--direct` paths.
- `remediation` adds a `status-allowed-values` arm (set-to-allowed /
  widen-schema, "did you mean").

NON-BREAKING: with no `allowed-values` declared (today's common.yaml) the check
is inert — verified rivet's own validate is unchanged (PASS, same warnings).
Declaring the canonical lifecycle set in common.yaml (the maintainer's call)
activates enforcement. 2 regression tests + verified end-to-end (a typo'd
status flags with full remediation; a valid one passes).

Implements: REQ-135
Verifies: REQ-135
Refs: REQ-004

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@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.

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: 97f860f Previous: 27a8b03 Ratio
traceability_matrix/1000 58154 ns/iter (± 212) 44761 ns/iter (± 166) 1.30
query/10000 121571 ns/iter (± 1633) 96878 ns/iter (± 778) 1.25

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

❌ Patch coverage is 72.30769% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/remediation.rs 2.70% 36 Missing ⚠️

📢 Thoughts on this report? Let us know!

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