Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/tools/aien-local-ci/crumb-shim.sh # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / tools / aien-local-ci / crumb-shim.sh` 90 lines ยท 4119 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 # crumb (operator shim, installed as ~/.local/bin/crumb on the Spark). 18 # 19 # Select authority from the target repository's origin/main, never from its 20 # working tree or HEAD. A candidate may alter crumb.lock or tools/crumb but 21 # cannot cause the operator shim to build or execute those sources. 22 # 23 # The trusted main's crumb.lock pins an ancestor of aien-architecture 24 # origin/main. Only the architecture clone itself may use its own main's tool. 25 # Other trees use the installed sandbox tool. No failed pin falls back. 26 # CRUMB_SHIM_WHICH=1 prints " " without running the tool. 27 # Location overrides are for offline fixtures; operator installs use trusted 28 # clone/cache/sandbox paths. 29 set -u 30 SANDBOX=${CRUMB_SANDBOX_TOOL:-/usr/local/bin/crumb} 31 CACHE=${CRUMB_TOOL_CACHE:-$HOME/.local/state/aien-local-ci/crumb-tools} 32 ARCH=${CRUMB_ARCH_CLONE:-$HOME/workspace/pipeline/clones/aien-architecture} 33 34 die() { echo "crumb (shim): $*" >&2; exit 97; } 35 36 target=. 37 for a in "$@"; do 38 case $a in -*) continue ;; esac 39 if [ -e "$a" ]; then target=$a; break; fi 40 done 41 [ -d "$target" ] || target=$(dirname -- "$target") 42 root=$(git -C "$target" rev-parse --show-toplevel 2>/dev/null || true) 43 arch_root=$(git -C "$ARCH" rev-parse --show-toplevel 2>/dev/null || true) 44 45 build_into() { # build_into 46 local final=$1 src=$2 tmpb 47 mkdir -p "$(dirname -- "$final")" || die "cannot create $(dirname -- "$final")" 48 make -s -C "$src" crumb >&2 || die "make crumb failed in $src" 49 tmpb=$(mktemp "$(dirname -- "$final")/.crumb.XXXXXX") || die "mktemp" 50 cp "$src/crumb" "$tmpb" && chmod 0755 "$tmpb" && mv -f "$tmpb" "$final" || { rm -f "$tmpb"; die "install $final"; } 51 } 52 53 archive_tool() { # archive_tool 54 local w 55 [ -x "$2" ] && return 56 w=$(mktemp -d) || die mktemp 57 trap 'rm -rf "$w"' EXIT 58 git -C "$ARCH" archive "$1" tools/crumb | tar -x -C "$w" || die "git archive $1 tools/crumb" 59 [ -f "$w/tools/crumb/Makefile" ] && [ -f "$w/tools/crumb/crumb.c" ] || die "missing tools/crumb at $1" 60 build_into "$2" "$w/tools/crumb" 61 rm -rf "$w"; trap - EXIT 62 } 63 64 tool=""; rule="" 65 if [ -n "$root" ]; then 66 main=$(git -C "$root" rev-parse --verify -q 'refs/remotes/origin/main^{commit}') \ 67 || die "no trusted origin/main in $root" 68 if lock=$(git -C "$root" show "$main:crumb.lock" 2>/dev/null); then 69 pin=$(printf '%s' "$lock" | tr -d '[:space:]' | tr 'A-F' 'a-f') 70 [[ $pin =~ ^[0-9a-f]{40}$ ]] || die "origin/main crumb.lock is not one 40-hex commit" 71 [ -n "$arch_root" ] || die "no architecture clone at $ARCH" 72 git -C "$ARCH" merge-base --is-ancestor "$pin" refs/remotes/origin/main 2>/dev/null \ 73 || die "origin/main crumb.lock pin $pin is not in architecture origin/main ancestry" 74 tool=$CACHE/$pin/crumb; rule="crumb.lock:$pin" 75 archive_tool "$pin" "$tool" 76 elif [ -n "$arch_root" ] && [ "$root" = "$arch_root" ]; then 77 git -C "$ARCH" cat-file -e "$main:tools/crumb/crumb.c" 2>/dev/null \ 78 && git -C "$ARCH" cat-file -e "$main:tools/crumb/Makefile" 2>/dev/null \ 79 || die "architecture origin/main has no tools/crumb source" 80 tool=$CACHE/main-$main/crumb; rule="architecture-main:$main" 81 archive_tool "$main" "$tool" 82 fi 83 fi 84 if [ -z "$tool" ]; then 85 tool=$SANDBOX; rule=sandbox 86 [ -x "$tool" ] || die "sandbox tool $tool is missing" 87 fi 88 89 if [ "${CRUMB_SHIM_WHICH:-}" = 1 ]; then printf '%s %s %s\n' "$tool" "$rule" "${root:--}"; exit 0; fi 90 exec "$tool" "$@"