[P0] First-class bounded RLM subagent fallback + KB command binding #144
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#144
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: #141. Reusable result-acceptance follow-up: #56.
Outcome
Completed on current
mainthrough PRs #146, #147, #149, and #180.The canonical domain-neutral path is now:
The final closure in #180 binds completion tools to the spawned child's exact normalized capability ceiling, narrowed authority context, and trusted runtime/agent lineage. The parent-bound subagent tool fails closed if placed in its own child ceiling; recursive
rlm(...)plans remain available only under existing completion depth, parallel, model, token, and wall-time budgets.No second scheduler, authority system, effect ledger, verifier stack, ambient capability, arbitrary
call/1, or product-specific AgentProlog branch was added. Broader evidence/result acceptance remains #56.Acceptance
unknown -> delegate_subagentresolves to inert canonicaltool(rlm_subagent)dataFinal verification
Worker A progress: opened draft PR #146 on a branch cut from exact
mainf21df8e, deliberately avoiding Worker B's #145 and #122/#125/#132 surfaces. First TDD slice implements the closed KB command-binding contract: terseprompt/2+ trigger + action records compile deterministically;delegate_subagentresolves only to canonical datatool(rlm_subagent); missing/ambiguous/invalid bindings are structured failures; arbitrary callable actions are rejected; output carries KB provenance + SHA-256 fingerprint. This does not claim the runtime fallback is complete. Next required slice remains canonicalrlm_subagentexecution through ordinary tool/capability/authority/budget boundaries with child completion/evidence/trace correlation and parent resume/replan.Worker A progress: merged #146 at
1d1ee7594962accafabdd61d26a725d8bdb86a05after exact-head27479d32d92773e5c597d453e8593152516130b7passed CI, Tree-sitter FFI, and clean SWI pack install with no review threads. This completes the closed short-KB command-binding slice: inert prompt/trigger/action records, deterministic direct/reference compilation,delegate_subagent -> tool(rlm_subagent), stable SHA-256 fingerprint/provenance, and explicit missing/ambiguous/invalid-action failures withoutcall/1or authority/Spec mutation.#144 remains open. Executable audit still shows the runtime half is missing:
rlm_agent:agent_spawncreates a supervised child handle with capability/authority narrowing and bounded agent runtime, but there is still no canonical registeredrlm_subagenthandler that composes child supervision with boundedrlm_completion, returns structured child evidence/usage/trace correlation, and resumes/replans the parent. The next non-conflicting slice should implement that generic runtime path on top of the ordinaryrlm_toolinvocation boundary; do not duplicate Worker B's #145 flake surface or #122/#125/#132.Worker A continued #144 on a fresh branch from merged #146 and opened draft #147 (
agent/rlm-subagent-runtime, exact head916e4c4d0181546c98079d70941466692ef7afc0). This is the first canonical runtime slice:rlm_subagentis registered through ordinaryrlm_tool; its trusted handler composesrlm_agentchild supervision/narrowing with boundedrlm_completion; the returned envelope carries completed/failed status, value, usage, explicit parent/child correlation and agent trace. Focused TDD covers success, tool capability denial before child creation, and child capability widening as structured failure. CI, Tree-sitter FFI, and clean-pack runs are now queued on the exact head, so #147 remains draft/unmerged.This does not claim all #144 acceptance yet. Next after exact-head feedback: cancellation/depth/concurrency end-to-end, explicit unknown->tool selection->parent continue/replan fixture, and richer evidence/provenance/result-acceptance integration. Worker B #145 and #122/#125/#132 remain untouched.
Worker A post-merge executable audit (2026-08-21): PR #147 merged as
09d9418911acdebb851c8a8362fcd02ca1b5fdebafter exact head916e4c4d0181546c98079d70941466692ef7afc0passed CI, Tree-sitter FFI, and clean SWI-pack gates with no review threads.Important: #147 is a real first-class
rlm_subagenttool registration/envelope slice, but it does not yet satisfy the full #144 supervision/cancellation contract. Source audit on merged main showsrlm_subagent_handler/7callsagent_spawn(...)to allocate a child identity and then callsrlm_completion(...)directly in the tool handler. The completion is not dispatched through the child's mailbox/worker lifecycle. Therefore the spawned child currently does not own the completion work, parentagent_cancel/4cannot be claimed to cancel that in-flight completion throughsignal_agent_workers, and the child's state/result lifecycle is not the authoritative completion path.rlm_agentalready has the machinery we should compose instead of inventing another scheduler: request messages dispatch through the bounded worker pool;agent_cancel/4recursively cancels children and signals their workers; worker results return through the child's engine. There is also a second gap:notify_parent_from_reply/3currently forwards onlyfailedchild replies, not successfulcompleted/result replies.Next runtime slice should therefore make the RLM subagent completion actually execute as child-owned supervised work (or add the smallest generic supervised-call API over the existing mailbox/worker path), forward a structured successful child result to the parent, and TDD cancellation/depth/concurrency/agent-limit behavior plus parent continuation. Do not add a second scheduler. Keep the ordinary
rlm_toolcapability/authority boundary from #147 and the merged closed KB command binding from #146.Remaining unchecked acceptance is real: unresolved-state policy ->
tool(rlm_subagent)-> child-owned bounded completion -> structured evidence/result -> parent consume/replan, with cancellation/time/token/depth/concurrency proofs and structured unavailable/denied/failed paths.Worker A fresh-main conformance audit after #147 (
09d9418911acdebb851c8a8362fcd02ca1b5fdeb) confirms the next implementation must change the genericrlm_agentsupervision seam before adding morerlm_subagentwrapper logic.Exact executable finding:
rlm_subagent_handler/7spawns a child and then callsrlm_completion/4directly in the tool-handler thread. Inrlm_agent, cancellation only signals threads recorded asagent_worker(RuntimeId, AgentId, CallId, Thread), which are created by the mailboxrequest(...) -> dispatch -> schedule_worker(...)path. Therefore the current completion is outside child worker ownership and parent cancellation cannot cancel it through the existing supervisor. Alsonotify_parent_from_reply/3only forwardskind:failed; a successful worker result never becomes a canonical parentchild_result.Smallest coherent next seam, without a second scheduler: add a trusted host-facing supervised-call operation to
rlm_agentthat (1) admits a call into the child engine/pending set, (2) schedules the supplied trusted handler on the existing bounded runtime worker pool, (3) awaits/pumps that same child-owned call to a terminal structured result, and (4) preserves worker registration soagent_cancel/4signals it. Then extend parent notification to forward successful terminal child results exactly once.rlm_subagentcan use this seam with a code-owned completion handler instead of directrlm_completion/4.TDD contract for that seam before wiring fallback: successful child call is visible in child status and parent child-result; parent cancellation interrupts a deliberately blocked child worker; worker-pool saturation is structured; agent-count ceiling remains enforced by spawn; authority/capability narrowing remains unchanged. Then the #144 integration fixture should compose merged #146
unknown -> tool(rlm_subagent)with the merged #147 ordinary tool boundary and prove child completion -> parent continuation/replan.I did not open a duplicate PR because current open #148 owns evolution-kernel files and #122/#125/#132 own skill/Harness/config surfaces; this mission should remain isolated to
rlm_agent+rlm_subagent+ focused tests. AgentProlog #1/#2 still have the correct dependency direction and need no downstream workaround.Worker A continued from fresh
main23d919628a449acc3ced08fc9bd8469cc2cbf8ea(after #148) and opened draft #149 from that exact head. This is a deliberate TDD-red conformance transaction, not a duplicate of #146/#147: it adds a deterministic test proving a successful child-owned worker result must propagate through the existingrlm_agentsupervised parent path as canonicalchild_resultwith trace correlation. Current main only forwardskind:failed, so the new test is expected to fail until the generic supervision seam is fixed. Exact PR head is4fd2d215536f3217d8ed6b36d04189d6ec2981c1; CI and clean-pack are queued.Next implementation remains in #149: extend existing
rlm_agentsuccess propagation, add the smallest trusted child-owned supervised-call operation over the existing bounded worker pool/cancellation registration, switchrlm_subagentaway from direct handler-threadrlm_completion/4, then add cancellation/backpressure and the full merged-#146unknown -> tool(rlm_subagent)-> child outcome -> parent continuation fixture. #122/#125/#132 and legacy harness surfaces remain untouched.Closed by PR #180. Exact reviewed head
c56c82dd5cpassed all required deterministic, packaging, Tree-sitter, and REAL OpenRouter checks and merged as0d8e1008ba. The issue body and roadmap now reflect the merged contract; broader verifier-backed result acceptance remains #56.