You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ocap-kernel): use E() for kernel service invocation to support remote presences (#872)
## Description
Switches `KernelServiceManager.invokeKernelService()` to use `E()` from
`@endo/eventual-send` instead of direct property access. This enables
CapTP remote presences (whose methods aren't enumerable) to be
registered as kernel service objects — a separate process can now create
an exo, register it on the kernel over CapTP, and have vats invoke
methods on it seamlessly.
## Changes
- **`KernelServiceManager.ts`** — Replace direct `service[method]()`
invocation with `E(service)[method]()`, removing the manual
method-exists check (E() handles this natively)
- **`kernel-facet.ts`** — Add `registerKernelServiceObject` to the
kernel facet so it's callable over CapTP
- **`captp-service-client.js`** (new) — Worker thread that sets up a
CapTP connection to the kernel, creates a test exo, and registers it as
a kernel service
- **`captp-service-vat.ts`** (new) — Minimal vat that calls
`E(testService).doSomething(3, 4)` and returns the result
- **`captp-service.test.ts`** (new) — E2E test proving the full
round-trip: worker registers exo over CapTP → vat invokes method → call
traverses CapTP → result returns
- **`service.test.ts`** — Fix assertion for error message format change
(exact match → regex)
- **`captp.integration.test.ts`** — Add `registerKernelServiceObject` to
mock kernel (required by `makeKernelFacet`)
## Testing
The core behavior change is unit-tested in
`KernelServiceManager.test.ts` (updated to cover both local exo and
remote presence scenarios). The new e2e test in
`packages/nodejs/test/e2e/captp-service.test.ts` validates the full
CapTP round-trip: a real kernel, a worker thread acting as a CapTP
client, and a bundled vat that invokes the remotely-registered service.
The existing `kernel-test` service test and `kernel-browser-runtime`
integration tests continue to pass with the updated assertions.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes the kernel’s service invocation path to use `E()`
(asynchronous eventual-send) and exposes service registration over the
kernel facet, which can affect error propagation and method resolution
for all kernel services.
>
> **Overview**
> **Kernel services can now be implemented as remote CapTP presences.**
`KernelServiceManager.invokeKernelService()` switches from direct
`service[method](...)` calls to `E(service)[method](...)`, enabling
proxy/presence objects whose methods aren’t enumerable.
>
> The kernel facet now exposes `registerKernelServiceObject`, and
tests/mocks are updated accordingly (including looser assertions around
error formatting under eventual-send/SES).
>
> Adds a Node.js e2e that spawns a worker CapTP client to register a
service exo over CapTP and verifies a vat can call it end-to-end;
updates dependencies (`@endo/eventual-send` in `ocap-kernel`,
`@endo/captp` for nodejs tests).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e9cd1c0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
0 commit comments