Skip to content

feat(query): add query complexity limits to prevent resource exhaustion - #57

Merged
adityamukho merged 1 commit into
mainfrom
fix/issue-46-query-limits
Apr 3, 2026
Merged

adityamukho merged 1 commit into
mainfrom
fix/issue-46-query-limits

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Summary

  • Add max_derived_facts and max_results fields to RecursiveEvaluator to limit query complexity
  • Add same fields to StratifiedEvaluator for stratified rule evaluation
  • Add default constants: DEFAULT_MAX_ITERATIONS (1000), DEFAULT_MAX_DERIVED_FACTS (100k), DEFAULT_MAX_RESULTS (1M)
  • Add limit checks in the evaluation loop to prevent runaway rule evaluation from malicious recursive rules
  • Add tests for both limit types on both evaluators

Closes #46

- Add max_derived_facts and max_results fields to RecursiveEvaluator
- Add max_derived_facts and max_results fields to StratifiedEvaluator
- Add DEFAULT_MAX_ITERATIONS (1000), DEFAULT_MAX_DERIVED_FACTS (100_000), DEFAULT_MAX_RESULTS (1_000_000)
- Add limit checks in evaluation loop to prevent runaway rule evaluation
- Add tests for both limit types on both evaluators
- Fix executor.rs to pass new parameters to StratifiedEvaluator

Closes #46
@codecov

codecov Bot commented Apr 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.04%. Comparing base (fb4ffd2) to head (8076c86).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   86.00%   86.04%   +0.03%     
==========================================
  Files          25       25              
  Lines        4237     4248      +11     
==========================================
+ Hits         3644     3655      +11     
  Misses        593      593              
Files with missing lines Coverage Δ
src/query/datalog/evaluator.rs 90.67% <100.00%> (+0.34%) ⬆️
src/query/datalog/executor.rs 93.23% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adityamukho
adityamukho merged commit 8b822b9 into main Apr 3, 2026
15 checks passed
@adityamukho
adityamukho deleted the fix/issue-46-query-limits branch April 3, 2026 02:15
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.

No query complexity limits

1 participant