Commit Graph

8 Commits

Author SHA1 Message Date
7a64be22d8 datalog: dl-eval ≡ dl-eval-magic equivalence test (215/215)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s
2026-05-08 10:19:58 +00:00
9695d31dab datalog: dl-rules-of relation-inspection helper (214/214)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
(dl-rules-of db rel-name) → list of rules with head matching
the given relation name. Useful for tooling and debugging
("show me how this relation is derived") without exposing the
internal :rules list directly.

2 new api tests cover hit and miss cases.
2026-05-08 10:17:44 +00:00
9c5a697e45 datalog: dl-clear-idb! helper (208/208)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
Wipes every rule-headed relation (the IDB) — leaves EDB facts and
rule definitions intact. Useful for inspecting the EDB-only
baseline or for forcing a clean re-saturation.

  (dl-saturate! db)
  (dl-clear-idb! db)        ; ancestor relation now empty
  (dl-saturate! db)         ; re-derives ancestor from parents

2 new api tests verify IDB-wipe and EDB-preservation.
2026-05-08 10:06:48 +00:00
282a3d3d06 datalog: dl-eval-magic single-call magic-sets entry (206/206)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s
Symmetric to dl-eval but routes single-positive-literal queries
through dl-magic-query for goal-directed evaluation. Multi-literal
query bodies fall back to standard dl-query (magic-sets is wired
for single goals only).

  (dl-eval-magic source-string "?- ancestor(a, X).")

1 new api test.
2026-05-08 10:04:59 +00:00
e2c149e60a datalog: comprehensive integration test (184/184)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 47s
Single program exercising recursion + stratified negation +
aggregation + comparison composed end-to-end via dl-eval. Confirms
the full pipeline (parser → safety → stratifier → semi-naive +
aggregate post-pass → query) on a non-trivial program.

  edge graph + banned set →
    reach transitive closure →
    safe (reach minus banned) →
    reach_count via count aggregation grouped by source →
    popular = reach_count >= 2
2026-05-08 09:47:56 +00:00
f33a8d69f5 datalog: dl-eval source + query convenience (181/181)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Single-call entry: dl-eval source-string query-string parses
both, builds a db via dl-program, saturates implicitly, runs
the query (extracted from the parsed `?- ...` clause), and
returns the substitution list.

Most user-friendly path:
  (dl-eval "parent(a, b). ..." "?- ancestor(a, X).")

2 new api tests cover ancestor and multi-goal usage.
2026-05-08 09:41:02 +00:00
408fc27366 datalog: dl-query accepts conjunctive goal lists (167/167)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
dl-query now auto-dispatches on the first element's shape:
- positive literal (head is a symbol) or {:neg ...} dict → wrap
- list of literals → conjunctive query

dl-query-coerce normalizes; dl-query-user-vars collects the union
of user-named vars (deduped, '_' filtered) for projection. Old
single-literal callers unchanged.

  (dl-query db '(p X))                   ; single
  (dl-query db '((p X) (q X)))           ; conjunction
  (dl-query db (list '(n X) '(> X 2)))   ; with comparison

2 new api tests cover multi-goal AND and conjunction with comparison.
2026-05-08 09:17:15 +00:00
ce603e9879 datalog: SX-data embedding API (Phase 9, 143/143)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
New lib/datalog/api.sx: dl-program-data facts rules takes SX data
lists. Rules accept either dict form or list form using <- as the
rule arrow (since SX parses :- as a keyword). dl-rule constructor
for the dict shape. dl-assert! adds a fact and re-saturates;
dl-retract! drops EDB matches, wipes all rule-headed IDB
relations, and re-saturates from scratch — simplest correct
semantics until provenance tracking arrives.

9 API tests cover ancestor closure via data, dict-rule form,
dl-rule constructor, incremental assert/retract, cyclic-graph
reach, assert into empty, fact-style rule (no arrow), dict
passthrough.
2026-05-08 08:34:08 +00:00