Engine: typed-array path for rule configs (Fourier lab skips ~3 MB of JSON at 50k) - #17
Merged
Merged
Conversation
Engine::update_rule_config_with_path(cfg, xy: &[f32], pen: &[u8]) takes the path as zero-copy typed-array views (JS passes a Float32Array of interleaved x/y and a Uint8Array of pen flags) and only the scalar fields as JSON. Backed by a generic Rule::apply_path hook (default: unsupported) that the Fourier rule implements with a shape check; the erased layer gains set_config_with_path (atomic) and config_json (the typed config serialized on demand, so rule_config() can never be stale). The lab packs its path with packPath() and uses the new call — at 50k epicycles that removes ~3 MB of JSON per push. Tests: Rust +3 native (apply_path, erased accept/reject), +2 browser (typed path round-trip incl. rule_config(), shape/rule errors); web +1 (packPath) and the lab tests now assert on the typed-array call. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Adds
Engine::update_rule_config_with_path(cfg, xy: Float32Array, pen: Uint8Array): the bulk path crosses the WASM boundary as zero-copy typed-array views while only scalar fields go through JSON. GenericRule::apply_pathhook (default unsupported; Fourier implements it with a shape check),set_config_with_path(atomic) andconfig_json(on-demand serialization, sorule_config()reflects typed-array pushes) on the erased layer,packPath()+LabApi.setRuleConfigWithPath()on the web side. Tests on all layers.