8000 fix(parser): reject what the grammar rejects (#651) by adityamukho · Pull Request #659 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(parser): reject what the grammar rejects (#651) - #659

Merged
adityamukho merged 2 commits into
v3from
fix/651-parser-tightening
Oct 20, 2026
Merged

adityamukho merged 2 commits into
v3from
fix/651-parser-tightening

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Closes #651 (closing keywords don't fire on v3; I'll close the issue by hand after merge).

The grammar verifier (#643) found inputs the parser accepted and tests/grammar/grammar.pest rejects. Some of them gave wrong answers. They are now errors (breaking for v3.0.0):

Input Before Now
[:find ?a :any-valid-time ?b :where …] (a value after any option and its argument) ?b joined :find PRS-061
(< ?a ?b), (?r ?a) as a clause (also in not/or/rule bodies) rule call, no rows PRS-097
(rule [(?r ?a) …]), (rule [(< ?a) …]) accepted PRS-105
(rule [(r ?a :c) …]) (r ?a ?x) bound ?x = :c new PRS-114
(?f ?x) as an aggregate / window / expression QRY-010/QRY-007 at run time PRS-025/PRS-029/PRS-063
(query []) accepted new PRS-111
empty :find / :where / :with one empty row / ignored new PRS-112
unknown query keyword (:foo, :limit, :in) ignored, or PRS-061 new PRS-113
"abc (no closing quote) read to end of input new PRS-109
: with no name (:+) the keyword : new PRS-110

Decisions (agreed with the maintainer):

  • A lone - stays the subtraction operator. The grammar gets the fix: op_sym now has "-" ~ !word_cont, like +.
  • Constant rule-head arguments are rejected. They match neither the grammar nor Datomic, and nothing tested or documented them. Workaround (in PRS-114): bind in the body, (rule [(r ?a ?x) [?a :edge ?x] [(= ?x :c)]]).
  • New codes only where no existing message fits. Variable or operator heads reuse the existing "must be a name" codes (PRS-025/029/063/097/105), whose docs now mention the v2.x behaviour.

Also included:

I scanned every (query …)/(rule …) form in the docs site, playground, demos, examples, src and tests: none outside the new tests hits a new rejection.

Verification: cargo test passes, and the verifier passes at bound 3 with no #651 drift. Bound 4 is running locally; I'll post the result here. Codex review: two findings, both checked against the code and both wrong (-?a is a plain_sym; (= ?x :c) is the binary form and runs).

Docs site: project-minigraf/minigraf-docs PR to follow (@since v3.0.0 notes in the Datalog reference).

🤖 Generated with Claude Code

https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT

The grammar verifier (#643) found inputs the parser accepted and
tests/grammar/grammar.pest rejects, some with wrong answers:

- a value after a query option and its argument joined the section
  before the option ([:find ?a :any-valid-time ?b ...] returned ?b as
  a column): now PRS-061
- a :where list headed by an operator or a variable, (< ?a ?b) or
  (?r ?a), was a call of a rule of that name and returned no rows:
  now PRS-097; a rule named by one: PRS-105
- a rule head argument that is not a variable: new PRS-114
- an aggregate, window or expression named by a variable failed at run
  time: now PRS-025 / PRS-029 / PRS-063
- (query []): new PRS-111; an empty :find/:where/:with: new PRS-112;
  an unknown query keyword: new PRS-113
- an unterminated string: new PRS-109; a ':' with no name: new PRS-110

A lone '-' stays the subtraction operator: the grammar's op_sym now
lists it. Removes the #651 entries from the verifier's KNOWN_DRIFT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
@adityamukho
Copy link
Copy Markdown
Collaborator Author

Bound 4 verifier passed locally: MINIGRAF_GRAMMAR_BOUND=4 cargo test --lib verifier, 4 passed in 234 s, no drift with no known cause and no stale entries.

@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!

…RIFT now empty; test counts combined)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
@adityamukho
adityamukho merged commit debacb9 into v3 Oct 20, 2026
24 checks passed
@adityamukho
adityamukho deleted the fix/651-parser-tightening branch October 20, 2026 15:24
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