Skip to content

runtime: native-payload transport core and link tokens (net P0) - #12064

Draft
proggeramlug wants to merge 1 commit into
mainfrom
net-transport-p0
Draft

proggeramlug wants to merge 1 commit into
mainfrom
net-transport-p0

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Refs #11919, Refs #11196

Phase P0 of the net transport ownership design. It adds runtime and perry-ffi support for native payloads that own a socket transport, so perry-ext-net can drop its id-keyed tables in phase A.

  • TransportCore sits first in TransportPayload<E>.
  • Link tokens: each token packs route, op and the cell address. A completion goes from its token to link_event_owner, then to the core, then through a generational handle check. There is no id map.
  • Liveness: each completion the driver still owes holds one link_ref, so a payload holding a driver handle cannot be swept until the handle's Closed has been dispatched. Drop never reaches the driver.
  • close: it hands the handle to the driver. A stale Closed arriving after a reopen delivers only its close event and its unref.
  • C ABI: js_perry_payload_* and js_perry_net_link_*, with a layout digest that covers the opaque core block (39 words; 48 on Windows). The net ABI version is now 3.
  • Id-routed subsystems keep their maps until they convert in phases A–C.

Tests:

  • Runtime: 5099 passed, 0 failed (8 new). Codegen: 2545 passed, 0 failed.
  • Witnesses N1, N5, N6, N7, N10 and N11, plus the layout digest check. Each one's sabotage turns it red.

Programs, n=3: hello, tsc and Zod produce identical output on both arms. Instructions are within +0.11% / −0.05%, and RSS is within ±1.5 MB.

Not covered: the Windows paths are written but were not compiled on any host. A compile-time size assert guards the core block size.

…d the payload C ABI (#11919 net P0)

NET-TRANSPORT-DESIGN prerequisite P0. A link-routed socket keeps its turnloop
state in a TransportCore at offset 0 of its payload (TransportPayload<E>);
tokens carry route|op|cell, dispatch goes cell -> link_event_owner -> core with
no map. Each terminal completion the driver owes (handle Closed, resolve,
deadline) holds one link_ref, so a payload naming a live descriptor is never
swept and Drop only frees memory. close moves the handle into the driver close;
a completion mutates the core only on a generational handle match, so a stale
Closed after reopen delivers its close once and touches nothing else. Teardown
discards link completions. Id routes keep their maps (transitional fork).

perry-ffi gains native_payload (PayloadFamily descriptor, alloc/alloc_closed/
payload_mut/close/attach/lifecycle/owner_link/link_ref/unref/link_event_owner/
js_state, prototype builder) over native_payload_abi.rs, and the link_* net
surface with TransportCore as an opaque 39-word block folded into the net ABI
digest (version 3). Witnesses N1, N5, N6, N7, N10, N11 and the digest, each
with a sabotage that turns it red.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant