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/interplane-forge/blob/main/patch/tests/lib.sh # interplane-forge INTERPLANE Forge 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 `interplane-forge / patch / tests / lib.sh` 305 lines ยท 18747 bytes Raw Blame History 1 # Git patch intake test library, sourced by patch/tests/run.sh and patch/tests/e2e.sh (run from the 2 # repository root on spark). It builds a TEST copy of forged from the build's own unit list 3 # (FORGE_STORE= ./run.sh units: the patch slice is composed only in a store-reading 4 # build) on a private port with private folders. The store is a fixture made by 5 # store/tests/fixstore.sh (IPL_DIR: interplane-native with bin/ built); in the test copy only, the 6 # data folder (every /home/drakestapleton/forge-data/ path), the port, and the first of the two 7 # origins a POST may name (tforg1, so the interplane program can post to this loopback copy) are 8 # rewritten. Nothing of the live forge, the real store (~/interplane-store-owner) or ~/forge-data is 9 # read or written. It makes a fixture repository, throwaway `ed25519` keys and the sign-in and upload 10 # helpers. 11 set -u 12 cd "$(dirname "$0")/../.." 13 ROOT=$(pwd) 14 tree_status=$(git status --porcelain) || exit 1 15 if [ -n "$tree_status" ]; then 16 echo "BUILD FAILED: patch fixtures require a clean Git checkout" >&2 17 exit 1 18 fi 19 OMV=${OMV:-$HOME/work/flux/omega-mv} 20 OMC=$OMV/seed/out/omc 21 PORT=${PATCH_TEST_PORT:-18487} 22 CORES=${PATCH_TEST_CORES:-2} 23 T=$(mktemp -d /tmp/forgepatch.XXXXXX) 24 mkdir -p "$T/data" "$T/social" "$T/storage" "$T/home" 25 IPL_DIR=${IPL_DIR:-$HOME/work/hive/agent-door/interplane-native} 26 PASS=0; FAIL=0 27 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 28 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 29 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; } 30 G() { git -c user.name=fixture -c user.email=fixture@example.org -c init.defaultBranch=main -c commit.gpgSign=false "$@"; } 31 32 # The site chrome is generated from the interplane.io site source. A store-reading build takes it 33 # from the store's interplane.io project, which the fixture store does not hold; the site's git 34 # store stands in when no source is named. 35 if [ -z "${FORGE_SITE_STORE:-}${FORGE_SITE_SRC:-}" ] && [ -d "$HOME/git/interplane.io.git" ]; then 36 export FORGE_SITE_STORE=$HOME/git/interplane.io.git 37 fi 38 39 # ---- fixture: a Radicle-shaped list and a bare repository per row, turned into a native store 40 # ($T/store, catalog.tsv and projects/NAME/repo.git) by store/tests/fixstore.sh. fixrepo has main 41 # (three commits) and side (one commit that is not on main); nostore is a second public project 42 # whose repo.git a test moves away while the server runs (GITS is the store's fixrepo repository). 43 RID1=zFixtureRepoOne1111111111111 44 RID2=zFixtureRepoTwo2222222222222 45 OWNER=drakestapleton 46 R=/$OWNER/fixrepo 47 cat > "$T/RIDS.md" < README.md 58 mkdir -p src docs 59 printf 'one\ntwo\nthree\n' > src/a.txt 60 printf 'alpha\n' > docs/note.md 61 G add -A && GIT_AUTHOR_DATE=2026-11-01T10:00:00Z GIT_COMMITTER_DATE=2026-11-01T10:00:00Z G commit -q -m 'first' || return 1 62 A=$(git rev-parse HEAD) 63 printf 'four\n' >> src/a.txt 64 GIT_AUTHOR_DATE=2026-11-02T10:00:00Z GIT_COMMITTER_DATE=2026-11-02T10:00:00Z G commit -q -am 'second' || return 1 65 printf 'beta\n' >> docs/note.md 66 GIT_AUTHOR_DATE=2026-11-03T10:00:00Z GIT_COMMITTER_DATE=2026-11-03T10:00:00Z G commit -q -am 'third' || return 1 67 MAIN=$(git rev-parse HEAD) 68 G checkout -q -b side "$A" 69 printf 'side\n' > side.txt 70 G add -A && GIT_AUTHOR_DATE=2026-11-04T10:00:00Z GIT_COMMITTER_DATE=2026-11-04T10:00:00Z G commit -q -m 'side work' || return 1 71 SIDE=$(git rev-parse HEAD) 72 G checkout -q main 73 git clone -q --bare "$T/src" "$T/storage/$RID1" || return 1 74 git clone -q --bare "$T/src" "$T/storage/$RID2" || return 1 75 cd "$ROOT" || return 1 76 [ -x "$IPL_DIR/ipl" ] || { echo "IPL_DIR=$IPL_DIR has no ipl program (store/tests/fixstore.sh needs it)"; return 1; } 77 # fixstore.sh signs the fixture's records with a throwaway key it keeps at /.fixkey. An ipl with 78 # owner pins (IPL_OWNER_PINS, default ~/.config/interplane/owner-pins: the real owner) refuses any other 79 # key, so the key is made here first and pinned in a private file for this run; an older ipl ignores it. 80 mkdir -p "$T/store" && ssh-keygen -q -t `ed25519` -N '' -C 'patch/tests/lib.sh throwaway key' -f "$T/store/.fixkey" || return 1 81 (umask 077; printf '* %s\n' "$(ssh-keygen -lf "$T/store/.fixkey.pub" | cut -d' ' -f2)" > "$T/pins") || return 1 82 export IPL_OWNER_PINS=$T/pins 83 FIXSTORE_FROM=/nonexistent IPL_DIR=$IPL_DIR bash store/tests/fixstore.sh "$T/RIDS.md" "$T/storage" "$T/store" > "$T/fixstore.log" 2>&1 \ 84 || { cat "$T/fixstore.log"; return 1; } 85 GITS=$T/store/projects/fixrepo/repo.git 86 [ -d "$GITS" ] && [ -d "$T/store/projects/nostore/repo.git" ] || { echo "the fixture store lacks a project"; cat "$T/fixstore.log"; return 1; } 87 [ "$(git --git-dir="$GITS" rev-parse refs/heads/main)" = "$MAIN" ] || { echo "the fixture store's main is not the fixture's"; return 1; } 88 } 89 fixture || { echo "FIXTURE FAILED"; rm -rf "$T"; exit 1; } 90 export FORGE_STORE=$T/store 91 92 # ---- build 93 buildfail() { echo "BUILD FAILED: $*"; [ -n "${KEEP:-}" ] || rm -rf "$T"; exit 1; } 94 FORGED_CPUS=$CORES ./run.sh units > "$T/units.txt" 2> "$T/units.err" || buildfail "./run.sh units: $(cat "$T/units.err")" 95 grep -qx 'patch/p4take.om' "$T/units.txt" || buildfail "the patch slice is not composed (FORGE_STORE, patch/READY, social/READY)" 96 rewrite() { 97 sed -e "s|/home/drakestapleton/forge-data/|$T/data/|g" \ 98 -e "s|^text tforg1 \".*\"|text tforg1 \"http://127.0.0.1:$PORT\"|" -e "s/18480/$PORT/g" 99 } 100 { printf 'om2\n'; cat $(cat "$T/units.txt"); } | rewrite > "$T/all.om" || buildfail "compose" 101 for t in "tfdata \"$T/data/\"" "tfsroot \"$T/store/\""; do 102 grep -q "^text $t\$" "$T/all.om" || buildfail "the test copy does not name the private $t" 103 done 104 if grep -qE '/home/drakestapleton/(forge-data|interplane-store|git/)' "$T/all.om"; then 105 buildfail "the test copy still names a live folder: $(grep -oE '/home/drakestapleton/(forge-data|interplane-store|git/)[^\" ]*' "$T/all.om" | sort -u | head -3 | tr '\n' ' ')" 106 fi 107 compile() { # SRC OUT 108 taskset -c "$CORES" nice -n 19 "$OMC" < "$1" > "$2" 2> "$T/omc.err" || return 1 109 chmod +x "$2" 110 } 111 compile "$T/all.om" "$T/forged" || buildfail "$(cat "$T/omc.err")" 112 echo "built $(sha256sum < "$T/forged" | cut -c1-16) in $T (omc $(sha256sum < "$OMC" | cut -c1-16), port $PORT)" 113 git log -1 --format='fixture head=%H tree=%T' 2>/dev/null || : 114 sha256sum "$T/all.om" "$T/forged" "$OMC" 115 116 # mutant NAME SED...: the test copy with one guard removed, as $T/forged.NAME; the sed program must 117 # change the source, else the mutant is void and the run stops 118 mutant() { 119 n=$1; shift 120 sed "$@" "$T/all.om" > "$T/all.$n.om" 121 if cmp -s "$T/all.om" "$T/all.$n.om"; then echo "MUTANT VOID: $n changed nothing"; exit 1; fi 122 compile "$T/all.$n.om" "$T/forged.$n" || { echo "MUTANT $n DID NOT COMPILE: $(cat "$T/omc.err")"; exit 1; } 123 } 124 125 PID= 126 start() { # [binary] 127 FORGE_SOCIAL_DIR="$T/social/" taskset -c "$CORES" nice -n 19 "${1:-$T/forged}" 2>> "$T/forged.err" & 128 PID=$! 129 for i in $(seq 100); do curl -s -o /dev/null "http://127.0.0.1:$PORT/" && return 0; sleep 0.1; done 130 echo "server did not start"; tail -5 "$T/forged.err"; exit 1 131 } 132 stop() { [ -n "$PID" ] && kill "$PID" 2>/dev/null; wait "$PID" 2>/dev/null; PID=; } 133 # alive: forged still answers. kill -0 alone is not enough: a forged that exited stays a zombie (kill -0 succeeds) 134 # until stop reaps it, so the process must not be in state Z and the port must still answer 135 alive() { kill -0 "$PID" 2>/dev/null && [ "$(sed 's/^.*) //' "/proc/$PID/stat" | cut -c1)" != Z ] && curl -s -o /dev/null --max-time 5 "$B/"; } 136 trap 'stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 137 B="http://127.0.0.1:$PORT" 138 139 # code METHOD PATH [curl args]: the status; body in $T/body, headers in $T/hdr (both emptied first: curl leaves the 140 # file of an answer without a body untouched, which would show the previous answer's body) 141 code() { 142 m=$1; p=$2; shift 2; : > "$T/body"; : > "$T/hdr" 143 curl -s -o "$T/body" -D "$T/hdr" -X "$m" "$@" "$B$p" -w '%{http_code}' 144 } 145 hdr() { grep -i "^$1:" "$T/hdr" | head -1 | cut -d' ' -f2- | tr -d '\r'; } 146 field() { grep -o "name=\"$1\" value=\"[^\"]*\"" "$T/body" | head -1 | sed 's/.*value="//; s/"$//'; } 147 148 # ---- throwaway keys and the did:key oracle (z + base58btc(0xed 0x01 || public key)) 149 did() { python3 - "$1" <<'EOF' 150 import sys, base64 151 blob = base64.b64decode(open(sys.argv[1]).read().split()[1]) 152 raw = b'\xed\x01' + blob[-32:] 153 A = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' 154 n = int.from_bytes(raw, 'big'); s = '' 155 while n: n, r = divmod(n, 58); s = A[r] + s 156 print('did:key:z' + s) 157 EOF 158 } 159 newkey() { ssh-keygen -q -t `ed25519` -N '' -C "$1" -f "$T/$1"; } 160 161 # signin KEY IP: sign in with $T/KEY from address IP; sets SES (session), TOK (CSRF token), DID, KEY, IP 162 signin() { 163 KEY=$T/$1; IP=$2; DID=$(did "$KEY.pub") 164 c=$(code GET /login -H "X-Real-IP: $IP"); [ "$c" = 200 ] || { bad "GET /login for $1: $c"; return 1; } 165 pre=$(hdr set-cookie | sed -n 's/^__Host-forge_pre=\([0-9a-f]*\);.*/\1/p') 166 lcsrf=$(field csrf); nonce=$(field nonce); ts=$(field ts) 167 printf '%s' "interplane-forge-login:$nonce:$ts" | ssh-keygen -Y sign -f "$KEY" -n interplane-forge > "$T/login.sig" 2>/dev/null 168 c=$(code POST /login -H "X-Real-IP: $IP" -H "Cookie: __Host-forge_pre=$pre" --data-urlencode "csrf=$lcsrf" \ 169 --data-urlencode "nonce=$nonce" --data-urlencode "ts=$ts" --data-urlencode "did=$DID" --data-urlencode "sig@$T/login.sig") 170 [ "$c" = 303 ] || { bad "POST /login for $1: $c"; return 1; } 171 SES=$(hdr set-cookie | sed -n 's/^__Host-forge_session=\([0-9a-f]*\);.*/\1/p') 172 c=$(code GET /settings -H "X-Real-IP: $IP" -H "Cookie: __Host-forge_session=$SES") 173 TOK=$(field csrf) 174 [ ${#SES} = 64 ] && [ ${#TOK} = 32 ] || { bad "session for $1: ses ${#SES} tok ${#TOK}"; return 1; } 175 } 176 177 # ---- a patch: work in a clone of the fixture, then mkmbox makes the mbox of BASE..HEAD 178 # newclone NAME [START]: a clone $T/NAME of the store's repository on a new branch at START (default main) 179 newclone() { 180 rm -rf "$T/$1"; git clone -q "$GITS" "$T/$1" && G -C "$T/$1" checkout -q -b work "${2:-origin/main}" 181 } 182 # commitf DIR PATH TEXT MESSAGE: append TEXT to PATH and commit, at a fixed time 183 commitf() { 184 mkdir -p "$(dirname "$1/$2")"; printf '%s\n' "$3" >> "$1/$2" 185 G -C "$1" add -A && GIT_AUTHOR_DATE=2026-11-10T10:00:00Z GIT_COMMITTER_DATE=2026-11-10T10:00:00Z G -C "$1" commit -q -m "$4" 186 } 187 # mkmbox DIR BASE: $MBOX = git format-patch --stdout BASE..HEAD of DIR; BASE is kept in $BASE 188 mkmbox() { 189 BASE=$(git -C "$1" rev-parse "$2"); MBOX=$T/mbox.$$.$RANDOM 190 git -C "$1" format-patch --stdout "$BASE..HEAD" > "$MBOX" 191 } 192 sha() { sha256sum "$@" | cut -d' ' -f1; } 193 # statement: the text the author's key signs, from REPOF BASE MBOX TITLE DESC 194 statement() { 195 printf 'interplane-patch 1\n%s\n%s\n%s\n%s\n' "$REPOF" "$BASE" "$(sha < "$MBOX")" "$(printf '%s\n%s' "$TITLE" "$DESC" | sha)" 196 } 197 # sigmake [KEYFILE]: sign the statement into $SIGF (default: the signed-in key) 198 sigmake() { 199 statement > "$T/stmt"; rm -f "$T/stmt.sig" 200 ssh-keygen -Y sign -f "${1:-$KEY}" -n interplane-patch "$T/stmt" > /dev/null 2>&1 201 SIGF=$T/stmt.sig 202 } 203 # upload [curl args]: POST the form (SES TOK IP REPOF BASE TITLE DESC MBOX SIGF) to $UPATH; the status 204 upload() { 205 : > "$T/body"; : > "$T/hdr" 206 basenc --base64url -w0 "$MBOX" | tr -d '=' > "$T/mb64" 207 curl -s -o "$T/body" -D "$T/hdr" -w '%{http_code}' -X POST -H "X-Real-IP: $IP" ${SES:+-H "Cookie: __Host-forge_session=$SES"} \ 208 --data-urlencode "csrf=$TOK" --data-urlencode "repo=$REPOF" --data-urlencode "base=$BASE" \ 209 --data-urlencode "title=$TITLE" --data-urlencode "description=$DESC" --data-urlencode "mbox@$T/mb64" \ 210 --data-urlencode "sig@$SIGF" "$@" "$B${UPATH:-$R/patches/new}" 211 } 212 reason() { sed -n 's/^refused: //p' "$T/body"; } 213 newid() { sed -n 's/^id //p' "$T/body"; } 214 # kept: how many patches the store holds for the fixture; tmpleft: work folders left behind 215 kept() { ls "$T/data/patches/$OWNER/fixrepo" 2>/dev/null | grep -c '^[0-9a-f]\{16\}$'; } 216 staged() { ls -a "$T/data/patches/$OWNER/fixrepo" 2>/dev/null | grep -c '^\.new-'; } 217 tmpleft() { ls "$T/data/patch-work" 2>/dev/null | grep -c '^pw'; } 218 # refused WANT_STATUS WANT_REASON LABEL: the last upload was refused with exactly that status and 219 # reason and nothing was kept (the store count is unchanged from $KEPT, nothing staged, no work folder) 220 refused() { 221 got="$1"; want="$2"; why="$3"; label="$4" 222 if [ "$got" = "$want" ] && [ "$(reason)" = "$why" ] && [ "$(kept)" = "$KEPT" ] && [ "$(staged)" = 0 ] && [ "$(tmpleft)" = 0 ]; then 223 ok "NEG $label: $got \"$why\", nothing kept" 224 else 225 bad "NEG $label: want $want \"$why\" and $KEPT kept; got $got \"$(head -c 200 "$T/body")\" kept $(kept) staged $(staged) work $(tmpleft)" 226 fi 227 } 228 # accepted LABEL: the last upload answered 201 "accepted", one more patch is kept, nothing left over 229 accepted() { 230 got="$1"; label="$2" 231 if [ "$got" = 201 ] && [ "$(head -1 "$T/body")" = accepted ] && [ "$(kept)" = $((KEPT+1)) ] && [ "$(staged)" = 0 ] && [ "$(tmpleft)" = 0 ]; then 232 KEPT=$((KEPT+1)); ID=$(newid); ok "POS $label: 201 accepted, id $ID" 233 else 234 bad "POS $label: want 201 accepted and $((KEPT+1)) kept; got $got \"$(head -c 200 "$T/body")\" kept $(kept) staged $(staged) work $(tmpleft)" 235 KEPT=$(kept) 236 fi 237 } 238 239 # ---- imported proposals (SPEC prstore/r1 extension, section 1). The forge never writes one: tools/ghimport does 240 # (branch ghimport/r1, tools/ghimport/src). These helpers plant item folders in the scratch store in the byte 241 # layout of that writer: 35imp.om prfiles/prgh/prmbox/prbund/oreach and 30item.om osrc for a pull request with 242 # GitHub metadata, 37code.om cfiles/ocsrc for a code-only one. The code file is made by git from a clone of the 243 # fixture repository, with the writer's own arguments. I is the folder of the item last made, IID its id (the 244 # first 16 hex of the SHA-256 of its statement), IMPD the store folder of the fixture repository. 245 GHO=aien-dev; GHR=gh-repo; IMPUTC=2026-11-17T09:00:00Z 246 IMPD=$T/data/patches/$OWNER/fixrepo 247 impstmt() { printf 'github-import 1\n%s/%s\n%s\n%s\n' "$GHO" "$GHR" "$1" "$2"; } # N HEAD 248 impid() { impstmt "$1" "$2" | sha256sum | cut -c1-16; } 249 # impsrc N [code]: source.json (osrc; with a second argument ocsrc, the code-only form) 250 impsrc() { 251 { printf '{"kind":"github-import","owner":"%s","repo":"%s","number":%s,"url":"https://github.com/%s/%s/pull/%s","export_sha256":"%s","imported_utc":"%s"' \ 252 "$GHO" "$GHR" "$1" "$GHO" "$GHR" "$1" "$(printf 'export %s' "$1" | sha256sum | cut -c1-64)" "$IMPUTC" 253 if [ -n "${2:-}" ]; then printf ',"metadata":"unavailable","state_derived":true}\n'; else printf '}\n'; fi; } > "$I/source.json" 254 } 255 # impgh N LOGIN OPENED CLOSED MERGED [DRAFT]: the gh file (prgh); a time is 20 bytes or "-" 256 impgh() { printf 'number %s\nlogin %s\nopened %s\nclosed %s\nmerged %s\nbase-ref main\nhead-ref feature-%s\ndraft %s\n' "$1" "$2" "$3" "$4" "$5" "$1" "${6:-false}" > "$I/gh"; } 257 # impnew N HEAD STATUS BASE: a pull request with GitHub metadata (prfiles), without its code file: statement, 258 # title, description (empty), status, labels (none), head, base, gh (login octo, open), thread (no record), 259 # source.json, and its line in the index 260 impnew() { 261 IID=$(impid "$1" "$2"); I=$IMPD/$IID; mkdir -p "$I" || return 1 262 impstmt "$1" "$2" > "$I/statement"; printf 'Imported pull request %s' "$1" > "$I/title"; : > "$I/description" 263 printf '%s\n' "$3" > "$I/status"; : > "$I/labels"; printf '%s\n' "$2" > "$I/head"; printf '%s\n' "$4" > "$I/base" 264 impgh "$1" octo 2026-11-10T11:00:00Z - -; : > "$I/thread"; impsrc "$1" 265 printf '%s\n' "$IID" >> "$IMPD/index" 266 } 267 # impcnew N HEAD STATUS [BASE]: a code-only pull request (cfiles), without its code file: statement, the fixed 268 # title, description (empty), head, thread (no record), gh (metadata unavailable), status, base when it has 269 # one, source.json (state_derived), and its line in the index. No labels file. 270 impcnew() { 271 IID=$(impid "$1" "$2"); I=$IMPD/$IID; mkdir -p "$I" || return 1 272 impstmt "$1" "$2" > "$I/statement"; printf 'GitHub %s/%s#%s (code only)' "$GHO" "$GHR" "$1" > "$I/title"; : > "$I/description" 273 printf '%s\n' "$2" > "$I/head"; : > "$I/thread"; printf 'number %s\nmetadata unavailable\nstate derived\n' "$1" > "$I/gh" 274 printf '%s\n' "$3" > "$I/status"; [ -z "${4:-}" ] || printf '%s\n' "$4" > "$I/base"; impsrc "$1" code 275 printf '%s\n' "$IID" >> "$IMPD/index" 276 } 277 # impmbox REPO: mbox and diff of the item's base..head from the work tree REPO (prmbox) 278 impmbox() { 279 git --git-dir="$1/.git" format-patch --stdout --no-relative --no-notes --no-signature "$(cat "$I/base")..$(cat "$I/head")" > "$I/mbox" \ 280 && git --git-dir="$1/.git" diff --no-color --no-ext-diff --no-textconv "$(cat "$I/base")...$(cat "$I/head")" > "$I/diff" 281 } 282 # impbundle REPO N: head.bundle of refs/pull/N/head ^base from REPO (prbund); of the head alone without a base file 283 impbundle() { 284 git -C "$1" update-ref "refs/pull/$2/head" "$(cat "$I/head")" || return 1 285 if [ -f "$I/base" ]; then git -C "$1" bundle create -q "$I/head.bundle" "refs/pull/$2/head" "^$(cat "$I/base")" 286 else git -C "$1" bundle create -q "$I/head.bundle" "refs/pull/$2/head"; fi 287 } 288 # impreach WORD MAIN|- [UTC]: the reach file of a merged pull request (oreach) 289 impreach() { printf '%s %s %s\n' "$1" "$2" "${3:-2026-11-17T09:30:00Z}" > "$I/reach"; } 290 # thread records (30item.om trec/trc3), appended to the item's thread; lengths are byte counts 291 blen() { printf '%s' "$1" | wc -c; } 292 thc() { printf 'comment %s %s %s\n%s\n' "$1" "$2" "$(blen "$3")" "$3" >> "$I/thread"; } # TIME LOGIN BODY 293 thr() { printf 'review %s %s %s %s\n%s\n' "$1" "$2" "$3" "$(blen "$4")" "$4" >> "$I/thread"; } # TIME LOGIN STATE|- BODY 294 thrc() { printf 'review-comment %s %s %s %s %s\n%s\n%s\n' "$1" "$2" "$3" "$(blen "$4")" "$(blen "$5")" "$4" "$5" >> "$I/thread"; } # TIME LOGIN LINE PATH BODY 295 # imphash: one hash over the SHA-256 of every file of every item folder without a meta file (the imported ones), 296 # the index, and the names the store folder holds 297 imphash() { (cd "$IMPD" && for d in */; do [ -f "$d/meta" ] || find "$d" -type f | sort | xargs -r sha256sum; done; sha256sum index; ls -a) | sha256sum | cut -d' ' -f1; } 298 # pdstaged: staging files left in the bundle diff cache folder 299 pdstaged() { ls -a "$T/data/pdiff/$OWNER/fixrepo" 2>/dev/null | grep -c '^\.new-'; } 300 # fold FILE: the PASS and FAIL lines an oracle program wrote, added to the counters; an oracle that did not 301 # reach its last line (DONE) is a failure of its own 302 fold() { 303 grep -a '^PASS \|^FAIL ' "$1"; p=$(grep -ac '^PASS ' "$1"); f=$(grep -ac '^FAIL ' "$1"); PASS=$((PASS+p)); FAIL=$((FAIL+f)) 304 [ "$(tail -1 "$1")" = DONE ] || bad "the oracle did not finish ($1): $(tail -3 "$1" | tr '\n' ' ' | cut -c1-300)" 305 }