|
| 1 | +# DigiEmu Core 2.0 Conformance |
| 2 | + |
| 3 | +Status: draft / hardening phase |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Conformance Definition |
| 8 | + |
| 9 | +An implementation is DigiEmu Core 2.0 conformant if, given the same canonical snapshot and verification inputs, it produces the same verification result as the reference implementation and passes the required test vectors. |
| 10 | + |
| 11 | +- Determinism: same input -> same canonical JSON -> same SHA-256 snapshot hash -> same verify result. |
| 12 | +- Independence: a third-party verifier can reproduce PASS/FAIL/ERROR with the same reason codes. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Canonical JSON Requirement |
| 17 | + |
| 18 | +- Implement `canonical_json_v1` semantics. |
| 19 | +- Non-canonical serialization must be detected as a conformance failure when it changes the state identity. |
| 20 | +- Canonicalization scope excludes self-referential hash fields (e.g., `expected_hash_v1`). |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## Snapshot Hash Requirement |
| 25 | + |
| 26 | +- Hash algorithm: `sha256(canonical_json_v1)`. |
| 27 | +- The same canonicalized snapshot MUST produce the exact same 64-hex digest. |
| 28 | +- Hash scope: explicitly excludes `expected_hash_v1` and includes all integrity-relevant fields. |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Replay Requirement |
| 33 | + |
| 34 | +- Given a bundle, the verifier MUST reconstruct the decision state deterministically using the documented reconstruction profile. |
| 35 | +- Any mismatch between reconstructed state and expected state MUST surface as a verification failure with a stable reason code. |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Verify Result Requirement |
| 40 | + |
| 41 | +- The implementation MUST emit verify results that validate against `schemas/VERIFY_RESULT_SCHEMA_v1.json` (v1) or `schemas/verify_result_v2.schema.json` (v2 draft) when in the respective mode. |
| 42 | +- PASS/FAIL/ERROR MUST be deterministically determined from canonicalization, hashing, and replay outcomes. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## PASS / FAIL / ERROR Semantics |
| 47 | + |
| 48 | +- PASS: canonicalization and hashing succeed; computed digest equals expected; reconstruction matches profile; no schema violations. |
| 49 | +- FAIL: verification completes but evidence indicates mismatch (e.g., hash mismatch, rule mismatch), with a stable reason code. |
| 50 | +- ERROR: verification cannot complete due to malformed inputs, schema violations, or internal errors; includes a stable reason code. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Required Test Vectors |
| 55 | + |
| 56 | +Implementations MUST pass all vectors under `testdata/core_2_conformance/`, including at minimum: |
| 57 | +- `basic_pass` |
| 58 | +- `hash_mismatch_fail` |
| 59 | +- `inside_payload_mutation_detected` |
| 60 | +- `invalid_schema_error` |
| 61 | +- `malformed_json_error` |
| 62 | +- `missing_required_field_error` |
| 63 | +- `outside_metadata_ignored` |
| 64 | +- `unknown_reason_code_error` |
| 65 | +- `unsupported_canonicalization_profile_error` |
| 66 | +- `unsupported_hash_algorithm_error` |
| 67 | +- `wrong_profile_fail` |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## CLI Behavior |
| 72 | + |
| 73 | +- The CLI MUST support `--json` output with `pretty` and `canonical` modes. |
| 74 | +- In JSON mode, stdout is JSON-only; operational errors go to stderr. |
| 75 | +- Exit codes follow the Phase A2 contract; VERIFY failures yield a non-zero exit code. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## JSON Report Output |
| 80 | + |
| 81 | +- JSON verify results MUST validate against `schemas/VERIFY_RESULT_SCHEMA_v1.json` or `schemas/verify_result_v2.schema.json` (draft) when applicable. |
| 82 | +- The `--json=canonical` mode MUST produce byte-stable canonical JSON suitable for test vectors and audit evidence. |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Version Compatibility |
| 87 | + |
| 88 | +- Implementations MUST clearly declare the supported snapshot, canonicalization, and schema versions. |
| 89 | +- Conformance is version-bound. A change in schema or canonicalization profile requires re-validation against test vectors. |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## Non-Goals |
| 94 | + |
| 95 | +- no agent identity certification |
| 96 | +- no trust scoring |
| 97 | +- no enterprise workflow |
| 98 | +- no legal compliance claim |
| 99 | +- no authorization framework |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## CLI Examples |
| 104 | + |
| 105 | +Example: verify a bundle with canonical JSON output to stdout: |
| 106 | + |
| 107 | +```bash |
| 108 | +go run ./cmd/digiemu verify --bundle examples/bundles/demo_ok_bundle_v1/snapshots/snapshot_demo_v1 --json=canonical |
| 109 | +``` |
| 110 | + |
| 111 | +Example: run conformance and emit a canonical JSON report: |
| 112 | + |
| 113 | +```bash |
| 114 | +go run ./cmd/digiemu experimental conformance run testdata/core_2_conformance --json=canonical |
| 115 | +``` |
| 116 | + |
| 117 | +The resulting JSON MUST validate against `schemas/VERIFY_RESULT_SCHEMA_v1.json` or the v2 draft schema where explicitly used. |
0 commit comments