8000 fix(rules): QRY-013 head entity, nil metadata for derived facts, UDFs in rule or branches (#548 PR 1) by adityamukho · Pull Request #668 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(rules): QRY-013 head entity, nil metadata for derived facts, UDFs in rule or branches (#548 PR 1) - #668

Merged
adityamukho merged 2 commits into
v3from
fix/548-executor-rules
Oct 20, 2026
Merged

adityamukho merged 2 commits into
v3from
fix/548-executor-rules

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

PR 1 of 3 for #548 (streaming engine part 6 of 9 of #473). It makes the executor changes in spec §4 (docs/superpowers/specs/2026-10-20-recursive-engine-design.md), so that both engines give one answer when PR 2 moves rule queries onto the engine. It also commits the implementation plan, docs/superpowers/plans/2026-10-20-548-recursive.md.

Changes

  • QRY-013 rule head entity is not an entity (new ErrorCode, row and section in ERROR_REFERENCE.md). A head whose entity is a string, number, boolean, nil or bare symbol fails on every path: positive rules (these raised INT-022), magic sets, and not / not-join / or rules (these silently dropped the row). The mixed pass now propagates instantiate_head's error, so an unbound head variable is INT-022 there too. QRY-012 stays reserved for streaming engine 7/9: memory accounting and optional cap (QRY-012) (#473) #549.
  • Derived facts have no metadata. Derived facts are loaded with tx-count 0 (load_fact(s) instead of transact); no stored fact has tx-count 0 (the counter starts at 1 and LogWriter rejects 0). PatternMatcher::metadata binds nil for them. FactStorage::transact has no non-test caller left and is now #[cfg(test)].
  • or / or-join branches in rule bodies get the database's FunctionRegistry instead of the built-ins only.
  • The plan lists five design decisions the spec leaves open (how a fact is marked, where nil is decided, the QRY-013 text, error propagation, the registry guard).

Breaking (v3.0.0)

  • A query that raised INT-022, or dropped rows, for a non-entity head now raises QRY-013. A not/or rule with an unbound head variable now raises INT-022.
  • Per-fact pseudo-attributes on derived facts bind nil. The old values were the evaluator's working values and had no meaning.

The UniFFI bindings need regenerating for the new ErrorCode variant. Binding PRs follow after merge.

Tests

tests/recursive_rules_test.rs: 5 new tests. 4 of them fail on origin/v3; the keyword/ref head test guards against a regression. There is also a unit test, test_head_entity_must_be_an_entity. Total 1687 (1677 passing, 10 ignored). --features test-oracle passes. Clippy (default, all features, wasm32) is clean. Codex review found no correctness issues; its one test-quality nit is fixed.

No closing keyword: #548 is closed by hand after PR 3. A docs-site PR follows.

🤖 Generated with Claude Code

https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT

adityamukho and others added 2 commits October 20, 2026 22:36
… in rule or branches (#548)

PR 1 of 3 for #548 (streaming engine 6/9), spec §4, so both engines give
one answer for rule queries:

- A rule head whose entity is not a ref or keyword fails with the new
  QRY-013 on every path (was INT-022 on positive rules; the not/or path
  dropped the row). The mixed pass propagates INT-022 for an unbound head
  variable too.
- Derived facts are loaded with tx-count 0 (no stored fact has it), and a
  per-fact pseudo-attribute reading one binds nil. FactStorage::transact is
  now test-only.
- or/or-join branches in rule bodies get the database's function registry.

Adds the implementation plan docs/superpowers/plans/2026-10-20-548-recursive.md.
Tests: 1687 total (1677 passing).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
@adityamukho
adityamukho merged commit 84ac845 into v3 Oct 20, 2026
23 of 24 checks passed
@adityamukho
adityamukho deleted the fix/548-executor-rules branch October 20, 2026 17:24
@codecov
codecov Bot commented Oct 20, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0