plans: briefings + roadmaps for lua, prolog, forth, erlang, haskell
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>
This commit is contained in:
75
plans/agent-briefings/erlang-loop.md
Normal file
75
plans/agent-briefings/erlang-loop.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# erlang-on-sx loop agent (single agent, queue-driven)
|
||||
|
||||
Role: iterates `plans/erlang-on-sx.md` forever. Actors + mailboxes + selective receive on delimited continuations. The million-process ring benchmark is the headline showcase.
|
||||
|
||||
```
|
||||
description: erlang-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/erlang-on-sx.md`. Isolated worktree, forever, one commit per feature. Never push.
|
||||
|
||||
## Restart baseline — check before iterating
|
||||
|
||||
1. Read `plans/erlang-on-sx.md` — roadmap + Progress log.
|
||||
2. `ls lib/erlang/` — pick up from the most advanced file.
|
||||
3. If `lib/erlang/tests/*.sx` exist, run them. Green before new work.
|
||||
4. If `lib/erlang/scoreboard.md` exists, that's your baseline.
|
||||
|
||||
## The queue
|
||||
|
||||
Phase order per `plans/erlang-on-sx.md`:
|
||||
|
||||
- **Phase 1** — tokenizer + parser (atoms, vars, tuples, lists, binaries, clauses with patterns + guards)
|
||||
- **Phase 2** — sequential eval + pattern matching + guards + core BIFs (`length`, `hd`, `tl`, `element`, `lists:map`, `io:format`)
|
||||
- **Phase 3** — **THE SHOWCASE**: scheduler + processes + mailboxes + `spawn`/`!`/`receive` via delimited continuations. 5 classic programs (ring, ping_pong, bank, echo, fib_server) green. Million-process ring benchmark works.
|
||||
- **Phase 4** — links, monitors, exit signals, `try/catch`
|
||||
- **Phase 5** — modules + `M:F(...)` cross-module calls + `gen_server` + `supervisor` + registered processes
|
||||
- **Phase 6** — list comprehensions + binary pattern matching + ETS-lite + drive corpus to 200+
|
||||
|
||||
Within a phase, pick the checkbox that unlocks the most tests per effort.
|
||||
|
||||
Every iteration: implement → test → commit → tick `[ ]` → Progress log → next.
|
||||
|
||||
## Ground rules (hard)
|
||||
|
||||
- **Scope:** only `lib/erlang/**` and `plans/erlang-on-sx.md`. Do **not** edit `spec/`, `hosts/`, `shared/`, other `lib/<lang>/` dirs, `lib/stdlib.sx`, or `lib/` root. Erlang primitives go in `lib/erlang/runtime.sx`.
|
||||
- **NEVER call `sx_build`.** 600s watchdog. If sx_server binary broken → Blockers entry, stop.
|
||||
- **Shared-file issues** → plan's Blockers with minimal repro.
|
||||
- **Delimited continuations** are in `lib/callcc.sx` + `spec/evaluator.sx` Step 5. `sx_summarise` spec/evaluator.sx first — 2300+ lines.
|
||||
- **SX files:** `sx-tree` MCP tools ONLY. `sx_validate` after edits.
|
||||
- **Worktree:** commit locally. Never push. Never touch `main`.
|
||||
- **Commit granularity:** one feature per commit.
|
||||
- **Plan file:** update Progress log + tick boxes every commit.
|
||||
|
||||
## Erlang-specific gotchas
|
||||
|
||||
- **Process** = record with `{pid, mailbox, state, continuation, links, monitors, trap_exit?}`. Scheduler queue is a list of runnable pids.
|
||||
- **`receive`** is selective — scan mailbox in order, try each pattern, bind on match, **keep unmatched messages in mailbox**. If no match, `perform` a suspend with the receive pattern; scheduler resumes the continuation when a matching message arrives.
|
||||
- **`after N -> ...`** timeout uses SX timer primitive; if no match within N ms, run the after-branch.
|
||||
- **Pattern matching on tuples/lists** is SX `case` on tagged values — bound variables must re-unify, not rebind.
|
||||
- **Guards are pure** — compile-time check that no side-effecting calls appear.
|
||||
- **Immutable data** — no in-place mutation; sends copy.
|
||||
- Atoms are interned strings.
|
||||
- Don't go near the preprocessor (`-define`, `-ifdef`). Out of scope.
|
||||
- Test corpus is custom (not BEAM conformance). Write your own plus classic programs in `lib/erlang/tests/programs/`.
|
||||
|
||||
## General gotchas (all loops)
|
||||
|
||||
- SX `do` = R7RS iteration. Use `begin` for multi-expr sequences.
|
||||
- `cond`/`when`/`let` clauses evaluate only the last expr.
|
||||
- `type-of` on user fn returns `"lambda"`.
|
||||
- Shell heredoc `||` gets eaten — escape or use `case`.
|
||||
|
||||
## Style
|
||||
|
||||
- No comments in `.sx` unless non-obvious.
|
||||
- No new planning docs — update `plans/erlang-on-sx.md` inline.
|
||||
- Short, factual commit messages (`erlang: spawn/1 + basic scheduler (+5)`).
|
||||
- One feature per iteration. Commit. Log. Next.
|
||||
|
||||
Go. Read the plan; find first `[ ]`; implement.
|
||||
71
plans/agent-briefings/forth-loop.md
Normal file
71
plans/agent-briefings/forth-loop.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# forth-on-sx loop agent (single agent, queue-driven)
|
||||
|
||||
Role: iterates `plans/forth-on-sx.md` forever. ANS-Forth 1994, Hayes Core conformance is the north star.
|
||||
|
||||
```
|
||||
description: forth-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/forth-on-sx.md`. Isolated worktree, forever, one commit per feature. Never push.
|
||||
|
||||
## Restart baseline — check before iterating
|
||||
|
||||
1. Read `plans/forth-on-sx.md` — roadmap + Progress log.
|
||||
2. `ls lib/forth/` — pick up from the most advanced file.
|
||||
3. If `lib/forth/tests/*.sx` exist, run them. Green before new work.
|
||||
4. If `lib/forth/scoreboard.md` exists, that's your baseline; attack worst failure mode.
|
||||
|
||||
## The queue
|
||||
|
||||
Phase order per `plans/forth-on-sx.md`:
|
||||
|
||||
- **Phase 1** — reader + interpret mode + core stack/arith/cmp/logic/IO words
|
||||
- **Phase 2** — colon definitions + compile mode + `VARIABLE`/`CONSTANT`/`VALUE`/`@`/`!`
|
||||
- **Phase 3** — control flow (`IF`/`ELSE`/`THEN`, `BEGIN`/`UNTIL`/`WHILE`/`REPEAT`/`AGAIN`, `DO`/`LOOP`, return stack) + vendor Hayes suite + first scoreboard
|
||||
- **Phase 4** — strings, `BASE` manipulation, more Core words
|
||||
- **Phase 5** — Core Extension, File/String word sets, drive to 100% Hayes
|
||||
- **Phase 6** — inline primitive compile + TCO colon-def endings + JIT cooperation
|
||||
|
||||
Within a phase, pick the checkbox that gets the most Hayes tests passing per unit of effort.
|
||||
|
||||
Every iteration: implement → test → commit → tick `[ ]` → append Progress log → next.
|
||||
|
||||
## Ground rules (hard)
|
||||
|
||||
- **Scope:** only `lib/forth/**` and `plans/forth-on-sx.md`. Do **not** edit `spec/`, `hosts/`, `shared/`, other `lib/<lang>/` dirs, `lib/stdlib.sx`, or `lib/` root. Forth primitives go in `lib/forth/runtime.sx`.
|
||||
- **NEVER call `sx_build`.** 600s watchdog. If sx_server binary broken → Blockers entry, stop.
|
||||
- **Shared-file issues** → plan's Blockers with minimal repro.
|
||||
- **SX files:** `sx-tree` MCP tools ONLY. `sx_validate` after edits.
|
||||
- **Worktree:** commit locally. Never push. Never touch `main`.
|
||||
- **Commit granularity:** one feature per commit.
|
||||
- **Plan file:** update Progress log + tick boxes every commit.
|
||||
|
||||
## Forth-specific gotchas
|
||||
|
||||
- **Case-insensitive** — lowercase on lookup.
|
||||
- Compile mode flag lives on interpreter state; `:` sets, `;` clears.
|
||||
- IMMEDIATE words run at compile time even inside definitions — critical for `IF`/`ELSE`/`THEN` implementation.
|
||||
- Return stack is separate from data stack. `>R`/`R>` move between them.
|
||||
- `BASE` is a user-manipulable variable; number parsing must respect it.
|
||||
- Colon-def body = SX lambda. Run on the CEK, inherit TCO.
|
||||
- For Hayes suite: Gerry Jackson's `gerryjackson/forth2012-test-suite` on GitHub has the Core subset. Vendor `src/core.fth` + `src/tester.fr`. Document which source in Progress log.
|
||||
|
||||
## General gotchas (all loops)
|
||||
|
||||
- SX `do` = R7RS iteration. Use `begin` for multi-expr sequences.
|
||||
- `cond`/`when`/`let` clauses evaluate only the last expr.
|
||||
- Shell heredoc `||` gets eaten — escape or use `case`.
|
||||
|
||||
## Style
|
||||
|
||||
- No comments in `.sx` unless non-obvious.
|
||||
- No new planning docs — update `plans/forth-on-sx.md` inline.
|
||||
- Short, factual commit messages (`forth: DO/LOOP + return stack (+12)`).
|
||||
- One feature per iteration. Commit. Log. Next.
|
||||
|
||||
Go. Read the plan; find first `[ ]`; implement.
|
||||
76
plans/agent-briefings/haskell-loop.md
Normal file
76
plans/agent-briefings/haskell-loop.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# haskell-on-sx loop agent (single agent, queue-driven)
|
||||
|
||||
Role: iterates `plans/haskell-on-sx.md` forever. Mini-Haskell 98 with real laziness (SX thunks are first-class). Phases 1-3 are untyped — laziness + ADTs first; HM inference is phase 4.
|
||||
|
||||
```
|
||||
description: haskell-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/haskell-on-sx.md`. Isolated worktree, forever, one commit per feature. Never push.
|
||||
|
||||
**Note:** there's an existing `/root/rose-ash/sx-haskell/` directory (~25 M). Check whether it has prior work you should fold into `lib/haskell/` rather than starting from scratch. Summarise what you find in the first iteration's Progress log entry; do not edit `sx-haskell/` itself.
|
||||
|
||||
## Restart baseline — check before iterating
|
||||
|
||||
1. Read `plans/haskell-on-sx.md` — roadmap + Progress log.
|
||||
2. First-run only: peek at `/root/rose-ash/sx-haskell/` — does any of it belong in `lib/haskell/`? Report in Progress log. Don't edit sx-haskell/.
|
||||
3. `ls lib/haskell/` — pick up from the most advanced file.
|
||||
4. Run `lib/haskell/tests/*.sx` if they exist. Green before new work.
|
||||
5. If `lib/haskell/scoreboard.md` exists, that's your baseline.
|
||||
|
||||
## The queue
|
||||
|
||||
Phase order per `plans/haskell-on-sx.md`:
|
||||
|
||||
- **Phase 1** — tokenizer + parser + **layout rule** (indentation-sensitive, painful but required per Haskell 98 §10.3)
|
||||
- **Phase 2** — desugar + eager eval + ADTs (`data` declarations, constructor tagging, pattern matching). Still untyped.
|
||||
- **Phase 3** — **laziness**: thunk-wrap every application arg, `force` = WHNF, pattern match forces scrutinee. Classic programs (infinite Fibonacci, sieve of Eratosthenes, quicksort, n-queens, expression calculator) green.
|
||||
- **Phase 4** — Hindley-Milner type inference (Algorithm W, let-polymorphism, type-sig checking)
|
||||
- **Phase 5** — typeclasses (dictionary passing, Eq/Ord/Show/Num/Functor/Monad/Applicative, `deriving`)
|
||||
- **Phase 6** — real `IO` monad backed by `perform`/`resume`, full Prelude, drive corpus to 150+
|
||||
|
||||
Within a phase, pick the checkbox with the best tests-per-effort ratio.
|
||||
|
||||
Every iteration: implement → test → commit → tick `[ ]` → Progress log → next.
|
||||
|
||||
## Ground rules (hard)
|
||||
|
||||
- **Scope:** only `lib/haskell/**` and `plans/haskell-on-sx.md`. Do **not** edit `spec/`, `hosts/`, `shared/`, other `lib/<lang>/` dirs, `lib/stdlib.sx`, `lib/` root, or `sx-haskell/`. Haskell primitives go in `lib/haskell/runtime.sx`.
|
||||
- **NEVER call `sx_build`.** 600s watchdog. If sx_server binary broken → Blockers entry, stop.
|
||||
- **Shared-file issues** → plan's Blockers with minimal repro.
|
||||
- **SX thunks** (`make-thunk`, force on use) are already in the trampolining evaluator — reuse. Don't invent your own thunk type.
|
||||
- **SX files:** `sx-tree` MCP tools ONLY. `sx_validate` after edits.
|
||||
- **Worktree:** commit locally. Never push. Never touch `main`.
|
||||
- **Commit granularity:** one feature per commit.
|
||||
- **Plan file:** update Progress log + tick boxes every commit.
|
||||
|
||||
## Haskell-specific gotchas
|
||||
|
||||
- **Layout rule is the hard bit of parsing** — you need a lexer-parser feedback loop that inserts virtual `{`, `;`, `}` based on indentation. Budget proportionally.
|
||||
- **Every application arg is a thunk** — compiling `f x y` to `(f (thunk x) (thunk y))` not `(f x y)`. Pattern-match forces.
|
||||
- **ADT representation:** tagged list, e.g. `data Maybe a = Nothing | Just a` → constructors are `(:Nothing)` (0-ary) and `(:Just <thunk>)` (1-ary). Pattern match on the head symbol.
|
||||
- **Let-polymorphism** (phase 4): generalise at let-binding boundaries only, not at lambda.
|
||||
- **Typeclass dictionaries** (phase 5): each class is a record type; each instance builds the record; method call = project + apply.
|
||||
- **`IO`** (phase 6): internally `World -> (a, World)` but in practice backed by `perform`/`resume` for real side effects. Desugar `do`-notation to `>>=`.
|
||||
- **Out of scope:** GHC extensions. No `DataKinds`, `GADTs`, `TypeFamilies`, `TemplateHaskell`. Stick to Haskell 98.
|
||||
|
||||
## General gotchas (all loops)
|
||||
|
||||
- SX `do` = R7RS iteration. Use `begin` for multi-expr sequences.
|
||||
- `cond`/`when`/`let` clauses evaluate only the last expr.
|
||||
- `type-of` on user fn returns `"lambda"`.
|
||||
- Shell heredoc `||` gets eaten — escape or use `case`.
|
||||
|
||||
## Style
|
||||
|
||||
- No comments in `.sx` unless non-obvious.
|
||||
- No new planning docs — update `plans/haskell-on-sx.md` inline.
|
||||
- Short, factual commit messages (`haskell: layout rule + first parse (+10)`).
|
||||
- One feature per iteration. Commit. Log. Next.
|
||||
|
||||
Go. Read the plan; (first run only) peek at sx-haskell/ and report; find first `[ ]`; implement.
|
||||
75
plans/agent-briefings/lua-loop.md
Normal file
75
plans/agent-briefings/lua-loop.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# lua-on-sx loop agent (single agent, queue-driven)
|
||||
|
||||
Role: iterates `plans/lua-on-sx.md` forever. One feature per commit. Scoreboard-driven once phase 3 is done: PUC-Rio 5.1.5 Core pass-rate is the north star.
|
||||
|
||||
```
|
||||
description: lua-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/lua-on-sx.md`. You run in an isolated git worktree. You work the plan's roadmap in phase order, forever, one commit per feature. You never push.
|
||||
|
||||
## Restart baseline — check before iterating
|
||||
|
||||
1. Read `plans/lua-on-sx.md` — the roadmap tells you what's done (`[x]`) and what's next (`[ ]`). The Progress log (newest-first) is your memory across crashes.
|
||||
2. `ls lib/lua/` — pick up from the most advanced file that exists.
|
||||
3. `bash lib/lua/conformance.sh` if it exists — current scoreboard is your starting number. If not yet created, that's phase 3 work.
|
||||
4. If `lib/lua/tests/` exists, run the SX unit tests. They must be green before you start new work.
|
||||
|
||||
## The queue
|
||||
|
||||
Work in phase order per `plans/lua-on-sx.md`. At the top level:
|
||||
|
||||
- **Phase 1** — tokenizer + parser (small snippets green first)
|
||||
- **Phase 2** — transpile arithmetic + control flow
|
||||
- **Phase 3** — tables + functions + first PUC-Rio scoreboard
|
||||
- **Phase 4** — metatables + `pcall`/`error` + generic `for`
|
||||
- **Phase 5** — coroutines via `perform`/`cek-resume` (showcase)
|
||||
- **Phase 6** — string/math/table/io stdlib
|
||||
- **Phase 7** — `require`/modules + drive conformance to 100%
|
||||
|
||||
Within a phase, pick the checkbox that unlocks the most tests per effort. Once the scoreboard exists, re-read `lib/lua/scoreboard.md` each iteration and attack the worst failure mode you can plausibly fix in < a day.
|
||||
|
||||
Every iteration:
|
||||
1. Implement
|
||||
2. Add/update tests in `lib/lua/tests/`
|
||||
3. Re-run conformance if it exists, regenerate scoreboard
|
||||
4. Commit with a short factual message (e.g. `lua: table constructor hash-part (+17)`)
|
||||
5. Tick the matching `[ ]` → `[x]` in `plans/lua-on-sx.md`
|
||||
6. Append a one-line dated bullet to the plan's Progress log (newest first)
|
||||
7. Move to next
|
||||
|
||||
## Ground rules (hard)
|
||||
|
||||
- **Scope:** only `lib/lua/**` and `plans/lua-on-sx.md`. Do **not** edit `spec/`, `hosts/`, `shared/`, `lib/js/**`, `lib/hyperscript/**`, `lib/prolog/**`, `lib/forth/**`, `lib/erlang/**`, `lib/haskell/**`, `lib/stdlib.sx`, or anything in `lib/` root. Lua primitives go in `lib/lua/runtime.sx`.
|
||||
- **NEVER call `sx_build`.** The 600s agent watchdog will kill you before an OCaml build finishes. If the sx_server binary is missing or broken, add a Blockers entry and stop — do not try to rebuild. Use the binary at `hosts/ocaml/_build/default/bin/sx_server.exe` if present.
|
||||
- **Shared-file issues** → plan's Blockers section with a minimal repro. Don't fix them.
|
||||
- **SX files:** `sx-tree` MCP tools ONLY (`sx_summarise`, `sx_read_subtree`, `sx_find_all`, `sx_get_context`, `sx_replace_node`, `sx_insert_child`, `sx_insert_near`, `sx_replace_by_pattern`, `sx_rename_symbol`, `sx_write_file`). Run `sx_validate` after edits. Never `Edit`/`Read`/`Write` on `.sx` files — a hook blocks it.
|
||||
- **Shell, Python, Markdown, JSON, Lua files:** edit normally.
|
||||
- **Worktree:** commit locally. Never push. Never touch `main`.
|
||||
- **Commit granularity:** one feature per commit. If partial, still commit — don't hoard.
|
||||
- **Tests:** never regress. If a feature needs a larger refactor, split into commits each green.
|
||||
- **Plan file:** update Progress log + tick boxes every commit. Don't rewrite history.
|
||||
- **If blocked** for two iterations on the same issue, add to Blockers and move on.
|
||||
|
||||
## Gotchas already learned (all loops)
|
||||
|
||||
- SX `do` is R7RS iteration — **use `begin`** for multi-expr sequences.
|
||||
- `cond` / `when` / `let` clauses evaluate only the last expr — wrap multi-expr bodies in `(begin ...)`.
|
||||
- `type-of` on user fn returns `"lambda"`. `type-of` on builtin returns `"function"`.
|
||||
- `&rest args` is SX varargs. `make-symbol` builds identifier symbols.
|
||||
- Shell heredoc `||` gets eaten by bash — escape or use `case`.
|
||||
- Lua tables map to SX dicts; `__meta` slot holds the metatable; never conflict with user keys.
|
||||
|
||||
## Style
|
||||
|
||||
- No comments in `.sx` unless non-obvious.
|
||||
- No new planning docs — update `plans/lua-on-sx.md` inline.
|
||||
- Short, factual commit messages.
|
||||
- One feature per iteration. Commit. Log. Next.
|
||||
|
||||
Go. Start by reading the plan to find the first unchecked `[ ]`, then implement it.
|
||||
74
plans/agent-briefings/prolog-loop.md
Normal file
74
plans/agent-briefings/prolog-loop.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# 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
|
||||
|
||||
1. Read `plans/prolog-on-sx.md` — roadmap + Progress log tell you where you are.
|
||||
2. There may be prior work on branch `worktree-agent-a081bc1308720af22` (commit `77ce74b9 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.
|
||||
3. `ls lib/prolog/` — pick up from the most advanced file that exists.
|
||||
4. Run `lib/prolog/tests/*.sx` if they exist. Must be green before new work.
|
||||
5. If `lib/prolog/scoreboard.md` exists, 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-query` primitive + 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/**` and `plans/prolog-on-sx.md`. Do **not** edit `spec/`, `hosts/`, `shared/`, other `lib/<lang>/` dirs, `lib/stdlib.sx`, or `lib/` root. Prolog primitives go in `lib/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.sx` Step 5 (IO suspension via `perform`/`cek-resume`). `sx_summarise` spec/evaluator.sx first — it's 2300+ lines.
|
||||
- **SX files:** `sx-tree` MCP tools ONLY. `sx_validate` after edits. Never `Edit`/`Read`/`Write` on `.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-var` primitive 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/2` evaluates arithmetic on already-ground terms — fail if unbound.
|
||||
|
||||
## General gotchas (all loops)
|
||||
|
||||
- SX `do` = R7RS iteration. Use `begin` for multi-expr sequences.
|
||||
- `cond`/`when`/`let` clauses evaluate only the last expr.
|
||||
- `sx_validate` after every structural edit.
|
||||
- Shell heredoc `||` gets eaten — escape or use `case`.
|
||||
|
||||
## Style
|
||||
|
||||
- No comments in `.sx` unless non-obvious.
|
||||
- No new planning docs — update `plans/prolog-on-sx.md` inline.
|
||||
- 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.
|
||||
Reference in New Issue
Block a user