Skip to content

feat(ts): protocol RPC shape — IR_HASH, params, error unions, async - #5

Merged
Kinflou merged 1 commit into
mainfrom
feat/protocol-rpc-shape
Sep 2, 2026
Merged

feat(ts): protocol RPC shape — IR_HASH, params, error unions, async#5
Kinflou merged 1 commit into
mainfrom
feat/protocol-rpc-shape

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 2, 2026

Copy link
Copy Markdown
Member

Moves the TypeScript code generator past bare method stubs toward the Rust generator's surface. No TS runtime to link against yet, so this is the typed layer only:

  • export const IR_HASH (bigint) per file with a protocol — the same canonical schema_ir_hash digest the Rust side emits (the protocol conformance fixture's value now matches the Rust golden's exactly).
  • error declarations → export interface.
  • <Proto><Fn>Params interface per function with arguments; the method takes one params object.
  • Discriminated-union error types from each ! — per function and a per-protocol union — every arm { code: <ordinal>; name; data }, keyed by the schema-global error ordinal; @throws in the method JSDoc. A ! on a one-way call is dropped.
  • Every method returns Promise<T>; one-way / -> ()Promise<void>.
  • u128/i128/s128bigint (were leaking through unmapped); Unitvoid.

Goldens re-blessed in a companion generation PR. Next increments: a TS runtime package, then <Proto>Client / dispatcher, then lib mode.

The TypeScript `code` generator moves past bare method stubs toward the
Rust generator's surface (no runtime to link against yet, so this is the
typed layer only):

  - `export const IR_HASH` (bigint) per file with a protocol — the same
    canonical `schema_ir_hash` digest the Rust side emits, so a TS peer
    and a Rust peer agree.
  - `error` declarations -> `export interface`.
  - `<Proto><Fn>Params` interface per function that takes arguments; the
    method takes one `params` object.
  - Discriminated-union error types from each `!` — per function
    (`<Proto><Fn>Error`) and a per-protocol `<Proto>Error` — every arm
    `{ code: <ordinal>; name; data }`, keyed by the schema-global error
    ordinal. `@throws` in the method's JSDoc. A `!` on a one-way call is
    dropped.
  - Every method returns `Promise<T>`; a one-way / `-> ()` call is
    `Promise<void>`.
  - `u128` / `i128` / `s128` -> `bigint` (were leaking through unmapped);
    `KindValue::Unit` -> `void`.
@Kinflou
Kinflou merged commit 86c2590 into main Sep 2, 2026
2 checks passed
@Kinflou
Kinflou deleted the feat/protocol-rpc-shape branch September 2, 2026 08:30
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