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 / calibration / scripts / evaluator_env.sh
| 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 | # Turing calibration (CAL-0 / EXP-001): Evaluator Environment. |
| 18 | # |
| 19 | # usage: evaluator_env.sh --frozen DIR --sealed DIR --out DIR [--ro DIR]... -- COMMAND [ARG...] |
| 20 | # |
| 21 | # --frozen DIR the frozen evaluation tree: a clean export of the freeze commit |
| 22 | # (candidate artifacts, reference coders, verifier, their builds). |
| 23 | # Bound READ-ONLY: nothing in the jail can alter a frozen artifact. |
| 24 | # --sealed DIR one sealed data set, ~/aien-data/turing-cal/sealed/<commit>. Read-only. |
| 25 | # --out DIR the only writable path (evaluation outputs). Must not overlap the |
| 26 | # frozen tree or the sealed data. |
| 27 | # --ro DIR extra read-only paths. Only the overlap audit uses this (to see |
| 28 | # development data next to sealed data); evaluation itself does not. |
| 29 | # |
| 30 | # The jail has no network (always), no user namespaces, a private /proc and pid |
| 31 | # space, an empty HOME and /tmp. The candidate side has no channel into it: it |
| 32 | # exposes no socket or service, and runs only after the candidate freeze. |
| 33 | # |
| 34 | # Exit code: COMMAND's exit code, or 3 when the jail refuses to start. |
| 35 | set -euo pipefail |
| 36 | here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 37 | # shellcheck source=tc_jail_lib.sh |
| 38 | . "$here/tc_jail_lib.sh" |
| 39 | |
| 40 | frozen="" sealed="" out="" |
| 41 | ros=() |
| 42 | while [ $# -gt 0 ]; do |
| 43 | case "$1" in |
| 44 | --frozen) frozen="$2"; shift 2 ;; |
| 45 | --sealed) sealed="$2"; shift 2 ;; |
| 46 | --out) out="$2"; shift 2 ;; |
| 47 | --ro) ros+=("$2"); shift 2 ;; |
| 48 | --) shift; break ;; |
| 49 | *) tc_die "unknown option '$1' (use -- before the command)" ;; |
| 50 | esac |
| 51 | done |
| 52 | [ $# -gt 0 ] || tc_die "no command given" |
| 53 | [ -n "$frozen" ] && [ -n "$sealed" ] && [ -n "$out" ] || tc_die "--frozen, --sealed and --out are required" |
| 54 | [ -d "$frozen" ] || tc_die "frozen tree '$frozen' missing" |
| 55 | [ -d "$sealed" ] || tc_die "sealed data '$sealed' missing" |
| 56 | tc_overlaps "$out" "$frozen" && tc_die "--out overlaps the frozen tree" |
| 57 | tc_overlaps "$out" "$sealed" && tc_die "--out overlaps the sealed data" |
| 58 | for d in "${ros[@]+"${ros[@]}"}"; do |
| 59 | tc_overlaps "$d" "$out" && tc_die "--ro '$d' overlaps --out" |
| 60 | done |
| 61 | mkdir -p "$out" |
| 62 | |
| 63 | tc_have_bwrap |
| 64 | tc_base_args |
| 65 | tc_ro "$frozen" |
| 66 | tc_ro "$sealed" |
| 67 | for d in "${ros[@]+"${ros[@]}"}"; do tc_ro "$d"; done |
| 68 | tc_rw "$out" |
| 69 | TC_ARGS+=(--setenv TC_ENV evaluator --chdir "$(tc_real "$out")") |
| 70 | exec "$TC_BWRAP" "${TC_ARGS[@]}" -- "$@" |