[EPIC][P0] First-class Prolog expert system: registry, routing, specialists, and closed-loop Spec→Plan→Expert→Verify→Repair #422
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm#422
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Mission
Make expert systems a first-class intelligence layer in
prolog-rlmand carry that architecture all the way through a complete bounded autonomous loop:The goal is not another agent framework. The goal is a reusable classical/symbolic expert substrate that existing RLM, plan, graph, tool, source-KB, SPEC and VERIFY machinery can compose with.
Operator decision: experts are free by default
A Prolog expert invocation is ordinary local computation.
Do not attach a model-token or monetary charge merely because an expert is invoked or nested.
Experts are still bounded by normal computational/runtime safety controls: cancellation, recursion/depth, inference/work limits, wall time, output limits, concurrency and capability/authority ceilings. These are resource/safety bounds, not a model-usage tax.
Any expert that uses an LLM must do so through an explicit fallback event that is visible in the trace and usage ledger. The expert remains a Prolog expert; the model is a fallback capability, not the identity of the expert.
Canonical architectural boundaries
This epic is compatible with the restored repository boundary in #141:
prolog-rlmowns reusable expert contracts, symbolic algorithms, source/project knowledge APIs, Spec/Plan/Verify integration, capability/authority semantics and generic tool abstractions.lost-rob0t/agentPrologowns product-specific coding tool implementations, product UX, product presets and concrete filesystem/Git/process/test packs where those are product-specific.Do not revive #49/#50's old in-repo concrete coding-tool catalog architecture.
Reuse; do not fork runtime machinery
This epic MUST compose with the existing canonical systems rather than create parallel ones:
rlm_tool, capabilities, authority, durable effects, async/Futures, cancellation, traces, graphs, context and provider runtime.There is exactly one scheduler/graph runtime, one capability model, one authority boundary, one durable effect mechanism and one verification truth boundary.
D6-11 is mandatory
The following closed deterministic state-mutating operations remain plan-native, not expert-owned:
They execute through the canonical schema → capability → authority → durable-effect/observation boundary as specified by #355.
Experts may reason about when these operations are needed and may produce typed plan requirements that include them, but they do not become fake "experts" merely to execute deterministic adapters.
edit/2andcreate/2remain write-expert-owned at the reasoning/payload-production layer. The actual filesystem mutation remains behind the canonical tool/effect boundary.First-class expert contract
Add one reusable expert abstraction with semantics equivalent to:
Exact names/arity follow repository conventions.
A contract should carry normalized, inspectable metadata such as:
Callable closures remain host/trusted runtime data. Model-visible catalogs expose sanitized schemas/metadata, never arbitrary executable terms.
Availability != selection != authority
Keep these separate:
An expert cannot widen its caller's capability/authority ceiling. Expert→expert calls narrow or preserve ceilings according to the existing capability model and may never silently escalate.
Expert selection belongs to Prolog
The runtime should be able to route goals using facts/rules/constraints without a model call.
Conceptual shape:
Real selection should support more than a flat predicate: preconditions, current evidence, goal type, project state, required capabilities, confidence/priority, conflicts and fallback ordering.
If no expert is applicable, return a structured unsupported/unknown result. Do not silently ask a model to invent an expert.
Expert recursion and cooperation
Experts may call other experts as structured subgoals.
Required semantics:
Example:
Expert result contract
Experts should return structured outcomes compatible with the runtime's existing structured result/evidence conventions, at minimum distinguishing:
Do not collapse missing evidence into falsehood or model prose into evidence.
Proof and explanation
For every material decision, retain enough inspectable state to answer:
This is structured explanation/provenance, not a requirement to expose private model chain-of-thought.
LLM fallback contract
Each expert may declare an explicit fallback policy. Default is
noneunless the expert genuinely benefits from a model fallback.Conceptual classes:
Fallback MUST:
Full closed loop
The eventual integration target is a canonical reusable expert workflow equivalent to:
The loop is bounded by explicit progress/recursion/time/work/tool/effect limits and stops structurally on no-progress, blocked requirements, cancellation or exhausted limits.
Child epics
This parent owns the architecture and integration. Create focused epics for:
Each child must remain independently testable and integrate through the shared contract.
Acceptance — expert substrate
Acceptance — full loop
A deterministic fixture must prove a complete loop with zero model calls:
Also prove:
Non-goals
call/1.Migration/reconciliation
As the child epics land, reconcile older expert research/issues against this contract. Preserve useful evidence/research, but close or supersede issue-level architecture that assumes experts are inherently model sessions or that expert invocation itself should be token/cost charged.
Refs #141 #288 #355 #93 #56 #68 #69 #70 #71 #219 #353 #354
Child epic map
Created the implementation hierarchy:
Implementation invariant across every child: pure Prolog expert invocation and expert→expert recursion are free local computation (
model_calls = 0, no synthetic token/cost charge). Only explicit model fallback or an actually paid external dependency is metered.Added child epic #388 for generic corpus symbolicization / knowledge ingestion. This is intentionally separate from source-code Project Knowledge (#380): arbitrary text, LLM logs, web/research results, reports, chat exports, JSONL/events, etc. become immutable-source, schema-versioned, append-only symbolic knowledge with exact provenance. The model sees only a bounded selected projection; it may choose among host-admitted immutable schemas/projections but cannot mutate/publish trusted schemas or turn extracted text into authority.
Machine Spirit #399D boundary note — semantic compile planning is not a second scheduler
Depth 2D introduces a compiler-local Semantic Build Graph (SBG) for content-addressed analyzer/SCL/SCC/mapping/export work and dynamic discourse dependencies.
This must preserve #376's one-runtime invariant:
No other #376-#387 architecture change is required by this research pass; the purpose of this note is to prevent an implementation of #393/#396 from accidentally creating a parallel worker runtime.
MACHINE-SPIRIT #400D handoff — epistemic query plans reuse the canonical runtime
Depth 3D introduces an Epistemic Query Plan (EQP) for demand-driven cross-theory reasoning. This must compose with #376's existing one-runtime/one-scheduler invariant.
EQP nodes may represent local theory evaluation, bridge propagation, SCC fixed-point/search, projected-interface joins, explanation expansion and cache invalidation, but they are typed plan work executed by the canonical runtime. Do not add a parallel epistemic actor scheduler.
Independent SCC-DAG nodes may execute concurrently through existing runtime primitives. Result combination must be deterministic from immutable plan/frontier/interface keys; different safe interleavings cannot change skeptical/credulous/undefined/conflicted/completeness outcomes.
Pure compiled-semantic epistemic reasoning is local expert/runtime computation and must incur zero model/provider calls. Resource exhaustion returns a structured epistemic/runtime status and never silently triggers an LLM fallback.
Epistemic warrant remains data/evidence for experts and VERIFY; it never widens capability/authority or substitutes stale derived state for fresh required observation.
Full execution design is on #400D.
Machine Spirit #401A procedural-intelligence handoff
Depth 4A’s classical-AI comparison preserves this epic’s one-runtime / zero-model / authority boundaries and adds one architectural distinction that should guide implementation:
Preferred Procedural Intelligence Fabric (PIF) uses:
conflict -> hypotheses -> discriminating evidence -> repair methodbefore blind repair where ambiguity matters.#379 and #385 have been updated to reflect the two strongest canonical deltas. #288 remains the sole plan graph scheduler; #384 remains the sole final acceptance boundary; #404 later owns experience/case -> generalized rule/method promotion.
Hard invariants added by the research:
Full source review, candidate designs, complexity analysis and A1-A20 conformance fixtures are preserved on #401. #401 remains open; next subpass is #401B.
Machine Spirit #405A synthesis handoff
Depth 8A (
#405) preserves the current expert architecture as the single execution/control spine of COVENANT-MS:No synthesis-level orchestrator, blackboard scheduler or learned expert mesh is added.
ms_run_envelope/conformance receipts only bind the loop to exact Frozen Spec, evidence/world cut, expert-registry, authority, verifier and procedure generations.Hard cross-depth law retained: expert registered/selected/admitted learned strategy never implies effect capability or authority. Predicted procedural effects never become VERIFY observations. Pure known expert cooperation remains a zero-model target.
Refs #397 #405 #377-#387 #288 #355.