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)