Skip to content

spec: make the ABNF read the sentences ergo.rego reads - #242

Merged
jbpros merged 2 commits into
mainfrom
spec/abnf-fixes
Oct 17, 2026
Merged

jbpros merged 2 commits into
mainfrom
spec/abnf-fixes

Conversation

@jbpros

@jbpros jbpros commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Follows #241. Fixes every disagreement between spec/sentences.abnf and ergo.rego that its check finds, and empties the list in spec/OPEN.md.

#241's check missed most of the cases. It only collected sentences under assert, for and from, not checks written as c: "x is 1", so it read 79 case sentences instead of 324. This PR collects those too, and that turned up three more groups, fixed here as well.

ABNF

  • Spaces inside keywords. Keywords of several words, like is not empty, if any, and named by, now take WS between their words, so x is not empty parses. sentences.md:212 already said a run of spaces reads as one.
  • Spaces at the ends. The ABNF says spaces at either end of a line are dropped before it's read, as ergo.rego does.
  • Elapsed time. It can now go in a whose, after a plus, and alone on the right of a phrase, like vulns whose days elapsed from found to now is more than 30 or n is days elapsed from started to ended. ergo.rego reads these and reports an elapsed time isn't supported yet except alone before a phrase, so a parser built from the ABNF reads the same sentences. spec: say what the forms ergo.rego doesn't run yet mean and list them as known differences #243 takes this further and says what these forms mean.
  • Lists without spaces. x is one of "a","b" parses, as sentences.md:212 says a list can be written with or without a space after each comma.

check_grammar.py

  • It reads every check in the cases.
  • It applies [sentence.words] after the ABNF parses a line, as sentences.md:407 says a parser has to. So count of approvers is empty doesn't parse as is followed by a field called empty. The word list is read from that rule in sentences.md, not copied into the script.
  • It drops spaces at either end of a line before the ABNF parser reads it.

check_grammar.py now reads 6565 sentences with 0 disagreements, and still 0 with #243 on top. check_rules.py passes. No .rego changed.

🤖 Generated with Claude Code

@jbpros jbpros added the core Relates to the ergo library or format themselves. label Oct 17, 2026
Base automatically changed from spec/abnf-check to main October 17, 2026 14:15
@jbpros
jbpros marked this pull request as ready for review October 17, 2026 14:15
… and plus

Fixes the three groups of sentences check_grammar.py found where the
ABNF and ergo.rego disagree:

- Keywords of several words, like "is not empty" and "named by", take
  WS between their words, as sentences.md says a run of spaces reads
  as one.
- Spaces at either end of a line are dropped before it's read, as
  ergo.rego does.
- An elapsed time can go in a whose or after a plus. ergo.rego reads it
  and says it isn't supported yet, as sentence.derived.elapsed says, so
  a parser built from the ABNF gives the same message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd an elapsed time on the right

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jbpros jbpros changed the title spec: read keywords with any run of spaces and elapsed times in whose and plus spec: make the ABNF read the sentences ergo.rego reads Oct 17, 2026
@jbpros
jbpros merged commit 4c34625 into main Oct 17, 2026
8 checks passed
@jbpros
jbpros deleted the spec/abnf-fixes branch October 17, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Relates to the ergo library or format themselves.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant