8000 fix(query): count only derived facts against max_results (#528) by adityamukho · Pull Request #534 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(query): count only derived facts against max_results (#528) - #534

Merged
adityamukho merged 1 commit into
v3from
fix/528-rule-max-results
Oct 11, 2026
Merged

adityamukho merged 1 commit into
v3from
fix/528-rule-max-results

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Closes #528.

Problem

RecursiveEvaluator::evaluate_recursive_rules seeded seen_facts with every base fact and returned INT-020 once seen_facts.len() >= max_results. The limit counted the database, not what the rules derive: with 1,000,000 or more live facts (the default limit), every rule query failed at its first derived fact. Affects every release since v0.18.0.

Fix

Count only facts added after the base facts (seen_facts.len() - base_count). A runaway rule still fails with INT-020.

Tests

  • test_max_results_counts_derived_facts_not_base_facts (tests/recursive_rules_test.rs): max_results(10) on 53 live facts; a bound-argument (magic sets) and an all-free rule query both answer; :max-results 5 on a query deriving 6 facts is still INT-020. Failed before the fix.
  • Existing limit tests (rule_limits_apply_while_the_engine_materialises, test_stratified_max_results_limit) still pass.
  • Full suite: 1417 passed, 10 ignored.

Measured

perf_envelope --scales 1m: recursive_ancestors returns its 6 rows in 40.1 s p50 / 40.8 s p99, 3.2 GiB RSS (was INT-020). Still slow because rule evaluation reads the whole database (#529).

Docs

OpenOptions::max_results docs, ERROR_REFERENCE.md (INT-020 cause), CHANGELOG.md (Fixed), BENCHMARKS.md, README, test counts. Docs site: project-minigraf/minigraf-docs PR to follow (@until/@since v3.0.0 text for :max-results).

Not backported to v2.x: not a data-integrity fix. #421 should mark #528 as fixed in v3.0.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h

RecursiveEvaluator seeded seen_facts with every base fact and compared
its size with max_results, so on a database with max_results (default
1,000,000) live facts every rule query failed with INT-020 at its first
derived fact, whatever the size of its answer. The limit now counts
only the facts the rules derive.

At 1M facts, recursive_ancestors in the performance envelope now
returns its 6 rows (40.1 s p50) instead of failing; BENCHMARKS.md and
the README are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
@codecov
codecov Bot commented Oct 11, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

9C23
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