Skip to content

feat(extension): Add distributed object capability programming - #43

Merged
grypez merged 24 commits into
mainfrom
grypez/captp-conformal
Sep 12, 2024
Merged

feat(extension): Add distributed object capability programming#43
grypez merged 24 commits into
mainfrom
grypez/captp-conformal

Conversation

@grypez

@grypezgrypez commented Sep 3, 2024

Copy link
Copy Markdown
Member

Refs: #23

Title technically correct.

> await kernel.capTpCall('whatIsTheGreatFrangooly', [])
< "Crowned with Chaos"

This establishes a CapTP connection using @endo/captp over @ocap/streams between the offscreen document and the (currently singular) iframe. The iframe exposes a bootstrap object with a single method, which is called by the offscreen.

Status

  • unresolved messages are not handled on delete, but they are enumerated and complained about
  • capTp is unit tested by a mock of the above process
  • not unit tested:
    • background.ts
    • offscreen.ts
    • iframe.ts
  • The implementation could use a lot of cleanup.
  • In particular I'm not committed to the current stream multiplexing implementation via StreamPayloadEnvelope.label.
    This ensures separate handling for Command and CapTP messages, which we need, but the current implementation is unlikely the ideal one.
  • the envelope solution is explicit and works well; I don't recommend fixing it

@socket-security

socket-securityBot commented Sep 3, 2024

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@grypez
grypezforce-pushed the grypez/captp-conformal branch from d8c48c4 to 3677520CompareSeptember 3, 2024 15:02
@grypez

Copy link
Copy Markdown
MemberAuthor

@SocketSecurity ignore npm/@endo/captp@4.3.0 npm/@endo/exo@1.5.3 npm/@endo/patterns@1.4.3

We have a close working relationship with the @Endo contributors and can rely on them for defensively correct implementations.

@grypez

Copy link
Copy Markdown
MemberAuthor

@SocketSecurity ignore npm/rimraf@3.0.2

Weexplicitlyrequire rimraf^6.0.1

@grypez
grypezforce-pushed the grypez/captp-conformal branch from 3f638e3 to 918f800CompareSeptember 9, 2024 22:33
@grypez

This comment was marked as resolved.

@grypez
grypezforce-pushed the grypez/captp-conformal branch 2 times, most recently from 822f49f to 4c5788aCompareSeptember 10, 2024 06:50
@grypez

This comment was marked as resolved.

@grypezgrypez changed the title vat connectionsfeat(extension): Add distributed object capability programmingSep 10, 2024
@grypez
grypezforce-pushed the grypez/captp-conformal branch from 4c5788a to 19f16cbCompareSeptember 11, 2024 10:48
@grypez
grypez marked this pull request as ready for review September 11, 2024 17:32

@rekmarksrekmarks 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.

Looks good overall! See inline comments.

Comment threadpackages/extension/src/dev-console.test.ts
Comment threadpackages/extension/src/dev-console.test.ts Outdated
Comment threadpackages/extension/src/dev-console.test.ts Outdated
Comment threadpackages/extension/src/message.ts Outdated
| DataObject[]
| { [key: string]: DataObject };

export enum ExtensionTarget {

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.

Good idea to put this in an enum, but might I suggest MessageTarget instead for the name?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

How about ExtensionMessageTarget?

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.

That'd work, although we're in the extension package, and there is only one kind of message. Also, if we do ExtensionMessageTarget, we should rename MessageId to ExtensionMessageId. Do you see a need to disambiguate it from anything in particular?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I do.

The word Extension in this enum is to clarify that there are a finitely enumerable set of targets to which one can send an ExtensionMessage, and those targets are enumerated by ExtensionMessageTargets. The underlying extension framework responds to the targets 'background' and 'offscreen', so these are extension targets.

MessageId is only used when sending messages to iframes, or in this implementation the iframe. As we approach $n$ iframes, I want to reserve the possibility of targeting a particular vat's iframe using the target key. That may be a faulty reservation. But in any case we don't use MessageId when sending an ExtensionMessage, so we shouldn't rename it to ExtensionMessageId.

Comment threadpackages/extension/src/message.test.ts Outdated
Comment threadpackages/extension/src/shared.test.ts
Comment threadpackages/extension/src/iframe.ts Outdated
Comment threadpackages/extension/src/iframe-manager.ts Outdated
Comment threadpackages/extension/src/iframe-manager.ts Outdated
Comment threadpackages/extension/src/iframe-manager.test.ts

@rekmarksrekmarks 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.

Ship it!

@grypez
grypez merged commit 784c42e into mainSep 12, 2024
@grypez
grypez deleted the grypez/captp-conformal branch September 12, 2024 20:34
@rekmarksrekmarks added the critical path High-priority issues that structure the rest of our work label Sep 13, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

critical pathHigh-priority issues that structure the rest of our work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@grypez@rekmarks