#!/bin/sh set -eu if [ "$#" -ne 5 ] && [ "$#" -ne 6 ]; then echo "usage: $0 AT_8191 AT_8192 AT_8193 AT_65536 AT_131072 [OUTPUT_JSON]" >&2 exit 2 fi at8191=$1 at8192=$2 at8193=$3 at65536=$4 at131072=$5 output=${6:-} for input in "$at8191" "$at8192" "$at8193" "$at65536" "$at131072"; do if [ ! -r "$input" ]; then echo "gem: online-merge boundary input is not readable: $input" >&2 exit 2 fi done if [ -n "$output" ] && [ -e "$output" ]; then echo "gem: refusing to overwrite online-merge boundary output: $output" >&2 exit 2 fi sha8191=$(shasum -a 256 "$at8191" | awk '{print $1}') sha8192=$(shasum -a 256 "$at8192" | awk '{print $1}') sha8193=$(shasum -a 256 "$at8193" | awk '{print $1}') sha65536=$(shasum -a 256 "$at65536" | awk '{print $1}') sha131072=$(shasum -a 256 "$at131072" | awk '{print $1}') analyze() { jq -n --arg path8191 "$at8191" --arg sha8191 "$sha8191" \ --arg path8192 "$at8192" --arg sha8192 "$sha8192" \ --arg path8193 "$at8193" --arg sha8193 "$sha8193" \ --arg path65536 "$at65536" --arg sha65536 "$sha65536" \ --arg path131072 "$at131072" --arg sha131072 "$sha131072" \ --slurpfile at8191 "$at8191" --slurpfile at8192 "$at8192" \ --slurpfile at8193 "$at8193" --slurpfile at65536 "$at65536" \ --slurpfile at131072 "$at131072" ' def valid($v; $tokens): $v.schema_version == 1 and $v.engine == "gem-native-cpu" and $v.workload == "d512-online-softmax-partition-differential" and $v.tokens == $tokens and $v.value_dimension == 512 and $v.partitions == 32 and $v.seed == 1 and $v.reference == "independent-double-direct-softmax" and $v.finite == true and $v.deterministic == true and $v.correlation_floor == 0.9999 and $v.nmse_ceiling == 0.0001 and $v.correlation >= $v.correlation_floor and $v.nmse <= $v.nmse_ceiling and ($v.maximum_absolute_error | type) == "number" and $v.maximum_absolute_error >= 0 and $v.passed == true and ($v.candidate_hash | test("^[0-9a-f]{16}$")) and $v.candidate_hash == $v.repeat_hash; $at8191[0] as $a | $at8192[0] as $b | $at8193[0] as $c | $at65536[0] as $d | $at131072[0] as $e | if valid($a; 8191) and valid($b; 8192) and valid($c; 8193) and valid($d; 65536) and valid($e; 131072) then { schema_version: 1, engine: "gem-native-cpu", workload: "d512-online-softmax-cpu-gate-audit", fixed_controls: { tokens: [8191, 8192, 8193, 65536, 131072], value_dimension: 512, partitions: 32, seed: 1, correlation_floor: 0.9999, nmse_ceiling: 0.0001 }, inputs: { at_8191: {path: $path8191, sha256: $sha8191}, at_8192: {path: $path8192, sha256: $sha8192}, at_8193: {path: $path8193, sha256: $sha8193}, at_65536: {path: $path65536, sha256: $sha65536}, at_131072: {path: $path131072, sha256: $sha131072} }, results: { at_8191: {correlation: $a.correlation, nmse: $a.nmse, maximum_absolute_error: $a.maximum_absolute_error}, at_8192: {correlation: $b.correlation, nmse: $b.nmse, maximum_absolute_error: $b.maximum_absolute_error}, at_8193: {correlation: $c.correlation, nmse: $c.nmse, maximum_absolute_error: $c.maximum_absolute_error}, at_65536: {correlation: $d.correlation, nmse: $d.nmse, maximum_absolute_error: $d.maximum_absolute_error}, at_131072: {correlation: $e.correlation, nmse: $e.nmse, maximum_absolute_error: $e.maximum_absolute_error} }, screening: { passed: true, promotion_eligible: false, interpretation: "CPU partial/merge algebra passes the future dispatch boundary and long tails; a Metal candidate differential and greedy continuation gate remain" } } else error("online-merge inputs fail the exact CPU gate contract") end' } if [ -n "$output" ]; then analyze > "$output" else analyze fi