feat: Prolog-RLM as a self-hosted language — stage0 kernel, stage1/stage2, RLM semantics, actors, MCP, RSI #464
Open
nsaspy
wants to merge 4 commits from
feat/prolog-rlm-language into main
pull from: feat/prolog-rlm-language
merge into: nsaspy:main
nsaspy:main
nsaspy:codex/claude-api-provider
nsaspy:codex/symbolic-experts
nsaspy:codex/openai-api-provider
nsaspy:feat/zai-provider-protocols
nsaspy:hardening/project-semantic-20260911
nsaspy:hardening/ws7-nix-ci-pinning
nsaspy:chore/track-prolog
nsaspy:rage/98-semantic-project-knowledge
nsaspy:fix/339-agent-zero-skill-graph
nsaspy:ci/tree-sitter-runner-labels
nsaspy:issue-293
nsaspy:research/text-streaming
nsaspy:docs/agent-editor-handoff
nsaspy:icon-add
nsaspy:hydra/fleet-jobs-20260904
nsaspy:rage/355-d6-11-plan-native-dispatch
nsaspy:cd/nix-installer-action-url
nsaspy:issue-355
nsaspy:rage/97-query-capture-apis
nsaspy:research/expert-direct-tool-projection
nsaspy:rage/96-versioned-syntax-facts
nsaspy:fix/direct-deadline-typing
nsaspy:dogfood/auto-dig-native-tools
nsaspy:feature/rage-feature-freeze
nsaspy:fix/323-native-batch-cardinality
nsaspy:fix/328-direct-user-namespace-text-string
nsaspy:fix/transient-provider-retry-2026-09-01
nsaspy:fix/openrouter-dotted-tool-result-name
nsaspy:rage/325-native-call-isolation
nsaspy:fix/316-original-batch-effect-isolation
nsaspy:fix/313-per-call-preflight
nsaspy:fix/312-peek-schema-contract
nsaspy:docs/agents-worktree-rule
nsaspy:fix/child-native-capability-narrowing
nsaspy:test/paid-lane-glm-53-flash
nsaspy:docs/spec-seeded-symbolic-plans
nsaspy:rage/290-spec-plan-authority
nsaspy:fix/304-context-peek-selector-contract
nsaspy:fix/298-native-any-json-schema
nsaspy:rage/288-spec-plan-graph-executor
nsaspy:feat/spec-plan-flow-api
nsaspy:prolog-rlm-v1
nsaspy:gpt-5-6-sol-high/questions-for-rlm-prolog-and-lambda-rlm
nsaspy:rage/277-planner-protocol-context
nsaspy:research-approval/rlm-research-026-task-deadlines-20260827135838
nsaspy:research-approval/rlm-research-025-lem-ui-20260827135751
nsaspy:rage/183-live-operator-behavior
nsaspy:agent/127-agentprolog-config
nsaspy:recovery/132-agentprolog-monorepo
nsaspy:rage/223-durable-context-mount-recovery
nsaspy:rage/223-constraint-benchmark-recovery
nsaspy:research-approval/rlm-research-011-managed-context-tool-discovery-20260827054019
nsaspy:feat/research-approval-schema
nsaspy:agent/rrlm-control-plane-research
nsaspy:docs/219-adrrd-review
nsaspy:salvage/231-runtime-status
nsaspy:salvage/231-runtime-status-run
nsaspy:tmp
nsaspy:tmp2
nsaspy:tmp3
nsaspy:rage/245-planner-structural-retry
nsaspy:rage/168-skill-selection-eval
nsaspy:rage/250-skill-catalog-graph
nsaspy:rage/56-result-acceptance
nsaspy:rage/172-parent-resume-replan
nsaspy:rage/175-deadline-policy-recovery
nsaspy:rage/257-provider-tool-choice-normalization
nsaspy:agent/tool-result-projection-presets
nsaspy:fix/234-numeric-schema-bounds
nsaspy:feature/231-rlm-cli-reference-harness
nsaspy:feature/223-durable-context-mounts
nsaspy:feature/223-real-constraint-benchmark
nsaspy:feature/223-real-constraint-benchmark-clean
nsaspy:feature/223-real-constraint-benchmark-final
nsaspy:feature/223-real-constraint-benchmark-impl
nsaspy:feature/223-real-constraint-benchmark-now
nsaspy:feature/223-real-constraint-benchmark-tdd
nsaspy:feature/223-real-constraint-benchmark-work
nsaspy:rage/176-root-planner-tool-projection
nsaspy:rage/172-typed-delegation-policy
nsaspy:rage/175-subagent-deadline-policy
nsaspy:rage/206-prompt-command-runtime
nsaspy:rage/203-subagent-skill-role-provenance
nsaspy:rage/200-permanent-rlm-context
nsaspy:fix/190-cli-help-success
nsaspy:archive/pr-132-agentprolog-config-20260827
nsaspy:feature/117-prolog-skill-activation-linear
nsaspy:feature/117-prolog-skill-activation
nsaspy:fix/194-completion-budget-usage
nsaspy:fix/191-capability-filtered-tool-schemas
nsaspy:fix/185-reasoning-effort
nsaspy:ci/report-workflow-failures-20260825
nsaspy:cleanup/186-remove-legacy-harnesses
nsaspy:fix/185-reasoning-routing
nsaspy:agent/evolution-async-evaluator
nsaspy:rage/181-binding-replay-race
nsaspy:agent/124-deepseek-harness-prolog
nsaspy:rage/144-fallback-closure
nsaspy:rage/164-conversation-metadata
nsaspy:agent/subagent-supervised-call-conformance
nsaspy:fix/160-context-adapter-closed-data
nsaspy:codex/move-agent-zero-adaptor
nsaspy:codex/sol-high-integration
nsaspy:fix/151-plunit-gate
nsaspy:fix/165-evolution-closed-data
nsaspy:fix/162-async-control-exceptions
nsaspy:fix/158-prompt-compiler-closed-dicts
nsaspy:fix/151-plunit-main-ownership
nsaspy:fix/156-registry-destroy-hooks
nsaspy:fix/154-anonymous-dict-canonicalization
nsaspy:fix/flake-lock-reproducibility
nsaspy:agent/issue-142-evolution-kernel
nsaspy:agent/141-flake-runtime-package
nsaspy:agent/rlm-subagent-runtime
nsaspy:agent/144-subagent-fallback-a
nsaspy:agent/107-bound-adapter-metadata
nsaspy:validation/clean-pack-install
nsaspy:fix/45-authoritative-nested-model-events
nsaspy:fix/46-router-safe-live-streaming
nsaspy:agent/prompt-context-compiler
nsaspy:agent/42-canonical-recursive-fingerprints
nsaspy:agent/136-static-load-errors-fail-ci
nsaspy:agent/44-completion-error-usage
nsaspy:fix/67-loader-registry-cleanup
nsaspy:agent/opentui-solid-reference-client-current
nsaspy:agent/95-project-source-registry
nsaspy:feature/issue-117-prolog-skill-compiler
nsaspy:backlog/roadmap-86-merged
nsaspy:agent/opentui-solid-reference-client
nsaspy:79-tool-effect-boundary
nsaspy:agent/prolog-agent-ui-research
nsaspy:agent/conversation-cold-context
nsaspy:agent/94-tree-sitter-ffi
nsaspy:agent/conversation-warm-context
nsaspy:111-opentui-solid-reference-client
nsaspy:109-prolog-agent-ui-v1
nsaspy:agent/conversation-runtime
nsaspy:agent/spec-mode-language
nsaspy:agent/spec-verify-foundation
nsaspy:agent/prompt-compiler-research
nsaspy:reconcile-backlog-postmerge
nsaspy:reconcile-backlog-issues
nsaspy:agent/prolog-agent-roadmap
nsaspy:feature/issue-84-effect-store-migration
nsaspy:fix/issue-80-effect-substrate-adversarial-hardening
nsaspy:feature/issue-57-effect-identity
nsaspy:agent/mcp-declaration-security
nsaspy:agent/external-tool-category-boundary
nsaspy:feature/issue-53-authority-pending-async
nsaspy:feature/issue-54-agent-graph-canonical-async
nsaspy:feature/issue-54-tools-mcp-canonical-async
nsaspy:feature/issue-54-async-canonical-runtime
nsaspy:agent/dual-sync-async-runtime
nsaspy:agent/reconcile-todo-status
nsaspy:feature/issue-20-deep-recursion-experiments
nsaspy:feature/issue-19-cli-demo-trace
nsaspy:feature/issue-18-benchmark-conformance
nsaspy:feature/issue-17-adaptive-recursion
nsaspy:feature/issue-16-durable-artifacts
nsaspy:feature/issue-15-mcp-2026-dual-version
nsaspy:feature/issue-14-mcp-2025-11-25
nsaspy:hotfix/live-tool-native-openrouter
nsaspy:feature/issue-13-chain-runtime
nsaspy:fix/stable-live-repair-gate
nsaspy:fix/live-repair-strategy-parser
nsaspy:feature/issue-12-durable-graph
nsaspy:feature/issue-11-agent-supervision
nsaspy:feature/issue-10-structured-outcomes-repair
nsaspy:feature/issue-9-rlm-completion
nsaspy:feature/issue-8-capability-tools
nsaspy:feature/issue-7-typed-plan-runtime
nsaspy:feature/issue-6-context-store
nsaspy:fix/openrouter-reasoning-response
nsaspy:fix/live-openrouter-smoke-stability
nsaspy:feature/issue-5-openrouter-provider
nsaspy:feature/issue-4-swi-bootstrap
nsaspy:agent/agentic-harness-research
nsaspy:agent/prolog-rlm-foundation
No reviewers
Labels
Clear labels
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
wontfix
This will not be worked on
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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!464
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/prolog-rlm-language"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Runtime invariant implemented
Prolog-RLM becomes a self-hosted LANGUAGE whose RLM semantics are part of the language design, not a harness layered on top:
prlm_kernel): our own Prolog machine — explicit'$v'(Name)variable representation, functional unification over immutable environments, an explicit choicepoint stack (standard cut scope, if-then-else commit, catch/throw ball unwinding), arithmetic, standard order, dynamic DB, modules with exports/imports, source loading with line provenance, and step budgets as a machine concept. Host usage is confined to a declared whitelist (prlm_host_primitive/1). No-escape is structural: program goals contain'$v'(_)and are never host-callable, so the engine cannot delegate program execution to SWI.lang/prlm_std.prlm,lang/prlm_meta.prlm,lang/prlm_ctx.prlm,lang/prlm_mode.prlm,lang/prlm_plan.prlm): standard library, meta-interpreter, context-compiler operations, mode-selection and planning rules — written IN the language and executed by the engine.msolve);prlm_selfhost_gate/1fails closed unless stage0-direct and stage2-interpreted runs agree solution-by-solution over a probe corpus, with stage1 proven loaded.prlm_rlm): SPEC → PLAN → EXECUTE → VERIFY → LEARN → CONTINUE with in-language mode selection (/direct,/symbolic,/symbolic-recursive,/auto,/learn); failed verification causes bounded repair/replanning — the spec object is never weakened. Supervised recursion: depth budget 500 shared per session, cancellation checked per step.prlm_validate_proposal/3admits only whitelisted plan-step shapes. Prolog-only mode needs no model.mcp_export/1directives +<name>_schema/1companions; external MCP tools consumed as capability-gated tools over a fail-closed transport.experiment/2,experiment_metric/4,experiment_change/2,experiment_result/2,experiment_failure/2facts; promotion only through gated tools; rejected candidates leave the runtime untouched (rollback check) and stay in the KB.Non-goals
git worktreeexecution and live network MCP transports are tool-boundary plugs (directory-isolated core, deterministic tests); production mapping documented.Tests / evidence
test/run_tests.pl→ 1496/1496 passed, 0 failed;test/check_runtime.plok;benchmark/run.pl -- deterministic16/16;bin/prolog-rlm.pl -- demo --jsonpass;bin/prlm.pl -- selfhostgate ok (17/17 equivalence);git diff --checkclean.Remaining follow-up scope
lang/*.prlm.git worktree-backed RSI execution behind the process tool boundary.Actors are runtime primitives of the language: identity, state, FIFO mailbox, messages, supervision (restart|stop|escalate), lifecycle, capabilities, cancellation (subtree) and child actors. Deterministic round-robin scheduler — no threads, fully reproducible traces. Agents are KINDS of actor, not a separate architecture: profiles, delegation with authority/capability narrowing (child subset of parent, never wider), depth charged against the shared session budget (default 500), checkpoint/restore, and structured results (agent_result{status,value,evidence,usage}) — never prose. The goal hook (prlm_agent_run_goal/5) defaults to a deterministic prolog-only implementation; the RLM layer replaces it. MCP connections and worker processes appear as external actors via the fail-closed prlm_actor_external_ask/5 hook. Kernel addition: prlm_call_first/5 — the single sanctioned bridge for trusted host code whose goals contain host variables (the machine unifier fails closed on them otherwise). 19 tests green.Completes the language layer on the stage0 kernel: - prlm_selfhost + lang/prlm_std.prlm + lang/prlm_meta.prlm: the standard library and the msolve meta-interpreter are WRITTEN IN THE LANGUAGE and executed by the engine. Stage2 runs stage1 under msolve; the gate (prlm_selfhost_gate/1) fails closed unless stage0-direct and stage2-interpreted execution agree solution-by-solution over the probe corpus (17 probes), with stage1 proven loaded (a fresh engine failing identically on both sides does not count). No-escape is structural: program terms contain '$v'(_) variables and are never host-callable. Kernel additions: module-qualified clause(M:Head, Body), call/N unwrapping, defining-module clause bodies, prlm_import/4, prlm_call_first/5 host-variable bridge. - prlm_rlm + lang/prlm_mode.prlm + lang/prlm_plan.prlm: the SPEC -> PLAN -> EXECUTE -> VERIFY -> LEARN -> CONTINUE loop as language semantics. Mode selection and planning run in-language. Failed verification causes bounded repair/replanning (planned_reorder / add_model_step / retry) — the specification object is never weakened. Modes: /direct (provider passthrough, no effects), /symbolic, /symbolic-recursive (agents allowed), /auto (in-language rules), /learn. spawn_agent in symbolic mode is forbidden_in_mode, not silently allowed. - prlm_usage + prlm_mcp_export: the language inspects its own usage from the one normalized event stream (calls, errors, ops, slow ops, pass/fail patterns, missing-capability signals) and generates its MCP surface from mcp_export/1 directives + the <name>_schema/1 companion convention; registered tools execute real engine predicates with evidence and provenance. MCP consumption projects external tool descriptors into capability-gated tools over a fail-closed transport. - prlm_learn: /learn converts completed verified outcomes into knowledge facts with provenance{source, time, confidence, scope}; LLM text goes only to the untrusted store (confidence 0.3, scope untrusted) and can never surface through prlm_knowledge/3. - prlm_rsi: bounded OBSERVE -> PROPOSE -> IMPLEMENT -> TEST -> BENCHMARK -> VERIFY -> ACCEPT/REJECT loop over isolated workspaces with the experiment/2, experiment_metric/4, experiment_change/2, experiment_result/2, experiment_failure/2 fact shapes; promotion of a candidate to the runtime happens only through gated tools after tests and metrics pass; rejected candidates keep the runtime untouched (rollback check) and stay in the KB. - bin/prlm.pl CLI (demo, stage0, stage1, stage2, selfhost, run --mode, mcp, usage, rsi, events; JSON lines, exit-code matrix) + literate docs (docs/prlm-language.md, self-hosting.md, rsi.md, docs/org/. All prlm suites registered in the deterministic corpus. Full repo gates: run_tests 1496/1496 passed (0 failed), check_runtime ok, benchmark deterministic 16/16, demo --json pass, git diff --check clean.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.