feat(wt-memory-gate-batch): --keep-data with a per-batch scratch outside git (TMPDIR), 14-day user tmpfiles retention (worldtree-dev's ask)

This commit is contained in:
vh
2026-10-17 07:55:26 -07:00
parent 39458e013a
commit f843cd92b1
2 changed files with 20 additions and 2 deletions
+4
View File
@@ -0,0 +1,4 @@
# lkraven user tmpfiles: the Worldtree memory gate keeps each batch's harness scratch (scripts/wt-memory-gate-batch
# --keep-data, worldtree-dev 2026-10-17); retention 14 days, cleaned by the user systemd-tmpfiles-clean.timer.
# Install: cp to ~/.config/user-tmpfiles.d/ and `systemctl --user enable --now systemd-tmpfiles-clean.timer`.
d %h/.local/state/wt-memory-gate-batch/scratch 0700 - - 14d
+16 -2
View File
@@ -55,6 +55,7 @@ WT_DEMO_API_CT="${WT_DEMO_API_CT:-worldtree-worldtree-api-1}"
WT_LEGACY_MODE="${WT_LEGACY_MODE:-off}" WT_LEGACY_MODE="${WT_LEGACY_MODE:-off}"
WT_BATCH_LABEL="${WT_BATCH_LABEL:-window-off}" WT_BATCH_LABEL="${WT_BATCH_LABEL:-window-off}"
STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/wt-memory-gate-batch" STATE_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/wt-memory-gate-batch"
SCRATCH_BASE="$STATE_DIR/scratch" # kept harness scratch, one dir per batch; outside every git checkout
LOCK_FILE="$STATE_DIR/lock" LOCK_FILE="$STATE_DIR/lock"
OUT_DIR="$WT_TREE/docs/eval/memory_acceptance_runs" OUT_DIR="$WT_TREE/docs/eval/memory_acceptance_runs"
@@ -112,8 +113,14 @@ legacy_args=()
if git -C "$WT_TREE" grep -q -e '"--legacy-mode"' "$deployed" -- core/memory_acceptance 2>/dev/null; then if git -C "$WT_TREE" grep -q -e '"--legacy-mode"' "$deployed" -- core/memory_acceptance 2>/dev/null; then
legacy_args=(--legacy-mode "$WT_LEGACY_MODE") legacy_args=(--legacy-mode "$WT_LEGACY_MODE")
fi fi
# --keep-data (worldtree-dev 2026-10-17, thread 01M555JEFQKK2G3WK155P1X9T1): keep the in-process instance's scratch
# (its memory writer/reader logs, records store, SQLite) so a miss can be traced after the batch. It only skips the
# harness's rmtree at stop: the number is the same harness. The scratch lands under $SCRATCH_BASE/<batch id>/ via
# TMPDIR (the harness mkdtemp's it; there is no --scratch-root flag), OUTSIDE every git checkout, because worldtree-dev
# commits the run dirs and a SQLite must never ride into the repo. Retention 14 days: lkraven's user tmpfiles rule
# (configs/wt-gate/wt-gate-scratch.conf -> ~/.config/user-tmpfiles.d/), not an rm in this script.
cmd=(python -m core.memory_acceptance.live --runs 3 --gate cmd=(python -m core.memory_acceptance.live --runs 3 --gate
"${legacy_args[@]}" --label "$WT_BATCH_LABEL" --out "$OUT_DIR") "${legacy_args[@]}" --label "$WT_BATCH_LABEL" --out "$OUT_DIR" --keep-data)
echo "wt-memory-gate-batch $(now)" echo "wt-memory-gate-batch $(now)"
echo " demo image $image" echo " demo image $image"
@@ -139,8 +146,12 @@ if [[ "$run_tree" == "$WT_GATE_TREE" ]]; then
fi fi
# ── 4. run ────────────────────────────────────────────────────────────────── # ── 4. run ──────────────────────────────────────────────────────────────────
log="$STATE_DIR/$(date -u +%Y%m%dT%H%M%SZ).log" # stderr (progress, errors) bid="$(date -u +%Y%m%dT%H%M%SZ)" # this batch's id: names the log and the scratch parent
log="$STATE_DIR/$bid.log" # stderr (progress, errors)
out="${log%.log}.stdout" # stdout; its last line is the run dir out="${log%.log}.stdout" # stdout; its last line is the run dir
scratch_parent="$SCRATCH_BASE/$bid"
[[ ! -e "$scratch_parent" ]] || refuse "scratch parent $scratch_parent already exists (the harness needs an empty scratch per batch)"
mkdir -p -m 0700 "$scratch_parent" || refuse "could not create $scratch_parent"
echo " log $log" echo " log $log"
set +e set +e
( (
@@ -157,6 +168,7 @@ set +e
# Remove this only on worldtree-dev's word, and then say so in the run notes. # Remove this only on worldtree-dev's word, and then say so in the run notes.
unset ALBOK_SERVICE ALBOK_TOKEN unset ALBOK_SERVICE ALBOK_TOKEN
export WORLDTREE_ROOT="$run_tree" export WORLDTREE_ROOT="$run_tree"
export TMPDIR="$scratch_parent" # the harness's mkdtemp(prefix="wt-tracer-") lands here, and --keep-data keeps it
# The editable install maps packages/ to the main tree; put the tree under # The editable install maps packages/ to the main tree; put the tree under
# test first (identical content is guaranteed by step 2, this keeps it explicit). # test first (identical content is guaranteed by step 2, this keeps it explicit).
export PYTHONPATH="$run_tree/packages/worldtree-memory/src${PYTHONPATH:+:$PYTHONPATH}" export PYTHONPATH="$run_tree/packages/worldtree-memory/src${PYTHONPATH:+:$PYTHONPATH}"
@@ -174,11 +186,13 @@ if [[ "$rc" -ne 0 || ! -f "$run_dir/trace1.md" ]]; then
fi fi
stamp="$(basename "$run_dir")" stamp="$(basename "$run_dir")"
kept="$(find "$scratch_parent" -mindepth 1 -maxdepth 1 -type d -name 'wt-tracer-*' -print -quit)"
verdict_line="$(grep -m1 -E '^Aggregate label: .*verdict: \*\*(PASS|FAIL)\*\*' "$run_dir/trace1.md" || true)" verdict_line="$(grep -m1 -E '^Aggregate label: .*verdict: \*\*(PASS|FAIL)\*\*' "$run_dir/trace1.md" || true)"
verdict="$(sed -nE 's/.*verdict: \*\*(PASS|FAIL)\*\*.*/\1/p' <<<"$verdict_line")" verdict="$(sed -nE 's/.*verdict: \*\*(PASS|FAIL)\*\*.*/\1/p' <<<"$verdict_line")"
echo " run stamp $stamp" echo " run stamp $stamp"
echo " verdict ${verdict:-NONE}" echo " verdict ${verdict:-NONE}"
echo " line ${verdict_line:-<no Aggregate verdict line in trace1.md>}" echo " line ${verdict_line:-<no Aggregate verdict line in trace1.md>}"
echo " kept scratch ${kept:-<none found under $scratch_parent>} (memory/writer, memory/reader; kept 14 days)"
case "$verdict" in case "$verdict" in
PASS) echo "→ report to worldtree-dev today with run stamp $stamp (PASS builds the n)."; exit 0 ;; PASS) echo "→ report to worldtree-dev today with run stamp $stamp (PASS builds the n)."; exit 0 ;;
FAIL) echo "→ report to worldtree-dev TODAY with run stamp $stamp. Do not retry." >&2; exit 1 ;; FAIL) echo "→ report to worldtree-dev TODAY with run stamp $stamp. Do not retry." >&2; exit 1 ;;