v0.4.0 — API consolidation + JBCT polish (breaking)
Highlights
Breaking release. API consolidation pass: factory naming, parse-don't-validate Grammar, Result/Option boundary cleanups, Formatter immutable config, SessionImpl record. Six logical phases over 16 commits. All 897 tests green throughout.
No incremental v2.5 cache remap. The original 0.4.0 plan item was superseded by the v2.5 spike's NO-GO recommendation (docs/incremental/V2.5-SPIKE.md) — the actual perf lever is pivot-selection in findBoundaryCandidate, not cache invalidation. A naive lever-1 swap was tried in 0.3.6 development but hit boundary-semantic regressions; deferred until that's resolved cleanly.
What changed (BREAKING)
Grammarparse-don't-validate.Grammar.of(...)removed; useGrammar.grammar(rules, ...)returningResult<Grammar>. Validation runs inside the factory; standalonevalidate()removed.- Factory rename across the codebase.
of()/create()/at()→typeName()for all public factories. Affected:SourceLocation.sourceLocation,SourceSpan.sourceSpan,ParserConfig.parserConfig,ParseResult.Success.success,ParseResult.Failure.failure,ParseResult.CutFailure.cutFailure,ActionCompiler.actionCompiler,SemanticValues.semanticValues,ParserGenerator.parserGenerator,CstHash.cstHash,SessionFactory.sessionFactory,TraceRecord.traceRecord. - Test assertion idiom. Tests rewritten from
assertTrue(result.isSuccess())+unwrap()toresult.onFailureDo(c -> fail(c.message())).onSuccessDo(...). Failure causes are no longer silently swallowed. SessionImpl→IncrementalSessionrecord. Drops theImplanti-pattern.Sessioninterface unchanged; record components are internal-only.Formatterbuilder is now immutable. NewFormatterConfigrecord;Formatterinstances are thread-safe to share post-construction.PegEngine.createWithoutActions(...)returnsResult<PegEngine>(symmetric withcreate).PegEngineaction dispatch is now aResult.liftboundary instead of try/catch.- Playground
parseRequestBodyreturnsResult<ParseRequest>with explicitBadRequestcause. - Incremental nullables → Option:
tryIncrementalReparse,findBoundaryCandidate. Zero(CstNode) nullcasts remain inpeglib-incremental.
Documentation
- Maven Mojo
execute()methods rewritten asResultpipelines with JBCT-boundary Javadoc explaining the lift contract. - CLI
mainmethods (AnalyzerMain,PlaygroundRepl,PlaygroundServer,PackratStatsProbe) carry JBCT-boundary Javadoc.
Migration
See CHANGELOG.md § [0.4.0] § "Migration guide" for per-change recipes.
Known limitations
- Incremental
singleCharEditperf is still ~325 ms/op pending the lever 1 boundary work. Targeted for 0.4.1 or later. - Generator-side
%recoverwas already shipped in 0.3.6 — orthogonal to this release.
Tests
897 passing (no change from 0.3.6 baseline — refactor preserved semantics throughout), 0 failures, 0 skipped.