On this page

0216. Typed interpreter network grants and errors

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

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.