Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/authority/reuse-gate.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / authority / reuse-gate.om` 228 lines ยท 3923 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note KV reuse admission v1. This module hashes nothing and deserializes no payload. 3 note The store must hash the exact payload with its existing SHA-256 owner before calling. 4 note Header words 0..7: format,semantic-profile,prefix-tokens,context-size,layout,dtype,rope-profile,reserved. 5 note Seven four-word identities: model,weights,engine,tokenizer,scope,prefix-tokens,numeric-target-config. 6 note Saved words 36..39 are payload SHA-256. Expected words 36..39 must be zero. 7 8 fn kvvalid p view ulong 40 to ulong 9 if ne get p 0 1 10 ret 100 11 end 12 if ne get p 7 0 13 ret 102 14 end 15 for i ulong 6 16 if eq get p add i 1 0 17 ret 103 18 end 19 end 20 if gt get p 2 get p 3 21 ret 103 22 end 23 if gt get p 5 4 24 ret 103 25 end 26 for g ulong 7 27 bits = ulong 0 28 for j ulong 4 29 bits = or bits get p add 8 add mul g 4 j 30 end 31 if eq bits 0 32 ret 104 33 end 34 end 35 ret 0 36 end 37 38 fn kvmatch s view ulong 40 w view ulong 40 h view ulong 4 to ulong 39 err = kvvalid s 40 if ne err 0 41 ret err 42 end 43 err = kvvalid w 44 if ne err 0 45 ret err 46 end 47 bits = ulong 0 48 for i ulong 4 49 if ne get w add i 36 0 50 ret 128 51 end 52 bits = or bits get s add i 36 53 end 54 if eq bits 0 55 ret 104 56 end 57 for i ulong 6 58 if ne get s add i 1 get w add i 1 59 ret add 111 i 60 end 61 end 62 for g ulong 7 63 diff = ulong 0 64 for j ulong 4 65 at = add 8 add mul g 4 j 66 diff = or diff xor get s at get w at 67 end 68 if ne diff 0 69 ret add 120 g 70 end 71 end 72 diff = ulong 0 73 for i ulong 4 74 diff = or diff xor get s add i 36 get h i 75 end 76 if ne diff 0 77 ret 127 78 end 79 ret 0 80 end 81 note SPDX-License-Identifier: AGPL-3.0-only 82 global checks ulong 1 83 global fails ulong 1 84 global report uchar 64 85 text title "reuse checks=" 86 fn check got ulong want ulong to void 87 put checks 0 add get checks 0 1 88 if ne got want 89 put fails 0 add get fails 0 1 90 end 91 end 92 fn profile p edit ulong 40 to void 93 for i ulong 40 94 put p i 0 95 end 96 put p 0 1 97 put p 1 1 98 put p 2 32 99 put p 3 4096 100 put p 4 1 101 put p 5 2 102 put p 6 1 103 for i ulong 28 104 put p add i 8 add i 100 105 end 106 end 107 fn saved s edit ulong 40 to void 108 profile s 109 for i ulong 4 110 put s add i 36 add i 200 111 end 112 end 113 fn payload h edit ulong 4 to void 114 for i ulong 4 115 put h i add i 200 116 end 117 end 118 fn summary to int 119 for i ulong len title 120 put report i get title i 121 end 122 n = get checks 0 123 at = len title 124 put report at uchar add 48 div n 100 125 put report add at 1 uchar add 48 rem div n 10 10 126 put report add at 2 uchar add 48 rem n 10 127 put report add at 3 32 128 put report add at 4 uchar add 48 div get fails 0 100 129 put report add at 5 uchar add 48 rem div get fails 0 10 10 130 put report add at 6 uchar add 48 rem get fails 0 10 131 put report add at 7 10 132 w = write 1 report 0 add at 8 133 if ne w long add at 8 134 ret 2 135 end 136 if ne get fails 0 0 137 ret 1 138 end 139 ret 0 140 end 141 fn main to int 142 s = new ulong 40 0 143 w = new ulong 40 0 144 h = new ulong 4 0 145 saved s 146 profile w 147 payload h 148 check kvmatch s w h 0 149 for i ulong 6 150 saved s 151 put s add i 1 add get s add i 1 1 152 check kvmatch s w h add 111 i 153 end 154 for i ulong 28 155 saved s 156 put s add i 8 add get s add i 8 1 157 check kvmatch s w h add 120 div i 4 158 end 159 for i ulong 4 160 saved s 161 payload h 162 put h i add get h i 1 163 check kvmatch s w h 127 164 end 165 payload h 166 for g ulong 7 167 saved s 168 profile w 169 for j ulong 4 170 put s add 8 add mul g 4 j 0 171 end 172 check kvmatch s w h 104 173 saved s 174 for j ulong 4 175 put w add 8 add mul g 4 j 0 176 end 177 check kvmatch s w h 104 178 end 179 profile w 180 saved s 181 put s 0 2 182 check kvmatch s w h 100 183 saved s 184 put w 0 2 185 check kvmatch s w h 100 186 profile w 187 put s 7 1 188 check kvmatch s w h 102 189 saved s 190 put w 7 1 191 check kvmatch s w h 102 192 profile w 193 for i ulong 6 194 saved s 195 put s add i 1 0 196 check kvmatch s w h 103 197 end 198 saved s 199 put s 2 4097 200 check kvmatch s w h 103 201 saved s 202 put s 5 5 203 check kvmatch s w h 103 204 saved s 205 for i ulong 4 206 put s add i 36 0 207 end 208 check kvmatch s w h 104 209 saved s 210 for i ulong 4 211 profile w 212 put w add i 36 1 213 check kvmatch s w h 128 214 end 215 profile w 216 saved s 217 check kvmatch s w h 0 218 note Whole-token prefix identity is required even if lengths match. 219 put w 28 999 220 check kvmatch s w h 125 221 profile w 222 put w 24 999 223 check kvmatch s w h 124 224 profile w 225 put w 16 999 226 check kvmatch s w h 122 227 ret summary 228 end