Skip to content

feat: schema-driven YAML extraction — the stpa.rs replacement (Phase 3)#120

Merged
avrabe merged 1 commit intomainfrom
feat/schema-driven-phase3
Apr 2, 2026
Merged

feat: schema-driven YAML extraction — the stpa.rs replacement (Phase 3)#120
avrabe merged 1 commit intomainfrom
feat/schema-driven-phase3

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 2, 2026

Summary

The architectural capstone: extract_schema_driven() uses schema metadata to parse YAML without hardcoded type knowledge.

  • yaml-section: losses on a type → parser finds losses: key, auto-sets artifact_type: loss
  • shorthand-links: {losses: leads-to-loss} → converts losses: [L-001] to proper Links
  • Falls back to generic artifacts: extraction
  • Handles mixed-section files

This single function replaces the 861-line formats/stpa.rs with its 14 serde structs. Deletion comes in Phase 6 after wiring into salsa (Phase 5).

4 new schema-driven tests. 14 total HIR tests.

Refs #22, #93.

🤖 Generated with Claude Code

The capstone: extract_schema_driven() uses yaml-section and
shorthand-links metadata from the schema to parse both generic-yaml
and STPA-yaml formats with ONE function.

- Reads yaml-section to map top-level keys to artifact types
- Converts shorthand-links fields to Link objects automatically
- Falls back to generic artifacts: extraction when no section matches
- Handles mixed-section files (losses + hazards in same file)

Added yaml-section + shorthand-links to controller-constraint and
loss-scenario types in STPA schema (was missing).

4 new tests: losses, hazards with shorthand links, mixed sections,
generic fallback. Total: 14 HIR tests.

This function can replace the 861-line stpa.rs once wired into
the salsa pipeline (Phase 5).
@avrabe avrabe merged commit e4f398e into main Apr 2, 2026
@avrabe avrabe deleted the feat/schema-driven-phase3 branch April 2, 2026 23:35
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: 34409b8 Previous: e4f398e Ratio
validate/10000 12550053 ns/iter (± 1657368) 10328007 ns/iter (± 93067) 1.22
traceability_matrix/1000 61361 ns/iter (± 1710) 47654 ns/iter (± 150) 1.29
query/1000 8407 ns/iter (± 43) 6562 ns/iter (± 47) 1.28
query/10000 128048 ns/iter (± 2270) 90301 ns/iter (± 409) 1.42
document_parse/100 176800 ns/iter (± 2008) 145353 ns/iter (± 13733) 1.22
document_parse/1000 1661441 ns/iter (± 30260) 1357315 ns/iter (± 19462) 1.22

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

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