os: std/network addresses and network interfaces (OS slice 5) #129

Open
opened 2026-10-05 21:07:23 +00:00 by orion · 9 comments
Collaborator

Goal

Slice 5 of docs/design/OS.md section 10: std/os answers which network interfaces the machine has, with their addresses, status, kind and traffic (NetworkInterface, InterfaceAddress, InterfaceStatus, InterfaceKind, InterfaceTraffic, section 5.5), and the address values they are made of exist as pure types. Windows, Linux and macOS; FreeBSD and the browser answer OsError.Unsupported until slice 7, like the other slices.

Source

What changed since OS.md was written

The design proposed a new pure std/network for Ipv4Address, Ipv6Address, IpAddress, MacAddress and Subnet. URI.md section 8a decided otherwise and it is built: the pure package is std/ip (three of the five values, with parsers, RFC 5952 display and tests, and SocketAddress), and std/network is the socket package that re-exports it. What this slice adds is Subnet, MacAddress and the interfaces. See the decision comment below.

Epic: why, and the steps

The slice spans two pure types, three runtime files (windows.c, posix.c, bsd.c), three TorbScript layers and two reading natives per system: more than one PR of one or two commits. Per the definition of ready it is an epic; this issue carries no ready label and each step is filed when it starts next.

  • Step 1: Subnet in std/ip, MacAddress in std/os, an audit of the IPv6 parser tests, the OS.md records corrected (#528)
  • Step 2a (#539): the types, the pure parsers, InterfaceAddress.subnet() and NetworkInterface.all on Linux
  • Step 2b (#569): NetworkInterface.all on macOS (the AF_LINK entry of Posix.interfaceEntries, std/os/src/macos/network.trb)
  • Step 2c (filed when 2b lands): NetworkInterface.all on Windows (GetAdaptersAddresses)
  • Step 3: InterfaceTraffic (Subtract), NetworkInterface.traffic (Linux /proc/net/dev parser, Windows GetIfEntry2, Bsd.linkTraffic), NetworkInterface.throughput (two readings and a sleep, a Task), docs/standard-library/os.md, then OS.md slice 5 marked done with a "How slice 5 landed" note

Acceptance criteria (of the epic)

  • Steps 1 to 3 landed and their issues closed
  • NetworkInterface.all() on Windows, Linux and macOS answers the loopback interface with Loopback kind and a loopback address, and every address's subnet().contains(address) holds
  • OS.md slice 5 marked done, with what differs from the sections above
  • docs/standard-library/os.md and ip.md document the whole network API

Seed impact

None for any step: no syntax change, no new driver flag, no std name the compiler looks up by string; the natives of steps 2 and 3 are declared in natives.trb like the processors' and volumes'. The compiler does not import NetworkInterface.

Dependencies

  • #126 (slice 2) is closed. Slices 3 and 4 (#127, #128) share only lib.trb, natives.trb and os.md with this one; a rebase settles that.
## Goal Slice 5 of `docs/design/OS.md` section 10: `std/os` answers which network interfaces the machine has, with their addresses, status, kind and traffic (`NetworkInterface`, `InterfaceAddress`, `InterfaceStatus`, `InterfaceKind`, `InterfaceTraffic`, section 5.5), and the address values they are made of exist as pure types. Windows, Linux and macOS; FreeBSD and the browser answer `OsError.Unsupported` until slice 7, like the other slices. ## Source - [OS.md slice 5](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/OS.md#55-network) (sections 5.5, 7 and 10) - [docs/ROADMAP.md](https://git.torb.dev/torbscript/language/src/branch/main/docs/ROADMAP.md): `std/os` "the rest of their slices" (#126 to #131). Its dependency #126 (slice 2) is closed. ## What changed since OS.md was written The design proposed a new pure `std/network` for `Ipv4Address`, `Ipv6Address`, `IpAddress`, `MacAddress` and `Subnet`. URI.md section 8a decided otherwise and it is built: the pure package is `std/ip` (three of the five values, with parsers, RFC 5952 display and tests, and `SocketAddress`), and `std/network` is the socket package that re-exports it. What this slice adds is `Subnet`, `MacAddress` and the interfaces. See the decision comment below. ## Epic: why, and the steps The slice spans two pure types, three runtime files (`windows.c`, `posix.c`, `bsd.c`), three TorbScript layers and two reading natives per system: more than one PR of one or two commits. Per the definition of ready it is an epic; this issue carries no `ready` label and each step is filed when it starts next. - [x] Step 1: `Subnet` in `std/ip`, `MacAddress` in `std/os`, an audit of the IPv6 parser tests, the OS.md records corrected (#528) - [x] Step 2a (#539): the types, the pure parsers, `InterfaceAddress.subnet()` and `NetworkInterface.all` on Linux - [ ] Step 2b (#569): `NetworkInterface.all` on macOS (the `AF_LINK` entry of `Posix.interfaceEntries`, `std/os/src/macos/network.trb`) - [ ] Step 2c (filed when 2b lands): `NetworkInterface.all` on Windows (`GetAdaptersAddresses`) - [ ] Step 3: `InterfaceTraffic` (`Subtract`), `NetworkInterface.traffic` (Linux `/proc/net/dev` parser, Windows `GetIfEntry2`, `Bsd.linkTraffic`), `NetworkInterface.throughput` (two readings and a sleep, a `Task`), `docs/standard-library/os.md`, then OS.md slice 5 marked done with a "How slice 5 landed" note ## Acceptance criteria (of the epic) - [ ] Steps 1 to 3 landed and their issues closed - [ ] `NetworkInterface.all()` on Windows, Linux and macOS answers the loopback interface with `Loopback` kind and a loopback address, and every address's `subnet().contains(address)` holds - [ ] OS.md slice 5 marked done, with what differs from the sections above - [ ] `docs/standard-library/os.md` and `ip.md` document the whole network API ## Seed impact None for any step: no syntax change, no new driver flag, no std name the compiler looks up by string; the natives of steps 2 and 3 are declared in `natives.trb` like the processors' and volumes'. The compiler does not import `NetworkInterface`. ## Dependencies - #126 (slice 2) is closed. Slices 3 and 4 (#127, #128) share only `lib.trb`, `natives.trb` and `os.md` with this one; a rebase settles that.
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop), source OS.md slice 5, not a duplicate. Depends on #126. next: waiting (dependency #126) until 2026-10-10T04:00:00Z

[loop:torbscript] intake: in scope (author orion, label loop), source OS.md slice 5, not a duplicate. Depends on #126. next: waiting (dependency #126) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261027 until 2026-10-27T05:15Z

[loop:torbscript] claim refine by session:loop-torbscript-20261027 until 2026-10-27T05:15Z
Author
Collaborator

[loop:torbscript] decided by the loop:

  • Epic, not one issue. Two new pure types, three runtime files, three TorbScript layers and the reading natives of three systems are more than one PR of one or two commits. Three steps (checklist in the body), the first filed now as #528 (loop, ready); steps 2 and 3 are filed when they start next. This issue gets no ready.
  • Three of the five address values already exist. URI.md section 8a moved the pure IP values into std/ip (built), and std/network is the socket package. So the sketch's "new pure std/network" is superseded; the slice adds Subnet and MacAddress only. The shapes as built (octets(): List<Int>) stand; OS.md is corrected in step 1.
  • Subnet in std/ip, MacAddress in std/os (module of its own). std/ip holds "nothing that is not IP" (URI.md 8a); a MAC is link-layer. A module of its own, not network.trb, so parsing a MAC needs no std/os/network sandbox grant (OS.md section 8).
  • A Subnet is always a network: the text 192.168.1.23/24 is refused (host bits set), InterfaceAddress.subnet() masks. Why: the value has Equals and Hash, and two spellings of one network must not be two values.
  • FreeBSD and the browser answer OsError.Unsupported until slice 7, like slices 2 to 4; "every supported system" in the old criteria means Windows, Linux and macOS.
  • The literal closed list of URI.md section 9 (a literal adapting to IpAddress, Subnet, ...) is a compiler change that OS.md only calls a candidate; not part of this slice.
  • Seed impact: none for any step. No duplicate among the open issues (keyword search: Subnet, MacAddress, network interface, getifaddrs).
[loop:torbscript] decided by the loop: - **Epic, not one issue.** Two new pure types, three runtime files, three TorbScript layers and the reading natives of three systems are more than one PR of one or two commits. Three steps (checklist in the body), the first filed now as #528 (`loop`, `ready`); steps 2 and 3 are filed when they start next. This issue gets no `ready`. - **Three of the five address values already exist.** URI.md section 8a moved the pure IP values into `std/ip` (built), and `std/network` is the socket package. So the sketch's "new pure `std/network`" is superseded; the slice adds `Subnet` and `MacAddress` only. The shapes as built (`octets(): List<Int>`) stand; OS.md is corrected in step 1. - **`Subnet` in `std/ip`, `MacAddress` in `std/os` (module of its own).** `std/ip` holds "nothing that is not IP" (URI.md 8a); a MAC is link-layer. A module of its own, not `network.trb`, so parsing a MAC needs no `std/os/network` sandbox grant (OS.md section 8). - **A `Subnet` is always a network:** the text `192.168.1.23/24` is refused (host bits set), `InterfaceAddress.subnet()` masks. Why: the value has `Equals` and `Hash`, and two spellings of one network must not be two values. - **FreeBSD and the browser answer `OsError.Unsupported` until slice 7**, like slices 2 to 4; "every supported system" in the old criteria means Windows, Linux and macOS. - **The literal closed list of URI.md section 9** (a literal adapting to `IpAddress`, `Subnet`, ...) is a compiler change that OS.md only calls a candidate; not part of this slice. - **Seed impact: none** for any step. No duplicate among the open issues (keyword search: Subnet, MacAddress, network interface, getifaddrs).
Author
Collaborator

[loop:torbscript] refine: the dependency #126 is closed. Body rewritten to the definition of ready as an epic (goal, source, what changed since OS.md, three-step checklist, epic acceptance criteria, seed impact none); step 1 filed as #528 (Subnet, MacAddress, IPv6 parser test audit, OS.md corrected; pure TorbScript, one PR in two commits) with loop and ready. #129 carries no ready. Claim by session:loop-torbscript-20261027 released. next: epic (step 1 = #528 implement; steps 2 and 3 filed when they start). Worker usage: about 130k tokens (sonnet).

[loop:torbscript] refine: the dependency #126 is closed. Body rewritten to the definition of ready as an epic (goal, source, what changed since OS.md, three-step checklist, epic acceptance criteria, seed impact none); step 1 filed as #528 (`Subnet`, `MacAddress`, IPv6 parser test audit, OS.md corrected; pure TorbScript, one PR in two commits) with `loop` and `ready`. #129 carries no `ready`. Claim by session:loop-torbscript-20261027 released. next: epic (step 1 = #528 implement; steps 2 and 3 filed when they start). Worker usage: about 130k tokens (sonnet).
Author
Collaborator

[loop:torbscript] claim refine (step 1 #528 landed, cut step 2) by session:loop-torbscript-20261028 until 2026-10-28T08:45Z

[loop:torbscript] claim refine (step 1 #528 landed, cut step 2) by session:loop-torbscript-20261028 until 2026-10-28T08:45Z
Author
Collaborator

[loop:torbscript] refine: verified on main that step 1 landed (#528 closed; Subnet in std/ip, MacAddress in std/os, commits 81e1067 and 29b5cb9) and ticked it in the body. Step 2 spans five types, three systems and three runtime files, more than one PR of one or two commits, so only its first sub-step is filed: #539 (types, pure parsers, InterfaceAddress.subnet(), NetworkInterface.all on Linux; macOS and Windows answer OsError.Unsupported until step 2b) with loop and ready; no duplicate among the open issues. The epic checklist now lists 2a (#539) and 2b (filed when 2a lands); step 3 not filed. Seed impact none. Claim by session:loop-torbscript-20261028 released. next: waiting (epic; step 2a is #539, implement). Worker usage: about 60k tokens (sonnet).

[loop:torbscript] refine: verified on `main` that step 1 landed (#528 closed; `Subnet` in `std/ip`, `MacAddress` in `std/os`, commits 81e1067 and 29b5cb9) and ticked it in the body. Step 2 spans five types, three systems and three runtime files, more than one PR of one or two commits, so only its first sub-step is filed: #539 (types, pure parsers, `InterfaceAddress.subnet()`, `NetworkInterface.all` on Linux; macOS and Windows answer `OsError.Unsupported` until step 2b) with `loop` and `ready`; no duplicate among the open issues. The epic checklist now lists 2a (#539) and 2b (filed when 2a lands); step 3 not filed. Seed impact none. Claim by session:loop-torbscript-20261028 released. next: waiting (epic; step 2a is #539, implement). Worker usage: about 60k tokens (sonnet).
Author
Collaborator

[loop:torbscript] claim refine (next step after the landed one) by session:loop-torbscript-20261029 until 2026-10-29T08:35Z

[loop:torbscript] claim refine (next step after the landed one) by session:loop-torbscript-20261029 until 2026-10-29T08:35Z
Author
Collaborator

[loop:torbscript] decided by the loop: step 2b is macOS alone and Windows becomes 2c. macOS shares getifaddrs, Posix.interfaceEntries (its AF_LINK hook is already stubbed in posix.c) and the grouping with Linux and later FreeBSD; Windows needs a different native (GetAdaptersAddresses) and file, so it is its own PR. Wi-Fi is not told apart from Ethernet on macOS in 2b (needs a framework; documented). Seed impact none.

[loop:torbscript] decided by the loop: step 2b is macOS alone and Windows becomes 2c. macOS shares `getifaddrs`, `Posix.interfaceEntries` (its `AF_LINK` hook is already stubbed in `posix.c`) and the grouping with Linux and later FreeBSD; Windows needs a different native (`GetAdaptersAddresses`) and file, so it is its own PR. Wi-Fi is not told apart from Ethernet on macOS in 2b (needs a framework; documented). Seed impact none.
Author
Collaborator

[loop:torbscript] refine: verified on main (152d95a) that step 2a landed (#539 closed; std/os/src/network.trb, std/os/src/linux/network.trb, Posix.interfaceEntries in runtime/os/posix.c, tests in std/os/tests/network.test.trb); #548 (UnixListener and UnixStream) is closed and belongs to #119, not to this epic. Ticked 2a, split old 2b into 2b (macOS) and 2c (Windows) in the checklist. Filed #569 (NetworkInterface.all on macOS; goal, acceptance criteria, OS.md 5.5 pointer, seed impact none, one PR in two commits) with loop and ready; no duplicate among open and closed issues (keywords: network, interface, macOS). Step 2c and step 3 are not filed. Claim by session:loop-torbscript-20261029 released. next: ready (#569). Worker usage: about 70k tokens (sonnet).

[loop:torbscript] refine: verified on `main` (152d95a) that step 2a landed (#539 closed; `std/os/src/network.trb`, `std/os/src/linux/network.trb`, `Posix.interfaceEntries` in `runtime/os/posix.c`, tests in `std/os/tests/network.test.trb`); #548 (UnixListener and UnixStream) is closed and belongs to #119, not to this epic. Ticked 2a, split old 2b into 2b (macOS) and 2c (Windows) in the checklist. Filed #569 (`NetworkInterface.all` on macOS; goal, acceptance criteria, OS.md 5.5 pointer, seed impact none, one PR in two commits) with `loop` and `ready`; no duplicate among open and closed issues (keywords: network, interface, macOS). Step 2c and step 3 are not filed. Claim by session:loop-torbscript-20261029 released. next: ready (#569). Worker usage: about 70k tokens (sonnet).
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#129
No description provided.