Skip to content

feat: add type-map config to ReqIF adapter#7

Merged
avrabe merged 14 commits intomainfrom
feat/reqif-type-map
Mar 10, 2026
Merged

feat: add type-map config to ReqIF adapter#7
avrabe merged 14 commits intomainfrom
feat/reqif-type-map

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Mar 10, 2026

Summary

  • Add type-map.* config support to the ReqIF import adapter
  • Allows remapping artifact types during import (e.g. requirementsw-req)
  • Unmapped types pass through unchanged
  • Config threaded through parse_reqif() and import_reqif_directory()

Motivation

StrictDoc ReqIF exports use generic types (REQUIREMENT, SECTION, TEXT) that don't match ASPICE schema types (sw-req, system-req). This feature lets projects remap types at import time:

sources:
  - path: upstream.reqif
    format: reqif
    config:
      type-map.requirement: sw-req
      type-map.section: documentation

Test plan

  • New unit test test_type_map_remaps_artifact_types — verifies mapping and passthrough
  • All existing ReqIF tests pass (roundtrip, minimal, duplicate attrs, StrictDoc integration)
  • Fuzz target updated for new signature
  • Integration test updated for new signature

🤖 Generated with Claude Code

avrabe and others added 4 commits March 9, 2026 19:55
Comprehensive audit covering source-ref integrity (20 refs, 1 fixed),
test coverage (151 tests across 6 levels), benchmark coverage (19 cases
in 7 groups), fuzz/mutation testing status (not yet implemented), and
traceability (85 artifacts, 0 broken links, 0 orphans).

Fix DD-002 source-ref from non-existent graph.rs to links.rs.

Overall quality score: 73% — strong foundation with gaps in fuzz
testing, mutation testing, and benchmark coverage for newer modules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 4 fuzz targets (cargo-fuzz/libfuzzer) for untrusted-input boundaries:
- fuzz_yaml_artifact: YAML artifact deserialization
- fuzz_schema_merge: schema parsing and merge operations
- fuzz_reqif_import: ReqIF XML import parsing
- fuzz_document_parse: markdown frontmatter parsing

Add 3 new benchmark groups (9 cases) to core_benchmarks.rs:
- diff: ArtifactDiff::compute at 100/1000/10000 scale
- query: query::execute filtering at 100/1000/10000 scale
- document_parse: Document::parse at 10/100/1000 sections

Update pre-commit hooks:
- rivet validate --strict (dogfood on artifact/schema changes)
- cargo bench --no-run (compile check, pre-push)
- cargo mutants smoke run (pre-push)

Add CI jobs:
- mutants: cargo-mutants on rivet-core (informational, non-blocking)
- fuzz: 30s per target on push to main (informational, non-blocking)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s, ReqIF.ForeignID)

StrictDoc's ReqIF output uses patterns rivet didn't handle:
- ATTRIBUTE-DEFINITION-ENUMERATION interleaved with STRING defs
  (quick-xml failed with "duplicate field"). Fixed by enabling the
  overlapped-lists feature.
- ATTRIBUTE-VALUE-ENUMERATION for enum fields (e.g. TYPE=Functional).
  Added enum value resolution via DATATYPE-DEFINITION-ENUMERATION.
- ReqIF.ForeignID as the human-readable UID (ZEP-SRS-18-1), with
  the XML IDENTIFIER being a UUID. Now used as artifact ID.
- ReqIF.Name / ReqIF.ChapterName as title, ReqIF.Text as description.
- SPECIFICATION-TYPE elements (parsed but ignored).
- Duplicate ATTRIBUTE-DEFINITION-STRING tolerance (first wins).
- UUID-to-resolved-ID mapping for SPEC-RELATION link targets.

Tested with Zephyr RTOS reqmgmt export: 256 artifacts, 223
requirements with ZEP-* IDs, 132 parent links preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Support remapping artifact types during ReqIF import via source config:

  sources:
    - path: upstream.reqif
      format: reqif
      config:
        type-map.requirement: sw-req
        type-map.section: documentation

Keys are matched case-insensitively against the resolved artifact type.
Unmapped types pass through unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 82.96089% with 122 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/reqif.rs 70.50% 59 Missing ⚠️
rivet-core/src/commits.rs 92.38% 37 Missing ⚠️
rivet-core/src/formats/aadl.rs 0.00% 20 Missing ⚠️
rivet-core/src/model.rs 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

avrabe and others added 10 commits March 10, 2026 20:14
…fooding

Adds `rivet commits` and `rivet commit-msg-check` commands for tracing
git commits to artifacts. Includes trace-exempt-artifacts config for
pre-existing artifacts, pre-commit hook setup, and built-in documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…L access

Eliminates /?goto= redirect pattern that caused race conditions, lost
query params and hash fragments. Non-HTMX requests now get full page
layout wrapped around the partial content inline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… analyses

Bumps spar to rev 5073591, syncs WIT with analyze function and
analysis-diagnostic record, registers 12 new analysis passes
(flow/mode/binding/property rules, EMV2, ARINC653, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Design covers mesh topology, prefixed IDs, externals config, cache/sync,
distributed baselining, and WASM embedding. 12-task implementation plan
with TDD steps. Also includes commit traceability design/plan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bump spar-hir and spar-analysis from rev 5073591 to 84a7363 (latest
origin/main, 0 commits behind). Adds build_wasm_assets() to build.rs
which auto-builds spar WASM assets when missing if spar repo is
available (via SPAR_DIR env var or ../spar default).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Compares local spar repo HEAD against the rev pinned in Cargo.toml
at build time. Warns when they diverge, showing commit distance
and suggesting cargo update command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kill and wait child process before panicking in serve_integration test
to avoid zombie processes. Inline unnecessary let binding in serve.rs
git-ref prefix computation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cargo-mutants no longer accepts --lib directly; pass it after --
as a cargo test argument.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@avrabe avrabe merged commit 3b04f01 into main Mar 10, 2026
14 of 15 checks passed
@avrabe avrabe deleted the feat/reqif-type-map branch March 10, 2026 21:10
avrabe added a commit that referenced this pull request Apr 22, 2026
* docs+feat(variant): feature-model schema reference + init scaffolder

Pain point: users reverse-engineer the feature-model YAML schema because
`rivet variant --help` has no field reference and `selects:` vs
`selected:` / group types / s-expression constraint syntax / bindings
file shape are undocumented.

Changes:
- Add docs/feature-model-schema.md: top-level reference for feature
  model YAML (root, features, group types, constraint syntax) with a
  worked example.
- Add docs/feature-model-bindings.md: dedicated binding file reference.
- Link both from docs/getting-started.md.
- Variant subcommand doc-comment now points at the schema reference so
  `rivet variant --help` surfaces it.
- Add `rivet variant init <name>` scaffolder that writes a starter
  feature-model.yaml + bindings/<name>.yaml with comments documenting
  every field.

Tests: 3 new integration tests in rivet-cli/tests/variant_init.rs
covering scaffolded file contents, overwrite protection, and that the
scaffolded template parses clean via `rivet variant list`.

Implements: REQ-042, REQ-043, REQ-044
Refs: REQ-046

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

* fix(hooks): pre-commit hook walks up to find rivet.yaml (marker discovery)

Pain point: `rivet init --hooks` emitted a pre-commit hook that ran
`rivet validate` at the git root. If the rivet project is relocated
inside the working tree (e.g. moved to subdir/), the hook either
silently validates the wrong directory or fails to find rivet.yaml.

Fix: the installed pre-commit hook now walks up from $PWD until it
finds a directory containing rivet.yaml, then cd's there before
invoking `rivet validate`. If no rivet.yaml exists in the ancestor
chain, the hook exits 0 silently so it does not block commits in
unrelated repositories.

Tests: rivet-cli/tests/hooks_install.rs adds 2 integration tests — one
verifies the hook body does not embed a hard-coded -p/--project flag and
uses the walk-up pattern; one stages a fresh project, moves rivet.yaml
into a subdirectory, and confirms the hook still discovers it when run
from a nested path.

Fixes: REQ-051

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

* feat(variant): check-all + optional --variant on validate (API ergonomics)

Pain point: variant-scoped validation required --model, --variant, and
--binding to be passed together — there was no way to validate just
model/binding consistency, and no single-invocation way to assert a
whole batch of variants is valid.

Changes:
- `rivet validate --model X --binding Y` (no --variant) now parses the
  model, parses the binding, and checks that every feature referenced
  in the binding exists in the model. Reports a clear diagnostic on
  unknown feature names instead of the old "must all be provided
  together" error. The full --model + --variant + --binding mode is
  unchanged.
- `rivet variant check-all --model M --binding B` iterates every
  variant declared under `variants:` in the binding file, prints a
  PASS/FAIL line per variant, and exits non-zero if any fail.
- `FeatureBinding` in rivet-core grows an optional `variants:` field
  (default empty) so the same file can carry bindings and declared
  variants without schema churn.

Tests: 5 new integration tests in rivet-cli/tests/variant_scoped_api.rs
cover the no-variant validate mode, the unknown-feature diagnostic,
check-all exit codes for mixed/all-pass fixtures, and JSON output shape.
Existing feature_model unit tests still pass (binding YAML is
backward-compatible — `variants:` defaults to empty).

Implements: REQ-044, REQ-045, REQ-046

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

* fix(sexpr): semantic notes on filter parse errors

Pain point: `[FilterError { offset: 14, message: "unexpected atom at
top level" }]` exposed parser internals. Users writing `A and B`,
`and A B`, or `(bogus A B)` got a positional offset with no hint that
they were using the wrong syntax.

Fix: extend `FilterError` with an optional `note` field, populated by a
classifier that inspects the source before parsing. Three common shapes
get a semantic nudge:
  - bare infix (`A and B`) → suggest `(and A B)`.
  - missing outer parens (`and A B`) → suggest wrapping it.
  - unknown head (`(bogus …)`) → reference the supported form list.
`FilterError::Display` renders the positional detail followed by the
note on a new line. Feature-model constraint errors now format via
Display instead of Debug, so the note bubbles out through
`rivet variant check` / `rivet validate --model` paths.

Tests: 4 new unit tests in sexpr_eval covering the three error shapes
plus a success case that must carry no note. All pre-existing tests
unchanged.

Fixes: REQ-043
Implements: REQ-042

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

* feat(variant-solve): per-feature origin tracking (selected vs mandatory vs implied)

Pain point: `rivet variant solve` output mixed user-picked features with
ones the solver added via mandatory-group propagation or constraint
implication. A flat list like `base, auth, oauth, token-cache, metrics`
didn't tell the user which features were their intent and which were
downstream effects.

Minimum-impact change per scope-limits brief (risk of conflict with
PR #156 cross-tree constraint work):
- Extend `ResolvedVariant` with a per-feature `origins: BTreeMap<String,
  FeatureOrigin>` where FeatureOrigin is UserSelected / Mandatory /
  ImpliedBy(name) / AllowedButUnbound.
- Populate origins alongside the existing selected-set fixpoint loop —
  no algorithmic changes. First-reason-wins on insertion so user
  selection beats later mandatory/implied discoveries.
- Text output of `rivet variant solve` prints one feature per line,
  prefixed with `+`, labeled (mandatory) / (selected) / (implied by X).
- JSON output is strictly additive: `effective_features` + `feature_count`
  preserved, new `origins` object keyed by feature name.

Tests:
- 4 new unit tests in rivet-core/src/feature_model.rs covering each
  origin variant.
- 2 new integration tests in rivet-cli/tests/variant_solve_origins.rs
  asserting text prefixes/labels and JSON backwards compatibility.
- All 15 pre-existing feature_model unit tests still pass; all 6
  proptest_feature_model properties still hold.

Implements: REQ-043, REQ-046
Refs: REQ-052

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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