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 / core / sovereign-core / om / qwen-native / model / attest.om
| 1 | note Build-time seeded Omega attestor. Emits host bindings only after hashing each opened file and comparing stats on the same descriptor. |
| 2 | global qa_path uchar 4300 |
| 3 | global qa_root uchar 4096 |
| 4 | global qa_input uchar 65536 |
| 5 | global qa_stat uchar 128 |
| 6 | global qa_before ulong 7 |
| 7 | global qa_info ulong 3 |
| 8 | text qa_declare "global qdiskpin ulong 910" |
| 9 | text qa_f27 "fn qdisk27 to void" |
| 10 | text qa_f35 "fn qdisk35 to void" |
| 11 | text qa_end "end" |
| 12 | text qa_put "put qdiskpin " |
| 13 | text qa_layer "/layers-" |
| 14 | text qa_suffix ".safetensors" |
| 15 | text qa_out "/outside.safetensors" |
| 16 | fn qa_print s view uchar * to void |
| 17 | for i ulong len s |
| 18 | tkpc ulong get s i |
| 19 | end |
| 20 | end |
| 21 | fn qa_word off ulong to ulong |
| 22 | v = ulong 0 |
| 23 | for i ulong 8 |
| 24 | v = or v shl ulong get qa_stat add i off mul i 8 |
| 25 | end |
| 26 | ret v |
| 27 | end |
| 28 | fn qa_value j ulong to ulong |
| 29 | if eq j 0 |
| 30 | ret qa_word 0 |
| 31 | end |
| 32 | if eq j 1 |
| 33 | ret qa_word 8 |
| 34 | end |
| 35 | if eq j 2 |
| 36 | ret qa_word 48 |
| 37 | end |
| 38 | ret qa_word add 88 mul sub j 3 8 |
| 39 | end |
| 40 | fn qa_cat p ulong s view uchar * to ulong |
| 41 | for i ulong len s |
| 42 | put qa_path add p i get s i |
| 43 | end |
| 44 | ret add p len s |
| 45 | end |
| 46 | fn qa_name j ulong to ulong |
| 47 | n = get qa_info 0 |
| 48 | for i ulong n |
| 49 | put qa_path i get qa_root i |
| 50 | end |
| 51 | if eq j 64 |
| 52 | ret qa_cat n qa_out |
| 53 | end |
| 54 | p = qa_cat n qa_layer |
| 55 | if ge j 10 |
| 56 | put qa_path p uchar add 48 div j 10 |
| 57 | p = add p 1 |
| 58 | end |
| 59 | put qa_path p uchar add 48 rem j 10 |
| 60 | ret qa_cat add p 1 qa_suffix |
| 61 | end |
| 62 | fn qa_hash fd int to void |
| 63 | hreset |
| 64 | while true bound 1048577 |
| 65 | r = read fd qa_input 0 len qa_input |
| 66 | if lt r 0 |
| 67 | exit 3 |
| 68 | end |
| 69 | if eq r 0 |
| 70 | break |
| 71 | end |
| 72 | for i ulong ulong r |
| 73 | if not hpush get qa_input i |
| 74 | exit 3 |
| 75 | end |
| 76 | end |
| 77 | end |
| 78 | if not hfinal |
| 79 | exit 3 |
| 80 | end |
| 81 | end |
| 82 | fn qa_shard j ulong to void |
| 83 | n = qa_name j |
| 84 | fd = fopen qa_path 0 n 557056 0 |
| 85 | if lt fd 0 |
| 86 | exit 2 |
| 87 | end |
| 88 | if ne fstat int fd qa_stat 0 128 0 |
| 89 | exit 3 |
| 90 | end |
| 91 | for i ulong 7 |
| 92 | put qa_before i qa_value i |
| 93 | end |
| 94 | qa_hash int fd |
| 95 | index = j |
| 96 | if eq j 64 |
| 97 | index = get qa_info 1 |
| 98 | end |
| 99 | for c ulong 64 |
| 100 | if ne get hd c qa_expected get qa_info 1 index c |
| 101 | exit 4 |
| 102 | end |
| 103 | end |
| 104 | if ne fstat int fd qa_stat 0 128 0 |
| 105 | exit 3 |
| 106 | end |
| 107 | for i ulong 7 |
| 108 | if ne get qa_before i qa_value i |
| 109 | exit 5 |
| 110 | end |
| 111 | qa_print qa_put |
| 112 | tcpu add add get qa_info 2 mul j 7 i |
| 113 | tkpc 32 |
| 114 | tcpu get qa_before i |
| 115 | tkpc 10 |
| 116 | end |
| 117 | r = fclose int fd |
| 118 | if ne r 0 |
| 119 | exit 3 |
| 120 | end |
| 121 | end |
| 122 | fn qa_model arg ulong layers ulong base ulong to void |
| 123 | n = argread arg qa_root 0 4095 |
| 124 | if le n 0 |
| 125 | exit 2 |
| 126 | end |
| 127 | put qa_info 0 ulong n |
| 128 | put qa_info 1 layers |
| 129 | put qa_info 2 base |
| 130 | if eq arg 1 |
| 131 | qa_print qa_f27 |
| 132 | else |
| 133 | qa_print qa_f35 |
| 134 | end |
| 135 | tkpc 10 |
| 136 | for j ulong layers |
| 137 | qa_shard j |
| 138 | end |
| 139 | qa_shard 64 |
| 140 | qa_print qa_end |
| 141 | tkpc 10 |
| 142 | end |
| 143 | fn main to int |
| 144 | if ne argcnt 3 |
| 145 | ret 2 |
| 146 | end |
| 147 | qa_print qa_declare |
| 148 | tkpc 10 |
| 149 | qa_model 1 64 0 |
| 150 | qa_model 2 40 455 |
| 151 | tkpfl |
| 152 | ret 0 |
| 153 | end |