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/si/agent-archive/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 / si / agent-archive / main.om` 191 lines ยท 3878 bytes Raw Blame History 1 note agent-archive CLI: reads TSV records (ts_ms\tagent\trole\tpriv\ttext) from stdin, 2 note builds SHA-256 hash-chained archive, verifies chain integrity, and exports public redacted JSONL. 3 note Compose: si/directives/om2.om + si/agent-archive/lib.om + si/agent-archive/main.om 4 5 text aa_cli_err_parse "agent-archive: malformed TSV record\n" 6 text aa_cli_err_chain "agent-archive: archive append or chain verification failed\n" 7 8 fn aa_write_all fd int buf view uchar * n ulong to bool 9 done = ulong 0 10 while lt done n bound 65536 11 k = write fd buf done sub n done 12 if le k 0 13 ret false 14 end 15 done = add done ulong k 16 end 17 ret true 18 end 19 20 fn aa_read_stdin dst edit uchar * to long 21 got = ulong 0 22 cap = len dst 23 while lt got cap bound 65536 24 k = read 0 dst got sub cap got 25 if lt k 0 26 ret -1 27 end 28 if eq k 0 29 break 30 end 31 got = add got ulong k 32 end 33 ret long got 34 end 35 36 fn aa_trim_eol line view uchar * to ulong 37 n = len line 38 if gt n 0 39 if eq get line sub n 1 10 40 n = sub n 1 41 end 42 end 43 if gt n 0 44 if eq get line sub n 1 13 45 n = sub n 1 46 end 47 end 48 ret n 49 end 50 51 fn aa_parse_tsv_rec line view uchar * rec edit AaChainEntry to long 52 n = aa_trim_eol line 53 tabs = new ulong 5 0 54 tc = ulong 0 55 i = ulong 0 56 while lt i n bound 16384 57 if eq get line i 9 58 if lt tc 5 59 put tabs tc i 60 end 61 tc = add tc 1 62 end 63 i = add i 1 64 end 65 if ne tc 4 66 ret -1 67 end 68 v = aa_parse_u64 part line 0 get tabs 0 69 if lt v 0 70 ret -1 71 end 72 put rec ts_ms ulong v 73 v = aa_parse_agent part line add get tabs 0 1 sub sub get tabs 1 get tabs 0 1 74 if lt v 0 75 ret -1 76 end 77 put rec agent_id ulong v 78 v = aa_parse_role part line add get tabs 1 1 sub sub get tabs 2 get tabs 1 1 79 if lt v 0 80 ret -1 81 end 82 put rec role_id ulong v 83 v = aa_parse_u64 part line add get tabs 2 1 sub sub get tabs 3 get tabs 2 1 84 if lt v 0 85 ret -1 86 end 87 put rec is_priv ulong v 88 ret long add get tabs 3 1 89 end 90 91 fn aa_cli_stage_line line view uchar * src_pos ulong meta edit AaArchiveMeta rec edit AaChainEntry text_buf edit uchar 16384 to int 92 toff_rel = aa_parse_tsv_rec line rec 93 if lt toff_rel 0 94 ret -10 95 end 96 eff = aa_trim_eol line 97 if lt eff ulong toff_rel 98 ret -10 99 end 100 put rec src_pos src_pos 101 ret aa_stage_record meta rec part line ulong toff_rel sub eff ulong toff_rel text_buf 102 end 103 104 fn aa_cli_export_all cnt ulong entries view ulong 288 hashes view uchar 4096 text_buf view uchar 16384 to int 105 rec = new AaChainEntry 0 0 0 0 0 0 0 0 0 106 outln = new uchar 2048 0 107 i = ulong 0 108 while lt i cnt bound 64 109 aa_load_entry entries i rec 110 en = aa_export_jsonl rec hashes text_buf false outln 111 if gt en 0 112 if not aa_write_all 1 outln ulong en 113 ret 1 114 end 115 end 116 i = add i 1 117 end 118 ret 0 119 end 120 121 fn aa_cli_ingest_all inbuf view uchar 16384 total ulong meta edit AaArchiveMeta entries edit ulong 288 hashes edit uchar 4096 text_buf edit uchar 16384 to int 122 rec = new AaChainEntry 0 0 0 0 0 0 0 0 0 123 cur = ulong 0 124 while lt cur total bound 16384 125 ls = cur 126 while lt cur total bound 16384 127 if eq get inbuf cur 10 128 cur = add cur 1 129 break 130 end 131 cur = add cur 1 132 end 133 ll = sub cur ls 134 if eq ll 0 135 continue 136 end 137 if eq get inbuf ls 10 138 continue 139 end 140 st = aa_cli_stage_line part inbuf ls ll ls meta rec text_buf 141 if ne st 0 142 ret st 143 end 144 idx = get meta cnt 145 cm = aa_commit_record meta rec entries 146 if lt cm 0 147 ret cm 148 end 149 if eq cm 0 150 if not aa_link_record idx rec hashes text_buf 151 ret -4 152 end 153 end 154 end 155 ret 0 156 end 157 158 fn main to int 159 inbuf = new uchar 16384 0 160 nread = aa_read_stdin inbuf 161 if lt nread 0 162 ret 1 163 end 164 meta = new AaArchiveMeta 0 0 0 165 entries = new ulong 288 0 166 hashes = new uchar 4096 0 167 text_buf = new uchar 16384 0 168 rc = aa_cli_ingest_all inbuf ulong nread meta entries hashes text_buf 169 if eq rc -10 170 w = aa_write_all 2 aa_cli_err_parse len aa_cli_err_parse 171 if not w 172 ret 2 173 end 174 ret 1 175 end 176 if ne rc 0 177 w = aa_write_all 2 aa_cli_err_chain len aa_cli_err_chain 178 if not w 179 ret 2 180 end 181 ret 1 182 end 183 if ne aa_verify_chain get meta cnt entries hashes text_buf 0 184 w = aa_write_all 2 aa_cli_err_chain len aa_cli_err_chain 185 if not w 186 ret 2 187 end 188 ret 1 189 end 190 ret aa_cli_export_all get meta cnt entries hashes text_buf 191 end