Layout engine polish: sparse-child fix, exhaustive edge tests, invariants docs#63
Merged
Conversation
Guard stack child constraint probes against non-VNode entries and skip sparse children in non-constraint measure loops. This prevents row/column measurement from throwing when children arrays contain undefined holes and adds a regression case in layout.edgecases.
Add deterministic layout suites for flex distribution, percentage sizing, auto sizing, margin interactions, aspect ratio, zero/empty edges, stability signatures, measure cache behavior, and hit-test clip boundaries.
Document int32/clamping rules, two-phase measure/layout flow, flex allocation invariants, percentage resolution order, margin semantics, and aspect-ratio precedence to match current engine behavior.
Add deterministic cases for single-flex remainder capture, zero-total-flex over-subscription clamps, fractional 0.5/1.5 allocation, and zero-space-after-gap collapse behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcc4f69271
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Use non-empty child counts for stack gap totals, justify start offsets, and justify extra-gap boundary math in row/column layout+measure constraint paths. Add regression coverage for sparse children with justify and with flex/percent constraint passes.
CI/docs/codeql jobs failed before build/test because actions/checkout recursive submodule clone of vendor/zireael could not authenticate in Actions. These workflows do not require submodule materialization to run guardrails/build/tests/docs/codeql, so use non-recursive checkout.
Fix lint failures in CI by formatting newly added layout test suites and normalizing import ordering.
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 performs a layout-engine polish pass focused on audit hardening and deterministic coverage.
What changed
Fixed a real stack measurement crash path when row/column children arrays contain sparse entries (
undefinedholes).VNodeinputs.layout.edgecases.test.ts.Added exhaustive deterministic layout tests across required audit areas:
layout.flex-distribution.test.ts(row/column flex distribution, gaps, min/max, remainder behavior)layout.percentage.test.ts(0%/100%/150%, nested %, cross-axis %, percent+flex ordering)layout.auto-sizing.test.ts(autosizing interactions with text/box/stack/flex)layout.margin.test.ts(negative margins, root margins, spacing key resolution, margin+padding)layout.aspect-ratio.test.ts(width/height derivation, precedence, min/max, flex context)layout.zero-edge.test.ts(empty stacks, zero-size viewports, empty text, deep nesting, single-child equivalence)layout.stability-signature.test.ts(layout-signature relevance and exclusions)layout.measure-cache.test.ts(cache hit/miss behavior by vnode identity/axis/constraints)layout.hit-test-edge.test.ts(nested clip intersections and boundary semantics)Updated documentation:
Layout Invariantstodocs/guide/layout.mdcovering coordinate/clamp rules, two-phase measure/layout, flex allocation invariants, percentage resolution order, margin semantics, and aspect-ratio precedence.Why
Validation
npm run buildnpm run typechecknode scripts/run-tests.mjsAll passed locally.