8000 fuzz(datalog_eval): skip inputs whose patterns join to a cross product (#575) by adityamukho · Pull Request #576 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fuzz(datalog_eval): skip inputs whose patterns join to a cross product (#575) - #576

Merged
adityamukho merged 3 commits into
v3from
fuzz/575-cartesian-guard-v3
Oct 13, 2026
Merged

adityamukho merged 3 commits into
v3from
fuzz/575-cartesian-guard-v3

Conversation

@adityamukho
@adityamukho adityamukho commented Oct 13, 2026 •
Copy link
Copy Markdown
Collaborator

Stops the nightly datalog_eval fuzz job from reporting the known cross-product OOM in #575. The engine fix is tracked in #549 (part of #473). This PR changes only the fuzz harness. No library code changes.

Why

The executor holds every intermediate binding, so a query whose patterns share no variables builds the whole cross product: 3^k rows over the harness's 3 facts. The nightly found a 21-pattern input that reached 2.1 GB. The streaming engine (#473) bounds this query's memory, and #549's optional query_memory_limit / QRY-012 covers what remains. Run time stays exponential, though, so the harness needs its own guard either way.

What

fuzz/fuzz_targets/datalog_eval.rs estimates how many rows a cross product of the input's patterns could produce, and skips the input above 50,000:

  • Every innermost [...] with at least three tokens counts as a pattern. Brackets inside string literals are ignored (found in Codex review).
  • Patterns are grouped by the variables they share. _ and ?_… are wildcards and share nothing, as in matcher.rs.
  • Each group's join is counted against the 3 facts with a budgeted depth-first search, and the group counts are multiplied. A group with no matches counts as 1, so a pattern that matches nothing can't mask a cross product.
  • The Nightly fuzz failure (main) #575 input is added to the corpus as a seed.
  • codecov.yml ignores fuzz/**. Harness code runs under cargo-fuzz, never under cargo test, so Codecov counted it as 0% patch coverage.

Verification

  • Nightly fuzz failure (main) #575 input: was an OOM (2.1 GB), now skipped (10 ms). A synthetic 13-pattern disjoint query is also skipped.
  • -runs=0 over the full corpus: only the Nightly fuzz failure (main) #575 seed is skipped (v3: 1 of 4,783 inputs), so the guard costs no engine coverage.
  • A query whose string literal contains many bracketed triples still runs.
  • Pre-push hook (fmt, clippy, tests) passed.

Refs #575. After this PR and its main counterpart merge, #575 will be closed as tracked by #549.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U611mBGbkSqJeSwNz2xd7s

adityamukho and others added 2 commits October 13, 2026 19:25
#575)

The executor holds every intermediate binding, so a query whose patterns
share no variables builds the whole cross product: 3^k rows over the
harness's 3 facts. The nightly found a 21-pattern input that reached
2.1 GB. That is a known limit, fixed by the streaming engine (#473) and
the optional query memory limit (#549), not a new bug.

The harness now estimates the rows a cross product could yield: it groups
the patterns by shared variables (`_` and `?_` are wildcards), counts each
group's join against the 3 facts, and multiplies the groups. Inputs above
50,000 rows are skipped. On the v3 corpus (4,783 inputs) only the #575
input is skipped, so no coverage is lost. The input is added as a seed.

Refs #575

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U611mBGbkSqJeSwNz2xd7s
A string such as "[?a ?b ?c] [?d ?f ?g] ..." was read as patterns, so the
cross-product estimate could skip a query with one real pattern. The
scanner now skips quoted strings, honouring backslash escapes.

Refs #575

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

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Harness code runs under cargo-fuzz, never under cargo test, so codecov
counted the #575 guard as 0% patch coverage.

Refs #575

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U611mBGbkSqJeSwNz2xd7s
@adityamukho
adityamukho merged commit f7d0328 into v3 Oct 13, 2026
24 checks passed
@adityamukho
adityamukho deleted the fuzz/575-cartesian-guard-v3 branch October 13, 2026 15:35
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