Skip to content

feat!: add typed error catalog and structured SDK facade - #76

Closed
google-labs-stitch[bot] wants to merge 4 commits into
mainfrom
stitch/typed-error-catalog-sdk-facade-jm1-1c53d19d-48f5-4629-a9c7-1d4f1252d558
Closed

google-labs-stitch[bot] wants to merge 4 commits into
mainfrom
stitch/typed-error-catalog-sdk-facade-jm1-1c53d19d-48f5-4629-a9c7-1d4f1252d558

Conversation

@google-labs-stitch

Copy link
Copy Markdown
Contributor

Summary

This pull request adds a typed error catalog in Rust, exports structured ErrorDetails diagnostics from WebAssembly, and replaces wildcard re-exports in src/index.ts with TuneletError and an encapsulated Tunelet facade.

Rust error catalog

  • Add ConfigField (Copy, #[non_exhaustive]) with const fn as_str (snake_case) and const fn camel_case (camelCase) for all 34 validated controls.
  • Record rejected values in ConfigProblem::OutOfRange and ConfigProblem::NotFinite, integer bounds in ConfigProblem::IntegerOutOfRange (including 1..=usize::MAX for PrepareConfig::new), and both frequency bounds in ConfigProblem::Unordered.
  • Include voice: Option<usize> (0..=3) on Error::InvalidConfig and EventProblem::Config for four-slot harmony interval arrays (chromatic_intervals and diatonic_intervals).
  • Add MidiProblem (Copy, #[non_exhaustive]) with the rejected u8 byte or field value across MidiEvent::from_bytes, MidiEvent::validate and block event preflight.
  • Add BufferName (Output, Left, Right) to Error::BufferLength across Processor and src/wasm.rs.
  • Record offset on Error::InvalidEvent, offset and frames on EventProblem::OffsetOutsideBlock, and offset and previous on EventProblem::OffsetDecreasing.

WebAssembly and TypeScript SDK

  • Export Tsify ErrorDetails, ConfigProblemKind, EventProblemKind, MidiProblemKind and InputTarget types from src/wasm.rs with camelCase paths and rejected constructor inputs.
  • Map BlockEvents to TimedEvent[] and strip Rust module paths from deserialization errors so tunelet::wasm::BlockEvents and tunelet::config::ProcessorConfig do not appear in declarations or error messages.
  • Emit clean TSDoc comments in pkg/tunelet.d.ts and dist/index.d.ts without raw rustdoc intra-doc link markers.
  • Export TuneletError and an encapsulated #inner Tunelet class from src/index.ts that guards pre-initialization calls, treats repeated free() and [Symbol.dispose]() calls as safe no-ops, rejects post-disposal calls, and rejects mismatched custom Wasm sources in loadTunelet(source) and initSync(module).

Verification

  • cargo fmt --check
  • cargo build --locked --release
  • cargo clippy --locked --lib -- -D warnings
  • cargo clippy --locked --lib --target wasm32-unknown-unknown --features wasm -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps
  • npm run build
  • Verified sample-exact PCM equivalence against HEAD and zero heap allocations after Processor::new across audio, control, feedback, drain, reset and error paths.
  • Verified TuneletError messages, details payloads, clean .d.ts declarations and SDK lifecycle transitions in Node.js.

Automated PR initiated by user @byteland-app via Stitch Loop.

- Add ConfigField with compile-time snake_case and camelCase paths
- Record rejected values, bounds and voice indices in ConfigProblem
- Add MidiProblem and BufferName enums to Error and EventProblem
- Record frame offsets and bounds on timed event preflight errors
- Export Tsify ErrorDetails and map BlockEvents to TimedEvent[]
- Emit clean TSDoc comments in generated TypeScript declarations
- Add TuneletError and an encapsulated Tunelet facade in src/index.ts
- Guard pre-init calls, disposal and mismatched Wasm sources
- Keep the clamp_i32 and ConfigField imports in src/formant.rs.
- Update the harmony_gain rustdoc in src/resynthesis.rs for Wasm.
- Keep the BufferName checks with process_into in src/processor.rs.
- Call Processor::check_block with domain_error in src/wasm.rs.
- Initialize validated Wasm modules asynchronously in src/index.ts.
- Keep the drainMono doc comment from main in src/wasm.rs.
@byteland-app

Copy link
Copy Markdown
Contributor

Closing this PR. At +3,094 lines across 18 files, this is overly invasive and breaks both Rust and TypeScript APIs. In particular, hardcoding 22 internal wasm-bindgen export symbol names in REQUIRED_WASM_EXPORTS is brittle across wasm-bindgen upgrades.

@byteland-app
byteland-app deleted the stitch/typed-error-catalog-sdk-facade-jm1-1c53d19d-48f5-4629-a9c7-1d4f1252d558 branch November 25, 2026 08:05
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Understood — leaving #76 closed with no further changes pushed to this branch, avoiding the breaking Rust/TypeScript error-catalog changes and the hardcoded REQUIRED_WASM_EXPORTS wasm-bindgen symbol list, and deferring to #63 for scoped non-breaking Wasm error formatting and lightweight Tunelet lifecycle guards (alongside #107 for package-boundary JSDoc normalization).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant