Add additive ProtocolEvidence JSON export for traceability-matrix-dhf - #1
Merged
Merged
Conversation
- samd_toolkit/evidence.py: export_evidence() serialises an executed IQ/OQ/PQ session (+ optional ISO 14971 RMF) to a Pydantic v2 ProtocolEvidence model. Shares envelope and iec_62304/iso_14971 block shapes with ml-samd-validator's ValidationEvidence; carries no drift/fairness data (not produced here). - Committed JSON Schema contract, kept in sync by test. - pydantic is an optional [evidence] extra; core stays dependency-free. - CI coverage floor 70% -> 80% (current 85%); README coverage badge + section. Existing IQ/OQ/PQ, HTML, RMF, IEC 62304, cyber and SPDX output verified byte-identical against the previous commit for Class I/II/III devices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
samd_toolkit/evidence.pyaddsexport_evidence(session, rmf=None, requirement_ids=None, path=None). It turns an executed IQ/OQ/PQValidationSessioninto a Pydantic v2ProtocolEvidencemodel. It can also include an ISO 14971RiskManagementFile. Ifpathis given, it writes the result as JSON.samd_toolkit/protocol-evidence.schema.jsonis the committed contract (JSON Schema 2020-12,schema_version: "1.0",source: "samd-val-kit"). A test fails if it drifts from the model.setup.py: pydantic is an optional[evidence]extra, so the core toolkit still has no dependencies. pydantic and jsonschema are added to[dev]. The schema file is included viapackage_data.evidence.pyis at 100%).Why
This gives traceability-matrix-dhf a machine-readable record of executed IQ/OQ/PQ protocols, supporting 21 CFR 820.30(f)/(g) and IEC 62304 §5.7.
Reviewer notes
ValidationEvidencepayload. The shared contract in traceability-matrix-dhf and ml-samd-validator requiresbaseline,snapshot,driftandfairness. This toolkit doesn't produce those, and filling them in would create false DHF records. The export reuses the shared envelope (generated_at,evidence_id,requirement_ids) and theiec_62304/iso_14971block shapes. The IQ/OQ/PQ record goes in a newprotocolblock.ValidationEvidenceRecord.from_validation_evidenceonly accepts ml-samd-validator payloads, so it needs asamd-val-kitsource adapter. The README says so.master.test_export_does_not_alter_existing_outputguards against mutation.--emit-evidenceCLI flag. The CLI only runs demos and has no session to export.Known pre-existing issues (not addressed here)
checklist.py,pdf_reporter.py,export_pdf,generate --device-class,rmf.generate_report).HTMLReporterlabels its timestamp "UTC" but uses naive localdatetime.now(). I left it alone to keep existing output byte-identical.🤖 Generated with Claude Code