Files
frame/tests/test_evidence.py
T
Lainandlain 9e24763ce2 docs(evidence): add M1 status-page photo (#7)
## What

Archives the M1 status-page photo into the evidence set at
`poc/evidence/m1-20260831/photos/status_page_20260831.jpg`
(full-resolution JPEG, 4032x3024,
no recompression) and registers it in the run manifest.

## What the photo shows

The live Frame status page on the Waveshare ESP32-S3-RLCD-4.2 after the
M1 soak: the UTC+8
time line, KEY/BOOT/RST counters, WiFi `CONNECTED 192.168.50.178`, and
TF `READY` / log OK.
The on-screen timestamp 16:28:52 UTC+8 correlates with the capture
filename epoch
2026-08-31T08:29:02.935Z.

## Hashes

- Archived JPEG sha256:
`03817e0424452eba786768960645aa9e369bdfef08fe1da9883a7b9b035e82ec`
  (verified byte-identical after copy)
- Original HEIC source `20260831_082902935_iOS.HEIC` sha256:
`62b86a8c0316fcd4ef5fbcc3ca59e308982627db5ef18d9b71bf9409cc446b9e` — the
HEIC itself
stays out of the repository; filename and hash are recorded in the
artifact note.

## Schema change (minimal additive)

`poc/evidence/schema.json` artifact items gain an optional `note` string
so provenance
(source file, screen-content summary, timestamp correlation) can travel
with the artifact
entry; `frame-evidence` needed no code change (generic jsonschema
validation) and one test
covers the new field.

## Remaining

Board and module photos remain TODO for M1-008; this PR only adds the
status-page photo.

Co-authored-by: ania-lain <[email protected]>
2026-08-31 16:47:37 +08:00

88 lines
2.5 KiB
Python

import json
from pathlib import Path
from typing import cast
from frame_tools.evidence import discover_manifests, validate_evidence
SCHEMA = Path("poc/evidence/schema.json")
def valid_manifest() -> dict[str, object]:
return {
"schema_version": 1,
"gate": "A",
"run_id": "test-run",
"verdict": "BLOCKED",
"started_at": "2026-08-30T00:00:00Z",
"finished_at": "2026-08-30T00:01:00Z",
"source": {
"repository_commit": "0" * 40,
"dirty": False,
"project_document_sha256": "0" * 64,
},
"platform": {
"idf_tag": "v6.0.2",
"compiler": "test compiler",
"target": "esp32s3",
"sdkconfig_sha256": "0" * 64,
},
"artifacts": [{"name": "log", "uri": "log.txt", "sha256": "0" * 64}],
}
def test_valid_manifest_passes(tmp_path: Path) -> None:
path = tmp_path / "manifest.json"
path.write_text(json.dumps(valid_manifest()), encoding="utf-8")
assert validate_evidence(SCHEMA, [path]) == []
def test_m1_gate_manifest_passes(tmp_path: Path) -> None:
manifest = valid_manifest()
manifest["gate"] = "M1"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
assert validate_evidence(SCHEMA, [path]) == []
def test_invalid_manifest_reports_json_path(tmp_path: Path) -> None:
manifest = valid_manifest()
manifest["gate"] = "F"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
errors = validate_evidence(SCHEMA, [path])
assert errors
assert "['gate']" in errors[0]
def test_invalid_date_time_is_rejected(tmp_path: Path) -> None:
manifest = valid_manifest()
manifest["started_at"] = "not-a-date"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
errors = validate_evidence(SCHEMA, [path])
assert errors
assert "['started_at']" in errors[0]
def test_artifact_note_passes(tmp_path: Path) -> None:
manifest = valid_manifest()
artifacts = cast(list[dict[str, object]], manifest["artifacts"])
artifacts[0]["note"] = "photo artifact with provenance note"
path = tmp_path / "manifest.json"
path.write_text(json.dumps(manifest), encoding="utf-8")
assert validate_evidence(SCHEMA, [path]) == []
def test_schema_is_not_discovered_as_a_manifest() -> None:
manifests, errors = discover_manifests([SCHEMA.parent], SCHEMA)
assert errors == []
assert SCHEMA not in manifests