Add Prolog capability reasoning for command execution #119

Closed
lost-rob0t wants to merge 14 commits from agent/prolog-capability-reasoner into master
lost-rob0t commented 2026-08-15 23:22:03 +00:00 (Migrated from github.com)

What changed

  • added kb/capabilities.pl as the declarative capability-provider knowledge base
  • added modules/capability_resolver.pl as the single symbolic provider-selection layer
  • kept the existing command runtime authoritative; no second dispatcher or execution stack was introduced
  • routed existing open and search execution through capability selection
  • preserved configured app mappings, direct-app handling, and legacy executable fallback behavior
  • added queryable provider properties such as scope, transport, side-effect, and certainty terms
  • added composable symbolic constraints: require(Property) and exclude(Property)
  • added constrained candidate/5, candidates/4, and select/4 predicates while retaining the simple default-policy APIs
  • added explain/4, returning selected provider, priority, proof evidence, properties, and surviving alternatives
  • added CapabilityCandidate, PrologEngine.capability_candidates(), and PrologEngine.selected_capability() so Python/TUI/agent code can inspect Prolog decisions without executing them
  • added Prolog regression coverage for multiple solutions, ordering, strict filtering, conflicting constraints, and explanation evidence
  • added Python unit coverage for candidate enumeration and non-executing selection
  • extended scripts/test-prolog-engine.sh with a real SWI-Prolog/PySWIP capability fixture that proves multiple solutions and selected-provider behavior end to end
  • documented the architecture and extension points in wiki/capability-reasoning.org

Why

Zara already resolves natural language into symbolic intents. This PR adds the next expert-system stage: reason about which implementation can satisfy an intent and its arguments, preserve multiple valid solutions, constrain them symbolically, and select the best surviving provider.

The authority boundary is:

language -> intent/args -> Prolog capability reasoning -> existing command executor

This is ordinary Zara Prolog reasoning. It has no Prolog-RLM runtime dependency.

Example

?- capability_resolver:candidates(open, [vim], Candidates).
Candidates = [100-mapped_app, 50-direct_app, 10-executable_fallback].

?- capability_resolver:candidates(
       open,
       [vim],
       [exclude(certainty(speculative))],
       Candidates).
Candidates = [100-mapped_app, 50-direct_app].

Current status

The previous green CI result predates the current master and the removal of Prolog-RLM in #136. This PR is intentionally draft and must be reconciled with current master, proven to add no RLM dependency/code path, and rerun through the exact-head deterministic gate before merge.

Do not treat its older green checks as merge authority.

## What changed - added `kb/capabilities.pl` as the declarative capability-provider knowledge base - added `modules/capability_resolver.pl` as the single symbolic provider-selection layer - kept the existing command runtime authoritative; no second dispatcher or execution stack was introduced - routed existing `open` and `search` execution through capability selection - preserved configured app mappings, direct-app handling, and legacy executable fallback behavior - added queryable provider properties such as scope, transport, side-effect, and certainty terms - added composable symbolic constraints: `require(Property)` and `exclude(Property)` - added constrained `candidate/5`, `candidates/4`, and `select/4` predicates while retaining the simple default-policy APIs - added `explain/4`, returning selected provider, priority, proof evidence, properties, and surviving alternatives - added `CapabilityCandidate`, `PrologEngine.capability_candidates()`, and `PrologEngine.selected_capability()` so Python/TUI/agent code can inspect Prolog decisions without executing them - added Prolog regression coverage for multiple solutions, ordering, strict filtering, conflicting constraints, and explanation evidence - added Python unit coverage for candidate enumeration and non-executing selection - extended `scripts/test-prolog-engine.sh` with a real SWI-Prolog/PySWIP capability fixture that proves multiple solutions and selected-provider behavior end to end - documented the architecture and extension points in `wiki/capability-reasoning.org` ## Why Zara already resolves natural language into symbolic intents. This PR adds the next expert-system stage: reason about which implementation can satisfy an intent and its arguments, preserve multiple valid solutions, constrain them symbolically, and select the best surviving provider. The authority boundary is: `language -> intent/args -> Prolog capability reasoning -> existing command executor` This is ordinary Zara Prolog reasoning. It has no Prolog-RLM runtime dependency. ## Example ```prolog ?- capability_resolver:candidates(open, [vim], Candidates). Candidates = [100-mapped_app, 50-direct_app, 10-executable_fallback]. ?- capability_resolver:candidates( open, [vim], [exclude(certainty(speculative))], Candidates). Candidates = [100-mapped_app, 50-direct_app]. ``` ## Current status The previous green CI result predates the current `master` and the removal of Prolog-RLM in #136. This PR is intentionally draft and must be reconciled with current `master`, proven to add no RLM dependency/code path, and rerun through the exact-head deterministic gate before merge. Do not treat its older green checks as merge authority.
nsaspy changed title from WIP: Add Prolog capability reasoning for command execution to Add Prolog capability reasoning for command execution 2026-08-28 03:31:12 +00:00
Owner

Closing per roadmap decision (issue #1, phase 11): this Prolog capability reasoner is reconciled as prior art only — it predates the ZARA/1 client split and the daemon runtime. The capability-reasoning behavior it prototyped is owned by #157 (capability/provider reasoning and typed ExecutionPlan), which will re-derive the design against the current runtime when consumed. Branch preserved for reference at consumption time.

Closing per roadmap decision (issue #1, phase 11): this Prolog capability reasoner is reconciled as prior art only — it predates the ZARA/1 client split and the daemon runtime. The capability-reasoning behavior it prototyped is owned by #157 (capability/provider reasoning and typed ExecutionPlan), which will re-derive the design against the current runtime when consumed. Branch preserved for reference at consumption time.
nsaspy closed this pull request 2026-09-04 14:40:03 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.