Skip to content

feat(codegen): ts-rs pilot + RPC output-validation drift guard#513

Open
beruro wants to merge 1 commit into
developfrom
feat/ts-rs-codegen
Open

feat(codegen): ts-rs pilot + RPC output-validation drift guard#513
beruro wants to merge 1 commit into
developfrom
feat/ts-rs-codegen

Conversation

@beruro

@beruro beruro commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

First slice of a batched split of a large local working tree. Introduces ts-rs codegen (feature-gated, zero production impact) and hardens the typed-invoke output validation into a drift guard — the P0 "cross-end contract drift" mitigation.

  • ts-rs optional dep on transport + session-persistence; .cargo/config.toml sets TS_RS_LARGE_INT=number so i64/u64 emit number (matches the existing hand-written Zod).
  • #[derive(TS)] on the transport events + CacheStats; transport events' serde aligned to camelCase and both adapters serialize the structs directly (wire == generated type).
  • invoke.ts: off/warn/throw output-validation modes + __orgiiRpcOutputDrift observability; default preserves dev-warn / prod-off. Unit tests added.
  • Generated bindings under crates/*/bindings/.

Notes

  • Feature-gated: normal builds do not link ts-rs (verified cargo check -p transport).
  • Based on latest develop.

Test plan

  • cargo test -p transport --features ts-rs (regenerates bindings; 9 tests pass)
  • cargo check -p transport (feature off — ts-rs not linked)
  • pnpm exec vitest run src/api/tauri/rpc (35 tests incl. new outputValidation)

- ts-rs (optional, feature-gated) on transport + session-persistence;
  .cargo/config.toml sets TS_RS_LARGE_INT=number so i64/u64 emit `number`
  matching the existing hand-written Zod contract. Zero production impact
  (feature off by default; verified cargo check -p transport builds clean).
- derive TS on AgentEvent/TextChunk/ToolEvent/ToolEventType + CacheStats;
  align transport event serde to camelCase and serialize structs directly
  in both adapters so the emitted wire == the generated TS type.
- invoke.ts: configurable output-validation mode (off/warn/throw) + drift
  ring buffer (window.__orgiiRpcOutputDrift); default preserves dev-warn /
  prod-off; adds unit tests.
- generated bindings committed under crates/*/bindings/.
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