Skip to content

feat(ocapn): Minimum viable OCapN#2962

Merged
kumavis merged 40 commits into
masterfrom
kumavis/ocapn-mvp-rebase
Sep 18, 2025
Merged

feat(ocapn): Minimum viable OCapN#2962
kumavis merged 40 commits into
masterfrom
kumavis/ocapn-mvp-rebase

Conversation

@kumavis

@kumavis kumavis commented Sep 18, 2025

Copy link
Copy Markdown
Member

This PR is intended to land a work-in-progress implementation of the client, and is not ready to be published.

The implementation is a single vat single process (no comms vat).

Implements Passables
Remote calls + Pipelining
Third Party Handoffs
Eager promise subscription (lazy promise subscription to be explored later)
A tcp-testing-only netlayer (no tor netlayer yet)
This does not yet implement GC messages.

this was mostly built against this test suite https://github.com/ocapn/ocapn-test-suite
which lags behind the spec a bit. I expect dramatic spec changes to come, so I don't mind being behind spec at this point.

There is some implementation weirdness around use of pass-style due to a need for an ImmutableArrayBuffer. This implementation currently still uses mutable Uint8Arrays and thus some homespun passStyleOf checks. The intention is to replace these with exclusively real pass-style before publishing.

This PR replaces #2781 with a rebase on master. See it for previous review and discussion. No other changes.

This is intended to be merged as is but is not yet deemed ready to be published

@kumavis

kumavis commented Sep 18, 2025

Copy link
Copy Markdown
Member Author

see previous PR #2781 for review and discussion

@kumavis
kumavis force-pushed the kumavis/ocapn-mvp-rebase branch from e5123d8 to 5c1c185 Compare September 18, 2025 20:43

@kriskowal kriskowal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I’m reapproving this with light review and some comments that can be addressed now or later given that we want this to grow fast and evolve. We will likely be relying on the rigor of our test suite.

There’s code in here for finalization, which I would like to be sure works somehow.

{ weakValues: gcImports },
);

let lastExportID = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

* Called when we have encountered a new value that needs to be assigned a slot.
*
* @param {any} val
* @returns {CapTPSlot}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment on lines +3 to +20
/**
* @typedef {import('../cryptography.js').OcapnPublicKey} OcapnPublicKey
* @typedef {import('../cryptography.js').OcapnKeyPair} OcapnKeyPair
* @typedef {import('../codecs/components.js').OcapnPublicKeyData} OcapnPublicKeyData
* @typedef {import('../codecs/components.js').OcapnLocation} OcapnLocation
* @typedef {import('../codecs/components.js').OcapnSignature} OcapnSignature
* @typedef {import('./types.js').Session} Session
* @typedef {import('./types.js').Connection} Connection
* @typedef {import('./types.js').Client} Client
* @typedef {import('./types.js').NetLayer} NetLayer
* @typedef {import('./types.js').SelfIdentity} SelfIdentity
* @typedef {import('./types.js').Logger} Logger
* @typedef {import('./types.js').LocationId} LocationId
* @typedef {import('./types.js').PendingSession} PendingSession
* @typedef {import('./types.js').SessionManager} SessionManager
* @typedef {import('./ocapn.js').GrantTracker} GrantTracker
* @typedef {import('./ocapn.js').Ocapn} Ocapn
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can use /** import {} from "" */ notation now, which is more transparent to the language server since it doesn’t create a new type.

@@ -0,0 +1,98 @@
// @ts-check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Elsewhere, we’re moving in the direction of writing all-types files as .ts. This is not a hard line but one we can move incrementally.

* @param {OcapnSignature} sig
* @returns {Uint8Array}
*/
export const ocapNSignatureToBytes = sig => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export const ocapNSignatureToBytes = sig => {
export const ocapnSignatureToBytes = sig => {

* @param {Uint8Array} peerIdTwo
* @returns {Uint8Array}
*/
export const makeSessionId = (peerIdOne, peerIdTwo) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As much as I loathe “id”, I will accept it in general if it’s consistently capitalized like you have here: Id.

@kumavis
kumavis merged commit 5bd7d9d into master Sep 18, 2025
19 checks passed
@kumavis
kumavis deleted the kumavis/ocapn-mvp-rebase branch September 18, 2025 21:14
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