[EPIC] Agentic Prolog RLM v0.1 #424

Closed
opened 2026-09-10 21:18:00 +00:00 by nsaspy · 1 comment
Owner

Goal

Deliver a usable prolog-rlm: a real SWI-Prolog language-model harness with external context, typed model-selected plans, capability-gated tools, bounded recursion, supervised agents, durable graph execution, structured traces, and dual-version MCP interoperability.

Current state — 2026-08-21

Canonical main inspected for this reconciliation: 290a87f5cff3a2c21b689877b167fa27dae16f61.

The original implementation dependency graph is complete: issues #4 through #20 are closed. This epic remains open as the v0.1/manual-validation umbrella, not as a container for every later feature idea.

The focused correctness blockers discovered during the depth/manual-validation audit are now complete:

  • #42 Canonicalize recursive-plan fingerprints before cycle detection. Merged in PR #135 on 2026-08-20.
  • #44 Preserve provider usage when completion plan execution fails. Merged in PR #134 on 2026-08-20.
  • #45 Preserve nested model events and true depths in completion trajectories. Merged in PR #139 on 2026-08-21.
  • #46 Make the live OpenRouter streaming gate router-safe. Merged in PR #138 on 2026-08-21.

The first clean-install validation slice is also merged:

  • #140 verifies a copied SWI pack install into an isolated pack root, then loads library(rlm) from a fresh SWI process outside the source checkout. The core pack no longer implicitly builds optional Tree-sitter support during SWI pack installation.

#44 aggregates planner + executed-model usage from the authoritative model_responses ledger on execution-error paths. #42 canonicalizes recursive-plan fingerprints before cycle detection. #46 keeps the live free-router streaming gate transport-safe without treating arbitrary routed-model sentinel compliance as deterministic semantics. #45 now records an authoritative append-only model-event ledger at execution time, preserving deterministic order, stable parent lineage, true depth, provider/model/status metadata, and usage across nested lexical scope restoration.

Later architecture tracks such as #49/#50, #54, #56/#57/#79, #68-#71, #74-#77, #93/#95-#99, #101/#107/#117, and #124/#126-#131 remain important follow-up work, but they are not retroactively added as v0.1 blockers here unless this epic's acceptance scope is explicitly changed.

Manual full-system validation remains the active umbrella gate. Validate the supported installation/build path from a clean environment, full repository suite, representative real-provider model -> plan -> execute -> model behavior, capability-gated tools, depth-1 recursion, persistence/recovery, bounded failure/cancellation behavior, configuration/docs, and required CI on current main. If testing exposes a regression in a previously completed slice, reopen the corresponding issue or create a focused regression issue when no prior issue maps cleanly, then reconcile TODO.md, README/status prose, roadmap text, and related parent/child issue state in the same slice.

P0 — First real RLM

  • #4 Bootstrap SWI-Prolog project structure, tests, and CI
  • #5 Implement provider-neutral model API with a real OpenAI-compatible backend
  • #6 Build opaque external context store and context operations
  • #7 Implement typed plan AST, validator, and interpreter
  • #8 Add capability-gated tool registry and one real tool
  • #9 Implement rlm_completion/4 with depth-1 recursion, budgets, cancellation, and tracing
  • #10 Add structured execution outcomes, trace inspection, and repair primitives

P0 exit criteria

A real-provider end-to-end run must use an external context handle, a model-selected typed plan, at least one capability-gated tool, one depth-1 recursive call, hard budgets/cancellation, and structured trajectory/outcome terms. Fake providers remain test doubles only.

The runtime implements these surfaces, and the focused #42/#44/#45/#46 correctness defects are closed. Final acceptance now depends on observing the complete supported path succeed together under the manual full-system validation gate rather than inferring readiness from component completion alone.

P1 — Agent runtime, durability, MCP, evaluation

  • #11 Implement rlm_agent supervision with engines, mailboxes, and bounded workers
  • #12 Implement rlm_graph state graphs, checkpoints, interrupts, and resumable execution
  • #13 Expand rlm_chain with messages, structured output, retries, streaming, and middleware
  • #14 Implement canonical rlm_mcp model plus MCP 2025-11-25 client/server adapter
  • #15 Add MCP 2026-07-28 adapter, dual-version negotiation, and conformance matrix
  • #16 Add durable artifact/blackboard state and fresh-root context handoff
  • #17 Implement adaptive recursion routing and candidate context-program selection
  • #18 Build benchmark and conformance suite for RLM, agents, and MCP

MCP compatibility rule

Support both MCP 2025-11-25 and 2026-07-28 behind one canonical internal API. Prefer 2026 when explicit mutual support is known; fall back to 2025 for legacy peers. Version-specific behavior must not leak into rlm_agent or rlm_graph.

P2 — Developer experience and experimental recursion

  • #19 Add CLI, interactive demo, examples, and trace export/visualization
  • #20 Experiment with depth >1 recursion and recursive agent harnesses

CI evidence

GitHub Actions is the execution oracle. Do not freeze a transient latest-run result into this epic as durable state. The merged CI contract includes deterministic unit/load checks, benchmark/conformance, deep-recursion experiments, credential-free CLI/trace and restart checks, plus credentialed REAL OpenRouter integration including structured repair, benchmark, depth 0/1/2, and one-command RLM CLI smoke. The merged clean-pack workflow separately installs the checkout as a copied SWI pack and loads the installed library(rlm) from a fresh process outside the checkout.

Research basis

Implementation choices are grounded in the repository's numbered RLM research records, including RLM/scaffold/harness work, lambda-RLM, PrologMCP, SWI engines/message queues, LangChain/LangGraph semantics, MCP dual-version research, adaptive recursion, durable artifact context, and the newer logic-native control/prompt-compilation work as it lands canonically.

## Goal Deliver a usable `prolog-rlm`: a real SWI-Prolog language-model harness with external context, typed model-selected plans, capability-gated tools, bounded recursion, supervised agents, durable graph execution, structured traces, and dual-version MCP interoperability. ## Current state — 2026-08-21 Canonical `main` inspected for this reconciliation: `290a87f5cff3a2c21b689877b167fa27dae16f61`. The original implementation dependency graph is complete: issues #4 through #20 are closed. This epic remains open as the **v0.1/manual-validation umbrella**, not as a container for every later feature idea. The focused correctness blockers discovered during the depth/manual-validation audit are now complete: - [x] #42 Canonicalize recursive-plan fingerprints before cycle detection. Merged in PR #135 on 2026-08-20. - [x] #44 Preserve provider usage when completion plan execution fails. Merged in PR #134 on 2026-08-20. - [x] #45 Preserve nested model events and true depths in completion trajectories. Merged in PR #139 on 2026-08-21. - [x] #46 Make the live OpenRouter streaming gate router-safe. Merged in PR #138 on 2026-08-21. The first clean-install validation slice is also merged: - [x] #140 verifies a copied SWI pack install into an isolated pack root, then loads `library(rlm)` from a fresh SWI process outside the source checkout. The core pack no longer implicitly builds optional Tree-sitter support during SWI pack installation. #44 aggregates planner + executed-model usage from the authoritative `model_responses` ledger on execution-error paths. #42 canonicalizes recursive-plan fingerprints before cycle detection. #46 keeps the live free-router streaming gate transport-safe without treating arbitrary routed-model sentinel compliance as deterministic semantics. #45 now records an authoritative append-only model-event ledger at execution time, preserving deterministic order, stable parent lineage, true depth, provider/model/status metadata, and usage across nested lexical scope restoration. Later architecture tracks such as #49/#50, #54, #56/#57/#79, #68-#71, #74-#77, #93/#95-#99, #101/#107/#117, and #124/#126-#131 remain important follow-up work, but they are not retroactively added as v0.1 blockers here unless this epic's acceptance scope is explicitly changed. **Manual full-system validation remains the active umbrella gate.** Validate the supported installation/build path from a clean environment, full repository suite, representative real-provider model -> plan -> execute -> model behavior, capability-gated tools, depth-1 recursion, persistence/recovery, bounded failure/cancellation behavior, configuration/docs, and required CI on current `main`. If testing exposes a regression in a previously completed slice, reopen the corresponding issue or create a focused regression issue when no prior issue maps cleanly, then reconcile `TODO.md`, README/status prose, roadmap text, and related parent/child issue state in the same slice. ## P0 — First real RLM - [x] #4 Bootstrap SWI-Prolog project structure, tests, and CI - [x] #5 Implement provider-neutral model API with a real OpenAI-compatible backend - [x] #6 Build opaque external context store and context operations - [x] #7 Implement typed plan AST, validator, and interpreter - [x] #8 Add capability-gated tool registry and one real tool - [x] #9 Implement `rlm_completion/4` with depth-1 recursion, budgets, cancellation, and tracing - [x] #10 Add structured execution outcomes, trace inspection, and repair primitives ### P0 exit criteria A real-provider end-to-end run must use an external context handle, a model-selected typed plan, at least one capability-gated tool, one depth-1 recursive call, hard budgets/cancellation, and structured trajectory/outcome terms. Fake providers remain test doubles only. The runtime implements these surfaces, and the focused #42/#44/#45/#46 correctness defects are closed. Final acceptance now depends on observing the complete supported path succeed together under the manual full-system validation gate rather than inferring readiness from component completion alone. ## P1 — Agent runtime, durability, MCP, evaluation - [x] #11 Implement `rlm_agent` supervision with engines, mailboxes, and bounded workers - [x] #12 Implement `rlm_graph` state graphs, checkpoints, interrupts, and resumable execution - [x] #13 Expand `rlm_chain` with messages, structured output, retries, streaming, and middleware - [x] #14 Implement canonical `rlm_mcp` model plus MCP 2025-11-25 client/server adapter - [x] #15 Add MCP 2026-07-28 adapter, dual-version negotiation, and conformance matrix - [x] #16 Add durable artifact/blackboard state and fresh-root context handoff - [x] #17 Implement adaptive recursion routing and candidate context-program selection - [x] #18 Build benchmark and conformance suite for RLM, agents, and MCP ### MCP compatibility rule Support both MCP `2025-11-25` and `2026-07-28` behind one canonical internal API. Prefer 2026 when explicit mutual support is known; fall back to 2025 for legacy peers. Version-specific behavior must not leak into `rlm_agent` or `rlm_graph`. ## P2 — Developer experience and experimental recursion - [x] #19 Add CLI, interactive demo, examples, and trace export/visualization - [x] #20 Experiment with depth >1 recursion and recursive agent harnesses ## CI evidence GitHub Actions is the execution oracle. Do not freeze a transient latest-run result into this epic as durable state. The merged CI contract includes deterministic unit/load checks, benchmark/conformance, deep-recursion experiments, credential-free CLI/trace and restart checks, plus credentialed REAL OpenRouter integration including structured repair, benchmark, depth 0/1/2, and one-command RLM CLI smoke. The merged clean-pack workflow separately installs the checkout as a copied SWI pack and loads the installed `library(rlm)` from a fresh process outside the checkout. ## Research basis Implementation choices are grounded in the repository's numbered RLM research records, including RLM/scaffold/harness work, lambda-RLM, PrologMCP, SWI engines/message queues, LangChain/LangGraph semantics, MCP dual-version research, adaptive recursion, durable artifact context, and the newer logic-native control/prompt-compilation work as it lands canonically.
Author
Owner

Duplicate of #3 (pre-existing Forgejo mirror with GitHub number parity). Closing this accidental duplicate created by today's open-state sync; #3 stays canonical on Forgejo.

Duplicate of #3 (pre-existing Forgejo mirror with GitHub number parity). Closing this accidental duplicate created by today's open-state sync; #3 stays canonical on Forgejo.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nsaspy/prolog-rlm#424
No description provided.