datalog: dl-magic-rewrite worklist now drains across rule chains (239/239)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

Real bug: the worklist used (set! queue (rest queue)) to pop the
head, which left queue bound to a fresh empty list as soon as the
last item was popped. Subsequent (append! queue ...) was a no-op
on the empty list — so when the head's rewrite generated new
(rel, adn) pairs to enqueue, they vanished. Multi-relation
programs (e.g. shortest -> path -> edge, or chained derived
relations) only had their head's rules rewritten; downstream
rules silently dropped.

Fix: use an index-based loop (idx 0 → len queue), with append!
adding to the same list. Items added after the current pointer
are picked up in subsequent iterations.

2 new regression tests:
- 4-level chain (a → r1 → r2 → r3 → r4) under magic returns 2
- shortest-path demo via magic equals dl-query (1 result)
This commit is contained in:
2026-05-08 14:41:05 +00:00
parent e981368dcf
commit 17d6f58cc5
4 changed files with 53 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
# datalog scoreboard
**237 / 237 passing** (0 failure(s)).
**239 / 239 passing** (0 failure(s)).
| Suite | Passed | Total | Status |
|-------|--------|-------|--------|
@@ -13,5 +13,5 @@
| negation | 10 | 10 | ok |
| aggregates | 20 | 20 | ok |
| api | 20 | 20 | ok |
| magic | 29 | 29 | ok |
| magic | 31 | 31 | ok |
| demo | 21 | 21 | ok |