interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / exp445 / check_weights.sh

47 lines · 2587 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# tools/exp445/check_weights.sh <config> <run dir> -- the operator's weight and server check, recorded with
18# the run (omega#445, docs/one_layer/EXP445_PROTOCOL.md section 9). Writes
19# <run dir>/weights.check sha256sum -c of the config's frozen hash list (PARAMS config.<X>.weights),
20# run in PARAMS models_root
21# <run dir>/server.json the server's identity: GET <config base_url>/models
22# Starts and stops nothing. Exit 0 only when every listed file is OK and the server lists the config's
23# frozen model id; run.sh refuses to generate and score.sh refuses the run otherwise. EXP445_PARAMS
24# names another PARAMS file (tests only).
25set -euo pipefail
26HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27ROOT="$(cd "$HERE/../.." && pwd)"
28die() { echo "check_weights.sh: $*" >&2; exit 2; }
29PARAMS="${EXP445_PARAMS:-$HERE/PARAMS}"
30[ -f "$PARAMS" ] || die "no PARAMS file $PARAMS"
31kv() { awk -F= -v k="$1" '$1 == k { print substr($0, length(k) + 2); exit }' "$PARAMS"; }
32[ $# -eq 2 ] || die "usage: check_weights.sh <config> <run dir>"
33c="$1" o="$2"
34list="$(kv "config.$c.weights")" root="$(kv models_root)" base="$(kv "config.$c.base_url")" model="$(kv "config.$c.model")"
35[ -n "$list" ] && [ -n "$root" ] && [ -n "$base" ] && [ -n "$model" ] || die "config $c (weights, models_root, base_url, model) is not named in $PARAMS"
36case "$list" in /*) ;; *) list="$ROOT/$list" ;; esac
37[ -s "$list" ] || die "no hash list $list"
38. "$HERE/reader.sh"
39mkdir -p "$o"
40(cd "$root" && sha256sum -c "$list") > "$o/weights.check" 2>&1 || true
41curl -sS -m 30 "$base/models" > "$o/server.json" || true
42if weights_ok "$o" "$list" "$model"; then
43 echo "check_weights.sh: config $c: $(wc -l < "$o/weights.check") files OK in $root; $base/models lists $model"
44else
45 grep -v ': OK$' "$o/weights.check" | head -5 >&2 || true
46 die "config $c: weights or server check FAILED (see $o/weights.check, $o/server.json)"
47fi