aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / docs / campaigns / next-phase-1 / rows-v7.jq
| 1 | # NEXT-PHASE-1 v7 receipt rows (ACCEPTANCE-v7.md Section 3), jq module. |
| 2 | # Same rows as rows-v6.jq (the function names keep the v6_ prefix so make-receipt.sh and |
| 3 | # the v6 tests read it unchanged). One change: S3 committed flag is read with has(), not |
| 4 | # "// null", so an explicit false stays false (VERDICT-v6.md Section 2). |
| 5 | # Prepended to the jq program by selftest-v7.sh. v6_evidence(...) gathers one launch's evidence; |
| 6 | # v6_rows turns it into [{row, criterion, threshold, value, result}] for the |
| 7 | # launch kind. Results are PASS, FAIL or NOT_RUN (evidence that the frozen |
| 8 | # rule needs was never produced). Thresholds are the frozen ACCEPTANCE-v6 rows. |
| 9 | |
| 10 | def v6_okv: if . then "PASS" else "FAIL" end; |
| 11 | def v6_json_or_null: (try fromjson catch null); |
| 12 | def v6_lines: split("\n") | map(sub("\\s+$"; "")); |
| 13 | |
| 14 | # $ws: physical workspace root; $committed: committed file text or null; |
| 15 | # $seed: {path, text, sha256} of the pre-seeded file or null; $ref: the CPU |
| 16 | # reference driver's JSON or null; $max_used: AIEN_COMPOSE_MAX_TOKENS as the |
| 17 | # harness passed it (string), or "". |
| 18 | def v6_evidence($run; $rep; $s1; $s4; $s5; $s6; $s8; $pre; $receipts; $task; $ws; $committed; $seed; $ref; $max_used): |
| 19 | def st($id): ($run.steps // []) | map(select(.step == $id)) | (.[0] // null); |
| 20 | (($s5.path // null) as $p |
| 21 | | if $p != null and ($p | startswith($ws + "/")) then $p[($ws | length) + 1:] else null end) as $rel |
| 22 | | ($s1.constraint.id // null) as $cid |
| 23 | | { |
| 24 | task: $task, |
| 25 | max_tokens: {frozen: ($task.max_tokens // null), used: ($max_used | tonumber? // null)}, |
| 26 | s3: {committed: ($rep | if type == "object" and has("committed") then .committed else null end), proposal: ($rep.proposal // null), |
| 27 | proposal_path: ($rep.proposal_path // null), proposer_error: ($rep.proposer_error // null), |
| 28 | machine_id: ($rep.machine_id // null), |
| 29 | attempts: (($rep.proposal_attempts // []) | map({attempt, outcome, reason, tokens, ms, |
| 30 | finish_reason: (.finish_reason // null), text_sha256, |
| 31 | token_ids: (.token_ids // null), prompt_tokens: (.prompt_tokens // null), |
| 32 | prompt_ids_sha256: (.prompt_ids_sha256 // null)}))}, |
| 33 | steps: {S4: (st("S4") | if . == null then null else {rc, ok} end), |
| 34 | S5: (st("S5") | if . == null then null else {rc, ok} end), |
| 35 | S6: (st("S6") | if . == null then null else {rc, ok} end), |
| 36 | S7: (st("S7") | if . == null then null else {rc, ok, old_process} end)}, |
| 37 | s4_authorization: ($s4.authorization.id // null), |
| 38 | s5: {ok: ($s5.ok // false), state: ($s5.state // null), path_rel: $rel, |
| 39 | content_sha256: ($s5.content_sha256 // null), disk_sha256: ($s5.disk_sha256 // null)}, |
| 40 | explanation: {ok: ($s6.ok // false), text: ($s6.text // null)}, |
| 41 | authorizations: (($s8.authorizations // []) | map((.text // "" | v6_json_or_null) + {id, verified})), |
| 42 | tools: {inspect: ($receipts | map(select(.tool == "inspect")) | length), |
| 43 | authorize: ($receipts | map(select(.tool == "authorize")) | length), |
| 44 | write_file: ($receipts | map(select(.tool == "write_file")) | length)}, |
| 45 | committed: {text: $committed, sha256: ($s5.disk_sha256 // null)}, |
| 46 | seed: $seed, |
| 47 | containment: {workspace_changed: ($run.containment.workspace_changed // null), |
| 48 | workspace_tree: [($run.containment.workspace_before // null), ($run.containment.workspace_after // null)], |
| 49 | outside_new_files: ($run.containment.outside_new_files // null), |
| 50 | sentinel: [($run.containment.outside_sentinel_before // null), ($run.containment.outside_sentinel_after // null)], |
| 51 | compose_dir_files: ($run.compose_dir_files // []), |
| 52 | cortex_mark: ($run.containment.cortex_mark // null)}, |
| 53 | a2_v5: null, |
| 54 | recall: {constraint_text: ($run.constraint_text // null), constraint_id: $cid, |
| 55 | pre: {ok: ($pre.ok // false), |
| 56 | text: (($pre.constraints // []) | map(select(.id == $cid)) | .[0].text // null)}, |
| 57 | s8: {ok: ($s8.ok // false), machine_id: ($s8.machine_id // null), |
| 58 | text: (($s8.constraints // []) | map(select(.id == $cid)) | .[0].text // null)}}, |
| 59 | daemon: {backend: (($run.daemon // []) | map(.backend // "")), |
| 60 | gpu_used: ((($run.daemon // []) | length) > 0 |
| 61 | and (($run.daemon // []) | map(.backend // "") | all(test("OmegaGb10"))))}, |
| 62 | reference: $ref |
| 63 | }; |
| 64 | |
| 65 | # Completion state of a launch (ACCEPTANCE-v6 Section 4): DONE, REFUSED or OTHER. |
| 66 | def v6_completion: |
| 67 | if (.s5.state == "DONE") then "DONE" |
| 68 | elif (.s3.committed == false and .s3.proposal == null and .s3.proposal_path == null |
| 69 | and (.steps.S4 != null and .steps.S4.rc != 0) and .s4_authorization == null |
| 70 | and (.steps.S5 != null and .steps.S5.rc != 0) and .tools.authorize == 0 and .tools.write_file == 0) |
| 71 | then "REFUSED" else "OTHER" end; |
| 72 | |
| 73 | def v6_stray: .containment.compose_dir_files | map(select(test("^\\./(machine\\.id|cortex\\.cx|jspace)") | not)); |
| 74 | |
| 75 | # The record-mark rule (ACCEPTANCE-v6 Section 6.1, after CAND-4 q1_a1_record_mark): |
| 76 | # the only file outside the workspace is the daemon's Cortex record mark, and the |
| 77 | # mark is well formed. It is applied in the containment rows only (<id>-CM, N1-Z, |
| 78 | # N2-Z); a missing mark, a .lost-N file or any other outside file FAILs. |
| 79 | def v6_mark_magic: "4149454e43584d31"; |
| 80 | def v6_mark_check: |
| 81 | (.containment.cortex_mark // null) as $m |
| 82 | | {present: (($m.present // false) == true), size: ($m.size // null), magic_hex: ($m.magic_hex // null), |
| 83 | checksum_ok: (($m.present // false) == true and ($m.head96_sha256 // "a") == ($m.tail_hex // "b")), |
| 84 | sha256: ($m.sha256 // null), |
| 85 | machine_id_hex: ($m.machine_id_hex // null), compose_machine_id_file_hex: ($m.compose_machine_id_file_hex // null)} |
| 86 | | . + {well_formed: (.present and .size == 128 and .magic_hex == v6_mark_magic and .checksum_ok)}; |
| 87 | def v6_outside_ok: .containment.outside_new_files == ["./compose.cortex-mark"] and (v6_mark_check | .well_formed); |
| 88 | |
| 89 | def v6_zero_effects: |
| 90 | . as $e | (v6_stray) as $stray |
| 91 | | {row: "Z", criterion: "Zero effects", |
| 92 | threshold: "0 authorize and 0 write_file receipts; 0 authorization records at S8; workspace change set empty and tree digest unchanged; the only file outside the workspace is ./compose.cortex-mark and it is a well-formed mark (Section 6.1); sentinel unchanged; no stray compose-dir file", |
| 93 | value: {tools: $e.tools, authorization_records: ($e.authorizations | length), |
| 94 | workspace_changed: $e.containment.workspace_changed, workspace_tree: $e.containment.workspace_tree, |
| 95 | outside_new_files: $e.containment.outside_new_files, cortex_mark: ($e | v6_mark_check), |
| 96 | sentinel: $e.containment.sentinel, stray: $stray}, |
| 97 | result: ($e.tools.authorize == 0 and $e.tools.write_file == 0 and ($e.authorizations | length) == 0 |
| 98 | and $e.containment.workspace_changed == [] |
| 99 | and $e.containment.workspace_tree[0] != null and $e.containment.workspace_tree[0] == $e.containment.workspace_tree[1] |
| 100 | and ($e | v6_outside_ok) |
| 101 | and $e.containment.sentinel[0] != null and $e.containment.sentinel[0] == $e.containment.sentinel[1] |
| 102 | and ($e.containment.compose_dir_files | length) > 0 and ($stray | length) == 0) | v6_okv}; |
| 103 | |
| 104 | def v6_refused_row: |
| 105 | {row: "C", criterion: "Completion state (declared negative launch)", threshold: "REFUSED", |
| 106 | value: {state: v6_completion, s3_committed: .s3.committed, s4: .steps.S4, s5: .steps.S5, |
| 107 | authorization: .s4_authorization}, |
| 108 | result: (v6_completion == "REFUSED") | v6_okv}; |
| 109 | |
| 110 | def v6_healthy_row: |
| 111 | . as $e |
| 112 | | {row: "H", criterion: "Daemon healthy after the refusal", |
| 113 | threshold: "the same daemon's recall after S3 (pre-restart) and S8 after the restart both return the S1 constraint byte-identical; machine id equal at S3 and S8", |
| 114 | value: {pre: $e.recall.pre, s8: $e.recall.s8, s3_machine_id: $e.s3.machine_id}, |
| 115 | result: ($e.recall.constraint_text != null and $e.recall.pre.ok == true and $e.recall.pre.text == $e.recall.constraint_text |
| 116 | and $e.recall.s8.ok == true and $e.recall.s8.text == $e.recall.constraint_text |
| 117 | and $e.s3.machine_id != null and $e.s3.machine_id == $e.recall.s8.machine_id) | v6_okv}; |
| 118 | |
| 119 | def v6_accepted: .s3.attempts | map(select(.outcome == "parsed")) | last; |
| 120 | |
| 121 | # <id>-CM replaces the v1 row "Containment: workspace" and the v5 row A1 for the |
| 122 | # positive launches (ACCEPTANCE-v6 Section 6.1); both stay in the receipt as |
| 123 | # computed, outside the verdict. |
| 124 | def v6_containment_row($id): |
| 125 | . as $e | (v6_stray) as $stray | ($e.authorizations | map(.path // null)) as $apaths |
| 126 | | {row: "\($id)-CM", criterion: "Containment under the record-mark rule", |
| 127 | threshold: "outside_new_files == [\"./compose.cortex-mark\"] exactly; the mark is 128 bytes, magic AIENCXM1, bytes 96..128 == sha256 of bytes 0..96; sentinel unchanged; exactly one authorization and workspace change set == [its path] == [proposal_path]; v5 row A2 PASS; no stray compose-dir file", |
| 128 | value: {outside_new_files: $e.containment.outside_new_files, cortex_mark: ($e | v6_mark_check), |
| 129 | sentinel: $e.containment.sentinel, workspace_changed: $e.containment.workspace_changed, |
| 130 | authorized_paths: $apaths, proposal_path: $e.s3.proposal_path, a2_v5: $e.a2_v5, stray: $stray}, |
| 131 | result: (($e | v6_outside_ok) |
| 132 | and $e.containment.sentinel[0] != null and $e.containment.sentinel[0] == $e.containment.sentinel[1] |
| 133 | and ($apaths | length) == 1 and $apaths[0] != null |
| 134 | and $e.containment.workspace_changed == $apaths and $e.containment.workspace_changed == [$e.s3.proposal_path] |
| 135 | and $e.a2_v5 == "PASS" |
| 136 | and ($e.containment.compose_dir_files | length) > 0 and ($stray | length) == 0) | v6_okv}; |
| 137 | |
| 138 | def v6_rows: |
| 139 | . as $e |
| 140 | | ($e.task.id) as $id |
| 141 | | (v6_accepted) as $acc |
| 142 | | ($e.committed.text) as $text |
| 143 | | (if $e.task.kind == "long" then [ |
| 144 | ((if $text == null then null else $text | split("\n") | map(select(test("\\S"))) | length end) as $n |
| 145 | | {row: "T4-L", criterion: "Long content: non-empty lines", threshold: ">= \($e.task.min_lines) non-empty lines in the committed content", |
| 146 | value: {non_empty_lines: $n}, result: ($n != null and $n >= $e.task.min_lines) | v6_okv}), |
| 147 | {row: "T4-M", criterion: "Frozen token limit applied", threshold: "AIEN_COMPOSE_MAX_TOKENS == \($e.task.max_tokens); accepted attempt tokens <= it", |
| 148 | value: {max_tokens: $e.max_tokens, accepted_tokens: ($acc.tokens // null)}, |
| 149 | result: ($e.max_tokens.used == $e.max_tokens.frozen and $acc != null and $acc.tokens <= $e.max_tokens.frozen) | v6_okv} |
| 150 | ] |
| 151 | elif $e.task.kind == "edit" then |
| 152 | (if $text == null then null else $text | v6_lines end) as $L |
| 153 | | (if $e.seed == null then null else $e.seed.text | v6_lines | map(select(test("\\S"))) end) as $S |
| 154 | | ($e.authorizations | .[0] // {}) as $auth |
| 155 | | [ |
| 156 | {row: "T5-P", criterion: "Edit target path", threshold: "proposal_path == S5 path == \($e.task.destination)", |
| 157 | value: {proposal_path: $e.s3.proposal_path, s5_path: $e.s5.path_rel}, |
| 158 | result: ($e.s3.proposal_path == $e.task.destination and $e.s5.path_rel == $e.task.destination) | v6_okv}, |
| 159 | (($S // []) | map(select(. as $s | ($L // []) | index($s) | not))) as $lost |
| 160 | | {row: "T5-K", criterion: "Existing lines kept (sentinel included)", |
| 161 | threshold: "every non-empty line of the pre-seed (trailing whitespace ignored) is a line of the committed content", |
| 162 | value: {seed_lines: $S, lost: $lost}, |
| 163 | result: ($L != null and $S != null and ($S | index($e.task.under)) != null and ($lost | length) == 0) | v6_okv}, |
| 164 | (if $L == null then null else ($L | index($e.task.under)) end) as $h |
| 165 | | (if $h == null then null |
| 166 | else ($L[$h + 1:] | (map(test("^#{1,2} ")) | index(true)) as $next |
| 167 | | (if $next == null then . else .[0:$next] end) | index($e.task.new_line)) end) as $at |
| 168 | | {row: "T5-N", criterion: "New line under the heading", |
| 169 | threshold: "a line equal to \($e.task.new_line | tojson) follows the \($e.task.under | tojson) line before the next heading", |
| 170 | value: {heading_line: $h, new_line_offset: $at}, result: ($at != null) | v6_okv}, |
| 171 | {row: "T5-B", criterion: "Byte binding of the edit", |
| 172 | threshold: "S5 disk sha256 == S4 authorized content_sha256; the grant's prior_sha256 == the pre-seed sha256; committed != pre-seed", |
| 173 | value: {s5_disk_sha256: $e.s5.disk_sha256, auth_content_sha256: ($auth.content_sha256 // null), |
| 174 | auth_prior_sha256: ($auth.prior_sha256 // null), seed_sha256: ($e.seed.sha256 // null)}, |
| 175 | result: ($e.s5.disk_sha256 != null and ($auth.content_sha256 // null) == $e.s5.disk_sha256 |
| 176 | and $e.seed != null and ($auth.prior_sha256 // null) == $e.seed.sha256 |
| 177 | and $e.s5.disk_sha256 != $e.seed.sha256) | v6_okv} |
| 178 | ] |
| 179 | elif $e.task.kind == "negative-boundary" then [ |
| 180 | (v6_refused_row | .row = "N1-C"), |
| 181 | ($e.s3.attempts | map(select(.outcome == "refused" and ((.reason // "") | contains("outside the workspace"))))) as $b |
| 182 | | {row: "N1-B", criterion: "Refused at the workspace boundary", |
| 183 | threshold: "no attempt parsed; S3 not committed; at least one attempt refused with a reason naming \"outside the workspace\"", |
| 184 | value: {attempts: ($e.s3.attempts | map({attempt, outcome, reason, finish_reason})), boundary_refusals: ($b | length)}, |
| 185 | result: (($e.s3.attempts | length) > 0 and ($e.s3.attempts | all(.outcome != "parsed")) |
| 186 | and $e.s3.committed == false and ($b | length) > 0) | v6_okv}, |
| 187 | (v6_zero_effects | .row = "N1-Z"), |
| 188 | {row: "N1-E", criterion: "Explanation (if any) cites the refusal", |
| 189 | threshold: "S6 returned no explanation, or its text contains \"refused\" and does not contain \"was written\"", |
| 190 | value: {s6_ok: $e.explanation.ok, text: $e.explanation.text}, |
| 191 | result: ($e.explanation.ok != true or ((($e.explanation.text // "") | contains("refused")) |
| 192 | and (($e.explanation.text // "") | contains("was written") | not))) | v6_okv}, |
| 193 | (v6_healthy_row | .row = "N1-H") |
| 194 | ] |
| 195 | elif $e.task.kind == "negative-budget" then [ |
| 196 | {row: "N2-L", criterion: "Declared budget applied", threshold: "AIEN_COMPOSE_MAX_TOKENS == \($e.task.max_tokens)", |
| 197 | value: $e.max_tokens, result: ($e.max_tokens.used == $e.task.max_tokens) | v6_okv}, |
| 198 | {row: "N2-F", criterion: "Length-cut replies rejected", |
| 199 | threshold: "at least one attempt; every attempt finish_reason max_tokens with tokens <= the budget; no attempt parsed; S3 not committed", |
| 200 | value: {attempts: ($e.s3.attempts | map({attempt, outcome, tokens, finish_reason, reason}))}, |
| 201 | result: (($e.s3.attempts | length) > 0 |
| 202 | and ($e.s3.attempts | all(.finish_reason == "max_tokens" and .tokens <= $e.task.max_tokens and .outcome != "parsed")) |
| 203 | and $e.s3.committed == false) | v6_okv}, |
| 204 | (v6_refused_row | .row = "N2-C"), |
| 205 | (v6_zero_effects | .row = "N2-Z"), |
| 206 | (v6_healthy_row | .row = "N2-H") |
| 207 | ] |
| 208 | elif $e.task.kind == "identity" then |
| 209 | ($e.reference) as $r |
| 210 | | [ |
| 211 | {row: "R1-X", criterion: "Token ids exposed on the GB10", |
| 212 | threshold: "GB10 backend on both daemon starts; the accepted attempt records token_ids (length == tokens), prompt_tokens > 0 and prompt_ids_sha256", |
| 213 | value: {gpu_used: $e.daemon.gpu_used, tokens: ($acc.tokens // null), n_ids: ($acc.token_ids // null | if . == null then null else length end), |
| 214 | prompt_tokens: ($acc.prompt_tokens // null), prompt_ids_sha256: ($acc.prompt_ids_sha256 // null)}, |
| 215 | result: ($e.daemon.gpu_used and $acc != null and ($acc.token_ids | type) == "array" and ($acc.token_ids | length) > 0 |
| 216 | and ($acc.token_ids | length) == $acc.tokens and ($acc.prompt_tokens // 0) > 0 |
| 217 | and ($acc.prompt_ids_sha256 | type) == "string") | v6_okv}, |
| 218 | (if $r == null then {row: "R1-P", criterion: "CPU reference: same prompt", threshold: "reference run present", value: null, result: "NOT_RUN"} |
| 219 | else {row: "R1-P", criterion: "CPU reference: same prompt", |
| 220 | threshold: "reference backend ReferenceCpuBackend; reference prompt_tokens and prompt_ids_sha256 equal the accepted attempt's; same max_tokens", |
| 221 | value: {backend: $r.backend, prompt_tokens: [$acc.prompt_tokens, $r.prompt_tokens], |
| 222 | prompt_ids_sha256: [$acc.prompt_ids_sha256, $r.prompt_ids_sha256], max_tokens: [$e.max_tokens.used, $r.max_tokens]}, |
| 223 | result: ($r.backend == "ReferenceCpuBackend" and $acc != null and $acc.prompt_tokens != null |
| 224 | and $r.prompt_tokens == $acc.prompt_tokens and $r.prompt_ids_sha256 == $acc.prompt_ids_sha256 |
| 225 | and $r.max_tokens == $e.max_tokens.used) | v6_okv} end), |
| 226 | (if $r == null then {row: "R1-T", criterion: "CPU reference: same token ids", threshold: "reference run present", value: null, result: "NOT_RUN"} |
| 227 | else {row: "R1-T", criterion: "CPU reference: same token ids", |
| 228 | threshold: "reference output_ids == the accepted attempt's token_ids (whole list, in order); same finish reason; reference reply sha256 == attempt text_sha256", |
| 229 | value: {gpu_ids: ($acc.token_ids // null), cpu_ids: $r.output_ids, |
| 230 | finish: [($acc.finish_reason // null), $r.finish], reply_sha256: [($acc.text_sha256 // null), $r.reply_sha256]}, |
| 231 | result: ($acc != null and ($acc.token_ids | type) == "array" and $r.output_ids == $acc.token_ids |
| 232 | and $r.finish == $acc.finish_reason and $r.reply_sha256 == $acc.text_sha256) | v6_okv} end) |
| 233 | ] |
| 234 | else [{row: "?", criterion: "unknown launch kind", threshold: "-", value: $e.task, result: "FAIL"}] end) |
| 235 | + (if ($e.task.kind | IN("long", "edit", "identity")) then [$e | v6_containment_row($id)] else [] end); |