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/interplane/core/main.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 / interplane / core / main.om` 244 lines ยท 4231 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note protocol/interplane/core/main.om: CLI entrypoint for interplane core envelope & policy engine 3 note Compose with: 4 note si/directives/om2.om om/tls/sha2.om protocol/interplane/core/envelope.om 5 note protocol/interplane/core/policy.om protocol/interplane/core/main.om 6 7 text ip_cmd_ident "check-ident" 8 text ip_cmd_ver "check-version" 9 text ip_cmd_eval "eval-policy" 10 text ip_cmd_parse "parse-stdin" 11 12 text ip_msg_ok "OK\n" 13 text ip_msg_allow "ALLOW\n" 14 text ip_msg_deny "DENY\n" 15 text ip_msg_invalid "INVALID\n" 16 text ip_msg_parsed "PARSED " 17 text ip_msg_nl "\n" 18 text ip_msg_usage "Usage: interplane-core |check-version |parse-stdin|eval-policy >\n" 19 20 fn ip_parse_dec s view uchar * to long 21 n = len s 22 if eq n ulong 0 23 ret long -1 24 end 25 if gt n ulong 12 26 ret long -1 27 end 28 acc = ulong 0 29 i = ulong 0 30 while lt i n bound 12 31 b = get s i 32 if or lt b uchar 48 gt b uchar 57 33 ret long -1 34 end 35 acc = add mul acc ulong 10 sub ulong b ulong 48 36 i = add i ulong 1 37 end 38 ret long acc 39 end 40 41 fn ip_read_arg_u64 idx ulong to long 42 buf = new uchar 32 0 43 k = argread idx buf ulong 0 ulong 32 44 if le k long 0 45 ret long -1 46 end 47 ret ip_parse_dec part buf 0 ulong k 48 end 49 50 fn ip_cli_ident to int 51 buf = new uchar 128 0 52 k = argread ulong 2 buf ulong 0 ulong 128 53 if le k long 0 54 w = ip_write_all int 1 ip_msg_invalid 55 if w 56 ret int 1 57 end 58 ret int 1 59 end 60 rc = ip_valid_ident part buf 0 ulong k 61 if ne rc IP_OK 62 w = ip_write_all int 1 ip_msg_invalid 63 if w 64 ret int 1 65 end 66 ret int 1 67 end 68 w = ip_write_all int 1 ip_msg_ok 69 if not w 70 ret int 1 71 end 72 ret int 0 73 end 74 75 fn ip_cli_version to int 76 buf = new uchar 64 0 77 k = argread ulong 2 buf ulong 0 ulong 64 78 if le k long 0 79 w = ip_write_all int 1 ip_msg_invalid 80 if w 81 ret int 1 82 end 83 ret int 1 84 end 85 rc = ip_validate_version part buf 0 ulong k 86 if ne rc IP_OK 87 w = ip_write_all int 1 ip_msg_invalid 88 if w 89 ret int 1 90 end 91 ret int 1 92 end 93 w = ip_write_all int 1 ip_msg_ok 94 if not w 95 ret int 1 96 end 97 ret int 0 98 end 99 100 fn ip_cli_parse_stdin to int 101 buf = new uchar 4096 0 102 tot = ulong 0 103 done = false 104 while not done bound 4096 105 if ge tot ulong 4096 106 break 107 end 108 remn = sub ulong 4096 tot 109 k = read int 0 buf tot remn 110 if lt k long 0 111 ret int 1 112 end 113 if eq k long 0 114 done = true 115 else 116 tot = add tot ulong k 117 end 118 end 119 meta = new ulong 4 0 120 dig = new uchar 32 0 121 rc = ip_parse_envelope part buf 0 tot meta dig 122 if ne rc IP_OK 123 w = ip_write_all int 1 ip_msg_invalid 124 if w 125 ret int 1 126 end 127 ret int 1 128 end 129 hx = new uchar 64 0 130 ip_digest_to_hex dig hx 131 w1 = ip_write_all int 1 ip_msg_parsed 132 w2 = ip_write_all int 1 hx 133 w3 = ip_write_all int 1 ip_msg_nl 134 if and w1 and w2 w3 135 ret int 0 136 end 137 ret int 1 138 end 139 140 fn ip_cli_eval to int 141 rpol = ip_read_arg_u64 ulong 2 142 aops = ip_read_arg_u64 ulong 3 143 orig = ip_read_arg_u64 ulong 4 144 tr = ip_read_arg_u64 ulong 5 145 rop = ip_read_arg_u64 ulong 6 146 cpol = ip_read_arg_u64 ulong 7 147 if lt rpol long 0 148 w = ip_write_all int 1 ip_msg_deny 149 if w 150 ret int 1 151 end 152 ret int 1 153 end 154 if lt aops long 0 155 w = ip_write_all int 1 ip_msg_deny 156 if w 157 ret int 1 158 end 159 ret int 1 160 end 161 if lt orig long 0 162 w = ip_write_all int 1 ip_msg_deny 163 if w 164 ret int 1 165 end 166 ret int 1 167 end 168 if lt tr long 0 169 w = ip_write_all int 1 ip_msg_deny 170 if w 171 ret int 1 172 end 173 ret int 1 174 end 175 if lt rop long 0 176 w = ip_write_all int 1 ip_msg_deny 177 if w 178 ret int 1 179 end 180 ret int 1 181 end 182 if lt cpol long 0 183 w = ip_write_all int 1 ip_msg_deny 184 if w 185 ret int 1 186 end 187 ret int 1 188 end 189 rc = ip_eval_policy ulong rpol ulong aops ulong orig ulong tr ulong rop ulong cpol 190 if ne rc POL_OK 191 w = ip_write_all int 1 ip_msg_deny 192 if w 193 ret int 1 194 end 195 ret int 1 196 end 197 w = ip_write_all int 1 ip_msg_allow 198 if not w 199 ret int 1 200 end 201 ret int 0 202 end 203 204 fn main to int 205 argc = argcnt 206 if lt argc long 2 207 w = ip_write_all int 2 ip_msg_usage 208 if w 209 ret int 2 210 end 211 ret int 2 212 end 213 cmd = new uchar 64 0 214 kc = argread ulong 1 cmd ulong 0 ulong 64 215 if le kc long 0 216 ret int 2 217 end 218 if ip_slice_eq part cmd 0 ulong kc ip_cmd_parse 219 ret ip_cli_parse_stdin 220 end 221 if ip_slice_eq part cmd 0 ulong kc ip_cmd_ident 222 if lt argc long 3 223 ret int 2 224 end 225 ret ip_cli_ident 226 end 227 if ip_slice_eq part cmd 0 ulong kc ip_cmd_ver 228 if lt argc long 3 229 ret int 2 230 end 231 ret ip_cli_version 232 end 233 if ip_slice_eq part cmd 0 ulong kc ip_cmd_eval 234 if lt argc long 8 235 ret int 2 236 end 237 ret ip_cli_eval 238 end 239 w = ip_write_all int 2 ip_msg_usage 240 if w 241 ret int 2 242 end 243 ret int 2 244 end