Skip to content

fix(magic-sets): fix fb adornment encoding — silent empty results and recursive binding (#297, #298) - #300

Merged
adityamukho merged 4 commits into
mainfrom
worktree-fix+magic-sets-fb-297-298
Jun 28, 2026
Merged

adityamukho merged 4 commits into
mainfrom
worktree-fix+magic-sets-fb-297-298

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Summary

Fixes two v1.2.0 regressions in magic sets rewriting (src/query/datalog/magic_sets.rs):

Fix — sentinel entity + 2-arg guard for fb adornments:

  1. New sentinel_entity(magic_attr) helper — deterministic Uuid::new_v5(OID, magic_attr), unique per magic predicate, stable across runs.
  2. build_seed_facts fb branch: sentinel replaces Uuid::new_v4(); keyword stays in value position.
  3. inject_magic_guard fb branch: emits 2-arg guard [Uuid(sentinel), bound_var] — variable now binds from value position, preserving Keyword type.
  4. build_propagation_rules fb branch: mirrors Phase 1 & 2 Complete: Minigraf embedded graph database with persistent storage #3 for guard; sentinel in propagation rule head so derived facts land in value position.

bf path is untouched.

Test plan

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.66667% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/query/datalog/magic_sets.rs 76.66% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 76ee74b into main Jun 28, 2026
23 of 29 checks passed
@adityamukho
adityamukho deleted the worktree-fix+magic-sets-fb-297-298 branch June 28, 2026 12:38
adityamukho added a commit that referenced this pull request Sep 26, 2026
…#297) (#409)

A recursive rule whose intermediate variable is bound by a call to another
user rule, e.g. (chain ?x ?y) :- (link ?x ?mid) (chain ?mid ?y), failed
with "Unbound variable in rule head: ?mid" (INT-022) when queried with a
literal first argument such as (chain :a ?y).

build_propagation_rules built the magic rule for the recursive call from
the guard plus only the non-RuleInvocation clauses preceding it, so it
emitted (__magic_chain_bf ?mid) :- (__magic_chain_bf ?x) with ?mid unbound.
#300 fixed only the case where a fact pattern binds the intermediate.

Keep every preceding clause, including rule invocations, as standard
magic-sets rewriting does. All rewritten rules are positive, so the added
dependency on the (guarded) called predicate is safe.

Adds integration tests for the reopened repro and a left-recursive variant,
and a unit test pinning the propagation-rule body.


Claude-Session: https://claude.ai/code/session_01BedF9ZmqVZLkvDwn91fuKy

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant