roadmap

Milestone 47 appendix: environment variables

An appendix to milestone 47 (navigation and naming). The page is complete without it. It holds how environment works on nife: where each kind of variable goes, the rules that keep the environment from being an open channel, and the limits that stand today.

Three things in one map, and where each goes

There is no argv and no envp. notes/abi.md is explicit: "no libc, no argv/envp array, no dynamic loader, no main wrapper", so a program gets argument words in registers and a populated cspace.

Unix puts three different things in one string-to-string map. That is why environment variables are both indispensable and a security disaster. Here each goes to its own place:

The environment is not an open channel

In Unix anyone can set any variable and hope the program reads it, so every process carries an unbounded implicit input. LD_PRELOAD, IFS, PATH and a long tail of library-specific variables are attacks that work because a program can be influenced by something it never asked for.

So a program declares the configuration it reads, and undeclared variables cannot reach it. It is the SHILL-style manifest's shape: a program declares its expected endowment, and the manifest is checked at spawn. grant_plan::Manifest::config is that declaration, clock's twin. A program declares it, the shell cannot, and the progenitor reads it to decide who gets the page. Declaring it closes the entire LD_PRELOAD class by construction rather than by blocklist.

And no inheritance by default. Unix's environment is inherited, which is why a secret in a shell leaks into every child. Here configuration is granted like everything else: at spawn, explicitly, visible in caps. Full explicitness is verbose, and the main page's governing constraint is against gratuitous divergence. The middle ground is inheritance with visibility: the shell's default set reaches the child, and the passing is explicit and inspectable, so caps printenv shows exactly what that program will see before it runs.

The page

Each declared key is checked against a closed domain when the page is assembled: a real IANA timezone identifier for TZ, a real locale code for LANG, a real terminal type for TERM. A value that does not parse is refused when the page is built, not carried. So a secret typed into the wrong bucket cannot ride through disguised as configuration. §111 holds the encoding choice and its reasons.

The page is assembled once with the defaults TZ=UTC, LANG=C, TERM=dumb and granted READ-only at a fixed slot and VA, the clock page's shape. The std PAL seeds std::env from it before main runs. printenv prints KEY=value for a declared key and KEY (unset) for one the page does not carry. It probes the slot before touching the page, so a process holding no capability never faults. caps printenv prints the three values from the boot shell's own read-only view of the same frame. notes/env-config.md has the files, constants and tests.

crates/system_initializer's per-command spawn logic is reachable only from a real init, so it is excluded from the host pass and from script/test's kernel suite. script/swish-check, which boots a real init on each board and runs printenv and caps printenv, is the gate for it. Init's capability table has sixteen slots, and a permanently-held kernel grant can exhaust them before any prompt appears; that gate is what catches it.

Limits that stand