Orchestrata Ultimate › Plans › prolog-codeintel-verification-plan

Prolog codebase-intelligence verification plan (session 242)

Source: plans/prolog-codeintel-verification-plan.md at 8a2cb42ad · last changed 2026-07-27 · first committed 2026-07-18 · 103 lines.

Prose pending.

Plan text

Prolog codebase-intelligence verification plan (session 242)

Subject: commit 3b159679 "Add Prolog codebase intelligence layer" (author Hannah hannah@openclaw.ai — external, landed on master unreviewed, no tests shipped). Files: src/orchestrata_ultimate/tools/codebase_db.pl (521 LOC), src/orchestrata_ultimate/tools/codebase_tools.py (289 LOC), schema/ast-ultimate.schema.json, PROLOG_STATUS.md.

User directive: "Prolog code intelligence is better than Python for recursive work and supposedly faster — test and verify that." Deliverable = a numbers-backed PASS/FAIL verdict, plus the layer brought up to project standards (reviewed, fixed, tested).

Facts established (session 242 recon, this machine)

Defects already found (to be confirmed/extended by reviewer)

# File Defect Severity
D1 codebase_tools.py:24 Default KB path with_suffix('.pl') → codebase_tools.pl, not codebase_db.pl — default construction is broken (verified: source_sink does not exist) HIGH
D2 codebase_tools.py:32-34 Binding substitution goal.replace(k, val, 1) sequentially — a value containing a later placeholder letter corrupts the goal (e.g. impact('llm.client.LLMClient'): the L inside the quoted atom is replaced by the limit). Injection-adjacent correctness bug HIGH
D3 codebase_tools.py:88-106 _parse_swipl_json regex "repair" of unquoted keys can corrupt string values containing word: text (docstrings!). Fix at the source: have Prolog emit valid JSON (atom_json_dict/3 on the reply dict) and delete the regex HIGH
D4 codebase_tools.py:18-19 Hardcoded shared /tmp/codebase_facts.pl + /tmp/codebase_result.json — two instances/parallel tests clobber each other (suite runs parallel by doctrine); also violates house norms (no fixed /tmp paths). Make per-instance/configurable seam HIGH
D5 codebase_tools.py:21 prolog_file: str = None — type error (pyright) MED
D6 codebase_tools.py:83-86,171-175 bare except: pass ×2 (ruff E722) MED
D7 codebase_tools.py _loaded is per-instance state gating while facts live on disk — fresh instance refuses queries despite valid facts file (verified). Provide attach()/auto-detect MED
D8 codebase_db.pl:296-297 reaches/2 tabled but dead — no tool predicate uses it (expose or remove) LOW
D9 PROLOG_STATUS.md False claims: janus availability, 0.3 s/query. Correct or replace the doc MED
D10 repo-wide No tests for either file (doctrine: real tests, no mocks) HIGH

The benchmark (core user ask)

Three-way comparison on identical recursive workloads over the same graph:

Workloads (all recursive):

Protocol: median of ≥5 timed runs per (mode, workload); 1 warmup discarded for warm modes; correctness parity asserted first (identical result sets for W1/W2/W4; canonical-set diff explained for W3) — a fast wrong answer loses. Output: scripts/benchmark_prolog_codeintel.py (rerunnable, argparse, no hardcoded paths) + reports/prolog-codeintel-benchmark.md with raw tables and per-workload winner+ratio.

Verdict rubric: the user's claim is assessed per deployment mode — "Prolog is better/faster than Python for recursive work" gets PASS/FAIL for P-sub and P-janus separately, with numbers. No hedging.

Waves (swarm)

Out of scope (backlogged, design decisions): registering CodebaseTools in the volk tool registry/MCP; replacing subprocess transport with janus in production.

Plan self-review — risks & mitigations