datalog: aggregates work as top-level query goals (183/183)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s

Bug: dl-match-lit (the naive matcher used by dl-find-bindings)
was missing dl-aggregate? dispatch — it was only present in
dl-fbs-aux (semi-naive). Symptom:
  (dl-query db '(count N X (p X)))
silently returned ().

Two fixes:
- Add aggregate branch to dl-match-lit before the positive case.
- dl-query-user-vars now projects only the result var (first arg)
  of an aggregate goal — the aggregated var and inner-goal vars
  are existentials and should not leak into substitutions.

2 new aggregate tests cover count and findall as direct query goals.
This commit is contained in:
2026-05-08 09:45:15 +00:00
parent f33a8d69f5
commit d66ddc614b
5 changed files with 60 additions and 15 deletions

View File

@@ -284,6 +284,16 @@ large graphs.
_Newest first._
- 2026-05-08 — Bug fix: aggregates work as top-level query goals.
`dl-match-lit` (the naive matcher used by `dl-find-bindings`) was
missing the `dl-aggregate?` dispatch — it was only present in
`dl-fbs-aux` (semi-naive). Symptom: `(dl-query db '(count N X (p X)))`
silently returned `()`. Also updated `dl-query-user-vars` to project
only the result var (first arg) of an aggregate goal — the
aggregated var and inner-goal vars are existentials and should not
appear in the projected substitution. 2 new aggregate tests cover
the regression.
- 2026-05-08 — Convenience: `dl-eval source query-source`. Parses
both strings, builds a db, saturates, runs the query, returns
the substitution list. Single-call user-friendly entry. 2 new