Done. X = a, exit 1 → Fetch::Found. #46

Merged
navicore merged 1 commit from repl-is-broken-by-bson-update into main 2026-07-04 18:31:33 +00:00
Owner

Summary

Root cause — the bson capability-table refactor (df76b24→d6f3228) removed the
json encoder from the runtime, but crates/repl/src/run.rs was never updated;
it kept requesting --format json, which the engine rejects (exit 2, empty
stdout), so fetch() always fell through to Fetch::NoSolutions → " false.".
Every ?- query in the REPL has been broken since, not just yours. Your Prolog
was correct.

The fix (crates/repl/src/run.rs, rewritten):

  • Single text exec instead of two (json + text). --format text is the engine's
    display path and works on the default [text] binary — no capability
    injection, no new parsers, no linking the heavy runtime.
  • Exit code is authoritative: 0→NoSolutions, 1→Found, 2/3→Failed (message
    parsed from error: on stdout, stderr fallback).
  • Self-describing solution split (split_text_solutions): the engine emits
    uniform Var = Value lines per solution, so the first variable's name is the
    group delimiter — no external count needed. Handles false./true. and values
    containing =.
  • exhausted = solutions.len() < limit — matches the existing ;-paging
    semantics (re-fetch on doubled limit at the boundary).
  • Removed the dead JSON helpers
    (top_field/json_count/json_exhausted/json_error).

The regression guard — fetch_runs_a_real_compiled_binary compiles your exact
membercheck program via plgc and asserts the bound-variable query returns ["X
= a"], plus the no-solution, multi-solution, limit-truncation, and parse-error
paths. This is the test that was missing: every prior test operated on
hand-written string fixtures, so a broken wire contract sailed past CI. It
locates plgc via $PLGC or target//plgc, which cargo test --workspace
always builds.

Results: 495 tests pass workspace-wide, cargo fmt --check clean, cargo clippy
-D warnings clean. I changed only crates/repl/src/run.rs — the
runtime/compiler were already correct and untouched.

Summary Root cause — the bson capability-table refactor (df76b24→d6f3228) removed the json encoder from the runtime, but crates/repl/src/run.rs was never updated; it kept requesting --format json, which the engine rejects (exit 2, empty stdout), so fetch() always fell through to Fetch::NoSolutions → " false.". Every ?- query in the REPL has been broken since, not just yours. Your Prolog was correct. The fix (crates/repl/src/run.rs, rewritten): - Single text exec instead of two (json + text). --format text is the engine's display path and works on the default [text] binary — no capability injection, no new parsers, no linking the heavy runtime. - Exit code is authoritative: 0→NoSolutions, 1→Found, 2/3→Failed (message parsed from error: <msg> on stdout, stderr fallback). - Self-describing solution split (split_text_solutions): the engine emits uniform Var = Value lines per solution, so the first variable's name is the group delimiter — no external count needed. Handles false./true. and values containing =. - exhausted = solutions.len() < limit — matches the existing ;-paging semantics (re-fetch on doubled limit at the boundary). - Removed the dead JSON helpers (top_field/json_count/json_exhausted/json_error). The regression guard — fetch_runs_a_real_compiled_binary compiles your exact membercheck program via plgc and asserts the bound-variable query returns ["X = a"], plus the no-solution, multi-solution, limit-truncation, and parse-error paths. This is the test that was missing: every prior test operated on hand-written string fixtures, so a broken wire contract sailed past CI. It locates plgc via $PLGC or target/<profile>/plgc, which cargo test --workspace always builds. Results: 495 tests pass workspace-wide, cargo fmt --check clean, cargo clippy -D warnings clean. I changed only crates/repl/src/run.rs — the runtime/compiler were already correct and untouched.
Done. X = a, exit 1 → Fetch::Found.
All checks were successful
WASM Gates / WASM gates (Tier 1 wasi + Tier 2 reactor) (pull_request) Successful in 9s
CI - Linux / CI - Linux x86_64 (pull_request) Successful in 1m2s
237082a719
Summary

 Root cause — the bson capability-table refactor (df76b24→d6f3228) removed the
 json encoder from the runtime, but crates/repl/src/run.rs was never updated;
 it kept requesting --format json, which the engine rejects (exit 2, empty
 stdout), so fetch() always fell through to Fetch::NoSolutions → "  false.".
 Every ?- query in the REPL has been broken since, not just yours. Your Prolog
 was correct.

 The fix (crates/repl/src/run.rs, rewritten):
 - Single text exec instead of two (json + text). --format text is the engine's
   display path and works on the default [text] binary — no capability
   injection, no new parsers, no linking the heavy runtime.
 - Exit code is authoritative: 0→NoSolutions, 1→Found, 2/3→Failed (message
   parsed from error: <msg> on stdout, stderr fallback).
 - Self-describing solution split (split_text_solutions): the engine emits
   uniform Var = Value lines per solution, so the first variable's name is the
   group delimiter — no external count needed. Handles false./true. and values
   containing =.
 - exhausted = solutions.len() < limit — matches the existing ;-paging
   semantics (re-fetch on doubled limit at the boundary).
 - Removed the dead JSON helpers
   (top_field/json_count/json_exhausted/json_error).

 The regression guard — fetch_runs_a_real_compiled_binary compiles your exact
 membercheck program via plgc and asserts the bound-variable query returns ["X
 = a"], plus the no-solution, multi-solution, limit-truncation, and parse-error
 paths. This is the test that was missing: every prior test operated on
 hand-written string fixtures, so a broken wire contract sailed past CI. It
 locates plgc via $PLGC or target/<profile>/plgc, which cargo test --workspace
 always builds.

 Results: 495 tests pass workspace-wide, cargo fmt --check clean, cargo clippy
 -D warnings clean. I changed only crates/repl/src/run.rs — the
 runtime/compiler were already correct and untouched.
navicore deleted branch repl-is-broken-by-bson-update 2026-07-04 18:31:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
navicore/patch-prolog!46
No description provided.