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 / open-model-qwen3 / v5-rows.sh

101 lines · 6262 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# OPEN-MODEL-QWEN3 v5 (ACCEPTANCE-v5.md Section 3, DRAFT, NOT FROZEN): the extra rows of one launch, computed
18# from the run directory beside the v8 receipt. Derived from v4-rows.sh; shell + jq only. Usage:
19# v5-rows.sh RUN_ROOT LAUNCH_ID TASKS.json OUT_DIR RECEIPT_BASENAME LAUNCH_RECORD|- [FROZEN.json]
20# LAUNCH_RECORD is the wrapper's <id>.launch-v5.json (wall time, memory before the part, build pins); "-" = none.
21# FROZEN defaults to frozen-v5.json beside this script.
22# Writes OUT_DIR/<sha256 of content>.v5rows.json (never edited afterwards) and prints one scoring-v5 result line
23# per row: {row: "<id>/<row>", rep: 1, verdict, receipt}. The saved file, the source file and the seed are hashed
24# or read here, after the run, not taken from the runtime's own report.
25set -eu
26R=${1:?RUN_ROOT} ID=${2:?LAUNCH_ID} TASKS=${3:?TASKS} OUT=${4:?OUT_DIR} REC=${5:?RECEIPT} LREC=${6:?LAUNCH_RECORD}
27HERE=$(cd "$(dirname "$0")" && pwd)
28FROZEN=${7:-$HERE/frozen-v5.json}
29# Every path is made absolute, because the row module is read with the working directory set to HERE (below).
30abs() { case $1 in /* | -) printf '%s' "$1" ;; *) printf '%s/%s' "$PWD" "$1" ;; esac; }
31R=$(abs "$R") TASKS=$(abs "$TASKS") OUT=$(abs "$OUT") LREC=$(abs "$LREC") FROZEN=$(abs "$FROZEN")
32S=$R/steps
33task=$(jq -c --arg id "$ID" '.tasks[] | select(.id == $id)' "$TASKS")
34[ -n "$task" ] || { echo "v5-rows: launch $ID not in $TASKS" >&2; exit 4; }
35j() { if [ -s "$1" ]; then jq -c . "$1" 2>/dev/null || echo null; else echo null; fi; }
36ws=$(cd "$R/ws" && pwd -P)
37committed='{"path_rel":null,"text":null,"file_sha256":null}'
38s5p=$(jq -r '.path // empty' "$S/S5.json" 2>/dev/null || true)
39if [ -n "$s5p" ] && [ -f "$s5p" ]; then
40 real=$(realpath -e "$s5p")
41 case "$real" in "$ws"/*)
42 committed=$(jq -n --arg p "${real#"$ws"/}" --rawfile t "$real" --arg h "$(sha256sum "$real" | cut -d' ' -f1)" \
43 '{path_rel: $p, text: $t, file_sha256: $h}') ;;
44 esac
45fi
46seed_text=null
47if [ "$(jq -r '.kind' <<<"$task")" = edit ]; then
48 sd=$(jq -r '.seed // empty' <<<"$task"); dest=$(jq -r '.destination // empty' <<<"$task")
49 [ -n "$sd" ] && [ -f "$HERE/$sd/$dest" ] && seed_text=$(jq -n --rawfile t "$HERE/$sd/$dest" '$t')
50fi
51source_now=null
52sp=$(jq -r '.source.path // empty' <<<"$task")
53if [ -n "$sp" ] && [ -f "$ws/$sp" ]; then
54 source_now=$(jq -n --arg p "$sp" --arg h "$(sha256sum "$ws/$sp" | cut -d' ' -f1)" '{path: $p, sha256: $h}')
55fi
56# N1: is there anything at the requested destination, resolved against the workspace (it points outside it)?
57dest_exists=null
58if [ "$(jq -r '.kind' <<<"$task")" = negative-boundary ]; then
59 dp="$ws/$(jq -r '.destination' <<<"$task")"
60 if [ -e "$dp" ] || [ -L "$dp" ]; then dest_exists=true; else dest_exists=false; fi
61fi
62# Daemon logs, one per daemon start recorded in run.json, in that order: only the lines the rows read.
63tmp=$(mktemp "$OUT/.v5rows.XXXXXX")
64logs='[]'
65nd=$(jq '(.daemon // []) | length' "$R/run.json" 2>/dev/null || echo 0)
66for k in $(seq 1 "$nd"); do
67 f=$R/daemon-$k.log
68 if [ -f "$f" ]; then
69 sed 's/\x1b\[[0-9;]*m//g; s/^[[:space:]]*//' "$f" >"$tmp"
70 l=$(jq -n --arg n "daemon-$k.log" --rawfile c "$tmp" '($c | split("\n")) as $L
71 | {name: $n, strict: [$L[] | select(startswith("STRICT "))], op_reports: [$L[] | select(startswith("OP_REPORT "))],
72 shards: [$L[] | select(startswith("CHECKPOINT_SHARDS "))], violations: ([$L[] | select(contains("STRICT_REAL_MODEL_VIOLATION"))] | length)}')
73 else
74 l=$(jq -n --arg n "daemon-$k.log" '{name: $n, missing: true, strict: [], op_reports: [], shards: [], violations: 0}')
75 fi
76 logs=$(jq -c --argjson l "$l" '. + [$l]' <<<"$logs")
77done
78launch=null; [ "$LREC" != - ] && launch=$(j "$LREC")
79mods=$(cat "$HERE/rows-oq3-v3.jq" "$HERE/rows-oq3-v4.jq" "$HERE/rows-oq3-v5.jq" | sha256sum | cut -d' ' -f1)
80run=$(j "$R/run.json")
81# jq looks for a top-level include in the working directory before -L, so a stray rows-oq3-v5.jq where the caller stands
82# would be used instead of this one. Read the module from HERE only.
83cd "$HERE"
84jq -L "$HERE" -n --argjson task "$task" --argjson report "$(j "$R/s3-report.json")" --argjson s5 "$(j "$S/S5.json")" \
85 --argjson s8 "$(j "$S/S8.json")" --argjson pre "$(j "$S/pre-restart-recall.json")" --argjson s3 "$(j "$S/S3.json")" \
86 --argjson committed "$committed" --argjson seed_text "$seed_text" --argjson source_now "$source_now" \
87 --argjson run "$run" --argjson logs "$logs" --argjson dest_exists "$dest_exists" --argjson launch "$launch" \
88 --argjson frozen "$(j "$FROZEN")" --arg rec "$REC" --arg mod "$mods" \
89 'include "rows-oq3-v5";
90 def j2: (try fromjson catch null);
91 {task: $task, daemon: ($run.daemon // null), report: $report, s5: ($s5 // {}), committed: $committed, seed_text: $seed_text, source_now: $source_now,
92 auths: (($s8.authorizations // []) | map((.text // "" | j2) + {id, verified})),
93 run_steps: ($run.steps // null), containment: ($run.containment // null), constraint_text: ($run.constraint_text // null),
94 s3_step: (if $s3 == null then null else {ok: $s3.ok, error: $s3.error} end),
95 recall_pre: $pre, recall_s8: $s8, host: (($s8.recall.host // []) | map({id, note, verified, text})),
96 logs: $logs, dest_exists: $dest_exists, launch: $launch, frozen: $frozen} as $ev
97 | {launch: $task.id, receipt: $rec, rows_modules_sha256: $mod, rows: ($ev | v5_rows)}' >"$tmp"
98h=$(sha256sum "$tmp" | cut -d' ' -f1)
99mv "$tmp" "$OUT/$h.v5rows.json"
100jq -c --arg id "$ID" --arg rec "$REC" --arg f "$h.v5rows.json" \
101 '.rows[] | {row: ($id + "/" + .row), rep: 1, verdict: .result, receipt: $rec, extra_rows_file: $f}' "$OUT/$h.v5rows.json"