Skip to content

feat(web_core): implement Stage 3 Sauce-TS bidirectional RPC and @index function - #2264

Open
gspencergoog wants to merge 7 commits into
v1_0_conformance_tsfrom
v1_0_sauce_ts
Open

feat(web_core): implement Stage 3 Sauce-TS bidirectional RPC and @index function#2264
gspencergoog wants to merge 7 commits into
v1_0_conformance_tsfrom
v1_0_sauce_ts

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

This pull request implements Stage 3 (Sauce-TS) deliverables for the Web Core renderer package (typescript/web_core). It introduces the RpcHandler engine for handling bidirectional remote function calls between the client renderer and server agent, enforces execution boundaries (callableFrom) and user activation constraints (requiresUserActivation), exports structured RPC error codes and exceptions (RpcError, RpcErrorCode), registers the built-in @index function with array index resolution, and cleans up legacy v0_9 re-export stubs.


Stack Context

  • 🥞 PR 1 (Base of Stack): #2257 (v1_0_firing_ts) — Core v1.0 Zod schemas, version adapters, callableFrom metadata, composition constraints, and data model path resolution.
  • 🥞 PR 2 (This PR): #2264 (v1_0_sauce_ts) — Bidirectional RPC execution (callRendererFunction, callAgentFunction), dynamic ValidationResult handling, multi-catalog resolution engine, and @index loop function.

Changes

1. Bidirectional RPC Engine (typescript/web_core/src/v1_0/rpc/)

  • Implemented RpcHandler in src/v1_0/rpc/rpc-handler.ts to process incoming callRendererFunction messages and return rendererFunctionResponse payloads.
  • Implemented outbound callAgentFunction request tracking and response resolution via incoming agentFunctionResponse messages matching functionCallId.
  • Created structured RpcErrorCode enum (INVALID_FUNCTION_CALL, EXECUTION_ERROR, TIMEOUT, CANCELLED, DISPOSED, DUPLICATE, NO_LISTENER) and RpcError exception class with prototype restoration.
  • Configured extensible RpcHandlerOptions options bag with backward-compatible array constructor overload.
  • Added isDisposed lifecycle guards failing fast post-disposal, and globalThis.crypto.randomUUID() feature checks with non-secure context fallbacks.
  • Enforced catalog execution boundary checks (callableFrom: rendererOnly, agentOnly, rendererOrAgent) and user activation context constraints (requiresUserActivation).

2. Basic Catalog @index Function & Property Merging

  • Centralized IndexApi in src/v0_9/basic_catalog/functions/basic_functions_api.ts with z.coerce.number().optional() schema validation.
  • Implemented IndexImplementation with strict /^\d+$/ path segment regex matching to resolve loop indices for nested child contexts, supporting optional offset configuration.
  • Updated processUpdateComponentsOp in src/processing/message-processor.ts to merge existing properties with incoming properties on partial updates.

3. Public Export & Modular Cleanup (typescript/web_core/src/v1_0/)

  • Re-exported RpcHandler, OutboundMessageListener, RpcHandlerOptions, RpcErrorCode, and RpcError from src/v1_0/index.ts.
  • Removed redundant src/v0_9/ stub files across catalog, rendering, reactivity, and state directories.

Impact & Risks

  • Impact: Enables full bidirectional RPC execution between renderer components and server agents while supporting context-aware loop index functions in component trees.
  • Risks: Low. Fully verified with dedicated RPC test suites and zero regression across existing protocol versions.

Testing

  • Unit Tests: Ran npm run test in typescript/web_core295/295 passing tests (100%).
  • Conformance Suite: Executed node tests/conformance/conformance_test.mjs216/216 passing test vectors (100%).
  • Static Analysis & Linting: Verified clean compilation with yarn build and zero ESLint errors with yarn lint.

Loading
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