0216. Typed interpreter network grants and errors
- Status: Accepted
- Date: 2026-11-10
- Plan: M16.6 (SM-INTERP-3, SM-INTERP-6)
Context
Interpreter network grants and error codes use implicit representations. Their refactoring must preserve existing equality, hashing, error values and behavior at the process ABI and across both backends.
Decision
Replace optional host lists with
NetGrant { All, NoNetwork, Hosts(Vec<String>) };
All is the default. Normalize an empty restriction to
NoNetwork to preserve the old equality and hashing
behavior. Represent a denial as
Option<NonZeroI32>: None means
allowed, and only the process ABI converts that to zero.
Define NetError with repr(i64) and
the existing values: Timeout = 1,
Reset = 2, Closed = 3,
AddrInUse = 4, Refused = 5,
Limit = 6, InvalidAddress = 10003, and
GrantExceeded = 10004. lower_platform
builds the same table from the enum. IR, C, string and sandbox
semantics do not change; the optional EBADF change is skipped to
preserve behavior.
Alternatives considered
- Keep optional host lists and raw integer codes — their meanings remain implicit and allow grant states and error constants to be confused.
- Change error mappings or retain empty host lists as a distinct grant — either would change existing behavior or equality and hashing semantics.
Consequences
Grant states and network errors become explicit and their values centralized. Callers must normalize empty restrictions and convert denial status at the ABI boundary; existing externally observable semantics remain unchanged.