datalog: dl-magic-query falls back on built-in/agg/neg goals (222/222)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s

Bug: dl-magic-query was always trying to seed a magic_<rel>^<adn>
fact for the query goal. For aggregate goals like (count N X (p X))
this produced a non-ground "fact" (magic_count^... N X (p X)) and
dl-add-fact! correctly rejected it, surfacing as an error.

Fix: dl-magic-query now detects built-in / aggregate / negation
goals up front and dispatches to plain dl-query for those cases —
magic-sets only applies to positive non-builtin literals against
rule-defined relations. Other shapes don't benefit from the
rewrite anyway.

1 new test confirms (count N X (p X)) returns the expected
{:N 3} via dl-magic-query.
This commit is contained in:
2026-05-08 10:32:01 +00:00
parent 5a3db1a458
commit a648247ae4
4 changed files with 38 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
{
"lang": "datalog",
"total_passed": 221,
"total_passed": 222,
"total_failed": 0,
"total": 221,
"total": 222,
"suites": [
{"name":"tokenize","passed":26,"failed":0,"total":26},
{"name":"parse","passed":18,"failed":0,"total":18},
@@ -13,8 +13,8 @@
{"name":"negation","passed":10,"failed":0,"total":10},
{"name":"aggregates","passed":19,"failed":0,"total":19},
{"name":"api","passed":20,"failed":0,"total":20},
{"name":"magic","passed":23,"failed":0,"total":23},
{"name":"magic","passed":24,"failed":0,"total":24},
{"name":"demo","passed":21,"failed":0,"total":21}
],
"generated": "2026-05-08T10:29:04+00:00"
"generated": "2026-05-08T10:31:43+00:00"
}