1 #!/bin/sh2 # 09_bundles: every directory under plugins/ is a bundle.3 #4 # The bundle is the unit of this repository (spec section 5). A directory that5 # is not a bundle looks like one in a listing, so this step refuses it before a6 # person or an agent builds on the mistake. The checks are the five parts, the7 # card, the ignore rule, the absence of tracked weights, and the digest.8 set -eu9 10 root=$(cd "$(dirname "$0")/../../.." && pwd)11 cd "$root"12 13 target=${CARGO_TARGET_DIR:-$root/target}14 case "$target" in15 /*) ;;16 *) target=$root/$target ;;17 esac18 export CARGO_TARGET_DIR=$target19 cli=$target/debug/inf3r20 if [ ! -x "$cli" ]; then21 cargo build -q -p inf3r-cli22 fi23 24 fail() {25 printf 'bundles: %s\n' "$1" >&226 exit 127 }28 29 # There is no central engine registry or shared engine base. A bundle that30 # needs a container image owns its recipe beside its manifest.31 [ ! -e docker/engines.map ] || fail "docker/engines.map is a central engine registry"32 [ ! -e docker/engines ] || fail "docker/engines holds shared engine bases"33 [ ! -e docker/bundle.Dockerfile ] || fail "docker/bundle.Dockerfile assumes one shared build shape"34 35 # `plugins/fixtures` is not a bundle: it speaks the raw protocol from Python to36 # prove that no SDK is needed. It is excluded from the workspace for that reason.37 for dir in plugins/*/*/; do38 dir=${dir%/}39 case "$dir" in40 plugins/fixtures/*) continue ;;41 esac42 43 [ -f "$dir/Cargo.toml" ] || fail "$dir is not a package"44 if [ -e "$dir/Dockerfile" ] &&45 grep -nE 'inf3r/engine-|docker/engines' "$dir/Dockerfile" | grep -q .; then46 fail "$dir depends on a shared engine base or lookup"47 fi48 for part in bundle.toml BUNDLE.md target.toml models model engine goldens; do49 [ -e "$dir/$part" ] || fail "$dir has no $part"50 done51 ls "$dir/models"/*.toml >/dev/null 2>&1 || fail "$dir has no models/*.toml"52 ls "$dir/goldens"/*.json >/dev/null 2>&1 || fail "$dir has no goldens/*.json"53 54 for key in model target engine run; do55 grep -q "^$key:" "$dir/BUNDLE.md" ||56 fail "$dir/BUNDLE.md has no '$key:' line"57 done58 59 git check-ignore -q "$dir/model/weights" ||60 fail "$dir/model is not ignored by git"61 if git ls-files "$dir/model" | grep -vE '/(\.gitkeep|\.gitignore)$' | grep -q .; then62 fail "$dir tracks a file under model/"63 fi64 65 "$cli" bundle verify "$dir" >/dev/null ||66 fail "$dir did not verify (run: inf3r bundle verify $dir)"67 68 # R9: the in-repo fixtures run their own golden on this host. An external69 # engine is never executed on the CI host; its image pipeline owns the70 # container gate and `08_image.sh` proves the mock gate.71 case "$dir" in72 plugins/mock/*|plugins/toy/*|plugins/echo/*)73 cargo test -q --manifest-path "$dir/Cargo.toml" --test goldens >/dev/null ||74 fail "$dir did not pass its recorded golden"75 ;;76 *)77 printf 'bundle %s: external engine; host golden skipped\n' "$dir"78 ;;79 esac80 printf 'bundle %s: ok\n' "$dir"81 done82 83 # A weight file is content. It is never in git, whatever a bundle's local rule84 # says. The check is after the loop so that one line names every offender.85 tracked=$(git ls-files plugins | grep -E '\.(gguf|safetensors|bin)$' || true)86 if [ -n "$tracked" ]; then87 printf '%s\n' "$tracked" >&288 fail "a weight file is tracked under plugins/"89 fi90 91 printf 'bundles: ok\n'