Skip to content

Conversation

@rekmarks
Copy link
Member

@rekmarks rekmarks commented Jan 14, 2026

Summary

  • Add kref-presence.ts with makePresenceManager() and convertKrefsToStandins()
  • Add endoify-node.js to kernel-shims for Node.js test environments
  • Split vitest configs for unit vs integration tests
  • Rationalize globalThis.kernel
  • Enable E() calls on vat objects from extension background
  • Expose captp.resolveKref() and captp.krefOf() on globalThis

Test plan

  • Build passes
  • All tests pass (3261 tests)
  • Unit tests for kref-presence
  • Manual browser testing of E() on vat objects

Part 4 of 4 in PR stack for omnium-III
Depends on: #753

🤖 Generated with Claude Code


Note

Enables E()-style calls on vat objects and improves test/runtime setup across packages.

  • Add kref-presence utilities: new makePresenceManager and convertKrefsToStandins; exported from @metamask/kernel-browser-runtime; unit and integration tests added
  • Extension/Omnium integration: background now sets globalThis.kernel to a promise, attaches CapTP PresenceManager on globalThis.captp/omnium (exposes resolveKref/krefOf), pings kernel on action, and greets bootstrap vat after launching default subcluster
  • Kernel facade/RPC tweaks: queueMessage converts kref strings to standins; launchSubcluster handler returns JSON-compatible result with nullable bootstrapResult; tests updated
  • Node test environment: new @metamask/kernel-shims/endoify-node (optional @libp2p/webrtc peer) and packages/tests switched to it; remove old local endoify imports
  • Testing/CI: split Vitest configs into unit vs integration (using endoify-node); add test:integration script; GitHub Actions runs build + integration
  • Misc: coverage thresholds updated; small echo-caplet response tweak; dependency/depcheck and resolutions adjustments

Written by Cursor Bugbot for commit 8b56b6b. This will update automatically on new commits. Configure here.

@rekmarks rekmarks requested a review from a team as a code owner January 14, 2026 22:28
}
}
return arg; // Pass primitive through
});
Copy link

Choose a reason for hiding this comment

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

Nested presences not converted to kref strings in args

Medium Severity

The sendToKernel function only converts top-level presence objects to kref strings, not presences nested within objects or arrays. When calling E(presence).method({ nested: anotherPresence }), the nested presence won't be converted to its kref string before being passed to CapTP. This creates an asymmetry with convertKrefsToStandins on the kernel side, which does recursively convert nested kref strings. The nested presence may be incorrectly serialized by CapTP since it doesn't know about presences created by the presence manager.

Fix in Cursor Fix in Web

@rekmarks rekmarks marked this pull request as draft January 14, 2026 23:26
@rekmarks rekmarks force-pushed the rekm/caplet-implementation branch from 451a6dd to 605f8d9 Compare January 14, 2026 23:45
@rekmarks rekmarks force-pushed the rekm/caplet-implementation branch from 605f8d9 to f08383c Compare January 15, 2026 00:01
@rekmarks rekmarks force-pushed the rekm/caplet-implementation branch from f08383c to 34a1f08 Compare January 15, 2026 06:25
@rekmarks rekmarks force-pushed the rekm/caplet-implementation branch from 34a1f08 to 4caf528 Compare January 15, 2026 21:29
rekmarks and others added 11 commits January 15, 2026 13:47
Set globalThis.kernel in the extension and omnium to the kernel itself. Remove
ping and getKernel methods from background console interface. The kernel
exposes ping().
…ects

Implement slot translation pattern to enable E() (eventual sends) on vat
objects from the extension background. This creates presences from kernel
krefs that forward method calls to kernel.queueMessage() via the existing
CapTP connection.

Key changes:
- Add background-kref.ts with makeBackgroundKref() factory
- Add node-endoify.js to kernel-shims for Node.js environments
- Update kernel-facade to convert kref strings to standins
- Fix launch-subcluster RPC result to use null for JSON compatibility
- Integrate resolveKref/krefOf into omnium background

The new approach uses @endo/marshal with smallcaps format (matching the
kernel) rather than trying to hook into CapTP internal marshalling, which
uses incompatible capdata format.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ntegration

Split the vitest configuration into two separate files to fix issues
with tests running from the repo root:
- vitest.config.ts: Unit tests with mock-endoify
- vitest.integration.config.ts: Integration tests with node-endoify

Add test:integration script to run integration tests separately.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…helpers

- Remove packages/nodejs/src/env/endoify.ts re-export, use @metamask/kernel-shims/node-endoify directly
- Update vitest configs to use kernel-shims for setup files
- Remove inline endoify imports from test files (now handled by vitest setup)
- Fix test helpers to handle SubclusterLaunchResult return type from launchSubcluster()
- Add kernel-shims dependency to kernel-test and nodejs-test-workers packages
- Set coverage thresholds to 0 temporarily

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…e configs

- Fix accidentally broken nodejs vat worker (which broke all tests relying
  on it)
- Rename node-endoify.js to endoify-node.js for consistency
- Update package.json export from ./node-endoify to ./endoify-node
- Update all vitest configs to use the new export path
- Update depcheckrc.yml ignore pattern

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Import and initialize makeBackgroundKref to enable E() calls on vat objects
- Expose captp.resolveKref and captp.krefOf on globalThis for console access
- Refactor startDefaultSubcluster to return the bootstrap vat rootKref
- Add greetBootstrapVat function that automatically calls hello() on the
  bootstrap vat after subcluster launch on startup
- Update global.d.ts with captp type declaration for IDE support

Co-Authored-By: Claude <[email protected]>
- Rename background-kref.ts to kref-presence.ts
- Rename makeBackgroundKref to makePresenceManager
- Rename BackgroundKref type to PresenceManager
- Rename BackgroundKrefOptions to PresenceManagerOptions
- Update all imports and references across affected packages
- Update JSDoc comments to reflect new naming
- All tests pass for kernel-browser-runtime, extension, omnium-gatherum

Co-Authored-By: Claude <[email protected]>
…nvertKrefsToStandins

- Move convertKrefsToStandins from kernel-facade.ts to kref-presence.ts for better organization
- Export convertKrefsToStandins for use by kernel-facade
- Add comprehensive unit tests for convertKrefsToStandins (20 tests covering kref conversion, arrays, objects, primitives)
- Add unit tests for makePresenceManager (3 tests for kref resolution and memoization)
- Add integration test in kernel-facade.test.ts verifying kref conversion in queueMessage

Co-Authored-By: Claude <[email protected]>
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