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
omega-mv / tools / physics0 / pd1-convert / extract.sh
| 1 | #!/bin/sh |
| 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 | # extract.sh: read the preserved GB10 campaign evidence (read-only) and print the |
| 18 | # label-free TSV that pd1_convert consumes. Nothing is synthesised: a field that |
| 19 | # was not recorded is emitted as the "not recorded" sentinel. |
| 20 | # |
| 21 | # The join tables below are the ONLY place a structural label (arm, directory |
| 22 | # prefix, variant name) is turned into an opaque knob value. They are the PD-1 |
| 23 | # answer key for knob q0 and must never be shipped to the learner lane; this |
| 24 | # script lives with the harness, not with the learner. |
| 25 | # |
| 26 | # Column meaning (opaque to the learner): |
| 27 | # src campaign id: 1 per-launch probe, 2 gate A/B under load, 3 lifecycle A/B, 4 single-trial variants |
| 28 | # q0 knob derived from arm / directory prefix (0 or 1; 255 not recorded) |
| 29 | # q1 variant ordinal where a variant field exists (255 otherwise) |
| 30 | # q2 q3 not recorded in any campaign (255) |
| 31 | # q4 ordinal position inside the run series (launch index or rep number) |
| 32 | # q5 not recorded (INT64_MIN) |
| 33 | # r0 latency in micro units (ms * 1000), -1 if not recorded |
| 34 | # r1 outcome class: 0 ok, 1 fail |
| 35 | # cov host load average * 1000 at campaign start when recorded, else 4294967295 |
| 36 | set -eu |
| 37 | EV=${EV:-$HOME/workspace/evidence-out} |
| 38 | NA8=255; NA32=4294967295; NA64=-9223372036854775808 |
| 39 | |
| 40 | # ---- src 1: E1-STALL-PROBE, per-launch marker2_ms in launch order (stderr) ---- |
| 41 | P=$EV/E1-STALL-PROBE/20261002T193710Z |
| 42 | for arm in A B; do |
| 43 | case $arm in A) q0=1;; B) q0=0;; esac # join: arm A = default allocation, arm B = alternative build define |
| 44 | grep '^GB10_PROBE ' "$P/arm_$arm.stderr" | awk -v q0=$q0 -v na8=$NA8 -v na32=$NA32 -v na64=$NA64 ' |
| 45 | { for (i=1;i<=NF;i++) if ($i ~ /^marker2_ms=/) { split($i,a,"="); ms=a[2] } |
| 46 | printf "1\t%d\t%d\t%d\t%d\t%d\t%s\t%d\t0\t%s\n", q0, na8, na8, na8, NR-1, na64, int(ms*1000+0.5), na32 }' |
| 47 | done |
| 48 | |
| 49 | # ---- src 2: M18-UNCACHED A/B, per-run rc under a documented host load ---- |
| 50 | M=$EV/M18-UNCACHED-20261003 |
| 51 | load=$(grep -m1 -oE 'load average: [0-9.]+' "$M/campaign.txt" | awk '{print int($3*1000+0.5)}') |
| 52 | [ -n "$load" ] || load=$NA32 |
| 53 | for d in "$M"/baseline-m18-L* "$M"/fix-m18-L*; do |
| 54 | case $(basename "$d") in baseline-*) q0=1;; fix-*) q0=0;; esac # join: directory prefix |
| 55 | awk -v q0=$q0 -v na8=$NA8 -v na64=$NA64 -v cov=$load ' |
| 56 | /^rep=/ { rep=$1; sub("rep=","",rep); rc=$NF; sub("rc=","",rc); cls=(rc=="0")?0:1 |
| 57 | printf "2\t%d\t%d\t%d\t%d\t%d\t%s\t-1\t%d\t%s\n", q0, na8, na8, na8, rep, na64, cls, cov }' "$d/exit-codes.txt" |
| 58 | done |
| 59 | |
| 60 | # ---- src 3: WORLD-UNCACHED, per-run rc and wait_ms where a gate printed it ---- |
| 61 | W=$EV/WORLD-UNCACHED-20261003 |
| 62 | for d in "$W"/red-001 "$W"/green-001 "$W"/baseline-m18-* "$W"/fix-m18-*; do |
| 63 | [ -f "$d/exit-codes.txt" ] || continue |
| 64 | case $(basename "$d") in red-*|baseline-*) q0=1;; green-*|fix-*) q0=0;; esac # join: directory prefix |
| 65 | ms=$(cat "$d"/*.log 2>/dev/null | grep -m1 -oE 'wait_ms=[0-9.]+' | cut -d= -f2 || true) |
| 66 | if [ -n "$ms" ]; then r0=$(awk -v m="$ms" 'BEGIN{print int(m*1000+0.5)}'); else r0=-1; fi |
| 67 | awk -v q0=$q0 -v na8=$NA8 -v na64=$NA64 -v na32=$NA32 -v r0=$r0 ' |
| 68 | /^rep=/ { rep=$1; sub("rep=","",rep); rc=$NF; sub("rc=","",rc); cls=(rc=="0")?0:1 |
| 69 | printf "3\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%d\t%s\n", q0, na8, na8, na8, rep, na64, (rep==1?r0:-1), cls, na32 }' "$d/exit-codes.txt" |
| 70 | done |
| 71 | |
| 72 | # ---- src 4: CHIPWAIT-ASTRA result.json, one trial per variant; allocation attribute NOT recorded ---- |
| 73 | A=$EV/CHIPWAIT-ASTRA-20261003/result.json |
| 74 | grep -oE '"variant":"[a-z0-9]+","result":"[A-Z]+"' "$A" | awk -F'"' -v na8=$NA8 -v na64=$NA64 -v na32=$NA32 ' |
| 75 | { v=$4; res=$8; cls=(res=="PASS")?0:1 |
| 76 | printf "4\t%d\t%d\t%d\t%d\t%d\t%s\t-1\t%d\t%s\n", na8, NR-1, na8, na8, NR, na64, cls, na32 }' |