46 lines
3.3 KiB
Bash
Executable File
46 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Row 162, sage-0837, rerun on sage-0871 (mos-0810 D1-D2, target 8e7ea89a1): activate --plan against a scratch data root with a hand-written pointer.
|
|
# Everything written lives under $P. The only live reads were made before this script, by hand, the second at the start of the sage-0871 slot:
|
|
# `systemctl --user show [email protected] -p WorkingDirectory` (19:32:16Z).
|
|
set -euo pipefail
|
|
LIVE=52f35e7a0933e9fa845f59860a5de1709f9e5756
|
|
TO="$(git -C /mnt/storage/src/mosaic-stack rev-parse --verify 8e7ea89a1^{commit})"
|
|
R="$HOME/darkwing-scratch/r162"
|
|
P="$R/plan-8e7"
|
|
WT="$R/wt"
|
|
export TMPDIR="$R/tmp"
|
|
[ ! -e "$P" ] || { echo "plan.sh: $P exists; remove it first" >&2; exit 1; }
|
|
mkdir -p "$P/cfg" "$P/data/state" "$P/data/bus" "$P/copies" "$P/bin"
|
|
step() { echo "$(date -u +%FT%TZ) $*" >> "$P/steps.log"; }
|
|
cat > "$P/cfg/config.json" <<EOF
|
|
{"configVersion":1,"environment":"development","dataRoot":"$P/data","execution":{"backend":"docker","provider":"zai","model":"glm-5.3-flash","adapter":"mock"}}
|
|
EOF
|
|
# The schema adopt would record for the live copy: SCHEMA_VERSION in its store.mjs, read from git.
|
|
SCHEMA="$(git -C /mnt/storage/src/mosaic-stack show "$LIVE:packages/bus/src/store.mjs" | sed -n "s/^export const SCHEMA_VERSION = '\([A-Za-z0-9]*\)';\$/\1/p")"
|
|
node -e '
|
|
const [copy,schema]=process.argv.slice(1);
|
|
process.stdout.write(JSON.stringify({copy,business:"mosaic-stack",pm:false,claude:"/hand-written/no-claude-pin-read",console:[],schema,activation:"hand-written",at:new Date().toISOString().replace(/\.\d+Z$/,"Z")})+"\n");' -- "$LIVE" "$SCHEMA" > "$P/data/state/stack-active.json"
|
|
step "pointer: hand-written, copy $LIVE, schema $SCHEMA"
|
|
step "copy: (cd $WT && scripts/stack-copy.sh copy $TO --copies $P/copies --allow-worktree)"
|
|
(cd "$WT" && scripts/stack-copy.sh copy "$TO" --copies "$P/copies" --allow-worktree) > "$P/copy.out" 2>&1 || { step "copy failed"; tail -20 "$P/copy.out"; exit 1; }
|
|
step "copy: $(tail -1 "$P/copy.out")"
|
|
{
|
|
echo "# SCRATCH ROOT, NOT LIVE. activate --plan run by darkwing at $(date -u +%FT%TZ) in the row 162 slot."
|
|
echo "# Data root: $P/data (config $P/cfg/config.json). There is no store file, so the store schema"
|
|
echo "# comes from the pointer. The pointer is HAND-WRITTEN: copy $LIVE is the live bus unit's"
|
|
echo "# WorkingDirectory; schema $SCHEMA is that copy's SCHEMA_VERSION read with git show. pm, claude"
|
|
echo "# and console are placeholders, so the bus and Console lines below are not the live flags."
|
|
echo "# Copies: $P/copies (a scratch copy of $TO). The real --plan against the live pointer runs"
|
|
echo "# again in Mos's window before any adopt."
|
|
echo "# Command: MOSAIC_CONFIG=$P/cfg/config.json scripts/stack-release.sh activate $TO mosaic-stack --plan --copies $P/copies --bin $P/bin"
|
|
set +e
|
|
(cd "$WT" && MOSAIC_CONFIG="$P/cfg/config.json" scripts/stack-release.sh activate "$TO" mosaic-stack --plan --copies "$P/copies" --bin "$P/bin" 2>&1)
|
|
echo "# exit $?"
|
|
} > "$R/out/scratch-plan-8e7ea89a1.txt"
|
|
step "plan: written to $R/out/scratch-plan.txt"
|
|
step "files under the data root after the plan: $(cd "$P/data" && find . | sort | tr '\n' ' ')"
|
|
chmod -R u+w "$P/copies/$TO"
|
|
rm -rf "$P/copies/$TO"
|
|
step "removed: chmod -R u+w $P/copies/$TO && rm -rf $P/copies/$TO; left: $(ls -A "$P/copies" | wc -l) entries"
|
|
cat "$P/steps.log"
|