[EPIC][experts] Canonical expert runtime: contract, registry, symbolic selection, invocation, recursion, and projections #421
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#421
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?
Parent: #376
Goal
Implement the reusable runtime substrate that makes a Prolog expert a first-class, inspectable, callable capability without creating another agent framework.
This epic owns the generic expert machinery only. Specialist domain logic belongs in sibling expert epics.
Core invariants
Experts are free local computation
Pure expert invocation, including expert→expert nesting, must perform zero provider calls and add zero model-token/cost usage.
Metering begins only when an expert explicitly invokes a metered dependency such as an LLM fallback or paid external API. That dependency's usage is recorded normally and linked to the expert invocation.
Runtime safety limits still apply: wall time, inference/work bound, recursion depth, output size, concurrency, cancellation and capability/authority ceilings.
One runtime path
Do not create separate plan experts, direct experts, chat experts or AgentProlog experts.
D6-11 exclusion
The plan-native set from #355 is excluded from expert mapping:
edit/2andcreate/2remain valid expert-owned reasoning goals and will be owned by the Write Expert epic.Public contract direction
Provide semantics equivalent to:
Exact names/arity should follow repository conventions.
Contract schema
A registered expert needs stable normalized metadata roughly equivalent to:
The model-visible/inspection catalog exposes sanitized metadata and schemas, never arbitrary callable closures.
Generated/model/project data cannot register executable expert handlers unless it crosses an existing explicit trusted extension/config boundary.
Symbolic applicability and selection
Selection must be possible without an LLM.
Support deterministic rule/fact/constraint inputs such as:
The selection outcome should preserve all considered candidates plus a structured reason for the chosen expert or why no expert was eligible.
Do not silently ask a model to choose when symbolic selection yields no valid candidate.
Invocation lifecycle
Normalize a canonical invocation record with stable identity and state transitions equivalent to:
Preserve parent/child lineage, run/session identity, expert/version identity, relevant context snapshot identity, capabilities and evidence refs.
Expert→expert calls
Nested calls use the same registry and invocation machinery.
Required semantics:
Use existing graph/async primitives where latency/concurrency requires them.
Tool/capability integration
An expert is reasoning, not ambient authority.
If an expert needs a tool it must use the existing typed registry/capability/authority/effect boundary. Registration or selection does not grant tool capability.
Preflight should be able to distinguish:
Explicit fallback boundary
Implement a generic fallback hook/policy that specialist experts may opt into.
A fallback event records at least:
Fallback must never replace the primary expert handler or make every expert secretly model-backed.
Direct/native projection
Replace/supersede the useful intent of #353 with a canonical adapter over the expert registry.
A direct-mode model may be shown selected expert capabilities as native callable tools only when host policy chooses to project them. Projection is availability, not authority. Invocation re-enters
expert_invokeand the normal capability/tool boundaries.Do not create a fourth native binding family if the existing registry/native tool path can adapt the expert contract cleanly.
Important correction from older research: the expert invocation itself is not token/cost charged. If an expert internally uses a model fallback, only that fallback's real provider usage is charged.
Plan/workflow projection
#288 plan graph routing should be able to bind typed expert-owned operations to expert ids/contracts during preflight or execution without embedding trusted closures in model-authored plan data.
The graph remains the scheduler. Expert selection does not become a second scheduler.
Observability / explanation
Expose bounded structured inspection for:
Deterministic acceptance
model_calls = 0.model_calls = 0and$0while preserving parent/child lineage.edit/2andcreate/2can be mapped to the Write Expert once that expert is registered.Non-goals
Refs #376 #141 #288 #355 #353 #354
Machine Spirit #401C handoff — expert portability is goal-contract based
Procedural federation must not persist/import trusted expert closures or assume expert IDs are portable across hosts. Reusable methods name typed solver/goal contracts; #377 performs local applicability/selection against the current registry/version/capability context.
Method identity remains stable if a different compatible expert implementation is selected.
compatible expertstill does not imply authority. Result adapters must preserveunknown/blocked/unsupported/cancelled/errorrather than Boolean-flattening them. See #401C PIFF/PSC design.Machine Spirit #401D handoff — expert runtime as DPEC dependency
Depth 4D keeps the existing expert runtime intact and makes its versioned goal-contract/registry state an explicit dependency of procedural host projections.
Required runtime consequences:
model_calls = 0.Full DPEC design and conformance fixtures are on #401.
MACHINE-SPIRIT #404A handoff — EPOCH
Depth 7A establishes that learned expert behavior must remain declarative strategy/composition data over this canonical registry, not generated executable handlers.
Add to the eventual contract:
An admitted learned composition may reference stable expert contract/version IDs, goal schemas, dependencies and bounded selection policy. Invocation still re-enters the normal #377 registry, capability narrowing, cancellation and trace path. Missing/incompatible expert versions make the learned composition stale/unsupported. Performance statistics may rank already-applicable experts but are operational evidence, not epistemic truth and never widen authority.
Promotion/suspension/version lineage belongs to #404 + durable memory; #377 should expose enough versioned selection/composition dependencies for replay and invalidation. Ref #404A EPOCH.
Machine Spirit #404B / CITADEL-EPOCH handoff
Learned selection profiles, expert-performance statistics and self-model outputs remain advisory control evidence over the existing registered expert contract. Add/retain lineage sufficient for #404 to detect self-selection bias:
A learned competence/profile may influence which already-authorized expert is tried, but it cannot widen authority/capability, weaken applicability/verification obligations, mark its own evidence independent, or change its own promotion policy. Refs #404B CITADEL fixtures B19, B27-B28, B40.
Machine Spirit #404C handoff — foreign learned expert/control artifacts
PACT-EPOCH requires imported learned selection rules or expert compositions to enter #377 as declarative foreign candidates, never as registered handlers or locally admitted policy merely because another memory/authority promoted them.
Preserve source artifact/version, learner kind, source authority/policy receipt, applicability/transfer assumptions and target-local admission receipt separately. Same expert name/id across trust domains is not principal/binding identity. Foreign compositions may reference compatible goal contracts only; local registry resolution, capability ceilings and authority remain unchanged. Full design: #404C.
MACHINE-SPIRIT #404D / CLOCKWORK runtime boundary
Depth 7D keeps the current expert-runtime architecture intact: learned candidates, locally admitted methods/control rules and imported LACs remain declarative selection/knowledge inputs. Admission never creates a trusted expert handler, capability or authority.
Latency-bearing evaluation reuses the existing
rlm_async/ #288 execution machinery; do not add a learning scheduler. Known-symbolic candidate validation/selection should remain provider-free where the profile supports it.A learned expert composition may select only already registered target-local expert contracts. Missing/incompatible registration remains unsupported/blocked rather than synthesizing an executable handler. Refs #397 #404 #379 #395.
#405B AEGIS-MS runtime handoff: material expert selection/fallback/control decisions should emit compact direct influence refs plus the relevant registry/control generations. Source/model/project data may parameterize an invocation as data but cannot register/replace trusted handlers, policies or capability ceilings. Child delegation preserves/narrows explicit authority context; no prior wider receipt can be spent after a current capability/policy change. This is metadata/conformance over the existing registry/invocation path, not a second scheduler or authority system.