refactor(parser): typed clause provenance via ClauseIrBuilder + ClauseDisposition (U5-M1)#5551
Merged
Merged
Conversation
…eDisposition (U5-M1)
Replace the ad-hoc `Vec<ClauseIr>` accumulation in `parse_effect_chain_ir`
with an item-scoped `ClauseIrBuilder` that is the single authority for
`ClauseIr` construction — a `_sealed` field makes every external struct
literal a compile error, so the builder's one internal `push` is the sole
construction site. Each clause now carries a typed identity + provenance:
- `ClauseId(u32)`: source-order identity minted by the builder.
- `source: OracleUnitSource` at the new honest `SpanPrecision::ChainRelative`
tier — byte-exact within the effect chain and carrying the verbatim
fragment, upgradeable to card-absolute once the document allocator is
threaded through `ParseContext` (a later unit). The fragment-precision
guard consults a widened `carries_fragment` (Exact | ChainRelative) rather
than `is_exact`, so the new tier can carry its fragment without reopening
the whole-document-fragment hole.
- `ClauseDisposition` (Emit / Continue / Special): folds the former
`absorbed_by_followup` + `special` discriminants into one typed enum. The
two continuations are orthogonal to the discriminant, so they are exposed
as role-named accessors that span variants: `followup()` (prior-patch;
carried by Emit + Continue) and `intrinsic()` (self-patch; carried by
Emit + Special).
`absorb_clause` re-mints a nested chain's clauses through the same
`.clause(...).push()` path, preserving the single-construction invariant.
The dead `is_otherwise` field is dropped (zero readers, verified).
Ten identical `Effect::Unimplemented { description: None }` placeholders (the
`.parsed` field of `Special`-disposition clauses, where the real semantics
live in the disposition) are folded into one `placeholder_parsed_clause`
helper — byte-identical, but DRY and distinct from the `Effect::unimplemented`
parse-gap constructor (which forces `description: Some`).
Faithful-by-intent, no behavior change: the IR snapshot parity tests hold
with zero `_lowered.snap` movement (63 snapshot tests + the full parser
suite green under `-D warnings`). locate() verbatim-fragment fallback rate:
1/4859 (0.02%) over the 568-card fixture.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
matthewevans
enabled auto-merge
July 11, 2026 04:37
Parse changes introduced by this PR✓ No card-parse changes detected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the ad-hoc
Vec<ClauseIr>accumulation inparse_effect_chain_irwith an item-scoped
ClauseIrBuilderthat is the single authority forClauseIrconstruction — a_sealedfield makes every external structliteral a compile error, so the builder's one internal
pushis the soleconstruction site. Each clause now carries a typed identity + provenance:
ClauseId(u32): source-order identity minted by the builder.source: OracleUnitSourceat the new honestSpanPrecision::ChainRelativetier — byte-exact within the effect chain and carrying the verbatim
fragment, upgradeable to card-absolute once the document allocator is
threaded through
ParseContext(a later unit). The fragment-precisionguard consults a widened
carries_fragment(Exact | ChainRelative) ratherthan
is_exact, so the new tier can carry its fragment without reopeningthe whole-document-fragment hole.
ClauseDisposition(Emit / Continue / Special): folds the formerabsorbed_by_followup+specialdiscriminants into one typed enum. Thetwo continuations are orthogonal to the discriminant, so they are exposed
as role-named accessors that span variants:
followup()(prior-patch;carried by Emit + Continue) and
intrinsic()(self-patch; carried byEmit + Special).
absorb_clausere-mints a nested chain's clauses through the same.clause(...).push()path, preserving the single-construction invariant.The dead
is_otherwisefield is dropped (zero readers, verified).Ten identical
Effect::Unimplemented { description: None }placeholders (the.parsedfield ofSpecial-disposition clauses, where the real semanticslive in the disposition) are folded into one
placeholder_parsed_clausehelper — byte-identical, but DRY and distinct from the
Effect::unimplementedparse-gap constructor (which forces
description: Some).Faithful-by-intent, no behavior change: the IR snapshot parity tests hold
with zero
_lowered.snapmovement (63 snapshot tests + the full parsersuite green under
-D warnings). locate() verbatim-fragment fallback rate:1/4859 (0.02%) over the 568-card fixture.