Files
rose-ash/plans/restore-minikanren.sh
giles 9dd9fb9c37 plans: layered-stack framing + chisel sequence + loop scaffolding
Design + ops scaffolding for the next phase of work, none of it touching
substrate or guest code.

lib-guest.md: rewrites Architectural framing as a 5-layer stack
  (substrate → lib/guest → languages → shared/ → applications),
  recursive dependency-direction rule, scaled two-consumer rule. Adds
  Phase B (long-running stratification) with sub-layer matrix
  (core/typed/relational/effects/layout/lazy/oo), language profiles, and
  the long-running-discipline section. Preserves existing Phase A
  progress log and rules.

ocaml-on-sx.md: scope reduced to substrate validation + HM + reference
  oracle. Phases 1-5 + minimal stdlib slice + vendored testsuite slice.
  Dream carved out into dream-on-sx.md; Phase 8 (ReasonML) deferred.
  Records lib-guest sequencing dependency.

datalog-on-sx.md: adds Phase 4 built-in predicates + body arithmetic,
  Phase 6 magic sets, safety analysis in Phase 3, Non-goals section.

New chisel plans (forward-looking, not yet launchable):
  kernel-on-sx.md       — first-class everything, env-as-value endgame
  idris-on-sx.md        — dependent types, evidence chisel
  probabilistic-on-sx.md — weighted nondeterminism + traces
  maude-on-sx.md        — rewriting as primitive
  linear-on-sx.md       — resource model, artdag-relevant

Loop briefings (4 active, 1 cold):
  minikanren-loop.md, ocaml-loop.md, datalog-loop.md, elm-loop.md, koka-loop.md

Restore scripts mirror the loop pattern:
  restore-{minikanren,ocaml,datalog,jit-perf,lib-guest}.sh
  Each captures worktree state, plan progress, MCP health, tmux status.
  Includes the .mcp.json absolute-path patch instruction (fresh worktrees
  have no _build/, so the relative mcp_tree path fails on first launch).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:27:50 +00:00

146 lines
4.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# restore-minikanren.sh — print recovery state for the miniKanren-on-SX loop.
#
# The loop runs as a Claude Code instance inside a tmux session named `minikanren`,
# operating in a git worktree at /root/rose-ash-loops/minikanren on branch
# loops/minikanren. This script shows you where things stand. To respawn, see the
# bottom of the output.
#
# Usage:
# bash plans/restore-minikanren.sh # status snapshot
# bash plans/restore-minikanren.sh --print # also cat the briefing
#
set -uo pipefail
cd "$(dirname "$0")/.."
WT="/root/rose-ash-loops/minikanren"
echo "=== minikanren loop state ==="
echo
if [ -d "$WT" ]; then
echo "Worktree: $WT"
echo "Branch: $(git -C "$WT" rev-parse --abbrev-ref HEAD 2>/dev/null || echo '?')"
echo "HEAD: $(git -C "$WT" log -1 --oneline 2>/dev/null || echo '?')"
else
echo "Worktree: MISSING ($WT)"
echo " Recreate with:"
echo " git worktree add /root/rose-ash-loops/minikanren -b loops/minikanren architecture"
fi
echo
echo "=== Recent commits on lib/minikanren/ + plan ==="
if [ -d "$WT" ]; then
git -C "$WT" log -15 --oneline -- lib/minikanren/ plans/minikanren-on-sx.md plans/agent-briefings/minikanren-loop.md 2>/dev/null \
|| echo " (none yet)"
else
echo " (worktree missing)"
fi
echo
echo "=== lib/minikanren/ contents ==="
if [ -d "$WT/lib/minikanren" ]; then
ls -1 "$WT/lib/minikanren/" 2>/dev/null | sed 's/^/ /'
else
echo " (lib/minikanren/ does not exist yet — Phase 1 not started)"
fi
echo
echo "=== lib/guest/ prerequisites ==="
for f in lib/guest/lex.sx lib/guest/pratt.sx lib/guest/match.sx; do
if [ -f "$f" ]; then
printf " ✓ %s (%d lines)\n" "$f" "$(wc -l < "$f")"
else
printf " ✗ %s MISSING\n" "$f"
fi
done
echo
echo "=== Plan progress (phase checkboxes) ==="
if [ -f plans/minikanren-on-sx.md ]; then
awk '/^### Phase [0-9]/ {phase=$0; next}
/^- \[/ && phase {
if (!shown[phase]++) print " " phase
print " " $0
}
/^### Phase / && !/^### Phase [0-9]/ {phase=""}
/^## / && !/^### / {phase=""}' plans/minikanren-on-sx.md \
| head -60
else
echo " plans/minikanren-on-sx.md NOT found"
fi
echo
echo "=== Tests (if Phase 1+ shipped) ==="
if [ -d "$WT/lib/minikanren/tests" ]; then
ls -1 "$WT/lib/minikanren/tests/" 2>/dev/null | sed 's/^/ /'
else
echo " (no tests yet)"
fi
echo
echo "=== sx_server.exe ==="
if [ -x hosts/ocaml/_build/default/bin/sx_server.exe ]; then
echo " ✓ built"
else
echo " ✗ NOT built — loop conformance runs need it. Run: sx_build target=ocaml"
fi
echo
echo "=== tmux session 'minikanren' ==="
if command -v tmux >/dev/null && tmux has-session -t minikanren 2>/dev/null; then
echo " ✓ session live"
echo " Attach: tmux attach -t minikanren"
echo " Last 8 visible lines:"
tmux capture-pane -t minikanren -p 2>/dev/null \
| grep -v '^[[:space:]]*$' \
| tail -8 \
| sed 's/^/ /'
else
echo " ✗ session not running"
fi
echo
echo "=== Remote loops/minikanren ==="
if git ls-remote --exit-code origin loops/minikanren >/dev/null 2>&1; then
echo " ✓ origin/loops/minikanren exists"
if [ -d "$WT" ]; then
AHEAD=$(git -C "$WT" rev-list --count origin/loops/minikanren..HEAD 2>/dev/null || echo "?")
BEHIND=$(git -C "$WT" rev-list --count HEAD..origin/loops/minikanren 2>/dev/null || echo "?")
echo " local ahead: $AHEAD, local behind: $BEHIND"
fi
else
echo " (origin/loops/minikanren not yet pushed)"
fi
echo
echo "=== Briefing ==="
[ -f plans/agent-briefings/minikanren-loop.md ] \
&& echo " plans/agent-briefings/minikanren-loop.md" \
|| echo " briefing NOT found"
echo
echo "=== To respawn ==="
cat <<'EOF'
If the worktree is missing:
git worktree add /root/rose-ash-loops/minikanren -b loops/minikanren architecture
If the tmux session died:
tmux new-session -d -s minikanren -c /root/rose-ash-loops/minikanren
tmux send-keys -t minikanren 'claude' Enter
# wait until the Claude UI box appears, then:
tmux send-keys -t minikanren 'You are the miniKanren-on-SX loop runner. Read /root/rose-ash/plans/agent-briefings/minikanren-loop.md in full and follow the iteration protocol indefinitely. Run the pre-flight check first; if lib/guest/match.sx is missing or lib-guest Step 6 has regressed, stop and report. Worktree: /root/rose-ash-loops/minikanren on branch loops/minikanren. Push to origin/loops/minikanren after every commit. Never push to main or architecture. Resume from the first unchecked [ ] in plans/minikanren-on-sx.md.' Enter Enter
If the session is alive but stuck, attach with `tmux attach -t minikanren` and
unstick manually. The plan file is the source of truth — the loop reads it
fresh every iteration and picks up wherever the queue left off.
EOF
if [ "${1:-}" = "--print" ]; then
echo
echo "=== Briefing contents ==="
[ -f plans/agent-briefings/minikanren-loop.md ] && cat plans/agent-briefings/minikanren-loop.md
fi