Skip to content

test: grammar conformance harness — pest shadow grammar + EDN corpus (#233) - #235

Merged
adityamukho merged 14 commits into
mainfrom
feature/grammar-conformance-harness
May 13, 2026
Merged

adityamukho merged 14 commits into
mainfrom
feature/grammar-conformance-harness

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a pest PEG shadow grammar (tests/grammar/grammar.pest) encoding the full structural Minigraf Datalog syntax as an executable spec
  • Adds a three-bucket .edn corpus: 31 valid fixtures, 10 syntax-error fixtures, 13 semantic-error fixtures
  • Adds tests/grammar_conformance.rs with three #[test] functions (valid_corpus, invalid_syntax_corpus, invalid_semantic_corpus) that sweep the corpus and verify the three-bucket contract against both parsers
  • Adds formal EBNF grammar and semantics documentation to .wiki/Datalog-Reference.md (wiki already updated)
  • pest/pest_derive added to [dev-dependencies] only — zero production impact

Closes #233. Sub-issue of #230.

Three-bucket contract

Bucket pest Real parser
valid/ ACCEPTS ACCEPTS
invalid/syntax/ REJECTS REJECTS
invalid/semantic/ ACCEPTS REJECTS

The conformance harness fails CI the moment the grammar doc and parser disagree on any corpus fixture.

Notable implementation detail

The fact rule is permissive ("[" ~ edn_value+ ~ "]") so that under-arity and over-arity facts land in invalid/semantic/ (the real parser enforces the [E A V] / [E A V {map}] shape), not invalid/syntax/. This preserves the three-bucket taxonomy correctly.

Test plan

  • cargo test --test grammar_conformance — all 3 tests pass (31 valid + 10 syntax + 13 semantic fixtures)
  • Full suite (cargo test) — 538 tests pass, 0 failures
  • cargo clippy --tests — clean

🤖 Generated with Claude Code

adityamukho and others added 14 commits May 8, 2026 19:15
Covers corpus layout (valid/invalid/syntax/invalid/semantic), pest shadow
grammar scope, three-bucket conformance test logic, and Cargo changes.
Resolves the open design question for issue #230 pre-implementation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rables

Scope now explicitly covers three deliverables: conformance harness,
EBNF grammar document, and semantics prose. Links to sub-issues #233
and #234. Tutorials correctly scoped out to #234.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add pest/pest_derive dev-dependencies, corpus directory structure
(tests/grammar/valid, invalid/syntax, invalid/semantic), placeholder
grammar.pest, and the full three-bucket conformance test harness.
Tests fail with "corpus is empty" as expected until fixtures are added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Task 7)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
10 .edn files in tests/grammar/invalid/syntax/ that are rejected by
both the pest grammar and the real Minigraf parser.  Note: the spec
suggested not_join_no_clauses.edn but pest's rule_invocation fallthrough
accepts (not-join [?e]), so the 10th file is transact_no_args.edn
((transact) with no argument) which both parsers structurally reject.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 fixture files where pest accepts (structural syntax is valid) but
the real Minigraf parser rejects (semantic check fails): not-safety
violations, nested not/or-inside-not, not-join unbound join vars,
unbound expr/aggregate/:with variables, :with without aggregate,
window-only func without :over, non-window func with :over, fact
too-few elements, retract wrong arity, invalid UUID format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit c9d9fe3 into main May 13, 2026
36 checks passed
@adityamukho
adityamukho deleted the feature/grammar-conformance-harness branch May 13, 2026 10:43
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.

[FEATURE] EBNF grammar specification and semantics documentation

1 participant