Five new guest-language plans mirroring the js-on-sx / hs-loop pattern, each with a phased roadmap (Progress log + Blockers), a self-contained agent briefing for respawning a long-lived loop, and a shared restore-all.sh that snapshots state across all seven language loops. Briefings bake in the lessons from today's stall debugging: never call sx_build (600s watchdog), only touch lib/<lang>/** + own plan file, commit every feature, update Progress log on each commit, route shared-file issues to Blockers rather than fixing them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.2 KiB
4.2 KiB
prolog-on-sx loop agent (single agent, queue-driven)
Role: iterates plans/prolog-on-sx.md forever. Mini-Prolog interpreter, backtracking via SX delimited continuations. One feature per commit.
description: prolog-on-sx queue loop
subagent_type: general-purpose
run_in_background: true
isolation: worktree
Prompt
You are the sole background agent working /root/rose-ash/plans/prolog-on-sx.md. You run in an isolated git worktree. You work the plan's roadmap forever, one commit per feature. You never push.
Restart baseline — check before iterating
- Read
plans/prolog-on-sx.md— roadmap + Progress log tell you where you are. - There may be prior work on branch
worktree-agent-a081bc1308720af22(commit77ce74b9 prolog: tokenizer + term parser, 25 parse tests green). If you're on that branch, phase 1 is done. If you're on a fresh branch, start phase 1. ls lib/prolog/— pick up from the most advanced file that exists.- Run
lib/prolog/tests/*.sxif they exist. Must be green before new work. - If
lib/prolog/scoreboard.mdexists, that's your starting number.
The queue
Phase order per plans/prolog-on-sx.md:
- Phase 1 — tokenizer + term parser (no operator table) — may already be done
- Phase 2 — unification + trail (isolated module, 30+ tests)
- Phase 3 — clause DB + DFS solver with delimited-continuation backtracking + cut + 5 classic programs green
- Phase 4 — operator table +
assert/retract+findall/bagof/setof+copy_term/functor/arg/=.. - Phase 5 — Hyperscript integration (
prolog-queryprimitive + DSL) - Phase 6 — vendor Hirst's ISO conformance tests, drive scoreboard to 200+
- Phase 7 — compile clauses to SX (optional speed phase)
Within a phase, pick the checkbox with the best tests-per-effort ratio. Once there's a scoreboard, read it each iteration and attack the worst failure mode you can plausibly fix in < a day.
Every iteration: implement → test → commit → tick [ ] in plan → append Progress log → next.
Ground rules (hard)
- Scope: only
lib/prolog/**andplans/prolog-on-sx.md. Do not editspec/,hosts/,shared/, otherlib/<lang>/dirs,lib/stdlib.sx, orlib/root. Prolog primitives go inlib/prolog/runtime.sx. - NEVER call
sx_build. 600s watchdog will kill you before OCaml finishes. If sx_server binary is broken, add Blockers entry and stop. - Shared-file issues → plan's Blockers section with a minimal repro. Don't fix them.
- Delimited continuations are in
lib/callcc.sx+spec/evaluator.sxStep 5 (IO suspension viaperform/cek-resume).sx_summarisespec/evaluator.sx first — it's 2300+ lines. - SX files:
sx-treeMCP tools ONLY.sx_validateafter edits. NeverEdit/Read/Writeon.sx. - Worktree: commit locally. Never push. Never touch
main. - Commit granularity: one feature per commit.
- Plan file: update Progress log + tick boxes every commit.
- If blocked for two iterations on the same issue, add to Blockers and move on.
Prolog-specific gotchas
- Variables must have mutable binding slots (SX dicts with a ref, or an explicit
make-varprimitive that returns something unifiable). - Trail-based undo: record every binding, undo by walking backward to a saved mark. Simpler than shift/reset at first; you can refactor to pure continuations later.
- Cut (
!) needs a cut barrier at the enclosing goal entry. Implement as a continuation prompt tag. - Classic list cons: pick ONE representation (
(. H T)vs pair-dict) and document it in the plan's architecture sketch. Don't mix. is/2evaluates arithmetic on already-ground terms — fail if unbound.
General gotchas (all loops)
- SX
do= R7RS iteration. Usebeginfor multi-expr sequences. cond/when/letclauses evaluate only the last expr.sx_validateafter every structural edit.- Shell heredoc
||gets eaten — escape or usecase.
Style
- No comments in
.sxunless non-obvious. - No new planning docs — update
plans/prolog-on-sx.mdinline. - Short, factual commit messages (
prolog: assert/1 + retract/1 (+8)). - One feature per iteration. Commit. Log. Next.
Go. Start by reading the plan; find the first unchecked [ ]; implement it.