Files
stack/agents/darkwing/work/queue-56-review/r1/probes.sh
T

51 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# Row 56 probes: edge cases outside Rocko's byte-check and delta-check, base against candidate.
export TMPDIR=~/darkwing-scratch/r56a/tmp
S=~/darkwing-scratch/r56a; W=$S/probes; rm -rf $W; mkdir -p $W
A=r-20260101T000000Z-aaaaaa
RESULT='{"runVersion":1,"taskId":"t","status":"succeeded","request":"r","response":"s","provider":"p","model":"m","startedAt":"a","finishedAt":"b","durationMs":1,"exitCode":0,"signal":null}'
root() { mkdir -p "$W/$1/data" "$W/$1/outside"; printf '{"configVersion":1,"environment":"development","dataRoot":"%s","execution":{"backend":"docker","provider":"zai","model":"m"}}\n' "$W/$1/data" > "$W/$1/config.json"; echo "$W/$1/data"; }
run_case() { local name="$1" cfg="$2"; shift 2
for tree in base cand mutwt; do
local rc=0 out
out="$(cd $S/$tree && env -u NODE_TEST_CONTEXT MOSAIC_CONFIG="$cfg" node scripts/mosaic-task.mjs "$@" 2>"$W/$name.$tree.err")" || rc=$?
printf ' %s: exit %s\n' "$tree" "$rc"; [ -z "$out" ] || printf '%s\n' "$out" | sed 's/^/ out| /'
[ -s "$W/$name.$tree.err" ] && head -1 "$W/$name.$tree.err" | sed 's/^/ err| /'
done; }
hdr() { printf '\n== %s\n' "$*"; }
hdr "P1 show ../x with no config file (mutwt carries D01 when run by this script)"
run_case p1 "$W/no-such-config.json" show ../x
D="$(root p2)"; mkdir -p "$D/runs/$A"; printf '%s\n' "$RESULT" > "$D/runs/$A/result.json"; chmod 000 "$D/runs/$A"
hdr "P2 show of a run directory with mode 000"; run_case p2 "$W/p2/config.json" show "$A"
chmod 755 "$D/runs/$A"
D="$(root p3)"; mkdir -p "$D/runs/r-.bad" "$D/runs/r-"; printf '%s\n' "$RESULT" > "$D/runs/r-.bad/result.json"
hdr "P3 list with r- names that aren't valid run ids"; run_case p3 "$W/p3/config.json" list
D="$(root p4)"; mkdir -p "$D/runs/$A"; printf '%s\n' "$RESULT" > "$D/runs/$A/result.json"; ln -s . "$D/runs/r-self"; mv "$D/runs" "$D/real-runs"; ln -s real-runs "$D/runs"
hdr "P4 runs/ is a link inside the data root"; run_case p4 "$W/p4/config.json" list
D="$(root p5)"; ln -s "$W/p5/outside" "$D/state"
hdr "P5 state/ linked out of the data root, no active.json or log there"
(cd $S/cand && node -e '
import("./packages/runs/src/index.mjs").then((m) => {
for (const f of ["readActivePointer", "readActivationLog"]) {
try { console.log(" " + f + ": " + JSON.stringify(m[f](process.argv[1]))); } catch (e) { console.log(" " + f + ": " + e.name + " " + e.exitCode + " " + e.message); }
}
});' "$D")
printf '{"pointerVersion":1,"release":"x","imageTag":"y","activatedAt":"z"}\n' > "$W/p5/outside/active.json"
hdr "P5b same, with active.json outside"
(cd $S/cand && node -e '
import("./packages/runs/src/index.mjs").then((m) => {
try { console.log(" readActivePointer: " + JSON.stringify(m.readActivePointer(process.argv[1]))); } catch (e) { console.log(" readActivePointer: " + e.name + " " + e.exitCode + " " + e.message.replace(process.argv[1], "<D>")); }
});' "$D")
D="$(root p6)"; mkdir -p "$D/state"
printf '%s\n' '{"at":"a","event":"activate","release":"0.0.1","imageTag":"t1","from":"0.0.0"}' '{"at":"b","event":"rollback","release":"0.0.0","imageTag":5}' > "$D/state/activation-log.jsonl"
hdr "P6 log lines release.sh rollback would still use (an extra key, a non-string imageTag)"
(cd $S/cand && node -e '
import("./packages/runs/src/index.mjs").then((m) => console.log(" " + JSON.stringify(m.readActivationLog(process.argv[1]))));' "$D")
echo; echo DONE