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/aien/blob/main/src/goal_microjobs/recovery.om # aien aien-dev/aien Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien / src / goal_microjobs / recovery.om` 157 lines ยท 2419 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: AGPL-3.0-or-later 3 note One-node M1 recovery over the kernel-validated original plan and journal. 4 note Mode 1 prefix is 1 newline, followed by the unchanged kernel input bytes. 5 note Capacity follows kernel.om:10,60-79: Inb=262144, load refuses >= len Inb - 1. 6 note Chunked parsing keeps one event, with no independent event-count ceiling. 7 global Ib uchar 4096 8 global Cur ulong 6 9 global Ob uchar 8192 10 global Op ulong 1 11 text conflict "RECOVERY_RESULT_CONFLICT\n" 12 fn die c int to void 13 exit c 14 end 15 fn ws c ulong to bool 16 ret or eq c 32 or eq c 10 or eq c 13 eq c 9 17 end 18 fn raw to ulong 19 if eq get Cur 5 1 20 ret 256 21 end 22 if eq get Cur 0 get Cur 1 23 r = read 0 Ib 0 len Ib 24 if lt r 0 25 die 4 26 end 27 if eq r 0 28 put Cur 5 1 29 ret 256 30 end 31 put Cur 0 0 32 put Cur 1 ulong r 33 end 34 c = ulong get Ib get Cur 0 35 put Cur 0 add get Cur 0 1 36 if eq get Cur 3 1 37 put Cur 2 add get Cur 2 1 38 if ge get Cur 2 262143 39 die 3 40 end 41 end 42 ret c 43 end 44 fn next to ulong 45 c = get Cur 4 46 if ne c 257 47 put Cur 4 257 48 ret c 49 end 50 ret raw 51 end 52 fn more to bool 53 c = next 54 while ws c bound 262144 55 c = raw 56 end 57 put Cur 4 c 58 ret ne c 256 59 end 60 fn word to ulong 61 if not more 62 die 2 63 end 64 c = next 65 v = ulong 0 66 while true bound 262144 67 if eq c 256 68 ret v 69 end 70 if ws c 71 ret v 72 end 73 if or lt c 48 gt c 57 74 die 3 75 end 76 d = sub c 48 77 if or gt v `1844674407370955161` and eq v `1844674407370955161` gt d 5 78 die 3 79 end 80 v = add mul v 10 d 81 c = raw 82 end 83 ret v 84 end 85 fn digit v ulong to void 86 if gt v 9 87 digit div v 10 88 end 89 put Ob get Op 0 uchar add rem v 10 48 90 put Op 0 add get Op 0 1 91 end 92 fn dec v ulong to void 93 digit v 94 put Ob get Op 0 32 95 put Op 0 add get Op 0 1 96 end 97 fn checkresult a view ulong 14 b view ulong 14 to void 98 for i ulong 14 99 if ne get a i get b i 100 w = write 2 conflict 0 len conflict 101 die 33 102 end 103 end 104 end 105 fn prepare to void 106 a = new ulong 40 0 107 e = new ulong 14 0 108 put Cur 3 1 109 for i ulong 40 110 put a i word 111 end 112 while more bound 262144 113 for j ulong 14 114 put e j word 115 end 116 if and eq get e 2 6 eq get e 3 1 117 for j ulong 4 118 put a add 35 j get e add 8 j 119 end 120 note RECOVERY-MUTANT first-correct-stop 121 end 122 end 123 for i ulong 40 124 dec get a i 125 end 126 put Ob get Op 0 10 127 put Op 0 add get Op 0 1 128 w = write 1 Ob 0 get Op 0 129 end 130 fn resume to void 131 a = new ulong 14 0 132 b = new ulong 14 0 133 for i ulong 14 134 put a i word 135 end 136 for i ulong 14 137 put b i word 138 end 139 if more 140 die 3 141 end 142 note RECOVERY-GUARD result-conflict 143 checkresult a b 144 end 145 fn main to int 146 put Cur 4 257 147 mode = word 148 if eq mode 1 149 prepare 150 ret 0 151 end 152 if eq mode 2 153 resume 154 ret 0 155 end 156 ret 2 157 end