test(drawlist): harden ZRDL v1/v2 edge cases and invariants#65
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4890a602c5
ℹ️ 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".
| const size = dv.getUint32(cursor + CMD.SIZE, true); | ||
| assert.equal(size >= CMD.HEADER_SIZE, true, `command ${i} has invalid size`); | ||
| cursor += align4(size); |
There was a problem hiding this comment.
Assert command size alignment when walking command stream
This helper advances with align4(size) but never asserts that size itself is 4-byte aligned, so a malformed command header with an unaligned size can still pass these tests even though the runtime validator rejects such streams (ch.size & 3u is checked in packages/native/vendor/zireael/src/core/zr_drawlist.c). Because this suite is explicitly documenting alignment invariants, it should fail when a command advertises a non-aligned size instead of normalizing it during traversal.
Useful? React with 👍 / 👎.
Summary
docs/guide/layout.mdunder "ZRDL Binary Format Invariants"What changed
packages/core/src/drawlist/__tests__/builder.limits.test.tspackages/core/src/drawlist/__tests__/builder.alignment.test.tspackages/core/src/drawlist/__tests__/builder.string-intern.test.tspackages/core/src/drawlist/__tests__/builder.string-cache.test.tspackages/core/src/drawlist/__tests__/builder.round-trip.test.tspackages/core/src/drawlist/__tests__/builder.reset.test.tsdocs/guide/layout.mdwith alignment, interning, limit, cache, and v1/v2 cursor invariantsNotes
Validation
npm run buildnpm run typechecknode scripts/run-tests.mjs