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/protocol/synapse/claims/src/10_base.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 / protocol / synapse / claims / src / 10_base.om` 395 lines ยท 7119 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note synapse-claims (aien-dev/synapse-claims): append-only, hash-chained, signed lease ledger for AI lanes. 3 note Unit = om2 line + om/tls/sha2.om + src/*.om (build.sh). This file: capacities, global state, buffered 4 note output, the string arena, word tables, decimal and hex helpers, die. 5 6 const lncap ulong 65536 7 const ncl ulong 131072 8 const nf ulong 24 9 const arcap ulong `33554432` 10 const arbank ulong `16777216` 11 const pecap ulong `8388608` 12 const outcap ulong 524288 13 const errcap ulong 8192 14 const socap ulong `1048576` 15 const sicap ulong `1048576` 16 const htmask ulong 262143 17 const evcap ulong 65536 18 const tbad ulong `18446744073709551615` 19 20 note gx cells (scalar state) 21 const xoutn ulong 0 22 const xerrn ulong 1 23 const xsel ulong 2 24 const xarn ulong 3 25 const xnc ulong 4 26 const xseq ulong 5 27 const xnow ulong 6 28 const xpkn ulong 7 29 const xson ulong 8 30 const xsin ulong 9 31 const xmfd ulong 10 32 const xpen ulong 11 33 const xpec ulong 12 34 const xlfd ulong 13 35 const xlkfd ulong 14 36 const xlp ulong 15 37 const xrfd ulong 16 38 const xrpos ulong 17 39 const xrlen ulong 18 40 const xreof ulong 19 41 const xhome ulong 20 42 const xhomel ulong 21 43 const xpled ulong 22 44 const xpledl ulong 23 45 const xplk ulong 24 46 const xplkl ulong 25 47 const xpkey ulong 26 48 const xpkeyl ulong 27 49 const xppub ulong 28 50 const xppubl ulong 29 51 const xpkd ulong 30 52 const xpkdl ulong 31 53 const xsig ulong 32 54 const xsigl ulong 33 55 const xevn ulong 34 56 const xbad ulong 35 57 const xwhy ulong 36 58 const xcmd ulong 37 59 const xall ulong 38 60 const xnowset ulong 39 61 const xidv ulong 40 62 const xttl ulong 41 63 const xmode ulong 42 64 const xstate ulong 43 65 const xpos ulong 44 66 const xkind ulong 45 67 68 global gout uchar 524288 69 global gerr uchar 8192 70 note gar0/gar1: the arcap-byte string arena as two banks; one global holds at most `16777216` elements 71 global gar0 uchar `16777216` 72 global gar1 uchar `16777216` 73 global gcl ulong `3145728` 74 global ght ulong 262144 75 global ghk ulong 262144 76 global gpend uchar `8388608` 77 global gpe ulong 8192 78 global gso uchar `1048576` 79 global gsi uchar `1048576` 80 global grd uchar 65536 81 global gpk uchar 4096 82 global glh uchar 64 83 global gtb uchar 32 84 global gst uchar 64 85 global gevb uchar 16384 86 global gx ulong 64 87 global gp ulong 64 88 global gop ulong 64 89 global gev ulong 32 90 global gfd uchar 8 91 global gws uchar 4 92 93 note word tables: index = position of the space-separated word 94 note wall: ops 0..4 (code-1), states 5..12 (code+4), kinds 13..17 (code+12), modes 18 excl 19 shared 95 text wall "claim renew release state expire PROPOSED IMPLEMENTED EXERCISED QUALIFIED MERGED DEPLOYED NOT_RUN BLOCKED repo branch path pr ext excl shared" 96 text wreason "same_target repo_covers path_overlap ext_casefold" 97 text wcmds "init claim renew release state who list conflicts verify expire" 98 text wflags "--home --now --sig-bin --agent --session --target --ttl --mode --state --intent --evidence --import --id --all --agent-prefix" 99 text wwhy "malformed seq prev hash id signature" 100 101 text tpref "synapse-claims: " 102 text tjerr "{\"ok\":false,\"error\":\"" 103 text tjend "\"}\n" 104 text ttrue "true" 105 text tfalse "false" 106 text mfull "arena full" 107 108 note ======== word tables ======== 109 110 fn tw_off t view uchar * w ulong to ulong 111 k = ulong 0 112 p = ulong 0 113 while lt p len t bound 999999 114 if eq k w 115 ret p 116 end 117 if eq get t p 32 118 k = add k 1 119 end 120 p = add p 1 121 end 122 ret p 123 end 124 125 fn tw_len t view uchar * w ulong to ulong 126 s = tw_off t w 127 e = s 128 while lt e len t bound 999999 129 if eq get t e 32 130 ret sub e s 131 end 132 e = add e 1 133 end 134 ret sub e s 135 end 136 137 note tw_eqat: s equals t[p .. p+len s) 138 fn tw_eqat s edit uchar * t view uchar * p ulong to bool 139 for i ulong len s 140 if ne get s i get t add p i 141 ret false 142 end 143 end 144 ret true 145 end 146 147 note tw_find: index of the word in t[base .. base+cnt) equal to s (whole slice), or tbad 148 fn tw_find s edit uchar * t view uchar * base ulong cnt ulong to ulong 149 for k ulong cnt 150 w = add base k 151 if eq tw_len t w len s 152 if tw_eqat s t tw_off t w 153 ret w 154 end 155 end 156 end 157 ret tbad 158 end 159 160 note ======== buffered output: xsel 0 stdout (gout), 1 stderr (gerr) ======== 161 162 fn o_flush to void 163 n = get gx xoutn 164 p = ulong 0 165 while lt p n bound 999999 166 w = write 1 gout p sub n p 167 if le w 0 168 exit 70 169 end 170 p = add p ulong w 171 end 172 put gx xoutn 0 173 end 174 175 fn e_flush to void 176 n = get gx xerrn 177 p = ulong 0 178 while lt p n bound 999999 179 w = write 2 gerr p sub n p 180 if le w 0 181 break 182 end 183 p = add p ulong w 184 end 185 put gx xerrn 0 186 end 187 188 fn o_b c uchar to void 189 if eq get gx xsel 1 190 m = get gx xerrn 191 if lt m errcap 192 put gerr m c 193 put gx xerrn add m 1 194 end 195 ret 196 end 197 if ge get gx xoutn outcap 198 o_flush 199 end 200 n = get gx xoutn 201 put gout n c 202 put gx xoutn add n 1 203 end 204 205 fn o_t t view uchar * to void 206 for i ulong len t 207 o_b get t i 208 end 209 end 210 211 fn o_wd t view uchar * w ulong to void 212 p = tw_off t w 213 for i ulong tw_len t w 214 o_b get t add p i 215 end 216 end 217 218 fn o_ar off ulong n ulong to void 219 for i ulong n 220 o_b ar_g add off i 221 end 222 end 223 224 fn o_u v ulong to void 225 x = v 226 k = ulong 0 227 for i ulong 20 228 put gst i uchar add 48 rem x 10 229 x = div x 10 230 k = add k 1 231 if eq x 0 232 break 233 end 234 end 235 for j ulong k 236 o_b get gst sub sub k j 1 237 end 238 end 239 240 note o_key: writes ,"KEY": (first true: {"KEY":) 241 fn o_key t view uchar * first bool to void 242 if first 243 o_b 123 244 else 245 o_b 44 246 end 247 o_b 34 248 o_t t 249 o_b 34 250 o_b 58 251 end 252 253 fn o_q to void 254 o_b 34 255 end 256 257 note die: {"ok":false,"error":"T"} on stdout, `synapse-claims: T` on stderr, exit code 258 fn die code int t view uchar * to void 259 o_t tjerr 260 o_t t 261 o_t tjend 262 o_flush 263 put gx xsel 1 264 o_t tpref 265 o_t t 266 o_b 10 267 e_flush 268 exit code 269 end 270 271 note ======== arena ======== 272 273 fn ar_b c uchar to void 274 n = get gx xarn 275 if ge n arcap 276 die 70 mfull 277 end 278 if lt n arbank 279 put gar0 n c 280 else 281 put gar1 sub n arbank c 282 end 283 put gx xarn add n 1 284 end 285 286 fn ar_g n ulong to uchar 287 if lt n arbank 288 ret get gar0 n 289 end 290 ret get gar1 sub n arbank 291 end 292 293 note ar_tv/ar_lnv/ar_cpv append to the arena; ar_t/ar_ln/ar_cp also return the start offset 294 fn ar_tv t view uchar * to void 295 for i ulong len t 296 ar_b get t i 297 end 298 end 299 300 fn ar_t t view uchar * to ulong 301 s = get gx xarn 302 ar_tv t 303 ret s 304 end 305 306 fn ar_lnv s edit uchar * off ulong n ulong to void 307 for i ulong n 308 ar_b get s add off i 309 end 310 end 311 312 fn ar_ln s edit uchar * off ulong n ulong to ulong 313 st = get gx xarn 314 ar_lnv s off n 315 ret st 316 end 317 318 fn ar_cpv off ulong n ulong to void 319 for i ulong n 320 ar_b ar_g add off i 321 end 322 end 323 324 fn ar_cp off ulong n ulong to ulong 325 st = get gx xarn 326 ar_cpv off n 327 ret st 328 end 329 330 fn ar_eq a ulong an ulong b ulong bn ulong to bool 331 if ne an bn 332 ret false 333 end 334 for i ulong an 335 if ne ar_g add a i ar_g add b i 336 ret false 337 end 338 end 339 ret true 340 end 341 342 fn lower c uchar to uchar 343 if and ge c 65 le c 90 344 ret add c 32 345 end 346 ret c 347 end 348 349 fn ar_eqci a ulong an ulong b ulong bn ulong to bool 350 if ne an bn 351 ret false 352 end 353 for i ulong an 354 if ne lower ar_g add a i lower ar_g add b i 355 ret false 356 end 357 end 358 ret true 359 end 360 361 fn hexd v ulong to uchar 362 if lt v 10 363 ret uchar add v 48 364 end 365 ret uchar add v 87 366 end 367 368 fn hexv c uchar to ulong 369 if and ge c 48 le c 57 370 ret ulong sub c 48 371 end 372 if and ge c 97 le c 102 373 ret ulong sub c 87 374 end 375 ret 16 376 end 377 378 note sf_ok: 1..256 bytes, each 0x21..0x7e except quote and backslash (identifiers, targets, URLs) 379 fn sf_ok s edit uchar * to bool 380 n = len s 381 if or eq n 0 gt n 256 382 ret false 383 end 384 for i ulong n 385 c = get s i 386 if or lt c 33 gt c 126 387 ret false 388 end 389 if or eq c 34 eq c 92 390 ret false 391 end 392 end 393 ret true 394 end 395