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/trace/tracegen.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 / trace / tracegen.om` 142 lines ยท 3225 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 note seed/trace/tracegen.om: deterministic fixtures for the trace CLI gate (omega-mv #610). Run in an empty 3 note scratch directory; it makes fx/ (it must not exist) and writes only through segment.om, plus the 4 note fault injection below. Build: cat seed/trace/segment.om seed/trace/tsha.om seed/trace/tracegen.om | seed/out/omc. 5 note Record i of the generator has type 1 + i mod 3, length (5 i) mod 53, payload byte j = (7 i + 3 j) mod 256. 6 note fx/a.seg 40 records, clean 7 note fx/b.seg 40 records, record 17 payload byte 0 xor 1 (compare a b: differ at=17) 8 note fx/c.seg 42 records, a plus records 40 and 41 (compare a c: prefix) 9 note fx/crc.seg a with byte 16 + 64*5 + 8 = 344 (record 5 payload byte 0) xor 1: crc-mismatch at 5 10 note fx/torn.seg a truncated to 16 + 64*39 + 30 = 2542 bytes: 39 records and a torn tail of 30 bytes 11 note fx/magic.seg 3 records, header byte 0 xor 1 ("@ITR"): refused, code 11 12 note fx/link.seg symbolic link to a.seg: refused, ELOOP 13 note fx/sub/ empty directory (list reports it as a directory) 14 note Regular fixtures are left mode 0400, so any open for writing by the CLI fails (EACCES). 15 note Exit status 0, or the number of the step that failed. 16 text paths "fx\nfx/a.seg\nfx/b.seg\nfx/c.seg\nfx/crc.seg\nfx/torn.seg\nfx/magic.seg\nfx/link.seg\nfx/sub\n" 17 text ltgt "a.seg" 18 fn setp k ulong to void 19 line = ulong 1 20 n = ulong 0 21 for i ulong len paths 22 b = get paths i 23 if eq b 10 24 line = add line 1 25 else 26 if eq line k 27 put tpath n b 28 n = add n 1 29 end 30 end 31 end 32 put tlen 0 n 33 end 34 note mkseg k n flip: segment k with records 0..n-1; when flip < n, payload byte 0 of record flip is xor 1. 35 fn mkseg k ulong n ulong flip ulong to ulong 36 setp k 37 for i ulong n 38 l = fill i flip 39 if ne segappend add 1 rem i 3 l 0 40 ret 1 41 end 42 end 43 ret 0 44 end 45 note fill i flip: payload of record i into pay; returns its length. 46 fn fill i ulong flip ulong to ulong 47 l = rem mul i 5 53 48 for j ulong l 49 put pay j uchar rem add mul i 7 mul j 3 256 50 end 51 if eq i flip 52 put pay 0 xor get pay 0 1 53 end 54 ret l 55 end 56 note xbyte k off: xor byte off of file k with 1, in place (O_RDWR|O_NOFOLLOW). 57 fn xbyte k ulong off ulong to ulong 58 setp k 59 fd = fopen tpath 0 get tlen 0 32770 0 60 if lt fd 0 61 ret 1 62 end 63 m = pread int fd trec 0 1 long off 64 put trec 0 xor get trec 0 1 65 w = pwrite int fd trec 0 1 long off 66 shut fd 67 if or ne m 1 ne w 1 68 ret 1 69 end 70 ret 0 71 end 72 fn mklink to ulong 73 setp 8 74 put tn 0 0 75 tput16 2 76 tput16 len ltgt 77 for i ulong len ltgt 78 put tpkt add get tn 0 i get ltgt i 79 end 80 put tn 0 add get tn 0 len ltgt 81 pkttop 82 s = symlnk tpkt 0 get tn 0 83 if lt s 0 84 ret 1 85 end 86 ret 0 87 end 88 fn ro k ulong to ulong 89 setp k 90 r = chmod tpath 0 get tlen 0 256 91 if ne r 0 92 ret 1 93 end 94 ret 0 95 end 96 fn main to int 97 setp 1 98 if ne makedir tpath 0 get tlen 0 448 0 99 ret 1 100 end 101 if ne mkseg 2 40 40 0 102 ret 2 103 end 104 if ne mkseg 3 40 17 0 105 ret 3 106 end 107 if ne mkseg 4 42 42 0 108 ret 4 109 end 110 if ne mkseg 5 40 40 0 111 ret 5 112 end 113 if ne xbyte 5 344 0 114 ret 6 115 end 116 if ne mkseg 6 40 40 0 117 ret 7 118 end 119 setp 6 120 if ne truncate tpath 0 get tlen 0 2542 0 121 ret 8 122 end 123 if ne mkseg 7 3 3 0 124 ret 9 125 end 126 if ne xbyte 7 0 0 127 ret 10 128 end 129 if ne mklink 0 130 ret 11 131 end 132 setp 9 133 if ne makedir tpath 0 get tlen 0 448 0 134 ret 12 135 end 136 for k ulong 6 137 if ne ro add k 2 0 138 ret 13 139 end 140 end 141 ret 0 142 end