Skip to content

Ryan capnweb compat#83

Merged
ryanrasti merged 1 commit into
mainfrom
ryan_capnweb_compat
Jul 14, 2026
Merged

Ryan capnweb compat#83
ryanrasti merged 1 commit into
mainfrom
ryan_capnweb_compat

Conversation

@ryanrasti

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/fromRpc shim + in-memory harness to adapt @expose capability objects to capnweb’s RPC model.
  • Updated query hydration to preserve the @expose field-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 thread src/capnweb/shim.ts
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 thread package.json
Comment on lines 89 to 92
"dependencies": {
"camelcase": "^9.0.0"
"camelcase": "^9.0.0",
"capnweb": "file:packages/capnweb"
}
Comment thread .gitmodules
Comment on lines +1 to +3
[submodule "packages/capnweb"]
path = packages/capnweb
url = https://github.com/ryanrasti/capnweb.git

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 3 comments.

Comment thread src/exoeval/expr.ts Outdated
const proto = Object.getPrototypeOf(value)
return proto === null || proto === Object.prototype
}
import { isPlainObject } from '../util'
Comment thread package.json
Comment on lines 89 to 92
"dependencies": {
"camelcase": "^9.0.0"
"camelcase": "^9.0.0",
"capnweb": "file:packages/capnweb"
}
Comment thread .gitmodules
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
ryanrasti force-pushed the ryan_capnweb_compat branch from 3664982 to 4dc56fc Compare July 14, 2026 22:21
@ryanrasti
ryanrasti merged commit 30848e8 into main Jul 14, 2026
3 checks passed
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.

2 participants