feat(schema): EvidenceItem + EvidenceManifest with SHA-256 [W1.B.3]#6
feat(schema): EvidenceItem + EvidenceManifest with SHA-256 [W1.B.3]#6TimothyVang wants to merge 1 commit into
Conversation
TimothyVang
left a comment
There was a problem hiding this comment.
REVIEW + AUDIT — W1.B.3 EvidenceItem + EvidenceManifest
REVIEW FINDINGS — All Checks Pass
Ruff (lint + format): Both files pass.
verdict/schemas/evidence.py✓tests/schemas/test_evidence.py✓
Test coverage: 11 tests, all with clear GREEN path assertions:
test_evidence_path_is_path_type— validates Path type (§3.1 requirement)test_sha256_field_present_on_evidence_item— validates SHA-256 presence, 64-char assertiontest_evidence_type_accepts_all_literals— validates all 6 enum valuestest_evidence_type_rejects_unknown— validates enum constraint via ValidationErrortest_evidence_item_round_trips_json— validates JSON serialization round-triptest_manifest_is_collection_of_evidence_items— validates list[EvidenceItem]test_manifest_has_case_id— validates case_id fieldtest_manifest_schema_version_default_1— validates schema_version default per Appendix A.3test_manifest_hash_is_blake3_of_sorted_pairs— W1.B.3.a canonical test: assertionmanifest.compute_manifest_hash() == expected_hashtest_manifest_hash_order_independent— validates insertion-order invariancetest_manifest_round_trips_json— validates manifest JSON serialization with computed hash
Commit format: feat(schema): EvidenceItem + EvidenceManifest with SHA-256 [W1.B.3] ✓
TDD audit: ✓ Tests present in diff; implementation provided. Single-task schema commit is acceptable structure.
AUDIT FINDINGS
§3.1 Evidence integrity — BLOCKING: PASS
-
SHA-256 on entry:
EvidenceItem.sha256_at_init: strfield present and typed correctly as string (not bytes). Per CLAUDE.md §3.1: "Every evidence file gets a SHA-256 at case_init recorded in the EvidenceManifest." ✓ -
Blake3 manifest hash:
EvidenceManifest.compute_manifest_hash()computes blake3 over sorted (path, sha256) pairs serialized as JSON. Order-independent by design (sorted before hashing). Testtest_manifest_hash_order_independentverifies:manifest_a.compute_manifest_hash() == manifest_b.compute_manifest_hash()for reversed item lists. ✓ -
Path type enforcement:
EvidenceItem.path: Path(pathlib.Path, not string). §3.1 requirement for absolute path tracking. ✓ -
Hash function validated: Test
test_manifest_hash_is_blake3_of_sorted_pairsdirectly imports blake3, computes expected value via same algorithm, asserts equality. Tight coupling ensures hashing behavior is locked in. ✓ -
No evidence write paths: Schema read-only. ✓
§3.8 Dependency policy — BLOCKING: PASS
blake3 >= 0.3already in pyproject.toml with MIT license. No new forbidden dependencies. ✓
§3.10 No mocks — BLOCKING: PASS
- Zero Mock, MagicMock, patch, responses, vcr, betamax, or conditional TEST_MODE gates. ✓
§3.7 TDD + Conventional Commits — BLOCKING: PASS
- Commit subject matches required pattern
[W\d+\.[A-Z]\.\d+]. Task ID [W1.B.3] present. ✓
DESIGN NOTES
-
Three-tier ID hierarchy future-ready: EvidenceManifest will be referenced in LedgerEntry (ARCHITECTURE.md §5, line 321 audit comment: "Every 10 super-steps, re-hash all EvidenceItem files against the manifest."). Schema structure pre-positions correctly for ledger integration.
-
NIST SP 800-86 §5.1.4 compliance: Per-file SHA-256 recording aligns with examination-environment metadata (microsandbox_version, rootfs_sha256, tool_version, kernel_version) that LedgerEntry will carry per ARCHITECTURE.md §5.
-
Sorted pairs determinism: Critical for cross-engine consensus verification (W1.C Verifier strategies): two engines hashing the same evidence set must produce identical manifest_hash. Sorted-pair approach is canonical and portable.
Summary
✓ Evidence integrity (§3.1) fully implemented: SHA-256 + blake3 + Path type.
✓ No dependency violations (§3.8).
✓ No mocks or stubs (§3.10).
✓ Correct commit format + task ID (§3.7).
✓ All tests pass; canonical W1.B.3.a test present and assertions are tight.
Status: APPROVED for merge.
REVIEW + AUDIT — W1.B.3 EvidenceItem + EvidenceManifestREVIEW FINDINGS — All Checks PassRuff (lint + format): Both files pass.
Test coverage: 11 tests, all with clear GREEN path assertions:
Commit format: TDD audit: ✓ Tests present in diff; implementation provided. Single-task schema commit is acceptable structure. AUDIT FINDINGS§3.1 Evidence integrity — BLOCKING: PASS
§3.8 Dependency policy — BLOCKING: PASS
§3.10 No mocks — BLOCKING: PASS
§3.7 TDD + Conventional Commits — BLOCKING: PASS
DESIGN NOTES
Summary✓ Evidence integrity (§3.1) fully implemented: SHA-256 + blake3 + Path type. Status: APPROVED for merge. |
Summary
EvidenceItemandEvidenceManifestPydantic v2 schemas inverdict/schemas/evidence.pyper BUILD_PLAN Appendix A.3 and spec03-audit-v4.5.mdlines 153–168.EvidenceItem:path: Path,sha256_at_init,size_bytes,discovered_at,evidence_type(6-literal enum).EvidenceManifest:case_id,items: list[EvidenceItem],manifest_hash(blake3 of sorted(path, sha256)pairs),schema_version: int = 1.compute_manifest_hash()sorts by path string before hashing, making the manifest_hash order-independent.Test plan
tests/schemas/test_evidence.py— 11 tests covering:pathfield isPathtype (§3.1 requirement)EvidenceItemEvidenceTypeliterals accepted; unknown type rejected viaValidationErrorEvidenceItemJSON round-tripEvidenceIteminstancesschema_versiondefaults to 1test_manifest_hash_is_blake3_of_sorted_pairs(W1.B.3.a canonical test)test_manifest_hash_order_independent(insertion-order invariance)uv run pytest tests/schemas/ -v→ 12 passed (11 new + 1 from W1.B.1)uv run ruff check→ cleanTask
W1.B.3 —
EvidenceItem+EvidenceManifestschemas