Files
rose-ash/lib/datalog/scoreboard.md
giles 82dfa20e82
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 13s
datalog: dl-magic-query pre-saturates for aggregate correctness
dl-magic-query could silently diverge from dl-query when an
aggregate's inner-goal relation was IDB. The rewriter passes
aggregate body lits through unchanged (no magic propagation
generated for them), so the inner relation was empty in the magic
db and the aggregate returned 0. Repro:

  (dl-eval-magic
    "u(a). u(b). u(c). u(d). banned(b). banned(d).
     active(X) :- u(X), not(banned(X)).
     n(N) :- count(N, X, active(X))."
    "?- n(N).")
  => ({:N 0})   ; should be ({:N 2})

dl-magic-query now pre-saturates the source db before copying facts
into the magic db. This guarantees equivalence with dl-query for
every stratified program; the magic benefit still comes from
goal-directed re-derivation of the query relation under the seed
(which matters for large recursive joins). The existing test cases
happened to dodge this because their aggregate inner-goals were all
EDB.

1 new regression test; conformance 274/274.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 08:59:28 +00:00

421 B

datalog scoreboard

274 / 274 passing (0 failure(s)).

Suite Passed Total Status
tokenize 31 31 ok
parse 23 23 ok
unify 29 29 ok
eval 42 42 ok
builtins 26 26 ok
semi_naive 8 8 ok
negation 12 12 ok
aggregates 23 23 ok
api 22 22 ok
magic 37 37 ok
demo 21 21 ok