Skip to content

feat: schema, LSP fixes, EU AI Act, salsa default, STPA analysis#101

Merged
avrabe merged 10 commits intomainfrom
feat/schema-packages
Apr 2, 2026
Merged

feat: schema, LSP fixes, EU AI Act, salsa default, STPA analysis#101
avrabe merged 10 commits intomainfrom
feat/schema-packages

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 1, 2026

Summary

Five workstreams in one PR:

1. Schema guidance (#93 Phase 1)

  • common-mistakes + example fields on ArtifactTypeDef
  • rivet schema show surfaces guidance in text + JSON

2. EU AI Act compliance schema (#99 Phase 1)

  • schemas/eu-ai-act.yaml — 15 artifact types (Annex IV + Articles 9-15)
  • 14 link types, 12 traceability rules for mandatory obligations
  • Embedded into binary, ready for rivet init --schema eu-ai-act

3. LSP diagnostic fixes

  • Parse errors surfaced with line/column (SC-LSP-001)
  • Type-aware allowed-values for YAML coercion (SC-LSP-004)
  • Unknown link types detected (new validation phase)
  • Unknown fields detected (new validation phase)
  • First LSP test suite: 25 unit + 16 YAML edge case tests

4. Salsa incremental as default (#22)

  • rivet validate now uses salsa by default
  • Old path available via --direct flag
  • Baseline-scoped validation auto-falls back to direct

5. STPA analysis of LSP accuracy

  • safety/stpa/lsp-diagnostics.yaml — losses, hazards, system constraints
  • 3 losses, 4 hazards, 7 system constraints
  • Tracks which constraints are satisfied by this PR

Test coverage: 49 new tests

  • 8 type-aware validation, 25 LSP unit, 16 YAML edge cases

Refs #22, #93, #99.

Test plan

  • cargo test --workspace — all tests pass
  • cargo clippy + cargo fmt — clean
  • CI

🤖 Generated with Claude Code

avrabe added 4 commits April 1, 2026 18:58
Extends ArtifactTypeDef with two optional guidance fields:
- common_mistakes: Vec<MistakeGuide> — problem/fix pairs for AI agents
- example: Option<String> — YAML snippet shown in schema show output

Both fields default to empty, so existing schemas parse unchanged.
The rivet schema show command (text + JSON) surfaces these fields.
Adds guidance fields to requirement, design-decision, and feature
types in the dev schema. Shown in 'rivet schema show' output and
available to AI agents via JSON format.
First-ever LSP tests (25 tests):
- lsp_word_at_position: word extraction, edge cases, special chars
- lsp_find_artifact_line: exact ID matching, format variants
- lsp_uri_to_path roundtrip
- Diagnostic-to-LSP mapping: severity, file grouping, line numbers

YAML edge case tests (16 tests):
- serde_yaml 0.9 uses YAML 1.2: yes/no are strings, only true/false
  are booleans (no Norway problem)
- Numeric coercion: bare 1.0 is float, quoted stays string
- Duplicate keys: struct-level is error, map-level last wins
- Error recovery: malformed YAML, missing fields, empty docs
Parse errors are now shown as LSP diagnostics instead of silently
returning empty results. Extends Diagnostic with source_file, line,
column fields. The LSP diagnostic publisher checks source_file first
(parse errors), then falls back to artifact-based file lookup.

Also adds collect_parse_errors() salsa tracked function that
composes with structural and conditional-rule validation in
validate_all().
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 83.53808% with 67 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rivet-core/src/validate.rs 88.35% 39 Missing ⚠️
rivet-core/src/db.rs 54.09% 28 Missing ⚠️

📢 Thoughts on this report? Let us know!

Phase 1 of #99: schemas/eu-ai-act.yaml with 15 artifact types mapping
to EU AI Act Annex IV (9 mandatory sections) and Articles 9-15.

Artifact types: ai-system-description, design-specification,
data-governance-record, third-party-component, monitoring-measure,
performance-evaluation, risk-management-process, risk-assessment,
risk-mitigation, misuse-risk, transparency-record,
human-oversight-measure, standards-reference, conformity-declaration,
post-market-plan.

14 link types + 12 traceability rules enforcing mandatory obligations.
Registered as embedded schema (compiled into binary).

EU AI Act high-risk provisions applicable from August 2, 2026.
@avrabe avrabe changed the title feat: schema guidance fields + LSP diagnostic fixes feat: schema guidance, LSP fixes, EU AI Act compliance schema Apr 2, 2026
avrabe added 2 commits April 1, 2026 20:03
Two new validation phases:
- Phase 8: unknown-link-type — warns when an artifact uses a link
  type not defined in the schema
- Phase 9: unknown-field — info when an artifact has fields not
  defined in its type's schema

Both are non-breaking (warning/info severity) but catch common
mistakes that previously went undetected.
Losses: undetected compliance violations, wasted time on false
positives, AI agent infinite retry loops.

Hazards: false negatives (H-LSP-001), false positives (H-LSP-002),
wrong location (H-LSP-003), misleading fix suggestions (H-LSP-004).

7 system constraints: SC-LSP-001 through SC-LSP-007 covering parse
error handling, validation completeness, schema change invalidation,
YAML type coercion, actionable messages, cascade prevention, and
incremental validation correctness.

Status of constraints:
- SC-LSP-001: SATISFIED (PR #101 — parse errors surfaced)
- SC-LSP-004: SATISFIED (PR #101 — type-aware validation)
- SC-LSP-002: PARTIALLY (document refs not in LSP yet)
- SC-LSP-003: NOT SATISFIED (schema changes not re-loaded)
- SC-LSP-005: PARTIALLY (some messages still vague)
- SC-LSP-006: PARTIALLY (parse errors no longer cascade to empty, but broken-link cascade still possible)
- SC-LSP-007: PENDING (#22 — salsa becoming default)
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: d41afd3 Previous: 0661926 Ratio
validate/100 65554 ns/iter (± 322) 44111 ns/iter (± 184) 1.49
validate/1000 859948 ns/iter (± 3956) 498872 ns/iter (± 4254) 1.72
validate/10000 9675760 ns/iter (± 447341) 5278435 ns/iter (± 108213) 1.83

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

The salsa incremental validation pipeline (db.rs) is now the default
path for 'rivet validate'. The old direct path is available via
--direct flag for fallback or when --baseline scoping is used.

Changes:
- Removed --incremental and --verify-incremental flags
- Added --direct flag (opt-in to old non-incremental path)
- Default: salsa tracked functions (parse_artifacts, validate_all,
  evaluate_conditional_rules) with automatic cache invalidation
- Baseline-scoped validation automatically uses direct path since
  salsa doesn't support scoped stores

The salsa path produces identical diagnostics to the direct path,
verified by the existing 22 salsa database tests and previous
--verify-incremental infrastructure.

Refs: #22
@avrabe avrabe changed the title feat: schema guidance, LSP fixes, EU AI Act compliance schema feat: schema, LSP fixes, EU AI Act, salsa default, STPA analysis Apr 2, 2026
avrabe added 2 commits April 1, 2026 20:24
Completes EU AI Act Phase 1 + Phase 2:

- rivet init --preset eu-ai-act — starter artifacts covering
  system description, design, risk management, monitoring, oversight
- eu-ai-act-stpa.bridge.yaml — maps STPA hazards → risk assessments,
  system constraints → risk mitigations
- eu-ai-act-aspice.bridge.yaml — maps ASPICE verification evidence →
  performance evaluations
- examples/eu-ai-act/ — full 17-artifact example project demonstrating
  Annex IV compliance for a predictive maintenance AI system
  - Validates clean (0 warnings)
  - Document with {{stats}}, {{coverage}}, {{diagnostics}} embeds
  - Realistic content: XGBoost+LSTM hybrid model, bias assessment,
    drift detection, human oversight dashboard
@avrabe avrabe merged commit 2f54fab into main Apr 2, 2026
13 checks passed
@avrabe avrabe deleted the feat/schema-packages branch April 2, 2026 00:27
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