Replace DocLayout with validated LayoutPlan for total coverage#128
Merged
Replace DocLayout with validated LayoutPlan for total coverage#128
Conversation
Introduces eure_document::plan with: - Form enum for the 6 grammar patterns + Flatten - ArrayForm enum (Inline, PerElement, PerElementIndexed) orthogonal to Form - LayoutPlan with total forms map over reachable NodeIds - PlanBuilder that rejects incompatible assignments up-front via typed PlanError variants instead of silent fallbacks - auto/sectioned/flat policy presets - Coverage and duplicate-emission checks in build() This coexists with the existing DocLayout for now; callers will migrate in follow-up commits. https://claude.ai/code/session_01TP4JqaAMFLYoMD5wzHESAs
…ensions, make check green - PlanBuilder::build() fill_defaults walk now threads allow_sections top-down so Section is never auto-assigned inside build_items bodies (fixes debug_assert!(inner.sections.is_empty()) on case_schema tests) - ArrayForm::Inline emission now calls emit_extensions_only so \$optional/ \$variant extensions on array nodes are emitted as path-prefixed bindings (fixes generated_case_schema_enforces_exclusive_json_fixture_shapes) - Remove unused _seg parameter from emit_array_child to satisfy clippy - Regenerate test-suite-case.schema.eure with new Section-based layout - Makefile eure-check: pass --offline to eure binary and run specific targets to avoid unreachable eure.dev network fetch in offline env https://claude.ai/code/session_01TP4JqaAMFLYoMD5wzHESAs
Merges main (current-index [^], Zed extension, Rust codegen tab) and
replaces the old best-effort DocLayout with a total, validated LayoutPlan
that owns the document and assigns explicit Form/ArrayForm per node.
Key changes:
- LayoutPlan: context-aware auto-form with Section/Binding/Inline/Flatten
- ArrayForm: PerElement/PerElementIndexed orthogonal to Form
- ArrayIndexKind enum: Specific(usize)/Push/Current replaces Option<usize>
- PlanError: typed thiserror enum; ScenarioError::LayoutPlan(PlanError)
- check_form_compat: *ValueBlock excludes Map/PartialMap (primitives only)
- check_array_form_compat: per-element check_form_compat
- OrderExtensionChild: typed error when ordering extension children
- ArrayFormReason::ElementIncompatibleForm { element, kind }
- emit_extensions_only: propagates allow_sections correctly
- build_items: uses allow_sections=false to enforce section context rule
- New tests: 6 additional cases covering the above invariants
- Delete layout.rs (old DocLayout)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
This PR replaces the best-effort
DocLayoutprojection system with a newLayoutPlanthat provides total, verified coverage of all reachable document nodes. The new system eliminates silent fallbacks and makes all failure cases explicit through typedPlanErrorvariants.Key Changes
Removed
crates/eure-document/src/layout.rs: The oldDocLayout,LayoutStyle, andproject_with_layoutare deleted entirely.Added
crates/eure-document/src/plan/module with three submodules:plan.rs: CoreLayoutPlanandPlanBuilderwith explicit form assignment and validationplan/emit.rs: Emission logic that converts a validated plan toSourceDocumentplan/traverse.rs: Reachable-node traversal helpersNew seven-variant form taxonomy (
Formenum):Inline:path = valueBindingBlock:path { ... }BindingValueBlock:path { = value ... }Section:@ pathwith itemsSectionBlock:@ path { ... }SectionValueBlock:@ path { = value ... }Flatten: Hoist children without self-emissionOrthogonal array handling (
ArrayFormenum):Inline: Single bindingpath = [...]PerElement(Form): Per-element with[]markerPerElementIndexed(Form): Per-element with explicit[i]indicesExplicit validation:
check_form_compat()andcheck_array_form_compat()validate form assignments against node kindsdry_walk_validate()performs structural validation before emissionPlanErrorvariants (no silent fallbacks)Updated schema integration (
eure-schema):materialize_layout_plan()replacesmaterialize_doc_layout()withResult<LayoutPlan, PlanError>LayoutStrategynow aliasesForminstead ofLayoutStyleUpdated test suite and CLI:
LayoutPlanAPIsection-blockinstead ofnested, etc.)PlanErrorin scenariosNotable Implementation Details
PlanBuilderAPI is fluent:set_form(),set_array_form(),order()all returnResult<&mut Self, PlanError>for chaining.dry_walk_validate) and real emission (emit), both using the same control flow to ensure validation mirrors what emission produces.$variantat the top of blocks.https://claude.ai/code/session_01TP4JqaAMFLYoMD5wzHESAs