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 / research / atemporal / at1 / integration / engine_shim.sh

64 lines · 3192 bytes Raw Blame History
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# AT-1 Agent 5: engine command for the evaluator's run.sh template '<engine> {case} {out}'.
18# sh engine_shim.sh <case-file> <out-file>
19# Runs the oracle on the case, writes the provenance file (the engine reads no clock), then
20# at1-model result <case> <oracle-record|none> <provenance>
21# which splices every reference_* line of the record in values-block order (charter reading (c))
22# and writes the complete AT1_RESULT_V1 file to <out-file>.
23# Exit 0 written; 2 case refused (the engine's own `AT1_CASE_REFUSED <code>` line on stderr, nothing
24# written); 1 any other failure. The case is parsed by the engine before the record and the
25# provenance are opened, so an oracle failure can never mask an engine refusal.
26# An oracle failure other than a refusal (exit 2) is copied to stderr; the engine then runs with
27# record "none" and its own verdict decides.
28# Environment (set by run.sh):
29# AT1_MODEL_BIN AT1_ORACLE_BIN executables
30# AT1_PROV_STATIC file with the provenance lines source_repo .. host, in contract order
31# AT1_COMP_DIR optional: keep the oracle record the engine consumed, as <class>_<name>.oracle
32# (first write wins, so the evaluator's T9 rerun cannot replace it)
33set -u
34if [ $# -ne 2 ]; then echo "usage: engine_shim.sh <case-file> <out-file>" >&2; exit 1; fi
35case_file=$1
36out_file=$2
37for v in AT1_MODEL_BIN AT1_ORACLE_BIN AT1_PROV_STATIC; do
38 eval "val=\${$v:-}"
39 if [ -z "$val" ]; then echo "engine_shim.sh: $v is not set" >&2; exit 1; fi
40done
41tmp=$(mktemp -d "${TMPDIR:-/tmp}/at1es.XXXXXX") || exit 1
42trap 'rm -rf "$tmp"' EXIT
43started=$(date -u +%Y-%m-%dT%H:%M:%SZ)
44rec=none
45"$AT1_ORACLE_BIN" emit "$case_file" -o "$tmp/oracle" > /dev/null 2> "$tmp/oracle.err"; orc=$?
46if [ $orc -eq 0 ]; then rec="$tmp/oracle"; fi
47finished=$(date -u +%Y-%m-%dT%H:%M:%SZ)
48{
49 cat "$AT1_PROV_STATIC"
50 echo "run_started_utc $started"
51 echo "run_finished_utc $finished"
52} > "$tmp/prov"
53"$AT1_MODEL_BIN" result "$case_file" "$rec" "$tmp/prov" > "$tmp/result" 2> "$tmp/err"; rc=$?
54if [ $rc -ne 0 ]; then cat "$tmp/err" >&2; [ $rc -eq 2 ] && exit 2; exit 1; fi
55if [ $orc -ne 0 ] && [ $orc -ne 2 ]; then
56 echo "engine_shim.sh: oracle exit $orc on $case_file (record none):" >&2
57 cat "$tmp/oracle.err" >&2
58fi
59if [ -n "${AT1_COMP_DIR:-}" ] && [ "$rec" != none ]; then
60 mkdir -p "$AT1_COMP_DIR" || exit 1
61 comp="$AT1_COMP_DIR/$(basename "$(dirname "$case_file")")_$(basename "$case_file" .case).oracle"
62 [ -e "$comp" ] || cp "$rec" "$comp" || exit 1
63fi
64cp "$tmp/result" "$out_file"