Ryan capnweb compat#83
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds end-to-end RPC coverage for typegres query-builder usage over two RPC mechanisms (exoeval-evaluated closures and capnweb record/replay closures), plus a capnweb shim that enforces the existing @expose capability surface across the RPC boundary.
Changes:
- Added comprehensive integration tests for “typegres over exoeval RPC” and “typegres over capnweb RPC”, including
@expose-gating scenarios and scalar/hydrate behaviors. - Introduced a capnweb
toRpc/fromRpcshim + in-memory harness to adapt@exposecapability objects to capnweb’s RPC model. - Updated query hydration to preserve the
@exposefield-marker (toolFieldsSymbol) on hydrated instances.
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rpc-exoeval.test.ts | New exoeval RPC end-to-end tests for query-builder composition and @expose gating. |
| src/rpc-capnweb.test.ts | New capnweb RPC end-to-end tests mirroring the exoeval scenarios. |
| src/capnweb/shim.ts | New capnweb shim to wrap/unwrap @expose objects/functions across RPC. |
| src/capnweb/shim.test.ts | Unit + end-to-end tests validating shim behavior and RPC closure replay. |
| src/capnweb/harness.ts | Test-only in-memory capnweb wiring for client/server session pairs. |
| src/builder/query.ts | Preserve toolFieldsSymbol marker during hydrateRows instance construction. |
| package.json | Adds local capnweb dependency via file:packages/capnweb. |
| .gitmodules | Adds packages/capnweb as a git submodule. |
| .gitignore | Stops ignoring all packages/, only ignores packages/exoagent/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+102
| export const toRpc = (value: unknown): unknown => { | ||
| if (value === null || (typeof value !== "object" && typeof value !== "function")) { | ||
| return value; | ||
| } | ||
| if (typeof value === "function") { | ||
| return wrapOutgoingFunction(value as (...args: unknown[]) => unknown); | ||
| } | ||
| if (proxyTargets.has(value)) { | ||
| // Already a wrapper (e.g. a value that round-tripped through fromRpc and back). | ||
| return value; | ||
| } | ||
| if (value instanceof RpcTarget) { | ||
| // Already a native capnweb capability (stub, promise, or hand-written RpcTarget). | ||
| return value; | ||
| } | ||
| if (isThenable(value)) { | ||
| return value.then(toRpc); | ||
| } | ||
| if (Array.isArray(value)) { | ||
| return value.map(toRpc); | ||
| } | ||
| if (isPlainObject(value)) { | ||
| return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, toRpc(v)])); | ||
| } | ||
| if (isRpcSerializableBuiltin(value)) { | ||
| return value; | ||
| } | ||
| return wrapInstance(value); | ||
| }; |
Comment on lines
89
to
92
| "dependencies": { | ||
| "camelcase": "^9.0.0" | ||
| "camelcase": "^9.0.0", | ||
| "capnweb": "file:packages/capnweb" | ||
| } |
Comment on lines
+1
to
+3
| [submodule "packages/capnweb"] | ||
| path = packages/capnweb | ||
| url = https://github.com/ryanrasti/capnweb.git |
| const proto = Object.getPrototypeOf(value) | ||
| return proto === null || proto === Object.prototype | ||
| } | ||
| import { isPlainObject } from '../util' |
Comment on lines
89
to
92
| "dependencies": { | ||
| "camelcase": "^9.0.0" | ||
| "camelcase": "^9.0.0", | ||
| "capnweb": "file:packages/capnweb" | ||
| } |
Comment on lines
+1
to
+3
| [submodule "packages/capnweb"] | ||
| path = packages/capnweb | ||
| url = https://github.com/ryanrasti/capnweb.git |
- Cap'n Web upstream based on cloudflare/capnweb#162, with extra commits to: - (a) unwrap RpcStubs that point back to local objects (getLocalTarget) - (b) replay record/replay closures synchronously instead of eagerly Promisifying them (so fully-local chains run sync end to end), plus allow zero-arg closures - @expose <-> RpcTarget translation exposing only the members we manually @expose, and crucially unwrapping RpcStubs that point to local objects (the record-replay closures) back to their raw builder objects
ryanrasti
force-pushed
the
ryan_capnweb_compat
branch
from
July 14, 2026 22:21
3664982 to
4dc56fc
Compare
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.
No description provided.