aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / evidence / allen-omega-L694 / L748 / independent-review / raw / application-numbered.txt
| 1 | 1 note Native application binding: conversation state, courier lifecycle and reply/code. |
| 2 | 2 note A initialized, queued AGAIN bytes, per-call event, reserved. |
| 3 | 3 note Events:0 none,1 visible answer/ack,2 AGAIN queued,3 code give-up, |
| 4 | 4 note 4 refused LINE payload,5 slow notice,6 silence timeout. |
| 5 | 5 note Transport acceptance is separate from payload acceptance: appreceive true |
| 6 | 6 note means envelope accepted; inspect A2 for malformed payload, never invent text. |
| 7 | 7 global A ulong 4 |
| 8 | 8 global Appjob uchar 4096 |
| 9 | 9 global Appwire uchar 8192 |
| 10 | 10 global Askin uchar 160 |
| 11 | 11 fn appinit run ulong now ulong to bool |
| 12 | 12 if or ne get A 0 0 ne get R 0 0 |
| 13 | 13 ret false |
| 14 | 14 end |
| 15 | 15 if ne get Q 0 0 |
| 16 | 16 ret false |
| 17 | 17 end |
| 18 | 18 if not qstart run now |
| 19 | 19 ret false |
| 20 | 20 end |
| 21 | 21 constants |
| 22 | 22 put A 0 1 |
| 23 | 23 put A 1 0 |
| 24 | 24 put A 2 0 |
| 25 | 25 ret true |
| 26 | 26 end |
| 27 | 27 fn appclock now ulong to bool |
| 28 | 28 if eq get A 0 0 |
| 29 | 29 ret false |
| 30 | 30 end |
| 31 | 31 ret and ge now get T 0 ge now get R 4 |
| 32 | 32 end |
| 33 | 33 fn appask now ulong to bool |
| 34 | 34 if not appclock now |
| 35 | 35 ret false |
| 36 | 36 end |
| 37 | 37 if or ne get R 1 0 ne get A 1 0 |
| 38 | 38 ret false |
| 39 | 39 end |
| 40 | 40 if or ne get T 10 0 ne get T 13 0 |
| 41 | 41 ret false |
| 42 | 42 end |
| 43 | 43 if and ne get T 5 0 eq get T 6 0 |
| 44 | 44 ret false |
| 45 | 45 end |
| 46 | 46 if or ge get R 0 4294967295 ge get Q 1 4294967295 |
| 47 | 47 ret false |
| 48 | 48 end |
| 49 | 49 if not textok |
| 50 | 50 ret false |
| 51 | 51 end |
| 52 | 52 kind = classify |
| 53 | 53 if or lt kind 1 gt kind 3 |
| 54 | 54 ret false |
| 55 | 55 end |
| 56 | 56 if and eq kind 3 eq get R 6 0 |
| 57 | 57 ret false |
| 58 | 58 end |
| 59 | 59 note Validate restored context before jobbuild reads its variable-layout names. |
| 60 | 60 if not ctxmeta 6 |
| 61 | 61 ret false |
| 62 | 62 end |
| 63 | 63 if not jobbuild kind add get R 0 1 |
| 64 | 64 ret false |
| 65 | 65 end |
| 66 | 66 if not ctxappend |
| 67 | 67 ret false |
| 68 | 68 end |
| 69 | 69 n = get Inlen 0 |
| 70 | 70 size = get Outlen 0 |
| 71 | 71 for i ulong n |
| 72 | 72 put Askin i get In i |
| 73 | 73 end |
| 74 | 74 for i ulong size |
| 75 | 75 put Appjob i get Outb i |
| 76 | 76 end |
| 77 | 77 for i ulong size |
| 78 | 78 put In i get Appjob i |
| 79 | 79 end |
| 80 | 80 put Inlen 0 size |
| 81 | 81 queued = qsubmit now |
| 82 | 82 for i ulong n |
| 83 | 83 put In i get Askin i |
| 84 | 84 end |
| 85 | 85 put Inlen 0 n |
| 86 | 86 if not queued |
| 87 | 87 ret false |
| 88 | 88 end |
| 89 | 89 note start preconditions were checked before qsubmit; no concurrent calls permitted. |
| 90 | 90 if not start kind now |
| 91 | 91 qcancel |
| 92 | 92 ret false |
| 93 | 93 end |
| 94 | 94 put A 2 0 |
| 95 | 95 if gt kind 1 |
| 96 | 96 codebeg get R 0 |
| 97 | 97 put A 2 1 |
| 98 | 98 end |
| 99 | 99 ret true |
| 100 | 100 end |
| 101 | 101 fn appcancel to void |
| 102 | 102 cancel |
| 103 | 103 qcancel |
| 104 | 104 put A 1 0 |
| 105 | 105 put A 2 0 |
| 106 | 106 end |
| 107 | 107 fn appreset to void |
| 108 | 108 appcancel |
| 109 | 109 reset |
| 110 | 110 end |
| 111 | 111 note First acknowledge the triggering LINE, then submit AGAIN with a new wire |
| 112 | 112 note sequence while retaining the original conversation ID in its body. |
| 113 | 113 fn appqueue now ulong to bool |
| 114 | 114 if eq get A 1 0 |
| 115 | 115 ret true |
| 116 | 116 end |
| 117 | 117 if or ne get T 10 0 ne get T 13 0 |
| 118 | 118 ret true |
| 119 | 119 end |
| 120 | 120 put Inlen 0 get A 1 |
| 121 | 121 for i ulong get A 1 |
| 122 | 122 put In i get Appjob i |
| 123 | 123 end |
| 124 | 124 if not qsubmit now |
| 125 | 125 ret false |
| 126 | 126 end |
| 127 | 127 put A 1 0 |
| 128 | 128 ret true |
| 129 | 129 end |
| 130 | 130 fn apppoll now ulong link bool to bool |
| 131 | 131 if not appclock now |
| 132 | 132 ret false |
| 133 | 133 end |
| 134 | 134 put A 2 0 |
| 135 | 135 put T 0 now |
| 136 | 136 status = tick now |
| 137 | 137 if eq status 1 |
| 138 | 138 put A 2 5 |
| 139 | 139 end |
| 140 | 140 if eq status 2 |
| 141 | 141 qcancel |
| 142 | 142 put A 1 0 |
| 143 | 143 put A 2 6 |
| 144 | 144 end |
| 145 | 145 if not appqueue now |
| 146 | 146 appcancel |
| 147 | 147 put A 2 3 |
| 148 | 148 ret false |
| 149 | 149 end |
| 150 | 150 ret qnext now link |
| 151 | 151 end |
| 152 | 152 fn appsent now ulong ok bool to bool |
| 153 | 153 if not appclock now |
| 154 | 154 ret false |
| 155 | 155 end |
| 156 | 156 if not qsent now ok |
| 157 | 157 ret false |
| 158 | 158 end |
| 159 | 159 put A 2 0 |
| 160 | 160 ret true |
| 161 | 161 end |
| 162 | 162 fn appbody now ulong to bool |
| 163 | 163 if eq get R 1 0 |
| 164 | 164 put A 2 4 |
| 165 | 165 ret true |
| 166 | 166 end |
| 167 | 167 if ineq 0 67 |
| 168 | 168 if or le get R 2 1 ne get C 0 get R 0 |
| 169 | 169 put A 2 4 |
| 170 | 170 ret true |
| 171 | 171 end |
| 172 | 172 if codetake |
| 173 | 173 if heard get C 0 now |
| 174 | 174 ret true |
| 175 | 175 end |
| 176 | 176 end |
| 177 | 177 put A 2 4 |
| 178 | 178 ret true |
| 179 | 179 end |
| 180 | 180 if or ineq 0 83 ineq 0 87 |
| 181 | 181 status = saytake now |
| 182 | 182 if eq status 1 |
| 183 | 183 if eq get R 1 0 |
| 184 | 184 put A 1 0 |
| 185 | 185 end |
| 186 | 186 if ne get S 1 0 |
| 187 | 187 put A 2 1 |
| 188 | 188 end |
| 189 | 189 ret true |
| 190 | 190 end |
| 191 | 191 if eq status 2 |
| 192 | 192 n = get Outlen 0 |
| 193 | 193 if or eq n 0 gt n 4096 |
| 194 | 194 cancel |
| 195 | 195 put A 1 0 |
| 196 | 196 put A 2 3 |
| 197 | 197 ret true |
| 198 | 198 end |
| 199 | 199 for i ulong n |
| 200 | 200 put Appjob i get Outb i |
| 201 | 201 end |
| 202 | 202 put A 1 n |
| 203 | 203 put A 2 2 |
| 204 | 204 ret true |
| 205 | 205 end |
| 206 | 206 if eq status 3 |
| 207 | 207 put A 1 0 |
| 208 | 208 put A 2 3 |
| 209 | 209 ret true |
| 210 | 210 end |
| 211 | 211 end |
| 212 | 212 put A 2 4 |
| 213 | 213 ret true |
| 214 | 214 end |
| 215 | 215 note Reply parsing can serialize AGAIN internally. Preserve the already offered |
| 216 | 216 note datagram until the provider records its send result, including on refusal. |
| 217 | 217 fn appreceive now ulong to bool |
| 218 | 218 if not appclock now |
| 219 | 219 ret false |
| 220 | 220 end |
| 221 | 221 result = qincoming now |
| 222 | 222 if eq result 0 |
| 223 | 223 ret false |
| 224 | 224 end |
| 225 | 225 put A 2 0 |
| 226 | 226 if not qtake |
| 227 | 227 ret true |
| 228 | 228 end |
| 229 | 229 n = get Outlen 0 |
| 230 | 230 e = get Err 0 |
| 231 | 231 for i ulong n |
| 232 | 232 put Appwire i get Outb i |
| 233 | 233 end |
| 234 | 234 ok = appbody now |
| 235 | 235 for i ulong n |
| 236 | 236 put Outb i get Appwire i |
| 237 | 237 end |
| 238 | 238 put Outlen 0 n |
| 239 | 239 put Err 0 e |
| 240 | 240 ret ok |
| 241 | 241 end |