Skip to content

feat(schema): EvidenceItem + EvidenceManifest with SHA-256 [W1.B.3]#6

Draft
TimothyVang wants to merge 1 commit into
feat/W1.B.1-artifactclass-enumfrom
feat/W1.B.3-evidenceitem-manifest
Draft

feat(schema): EvidenceItem + EvidenceManifest with SHA-256 [W1.B.3]#6
TimothyVang wants to merge 1 commit into
feat/W1.B.1-artifactclass-enumfrom
feat/W1.B.3-evidenceitem-manifest

Conversation

@TimothyVang

Copy link
Copy Markdown
Owner

Summary

  • Implements EvidenceItem and EvidenceManifest Pydantic v2 schemas in verdict/schemas/evidence.py per BUILD_PLAN Appendix A.3 and spec 03-audit-v4.5.md lines 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:
    • path field is Path type (§3.1 requirement)
    • SHA-256 field present on EvidenceItem
    • All 6 EvidenceType literals accepted; unknown type rejected via ValidationError
    • EvidenceItem JSON round-trip
    • Manifest is collection of EvidenceItem instances
    • schema_version defaults to 1
    • test_manifest_hash_is_blake3_of_sorted_pairs (W1.B.3.a canonical test)
    • test_manifest_hash_order_independent (insertion-order invariance)
    • Manifest JSON round-trip
  • uv run pytest tests/schemas/ -v → 12 passed (11 new + 1 from W1.B.1)
  • uv run ruff check → clean

Task

W1.B.3 — EvidenceItem + EvidenceManifest schemas

@TimothyVang TimothyVang left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 assertion
  • test_evidence_type_accepts_all_literals — validates all 6 enum values
  • test_evidence_type_rejects_unknown — validates enum constraint via ValidationError
  • test_evidence_item_round_trips_json — validates JSON serialization round-trip
  • test_manifest_is_collection_of_evidence_items — validates list[EvidenceItem]
  • test_manifest_has_case_id — validates case_id field
  • test_manifest_schema_version_default_1 — validates schema_version default per Appendix A.3
  • test_manifest_hash_is_blake3_of_sorted_pairsW1.B.3.a canonical test: assertion manifest.compute_manifest_hash() == expected_hash
  • test_manifest_hash_order_independent — validates insertion-order invariance
  • test_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

  1. SHA-256 on entry: EvidenceItem.sha256_at_init: str field 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." ✓

  2. Blake3 manifest hash: EvidenceManifest.compute_manifest_hash() computes blake3 over sorted (path, sha256) pairs serialized as JSON. Order-independent by design (sorted before hashing). Test test_manifest_hash_order_independent verifies: manifest_a.compute_manifest_hash() == manifest_b.compute_manifest_hash() for reversed item lists. ✓

  3. Path type enforcement: EvidenceItem.path: Path (pathlib.Path, not string). §3.1 requirement for absolute path tracking. ✓

  4. Hash function validated: Test test_manifest_hash_is_blake3_of_sorted_pairs directly imports blake3, computes expected value via same algorithm, asserts equality. Tight coupling ensures hashing behavior is locked in. ✓

  5. No evidence write paths: Schema read-only. ✓

§3.8 Dependency policy — BLOCKING: PASS

  • blake3 >= 0.3 already 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.

@TimothyVang

Copy link
Copy Markdown
Owner Author

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 assertion
  • test_evidence_type_accepts_all_literals — validates all 6 enum values
  • test_evidence_type_rejects_unknown — validates enum constraint via ValidationError
  • test_evidence_item_round_trips_json — validates JSON serialization round-trip
  • test_manifest_is_collection_of_evidence_items — validates list[EvidenceItem]
  • test_manifest_has_case_id — validates case_id field
  • test_manifest_schema_version_default_1 — validates schema_version default per Appendix A.3
  • test_manifest_hash_is_blake3_of_sorted_pairsW1.B.3.a canonical test: assertion manifest.compute_manifest_hash() == expected_hash
  • test_manifest_hash_order_independent — validates insertion-order invariance
  • test_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

  1. SHA-256 on entry: EvidenceItem.sha256_at_init: str field 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." ✓

  2. Blake3 manifest hash: EvidenceManifest.compute_manifest_hash() computes blake3 over sorted (path, sha256) pairs serialized as JSON. Order-independent by design (sorted before hashing). Test test_manifest_hash_order_independent verifies: manifest_a.compute_manifest_hash() == manifest_b.compute_manifest_hash() for reversed item lists. ✓

  3. Path type enforcement: EvidenceItem.path: Path (pathlib.Path, not string). §3.1 requirement for absolute path tracking. ✓

  4. Hash function validated: Test test_manifest_hash_is_blake3_of_sorted_pairs directly imports blake3, computes expected value via same algorithm, asserts equality. Tight coupling ensures hashing behavior is locked in. ✓

  5. No evidence write paths: Schema read-only. ✓

§3.8 Dependency policy — BLOCKING: PASS

  • blake3 >= 0.3 already 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.

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