decisions DECIDED

255. Each socket is its own capability, and a reply carries it

Raised for milestone 649 (every client of a network stack shares its socket numbers).

Two rulings, both calef's, both 2026-10-07 (UTC). The first is the shape: each socket is its own capability. Building it found that a reply could not carry a capability, which was a fork on the system call surface. The second ruling took option A, a new Reply method that carries one. This section records both, the method's semantics (§10 (process model: capability-based, microkernel) requires them written here), and the socket_protocol contract that two programs now agree on.

The rulings

The shape, recorded by the maintainer session on PR #1798 at 15:04Z, superseding calef's per-caller-windows ruling of about 03:50Z the same day:

milestone 649's fix makes each socket its own capability. On open, the network stack mints a badged endpoint for that one socket (milestone 606's badge model); every later call (send, receive, attach a page, close) is made on that capability; the stack identifies the socket by the kernel-stamped badge, never by a client-supplied sid, so socket_protocol drops the sid argument; close unbinds the badge; a socket can be handed to another program by passing the capability. This is §27's directory-capability model applied to sockets.

calef's words: "Naming socks as capabilities seems right. Can we do that?", then "Yes".

The delivery fork, recorded on PR #1817 at 15:23Z:

§255 delivery fork ruled (calef, 2026-10-07 UTC): option A. Add a new Reply method (provisionally REPLY_CAP) that carries one capability, so the stack hands each socket capability to its client in the CALL reply and delivery never blocks the stack.

REPLY_CAPABILITY: a reply that carries one capability

invoke(reply, REPLY_CAPABILITY, r0, r1, capability_slot), method 1 on a Reply capability. Name ratified by calef on 2026-10-07 (UTC), recorded on #1817, to match SEND_CAPABILITY, RECEIVE_CAPABILITY and NO_CAPABILITY in design/naming/capability-spelling-worklist.md; the method number is provisional. The runtime pair is reply_capability and call_receiving. abi::reply::REPLY_CAPABILITY carries the same contract at the definition.

The socket_protocol contract

Slot pressure, counted from what each client holds: a client spends one slot of its 64 per open socket, and nothing per page it attaches, because SEND_CAP sends a copy and the client keeps its own. The std::net PAL also keeps one frame per id that has carried bytes, so a std program holding its six sockets spends twelve slots. The stack spends one slot per socket for the instant between minting and answering.

Refused

Prior art

Servers that keep windows for many clients

Also ruled on #1798 the same day, and recorded there by the GLM lane: per-caller scoping becomes a written rule for every server that keeps windows for many clients, and milestone 649's lane audits the rest, system_log's reader windows first.

The rule itself has its own section since PR #1798's merge: §256 (a server that keeps windows for many clients scopes each by the caller's badge), which also holds the rest of the audit.