interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-sovereign-core-mv / docs / campaigns / next-phase-1 / rows-v6.jq

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