Files
rose-ash/lib/datalog/scoreboard.md
giles c6f646607e
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 27s
datalog: dl-retract! preserves EDB in mixed relations
A "mixed" relation has both user-asserted facts AND rules with the
same head. Previously dl-retract! wiped every rule-head relation
wholesale before re-saturating — the saturator only re-derives the
IDB portion, so explicit EDB facts vanished even for a no-op retract
of a non-existent tuple. Repro:

  (let ((db (dl-program "p(a). p(b). p(X) :- q(X). q(c).")))
    (dl-retract! db (quote (p z)))
    (dl-query db (quote (p X))))

went from {a, b, c} to just {c}.

Fix: track :edb-keys provenance in the db.

  - dl-make-db now allocates an :edb-keys dict.
  - dl-add-fact! (public) marks (rel-key, tuple-key) in :edb-keys.
  - New internal dl-add-derived! does the append without marking.
  - Saturator (semi-naive + naive driver) now calls dl-add-derived!.
  - dl-retract! strips only the IDB-derived portion of rule-head
    relations (anything not in :edb-keys) and preserves the EDB
    portion through the re-saturate pass.

2 new regression tests; conformance 262/262.

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

421 B

datalog scoreboard

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

Suite Passed Total Status
tokenize 30 30 ok
parse 22 22 ok
unify 29 29 ok
eval 39 39 ok
builtins 23 23 ok
semi_naive 8 8 ok
negation 10 10 ok
aggregates 22 22 ok
api 22 22 ok
magic 36 36 ok
demo 21 21 ok