Skip to content

Release 0.4.2: standalone-parser fix (no FQCN, no peglib runtime dep)#30

Merged
siy merged 4 commits into
mainfrom
release-0.4.2
May 5, 2026
Merged

Release 0.4.2: standalone-parser fix (no FQCN, no peglib runtime dep)#30
siy merged 4 commits into
mainfrom
release-0.4.2

Conversation

@siy

@siy siy commented May 5, 2026

Copy link
Copy Markdown
Owner

Single-fix maintenance release.

Fixed

  • Generated parsers no longer leak FQCN references to peglib (org.pragmatica.peg.action.RuleId, java.util.ArrayDeque, etc.). The standalone-parser contract documented on ParserGenerator is now enforced end-to-end.
  • See CHANGELOG [0.4.2] entry for full details.

Why this is needed

Downstream projects without peglib on their compile classpath could not build the emitted source, despite the generator's documented contract that generated parsers depend only on pragmatica-lite:core. The emitted RuleId interface declared extends org.pragmatica.peg.action.RuleId and the emitted parseRuleAt signature used the FQCN — both vestigial since the generated withAction API uses string-based dispatch.

Test plan

  • 897/0/0 across all 5 modules
  • RuleIdEmissionTest updated to assert standalone shape + absence of org.pragmatica.peg.action.RuleId in emitted source
  • mvn verify BUILD SUCCESS
  • Version consistency verified across 6 POMs + README + CHANGELOG

Summary by CodeRabbit

  • Bug Fixes

    • Generated parsers are now standalone and no longer extend the library's internal RuleId interface, improving portability. Existing generated parsers must be regenerated to apply this fix.
  • Documentation

    • Updated dependency and plugin version references to 0.4.2 in README and examples.
    • Added design documentation for planned performance optimizations.

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Version 0.4.2 release adjusts generated parser code to emit a standalone RuleId interface that no longer extends or references org.pragmatica.peg.action.RuleId. All module POM files and documentation are updated to reflect this version. A design spike document outlines a planned allocation-reduction generator enhancement for future work.

Changes

Generated Parser RuleId Standalone Refactoring

Layer / File(s) Summary
Generator RuleId Emission
peglib-core/src/main/java/org/pragmatica/peg/generator/ParserGenerator.java
generateRuleIdInterface now emits public sealed interface RuleId without extending org.pragmatica.peg.action.RuleId. CST dispatch and parseRuleAt method signatures are updated to accept Class<? extends RuleId> instead of the fully-qualified library type. ArrayDeque imports are added for generated CST recovery code.
Test Assertions
peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java
RuleIdEmissionTest assertions now verify that generated parsers emit standalone RuleId without referencing the library base class. CST test renamed and updated; AST test assertions changed to confirm absence of the FQCN. Runtime assignability check for inherited RuleId is removed.
Release Notes & README
CHANGELOG.md, README.md
CHANGELOG entry added for version 0.4.2 documenting standalone RuleId fix and regeneration requirements. README Maven dependency and plugin configuration versions updated from 0.4.1 to 0.4.2.
Module Versions
pom.xml, peglib-core/pom.xml, peglib-formatter/pom.xml, peglib-incremental/pom.xml, peglib-maven-plugin/pom.xml, peglib-playground/pom.xml
All parent POM version references bumped from 0.4.1 to 0.4.2.

Allocation-Reduction Generator Design Spike

Layer / File(s) Summary
Spike Documentation
docs/incremental/UNSAFE-GENERATOR-SPIKE.md
New design spike document outlining a Phase 1 proposal to reduce parser allocations by replacing per-call CstParseResult objects with boolean-returning methods and mutable parser-class state fields (lastSuccess, lastCutFailed, lastNode, lastText, lastEndOffset, lastEndLine, lastEndColumn, lastExpected). Includes scope, state-capture discipline, trivia/cut-failure semantics, risks, and a gating plan via ParserConfig flag for future implementation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • siy/java-peglib#21: Directly adjusts the same generated RuleId shape and parseRuleAt signatures to remove org.pragmatica.peg.action.RuleId extension.
  • siy/java-peglib#22: Related through RuleId/type handling—implements a RuleIdRegistry generating runtime RuleId classes while this PR makes generated RuleId standalone.
  • siy/java-peglib#17: Directly related as it introduced the generated RuleId extension to the library RuleId that this PR now removes.

Poem

🐰 Hop along, the rules now stand alone,
No library umbra cast—the seeds are sown.
State fields flutter where allocations fled,
A spike takes shape, tomorrow's path ahead!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely describes the main change: a release that fixes the standalone-parser behavior by removing FQCN references and the peglib runtime dependency.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-0.4.2

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java (1)

43-45: ⚡ Quick win

Strengthen regression assertions for the full standalone contract surface.

These tests currently guard org.pragmatica.peg.action.RuleId leakage, but they don’t pin the parseRuleAt(Class<? extends RuleId>, ...) shape or guard other FQCN regressions called out in this release (for example java.util.ArrayDeque).

Suggested assertion additions
@@
         assertThat(source).contains("public sealed interface RuleId {");
         assertThat(source).doesNotContain("org.pragmatica.peg.action.RuleId");
+        assertThat(source).doesNotContain("java.util.ArrayDeque");
+        assertThat(source).contains("Class<? extends RuleId> ruleId");
+        assertThat(source).doesNotContain("Class<? extends org.pragmatica.peg.action.RuleId>");
         assertThat(source).contains("record Number() implements RuleId");
         assertThat(source).contains("record Sum() implements RuleId");
@@
         assertThat(source).contains("public sealed interface RuleId {");
         assertThat(source).doesNotContain("org.pragmatica.peg.action.RuleId");
+        assertThat(source).doesNotContain("java.util.ArrayDeque");
         assertThat(source).contains("record Number() implements RuleId");
         assertThat(source).contains("record Sum() implements RuleId");

Also applies to: 58-60

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java`
around lines 43 - 45, The test should be extended to assert the full standalone
contract surface and prevent FQCN regressions: update RuleIdEmissionTest to
additionally assert the presence of the parseRuleAt method signature (e.g.,
"parseRuleAt(Class<? extends RuleId>") and to assert that no other unexpected
fully-qualified class names appear (e.g.,
doesNotContain("java.util.ArrayDeque"),
doesNotContain("org.pragmatica.peg.action.RuleId") remains) so the generated
source contains "public sealed interface RuleId {" and "record Number()
implements RuleId" while also pinning the parseRuleAt shape and banning prior
FQCN leaks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java`:
- Around line 43-45: The test should be extended to assert the full standalone
contract surface and prevent FQCN regressions: update RuleIdEmissionTest to
additionally assert the presence of the parseRuleAt method signature (e.g.,
"parseRuleAt(Class<? extends RuleId>") and to assert that no other unexpected
fully-qualified class names appear (e.g.,
doesNotContain("java.util.ArrayDeque"),
doesNotContain("org.pragmatica.peg.action.RuleId") remains) so the generated
source contains "public sealed interface RuleId {" and "record Number()
implements RuleId" while also pinning the parseRuleAt shape and banning prior
FQCN leaks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90cce030-b321-4cf3-956e-d3b6b0efa455

📥 Commits

Reviewing files that changed from the base of the PR and between 03a9c54 and 5302695.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • README.md
  • docs/incremental/UNSAFE-GENERATOR-SPIKE.md
  • peglib-core/pom.xml
  • peglib-core/src/main/java/org/pragmatica/peg/generator/ParserGenerator.java
  • peglib-core/src/test/java/org/pragmatica/peg/action/RuleIdEmissionTest.java
  • peglib-formatter/pom.xml
  • peglib-incremental/pom.xml
  • peglib-maven-plugin/pom.xml
  • peglib-playground/pom.xml
  • pom.xml

@siy siy merged commit f7a69b6 into main May 5, 2026
2 checks passed
@siy siy deleted the release-0.4.2 branch May 5, 2026 04:34
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