feat(ocap-kernel): reference-marker sigil at queueMessage RPC boundary - #984
Open
FUDCo wants to merge 2 commits into
Open
feat(ocap-kernel): reference-marker sigil at queueMessage RPC boundary#984FUDCo wants to merge 2 commits into
FUDCo wants to merge 2 commits into
Conversation
JSON has no native way to express an ocap reference, so the queueMessage RPC boundary — which accepts args as plain JSON — has no way to name a live kernel object as a call argument. That leaves external callers (plugin code speaking JSON over the daemon socket, CLI users typing message sends at a terminal, test harnesses composing RPC calls) without a way to invoke methods that take a reference argument. This introduces a compact sigil convention at the queueMessage handler: anywhere in the args tree, a string of the form `@@NAME` (where NAME is one or more alphanumeric characters) is interpreted as a reference marker naming the kernel object with that reference. The handler walks the parsed args, replaces each marker with a `kslot(NAME)` standin, and hands the transformed args to `kernel.queueMessage` as usual. `kser` sees a real remotable and encodes it as a slot in the resulting CapData. NAME must currently be a well-formed kref (`ko\d+` or `kp\d+`); a future registry mapping symbolic names to krefs could accept richer NAMEs while preserving the sigil syntax. Internal callers of `Kernel.queueMessage` never traffic in markers and are unaffected — the walk lives strictly at the RPC boundary. Caveat: a legitimate string argument that begins with `@@` followed by alphanumerics will be misinterpreted as a reference marker. Callers that need to send such a literal string must wrap it inside an object so the sigil isn't the whole string value. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
FUDCo
marked this pull request as draft
July 28, 2026 22:14
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
FUDCo
marked this pull request as ready for review
July 28, 2026 23:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@@NAMEstring-sigil convention at thequeueMessageRPC boundary so external JSON-RPC callers can pass live kernel object references as method arguments.kslot(NAME)standin, then hands the transformed args tokernel.queueMessage.ksersees a real remotable and encodes it as a slot in the dispatched CapData.Kernel.ts,kernel-marshal.ts,KernelQueue.ts, or any other internal path. The walk lives strictly at the RPC boundary; internal callers ofKernel.queueMessagenever see markers.Why
JSON has no native way to express an ocap reference. Anyone speaking JSON-RPC to
queueMessage— plugin code over the daemon socket, users typing message sends at a terminal, test harnesses composing RPC calls — has been unable to invoke methods whose arguments are references. This gap surfaced concretely in the orchestration demo when the LLM producer needed to pass a receive-shipment endpoint (obtained from a prior call) as an argument to a later service call, but it's a general limitation of the queueMessage RPC surface.Design
NAMEmust be alphanumeric ([A-Za-z0-9]+), which fits current krefs (ko\d+/kp\d+) and leaves room for a future registry mapping symbolic names to krefs without changing the sigil syntax.Caveat: a legitimate string arg that begins with
@@followed by alphanumerics will be misinterpreted as a reference marker. Callers needing to send such a literal string must wrap it inside an object so the sigil isn't the whole string value. Judged an acceptable trade for the ergonomics of a compact CLI-friendly notation.Test plan
yarn workspace @metamask/ocap-kernel test:dev:quiet— all tests pass, including new coverage for the sigil expansion (top-level, nested-in-array, nested-in-record, pass-through of non-sigil strings, rejection of bare@@, rejection of non-alphanumeric NAME, rejection of malformed kref).yarn workspace @metamask/ocap-kernel lint— clean.@@koNstrings on the wire and observes live remotables arriving at receiving vats).🤖 Generated with Claude Code
Note
Low Risk
Scoped to the RPC adapter with validation on malformed krefs; the main caveat is accidental expansion of literal
@@+ alphanumeric strings used as whole argument values.Overview
Adds
@@NAMEreference markers on thequeueMessageJSON-RPC path so external callers can pass live kernel object refs in message args without building remotables in-process.Before forwarding to
kernel.queueMessage, the handler recursively walks the parsed args and replaces whole strings matching@@+ alphanumericNAMEwithkslotstandins (afterinsistKRef), sokseremits real CapData slots. Nested arrays and plain objects are supported; internalKernel.queueMessagecallers are unchanged.Malformed krefs fail before the kernel is invoked. Literal strings that look like markers (e.g.
@@ko7as a full arg value) are expanded—callers must structure those literals to avoid the sigil. Changelog and unit tests cover expansion, pass-through, and rejection cases.Reviewed by Cursor Bugbot for commit 02852a4. Bugbot is set up for automated code reviews on this repo. Configure here.