Skip to content

Add test harness, CI, and RiskControl evidence export for traceability-matrix-dhf - #1

Merged
LSaiko merged 3 commits into
masterfrom
evidence-export
Sep 23, 2026
Merged

LSaiko merged 3 commits into
masterfrom
evidence-export

Conversation

@LSaiko

@LSaiko LSaiko commented Sep 23, 2026

Copy link
Copy Markdown
Owner

What changed

1. Tests and CI (e04402a)

  • test_golden.py saves a SHA-256 fingerprint of every workbook cell value for all 3 scenarios, with and without --iso14971. The fingerprints were taken before any code change, so any unintended change to the openpyxl output fails the test. After an intended output change, refresh them with python test_golden.py --update.
  • Smoke test: generate --format all for each scenario (xlsx, docx and pdf).
  • .github/workflows/ci.yml: pytest on Python 3.9 and 3.13, a 75% coverage minimum (measured: 77%), and check on all 3 scenarios.
  • New dev install option in pyproject.toml, and pytest-cov settings.

2. Risk evidence export (3b4d929)

  • generate --evidence writes <output>.risk.json next to the workbook. The workbook itself is unchanged; the golden test verifies this.
  • The file has source: "foremode" at the top level and a risk_controls list. Each record matches traceability-matrix-dhf's RiskControl model. A copy of that schema lives at schemas/risk-control.schema.json.
  • Field mapping:
    • hazard and harm come from the iso14971 fields in the scenario, falling back to the failure mode and effect.
    • severity = ceil(S/2) and probability = ceil(O/2), converting the 1–10 pFMEA scale to the 1–5 DHF scale.
    • control_measure = prevention + detection controls, plus the planned action if there is one.
    • residual_risk_acceptable is left null for a quality engineer to decide.
  • If the failure and rating rows don't match up one-to-one, the export stops with an error instead of silently dropping risks.

3. README (8624eab)

  • CI and coverage badges, a "Risk evidence export" section with the mapping table, and an updated repo-structure list.

Reviewer notes

  • The task asked for a RiskRecord schema that doesn't exist. traceability-matrix-dhf has no docs/adapters.md and no RiskRecord on any branch; Persist the DHF store in SQLite behind a TraceabilityStore interface traceability-matrix-dhf#1 didn't add one. This PR targets the RiskControl model that ingestion already accepts. RiskControl doesn't allow extra fields, so source goes on the top level of the file rather than on each record.
  • test_evidence.py also loads the records into the live DHF DhfProject model when a sibling ../traceability-matrix-dhf checkout exists, and checks that the schema copy still matches that model. It is skipped in CI, where there's no sibling checkout.
  • Verified locally: 31 tests pass on 3.14 and 3.12. The 3.9 CI leg hasn't been run locally.

🤖 Generated with Claude Code

LSaiko and others added 3 commits September 22, 2026 23:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
generate --evidence writes <output>.risk.json (source=foremode) alongside the
unchanged openpyxl workbook; records validate against DHF's RiskControl schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LSaiko
LSaiko merged commit cc1da56 into master Sep 23, 2026
4 checks passed
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