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/pulse/src/20main.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 / pulse / src / 20main.om` 272 lines ยท 4680 bytes Raw Blame History 1 note synapse-pulse 20main.om: arguments, defaults, run order, findings file, alert, exit code. 2 fn pu_usage to void 3 syn_die tusage 64 4 end 5 6 note pu_pfx: b starts with t 7 fn pu_pfx b view uchar * t view uchar * to bool 8 for j ulong len t 9 if ne get b j get t j 10 ret false 11 end 12 end 13 ret true 14 end 15 16 note pu_envopt: option i from environment entry with prefix t, plus suffix s; true when found 17 fn pu_envopt i ulong t view uchar * s view uchar * to bool 18 b = new uchar 8192 0 19 for e ulong ulong envcnt 20 n = envread e b 0 len b 21 if gt n long len t 22 if pu_pfx b t 23 m = syn_mark 24 syn_pa b len t sub ulong n len t 25 syn_pt s 26 put gop i m 27 put gopl i syn_len m 28 ret true 29 end 30 end 31 end 32 ret false 33 end 34 35 fn pu_setdef i ulong t view uchar * to void 36 if eq get gopl i 0 37 m = syn_mark 38 syn_pt t 39 put gop i m 40 put gopl i syn_len m 41 end 42 end 43 44 fn pu_args to void 45 n = ulong argcnt 46 i = ulong 1 47 sawrun = false 48 while lt i n bound 1000 49 o = syn_arg i 50 l = ulong get gxs 2 51 if syn_seq o l trun 52 sawrun = true 53 i = add i 1 54 continue 55 end 56 if syn_seq o l talert 57 put gfl 0 1 58 i = add i 1 59 continue 60 end 61 k = ulong 99 62 if syn_seq o l thome 63 k = 0 64 end 65 if syn_seq o l tadir 66 k = 1 67 end 68 if syn_seq o l tgh 69 k = 2 70 end 71 if syn_seq o l tsess 72 k = 3 73 end 74 if syn_seq o l tcbin 75 k = 4 76 end 77 if syn_seq o l toff 78 k = 5 79 end 80 if syn_seq o l tnow 81 k = 6 82 end 83 if or eq k 99 ge add i 1 n 84 pu_usage 85 end 86 v = syn_arg add i 1 87 vl = ulong get gxs 2 88 if eq vl 0 89 pu_usage 90 end 91 put gop k v 92 put gopl k vl 93 i = add i 2 94 end 95 if not sawrun 96 pu_usage 97 end 98 end 99 100 note the AIEN_COORD_HOME branch above used tnl as an empty suffix; strip it 101 fn pu_fixhome to void 102 l = get gopl 0 103 if and gt l 0 eq get gsp add get gop 0 sub l 1 10 104 put gopl 0 sub l 1 105 end 106 end 107 108 note pu_envraw: option i from environment entry with prefix t, value only; true when present and non-empty 109 fn pu_envraw i ulong t view uchar * to bool 110 if pu_envopt i t tnl 111 put gopl i sub get gopl i 1 112 ret true 113 end 114 ret false 115 end 116 117 note pu_hdef: when option i is unset, default it to HOME (slot 7) + t; with no HOME, refuse with msg (exit 64) 118 fn pu_hdef i ulong t view uchar * msg view uchar * to void 119 if eq get gopl i 0 120 if not pu_opt 7 121 syn_die msg 64 122 end 123 m = syn_mark 124 pu_popt 7 125 syn_pt t 126 put gop i m 127 put gopl i syn_len m 128 end 129 end 130 131 note pu_envkv: option i = text k followed by option j (e.g. HOME= + the caller's HOME) 132 fn pu_envkv i ulong k view uchar * j ulong to void 133 m = syn_mark 134 syn_pt k 135 pu_popt j 136 put gop i m 137 put gopl i syn_len m 138 end 139 140 note option slots: 0 coord home, 1 alert dir, 2 gh, 3 sessions, 4 claims-bin, 5 offline, 6 now, 141 note 7 caller HOME, 8 caller PATH, 9 gh child HOME=, 10 gh child PATH=. No path is built in: every 142 note default is HOME-relative, HOME comes only from the caller's environment, and a needed but unset HOME 143 note refuses with 64 instead of guessing. 144 fn pu_setup to void 145 if pu_envraw 7 tenvhm 146 if ne get gsp get gop 7 47 147 syn_die tbadenvh 64 148 end 149 end 150 if pu_opt 5 151 put gfl 1 1 152 end 153 if eq get gopl 0 0 154 if not pu_envopt 0 tenvh tnl 155 if pu_opt 7 156 pu_hdef 0 tdhome tnohome 157 end 158 end 159 end 160 if eq get gopl 0 0 161 syn_die tnohome 64 162 end 163 pu_fixhome 164 if eq get gfl 0 1 165 pu_hdef 1 tdadir tnohadir 166 end 167 pu_hdef 3 tdsess tnohsess 168 if eq get gfl 1 0 169 pu_hdef 2 tdgh tnohgh 170 if not pu_opt 7 171 syn_die tnohkid 64 172 end 173 pu_envkv 9 tenvhm 7 174 if not pu_envraw 8 tenvpath 175 pu_setdef 8 tdpath 176 end 177 pu_envkv 10 tenvpath 8 178 end 179 if eq get gopl 4 0 180 syn_die tnocbin 64 181 end 182 if ne get gsp get gop 4 47 183 syn_die tnocbin 64 184 end 185 if pu_opt 6 186 t = syn_tsp get gop 6 get gopl 6 187 if eq get gxs 2 0 188 syn_die tbadnow 64 189 end 190 put gnow 0 t 191 put gfl 2 1 192 else 193 put gnow 0 div ulong realns `1000000000` 194 end 195 m = pu_pathi 0 tslpu 196 r = syn_mkdir m syn_len m 197 syn_rew m 198 m = pu_pathi 0 tsletag 199 r = syn_mkdir m syn_len m 200 syn_rew m 201 m = syn_mark 202 syn_pt tstops 203 pu_toks m syn_len m 0 0 204 syn_rew m 205 end 206 207 text tsum1 " coordination finding(s) in " 208 text tsum2 "; first: " 209 fn pu_mkalert to ulong 210 if eq get gcnt 0 0 211 pu_alert 0 0 0 212 ret 0 213 end 214 m = syn_mark 215 syn_pd get gcnt 0 216 syn_pt tsum1 217 pu_popt 0 218 syn_pt tslfind 219 syn_pt tsum2 220 syn_ps get gcnt 9 get gcnt 10 221 pu_alert 1 m syn_len m 222 ret 1 223 end 224 225 text tofull "synapse-pulse: findings over 4 MiB, truncated" 226 text tfwerr "synapse-pulse: cannot write findings.jsonl" 227 fn main to int 228 pu_args 229 pu_setup 230 r = pu_ldclaims 231 if lt r 0 232 ret int neg r 233 end 234 r = pu_expire 235 if lt r 0 236 ret int neg r 237 end 238 r = pu_ldconf 239 if lt r 0 240 ret int neg r 241 end 242 pu_sessions 243 pu_dup 244 pu_repos 245 pu_github 246 if eq get gfl 7 1 247 w = write 2 tofull 0 len tofull 248 w = write 2 tnl 0 1 249 end 250 w = write 1 gout 0 get gon 0 251 fp = pu_pathi 0 tslfind 252 fd = syn_wbeg fp syn_len fp 253 if lt fd 0 254 syn_die tfwerr 70 255 end 256 w = write int fd gout 0 get gon 0 257 r = syn_wend fd fp syn_len fp 258 if lt r 0 259 syn_die tfwerr 70 260 end 261 syn_rew fp 262 if eq get gfl 0 1 263 r2 = pu_mkalert 264 end 265 if gt get gcnt 0 0 266 ret 1 267 end 268 if and gt get gcnt 3 0 eq get gcnt 4 0 269 ret 75 270 end 271 ret 0 272 end