From 0a470ba1d597a149cf98ea7663a5849522c70ca6 Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Sun, 15 Nov 2026 11:07:51 -0600 Subject: [PATCH] Fix security finding acf_c817f3863320f402ac236824c42294da --- CONTRIBUTORS.md | 1 + Makefile | 23 +++-- tests/gates/run.sh | 51 ++++++---- tools/pinned_checkout.sh | 179 ++++++++++++++++++++++++++++++++++ tools/require_physics_pin.sh | 13 +-- tools/test_pinned_checkout.sh | 71 ++++++++++++++ 6 files changed, 298 insertions(+), 40 deletions(-) create mode 100755 tools/pinned_checkout.sh create mode 100755 tools/test_pinned_checkout.sh diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index aa4a7bd38..4cc6c64af 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,6 +7,7 @@ The current development method is [Human-Directed Agentic Engineering (HDAE)](RE | Model | What it did | |---|---| +| Codex | Isolated every gate dependency pin in a fresh read-only checkout copied from the locked object graph; disabled replacements and grafts; added raw commit, tree, blob, path and mode verification; strengthened Physics pin checks and added hostile-source regression controls. Static verification only. | | Grok 4.7 (via Cursor Agent) | Merged main `fd3751b31` (#1020, carrying #1045 and #1050) into #1052. The only conflict was the generated root `.crumb` (child `last_commit` stamps, the `tests` digest, and the root digest). Recompiled with the crumb.lock tool (`d0f0b95d`); `crumb verify .` current. The #525/#962 pins were left as committed: `src/checker2/c2_check.c`, `src/compiler/osc_ir.c` and `src/compiler/osc_ir.h` still hash to the SHA-256s in `ACCEPTED`. | | Claude Opus 5.5 (via omp) | #1020 (actions/cache-4.3.0 ->6.1.0): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | | Claude Opus 5.5 (via omp) | #1018 (actions/upload-artifact-4 ->7): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | diff --git a/Makefile b/Makefile index 7e1426b3b..568791067 100644 --- a/Makefile +++ b/Makefile @@ -115,14 +115,9 @@ check-physics-lock: echo "error: physics.lock not found at repo root" >&2; exit 1; \ fi; \ locked=$$(tr -d '[:space:]' < physics.lock); \ - actual=$$(git -C $(PHYSICS_DIR) rev-parse HEAD 2>/dev/null); \ - if [ -z "$$actual" ]; then \ - echo "error: could not read HEAD of PHYSICS_DIR=$(PHYSICS_DIR) (git -C $(PHYSICS_DIR) rev-parse HEAD failed)" >&2; \ - exit 1; \ - fi; \ - if [ "$$actual" != "$$locked" ]; then \ - echo "error: PHYSICS_DIR=$(PHYSICS_DIR) is at commit $$actual but physics.lock pins $$locked." >&2; \ - echo " Checkout the pinned physics commit, or override with PHYSICS_LOCK_CHECK=0." >&2; \ + if ! tools/pinned_checkout.sh verify "$(PHYSICS_DIR)" "$$locked" >/dev/null; then \ + echo "error: PHYSICS_DIR=$(PHYSICS_DIR) is not an exact worktree of physics.lock ($$locked)." >&2; \ + echo " Use an unmodified checkout at the pin, or override with PHYSICS_LOCK_CHECK=0." >&2; \ exit 1; \ fi; \ fi @@ -138,8 +133,9 @@ $(OUT_DIR)/%.o: src/%.c | $(OUT_DIR) # path for exactly these). They must be rebuilt when PHYSICS_DIR points at another tree, not only # when a file there is newer, and none may compile before check-physics-lock passes (#488). # The stamp records the resolved PHYSICS_DIR and its git HEAD and is rewritten only when that -# text changes, so an unchanged PHYSICS_DIR rebuilds nothing. Its phony prerequisite runs the -# lock check first: when the check refuses, the stamp is not made and no physics object compiles. +# text changes, so an unchanged PHYSICS_DIR rebuilds nothing. Its phony prerequisite proves the +# commit, every tree/blob and the raw worktree bytes and modes first: when that proof refuses, +# the stamp is not made and no physics object compiles. # The other objects take nothing from PHYSICS_DIR and are shared with physics-free builds # (crumbline-learner, omega, test-program-id), so they stay ungated. PHYSICS_STAMP = $(OUT_DIR)/physics.stamp @@ -260,6 +256,13 @@ test-gate14-combine: .PHONY: test-gate-physics-pin test-gate-physics-pin: tools/test_gate_physics_pin.sh + tools/test_pinned_checkout.sh + +# Host-only self-test of exact pinned-checkout materialization and verification: +# dirty sources and replace refs cannot affect output; byte, mode and extra-path mutants refuse. +.PHONY: test-pinned-checkout +test-pinned-checkout: + tools/test_pinned_checkout.sh # Host-only self-test of the E1 closure combiner (tools/e1_combine.sh): good # synthetic constituent set accepted, every hostile mutant refused. No GPU. diff --git a/tests/gates/run.sh b/tests/gates/run.sh index 0919c6231..defa7ced6 100755 --- a/tests/gates/run.sh +++ b/tests/gates/run.sh @@ -23,8 +23,10 @@ # Pinned sibling sources. The hosted jobs checked out aien-spark/physics at physics.lock, # aien-dev/aienux at aienos.lock and aien-dev/aienux at # argus.lock, as physics-src/, aienos-src/ and aienos-argus/ next to the Makefile, and exclude -# them from git status. Here the same commits are materialised under build/pins/ (build/ is -# gitignored) from the sibling local clones ../physics and ../aienos, offline. +# them from git status. Here the same commits are materialised as private, read-only checkouts +# under build/pins/ (build/ is gitignored) from the sibling clones, offline. Each invocation +# gets fresh source bytes proven against the locked commit's objects; no gate consumes a shared +# mutable dependency worktree. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" cd "$ROOT" @@ -34,35 +36,43 @@ step="${1:?usage: tests/gates/run.sh }" # at the same moment in one worktree; with one shared build/ a gate links an object another gate's # compiler is still writing (omega#511: OMEGA-M12 "undefined reference to omega_tern_*" with the # object on the link line). OUT_DIR is read by the Makefile (?=) and by every make it spawns. -# The pins stay at build/pins, shared read-only under their own lock. The directory name keeps -# only [A-Za-z0-9_.-] from the step word: "spark:test-r13-host" would put a colon in a make -# target ("multiple target patterns"). -export OUT_DIR="build/step-$(printf '%s' "$step" | tr -c 'A-Za-z0-9_.-' '-')" -mkdir -p "$OUT_DIR" +# Each invocation's pins stay in a private random directory under build/pins. The step directory +# name keeps only [A-Za-z0-9_.-] from the step word: "spark:test-r13-host" would put a colon in +# a make target ("multiple target patterns"). +step_key="$(printf '%s' "$step" | tr -c 'A-Za-z0-9_.-' '-')" +export OUT_DIR="build/step-$step_key" +mkdir -p "$OUT_DIR" "$ROOT/build/pins" obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; } -PINS="$ROOT/build/pins" +PINS="$(mktemp -d "$ROOT/build/pins/$step_key.XXXXXX")" +STEP_MARK="" +cleanup() { + if [ -n "$STEP_MARK" ]; then rm -f -- "$STEP_MARK"; fi + case "$PINS" in + "$ROOT/build/pins/$step_key".*) + chmod -R u+w -- "$PINS" 2>/dev/null || true + rm -rf -- "$PINS" ;; + esac +} +trap cleanup EXIT NOPHYS="PHYSICS_DIR=/nonexistent PHYSICS_LOCK_CHECK=0" lock() { awk 'NF && $1 !~ /^#/ {print $1; exit}' "$1"; } -# pin : build/pins/ is a detached checkout of -# taken from the object store of ../. Reused when already at that commit. +# pin : materialize a fresh detached checkout of +# from ../. pinned_checkout.sh disables replacement objects and grafts, copies +# the commit graph into this invocation's repository, re-hashes commit/tree/blob identities, +# verifies raw worktree bytes and modes, and makes the result read-only before returning it. pin() { - local name="$1" repo="$2" sha="$3" dir="$PINS/$1" + local name="$1" repo="$2" sha="$3" dir="$PINS/$1" tree if [ ! -d "../$repo/.git" ] && [ ! -f "../$repo/.git" ]; then echo "run.sh: ../$repo is missing; the hosted job checks out aien-dev/$repo at $sha" >&2 exit 3 fi - mkdir -p "$PINS" - ( - flock -x 9 - if [ ! -d "$dir" ] || [ "$(git -C "$dir" rev-parse HEAD 2>/dev/null)" != "$sha" ]; then - rm -rf "$dir" - git clone --quiet --shared --no-checkout "../$repo" "$dir" - git -C "$dir" checkout --quiet --detach "$sha" - fi - ) 9>"$PINS/.$name.lock" + chmod u+w -- "$PINS" + tree="$(tools/pinned_checkout.sh materialize "../$repo" "$sha" "$dir")" + chmod a-w -- "$PINS" obs "pin_${name//-/_}" "\"$sha\"" + obs "pin_${name//-/_}_tree" "\"$tree\"" } # Every step that builds against physics takes the commit from physics.lock, never a literal: # the Makefile's check-physics-lock refuses any other commit, so a literal here goes red on @@ -76,7 +86,6 @@ export OMEGA_CANDIDATE_COMMIT="$(git rev-parse HEAD)" # Only receipts written during this step count: a hosted job starts from a fresh checkout, so it # can only see its own run, while a reused local tree keeps build/qual-runs from earlier runs. STEP_MARK="$(mktemp /tmp/omega-gate-step.XXXXXX)" -trap 'rm -f "$STEP_MARK"' EXIT receipt() { local r; r="$(find build/qual-runs -name "$1" -type f -newer "$STEP_MARK" | head -n 1)"; shift test -n "$r" diff --git a/tools/pinned_checkout.sh b/tools/pinned_checkout.sh new file mode 100755 index 000000000..6cfaf02ca --- /dev/null +++ b/tools/pinned_checkout.sh @@ -0,0 +1,179 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Drake Stapleton (AIEN / aien-dev) +# +# Materialize or verify an exact, read-only checkout from a full commit id. +# Replace refs and grafts are disabled, object identities are re-hashed, and the +# worktree is compared as raw bytes and modes without checkout filters. +set -euo pipefail +unset GIT_CONFIG GIT_CONFIG_COUNT GIT_CONFIG_PARAMETERS GIT_DIR GIT_WORK_TREE GIT_COMMON_DIR +unset GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_NAMESPACE +export GIT_NO_REPLACE_OBJECTS=1 +export GIT_GRAFT_FILE=/nonexistent/omega-pinned-checkout-grafts +export GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null GIT_ATTR_NOSYSTEM=1 +export LC_ALL=C + +PROG=${0##*/} +tmpd="" +created="" + +die() { echo "$PROG: REFUSED: $*" >&2; exit 1; } + +cleanup() { + local rc=$? + if [ -n "$tmpd" ] && [ -d "$tmpd" ]; then rm -rf -- "$tmpd"; fi + if [ "$rc" -ne 0 ] && [ -n "$created" ] && [ -d "$created" ]; then + chmod -R u+w -- "$created" 2>/dev/null || true + rm -rf -- "$created" + fi +} +trap cleanup EXIT + +full_commit() { + [[ "$1" =~ ^[0-9a-f]{40}$ ]] || die "commit must be one full lowercase 40-hex id: '$1'" +} + +rehash() { + local repo=$1 type=$2 id=$3 got + got=$(git -C "$repo" cat-file "$type" "$id" 2>/dev/null | + git hash-object -t "$type" --stdin 2>/dev/null) || + die "cannot read $type object $id from $repo" + [ "$got" = "$id" ] || die "$type object $id fails its content hash in $repo" +} + +# verify_checkout : print the verified root tree id. +verify_checkout() { + local dir=$1 commit=$2 top actual tree ent meta path mode type id file got gitlink_entries + local bad="" + full_commit "$commit" + [ -d "$dir" ] || die "$dir is not a directory" + dir=$(cd "$dir" && pwd -P) || die "cannot resolve $dir" + top=$(git -C "$dir" rev-parse --show-toplevel 2>/dev/null) || die "$dir is not a Git worktree" + top=$(cd "$top" && pwd -P) || die "cannot resolve worktree root $top" + [ "$top" = "$dir" ] || die "$dir is not the root of its Git worktree ($top)" + + actual=$(git -C "$dir" rev-parse --verify -q "$commit^{commit}" 2>/dev/null) || + die "$dir does not hold commit $commit" + [ "$actual" = "$commit" ] || die "$commit resolves to unexpected commit $actual in $dir" + actual=$(git -C "$dir" rev-parse --verify -q HEAD 2>/dev/null) || die "cannot read HEAD in $dir" + [ "$actual" = "$commit" ] || die "$dir is at $actual, not locked commit $commit" + + rehash "$dir" commit "$commit" + tree=$(git -C "$dir" rev-parse --verify -q "$commit^{tree}" 2>/dev/null) || + die "cannot resolve the root tree of $commit" + rehash "$dir" tree "$tree" + + tmpd=$(mktemp -d "${TMPDIR:-/tmp}/omega-pinned-checkout.XXXXXX") || die "mktemp failed" + : > "$tmpd/want0" + : > "$tmpd/regular" + : > "$tmpd/regular.ids" + + # Re-hash every nested tree. Blob ids are proved below from the exact bytes + # in the worktree, binding what consumers read to the locked tree. + git -C "$dir" ls-tree -r -t -z --full-tree "$commit" > "$tmpd/objects" || + die "cannot enumerate objects at $commit" + while IFS= read -r -d '' ent; do + meta=${ent%%$'\t'*} + path=${ent#*$'\t'} + read -r mode type id <<< "$meta" + case "$path" in *$'\n'*) die "path with a newline at $commit is unsupported" ;; esac + case "$type" in + tree) rehash "$dir" tree "$id" ;; + blob) ;; + commit) [ "$mode" = 160000 ] || die "$path has unexpected commit mode $mode" ;; + *) die "$path has unsupported object type $type" ;; + esac + done < "$tmpd/objects" + + git -C "$dir" ls-tree -r -z --full-tree "$commit" > "$tmpd/entries" || + die "cannot enumerate paths at $commit" + while IFS= read -r -d '' ent; do + meta=${ent%%$'\t'*} + path=${ent#*$'\t'} + read -r mode type id <<< "$meta" + case "$path" in *$'\n'*) die "path with a newline at $commit is unsupported" ;; esac + file=$dir/$path + case "$mode:$type" in + 100644:blob|100755:blob) + [ -f "$file" ] && [ ! -L "$file" ] || { bad+="$path(type) "; continue; } + if [ "$mode" = 100755 ]; then + [ -x "$file" ] || { bad+="$path(mode) "; continue; } + else + [ ! -x "$file" ] || { bad+="$path(mode) "; continue; } + fi + printf '%s\n' "$file" >> "$tmpd/regular" + printf '%s\n' "$id" >> "$tmpd/regular.ids" + printf '%s\0' "$path" >> "$tmpd/want0" ;; + 120000:blob) + if [ -L "$file" ]; then + # readlink -z preserves embedded/trailing newlines; remove only its NUL delimiter. + got=$(readlink -z -- "$file" | head -c -1 | git hash-object --stdin 2>/dev/null) || got="" + [ "$got" = "$id" ] || bad+="$path(symlink) " + else + bad+="$path(type) " + fi + printf '%s\0' "$path" >> "$tmpd/want0" ;; + 160000:commit) + if [ -e "$file" ] || [ -L "$file" ]; then + if [ -d "$file" ] && [ ! -L "$file" ]; then + gitlink_entries=$(find "$file" -mindepth 1 -print -quit 2>/dev/null) || + { bad+="$path(unreadable-gitlink) "; continue; } + [ -z "$gitlink_entries" ] || bad+="$path(gitlink) " + else + bad+="$path(gitlink) " + fi + fi ;; + *) die "$path has unsupported mode and type $mode $type at $commit" ;; + esac + done < "$tmpd/entries" + + if [ -s "$tmpd/regular" ]; then + git hash-object --no-filters --stdin-paths < "$tmpd/regular" > "$tmpd/regular.got" 2>/dev/null || + die "cannot hash regular files under $dir" + if ! cmp -s "$tmpd/regular.ids" "$tmpd/regular.got"; then + bad+="regular-file-content " + fi + fi + + (cd "$dir" && find . -path './.git' -prune -o ! -type d -printf '%P\0') > "$tmpd/have0" || + die "cannot enumerate every worktree path under $dir" + sort -z -o "$tmpd/want0" "$tmpd/want0" + sort -z -o "$tmpd/have0" "$tmpd/have0" + if ! cmp -s "$tmpd/want0" "$tmpd/have0"; then bad+="missing-or-extra-path "; fi + [ -z "$bad" ] || die "$dir differs from $commit: ${bad:0:300}" + + rm -rf -- "$tmpd" + tmpd="" + printf '%s\n' "$tree" +} + +cmd=${1:-} +case "$cmd" in +verify) + [ $# = 3 ] || die "usage: $PROG verify CHECKOUT COMMIT" + verify_checkout "$2" "$3" ;; +materialize) + [ $# = 4 ] || die "usage: $PROG materialize SOURCE_REPOSITORY COMMIT DESTINATION" + source_repo=$2 + commit=$3 + destination=$4 + full_commit "$commit" + [ -d "$source_repo" ] || die "$source_repo is not a repository directory" + source_repo=$(cd "$source_repo" && pwd -P) || die "cannot resolve $source_repo" + git -C "$source_repo" rev-parse --git-dir >/dev/null 2>&1 || die "$source_repo is not a Git repository" + [ ! -e "$destination" ] && [ ! -L "$destination" ] || die "destination already exists: $destination" + mkdir -p -- "$(dirname "$destination")" || die "cannot create destination parent" + git init --quiet "$destination" || die "cannot initialize $destination" + created=$destination + # Fetching into a new repository copies the locked object graph instead of + # sharing a mutable worktree or object alternate with the sibling clone. + git -C "$destination" -c protocol.file.allow=always fetch --quiet --no-tags --depth=1 \ + "$source_repo" "$commit" || die "cannot fetch locked commit $commit from $source_repo" + git -C "$destination" checkout --quiet --detach "$commit" || die "cannot check out $commit" + tree=$(verify_checkout "$destination" "$commit") + chmod -R a-w -- "$destination" || die "cannot make $destination read-only" + created="" + printf '%s\n' "$tree" ;; +*) + die "usage: $PROG verify CHECKOUT COMMIT | materialize SOURCE_REPOSITORY COMMIT DESTINATION" ;; +esac diff --git a/tools/require_physics_pin.sh b/tools/require_physics_pin.sh index 683b067aa..409645c52 100755 --- a/tools/require_physics_pin.sh +++ b/tools/require_physics_pin.sh @@ -3,7 +3,7 @@ # omega#456: the chip runners build against a Physics checkout given on their command line (default # ~/workspace/physics-own30b-k). They build single targets, so the Makefile's check-physics-lock (run by `all`) # never ran for them. Each runner calls this first, before it writes evidence or builds anything: it refuses -# (exit 2) when PHYSICS_DIR's HEAD is not the commit in this repo's physics.lock, or when HEAD cannot be read. +# (exit 2) unless PHYSICS_DIR's commit, trees, blobs, raw worktree bytes and modes exactly match physics.lock. # PHYSICS_LOCK_CHECK=0 skips the check, the same override the Makefile honours, and says so on stderr. set -u PHYS="${1:?usage: require_physics_pin.sh PHYSICS_DIR}" @@ -14,14 +14,9 @@ if [ "${PHYSICS_LOCK_CHECK:-1}" = "0" ]; then fi [ -f "$ROOT/physics.lock" ] || { echo "require_physics_pin: REFUSED: $ROOT/physics.lock not found" >&2; exit 2; } locked=$(tr -d '[:space:]' < "$ROOT/physics.lock") -actual=$(git -C "$PHYS" rev-parse HEAD 2>/dev/null) || actual="" -if [ -z "$actual" ]; then - echo "require_physics_pin: REFUSED: cannot read HEAD of PHYSICS_DIR=$PHYS" >&2 - exit 2 -fi -if [ "$actual" != "$locked" ]; then - echo "require_physics_pin: REFUSED: PHYSICS_DIR=$PHYS is at $actual but physics.lock pins $locked" >&2 - echo " check out the pinned Physics commit there, pass a checkout at the pin, or set PHYSICS_LOCK_CHECK=0" >&2 +if ! "$ROOT/tools/pinned_checkout.sh" verify "$PHYS" "$locked" >/dev/null; then + echo "require_physics_pin: REFUSED: PHYSICS_DIR=$PHYS is not an exact worktree of physics.lock ($locked)" >&2 + echo " pass an unmodified checkout at the pin, or set PHYSICS_LOCK_CHECK=0" >&2 exit 2 fi exit 0 diff --git a/tools/test_pinned_checkout.sh b/tools/test_pinned_checkout.sh new file mode 100755 index 000000000..2bf3593a9 --- /dev/null +++ b/tools/test_pinned_checkout.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright 2026 Drake Stapleton (AIEN / aien-dev) +# Host-only regression controls for tools/pinned_checkout.sh. No network or GPU. +set -euo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +TOOL="$ROOT/tools/pinned_checkout.sh" +SCR="$(mktemp -d "${TMPDIR:-/tmp}/omega-pin-test.XXXXXX")" +trap 'chmod -R u+w "$SCR" 2>/dev/null || true; rm -rf "$SCR"' EXIT +SRC="$SCR/source" +PASS=0 + +check() { + local title=$1 + shift + if "$@"; then PASS=$((PASS + 1)); else echo "FAIL $title" >&2; exit 1; fi +} +refuse() { ! "$@" >/dev/null 2>&1; } + +git init -q "$SRC" +git -C "$SRC" config user.name pin-test +git -C "$SRC" config user.email pin-test@example.invalid +printf 'locked bytes\n' > "$SRC/regular" +printf '#!/bin/sh\nexit 0\n' > "$SRC/executable" +chmod 755 "$SRC/executable" +ln -s regular "$SRC/link" +git -C "$SRC" add regular executable link +git -C "$SRC" commit -qm locked +LOCK=$(git -C "$SRC" rev-parse HEAD) +TREE=$(git -C "$SRC" rev-parse "$LOCK^{tree}") + +printf 'replacement bytes\n' > "$SRC/regular" +git -C "$SRC" add regular +git -C "$SRC" commit -qm replacement +REPLACEMENT=$(git -C "$SRC" rev-parse HEAD) +git -C "$SRC" replace "$LOCK" "$REPLACEMENT" +git -C "$SRC" -c advice.detachedHead=false checkout -q "$LOCK" +printf 'dirty bytes\n' > "$SRC/regular" +printf 'untracked\n' > "$SRC/untracked" + +PIN1="$SCR/pin1" +GOT_TREE=$("$TOOL" materialize "$SRC" "$LOCK" "$PIN1") +check "tree identity retained" test "$GOT_TREE" = "$TREE" +check "dirty source ignored" grep -qx 'locked bytes' "$PIN1/regular" +check "replacement ref ignored" test "$(git -C "$PIN1" rev-parse HEAD)" = "$LOCK" +check "independent objects copied" test ! -s "$PIN1/.git/objects/info/alternates" +check "executable mode retained" test -x "$PIN1/executable" +check "symlink retained" test "$(readlink "$PIN1/link")" = regular +check "materialized tree verifies" test "$("$TOOL" verify "$PIN1" "$LOCK")" = "$TREE" +check "source files are read-only" test "$((8#$(stat -c %a "$PIN1/regular") & 8#222))" -eq 0 + +chmod u+w "$PIN1/regular" +printf 'changed after setup\n' > "$PIN1/regular" +check "changed bytes refused" refuse "$TOOL" verify "$PIN1" "$LOCK" + +PIN2="$SCR/pin2" +"$TOOL" materialize "$SRC" "$LOCK" "$PIN2" >/dev/null +chmod u+w "$PIN2/executable" +chmod a-x "$PIN2/executable" +check "changed mode refused" refuse "$TOOL" verify "$PIN2" "$LOCK" + +PIN3="$SCR/pin3" +"$TOOL" materialize "$SRC" "$LOCK" "$PIN3" >/dev/null +chmod u+w "$PIN3" +printf 'extra\n' > "$PIN3/extra" +check "extra path refused" refuse "$TOOL" verify "$PIN3" "$LOCK" +check "short commit refused" refuse "$TOOL" materialize "$SRC" "${LOCK:0:12}" "$SCR/short" +mkdir "$SCR/existing" +check "existing destination refused" refuse "$TOOL" materialize "$SRC" "$LOCK" "$SCR/existing" + +echo "OMEGA_PINNED_CHECKOUT_PASS checks=$PASS"