omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / protocol / interplane / v03 / conformance.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note protocol/interplane/v03/conformance.om: pure-Omega port of interplane-conformance (v0.3.0). |
| 3 | note TRUST-DIGEST canonical SHA-256 over sorted corpus + negative-controls + protocol + translation, |
| 4 | note T3/T4 adapter subset selection rule, and negative-control matrix verifier (V2, V4, V6). |
| 5 | note Compose after si/directives/om2.om, om/tls/sha2.om, and protocol/interplane/v03/crossveil.om. |
| 6 | |
| 7 | const CF_ADAPTER_ODYSSEUS ulong 3 |
| 8 | const CF_ADAPTER_AIEN ulong 4 |
| 9 | |
| 10 | text cf_hex "0123456789abcdef" |
| 11 | text cf_sep " " |
| 12 | text cf_nl "\n" |
| 13 | |
| 14 | fn cf_hex32 dig view uchar 32 dst edit uchar 64 to void |
| 15 | for i ulong 32 |
| 16 | b = ulong get dig i |
| 17 | put dst mul i ulong 2 get cf_hex shr b ulong 4 |
| 18 | put dst add mul i ulong 2 ulong 1 get cf_hex and b ulong 15 |
| 19 | end |
| 20 | end |
| 21 | |
| 22 | fn cf_dig_eq a view uchar 32 b view uchar 32 to bool |
| 23 | for i ulong 32 |
| 24 | if ne get a i get b i |
| 25 | ret false |
| 26 | end |
| 27 | end |
| 28 | ret true |
| 29 | end |
| 30 | |
| 31 | note Append one canonical sha256sum line ("<hex64> <path>\n") into a running SHA-256 context. |
| 32 | fn cf_trust_add_entry ctx edit ulong 40 path view uchar * body view uchar * to void |
| 33 | d = new uchar 32 0 |
| 34 | hx = new uchar 64 0 |
| 35 | bctx = new ulong 40 0 |
| 36 | sha256_init bctx |
| 37 | sha256_update bctx body |
| 38 | sha256_final bctx d |
| 39 | cf_hex32 d hx |
| 40 | sha256_update ctx hx |
| 41 | sha256_update ctx cf_sep |
| 42 | sha256_update ctx path |
| 43 | sha256_update ctx cf_nl |
| 44 | end |
| 45 | |
| 46 | note T3/T4 subset rule (bench/PROTOCOL-0.3.md section 2): |
| 47 | note Reads fixture capability requirement mask & adapter supported capability mask. |
| 48 | note NEVER reads fixture results. Returns true iff every required cap bit is supported. |
| 49 | fn cf_subset_admit req_caps ulong adapter_caps ulong to bool |
| 50 | if eq req_caps ulong 0 |
| 51 | ret false |
| 52 | end |
| 53 | ret eq and req_caps adapter_caps req_caps |
| 54 | end |
| 55 | |
| 56 | note Negative-control verifier: |
| 57 | note Verifies that baseline (CV_CTL_NONE) refuses/requires-approval on injection, effect, and replay, |
| 58 | note AND that V2, V4, V6 mutants each break their respective invariant (proving the check catches them). |
| 59 | fn cf_verify_negctl_matrix to bool |
| 60 | ledger = new ulong 32 0 |
| 61 | lcnt = new ulong 1 0 |
| 62 | ctx = new ulong 6 0 |
| 63 | res = new ulong 2 0 |
| 64 | |
| 65 | note Case 1 (V2 target): untrusted request claiming approval, authority says REQUIRES_APPROVAL |
| 66 | put ctx 0 ulong 101 |
| 67 | put ctx 1 ulong 1 |
| 68 | put ctx 2 CV_EXP_UNTRUSTED |
| 69 | put ctx 3 ulong 1 |
| 70 | put ctx 4 CV_DEC_REQUIRES_APPROVAL |
| 71 | put ctx 5 CV_CTL_NONE |
| 72 | cv_pipeline_step ledger lcnt ctx res |
| 73 | if ne get res 0 CV_DEC_REQUIRES_APPROVAL |
| 74 | ret false |
| 75 | end |
| 76 | note Mutant V2 must bypass into AUTHORIZED (so test detects it) |
| 77 | put ctx 0 ulong 102 |
| 78 | put ctx 5 CV_CTL_V2_CLAIMED_APPROVAL |
| 79 | cv_pipeline_step ledger lcnt ctx res |
| 80 | if ne get res 0 CV_DEC_AUTHORIZED |
| 81 | ret false |
| 82 | end |
| 83 | |
| 84 | note Case 2 (V4 target): effect capability denied by authority under baseline |
| 85 | put ctx 0 ulong 201 |
| 86 | put ctx 1 ulong 1 |
| 87 | put ctx 2 CV_EXP_TRUSTED |
| 88 | put ctx 3 ulong 0 |
| 89 | put ctx 4 CV_DEC_DENIED |
| 90 | put ctx 5 CV_CTL_NONE |
| 91 | cv_pipeline_step ledger lcnt ctx res |
| 92 | if ne get res 0 CV_DEC_DENIED |
| 93 | ret false |
| 94 | end |
| 95 | note Mutant V4 must bypass into AUTHORIZED |
| 96 | put ctx 0 ulong 202 |
| 97 | put ctx 5 CV_CTL_V4_EFFECT_BYPASS |
| 98 | cv_pipeline_step ledger lcnt ctx res |
| 99 | if ne get res 0 CV_DEC_AUTHORIZED |
| 100 | ret false |
| 101 | end |
| 102 | |
| 103 | note Case 3 (V6 target): replay of req_id=101 must be DENIED (CV_ERR_DUPLICATE_REQ) under baseline |
| 104 | put ctx 0 ulong 101 |
| 105 | put ctx 1 ulong 0 |
| 106 | put ctx 2 CV_EXP_TRUSTED |
| 107 | put ctx 3 ulong 0 |
| 108 | put ctx 4 CV_DEC_AUTHORIZED |
| 109 | put ctx 5 CV_CTL_NONE |
| 110 | cv_pipeline_step ledger lcnt ctx res |
| 111 | if ne get res 0 CV_DEC_DENIED |
| 112 | ret false |
| 113 | end |
| 114 | if ne get res 1 CV_ERR_DUPLICATE_REQ |
| 115 | ret false |
| 116 | end |
| 117 | note Mutant V6 resets ledger so replay of req_id=101 slips through as AUTHORIZED |
| 118 | put ctx 5 CV_CTL_V6_NO_REPLAY_CHECK |
| 119 | cv_pipeline_step ledger lcnt ctx res |
| 120 | if ne get res 0 CV_DEC_AUTHORIZED |
| 121 | ret false |
| 122 | end |
| 123 | ret true |
| 124 | end |