wai: reader limits for the extension formats' durations #258
Loading…
Reference in a new issue
No description provided.
Delete branch "wai/extension-duration-limits"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #256, which is stacked on #255. This branch contains both PRs' commits unchanged. Until they merge, the diff here includes them; after they merge, this needs no rebase.
This PR closes the known gap #256 recorded: nothing bounded the durations that the extension formats declare.
Why
Score, haptic, audio scene, splat4d and film contracts each declare a length, and rendering allocates memory in proportion to it:
durationsamples, outrightduration × 2bytes per channelNothing bounded these declarations, so a contract a few bytes long could ask a renderer for unbounded memory.
The limits
Each extension's §2.1 now has a reader limit, shared with SPEC §2 through the always-on module
wai::limits:duration × channelsdurationn_frames/frames/ the shots' frames togetherA reader may refuse a contract past its limit (
duration_too_long). It refuses when it reads the contract, before rendering anything.Film ticks
A film frame's tick is
start_tick + f × ticks_per_frame. That computation wrapped in release builds and panicked in debug builds. Now:Film::frame_ticksaturates instead of wrapping;Reel::frame_tickuses checked arithmetic.Checked
The new test.
tests/extension_duration_limits.rsrewrites a committed vector of each format:Falsified. With the readers as they were, all three tests fail.
Unchanged. The world, audio, haptic, splat4d, score and film corpora verify unchanged, and the 275 lib tests with the container features pass.
Guards. All checks are clean: tests-in-CI, spec refs, section refs, workflow concurrency, lockfiles, vanity metrics, comparative prose, public names.
Remaining gap, now recorded in SECURITY.md: replaying a world to a far tick still costs time in proportion to the tick. Memory is bounded; time is not.
🤖 Generated with Claude Code