The specification
All twelve specification sections combined in order for offline reading and printing. Return to the section index for individual pages.
Overview
Nether C is a C dialect in which nothing runs.
A Nether C program is not executed. It is buried: evaluated as far as the world currently permits, leaving behind a trace — a complete, immutable, content-addressed record of everything that happened — together with the holes where the program asked the world a question that has not yet been answered. Answering a hole is a separate, later act called exhumation, and it produces a new trace rather than modifying the old one.
That is the whole language. Everything below is consequence.
0.1 Why
Most languages draw a line between compile time and run time and then spend their lifetime negotiating across it: constant folding, macros, constexpr, build systems, staged metaprogramming, reproducible builds, provenance tracking, incremental compilation. Each is a separate mechanism for the same underlying question — how much of this program can we settle now, and what must wait for the world?
Nether C makes that question the only question. There is one mechanism, and the line between what is settled and what is pending is a first-class, inspectable, addressable thing.
The design's history, rejected alternatives, and costs are in section 90, which is not normative. This specification stands on its own: no knowledge of another language is required.
0.2 The thesis, in one sentence
Evaluation is not something a program does later; it is something that has already happened as far as it could, and the trace is the record of how far that was.
0.3 What a Nether C implementation must provide
An implementation MUST provide:
- A burier, which takes source and a set of granted capabilities and produces a trace (section 06).
- A ledger, a content-addressed store of immutable values and traces (section 07).
- The rites, a command-line interface over the two (section 08).
An implementation MUST NOT provide a way to execute a Nether C program that does not produce a trace. There is no run. This is not a missing feature; it is the single load-bearing constraint of the design, and an implementation that adds it is not an implementation of this specification.
0.4 Reading order
The specification is written to be read in order, but sections 01, 02 and 06 are the ones that carry the design. A reader in a hurry should read those three and skip the rest until they need it.
| Section | What it settles |
|---|---|
| 01 Strata | The nine depths, what each grants, what each costs |
| 02 Calculus | The typing rules for depth, seal, shade, look |
| 03 Lexical | Source encoding and tokens |
| 04 Grammar | The complete EBNF |
| 05 Types | The type system and the data model |
| 06 Evaluation | Burial, demand, holes, residue, replay |
| 07 Ledger | Canonical encoding, cairns, the trace format |
| 08 Rites | The command-line contract |
| 09 Prelude | The standard library, and what each function costs |
| 10 Glossary | Every term, defined once |
| 90 Rationale | Non-normative: why, and what it cost |
0.5 Normative language
The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY and OPTIONAL are to be interpreted as described in RFC 2119.
Every normative claim appears exactly once, in one section. Where another section needs it, it links rather than restates. A claim stated twice will eventually be stated two different ways.
Text in a block quote, and the whole of section 90, is non-normative.
0.6 Status
This specification is a draft. Sections marked status: draft are subject to change without a version bump. Nothing here is frozen except where a section says so explicitly, and three do: the canonical encoding (§7.1), the node encoding on the same terms (§7.3.1), and the one frozen requirement, which is that there is no run (§8.0).
Open design questions are tracked as items in the repository's roadmap (cairn list --filter 'title~Decide'), not as inline TODOs. Where this document states a rule that a roadmap item is still arguing about, it says so in a block quote and names the item.
Three such questions have been settled and no longer appear that way: the form of the Orpheus rule (§1.6), the fuel budget and the opaque barrier (§6.4), and whether stratum 8 is admissible at all (§1.7). What each of them cost is in section 90.
A fourth — what a prelude function does when it cannot answer — is settled in §9.9: a no from the world is an answer and gets a value; a mistake in the program is collapse and stops the burial.
Which questions are open is a fact about the roadmap and not about this document, so this section does not count them. The filter above lists them, and each is named where it bites: a rule a roadmap item is still arguing about is block-quoted in its own section, beside the rule, where somebody relying on it will see it rather than somewhere they have to think to look.
Settling one is not the same as knowing they are all settled. A question nobody has asked yet leaves no trace here.
0.6.1 What a release promises
A trace is a fact about the past: this implementation, given this source and these answers, wrote this. A later release of the language cannot make that untrue, and it is not asked to keep it reproducible by every later implementation either. What a trace written by an older release may still claim is four things, and each has its own answer.
| A trace written by an older release is | when |
|---|---|
| readable | its domain separator is this implementation's (§7.7) |
| verifiable — its cairns check | the same: a cairn is checked under the domain it was written in |
| replayable (§6.7) | by the implementation that wrote it, and by any later one whose burial of that residue is unchanged |
| true | always. Its depth, holes and witnesses say what that implementation did, and nothing later reinterprets them |
Replay is the one that a language change can take away, because a residue is source (§6.5) and replay buries it again. So the promise is not that every release replays every old trace. It is that the release which wrote one can always be had again: a release binary is built reproducibly and its hash published (scripts/task release:build), and that binary replays its own traces for as long as anybody keeps one.
After 1.0, a release follows Semantic Versioning by these rules, layer by layer:
- Encoding. Any change to §7.1 or §7.3.1 moves the domain separator, and a moved domain is a major release. There is no minor change to a frozen format.
- Syntax and meaning. A change after which a program that buried before buries to a different trace, or no longer lowers, is major. A change that only lets more programs lower is minor.
- Prelude. Adding a function is minor. Changing a function's signature, its stratum, or what it answers is major, because a trace's holes name prelude calls and their strata.
- Rites. A flag that changes what a rite writes into the store is major. One that changes only what it prints is minor, and what it prints in
--jsonis part of what it writes for this purpose.
A major release says, in its changelog, which of the four claims above its older traces lose, and the rejected alternative to the change goes in §90.2 as every design decision's does. Before 1.0 the draft status above holds and none of this binds; it is written down now so that 1.0 is a decision to start keeping it rather than a decision about what it says.
0.7 A first program
// hello.nc — there is no main; there is a demand.
U0 greet()
{
"Hello from the nether\n"; // deposited, not printed
}
demand greet();$ nether bury hello.nc
buried hello.nc → efed9b2a depth 0 holes 0 4 nodes
$ nether lamp efed9b2a
Hello from the netherBurying said nothing about the greeting, and it never can: a Nether C program holds no capability that reaches a terminal. It left a deposit in the ledger. Seeing it is a second act, performed by a person who chose to carry a light down there. See section 08 for why observation is a tool rather than a power.
The strata
Every value in Nether C carries a depth: a natural number between 0 and 8 recording how far into the world its history reaches. Every expression has a depth. Every function's type includes the deepest stratum it may reach.
Depth is not a permission that is checked and forgotten. It is part of the type, it propagates through every operation, and it is recorded permanently in the trace.
1.1 The lattice
The nine strata form a total order, 0 ≤ 1 ≤ … ≤ 8. Depth composes by maximum: an expression built from parts is exactly as deep as its deepest part.
| Depth | Name | Grants | Costs | Witness obligation |
|---|---|---|---|---|
| 0 | Pure | arithmetic, data, functions | nothing | none |
| 1 | Store | reading the ledger by cairn | nothing observable | the cairn read |
| 2 | Frozen Environment | declared variables, a pinned clock, the target triple | the value must be declared in advance | the declaration and the value |
| 3 | Read the Disk | reading files | the result depends on a filesystem | path, bytes read, and their cairn |
| 4 | Write the Disk | creating and modifying files | irreversibility outside the ledger | path and the cairn of what was written |
| 5 | Read the Network | fetching | the result depends on a remote party | request, response, and its cairn |
| 6 | Write the Network | sending | the world remembers what was said | request and the response, if any |
| 7 | Entropy | true randomness | replayability | the drawn value |
| 8 | Unrecorded | foreign code | provenance itself | nothing can be recorded |
Strata 0 through 7 are recordable: everything the world answered can be written to the ledger and served back later, so a trace that reached them can be replayed exactly. Stratum 8 is not, and is treated separately in §1.7.
1.2 The monotonicity law
Law. No evaluation step lowers the depth of a value.
This is the one invariant the whole design rests on. An implementation MUST NOT provide any operation that produces a value of lower depth than its inputs, except the two escapes defined in §1.5 and §1.6, both of which carry a name or an opacity rather than the value itself.
There is no ascend.
1.3 Descent
Bytes@3 src = descend disk { read("kernel.nc") };descend κ { … } is an expression. It acquires the capability named κ for the duration of the block, evaluates the block, and takes the value of the block's tail expression. The body is checked holding δ ∪ {s(κ)}, where δ is what the enclosing scope holds.
It acquires that capability and no other. The strata are ordered by how much of the world has been disturbed (§1.8), which is an order for comparing two histories and not one for implying a permission: net is deeper than disk! and does not carry it.
Answer<U0> wrote = descend net { write("kernel.nc", b"") }; // needs disk!That descent supplies net, and the call needs disk!. At the top level of a file there is nobody to ask for it, so an implementation MUST reject this, naming the capability that grants the stratum the call reaches. The program that means it nests — descend net { descend disk! { … } } — and says both out loud.
Inside a function body the same expression is not an error: it is what the function asks of whoever calls it, and the signature comes out @4 (ABS). Either way the capability is named somewhere a reader can find it, which is the whole of why the names are fixed rather than open.
A descend whose tail expression is U0 may be used as a statement.
- Descent is lexically scoped: the capability is not available outside the block, and neither are the block's local bindings. Only the tail value leaves, carrying its depth with it.
- Descent is one-way within the block: no construct inside the block gives back a capability the block is holding.
- Descents nest, and nesting accumulates.
descend disk { descend net { … } }has a body holding both, and still nothing else. - A
descendfor a capability the enclosing scope already holds is legal and has no effect. An implementation SHOULD warn about it.
The capability names and their strata are fixed by this specification and listed in section 09. An implementation MUST NOT define additional capability names; a capability that is not in the prelude cannot be audited by a reader of this document, which defeats the purpose of naming them at all.
1.4 What the trace records
When an expression at depth d > 0 is evaluated, the implementation MUST write to the ledger, before the value is returned to the program:
- the witness listed for that stratum in the table in §1.1;
- the source span of the expression that reached it;
- the depth itself.
The order matters. An answer that is returned before it is recorded is an answer that can be lost, and a ledger with a gap in it cannot support any of the guarantees in section 06.
1.5 Seal
Cairn id = seal src; // src : Bytes@3, id : Cairn@0seal e produces the cairn of e — the content address of its value. The result has depth 0 regardless of the depth of e.
This is sound because a cairn is a name, and a name is pure. Knowing that a file's contents hash to a1f0c93d tells you nothing about the file that you could not have computed yourself given the same bytes; it is a claim about the deep value, not the deep value.
It is worth being exact about what that sentence does and does not say, because seal is the place a reader is most likely to expect more of depth than depth offers.
Depth is a claim about where a value has been, and about nothing else. It says which strata a value's history reached and therefore what the trace owes a witness for. It is not a claim about what a deep value can be made to reveal, and Nether C has no rule that confines that.
seal is the shortest demonstration. The cairn of a depth-3 file is at depth 0, §9.2's hex turns it into a Str at depth 0, and §5.3 makes equality a comparison of cairns:
Bytes@3 src = must(descend disk { read("secret") });
Bool@0 is_the_one =
(seal src == #4d9f7b2e0c81a35f6d0e92b7c4a1f80d35e6b92c7f0a4d81b3e5c9270af61d84);That decides something about a depth-3 value at depth 0, holding nothing and writing no witness for the comparison. Against a low-entropy secret — a version string, a four-digit number, a file that is one of three — guessing settles it.
None of which is a hole in the rule above. Every step is a claim about the deep value rather than the deep value, the history is intact, and the trace still says the file was read. It is a hole in the rule a reader might have inferred instead, which is why the rule is written down here.
A program that must not reveal a deep value is not a program this type system can check. §90.3 says so beside the other things it is worse at.
seal on a shade (§1.6) is legal and names the shade. A shade carries the stratum it came out of, and §7.1 encodes that alongside what it holds, so seal shade e is not seal e. The cairn of what is inside is had by sealing it before shading it, which costs nothing and needs no capability.
1.6 Shade, and the Orpheus rule
Shade<Bytes> reply = descend net { shade must(get("https://example.invalid/index.json")) };
Cairn witness = seal reply; // legal: Cairn@0
// ILLEGAL here — see below
I64 n = len(look(reply));shade e, where e : T@d, produces a value of type Shade<T> at depth 0. The shade is opaque: it MAY be stored, copied, passed, compared for equality, and sealed. It MUST NOT be destructured, pattern-matched, or otherwise observed.
look s, where s : Shade<T> originating at depth d, has type T@d, and is well-typed only where the capability that grants stratum d is held. That one: a shade out of stratum 3 opens under descend disk, and not under a descend net that happens to be deeper.
The Orpheus rule. You may carry a shade up out of any stratum. You may only look at it by going back down.
The check is local: it asks whether the shade's origin stratum is among the capabilities held at the point of the look. It does not propagate, it does not stain the enclosing scope, and it produces an error that names the origin, what is held, and the descend that would fix it.
error: cannot look at a shade from stratum 5 at depth 0
--> stamp.nc:14:21
|
14 | I64 n = len(look(reply));
| ^^^^^^^^^^^ this shade came from `get` at stratum 5
|
= the value is here, but you are not. Wrap the look in `descend net { … }`.Where something is held and it is the wrong one, the error MUST say so rather than report a number: a shade from stratum 3 looked at under descend net is not a shallower scope, and an implementation that prints at depth 5 has told the reader their scope is deep enough.
What the rule buys, and what it does not
It is a rule about the program's text, and it is worth being exact about that, because a reader meets it among the capabilities and will take it for one.
What it buys is two things. [LOOK] concludes τ @ max(d, d′), so opening a shade does not launder it: the value comes out at the depth it went in, and everything built from it is that deep. And a descend naming the stratum stands at every point in the source where the value is observed, which is what a reader auditing a program actually reads.
What it does not buy is a capability at burial. Nothing about look reaches the world — the value is in hand already — so no grant gates it, and §6.1 says so in as many words. A writer who wants to open a shade writes the descend and burial evaluates it, whatever the invocation held.
So shade is what lets a deep value be held, passed and stored at depth 0 without its depth spreading to everything it touches, and look is what costs naming the stratum again to get it back. Neither is an authority, and §1.4's witness for the stratum was written when the value was first fetched — once, by whoever held the capability then.
This rule is settled. Two alternatives were considered and rejected — re-staining the entire enclosing scope, and tainting only the binding — and both are recorded in §90.2.
1.7 Stratum 8, the Unrecorded
Stratum 8 is foreign code: anything whose behaviour the implementation cannot observe well enough to record a witness for.
It is in the lattice because a language that cannot call C is a language nobody can adopt. It is at the bottom because it is the only stratum that breaks the language's central promise rather than merely deepening it: a trace that reached stratum 8 has a gap in it, and no amount of later care can fill that gap in.
An implementation MUST:
- mark any trace that reached stratum 8, permanently and transitively, in the trace itself;
- refuse to report such a trace as replayable, in every rite that reports replayability;
- surface the mark in
nether strataoutput without being asked.
A value derived from an unrecorded call is itself at depth 8. There is no sealing or shading out of stratum 8 that removes the mark — seal still yields a Cairn@0, but the trace remains marked, because what is unsound is not the name but the claim that the trace is complete.
This is settled: stratum 8 exists, and is quarantined loudly. The alternative — refusing foreign code entirely — is purer, and is recorded in §90.2 along with why a language that cannot call C proves nothing about whether its ideas were good.
1.8 Why write is deeper than read
Strata 4 and 6 sit below 3 and 5 because the ordering is how much of the world you have disturbed, not how much you have learned. A read can be replayed from the ledger with no trace left outside it; a write cannot be taken back, and a message sent cannot be unsent.
This makes the ordering slightly unusual: a program that only reads the network (5) is deeper than one that writes the disk (4), which is arguable. The specification takes the position that reaching outside the machine is a larger commitment than modifying the machine you are already on. An implementation MUST use the ordering in §1.1 regardless of its opinion, since depth comparisons must mean the same thing everywhere.
The calculus of depth
This section is the formal core. It fits on one page, and that is a constraint rather than an observation: a depth system that cannot be stated on one page cannot be taught, and a lattice nobody can hold in their head will be worked around rather than used.
2.1 Judgement form
Γ ; δ ⊢ e : τ @ dRead: in context Γ, holding the capabilities δ, the expression e has type τ and depth d.
- Γ maps identifiers to depth-annotated types,
x : τ@d. - δ is the ambient capabilities: the set of strata whose capabilities are currently held. It holds 0 and nothing else at the top level of a file, and is added to only by
descend. - d is the value depth: how far into the world this value's history reaches.
δ is a set and d is a number, and the two are different kinds of thing on purpose. A value's depth is how far it went, which composes by maximum and fits in a byte. Authority is which doors are open, which does not: the capabilities are in bijection with the strata §9.1 names them for, and holding one holds no other. §1.8 orders the strata by how much of the world has been disturbed, and an order fit for comparing two histories is not one fit for implying one permission from another — under it net would imply disk!, and may fetch a URL would mean may delete a file.
Stratum 0 is in δ always. Nothing grants it and nothing needs it, and having it there is what lets [APP] and [LOOK] be stated without a special case.
dƒ ⊆ δ and d ∈ δ are required where they are written, which is the premises of [APP] and [LOOK], and an implementation MUST reject any program in which either fails. Neither is a property of every judgement: [DESCEND] is precisely the rule that concludes outside the capabilities it added, so descend disk { read(p) } has depth 3 in a scope holding nothing. What holds everywhere is §2.4.
Function types carry a latent set and a return depth, written τ₁ --dƒ--> τ₂@d_r.
- dƒ is the latent set: the capabilities a caller must already hold to apply it. In source syntax it is the trailing annotation on the signature —
Bytes read(Str path) @3for one,@{3,5}for two,@0for none (§3.5). - d_r is the depth of what comes back. It rides on the return type, where it is written at all (
Bytes@3 load(Str path)), and like every other depth it is inferred unless written.
Both are needed, because they are different numbers. A function that does its own descending asks its caller for nothing and still hands back something deep.
2.2 The rules
x : τ@d ∈ Γ
[VAR] ───────────────────
Γ ; δ ⊢ x : τ@d
[LIT] ───────────────────── ℓ a literal
Γ ; δ ⊢ ℓ : τ@0
Γ ; δ ⊢ eᵢ : τᵢ@dᵢ (i = 1..n)
[PRIM] ────────────────────────────────────────
Γ ; δ ⊢ ⊕(e₁..eₙ) : τ@max(d₁..dₙ)
Γ ; δ ⊢ f : (τ₁ --dƒ--> τ₂@d_r)@d_f Γ ; δ ⊢ a : τ₁@d_a
dƒ ⊆ δ
[APP] ────────────────────────────────────────────────────────────
Γ ; δ ⊢ f a : τ₂ @ max(d_r, d_f, d_a)
Γ, x : τ₁@0 ; dƒ ⊢ b : τ₂@d₂ dƒ least
[ABS] ──────────────────────────────────────────────────
Γ ; δ ⊢ λx.b : (τ₁ --dƒ--> τ₂@d₂)@0
Γ ; δ ∪ {s(κ)} ⊢ e : τ@d
[DESCEND] ──────────────────────────────────
Γ ; δ ⊢ descend κ {e} : τ@d
Γ ; δ ⊢ e : τ@d
[SEAL] ─────────────────────────────
Γ ; δ ⊢ seal e : Cairn@0
Γ ; δ ⊢ e : τ@d
[SHADE] ────────────────────────────────
Γ ; δ ⊢ shade e : Shadeᵈ⟨τ⟩@0
Γ ; δ ⊢ s : Shadeᵈ⟨τ⟩@d′ d ∈ δ
[LOOK] ──────────────────────────────────────────
Γ ; δ ⊢ look s : τ @ max(d, d′)
Γ ; δ ⊢ e : τ@d
[OPAQUE] ──────────────────────────────────
Γ ; δ ⊢ opaque e : τ@d (residual; see §06)
Γ ; δ ⊢ e : τ@d
[DEMAND] ─────────────────────────────
Γ ; δ ⊢ demand e : U0@ds(κ) is the stratum of capability κ, fixed by section 01.
That is the whole system: eleven rules.
2.3 What each rule is doing
[LIT] is why pure code disappears at burial. A literal is at depth 0, and by [PRIM] anything built only from literals is at depth 0, and by section 06 anything at depth 0 is fully evaluated before the trace exists.
[PRIM] ranges over every primitive operation, and a conditional is one of them: if, while, && and || take their condition and their arms as operands, and the maximum is over all of them. The condition belongs in that maximum because the result's history runs through it: a value that exists because a depth-3 file said one thing rather than another is a value the disk was consulted for, and a trace that called it pure would owe no witness for a read that happened. That is provenance, which is what a depth is.
It is not an argument about what an observer learns. Depth does not confine that, and §1.5 says so where it is easiest to see.
The arms are why [PRIM] is the one rule whose depth is a bound rather than a fact, and §2.4 is about that.
[APP] takes the maximum of three things, not two: the depth of what the function hands back d_r, the depth of the function value itself d_f (a function fetched over the network is a deep value even before it is called), and the depth of the argument. Forgetting the middle one is the classic soundness hole in effect systems that carry effects only on arrows.
The latent set is the premise and not one of the three. A capability is what it takes to reach a stratum, and dƒ is what the function needs its caller to hold already. The other three are facts about where values have been, and whoever took them there held the capability at the time: applying len to a depth-3 Bytes reaches nothing. That is why [PRIM] has no ambient premise either, and why §2.5 can say a shallow value combines with a deep one without coercion.
[ABS] is where both numbers come from, and the closure itself is pure: building a function that will touch the disk does not touch the disk.
The body is checked at dƒ rather than at the capabilities held wherever the function happened to be written, and dƒ is the least set, by inclusion, at which the body checks — what the function asks of whoever calls it. It is unique: it is exactly the capabilities the body reaches for bare, and a collection of demands has one union. A body containing its own descend asks for nothing, because the descent supplies the capability from inside; a body that calls a prelude function bare asks for that one, which is how Answer<Bytes> read(Str path) @3 works and why it is written that way in section 09. A body that calls two bare at different strata asks for both, and is written @{3,5}. All of it is ordinary, and the choice is the choice of who holds the capability.
The body's own value depth d₂ is what comes back, separately. Parameters are bound at depth 0: a parameter's real depth arrives at the call site, and [APP] joins it there.
Bytes load(Str p) { descend disk { must(read(p)) } } // --0--> Bytes@3
Answer<Bytes> raw(Str p) @3 { read(p) } // --3--> Answer<Bytes>@3
Bytes@3 a = load("kernel.nc"); // legal at δ 0
Bytes@3 b = descend disk { must(raw("kernel.nc")) };load descends for itself and is callable anywhere. raw does not, so it asks, and its callers descend instead. Neither launders anything: both hand back a Bytes@3, and nothing anywhere lowers a depth.
[DESCEND] is the only rule that adds to δ, and it adds only inside its own premise. Nothing takes anything out of δ. Nothing lowers d.
[ABS] does not add to δ; it starts a new one. A function body is checked once, against its own signature, and not once for every place the function is called.
[SEAL] is the first escape: a name is pure regardless of what it names. See §1.5 for why this is sound.
[SHADE] is the second escape, and unlike seal it keeps the value — opaquely. The origin depth d is carried in the type as Shadeᵈ⟨τ⟩, which is what makes [LOOK] checkable. When shade e appears inside a function body and e depends on a parameter x, every call site supplying argument a for x MUST satisfy d_a ≤ d, so substituting x := a preserves both typing and the canonical Value::Shade.origin.
[LOOK] carries the entire Orpheus rule in one premise: d ∈ δ. You may look only where you hold the capability the value came from — that one, and not merely one at least as deep. A shade out of stratum 3 opens under descend disk and nowhere else, which is what going back down says and what a comparison of two numbers did not. The result also inherits d′, the depth of the shade value — a shade that was itself fetched over the network is deep for two independent reasons.
2.4 Metatheory
Two properties an implementation MUST preserve. Both are mechanized over the core calculus in proof/calculus.py and tested generatively by crates/nether-bury/tests/monotone.rs (item 0052, buried).
Soundness of the bound. If
Γ ; δ ⊢ e : τ@dande ⟶ e′withΓ ; δ ⊢ e′ : τ@d′, thend′ ≤ d— never more.
A depth in a type is an upper bound on how far into the world the value's history reaches. Evaluation can only ever find out that something was shallower than it looked:
if (true) { 1 } else { must(descend disk { read("k") }) }has depth 3 by [PRIM] and reduces to 1, which is at depth 0. Nothing was lowered — the depth 3 was a bound over an arm that was never taken, and burial found out which arm it was.
The other direction is the one that matters. A type claiming depth 3 for a value that turns out to be pure is conservative and harmless. A type claiming depth 0 for a value that reached the disk is a value escaping at a depth its type did not admit, and that is the single thing the lattice exists to prevent.
This is not §1.2, which says something else: that no operation takes a deep value and hands back a shallow one. There is no ascend. Picking an arm takes no deep value anywhere, because the deep value was never produced.
The depth in a trace is a third number and an exact one: what evaluation actually reached, recorded with a witness for each stratum (§1.4). A bound is what a type offers before anything runs; a trace says what happened.
Ambient soundness. If
Γ ; δ ⊢ e : τ@dthend ≤ max(δ ∪ g(e)), whereg(e)is the set ofs(κ)over thedescend κexpressions ineand, transitively, in the body of everythingeapplies — and empty when there are none.
A value can never be deeper than the capabilities that were held while it was made — held at the point it was made, which is the ambient depth or a descent inside the expression that granted more. Nothing else in the system grants anything, which is what makes nether strata a blame tool rather than a guess: a value at depth 5 means some descend net is responsible, and it is either enclosing, or written in the expression, or written in the body of something the expression calls. Either way it can be found by construction, by following the calls.
A judgement with g(e) empty therefore satisfies d ≤ max δ, and that is most of them. The descent is the exception, and it is the only one.
2.5 Subsumption, and its deliberate absence
There is no subsumption rule. τ@0 is not a subtype of τ@3, and a value at depth 0 is not silently usable where a depth-3 value is expected — because nothing needs that: [PRIM] and [APP] already take the maximum, so a shallow value combines with a deep one without any coercion.
Nor is one capability a subtype of another. δ is a set and dƒ ⊆ δ asks for membership, so holding net is not holding disk! and never becomes it — §2.1 is why, and it is the same refusal one level up.
The reverse direction — using a deep value where a shallow one is required — is exactly what the language exists to prevent, and it is available only through seal and shade.
Explicit depth boundaries cost convenience. The tradeoff is recorded in section 90.
Lexical structure
3.1 Source encoding
A Nether C source file is a sequence of Unicode scalar values encoded as UTF-8. An implementation MUST reject a file that is not well-formed UTF-8, rather than substituting replacement characters.
A ledger must be able to record names, not just the ones that fit in an eight-bit character set.
Line terminators are U+000A. A U+000D immediately preceding U+000A is discarded; a U+000D anywhere else is an error. Source files SHOULD end with a line terminator.
3.2 Comments
// to the end of the line
/* to the closing delimiter; these do not nest */Comments are whitespace. They are not preserved in the AST and do not appear in the ledger.
3.3 Identifiers
identifier := XID_Start XID_Continue*Identifiers are compared by exact code-point sequence after NFC normalisation, and an implementation MUST normalise an identifier before comparing or recording it, so that two spellings of one name cannot resolve to two different bindings.
Normalisation happens here, in the lexer, and nowhere below it. The ledger stores the bytes it is handed and does not alter them (§7.1 rule 6): a Str that a program constructs from arbitrary input is that program's business, and a store that quietly rewrites it would be addressing something the caller never wrote.
3.4 Keywords
Reserved, and never usable as identifiers:
descend seal shade look opaque demand
if else while for return break continue
struct typedef sizeof true falsesizeof is reserved and has no meaning. §4.5 has no production for it and nothing in this specification says what it would evaluate to: there is no pointer type, no allocation and no memory layout, so there is nothing for it to measure. It stays reserved so that a program cannot bind the word to something that is not what a reader would assume, and writing one is an error that names len. §90.2.
Type names in the prelude (U0, I64, Bytes, Str, Cairn, Shade, Answer, Refusal, Bool) are ordinary identifiers bound in the prelude scope, not keywords. A program MAY shadow them, and SHOULD NOT.
3.5 Depth annotations
depth_annotation := "@" ( "0".."8" )
latent_annotation := "@" ( "0".."8" | "{" stratum { "," stratum } "}" )
stratum := "1".."8"A depth annotation may appear:
- after a type, binding tighter than anything else:
Bytes@3,I64@0. It is one digit, because a value depth is one number; - after a function signature, giving its latent set:
Bytes read(Str p) @3, orBytes sync(Str p, Str u) @{3,5}for a body that asks its caller for two.
The braced form spells a set of two or more, ascending and without repeats, and holds no 0: stratum 0 is held everywhere, so naming it in a set says nothing, and @{3} and @3 would be two spellings of one thing. @0 is the bare form and is how a function says it asks for nothing.
Neither MUST appear anywhere else. In particular there is no depth annotation on an expression — depth is inferred for expressions and only ever asserted on declarations. An annotation that disagrees with inference is an error, not a coercion.
Whitespace is permitted between @ and the digit in a signature annotation and forbidden in a type annotation, so that Bytes@3 is unambiguously one token sequence.
3.6 Literals
digit := "0".."9"
hexdigit := digit | "a".."f" | "A".."F"
int_literal := dec | hex | bin
dec := digit ( digit | "_" )*
hex := "0x" hexdigit ( hexdigit | "_" )*
bin := "0b" ( "0" | "1" ) ( "0" | "1" | "_" )*
bool_literal := "true" | "false"
cairn_literal := "#" lowerhex{64}
lowerhex := digit | "a".."f"
str_literal := '"' ( str_char | escape )* '"'
bytes_literal := "b" '"' ( str_char | escape | byte_escape )* '"'
escape := "\\" ( "n" | "t" | "r" | "0" | "\\" | '"' | "u{" hexdigit+ "}" )
byte_escape := "\\x" hexdigit hexdigitThere are no floating-point literals. Floating-point arithmetic is not in the language, because IEEE 754 has platform-observable behaviour that would make the canonical encoding of section 07 unsound, and a reproducibility guarantee with an asterisk on it is not a guarantee. A future version MAY add a rational or fixed-point type; it will not add binary floats without a stated evaluation semantics.
An integer literal is I64. There is no unsigned type and no integer promotion; see section 05.
A cairn literal is Cairn, and is exactly sixty-four lowercase hexadecimal digits after the #. Not sixty-three, not sixty-five, no _ separators, and no uppercase: a cairn is a name, two spellings of one name are two names, and §7.1 refuses the same thing one level down for the same reason.
It is the spelling the rites print. A name copied out of nether lamp or nether cairn pastes into a program with a # in front of it and means the same thing there. There is no short form — a prefix is something a person types at a terminal, where a ledger is present to resolve it, and a program has no ledger while it is being read.
The literal exists because §6.5 requires a residue to be a program. A burial that folds seal has a cairn to write down, and a value the language cannot spell is a residue that does not parse.
\x is in bytes_literal for the same reason and not in str_literal for a different one. A source file is UTF-8 (§3.1), so the byte 0xe2 cannot be written on its own, and \u{e2} is the character U+00E2 — two bytes when it is encoded, which is not what a Bytes value holding one byte wants said about it. \xe2 is that byte. It takes exactly two hexadecimal digits, because a variable-length one makes \xef followed by the letter f two different literals depending on how far the reader is willing to look.
A Str is UTF-8 (§5.1), so a byte escape there would spell values the type cannot hold, and the two escapes would then mean different things in the two literals. \u{…} means a scalar value in both.
The three spellings do not hold the same range, because they are not spelling the same thing.
- A decimal literal spells a magnitude. It is an error above
2⁶³ − 1. - A hexadecimal or binary literal spells a bit pattern. It is sixty-four bits wide and is read as two's complement, so
0x8000_0000_0000_0000is−2⁶³and0xFFFF_FFFF_FFFF_FFFFis−1. It is an error above sixty-four bits.
That split is what makes every I64 writable. - is an operator applied to a literal, so −2⁶³ has no decimal spelling at all — the literal it would need is one past the top — and a type with a value nobody can write is a type with a hole in it.
3.7 Punctuation
( ) { } [ ] ; , . -> @
+ - * / % ! ~ & | ^ << >>
= == != < <= > >= && ||
+= -= *= /= %= &= |= ^= <<= >>=3.8 Tokens the language does not have
For the avoidance of doubt, and because a C programmer will look for them:
- No preprocessor. No
#include, no#define, no#if, and in particular no#exe. Everything#exedid, burial does — see section 06 — so a second mechanism for it would be a second, worse burial. The#is not free for one either way: §3.6 spends it on the cairn literal, which is the nearest thing this language has to the thing#includewas reaching for and arrives at it from the other end. - No
goto. - No pointer syntax. See section 05.
Grammar
EBNF. { x } is zero or more, [ x ] is optional, | is alternation. Terminals are quoted. Lexical productions are in section 03.
The grammar is recursive and an implementation is not. How deeply an expression or a type may nest is one of the limits §6.4 requires an implementation to state, and to report reaching rather than crash into.
4.1 Compilation unit
unit := { item } ;
item := struct_decl
| typedef_decl
| func_decl
| let_decl
| demand_stmt ;
demand_stmt := "demand" expr ";" ;There is no entry point. A unit is a set of declarations plus the demands that give some of them a reason to be evaluated.
4.2 Declarations
struct_decl := "struct" identifier "{" { field } "}" ";" ;
field := type identifier ";" ;
typedef_decl := "typedef" type identifier ";" ;
func_decl := type identifier "(" [ params ] ")" [ latent ] block ;
params := param { "," param } ;
param := type identifier ;
latent := "@" ( digit | "{" digit { "," digit } "}" ) ;
let_decl := type identifier [ "=" expr ] ";" ;A let_decl at unit level is a declaration; the same production inside a block is a statement. A unit-level one MUST have its initialiser: a global with no value is a value nothing can supply, since there is no statement above it to assign one.
A block-level one may go without, and that is the only way to construct an aggregate: declare it, then write its fields. What may be written, and for how long, is §5.4.
4.3 Types
type := type_atom { "[" [ int_literal ] "]" } [ "@" digit ] ;
type_atom := identifier
| identifier "<" type { "," type } ">" ;Shade<Bytes>@0 is a shade of Bytes at value depth 0. The two depths on a shade are different things and it is worth being careful: the one after the > is how deep the shade is, and the one inside is how deep the value it holds came from.
A shade's origin is the depth written on its type argument. Shade<Bytes@5> is a shade of bytes that came from stratum 5, and Shade<Bytes@5>@0 is that shade held at depth 0, which is the ordinary case and what makes a shade worth having.
Where a shade is constructed, the origin is inferred and may not be written: shade e takes its origin from the depth of e, and letting a programmer write one there would let them claim an origin the value does not have.
Where a shade is received — a parameter, a struct field, a return type — the origin MUST be written. There is nothing to infer it from, and the claim is not believed: it is checked at every call site, which is the opposite of the situation the rule above guards against.
// Takes a shade from stratum 5. Its name may be carried anywhere; opening it
// needs `descend net`, wherever the caller is.
Cairn keep(Shade<Bytes@5> s) @0 { seal s }That is the whole of it. No new syntax: the depth annotation on a type already means "this value came from there", and a shade's argument is a type.
4.4 Statements
block := "{" { stmt } [ expr ] "}" ;
stmt := let_decl
| expr ";"
| "if" "(" expr ")" block [ "else" ( block | if_stmt ) ]
| "while" "(" expr ")" block
| "for" "(" [ let_decl | expr ] ";" [ expr ] ";" [ expr ] ")" block
| "return" [ expr ] ";"
| "break" ";"
| "continue" ";"
| block ;A block's optional trailing expr — with no semicolon — is its tail value. A block with no tail value has type U0.
4.5 Expressions
expr := assign ;
assign := logical_or [ assign_op assign ] ;
assign_op := "=" | "+=" | "-=" | "*=" | "/=" | "%="
| "&=" | "|=" | "^=" | "<<=" | ">>=" ;
logical_or := logical_and { "||" logical_and } ;
logical_and := bit_or { "&&" bit_or } ;
bit_or := bit_xor { "|" bit_xor } ;
bit_xor := bit_and { "^" bit_and } ;
bit_and := equality { "&" equality } ;
equality := relational { ( "==" | "!=" ) relational } ;
relational := shift { ( "<" | "<=" | ">" | ">=" ) shift } ;
shift := additive { ( "<<" | ">>" ) additive } ;
additive := multiply { ( "+" | "-" ) multiply } ;
multiply := unary { ( "*" | "/" | "%" ) unary } ;
unary := ( "-" | "!" | "~" ) unary
| "seal" unary
| "shade" unary
| "look" unary
| "opaque" unary
| postfix ;
postfix := primary { call_suffix | index_suffix | field_suffix } ;
call_suffix := "(" [ args ] ")" ;
index_suffix := "[" expr "]" ;
field_suffix := "." identifier ;
args := expr { "," expr } ;
primary := int_literal
| str_literal
| bytes_literal
| bool_literal
| cairn_literal
| identifier
| descend_expr
| block
| "(" expr ")" ;
descend_expr := "descend" identifier [ "!" ] block ;In descend_expr, no whitespace or comment MAY appear between identifier and "!" (for example disk! and net!).
4.6 Precedence
Highest to lowest. All binary operators are left-associative; assignment and the unary rites are right-associative.
| Level | Operators |
|---|---|
| 1 | () [] . |
| 2 | - ! ~ seal shade look opaque (unary) |
| 3 | * / % |
| 4 | + - |
| 5 | << >> |
| 6 | < <= > >= |
| 7 | == != |
| 8 | & |
| 9 | ^ |
| 10 | \| |
| 11 | && |
| 12 | \|\| |
| 13 | = and the compound assignments |
seal read(p) therefore seals the result of the call, not the function.
4.7 The bare-expression statement
"Hello from the nether\n";An expression statement whose value is not U0 deposits that value into the trace, tagged with its source span. It is not printed; nothing in Nether C is printed. See §6.8.
An implementation MUST NOT warn about a discarded value in this position. It is not discarded.
Types and the data model
5.1 Base types
| Type | Values | Canonical encoding |
|---|---|---|
U0 | exactly one, written () | the empty sequence |
Bool | true, false | one byte, 0x00 or 0x01 |
I64 | −2⁶³ … 2⁶³−1 | fixed 8 bytes, two's complement, big-endian |
Bytes | any finite byte string | length prefix, then the bytes |
Str | any well-formed UTF-8 string | as Bytes, over the bytes as given |
Cairn | a content address | 32 bytes |
Shadeᵈ⟨T⟩ | an opaque T from depth d | one byte origin stratum, then the 32-byte cairn of the value |
Answer⟨T⟩ | what the world said: a T, or a refusal | 0x07: one discriminant byte, then the T or the Refusal |
Refusal | one of six codes, and nothing else | 0x08: one byte, in the order §5.1.1 lists them |
I64 is the only integer type. There is no unsigned type, no char, no integer promotion and no implicit narrowing. Arithmetic wraps; an implementation MUST NOT make overflow undefined, because a canonical encoding cannot be built on top of behaviour that varies by compiler.
One integer width does not mean one interchangeable type. Conversions must be explicit; the language does not silently reinterpret a value.
5.1.1 Answers and refusals
Nether C has no exceptions and no error type. It has Answer⟨T⟩, which is what a function returns when the world is entitled to say no.
Answer⟨T⟩ ::= Given T | Refused Refusal
Refusal ::= absent the thing is not there
| denied it is there and you may not have it
| malformed it is there and it is not what it claims to be
| unreachable nothing answered
| exhausted a limit was reached: space, quota, size
| conflict something else changed it firstThe set of refusal codes is closed and fixed by this specification. An implementation MUST NOT add to it. They encode as 0x00 through 0x05, in the order written above, and that order is part of the format: see §7.1. The six names are bound in the prelude scope and compare by equality:
if (refusal(a) == absent) { /* ... */ }A Refusal carries a code and nothing else — no message, no platform error number, no path. Those things vary between operating systems, and a value whose encoding varies between operating systems cannot have a stable cairn, which would put a hole in section 07 large enough to sink every reproducibility claim in this document.
The detail is not lost. It is recorded in the witness, alongside everything else the world said (§1.4), where nether lamp can show it to a person and no program can branch on it.
A program may act on what kind of no it received. It may not act on how a particular kernel chose to phrase it.
An Answer is not only the world's: utf8 is at depth 0 and refuses malformed, having asked nobody anything, and a program builds either case with answered and refused (§9.2).
5.2 Aggregates
struct Header {
I64 len;
Bytes tag;
};
typedef I64[16] Row;Structs are nominal: two structs with identical fields are different types. Arrays are fixed-length when the length is written and slices when it is not.
There is no union type, and no pointer type at all. A value is reached by name, index or field; there is no way to name a location. This is not a safety feature bolted on — section 07 requires every value to have a content address, and an address that depends on where a value happens to live is not a content address.
5.3 Equality
Equality is structural and total: two values of the same type are equal exactly when their canonical encodings are equal, which is exactly when their cairns are equal.
An implementation MUST compare by cairn. This makes deep equality a 32-byte comparison, which is the main practical payoff of content addressing and is worth stating as a requirement rather than leaving as an optimisation.
Shade is comparable, and the rule above is the whole of it. A shade's origin stratum is part of its type and of its encoding (§7.1), so two shades are equal when they came out of the same stratum holding the same value. Comparing them does not count as looking at them, because it reveals only what seal on each would reveal anyway.
5.4 Mutation
Nothing in the ledger ever changes. A local, before it is in the ledger, is not in the ledger.
That is the whole of the rule, and the rest of this section is what it means.
A local is a binding inside a block. It may be assigned, and its fields and elements may be assigned, until it is named — and after that it may not. A local is named the moment its value is used as a value: sealed, shaded, deposited, returned, or passed as an argument. From then on its cairn exists, and nothing can change what a cairn names.
A global — a unit-level let — may not be assigned at all. There is no statement above it to do the assigning, and its initialiser is required (§4.2).
A local is named where its value is read directly. Arithmetic on it is not: t + 1 is a different value with a different cairn, and t's own name never existed. That is what makes for (I64 i = 0; i < n; i += 1) legal, and it is why the rule is about naming rather than about reading.
Watch the precedence. §4.6 puts the rites above arithmetic, so seal n + 1 is (seal n) + 1 and does name n. seal (n + 1) does not.
If any path through a block names a local, it is named for everything after that block. An implementation cannot know which arm will run, and the value is named on the one that does.
A loop body comes after itself, so a local named anywhere in one is named for the whole of it — including the lines written above the naming. The second turn's assignment is after the first turn's naming, and there is no third thing to say about it:
U0 turn(Bool c)
{
Bytes h;
while (c) { h = b"y"; Cairn k = seal h; } // error: named on the turn before
}Which leaves the counter, and the counter is fine: i += 1 assigns a local that arithmetic never named, so the rule above has nothing to freeze. That is the same distinction as three paragraphs up and it is the reason the rule is about naming rather than about reading.
An implementation SHOULD compile the assignments to in-place writes. No program can observe the difference, which is what makes it sound.
Reading a field or an element that has not been assigned collapses (§9.9). It is a mistake in the program and not a fact about the world: there is no value there and there never was one.
U0 build()
{
Header h;
h.len = 3; // legal: h has not been read yet
h.tag = b"nc";
Cairn c = seal h;
h.len = 4; // error: h was sealed at line 6
}This is also what makes a for loop work. Its step assigns the counter, which is a local and has not been named, so the loop advances without anything in the ledger changing.
The line is drawn at the ledger rather than at the function body, and it is worth being exact about why. The protected state is shared, addressable, permanent memory. A counter in a loop is none of those: nothing else can see it, it has no name, and it stops existing when the block does. Forbidding it would buy nothing and cost the language its loops.
Below, nothing changes. A local is not below yet.
5.5 Depth is not a type constructor
τ@d is a type paired with a depth, not a type of its own. In particular Bytes@3 and Bytes@0 are the same type at different depths: they unify, and unification takes the maximum.
Shadeᵈ⟨T⟩ is a distinct type, because a shade's whole purpose is to be something you cannot use as a T. Its d is written as the depth on T (§4.3) — Shade<Bytes@5> — and two shades of the same type with different origins are different types, because look on them is legal in different places.
5.6 Types are written; depths are inferred
Every binding carries its type. Struct fields, function parameters and return types, unit-level let declarations, and block-level ones. There is one let_decl production (§4.2) and it begins with a type, everywhere it appears.
Depth is inferred everywhere, and MAY be written anywhere a type is written. A written depth is a checked assertion: if inference produces a different one, that is an error naming both depths and the expression responsible.
That is the whole rule, and the two halves are not arbitrary. A type is a fact about what a value is, which the person writing the program knows and the reader wants told. A depth is a fact about where it came from, which is derived from everything it touched and is exactly the thing a person gets wrong. Writing what you know and deriving what you do not is the trade the language is making.
An earlier draft said types were inferred inside a function body, and there was no way to write such a binding: the grammar has one
let_decland it begins with a type. Adding a second form to get inference would have put a keyword in the language to save four characters, and maden = 0;mean a binding in one reading and an assignment in another. See §90.2.
Depth annotations must remain optional in ordinary code. Depth inference (buried) is tested by deleting every
@nfrom every sample program in this specification and requiring them all still to bury.
Burial, holes and replay
6.1 Burial
Burial is the only form of evaluation Nether C has. It takes source and a set of granted capabilities, and produces a trace.
bury : Source × Capabilities × Fuel → TraceBurial evaluates every expression it can and stops at every expression it cannot. It can evaluate a call when the capability that grants the call's stratum is among the granted ones and every argument has a value. It cannot when the world has not granted that capability, and every such point becomes a hole.
Granted capabilities are a set and one grants no other, on §2.1's reasoning. A burial holding net does not answer a read: the read is a hole owed to disk, and an exhumation that grants disk is what fills it.
A grant gates a call, and not a depth. An expression that reaches no prelude function is evaluated whatever depth it has, because there is nothing for the world to answer:
$ nether bury peek.nc
buried peek.nc → f51bdfe5 depth 0 holes 0 2 nodespeek.nc is demand descend disk { 1 + 1 };. It holds the disk and asks it nothing, so it is 2, and no capability was granted to get there. This is worth saying outright because it decides what §1.6's look costs: look s on a shade that already has a value reaches nothing either, and burial evaluates it with nothing granted. What the Orpheus rule buys is settled there.
A trace is complete and immutable. Burial MUST NOT modify a trace it was given; every burial produces a new trace with a new cairn.
6.2 Demand
There is no main. A file's top level is a sequence of declarations and demand statements, and nothing is evaluated except what a demand transitively requires.
Bytes@3 src = must(descend disk { read("main.nc") });
Bytes obj = compile(src); // pure, but starves: src is a hole
Bytes unused = compile(other); // never evaluated: nothing demands it
demand obj;must here says this file is not allowed to be missing. A program that wants to handle a missing file inspects the Answer instead (§9.9).
Evaluation is demand-driven. The implementation MUST NOT evaluate any expression that no demand depends on, transitively — not as an optimisation but as a semantic guarantee, because evaluating an undemanded expression could reach the world and leave a witness for something the program never asked for.
Where several demands exist, they are evaluated in source order. Within a single demand, evaluation is left to right and innermost first:
- a call evaluates the expression naming the function, then its arguments in order;
- an operator evaluates its left operand and then its right;
- a block evaluates its statements in order and then its tail;
ifevaluates its condition and then only the arm the condition chose, which is also what&&and||are (section 04);- a loop evaluates its body and then its step, once per turn;
- every other construct evaluates the one subexpression it has.
This is specified rather than left to the implementation because burial puts the order in the trace three times over. The order holes were discovered in is a field of the trace (§7.3). Which of several places asked a shared question first decides the span the hole keeps (§6.3). And which node is reached first decides where a fuel budget runs out (§6.4), since a step is charged when evaluation of a node begins. Two burials of the same source and the same capabilities MUST produce the same trace, and a trace that holds the order cannot do that while the order is anyone's business.
6.2.1 Burying in parallel
The order above is the order a trace records, not an order evaluation has to happen in. An implementation MAY evaluate on several threads, out of order, or ahead of need, on one condition:
Serial equivalence. A parallel burial MUST leave exactly the trace the order above would, and where that order would halt, it MUST halt with the same diagnostic at the same place.
What that fixes, because each is part of a trace or of what a burial reports:
- Holes, in the order the serial evaluation discovered them, and for a shared question the span of the place that asked it first (§6.3).
- Deposits, in the order they were made (§8.4).
- Witnesses, in the order the world answered (§6.6).
- The halt. If the serial order would collapse before it ran out of fuel, the burial collapses there; if it would run out first, it runs out at the step the serial order would have reached (§6.4). A collapse found ahead of need on another thread is not one the program reached until the serial order reaches it.
- The steps. The rite reports the steps the serial order spends, whatever the threads spent between them.
What is free:
- Pure work in any order, on any thread, including work that is thrown away. Evaluating ahead of need is §6.5's speculation by another name, and the same three refusals keep it invisible: it forms no hole, deposits nothing and collapses nothing until the serial order commits to it.
- The order objects reach the store. A store is a set (§7.5), and two writes of one object are one.
Nothing that reaches the world is free. A burial holds no capability, and exhume asks the world in the order its holes are recorded; asking two at once is a matter for §6.6, not for this section.
// order.nc — the order a burial leaves, which a parallel one must leave too.
// spec/06-evaluation.md §6.2.1.
//
// `b` is declared first and `a` is asked for first, so the holes are in the
// order the demand reached them and not the order they were written. The
// deposits are in demand order, with a starved demand between them.
Bytes@3 b = must(descend disk { read("b.txt") });
Bytes@3 a = must(descend disk { read("a.txt") });
U0 first() { "one\n"; }
U0 second() { "two\n"; }
demand first();
demand concat(a, b);
demand second();$ nether bury order.nc
buried order.nc → 22644e59 depth 3 holes 2 10 nodes
hole ① read("a.txt") stratum 3 disk
hole ② read("b.txt") stratum 3 disk
$ nether lamp 22644e59
one
twob is declared first and a is asked for first, so a is hole ①. The deposits are in demand order, with a demand that starved between them. A parallel burial that discovered b first, or deposited two first, has written a different trace.
6.3 Holes
A hole is a suspended world-question. An implementation MUST record, for each hole:
| Field | Meaning |
|---|---|
call | the prelude function and its fully-evaluated arguments |
stratum | the depth the call would reach |
span | the source location that asked |
A hole does not record what it depends on. It cannot depend on anything: a hole is only formed once every one of its arguments is a finished value, so nothing it needs can still be waiting on another hole. A field for it would be empty in every trace any burial could produce.
A hole does not record its dependents. It cannot: a node is immutable and named by its content, so a hole that listed the things waiting on it would get a new name every time something else came to wait, and every reference to the old name would be to a hole that no longer exists.
Which nodes are suspended on a hole is derived by reading the graph backwards, the same way provenance is, and for the same reason (§7.4).
A hole's arguments are themselves fully buried. read(concat(dir, name)) does not leave a hole containing concat; it leaves a hole containing the finished path string. A hole is always a question the world can answer immediately.
A hole is answered by whatever the world says, including a refusal. A refusal is an ordinary witness: it is recorded, it is served back on replay, and a trace whose program handled it replays identically to one whose program did not. Refusal does not make a trace incomplete and does not mark it.
Two holes with identical call fields at a read stratum in the same trace MUST be the same hole. The read strata are 1, 2, 3 and 5. This is what makes exhumation cheap: reading the same file twice is one question, asked once.
Such a hole keeps the span of the first place that asked, in the order §6.2 fixes. Which place that is, is therefore a fact about the program rather than about the implementation, and two burials of the same source agree on it. A hole is a question for the world, and the world does not care how many places were waiting on the answer.
Holes at 4, 6, 7 and 8 are never merged, however identical their calls. §1.8 is the reason and it is the whole of it: those strata are ordered where they are because of what they disturb rather than what they learn, and a thing that cannot be taken back cannot be done once and counted twice. Two posts to the same address with the same body are two messages, and §1.1 prices stratum 6 at the world remembers what was said. Two draws are two draws, or draw is a pure function of its argument and §9.7 is wrong to call it the only source of nondeterminism in the language. write and remove are the arguable ones — writing the same bytes twice changes nothing the second time — and they are not merged either, because a trace that describes fewer acts than the program performed is a trace that lies about what was done.
So a call can be asked more than once, and then it is answered more than once:
The answers to one call are served in the order §6.2 fixes — the *n*th hole that asks it takes the *n*th answer recorded for it. An implementation MUST NOT address an answer by the place that asked. A span is a fact about one text, a residue is printed and lowered again (§6.5), and an answer that could not survive that would break the staging law wherever the world had already said something.
At a read stratum there is one hole and one answer, and this says nothing new about it.
6.4 Starvation and fuel
An expression starves when it cannot be evaluated and cannot become a hole — because it depends, transitively, on a hole. Starvation is normal; a starved expression is residualised and waits.
An expression that can never produce a value has not starved. It has collapsed, and a burial that hits one caves in rather than waiting (§9.9).
Burial takes a fuel budget: a bound on the number of evaluation steps.
A step is one evaluation of one expression node. It is charged when evaluation of that node begins, before anything else happens to it, and it is charged once. Bulk byte operations (concatenation, slicing, hashing, sealing, depositing, UTF-8 decoding, structural equality on bytes/strings, and naming world-call arguments) also charge floor(bytes / 64) additional steps deterministically so large byte allocations cannot amplify work beyond the fuel budget. Three consequences, because each is a place two implementations could otherwise disagree:
- A unit-level binding is evaluated at most once, however many times it is named, and the steps its value costs are charged to the first demand that reaches it.
opaque ecosts one step andecosts nothing, becauseeis not evaluated.- A residue costs nothing for what has already been reduced, which is what makes the staging law in §6.5 affordable rather than merely true.
Fuel accounting MUST be deterministic — the same source and capabilities must exhaust at exactly the same point on every implementation and every machine. That is a requirement about agreement between implementations and not only with oneself, which is why the step is defined here rather than left to one. It rests on the evaluation order in §6.2 and not only on the definition of a step: a step is charged when evaluation of a node begins, so where a budget runs out is which node was reached first.
Exhausting fuel is a diagnostic, not a crash. The implementation MUST report the source span at which fuel ran out and the shape of what was being evaluated:
error: burial ran out of fuel after 1,000,000 steps
--> lib/table.nc:31:3
|
31 | for (I64 i = 0; i < n; i++)
| ^^^ unrolled 262,144 times; `n` is a literal, so this will not stop
|
= raise the budget with --fuel, or place an `opaque` barrier at line 29Burial has one other bound, and it is the implementation's own. Fuel is a bound on work; it is not a bound on space, and no single budget is both — a program can spend a million steps a thousand frames deep or a million steps two frames deep. So an implementation has limits of its own: how deep a chain of calls it can hold, how large a value it can address.
Reaching one MUST be reported the way exhausted fuel is — naming the limit, its value, and where it was reached — and MUST NOT be a crash. An implementation MUST state its limits.
Two implementations with different limits may therefore disagree about whether a given program buries at all. They MUST NOT disagree about the result when both of them finish, and that is the sentence the reproducibility claims in this document actually rest on.
opaque e evaluates to e but is never burned through: burial residualises it whole. It is how a programmer says do not evaluate through this, even though you could — for a loop that would unroll into a gigabyte, or a function whose specialised form would be larger than its general one.
opaque has a typing rule ([OPAQUE], section 02) rather than being a compiler flag, because whether an expression is burned through changes the trace, and anything that changes the trace belongs in the language.
This is settled. The rejected alternative — leaving both the budget and the barrier to the command line — is recorded in §90.2.
6.5 Residue
What survives burial is the residue: the program that is left once everything that could be evaluated has been.
A residue is a program, not a set of nodes. It has branches, loops, bindings and blocks in it — a while whose condition waits on a hole residualises whole, and so does the if around it — and none of those is a thing §7.3 knows how to store. Nor should it: a node records something that happened, and a residue is something that has not happened yet.
So a residue is written down the way programs are written down. It is source, in the syntax of section 04, held in the ledger as an ordinary Bytes value and named like any other. Burying it again means lexing, parsing and lowering it again, which is exactly what burying anything means.
An implementation MUST be able to print any residue it can produce, and lowering what it printed MUST give back the same program. Without that the staging law below is unprovable, because the second burial would not be burying the first one's residue.
The residue is a complete program. It can be buried again, with more capabilities, and the result is the same as if those capabilities had been granted the first time:
Staging law. For capability sets A and B,
bury(bury(p, A), B) ≡ bury(p, A ∪ B).
An implementation MUST satisfy this. It is what makes descent incremental rather than a single all-or-nothing act, and it is the property nether graft relies on.
Earlier drafts of this section counted nine hundred nodes for a program with one hole in it. That number was the residue being counted as nodes, which is the reading §6.5 rejects. A trace names its residue and does not contain it, so the count is small: the transcripts in §8.2 are what an implementation actually prints.
A call that starved. Burial reduces applications ([APP], section 02), and an application can fail to produce a value in two ways. They residualise differently, and the difference is what a residue can be specialised to.
An argument that is still waiting takes the call with it. The residue is the call as it was written, its arguments reduced as far as they went: §6.2's compile(src) is compile(src), because inlining the body would only put the same hole inside it.
When every argument is a value, burial evaluates the body. If the body finishes, the call is what it produced. If the body starves, the residue is the body, reduced as far as those arguments permitted, and not the call. The arguments were all values, so the reduced body needs none of them: it is written down as a function of no parameters and the call site names that.
An implementation MUST residualise a starved call whose arguments are all values as its reduced body, except where a residue keeps its depths says the call stays. Leaving the call as written is also a program and also correct, and it is not a residue: the next burial would redo the work this one already did, and nothing could ever be specialised to anything.
A block reduces its statements in order. A statement that finished and bound nothing is not in the residue — it has already happened, and what it deposited is already in the trace. Once a statement starves, that statement stays in place, with whatever it bound left as an unknown, and the statements and tail after it are reduced speculatively in place under the rules below. Statement order is kept: a return after a starved statement stays after it with its operand reduced, and nothing after that return is in the residue.
What this is for. Bury an interpreter against a program it is to interpret, with the program's own questions unanswered, and the residue does not name the interpreter's entry point. The syntax read before the first unanswered question is not read again. That is the first Futamura projection, and it is a consequence of this section rather than a feature of its own: a specialiser is what a partial evaluator is when it is pointed at an interpreter.
Reducing under an undecided branch
An if whose condition waits on the world residualises whole. Both arms survive, because which one runs is a thing only the answer settles. But the arms may be reduced where they stand, and so may the statements after a starved statement in a block, and an implementation SHOULD reduce both: without them a first projection stops at the first binding of an unanswered value or the first branch on it, which for an interpreter is the first one it reaches.
Reduction in both places is speculative, and a speculative reduction may produce a value or it may stop. It MUST NOT do anything else. Three things in particular:
- It MUST NOT form a hole. A world-question inside an undecided arm stops where it is and residualises, even where the other arm asks the same question and a hole for it already exists (§6.3). A trace that recorded it would be owed an answer to something the program has not asked.
- It MUST NOT deposit. A deposit is the program saying this value matters (§4.7), and an arm that may not run has not said it.
- It MUST NOT collapse. An out-of-range slice in an arm the world never takes is a mistake nothing reaches, and a burial that caved in on it would make whether a program buries depend on how far a specialiser got — which is what §90.2 refused when it refused
rescue. The reduction stops there and the arm residualises as it stands.
So speculation folds, and nothing it does is visible in the trace. What it leaves is a smaller program inside the same branch.
This does not weaken §6.2, which is the guarantee it looks like it touches. §6.2 forbids evaluating what no demand requires because such an expression could reach the world; the three clauses above are that reason, made into a rule. A reduction that cannot ask, cannot deposit and cannot collapse leaves nothing behind for §6.2 to be protecting.
Nor does it disturb the staging law. Reducing an arm does not change which arm is taken, so the composite trace is the one a single burial would have written. What differs is fuel, and a budget is not in a trace (§8.2) precisely because it is not part of what was produced.
What it costs. A specialised body can be larger than the general one, and there is one per call site that starved, each carrying the constants it was specialised to. Speculation adds to that: both arms of an undecided branch are reduced and only one will ever be taken, so the work is charged for a path that may not exist and the residue carries both.
The sharper cost is that a program which buries today may stop burying. An arm that never terminates is reduced until the budget runs out, and fuel exhausted is a halt with no trace at all (§6.4) — where before the arm simply residualised and nobody noticed.
That is a smaller loss than it reads as. Such a program only buried because the world answered the way that avoided the arm; had it answered the other way, the burial would not have finished either. Speculation turns a non-termination that was conditional into one that is certain, which is a bug found rather than a bug introduced.
opaque (§6.4) is the control for the case where it was meant, and is why that sentence is in §6.4. It is also the only control: there is no construct that makes burial reduce more, because everything here already reduces as far as it can and the one direction worth asking for is less.
A residue keeps its depths
A residue is a program, so it is checked like one, and it MUST check wherever the program it came from checked. Reduction may lower a depth (§2.4), and most of the time that is the point. [LOOK] is where it is not. Its premise is membership, d ∈ δ, not a ceiling (§1.6), and a depth that falls can fall out of what a look holds:
Bytes@5 g(Bool c) {
Bytes x;
if (c) { x = must(descend net { get("u") }); }
else { x = must(descend disk { read("f") }); }
descend net { look shade x }
}
demand g(false);One arm writes x from 5 and the other from 3, so x is 5 deep, the shade comes from 5, and descend net holds 5. The condition is decided, and taking the else arm leaves an x written only from 3. net does not hold 3. The program checks and the residue that reduction would leave does not.
The depth reaches the shade by more than one path. A local can lose the deeper of the arms that wrote it, as here. A call specialised to a constant can return less deeply than its function says. And in a unit built other than from §04 source, a branch can sit under the shade itself. So the rule is stated about depths, not about shade:
A residual that is not a value MUST NOT be shallower than the code it replaced. Where reducing would make it so, the code stays as written, with what it reads assigned first as in the rest of this section:
- A branch whose condition is decided stays whole, its condition reduced, when the arm not taken is deeper than the arm taken, or writes a local more deeply than the arm taken does.
- A starved call whose reduced body would return less deeply than the function stays the call, its arguments reduced.
A value is exempt. It is pure, and stratum 0 is in every δ (section 02), so no look can be refused for one.
What it costs. Less is specialised. A branch decided by a constant, with arms of different depths, is no longer folded, and a call that the constant would have made shallower is no longer minted. For an interpreter, that is a branch on a guest's syntax whose arms reach the world differently. The residue is larger, and the next burial decides the same branch the same way and leaves it the same, so the staging law is untouched.
The rejected forms of this rule are in §90.2.
6.6 Exhumation
Exhumation grants a capability, answers the holes it can, records every answer, and buries the residue again.
$ nether bury build.nc
buried build.nc → 76c4b655 depth 3 holes 1 4 nodes
hole ① read("main.nc") stratum 3 disk
$ nether exhume 76c4b655 --grant disk --root .
① read("main.nc") → 29 bytes 6940fecb
sealed 76c4b655 + 6940fecb → bb9ed429 depth 3 holes 0The result is a new trace with a new cairn. The original trace still exists, unchanged, and still has its hole. Nothing in the ledger is ever revised.
The new trace names the witnesses it recorded (§7.3). It has to: a witness records the call it answered and not the hole it answered, so a witness nothing names is a witness nothing can find, and §6.7 is re-burying with only the answers already recorded.
A trace with no holes is sealed. A sealed trace has a value.
Answering in parallel
A trace's holes list is in the order §6.2 discovered them, and the new trace's witnesses list MUST record the answers in that same order. An implementation MAY answer a contiguous run of read-stratum holes (strata 1, 2, 3 and 5) concurrently, under a fixed bound on how many questions are in flight at once, provided that:
- No hole at an act stratum (strata 4, 6, 7 and 8) overlaps any other hole. An act is answered alone, in sequence, after every hole before it in the trace has been answered and before any hole after it is asked, so a
readnever races awriteorremovein the same exhumation and twoposts ordraws never reorder. - Every answer is written to the ledger before it is returned (§1.4), and the witnesses and answers are committed to the trace and to the resumed burial in the order the holes were listed, whatever order the threads finished in.
- If a hole fails with a collapse or an unavailable provider, the rite stops at the first such hole in discovery order, cancels any hole after it in the run that has not yet been asked, and reports that first failure without writing a new trace.
Answering across machines
A trace's open questions MAY be partitioned across isolated machines whose stores exchange verified objects (§7.5.3, §7.5.4). Content addressing verifies the objects exchanged; it does not decide which question a witness answered or reconcile two machines that observed different answers from the world. An implementation that distributes hole answering across workers and merges their results into one trace MUST obey four rules:
- Assignment by hole slot. A trace's
holeslist is ordered by discovery (§6.2), and at act strata (4,6,7and8) two entries inholesmay share the samecallor the sameHolecairn (§7.3.1). A worker assignment for a base traceTis therefore a subset of slot indicesiin0..T.holes.len(), not a set ofCalls or deduplicatedHolecairns. A worker answers its assigned slots in ascending slot order, obeying the act-stratum sequencing and failure rules of §6.6 within its assignment, records each answer andWitnessnode in its own store before returning (§1.4), and delivers(i, w)pairs naming the slot indexiand the recordedWitnesscairnwalongside its store objects. - Answer identity. A delivered pair
(i, w)is valid forTif and only ifi < T.holes.len(),T.holes[i]decodes from the store asNode::Hole { call, stratum, span },wdecodes from the store asNode::Witness { stratum: w_stratum, call: w_call, answer, span: w_span },answerdecodes from the store as aValue, and(w_stratum, w_call, w_span) == (stratum, call, span). If any of those objects is absent or corrupt in the merging store (for example, after an interrupted transfer), or ifwdoes not matchT.holes[i], merging MUST fail rather than skip the slot. - Duplicate delivery and conflicts. If two deliveries (from a worker retry or overlapping assignments) supply the same
(i, w)— identical slotiand identicalWitnesscairnw— the duplicate delivery is idempotent and accepted once. If two deliveries supply(i, w_1)and(i, w_2)withw_1 != w_2for the same sloti, or if at a read stratum (1,2,3or5) two slots with the samecallwere given differentanswercairns, the workers observed conflicting answers. Merging MUST reject the conflict, naming the slot and both witness cairns, rather than picking one by arrival order. - Deterministic merge order and capability-free assembly. Merging holds no world capabilities (§6.7). Starting from
T.witnesses, it appends the verified witnessw_ifor each answered slotiin strict ascending slot order0..T.holes.len(), regardless of the order in which workers finished or delivered their bundles, feeds each answered slot's(call, value)in that same ascending slot order to the resumed burial ofT.residue, and leaves any unanswered slot open.
When the union of worker assignments covers 0..T.holes.len() with the same recorded answers as a single serial machine, the merged trace is byte-identical to the serial trace and satisfies §6.7's replay law. No equality is promised when workers independently sample nondeterministic or mutable worlds without agreeing on the recorded answers, and content addressing does not prevent a retried act-stratum worker from repeating an external effect before its witness reaches the coordinator.
6.7 Replay
$ nether exhume bb9ed429 --replay
identical.Replay re-buries a trace using only the answers already recorded in the ledger. The implementation MUST hold no capabilities at all during replay: it does not prefer the ledger over the world, it cannot reach the world.
Replay law. Replaying a sealed trace produces a trace with the same cairn, unless the original trace is marked as having reached stratum 8.
This is why a trace does not record what its burial spent (§8.2). Replay buries a residue that is already folded, which costs less than folding it did, so a trace holding that number could never come back as itself.
"Identical" means byte-identical under the canonical encoding of section 07 — not merely equal in value. A trace that replays to a different cairn is a bug in the implementation, and nether exhume --replay MUST report the first differing node rather than only the mismatch.
Stratum 7 (entropy) does not break replay: the drawn value is a recorded witness like any other, and replaying serves it back. What entropy breaks is re-derivation — burying the same source again produces a different trace — which is a different and weaker property that Nether C does not promise for programs that reached stratum 7.
Stratum 8 breaks replay outright, because there is no witness to serve back. See §1.7.
6.8 What burial prints
Burial prints a summary of what it wrote, and nothing else:
buried <source> → <cairn> depth <n> holes <n> <n> nodesIt MUST NOT print any value the program deposited. A program's deposits are read with nether lamp (section 08), by a person who decided to go and look. A Nether C program cannot leak to a log: it holds no capability that reaches one.
The ledger
The format is the contract. Everything else in this specification is negotiable; an ambiguity here is a reproducibility bug that will be found years from now by somebody who cannot fix it.
7.1 Canonical encoding
Frozen. Every value has exactly one encoding, on every platform, forever. Changing anything in this section changes the domain separator in §7.2, which changes every cairn that has ever existed. Treat it as immovable and mean it.
A value is a tag byte followed by a payload. There is no length prefix on the value as a whole and no terminator: every payload's extent is determined by the tag and by lengths inside it.
| Tag | Type | Payload |
|---|---|---|
0x00 | U0 | empty |
0x01 | Bool | one byte, 0x00 or 0x01, and nothing else |
0x02 | I64 | eight bytes, two's complement, big-endian |
0x03 | Bytes | u64 length, then exactly that many bytes |
0x04 | Str | u64 length, then exactly that many bytes of well-formed UTF-8 |
0x05 | Cairn | thirty-two bytes |
0x06 | Shade | one byte origin stratum, then the thirty-two byte cairn of the value |
0x07 | Answer | one byte, 0x00 given or 0x01 refused, then the value or the refusal |
0x08 | Refusal | one byte, 0x00..0x05, in the order §5.1.1 lists them |
0x10 | Struct | u64 name length, the name in UTF-8, u64 field count, then the fields |
0x11 | Array | u64 element count, then the elements |
0x20 | Node | see §7.3 |
Rules an implementation MUST follow:
- Integers are fixed-width big-endian. There is no variable-length integer encoding anywhere in the format, including lengths.
- Lengths and counts are
u64big-endian, even where the value is small. Eight bytes to say0is the price of there being one encoding. - Struct fields are encoded in declaration order, not alphabetical order, and the struct's type name is encoded with it. Nominal typing means the name is part of the value.
- There is no map type, and therefore no question of key ordering. An association is an array of pairs, and its order is the program's.
- There is no floating-point type. See §3.6.
- The encoder does not transform what it is given. It does not normalise text, reorder anything, or trim anything. A store that silently alters the bytes you handed it is not content-addressed; it is content-addressed to something else. See §7.1.1.
7.1.1 What a decoder MUST reject
Lenient decoding of a canonical format is how two implementations start disagreeing, so rejection is specified rather than left to judgement. A decoder MUST reject:
- a tag byte not in the table above;
- a
Boolpayload other than0x00or0x01; - a
Strpayload that is not well-formed UTF-8; - a
Shadeorigin byte greater than8; - an
Answerdiscriminant other than0x00or0x01; - a
Refusalcode greater than0x05; - a
Structwhose name is empty, or whose name is not well-formed UTF-8; - any length or count that exceeds the bytes remaining;
- trailing bytes after a complete value.
A decoder MUST NOT accept an input and then re-encode it differently. For every byte string b that decodes to a value v, encode(v) MUST equal b. That round trip is the definition of canonical and is the property worth testing first.
7.2 Cairns
cairn(v) = blake3( DOMAIN || encode(v) )
DOMAIN = b"netherc/cairn/v4\x00"A cairn is 32 bytes. Its text form is lowercase hexadecimal. Tools MAY display a prefix; the first 8 hexadecimal characters are the RECOMMENDED short form, and any tool that accepts a short form MUST reject an ambiguous one rather than picking a match.
The domain separator is versioned. Changing what an existing tag means changes the domain, which changes every cairn, which is the correct and honest consequence: values encoded under different rules are not the same values.
Adding a tag that was previously unassigned does not. A decoder under v1 rejected 0x07 as unknown and still does not accept anything it accepted before; every byte string that had a meaning keeps exactly the meaning it had. Nothing is reinterpreted, so nothing is renamed.
This is the narrower rule, and it is narrower because the broad one made the format unable to grow without discarding everything ever written under it. §90.2 records what was given up to narrow it.
The domain is at v4. It has moved three times, every time because Trace changed what it holds (§7.3.1): to v2 when a residue stopped being nodes, to v3 when a trace began naming its witnesses, and to v4 when it stopped recording what the burial spent. Each is the bumping case and not the exempt one — a byte string that decoded to a trace under one domain decodes to a different trace under the next, and the two are not the same value however similar they look. Nothing had been buried any of those times, so the bumps cost nothing. That is the only reason they were affordable, and it is why the rule is worth having before it is not.
7.3 Nodes
A node is the unit the ledger stores. Every node is content-addressed by its cairn.
| Node | Contents |
|---|---|
Literal | a value |
Apply | a function cairn, argument cairns, and the resulting value cairn |
Hole | the fields listed in §6.3 |
Deposit | a value cairn and the source span that deposited it |
Witness | a stratum, a call, the answer, and the span that asked |
Trace | the residue, the holes, the witnesses, the deposits, the source, the depth, and the stratum-8 mark |
Nodes reference other nodes only by cairn. The graph is therefore acyclic by construction: a node cannot name a node that does not yet exist, and a node that exists cannot change.
7.3.1 Node encoding
Frozen, on the same terms as §7.1. A node is the tag 0x20, then a kind byte, then the kind's payload.
| Kind | Node | Payload |
|---|---|---|
0x00 | Literal | one value |
0x01 | Apply | cairn of the function, cairn-list of arguments, cairn of the result |
0x02 | Hole | call, one byte stratum, span |
0x03 | Deposit | cairn of the value, span |
0x04 | Witness | one byte stratum, call, cairn of the answer, span |
0x05 | Trace | cairn of the residue source, cairn-list of holes, cairn-list of witnesses, cairn-list of deposits, cairn of the source buried, one byte depth, one byte stratum-8 mark |
Three shapes appear inside more than one of them:
| Shape | Encoding |
|---|---|
cairn-list | u64 count, then that many thirty-two byte cairns |
span | cairn of the source, u64 start, u64 end |
call | u64 name length, the name in UTF-8, cairn-list of arguments |
A Trace's three cairn-lists are not all the same kind of list, and the difference is worth stating because both readings decode.
The deposit list holds one entry per deposit the program made, and may name the same cairn more than once. A value deposited a thousand times from one span is one
Depositnode — same value, same span, so one content address — and a thousand entries. The node is what the program said; the list is what it did, and §4.7 makes a bare expression statement an act of the program rather than a declaration about it.The hole list holds one entry per question the burial left open, and is the same kind of list for the same reason. At a read stratum two asks are one hole and one entry; at 4, 6, 7 and 8 they are two acts and two entries, and two acts written in one place are two entries naming one node. §6.3 is which of those a given pair is.
A decoder MUST reject, in addition to the clauses in §7.1.1:
- a kind byte not in the table above;
- a stratum or depth greater than
8; - a stratum-8 mark other than
0x00or0x01; - a
callwith an empty name; - a
spanwhose end is before its start.
A span names its source by cairn rather than by path. A path is a fact about one machine at one moment; the trace has to mean the same thing on a machine that has never seen that filesystem.
7.3.2 What a decoder cannot check
A Trace's depth is how deep it goes, counting both directions at once: the join of the depth of its residue, the greatest stratum of any Hole it names, and the greatest stratum of any Witness it names.
All three are needed and no two are enough. A stage-one burial has answered nothing, so its witnesses say 0 and its residue and holes say how deep the program still reaches — which is why §8.2's transcript reads depth 3 over a program with one unanswered read. A sealed trace has no holes left, so its residue says 0 and its witnesses say how deep it went — which is why §6.6's reads depth 3 holes 0. One rule, both transcripts.
seal is the case that rules out the residue alone. §1.5 makes seal e depth 0 whatever e is, so a program that reaches the world only through a seal demands something pure and still owes a hole:
// owed.nc — a trace that owes the network. spec/07-ledger.md §7.3.2.
//
// The fetch is demanded only through a seal, and §1.5 makes a seal pure, so
// the residue is at depth 0 and the hole is at 5. The trace's depth is the
// join of both.
Bytes@5 page = must(descend net { get("https://example.invalid/x") });
Cairn c = seal page;
demand c;$ nether bury owed.nc
buried owed.nc → 71301eea depth 5 holes 1 4 nodes
hole ① get("https://example.invalid/x") stratum 5 netThat trace cannot take a step without a network fetch, and calling it pure would be the strongest claim the language makes, made falsely.
opaque is the case that rules out the holes alone: a world-question inside an opaque barrier is never evaluated and never becomes a hole, and the expression is still at its stratum.
The stratum-8 mark is the other half of §1.7 and is not the same test. It is set exactly when a Witness the trace names is at stratum 8 — reached, not owed. A trace whose only stratum-8 call is still a hole has depth 8 and is not marked, because nothing has happened off the record yet.
Neither claim is checkable on put. A decoder sees one node, and both are facts about a graph that may not be wholly present. An implementation MUST NOT be required to enforce them there. §8.6 is where the hole and witness halves are caught, because strata is the rite that has the whole graph in hand. The residue half needs lowering the residue, which is burying it, and that is bury's job rather than strata's.
7.4 Provenance
Provenance is not a separate index. It is the Apply and Witness nodes themselves, read backwards: given a value's cairn, the ledger can find every node that produced it, and from those, their inputs, down to literals and holes.
An implementation MUST maintain a reverse index sufficient to answer what produced this cairn in time proportional to the answer, not to the size of the store. nether lamp --provenance is unusable otherwise, and it is the rite that makes the language comprehensible.
7.5 The store
The store is a set of (cairn, bytes) pairs, where the bytes are the canonical encoding of a value or a node. Both have cairns and both are addressed the same way: a Deposit names the value it deposited directly, rather than naming a Literal node that wraps it.
put(stored) -> Cairn idempotent
get(Cairn) -> Stored fails if absent
has(Cairn) -> Bool
resolve(hex_prefix) -> Cairn | Ambiguous | Absentput MUST be atomic: a reader MUST never observe a partially written node. An implementation SHOULD write to a temporary path and rename.
Because writing is idempotent and content-addressed, concurrent writers need no coordination beyond atomicity of the individual write. Two burials that compute the same value write the same bytes to the same place.
7.5.1 What survives a crash
A store is crash-consistent and not durable. A put that returned may not be on the disk after a power loss, and an implementation MAY fsync but is not required to.
What a store MUST NOT do is serve bytes that are not what the name says. That is what makes the weaker promise enough. After a crash an object is in one of two states, and both are safe:
- absent, which is indistinguishable from never having been written, and which a later
putrepairs by writing it again; - present and wrong, which
getcatches, because the name is the content and checking costs one hash of bytes it has already read.
So a crash can lose work and cannot manufacture a fact. That is the property the reproducibility claims in this document rest on, and it is weaker than durability on purpose: a build tool that paid for an fsync per node would pay it thousands of times for a single burial, to protect work it can simply do again.
An implementation MUST NOT skip the check in get on the grounds that it fsyncs. The check is against bit rot and a bad disk as much as against a crash, and those do not announce themselves.
The reverse index of §7.4 is a set of fixed-size records. An implementation MUST detect a partial one rather than read past it — a record half written is a record that would otherwise be read as a different cairn, and a wrong edge in a provenance walk is worse than a missing one.
7.5.2 What a damaged store can still tell you
get checks one object when something asks for it. A read-only audit of the whole store walks every entry on disk without modifying anything and separates four kinds of damage:
- Corrupt objects — files under
objects/whose names are valid cairns and whose bytes either do not decode or do not hash to that name. - Missing references — cairns named by the forward references of a verified node (§7.4) that are absent from
objects/. - Malformed filenames — entries under
objects/orrefs/whose path is not a two-hex-digit fan-out directory followed by a sixty-two-hex-digit file. - Derived-index errors — ragged files in
refs/(§7.5.1) or forward edges of verified nodes that are missing fromrefs/.
Which traces are affected MUST be derived from verified forward edges and not from refs/: a broken reverse index does not damage a trace, and a missing reverse edge would hide one that is damaged. When a trace's holes, witnesses or deposits list names a corrupt or absent node, what that node in turn referenced cannot be read, and the audit MUST mark the trace's reachability as incomplete rather than claiming its listed faults are the whole of what was lost. Healthy objects and healthy traces remain readable while damaged ones are reported.
7.5.3 A second store, and what they owe each other
Two stores under the same domain separator (§7.2) have a set-difference problem and nothing else: a cairn is either present or absent, and if it is present and verified (§7.5.1), it names the same canonical bytes in both.
Possessing or naming a cairn establishes byte identity and nothing else:
- It does not establish availability. A store holding a
Tracenode may lack the nodes or values its lists name (§7.3.2). - It does not establish authentication or mutation authority. Knowing a cairn is not permission to write to another store, and a store that accepts writes from a peer does so under its own capability gate, never because the peer knew a name.
- It does not establish agreement about what the world said. Two stores that exhumed the same stage-one trace against different worlds hold different
Witnessnodes and therefore different sealedTracecairns. Reconciling them keeps both traces and both witnesses without conflict, because their cairns differ.
Root closure and bounded comparison
Reconciliation is defined over an explicit set of root cairns $R$, never over an unrooted enumeration of a peer's store. For a verified object at cairn $c$, its immediate forward references $\operatorname{refs}(c)$ are empty when $c$ decodes to a Value (0x00..0x11) and are the cairn fields of its payload (§7.3.1) when $c$ decodes to a Node (0x20). The root closure $\operatorname{cl}(R)$ is the least set containing $R$ and closed under $\operatorname{refs}$. Because the node graph is acyclic by construction (§7.3), $\operatorname{cl}(R)$ is finite.
An exchange proceeds top-down in bounded rounds from a frontier Queue initialized to $\{r \in R \mid \neg\text{has}(r)\}$:
- Domain handshake. Both sides state their domain separator (
netherc/cairn/v4\x00, §7.2). A peer speaking any other domain MUST be refused before any cairn is requested or any object is read (§7.7). - Bounded
wantbatch. The requester pops at mostMAX_WANT(1,024) full 32-byte cairns from its frontier and asks the peer for them. - Bounded response. For each requested cairn $c$ in batch order, the peer checks its own copy via
get(c)and replies with either:object(c, bytes), wherelen(bytes)does not exceedMAX_OBJECT_BYTES(64 MiB + 64 KiB, §7.5.4), orabsent(c)if the peer does not hold $c$. A peer whose local copy of $c$ fails verification MUST NOT transmit the corrupt bytes; it MUST treat $c$ as locally corrupt and refuse to serve it.
- Receiver verification and frontier expansion. For each
object(c, bytes)received, the requester MUST:- reject the response if $c$ was not in the current
wantbatch or iflen(bytes) > MAX_OBJECT_BYTES; - decode
bytesunder §7.1.1 and §7.3.1, verifyingencode(decode(bytes)) == bytes; - verify
cairn(bytes) == cunderDOMAIN; - commit
(c, bytes)viaput(§7.5), which derives the local reverse index entries inrefs/before atomically placing the object inobjects/; - for each $d \in \operatorname{refs}(c)$ with $\neg\text{has}(d)$, push $d$ onto the frontier.
- reject the response if $c$ was not in the current
Only canonical objects are exchanged. The reverse index refs/ (§7.4) and burial memo (§8.2.1) MUST NOT be transmitted or accepted from another store; every receiver derives its own index from objects it has verified itself.
Interruption, resume and discovery privacy
Because each verified object is committed atomically via put before its children enter the frontier, an interrupted exchange leaves the receiving store clean (§7.5.2) with a verified upper prefix of $\operatorname{cl}(R)$ already on disk. Repeating the exchange for $R$ tests has at each step, skips the prefix already present, and asks only for the remaining frontier.
A peer answers only about full 32-byte cairns named in a want batch. Prefix resolution (resolve, §7.2) and store-wide listing are local operations and MUST NOT be answered for an untrusted peer, so a stranger cannot enumerate private traces by probing two-character fan-out prefixes. Asking want(c) still discloses to the peer that the requester knows the cairn $c$ (§90.3).
Strata of exchange
Reading objects from a second directory on the local filesystem is a stratum-3 (disk) read coupled with a stratum-4 (disk!) write to commit verified objects into the receiving store. Fetching missing objects from a remote store over a socket is a stratum-5 (net) read coupled with stratum 4 (disk!) locally. Actively pushing (send) objects to a remote store is a stratum-6 (net!) act, because it alters state outside the machine and cannot be unsent (§1.8).
Exchange transcripts
Four transcripts fix the observable behaviour across equal, partial, divergent and hostile peers:
# 1. Equal stores: local already holds cl({efed9b2a}) (6 objects)
domain netherc/cairn/v4
root efed9b2a
round 0 want 0 (6 already present)
result reconciled efed9b2a: 6 present, 0 fetched, 0 absent# 2. Partial peer: local has nothing; peer holds efed9b2a but lacks witness 9a40c112
domain netherc/cairn/v4
root efed9b2a
round 0 want [efed9b2a]
recv object efed9b2a (Trace, verified)
round 1 want [61a6cc41, 9a40c112, 3f08d119, 8106589a]
recv object 61a6cc41 (Bytes, verified)
recv absent 9a40c112
recv object 3f08d119 (Deposit, verified)
recv object 8106589a (Bytes, verified)
round 2 want [04e2b771]
recv object 04e2b771 (Str, verified)
result incomplete efed9b2a: 5 fetched, 1 absent (9a40c112)# 3. Divergent stores: two exhumations of 76c4b655 with different world answers
domain netherc/cairn/v4
roots efed9b2a 4c19e08d
round 0 want [4c19e08d] (efed9b2a already present: 6 objects)
recv object 4c19e08d (Trace, verified)
round 1 want [d17a8803, 5b2209ce] (residue 61a6cc41 and source 8106589a shared)
recv object d17a8803 (Witness, verified)
recv object 5b2209ce (Deposit, verified)
round 2 want [7e91a440]
recv object 7e91a440 (Bytes, verified)
result reconciled 2 roots: 6 shared, 4 fetched, 0 absent# 4. Hostile peer: serves tampered bytes for 21ca4ef0 (hash is b8019f44)
domain netherc/cairn/v4
root 76c4b655
round 0 want [76c4b655]
recv object 76c4b655 (Trace, verified)
round 1 want [61a6cc41, 21ca4ef0, 8106589a]
recv object 61a6cc41 (Bytes, verified)
recv object 21ca4ef0 -> refused: corrupt from peer (asked 21ca4ef0, found b8019f44)
result aborted 76c4b655: peer served corrupt bytes for 21ca4ef0 (2 committed, 21ca4ef0 not written)7.5.4 Moving a store
Moving a store to another machine by copying its directory copies refs/, memo/ and tmp/, none of which is canonical, and verifies nothing at the destination. A portable bundle carries only verified canonical objects in a single self-checking stream:
BUNDLE = DOMAIN # b"netherc/cairn/v4\x00" (17 bytes, §7.2)
|| b"bundle\x00" # 7-byte stream marker
|| u64_be(count) # number of objects in the bundle
|| ENTRY * count
|| blake3(all preceding bytes) # 32-byte whole-stream trailer
ENTRY = cairn (32 bytes)
|| u64_be(len) # byte length of canonical payload
|| payload (len bytes)- Export (
export). Walksobjects/, verifies every object against its cairn and the canonical decoder (§7.1.1, §7.3.1), and refuses to export if any object is corrupt or any filename underobjects/is malformed (§7.5.2). Verified objects are emitted in topological dependency order (every referenced object in the store before the nodes that reference it, with ties broken lexicographically by cairn) so any prefix of the stream is closed under in-store forward references.refs/,memo/andtmp/are omitted. - Import (
import). Checks the 24-byte header, refusing an unknown magic or a mismatched domain version (§7.7) before reading entries. For each of thecountentries,importenforceslen <= MAX_OBJECT_BYTES(64 MiB + 64 KiB framing) before allocating, rejects duplicate cairns and out-of-order forward references within the bundle, verifies canonical decoding andcairn(payload) == cairn, and stages raw verified entries intmp/without retaining decoded ASTs in RAM. After allcountentries are read,importverifies the 32-byteblake3trailer over the entire stream and requires end-of-stream with no trailing bytes before committing any object to the destination store:- if the destination store does not yet hold
cairn, viaput(§7.5), which writes deduplicated reverse edges torefs/first and atomically renames the object intoobjects/; - if the destination store already holds
cairn, by verifying the existing on-disk object directly without overwriting it, and ensuring all of its reverse edges are present inrefs/.
- if the destination store does not yet hold
- Interrupted or truncated import. Because raw verified entries are staged in
tmp/and committed only after the whole-stream trailer checks, an import that is truncated, tampered with, or has trailing bytes commits nothing and removes its staging file, leaving the destination store unchanged and clean (§7.5.2). Because committed entries are emitted in leaves-before-referrers order, a crash mid-commit still leaves a verified, dependency-closed prefix; re-runningimportverifies the already-present prefix in place without overwriting it and commits the remainder.
7.5.5 Packages
A package is an ordinary canonical Struct value (§7.1, tag 0x10) stored in the ledger and addressed by its cairn. There is no central registry and no version-range solver: a dependency is the exact cairn of another package value, and resolution is an offline lookup in a verified store.
A package root is a Struct with type name "Package" and three fields in declaration order:
| Field | Type | Meaning |
|---|---|---|
domain | Str | "netherc/cairn/v4" — the canonical domain (§7.2, without the trailing NUL) under which the package and its closure were formed |
entrypoint | Cairn | the cairn of a Bytes value in the store holding the package's well-formed UTF-8 source unit (§3.1) |
deps | Array of Struct "Dep" | direct dependencies, sorted in strictly ascending byte order of alias |
Each element of deps is a Struct with type name "Dep" and two fields in declaration order:
| Field | Type | Meaning |
|---|---|---|
alias | Str | local human-readable alias (non-empty, unique within this package's deps) |
cairn | Cairn | exact 32-byte cairn of the dependency "Package" value |
An implementation that writes or resolves a package MUST enforce five rules:
- Canonical dependency order. Within a
"Package"value,depsMUST be ordered by strictly ascending UTF-8 bytes ofaliaswith no empty or duplicatealias, so a given entrypoint and dependency set have exactly one encoding and one cairn. - Local aliases, global cairns. An
aliasis local to the"Package"value that declares it. Two packages in one closure MAY bind the same alias to different dependency cairns or different aliases to the same dependency cairn; global identity is always the 32-bytecairn. - Compatibility check. Before walking
entrypointordeps, resolution MUST check thatdomainequals"netherc/cairn/v4". A package whosedomainnames any other version (§7.7) MUST be refused explicitly as incompatible rather than interpreted. - Offline closure and topological order. Resolution reads every reachable
"Package"andentrypointBytesobject from the local store viaget(§7.5.1), walkingdepsdepth-first indepsorder and emitting each distinct package cairn once in topological post-order (every dependency before the packages that depend on it, ending with the root package). The resolved source unit is the concatenation of each package's verifiedentrypointbytes in that topological order, inserting a single\nbyte between consecutive non-empty entrypoints when the preceding bytes do not already end with\n, addressed by the cairn of the resultingBytesvalue. - Explicit failure on missing, corrupt or malformed objects. A cairn establishes byte identity, not availability. If the root package, any transitive dependency package, or any
entrypointBytesobject is absent from the store, fails verification onget, is not a well-formed"Package"or UTF-8Bytesvalue, or forms a dependency cycle, resolution MUST fail explicitly naming the offending cairn and reason. It MUST NOT fetch from the network or substitute an empty unit.
7.6 Garbage
There is none.
A content-addressed store of immutable values has no unreachable objects, only objects nothing currently points at — and the entire premise of the language is that something might point at them later. Deleting a node destroys a provenance chain that another trace may depend on, and there is no way to know that it does not without reading every trace that will ever exist.
An implementation MAY provide an explicit, operator-invoked prune with a stated reachability root. It MUST NOT prune automatically, and it MUST NOT prune Witness nodes at all: a witness is the only copy of something the world said once and may never say again.
This is a real cost, stated plainly: a Nether C store grows monotonically. Whether that is affordable is a question the roadmap item Measure a year of a real store (0210) has to answer with measurements rather than opinions.
7.7 Versioning
The format carries no version field inside a node. The version is the domain separator in §7.2.
An implementation encountering a cairn it cannot verify under its own domain MUST report that the node was written under a different format version and refuse it. It MUST NOT attempt to interpret it. There is no migration path between format versions and there is not meant to be one: a value encoded under different rules is a different value, and pretending otherwise would make every reproducibility claim in this document conditional.
The rites
Six verbs. The one that is missing is the point.
8.0 There is no run
An implementation MUST NOT provide a command that executes a Nether C program without producing a trace, under any name.
nether run MUST exit with code 64 and explain what to use instead.
$ nether run hello.nc
nether: there is no `run`.
A Nether C program is not executed. It is buried — evaluated as far as the
world allows — and what remains is a trace and the holes the world still
owes an answer to.
You probably want:
nether bury <file.nc> to evaluate it
nether exhume <cairn> to answer its holes
nether lamp <cairn> to see what it left behindIt is spelled out here, in the specification, so that it is a rule rather than a joke, and so that anyone proposing to add it has something to argue against.
This requirement is frozen alongside §7.1 and §7.3.1.
8.1 Common behaviour
Every rite:
- accepts
--jsonand, when given it, writes a single JSON object to stdout and nothing else; - writes human-readable output to stdout and diagnostics to stderr;
- treats a cairn argument as a full cairn or an unambiguous hexadecimal prefix, and MUST fail on an ambiguous prefix rather than choosing;
- names a source position by the cairn of the source and not by a path, because that is all a span holds (§7.3);
- exits with a code from §8.8.
No rite writes to the ledger except bury, exhume and graft, and each of those writes before it prints.
8.2 bury
nether bury <file.nc> [--fuel <n>] [--json]Evaluates the pure part of <file.nc> and writes a trace; prints a summary of what was written.
$ nether bury build.nc
buried build.nc → 76c4b655 depth 3 holes 1 4 nodes
hole ① read("main.nc") stratum 3 diskbury holds no capabilities, so every world-touching expression becomes a hole. This is the only default that cannot surprise anyone. Answering holes is exhume's work, where --grant names one capability at a time and one capability implies no other (§2.1). Passing --grant to bury MUST be refused (exit code 64) rather than accepted and ignored: a flag that validates its argument and changes nothing looks like it worked, which is the failure §8.0 is about in a smaller place.
--fuel sets the budget of §6.4. Its default MUST be finite, and the rite MUST report what it was when asked.
It is not recorded in the trace, because it cannot have affected one. Running out of fuel produces a halt and no trace at all (§6.4), so a budget has exactly two outcomes: the burial finished, or there is nothing to record it in. A budget that did not bind left no mark, and a budget that bound left no trace.
Nor is what the burial spent, and for the same reason one step further on. How many steps a burial took is a fact about that burial rather than about the program it produced, and a trace that recorded it could not be replayed: §6.7 asks a sealed trace to come back byte-identical, and replaying buries a residue that is already folded, which is a cheaper burial. A rite reports what it spent, because that is where it is a fact.
8.2.1 Burying what is already buried
A burial with no --grant is a function of two things: the source, and the implementation burying it. Nothing else can reach it — it holds no capability, and §6.4 makes its fuel deterministic — so burying the same bytes twice with the same implementation produces the same trace, to the cairn, and the second time is work the first already did.
An implementation MAY remember. It keeps a memo from the pair (its own identity, the source's cairn) to the trace that burial wrote and the steps it spent. The memo is an index in §7.4's sense, not part of the ledger: it holds no fact the store does not, and losing it loses time and nothing else.
Its identity MUST change whenever what it would bury could, and a version number nobody remembered to bump does not. The cairn of the implementation's own executable is one that cannot be forgotten.
A remembered burial MUST be indistinguishable from a fresh one in everything but time:
- It is honoured only if the trace is there. The memo names a cairn, and
geton it MUST return aTracewhosesourceis that source and which names no witness. Anything else is a stale entry, and the rite buries. - It is honoured only within budget. A fresh burial that needed more steps than
--fuelallows halts at the step where the budget ran out, and §6.4 requires every implementation to halt there. So a memo whose steps exceed the budget is not honoured, and the burial runs out exactly where it would have. - It reports what the burial costs. The steps the rite reports are the ones recorded, which are the ones a fresh burial spends, so two implementations agree on them whether or not either remembered. The rite MUST also say that it remembered, because that is the fact about this invocation.
- It writes nothing new. Everything the trace names is already in the store, or the first rule refused the entry.
Burying §8.2's program a second time:
$ nether bury build.nc
buried build.nc → 76c4b655 depth 3 holes 1 4 nodes remembered
hole ① read("main.nc") stratum 3 diskBurial still holds no capability. Reading a memo is the rite consulting its own index before it buries, the way writing the trace afterwards is the rite and not the program; the program asks the same questions of the same world either way, and a burial with a --grant is never remembered, because the world it asked may answer differently next time.
8.3 exhume
nether exhume <cairn> [--grant <cap>]... [--declare <name>=<value>]...
[--clock <seconds>] [--target <triple>] [--root <path>]
[--reach <host>]... [--load <path>]... [--replay] [--json]Grants capabilities, answers holes, records every answer, re-buries the residue, and writes a new trace.
--replay grants nothing and serves only from the ledger. It MUST fail rather than reach the world if an answer is missing, and it MUST report the first node whose cairn differs from the original.
--grant and --replay are mutually exclusive.
8.3.1 Declaring an environment
The three flags are the declaration §9.4 puts outside the program. They are the whole of what env may answer from, and an implementation MUST NOT read the process environment, the wall clock or the host triple to fill any of them in.
--declare MAY be given any number of times, including with an empty value: --declare CC= declares CC and leaves it unset, which is the refusal §9.4 distinguishes from the collapse. A name given twice is an error rather than a last-one-wins, because the two invocations differ and only one of them can be what was meant.
--clock is whole seconds since the Unix epoch and --target is a triple, and both are required whenever env is granted. There is no default. A default would be the host's, and a rite whose answer depends on which machine ran it is the thing §6.7 exists to prevent.
Granting env and declaring nothing is legal and means an environment in which every name is undeclared. Declaring without granting env is an error: the declaration could not be read, so accepting it would be §8.0's failure in a smaller place.
8.3.2 Declaring a reach
--reach names one host net and net! may open a socket to. It MAY be given any number of times, and a host nobody named is denied (§9.6).
The reasoning is the one an implementation already applies to the disk. §09 says nothing about where a path is rooted, and an implementation that rooted it nowhere would be one nobody could grant a capability to; a socket is the same argument with a longer reach. --grant net says which stratum, and --reach says how far.
A host is a name and optionally a port: example.com, or example.com:8080. Without a port it matches whatever port the URL asks for, because the port is a detail of the service and the host is the party being trusted. It matches that host exactly — a subdomain is a different party, and a reach that spread to one would be a reach nobody declared.
That default is the widest thing any flag in this section does, and it is worth saying rather than implying: --reach example.com permits 22 and 25 and 6379 on that host as readily as 443, and the program chooses which. What it declares is the party trusted, not the service used. An operator who means one service writes the port, and §90.2 records the narrower default that was considered.
Granting net and reaching nothing is legal and means a network with nothing in it, which is the right default for the same reason as no --grant at all. Reaching without granting net is an error, on §8.3.1's reasoning.
8.3.3 Declaring what may be loaded
--load names one shared object unrecorded may load. It MAY be given any number of times, and a symbol found in nothing named is denied.
A symbol is looked for in the objects in the order they were given, and the first that has it answers. Order is the invocation's and not the loader's, because two objects that both define a symbol is a question only the person running the rite can settle.
Granting unrecorded and loading nothing is legal and means no foreign code, which is the one case where the useless invocation is also the safe one. Loading without granting unrecorded is an error, on §8.3.1's reasoning.
This is the same argument as §8.3.2 in the place it matters most. A stratum-8 call that may load any object on the machine is ambient authority, and §1.7 already says this stratum is the one that has to be quarantined loudly.
8.3.4 Declaring a root
--root names the one directory disk and disk! resolve every path against. It is required whenever either is granted, and there is no default, on §8.3.1's reasoning: the only default available is the directory the rite happened to be run in, and a rite whose answer depends on where it was run is what §6.7 exists to prevent. Rooting without granting disk is an error, on the same reasoning again.
This is the flag §8.3.2 was already arguing from. It makes its case for --reach by pointing at the disk — §09 says nothing about where a path is rooted, and an implementation that rooted it nowhere would be one nobody could grant a capability to — and then the disk was the one capability the invocation could not bound. Two implementations answered read("main.nc") differently while the hole's call was byte-identical, and §6.3 makes that call the whole of what the question is.
A path is resolved against the root and MUST NOT climb out of it. A path that would — .., an absolute path, a drive letter — is denied and not absent: the file may well be there, and what refused is this build. That is §9.9's distinction, and §9.5 gives both refusals to every path-taking function for exactly this.
Textual resolution is not enough on its own, and an implementation MUST also refuse a path that leaves the root through a symbolic link. Nothing textual can see one, and a program buried with disk! can make one for itself to read back through.
--root MAY be given once. A path does not name its root the way a URL names its host, so a second root makes every path ambiguous and a write undecidable — which is why --reach repeats and this does not.
8.4 lamp
nether lamp <cairn> [--provenance] [--depth <n>] [--json]Carries light down. With no flags, renders the value at that cairn — including every Deposit node in a trace, in the order they were made, which is how a program's output is read.
That order is the trace's own deposit list (§7.3.1). A trace exhumed from another names the earlier trace's deposits first and then what burying its residue deposited, each in evaluation order, so the list is the order they were made in. lamp MUST NOT reorder it. Two spellings of one program that make the same deposits read the same, whatever their sources' cairns are.
$ nether lamp efed9b2a
Hello from the netherA value deposited more than once is rendered more than once. The trace holds one entry per deposit (§7.3.1) and lamp renders one line per entry, so a loop that deposits on every turn reads as the program wrote it rather than as the ledger stored it:
$ nether lamp cbd2ade7
tick
tick
tick
tick--provenance walks backwards instead: from a value to the nodes that produced it, to their inputs, to the literals and holes at the bottom.
$ nether lamp 21ca4ef0 --provenance
21ca4ef0 hole read("main.nc") stratum 3
└─ trace depth 3 residue 61a6cc41 1 hole(s) 0 witness(es) 0 deposit(s)That is the walk over the trace from §8.2, which has a hole and no answers yet: the hole, and the trace waiting on it. Once §8.3 has recorded a witness the same walk reaches it, which is what §7.4 means by the forward edge read backwards — a hole records no dependents and does not need to.
lamp is a tool the operator carries, not a capability the program holds. A program cannot invoke it, cannot reach a terminal, and has no way to know whether anyone is looking. This separation makes it structurally impossible for a Nether C program to leak to a log.
8.4.1 Inspecting a byte offset in an editor
nether lamp <cairn> --at <byte> [--source <path>] [--depth <n>] [--json]Inspects an already buried Trace node at a 0-based UTF-8 byte offset <byte> into its source (§7.3). An editor adapter calls this rite instead of reimplementing the depth checker or running a stateful language server.
- Named source versus stale buffer. A trace's spans are byte offsets into the
Bytesvalue named bytrace.source. When--source <path>is given,lamphashes the bytes at<path>as a canonicalBytesvalue (§7.1) and compares that cairn againsttrace.source. If the two cairns differ, the editor buffer is stale with respect to the trace, andlampMUST refuse with exit code 1 naming both short cairns rather than guessing shifted offsets. - Absent objects and bounds.
lampreads theBytesvalue attrace.sourcefrom the store. Iftrace.sourceor any reachable trace node covering<byte>is absent or corrupt,lampMUST fail reporting the store error with §8.8's store exit codes (66absent,65malformed). If<byte>is at or past the byte length oftrace.source, or falls outside every expression in the unit,lampMUST fail with exit code 1 rather than clamping the offset. - Depth, origin and provenance from the compiler and ledger.
lampruns the parser, lowerer and depth checker ontrace.sourceand reports for<byte>:- the innermost expression whose byte span
start..endcontains<byte>, its derived depth0..8, its type, and its byte spanstart..end; - the innermost enclosing
descend κspan (if any) and the deepest call inside the expression (if any) responsible for its depth; and - any recorded
Deposit,HoleorWitnessnode under<cairn>whosespancovers<byte>, together with its cairn, summary and backward provenance walk (§7.4) up to--depth <n>.
- the innermost expression whose byte span
8.5 cairn
nether cairn <path> | --verify <cairn> [--json]Names a thing by its content, or checks that a name still holds. --verify MUST report what differs, not merely that something does.
8.6 strata
nether strata <cairn> [--json]Blame for depth. Reports the deepest stratum a trace reached and the source span that took it there.
$ nether strata 76c4b655
depth 3 disk
3 read("main.nc") 8106589a:10:35 pending
0 everything else
replayable: yes
of that, 0 (pure) has happened; the rest is what exhuming will cost.Holes are reported apart from witnesses, because they are not the same depth: a hole is a stratum the trace will need and a witness is one it reached (§7.3.2). A trace that has answered nothing has reached nothing, and that is the line under the list rather than the number above it: the transcript is one of those traces — one read, still pending — and its number is what §7.3.2 says a trace's depth is.
If the trace is marked as having reached stratum 8, or if any witness under it reached stratum 8, strata MUST say so without being asked, and MUST report replayable: no. A hole or a witness deeper than the recorded depth, or a stratum-8 witness under a trace whose unrecorded mark is false, is a malformed trace (§7.3.2), and strata MUST reject it with exit code 65.
A trace's claims fall into three classes:
- Derivable from verified objects in the store: the
Tracenode and every node reachable from it are checked against their content addresses onget(§7.5.1);stratawalks forwardnodes()edges and never the reverse index. From the nodes present, it checks the hole and witness halves ofdepth, theunrecordedmark against reachableWitnessnodes, and the openholeslist. The residue half ofdepthand the well-formedness ofresidueandsourceare checked whenexhumere-buriesresidue. - Bounded by missing objects, refused on corrupt ones: a store does not require a trace's entire graph to be present (§7.3.2). When a reachable node is absent,
stratareports how many nodes are missing and states that its survey is a lower bound rather than an unqualified certificate. When a reachable node is present and fails verification onget, that is a corrupt object (§7.5.1) rather than an absent one, andstrataMUST fail with exit code 65 instead of counting it as missing. - Externally trusted: content addressing proves a
Witnessnode is intact and names thecallandanswercairns it was written with; it cannot prove the writer obtainedanswerfrom the world rather than inventing it. Checking the world's answer means re-runningexhumeagainst the world or comparing witnesses across independent stores.
"Why is this value at depth 5" has to be a command, not an investigation.
8.7 graft
nether graft <cairn> --replace <cairn> --with <cairn> [--json]Answers a hole differently and re-buries only what changed, which §6.5 guarantees is sound. --replace names a hole the trace still has, and --with the value to answer it with.
A graft replaces a hole and nothing else. If --replace names an answer the trace was already given, graft MUST refuse and exit 1: that answer has been consumed, what it produced is in the trace's deposits rather than its residue, and burying the residue again cannot change them. To answer it differently, graft or exhume the trace that still has the hole.
graft MUST report how many nodes were reused and how many were recomputed. That ratio is the whole argument for content addressing, and a build tool that hides it is asking to be trusted rather than measured.
8.8 Exit codes
| Code | Meaning |
|---|---|
| 0 | success |
| 1 | the operation failed for a stated reason |
| 64 | usage error, including run |
| 65 | the source or trace is malformed |
| 66 | a cairn was not found in the ledger |
| 69 | not implemented in this build |
| 70 | internal error; this is a bug |
| 75 | fuel exhausted |
| 77 | a capability was needed and not granted (reserved for strict-grant modes; exhume without matching grants reports unchanged and exits 0) |
The prelude
Every function's signature carries the stratum it costs. Reading this section is how a programmer finds out what a thing will do to their program's depth, so nothing here may be deeper than it must.
The prelude is deliberately small. It should be readable in full in ten minutes.
The listings below are a notation and not a program. A signature and a semicolon is not something section 04 parses — func_decl wants a block — and there is no production for one because nothing a program can write would supply a body for read. They are here the way a header file is here: to be read.
9.1 Capabilities
These are the names descend accepts. An implementation MUST NOT define others.
Each grants its own stratum and no other. The table is a bijection — one capability per stratum, one stratum per capability — which is what lets §2.1 treat a set of capabilities and a set of strata as the same object.
| Capability | Stratum | Grants |
|---|---|---|
store | 1 | reading the ledger by cairn |
env | 2 | the frozen environment |
disk | 3 | reading files |
disk! | 4 | creating and modifying files |
net | 5 | fetching |
net! | 6 | sending |
entropy | 7 | true randomness |
unrecorded | 8 | foreign code |
The ! suffix marks the writing half of a pair, and reads as it does in the rest of the language: this one does not take back.
9.2 Depth 0
I64 min(I64 a, I64 b) @0;
I64 max(I64 a, I64 b) @0;
I64 abs(I64 x) @0;
I64 len(Bytes b) @0;
Bytes slice(Bytes b, I64 from, I64 to) @0;
Bytes concat(Bytes a, Bytes b) @0;
Bool starts_with(Bytes b, Bytes p) @0;
Answer<Str> utf8(Bytes b) @0; // Refused malformed
Bytes raw(Str s) @0;
Str join(Str[] parts, Str sep) @0;
Str[] split(Str s, Str sep) @0;
Cairn cairn_of(Bytes b) @0; // the same value `seal` would give
Str hex(Cairn c) @0;
Refusal absent; denied; malformed; // the six closed codes,
Refusal unreachable; exhausted; conflict; // bound as prelude constants
Bool given(Answer<T> a) @0; // did the world say yes?
Refusal refusal(Answer<T> a) @0; // which no was it? collapses if given
T must(Answer<T> a) @0; // the value. collapses if refused
Answer<T> answered(T v) @0; // a yes a program built
Answer<T> refused(Refusal r) @0; // a no a program builtgiven and refusal are how a program handles a no. must is how it declares it will not: this cannot be refused, and if it is, that is a bug and I want the burial to stop. It is the right thing to write when a refusal would mean the program's assumptions were already wrong, and the wrong thing to write anywhere else.
There is no pattern matching in this draft, so an answer is inspected the way C has always inspected one:
Answer<Bytes>@3 a = descend disk { read("main.nc") };
if (given(a)) {
Bytes@3 src = must(a);
// ...
} else if (refusal(a) == absent) {
// ...
}answered and refused go the other way, so a function a program writes can hand its caller the shape utf8 hands it, and say no without collapsing:
// verdict.nc — a function that says no the way the prelude does. §9.2.
Answer<Bytes> first(Bytes b)
{
if (len(b) == 0) {
return refused(absent);
}
return answered(slice(b, 0, 1));
}
U0 report()
{
Answer<Bytes> a = first(b"nether");
Answer<Bytes> none = first(b"");
if (given(a)) { concat(must(a), b"\n"); }
if (refusal(none) == absent) { "nothing there\n"; }
}
demand report();$ nether lamp 0909a5ab
n
nothing thereanswered takes its T from its argument, the way the three inspectors do. refused has no T to take: a refusal is a code and nothing else. It takes the one it is declared into, so it MUST be the whole value of a binding or a return whose declared type is an Answer. Anywhere else it is an error, because anywhere else nothing says what it is a refusal of:
$ nether bury unlanded.nc
error: expected a declared `Answer<T>` for `refused`
--> unlanded.nc:1:24
|
1 | Answer<Bytes> x = must(refused(absent));
| ^^^^^^^^^^^^^^^Both are at depth 0 and neither records a witness. Nothing was asked, so there is nobody whose answer §1.4 would be recording — the same reason utf8's malformed has none.
compile is not in the prelude. Nether C does not know how to compile Nether C until Self-Burial; until then it is an ordinary function a program supplies for itself.
9.3 Stratum 1 — store
Answer<Bytes> fetch_node(Cairn c) @1; // Refused absent
Bool has_node(Cairn c) @1;Reading the ledger is at depth 1 rather than 0 because the ledger is a place on a machine, and a program that reads it can fail in a way a pure program cannot. The value it returns is nevertheless fully determined by the cairn, which is why it is only one stratum down.
9.4 Stratum 2 — env
Answer<Str> env(Str name) @2; // Refused absent
I64 clock() @2; // the pinned build time
Str target() @2; // the target tripleenv distinguishes two different mistakes. Reading a variable that was declared and is not set is a refusal: the world was asked and said no. Reading a variable that was never declared is not a refusal, it is a bug in the program, and it collapses (§9.9).
Neither returns empty. A build that silently behaves differently because a variable was absent is exactly the class of bug this language exists to make impossible.
The declaration lives outside the program, in the exhumation that answers the hole: §8.3.1 is the invocation.
A trace records every value read from it, as a Witness like any other, and does not record the declared set. It does not need to. A read produces a witness; a refusal is an answer and is witnessed the same way; and a name that was never declared collapses, which produces no trace at all. So everything the declaration did to the program is already named by the trace, and what is left over is a name the program never read — which changed nothing, and which two cairns therefore must not be made to differ by.
9.5 Strata 3 and 4 — disk, disk!
Answer<Bytes> read(Str path) @3; // absent, denied
Answer<Str[]> list(Str path) @3; // absent, denied
Bool exists(Str path) @3;
Answer<U0> write(Str p, Bytes c) @4; // denied, exhausted
Answer<U0> remove(Str path) @4; // absent, deniedread becomes a hole; the answer is sealed and recorded before it reaches the program. write is the first genuinely irreversible thing the language can do, and the only prelude function whose witness records something the ledger cannot later reproduce on its own.
Where a path is rooted is not said here. It is the invocation's, and §8.3.4 is where an operator says it — which is also where denied comes from for a path that would climb out, as against the absent of a path that is simply not there.
9.6 Strata 5 and 6 — net, net!
Answer<Bytes> get(Str url) @5; // unreachable, denied, absent
Answer<Bytes> post(Str url, Bytes b) @6; // unreachable, denied, conflictThe response is sealed on arrival, with the request as its witness. Replay serves the recorded response and MUST NOT open a socket.
A URL names a scheme, and an implementation MUST state which schemes it serves. It is not required to serve all of them: https is TLS, and an implementation that wrote its own would be writing its own cryptography. One that will not serve a scheme MUST refuse it with denied rather than unreachable, because those are different sentences — denied is this build saying no, and unreachable is the world not answering. A trace would otherwise record "the host was down" for a build that never dialled.
Where an implementation may reach at all is §8.3.2, and is a fact about the invocation rather than about the language.
9.7 Stratum 7 — entropy
Bytes draw(I64 n) @7;draw is the only source of nondeterminism in the language, and it is nearly the deepest thing in it.
Entropy is stratum 7: the deepest recordable thing. Once drawn bytes affect a trace, the source alone is not enough to re-derive it. Replay needs the recorded answer.
A trace that called draw records the drawn bytes as a witness, so replay is exact. What is lost is re-derivation: burying the same source again produces a different trace. See §6.7.
9.8 Stratum 8 — unrecorded
Answer<Bytes> call_foreign(Str sym, Bytes args) @8;Marks the trace, permanently and transitively. Everything downstream of the call is at depth 8 and the trace can no longer claim to be replayable.
An implementation MUST make this unpleasant to reach for — at minimum, naming the symbol in nether strata output — because a stratum-8 call is a hole in the record that no later care can fill in.
What may be loaded at all is §8.3.3.
9.8.1 The other side
sym names a function with C linkage and this signature:
int32_t sym(const uint8_t *args, size_t args_len,
uint8_t *out, size_t out_cap, size_t *out_len);That is C, not Nether C. It is here the way a header file is here: to be read, and written against.
It is handed the Bytes the program passed, and a buffer to write its answer into. It MUST set *out_len to the length of its answer whether or not the answer fit, and MUST NOT write more than out_cap bytes. It returns:
| Value | Meaning |
|---|---|
0 | the answer is in out, and is *out_len bytes |
1 | out_cap was too small; *out_len is what is needed |
2..7 | a refusal, in the order §5.1.1 lists them |
| anything else | malformed |
On 1 the implementation MUST call once more with a buffer of at least *out_len, and MUST NOT call a third time: a callee whose answer grows every time it is asked is a callee that never finishes.
Neither side frees the other's memory. The buffer belongs to the caller for its whole life, and args belongs to the caller too — a callee that keeps either pointer after it returns has kept a pointer to something it does not own, and no wording here can stop it. That is what stratum 8 is, and it is why §1.7 marks the trace rather than trying to make the call safe.
An implementation MUST NOT assume anything else about the callee. In particular it MUST record the witness before the call, so that a callee which does not return leaves a trace saying what was attempted.
9.9 Failure, and the difference between two of them
Nether C has no exceptions and no unwinding. Unwinding has no meaning in a language where evaluation is demand-driven and partially staged, and a stack that can be unwound is a stack that can be observed.
It has two things instead, and the whole of failure handling is knowing which one you are looking at.
A refusal is an answer
When the world is asked a question it is entitled to answer no to — the file is not there, the response never came — that no is the answer. It is a value, of type Answer⟨T⟩, and it is recorded as a witness exactly like a yes.
This is not a concession to practicality. It follows from §1.4: everything the world says gets written down before the program sees it. A missing file is something the world said. Replay serves it back, and a program that handled it replays identically.
The world is where most refusals come from and it is not where the type comes from. utf8 is at depth 0 and refuses malformed: bytes that are not UTF-8 are a fact about bytes the program already had, nothing was asked of anybody, and there is no witness because nothing happened. A program's own parser is in the same position, and §9.2 gives it the same two constructors rather than leaving the prelude able to do something a program cannot. What Answer⟨T⟩ says is that this can be refused and which no it was; where the no came from is what the stratum says, and a depth-0 refusal is one nobody owes a witness for.
A collapse is a bug
An expression collapses when it cannot produce a value and never will: must on a refusal, refusal on a given answer, an out-of-range slice, env on a variable that was never declared.
A collapse is not catchable. There is no rescue, no try, no recovery form, and there will not be one. A burial that hits one caves in: it stops and reports the source span, because every way to collapse is a mistake in the program rather than a fact about the world, and a mistake that can be caught is a mistake that will be ignored.
A collapse is not a starvation, which is what an expression does while it waits on a hole (§6.4). That is ordinary: a starved expression is residualised and finishes later, at somebody else's exhumation. A collapsed one never finishes.
What it costs
Every call site that touches the world gets a check, or an explicit must that says a check is unnecessary. Code that reads six files reads as six answers.
That is the bargain C has always offered — if (fp == NULL) — and Nether C is a C dialect, so it offers the same one rather than a better-looking one that hides where the world can say no. The rejected alternatives are in §90.2.
Glossary
Every term used normatively elsewhere, defined once.
Ambient capabilities (δ) — the set of strata whose capabilities are currently held. Holds 0 and nothing else at the top level; added to only by descend, which adds the one it names. §2.1
Answer — what a function returns when the world is entitled to say no: either the value, or a refusal. Not an error type; a record of what was said. §5.1.1
Bury — to evaluate a program as far as the granted capabilities allow, producing a trace. The only form of evaluation in the language. §6.1
Cairn — the content address of a value: blake3 over its canonical encoding, under a versioned domain separator. Always at depth 0. §7.2
Capability — a named grant of access to one stratum of the world. Acquired by descend, lexically scoped, never ambient. §9.1
Collapse — what an expression does when it can never produce a value: must on a refusal, an out-of-range index. Not catchable, and a burial that hits one caves in. §9.9
Demand — a top-level statement naming an expression that must be evaluated. Nothing else is evaluated. There is no main. §6.2
Deposit — a value left in the trace by a bare-expression statement. Not printed; read afterwards with lamp. §4.7
Depth (d) — how far into the world a value's history reaches, 0 to 8. A claim about where a value has been and not about what it can be made to reveal (§1.5). Part of the value's type; composes by maximum; never decreases. §1.1
Descend — the expression that acquires a capability for the extent of a block. One-way within the block; only the tail value leaves. §1.3
Exhume — to grant a capability, answer a trace's holes, record the answers, and re-bury the residue, producing a new trace. §6.6
Fuel — the deterministic bound on evaluation steps a burial may take. Exhausting it is a diagnostic naming a span. §6.4
Graft — to substitute a subtrace by cairn and re-bury only what changed. §8.7
Hole — a suspended world-question: the call, its stratum, and its span. A hole does not record its dependents. Identical calls at a read stratum (1, 2, 3, 5) are one hole; calls at act strata (4, 6, 7, 8) are never merged. §6.3
Lamp — the rite that renders a value or walks its provenance. A tool the operator carries; never a capability the program holds. §8.4
Latent set (dƒ) — the capabilities a caller must already hold to apply a function. Carried in its arrow type, written as a trailing @n or @{n,m} on its signature, and not what the function reaches: that is a fact about a trace and no rule consumes it. §2.1
Ledger — the content-addressed store of nodes. Immutable, append-only, not garbage-collected. §7
Look — to open a shade. Well-typed only where the ambient capabilities hold the stratum the shade came out of, and not merely a deeper one: the Orpheus rule. §1.6
Node — the unit the ledger stores, addressed by its cairn: a literal, an application, a hole, a deposit, a witness, or a trace. §7.3
Opaque — a barrier burial will not evaluate through, even where it could. A typing rule, not a flag. §6.4
Orpheus rule — you may carry a shade up out of any stratum; you may only look at it by going back down. §1.6
Provenance — the backwards reading of the apply and witness nodes: what produced this value, and what produced that. §7.4
Refusal — one of six closed codes — absent, denied, malformed, unreachable, exhausted, conflict — and nothing else. The detail lives in the witness so that the value stays portable. §5.1.1
Replay — re-burying a trace with no capabilities at all, serving every answer from the ledger. Produces the same cairn, or reports the first node that differs. §6.7
Residue — what survives a burial: a complete program in source form (§4), not a set of nodes, held in the ledger as Bytes so it can be buried again. §6.5
Rite — one of the six commands: bury, exhume, lamp, cairn, strata, graft. §8
Seal — to take the cairn of a value. Always yields depth 0, because a name is pure regardless of what it names — which is also the shortest demonstration that depth confines provenance and not secrecy. §1.5
Sealed trace — a trace with no holes. It has a value. §6.6
Shade — a value carried up out of a deeper stratum, opaque: storable, sealable, comparable, not observable. §1.6
Starve — to be unevaluable yet, because of a transitive dependence on a hole. Ordinary: a starved expression is residualised and finishes at somebody else's exhumation. Unevaluable ever is a collapse. §6.4
Stratum — one of the nine depths, each with a grant, a cost and a witness obligation. §1.1
Trace — the immutable, content-addressed record a burial produces. §6.1
Unrecorded — stratum 8: foreign code whose behaviour cannot be witnessed. Marks a trace permanently. §1.7
Witness — the record an implementation must write before returning a world-derived value to the program. §1.4
Rationale
Non-normative throughout. Nothing here constrains an implementation.
This section exists because a design document that lists only advantages is marketing. For each core choice: what Nether C does, why, and what it cost.
90.1 Core design choices
There is no run
Ordinary C dialects compile and execute a program on demand, coupling build and execution for immediacy. Nether C separates evaluation from execution: burial is partial evaluation, and the trace holds the residue and any unanswered holes.
What it cost. Immediacy. There is no REPL and there cannot be a good one, because the thing a REPL is for — see the effect now — is precisely what this language refuses to do. The Necropolis browser view is the compensation, and it is a worse experience than a REPL for the things a REPL is best at.
A bare expression deposits rather than prints
"Hello\n"; is a complete statement, and it still means this value matters. It simply deposits into the ledger instead of writing to a terminal.
What it cost. printf debugging. The first thing every programmer does in a new language is print something, and in Nether C that takes two commands instead of one. This is the single largest ergonomic tax in the design, and it is charged on the first thirty seconds of every newcomer's experience.
The defence is that it buys the strongest property in the language: a program holds no capability that reaches a log, so it cannot leak to one. Whether that trade is worth it is genuinely arguable, and if Nether C fails to find users, this is the most likely reason.
Entropy sits at stratum 7
Nether C puts randomness at depth 7 — nearly the deepest recordable stratum — because drawn bytes are the one act that makes a program impossible to re-derive from source and environment alone. You can replay a recorded draw, but you can never reproduce it without its witness.
What it cost. Every program that uses randomness carries depth 7 on every value derived from it and must record its witnesses in the ledger to remain replayable.
Nine strata instead of ambient authority
Rather than granting ambient access to the machine, Nether C partitions authority into a nine-stratum lattice and records the deepest stratum reached in every value's type.
What it cost. Speed of expression. You write what you mean, discover it is at depth 5, and go back to add a descend. Depth inference is what keeps this from being intolerable, and if inference is not good enough the language is not usable.
Immutable ledger values
Everything written to the ledger is shared, content-addressed, and immutable. Nothing in the ledger can be revised.
What it cost. Every algorithm that wants an in-place update. §5.4 permits building an aggregate before it is first read, which covers construction but not, say, a hash table that is updated a million times. A Nether C program that needs one will be slow, and the honest answer today is that such a program should be written somewhere else and called at stratum 8.
The ledger graph is canonical
Nether C makes the text disposable and the graph canonical. The source is one rendering of the program; the trace is what actually exists.
What it cost. Charm, so far. The ledger graph is a better substrate for diffing, provenance and reproducibility, and it is still more austere to look at than a rich interactive document format. The Necropolis (web/necropolis/) closes part of that gap locally in a browser, though visual richness remains work in progress.
The Decay Rule
The trusted core may only ever get smaller — checked in CI and recorded in .decay-ceiling.
A fixed size ceiling keeps a system from sprawling; a monotonically decreasing ceiling is more demanding.
90.2 Rejected alternatives
The Orpheus rule: two rejected forms
Scope re-stain. look raises the depth of the whole enclosing scope to the shade's origin. Mythologically exact — turning around costs you everything — and it produces errors nobody can read: one look deep inside a function poisons every caller, and the diagnostic points at the caller rather than the cause.
Binding taint. Only the bound value takes the depth. Tractable, familiar, and it reduces shade to a newtype: if looking is free, nothing has been carried.
The rule in §1.6 — you may only look by going back down — was chosen because it is a local check rather than a propagation, gives an error that names the exact fix, and keeps the myth intact. Orpheus could have kept her; what he could not do was look on the way up.
proof/orpheus.py checks both halves of [LOOK]'s premise d ∈ δ:
- Sufficiency:
d ∈ δimplies bothmax(d, d′) ≤ max(δ ∪ g(s))whend′ ≤ max(δ ∪ g(s))(preserving §2.4's ambient soundness) and{d} ⊆ δ ∪ g(s)(preserving per-stratum capability confinement). - Necessity and the non-interval counterexample: for a closed shade value (
g(s) = {},d′ = 0), capability confinement{d} ⊆ δis equivalent tod ∈ δ, whereas the numeric ceilingmax(d, 0) ≤ max(δ)of §2.4 alone is equivalent tod ≤ max(δ). Whenδis not a downward-closed interval — for exampled = 3(disk) andδ = {0, 5}(net) —3 ≤ max({0, 5})holds (3 ≤ 5) while3is not in{0, 5}. Requiringd ∈ δrather thand ≤ max(δ)is therefore stronger than §2.4's numeric ceiling alone and exactly what §1.6's per-capability rule requires. Dropping the premise altogether (binding taint) fails even §2.4 (d = 3, d′ = 0, δ = {0}), and pushing{d} ⊆ dƒonto the enclosing function (scope re-stain) combined with[APP]'sdƒ ⊆ δ_callerstill forcesd ∈ δ_callerat every call site.
A residue that lowers a depth
§6.5 leaves code as written where reducing it would lower a depth. The monotone soak found the case it answers: a residue that the checker refused, from a program the checker accepted, because a look asked for a stratum the shallower residue no longer came from. Three other answers were weighed.
Keep only a branch under shade. The narrowest fix, and it misses two of the three paths. A call specialised to a constant can return from 3 where its function returns from 5, and a local can lose the arm that wrote it deeply. Both reach a shade with no branch under it.
Let a residue state a shade's origin. Syntax for shade@5 e, so that a reduced operand keeps the origin it had. That is a program stating a depth its operand does not have. §5.6 makes a written depth a checked assertion, and an error where inference gives another, so a residue would be allowed to say what a program may not.
Change [LOOK] to a ceiling. d ≤ max(δ) is monotone, so a falling depth could never fall out of it. It is rejected above, with numeric_vs_membership_counterexample as the reason: under net, a ceiling lets a program look at what came from the disk.
The rule chosen costs specialisation, which §6.5 states. It is a rule about what a residue may be, so it holds whatever path the depth takes.
What a grant gates: a call, or a depth
§6.1 said burial could evaluate an expression "when the expression's depth is within the granted capabilities". Read as written, that leaves a whole class of expression with no outcome. descend disk { 1 + 1 } under no grant is at depth 3 and not within nothing, so burial cannot evaluate it; §6.3 forms a hole only from a prelude call with finished arguments, and there is no call; and §6.4 starves only what waits on a hole, and there is none. It has not collapsed either — it produces 2, and will the moment anybody asks. Three rules, no answer. look on a shade that already has a value is the same shape.
The alternative was to make it a fourth outcome: an expression that is deep, ungranted and not a call is neither evaluated nor a hole, and §6.5 would say it residualises as the descent written out, since there is nothing inside it to reduce. That is coherent and it buys nothing. The burial would be refusing to fold arithmetic on the grounds that somebody once wrote descend disk around it, and the residue it produced would fold on the next burial for a reason unrelated to anything the world said.
So a grant gates a call. What is owed to the world is a question, and an expression that asks no question is not owed anything.
That has a consequence for the Orpheus rule that is worth stating rather than leaving to be discovered, and §1.6 now states it. look is checked and never granted: it costs the writer a descend and costs the operator nothing. The binding-taint form rejected below was turned down partly because "if looking is free, nothing has been carried", and looking is free of the world under either form. What is carried is not the cost of opening — it is that a deep value can be held, passed and stored at depth 0 without staining what holds it, and that opening it names the stratum again where a reader can see it.
What it cost. A sentence admitting that one of the two escapes in the lattice is a discipline rather than a gate. That reads as a weakening and is not: the witness was written when the value was fetched, by whoever held the capability then, and nothing about looking at it later can un-write that.
Stratum 8: refusing foreign code
The purer design has no stratum 8. Every value in every trace would then have a complete history, unconditionally, and every claim in this specification could drop its qualifier.
It was rejected because a language that cannot call C cannot be adopted, and an unadopted language proves nothing about whether its ideas were good. The quarantine in §1.7 is the compromise: foreign code is permitted, and a trace that used it is permanently forbidden from claiming to be replayable.
This remains the weakest part of the design.
Failure: three rejected forms
Exceptions. Rejected outright. Unwinding presumes a stack that exists at a single moment, and burial has no such moment — an expression may be evaluated now, residualised, and finished a week later by somebody else's exhumation. There is nothing to unwind to.
rescue e else f, catching a collapse. Superficially the most elegant option: a collapsed node would be a first-class thing in the trace, so expose it and let a program handle it. Rejected for two reasons. It makes bugs catchable, and a bug that can be caught is a bug that will be ignored. Worse, it makes evaluation order observable — whether rescue fires depends on how far burial got before it collapsed, which is exactly the kind of dependence §6.2 exists to forbid.
Nothing, and say so. Declare failure a burial-level diagnostic and put recovery outside the language. Honest, and fatal: a build system that cannot say if this file is missing, generate it is not a build system, and build systems are the case that motivates the whole design.
What was chosen instead splits the question in two. A no from the world is an answer and gets a value; a mistake in the program is a collapse and gets a stopped burial. The cost is a check at every world-touching call site, which is the bargain C has always offered and which this language is in no position to improve on.
One word for starving and for collapsing
An earlier draft used starve for both: for an expression waiting on a hole (§6.4) and for one that can never produce a value at all (§9.9). §10 defended the merge — "deliberately given one name because both stop a burial" — and that reason was not true of the first one. §6.4 says a starved expression is residualised and waits. It does not stop anything; it is the ordinary outcome, and it is what the whole language is for.
Two other ways out were available.
Rename §6.4's instead, and keep starve for the fatal case. Rejected because the word is already spent: starved means waiting on something somebody else must supply in this project's vocabulary table and in the roadmap's own item status, and a term that means one thing in the tooling and its opposite in the specification is worse than either.
Leave them merged and rely on context. Rejected on contact with the implementation: nether-bury has to tell them apart to report either, one is a Halt and the other is not, and a reader of §9.9 who has not read §6.4 comes away believing burial stops whenever anything waits.
So the fatal one is a collapse. It reads in the register the rest of the language is written in — a burial that hits one caves in — and it leaves starve meaning the one thing it means everywhere else.
A shade's origin: in the value, or only in the type
§5.3 once said both things at once. Equality is structural — two values are equal exactly when their encodings are — and then, one paragraph later, that two shades are equal when their underlying values are. §7.1 encodes a shade as an origin byte and the cairn of what it holds, so a shade of the same bytes from stratum 3 and from stratum 5 were unequal by the first rule and equal by the second.
The other way out was to drop the origin byte, making Shadeᵈ⟨T⟩ encode exactly as the cairn of what it holds and leaving the origin a fact the type carries. Rejected, and not only because §7.1 is frozen. §1.6 says a shade MAY be stored, and the only place a Nether C value is stored is the ledger. A shade read back out of the ledger with no origin has lost the one thing that makes the Orpheus rule checkable, and look on it could not be typed at all. The origin is not metadata about the shade; it is half of what a shade is.
What that costs is the sentence in §1.5: seal on a shade no longer reaches through to the value inside. It names the shade. That is the tighter rule anyway — a shade is opaque, and reaching through an opaque thing for a name was a small hole in it — and it takes nothing away, because seal e is legal at any depth and can simply be written before the shade.
sizeof, which had no answer
§4.5 carried "sizeof" "(" type ")" as a production from the first draft, inherited from C along with the rest of the surface, and nothing anywhere said what it evaluated to. Burial residualised it, which was the only honest thing left to do with a form that has no value.
Two ways to give it one were available.
The length of the canonical encoding. Precise, and a different question from the one sizeof is asked: §7.1 gives Bytes a length prefix and then the bytes, so the answer depends on the value and not on the type. sizeof(Bytes) would have no answer even then, and sizeof of a value is a different operator wearing the same name.
A fixed size per type. That means inventing a memory layout, and the whole of the C reason for sizeof — how much memory to ask for — does not exist here. There is no pointer type, no array decay and no allocation. A layout invented only so that one operator can report it is a fact about nothing.
So there is no sizeof. len answers the question people reach for it to ask. The word stays reserved (§3.4) because a C programmer will write it, and an error that names len is worth more than a program that binds sizeof to something of its own.
Normalising text in the ledger
An earlier draft had the ledger encode Str over its NFC form, so that two spellings of one string could not produce two cairns. It was removed while freezing §7.1, for two reasons.
The first is a matter of what a content-addressed store is for. If the store normalises, then cairn(s) is not the name of s; it is the name of something the store decided s ought to be. A program that writes a decomposed string and reads back a composed one has been lied to by the one component whose entire job is not lying about bytes.
The second is that normalisation belongs where the ambiguity is actually a problem: identifiers. Two spellings of a variable name must resolve to one binding, and §3.3 makes the lexer responsible for that. Nothing below the lexer needs an opinion.
It also removes a dependency — full NFC is a megabyte of Unicode tables — but that is a consequence of the decision, not the reason for it. Had the argument gone the other way, the tables would have been the right thing to add.
Inferring the type of a block-level binding
§5.6 used to say types were inferred within a function body. §4.2 has one let_decl production and it begins with a type, so the binding §5.6 described could not be written at all.
The fix would have been a second statement form. n = 0; is unavailable — §5.4 keeps assignment, so that spelling is already taken and the two would be indistinguishable — which leaves a keyword, let n = 0;, and a language with two ways to bind a name.
It was rejected for what it buys: four characters, in exchange for a keyword, a second binding form, and a reader who has to know which one they are looking at. Nether C is a C dialect and C writes the type. The language already asks for types on every other binding, and making one of them different is the kind of exception that has to be remembered rather than understood.
What the rule became is a better sentence than the one it replaced. Types are written; depths are inferred. A type is a fact about what a value is, which the writer knows. A depth is a fact about where it came from, which is derived from everything it touched and is exactly what a person gets wrong.
Struct literals, and forbidding assignment outright
§4.4 had an assign production and a for step that nothing could reach: §5.4 said a binding may not be reassigned, and §4.2 required every let to have an initialiser, so there was no way to write a struct value and no way for for (I64 i = 0; i < n; i += 1) to advance its own counter. Three constructs in the grammar with nothing that could produce them.
A struct literal in primary was the obvious fix: make aggregates ordinary values, Header { len: 3, tag: b"nc" }, and drop §5.4's build-then-seal discipline entirely. It is a smaller grammar and a cleaner story. It was rejected because it fixes one of the three: for still cannot step, assign is still unreachable, and a language that cannot advance a counter has no loops worth the name.
Forbidding assignment outright — remove assign, remove the for step, remove §5.4's example — was the honest minimum, and it leaves a language with while and manual recursion and nothing else. Immutability of the ledger does not require that: shared, permanent ledger entries cannot mutate, whereas a local loop counter before its value is named is none of those.
What was chosen draws the line at the ledger. A local may be assigned until it is named, and naming it is exactly the moment its cairn exists. That keeps §5.4's original sentence — "once a value has been read, its cairn exists, and nothing can change what a cairn names" — which turned out to be right all along, and makes all three constructs reachable for one reason rather than three.
The cost is that "there is no mutation" stops being true as a flat statement and becomes true only of the ledger. That is a worse sentence and a better rule.
Recording the fuel budget in the trace
§8.2 used to require that the budget be reported in the trace, "because a trace buried under a different budget is a different trace". It is not, and it cannot be: running out of fuel produces a halt rather than a trace, so a budget either lets the burial finish — in which case it changed nothing — or there is no trace to have changed.
The rejected alternative was to add the budget to Node::Trace anyway and justify it differently: that a trace should record the conditions it was made under even where they did not bind. There is a real argument for it. If a later burial of the same residue under a smaller budget halts where the first did not, somebody will want to know what the first one was allowed.
It was rejected because the cost is concrete and the benefit is speculative. Adding a field to Trace changes what an existing tag means, which bumps the domain separator (§7.2) and renames every value ever stored. Paying that to record a number that provably did not affect the result is the wrong trade, and if the diagnostic case turns out to matter it can be served by the rite's own output rather than by the trace.
Calling a nullary function without parentheses
An early draft of this specification allowed demand greet; without parentheses, inspired by C dialects that invoke nullary functions by name. It did not call anything — §4.5 requires call_suffix, so a bare identifier is the function itself. The body never ran and nothing was deposited, and nobody noticed until burial was implemented.
The tempting fix is the grammar: let a bare identifier of function type call itself. It was rejected because it reintroduces exactly the ambiguity the rest of the language spent its budget removing. greet would mean the function in one position and its result in another, and the reader would have to know the type to know which — in a language whose whole proposition is that a value's type tells you what it cost.
It would also make seal greet ambiguous in a way that matters: the cairn of a function and the cairn of what it returns are different names for different things, and there would be no way to write the first one.
What it costs is two characters on every nullary call, in exchange for an unambiguous distinction between a function value and its result.
A residue as nodes
§6.5 used to say the residue was "every node that could not be reduced, plus the holes, plus the provenance edges between them", and §7.3 listed six node kinds, none of which can hold a branch, a loop, a binding or a block. A residue routinely contains all four. The two sections could not both be right.
The rejected fix was to add node kinds until a residual program fitted — Branch, Loop, Bind, an unreduced Apply. It has one real argument in its favour: §6.6 counts nine hundred and three nodes for a program with a single hole in it, which is the residue being counted, so the summary already assumed this reading.
It was rejected because it makes the ledger hold two unrelated things in one vocabulary. A node records something that happened — this was applied to that, the world said this, at this place in this file. A residue is something that has not happened. Encoding both as nodes means every consumer of a trace has to know which kind of node it is looking at, and the distinction is not visible in the type.
What was chosen instead: a residue is a program, a program is source, and source is Bytes. It costs a print and a parse on every re-burial, which is real work that the node encoding would not have needed. It buys a Trace whose parts each mean one thing, and it means the staging law is stated over something that demonstrably round-trips — the printer has a proof that lowering what it printed gives back the same program, node for node.
Bumping the domain for any change at all
§7.2 used to say that changing the encoding changed the domain separator, full stop. Taken literally that made the format unable to grow: assigning a tag that had never meant anything would have renamed every value ever stored, including all the ones the new tag has no bearing on.
The rule now distinguishes two things. Changing what an existing tag means bumps the domain, because a byte string that decoded to one value now decodes to another and calling both by the same name is a lie. Assigning a tag that was previously rejected as unknown does not, because no byte string changes meaning — the ones that decoded still decode identically, and the ones that were refused are simply refused less often.
What this gives up is a very simple sentence. "Any change bumps the domain" can be checked by looking at a diff; "any change to what an existing tag means" needs somebody to think about which kind of change they made. That is a real cost and it is paid by whoever reviews the next format change.
It was taken because the alternative was worse in a way that only shows up later. A format that cannot add a tag without discarding history is a format that will be forked rather than extended, and then there are two.
Writing our own cryptography
The repository has no third-party dependencies. Not in Rust, not in the site, not in the graphics: site/gfx.py contains a GIF89a encoder, an LZW compressor, a PNG encoder and a bitmap font rather than importing any of them, and the argument each time was that the part actually needed was smaller than the cost of the dependency.
That argument does not survive contact with §7.2, which specifies blake3.
A hash function is not an encoder. An encoder that is subtly wrong produces a file somebody notices. A hash function that is subtly wrong produces cairns that look fine, verify fine, and collide — and the failure surfaces years later as two different values with the same name, in a store nobody can now audit, underneath every reproducibility claim in this document. Timing behaviour, buffer edge cases and the compression-function rounds are exactly the places where hand-written implementations go wrong quietly.
So the rule is narrower than "no dependencies", and it is worth stating precisely, because the broad version is the kind of principle that feels good until it costs something:
Write your own encoders, parsers, renderers and formats. Do not write your own cryptography.
blake3 is a permitted dependency. Every addition after it needs its own entry in this section.
This is also consistent with the Decay Rule rather than in tension with it. The ceiling counts the lines this project is responsible for, and three hundred lines of hand-rolled hashing would be three hundred lines of exactly the code nobody should be reviewing here.
Unicode, and the line the rule is actually drawn on
§3.3 needs two things Unicode is the authority for: which code points start and continue an identifier, and NFC. Working out how many lines the part actually needed would be, as the rule requires: the XID properties are about seven hundred ranges, and NFC is two thousand decomposition mappings, nine hundred combining classes and an exclusion list. Two hundred lines of algorithm and forty-five hundred lines of data.
The failure mode is blake3's. Two identifiers that should compare equal and do not are a program that resolves one name to two bindings, quietly, and §3.3 already says so in as many words.
The Decay Rule settles the rest. .decay-ceiling counts the code every guarantee rests on, and four and a half thousand lines of UCD is not that code: it is not ours, we would not read it, and it changes once a year when Unicode publishes. Putting it in the count would mean every future commit measuring itself against a number that is mostly somebody else's data. Generating it at build time moves the lines and not the problem.
What it cost, measured rather than estimated: in the module web/necropolis/ downloads, the tables are the largest single thing there is. The data section is 141 KB on the wire's far side and 67 KB compressed, of which about 10 KB is every diagnostic this project writes and the rest is perfect_hash, decompose and lookups. That is 44% of what a browser downloads to bury a program, spent on a correctness property most programs never exercise — and it is still the right trade, because the property it buys is that two spellings of one name cannot become two bindings, quietly. The alternative is a subset of somebody else's data, which is the thing the rule above refuses. tests/wasm/run prints the breakdown on every build so that this stays a decision rather than a discovery.
So unicode-ident and unicode-normalization are permitted, the language pins Unicode 16.0, and the rule the three of them share is worth stating because "no dependencies" was never quite it:
A dependency is admissible when what it holds is data, or a construction, that somebody else is the authority for. It is inadmissible when what it holds is behaviour this project could write and should understand.
blake3 is the first kind. Unicode is the first kind. A markdown renderer, a GIF encoder, an argument parser and a web framework are the second kind, which is why this repository has written four of those and imported none.
Fuel and opaque as command-line concerns
The obvious cheap answer: make the fuel budget a --fuel flag and the barrier a --no-inline list, and keep both out of the language.
Rejected because a trace buried under a different budget is a different trace. If the trace depends on it, it is part of the trace, and a thing that is part of the trace has to be visible in the source that produced it. A build that succeeds on one machine and exhausts on another because somebody's shell alias differed is precisely the class of failure this language exists to make impossible.
The cost is a keyword. opaque is the only construct in Nether C that exists to make the compiler do less, which is an odd thing to have to teach, and it will be the first thing a newcomer mistakes for an optimisation hint.
Leaving a starved call as the call it was written as
The first implementation of burial did this. A call whose body could not be finished residualised as the call, and the reduction the body had already gone through was thrown away. It is a defensible rule: the residue is smaller, it reads like the program somebody wrote, and it is never wrong — burying the residue simply does the work again.
Rejected because it makes a first projection impossible, and a language whose whole claim is that burial is partial evaluation cannot leave the projection out. Measured on this repository's own bootstrap — lib/interpreter.nc joined with lib/value.nc and lib/evaluate.nc, buried against build.nc with read("main.nc") unanswered — the residue was 1,163 lines whose only demand was interpret(b"…the whole of build.nc…"). The 4,993,540 steps that had read and checked the guest were in the trace and not in the residue, so the next burial spent them again. Nothing had been specialised to anything.
The cost is size, and it is not small. The same burial under §6.5's rule mints one function per starved call site — 21 of them, and a residue of 1,478 lines against 1,163 — because each carries the constants it was specialised to, the guest's source among them. An implementation can drop the bindings nothing in the residual body reads, and should; what it cannot do is drop the shape, and a programmer who wants the smaller residue back has to ask for it with opaque.
A Bytes literal without a byte escape
There was no \x until demand b"\u{e9}" was found to print as a residue that lowers to a different program. Three ways not to add one were considered.
Let a bytes_literal hold raw bytes. The obvious answer, and the one C takes. Rejected because §3.1 says a source file is UTF-8, and a lone 0xe2 is not. Relaxing that for the inside of one literal means a lexer that stops being able to work in str, an editor that shows the file as damaged, and a diff nobody can read.
Let \u{…} mean a byte inside b"…". No new syntax, and the printer already writes it. Rejected because the same escape would then mean a scalar value in one literal and a byte in the other, and \u{1f480} would be legal in one and an error in the other. An escape that means two things is read wrongly once and then trusted.
Take the variable-length \x. C's spelling, so it would look familiar. Rejected because b"\xeff" is then one literal or two depending on how far the reader looks, and it is a bug people have actually written. Exactly two digits has one reading.
The cost is a fourth thing to know about literals, and an asymmetry: \x is admissible in b"…" and not in "…". The asymmetry is the type's, not the lexer's — a Str is UTF-8 and a Bytes is not — but it still has to be taught.
One number for how far a value went and for what you may do
δ was a number: the deepest stratum whose capability is currently held. [APP]'s premise was dƒ ≤ δ and [DESCEND] raised δ to max(δ, s(κ)), so the same total order carried two unrelated jobs — how far a value's history reaches, and which capabilities are in hand.
It does not survive the second one. disk! is stratum 4 and net is 5, so inside descend net the premise 4 ≤ 5 held, and the write in §1.3's second sample was accepted. A reader auditing that program's descents would have been told it touches the network. §9.1 fixes the capability names precisely so that reading them is an audit; an order that implies one permission from another takes the audit back. §1.8 had already said the ordering was how much of the world you have disturbed and called the 4-before-5 placement "arguable" — fine for comparing two histories, and not a thing to rest authority on.
Three ways to keep one number were considered.
Declare the subsumption and mean it. Say in §1.1 and §8.2 that a grant at stratum n grants every capability at or below it, and that --grant net is --grant disk! as well. Honest, and it leaves no invocation that says fetch this URL and touch no files — which is the case the whole apparatus exists for. §8.3.2 spends a subsection bounding which host net may reach; under this reading it would be a fence beside an open gate.
Split the two gates. Keep dƒ ≤ δ as a static declaration of reach and put the real authority in the grant, so descend net { write(p, c) } checks and then leaves a hole because disk! was not granted. It is sound — nothing happens that was not granted — and it costs the property that made the names worth fixing: the program text stops disclosing what the program reaches, and only the invocation knows.
Let a function ask for at most one capability. Keep the arrow's dƒ a number and read the premise as membership, κ(dƒ) ∈ δ. A body that calls two prelude functions bare at different strata then has no derivation and must descend for one of them itself. Sound, no grammar change, and an exception that has to be remembered rather than understood — the same objection that killed a second binding form earlier in this section.
What was taken instead: δ is a set of strata, dƒ is a set, and the premise is dƒ ⊆ δ. The capabilities are in bijection with the strata, so a set of one is a set of the other and no new object enters the calculus. [LOOK] gets the sharper rule as a consequence — d ∈ δ, so a shade out of stratum 3 opens under descend disk and not under a deeper descend net, which is what going back down always said and what a comparison of two numbers did not enforce.
What it cost. A second spelling in the grammar: @{3,5} for a signature that asks for two, where a single digit used to cover everything (§3.5). A reader who knew δ as a number has to relearn it. And a program that reads and writes the disk now nests two descents where one used to do, since disk no longer arrives with disk! — which is the cost being paid for, stated as a cost.
Also rejected: letting descend take a list, descend disk, disk! { … }, to buy that nesting back. It is a grammar change for an ergonomic one, nesting already says it, and §1.3 is clearer when one descend means one capability.
One hole for every identical call, whatever stratum it was
The rule §6.3 shipped with was simpler and read better: two holes with identical calls in one trace are the same hole, and the justification given for it was a read — asking the same file for its contents twice is one question.
Rejected because it ranges over the other half of the lattice, where it is false. Two posts to the same address with the same body became one message and one witness, and §1.8 spends a section arguing that a write is deeper than a read precisely because it cannot be taken back. Two draw(8)s became the same eight bytes, which makes the one prelude function §9.7 calls the only source of nondeterminism in the language a pure function of its argument within a trace. Neither was noticed because the rule was written with a read in front of it and proved with a read.
The cost is that §6.3 is now two sentences where it was one, and that a call is no longer a name for a question — it is a name for a kind of question, which is why the answers to one have to be ordered. Addressing an answer by the span that asked would have kept the one-to-one and was rejected too: a span is a fact about one text, and §6.5 requires a residue to be printed and lowered again, which gives every hole in it a new one.
Evaluation order as the implementation's business
§6.2 left the order inside a demand unspecified and asked only that it be deterministic for a given source and capability set. That is the usual and usually correct thing to say: burial is pure, nothing a program can write observes the order, and an implementation that wants to evaluate arguments right to left should be allowed to.
Rejected because burial writes the order down. A trace carries the holes in the order they were discovered (§7.3); a shared hole keeps the span of the first place that asked (§6.3), and §6.3 calls which place that is "a fact about the program rather than about the implementation"; and a fuel budget runs out at whichever node was reached first, which §6.4 requires two implementations to agree on. Three sentences in three sections all rest on an order that a fourth declined to fix. The total fuel a finished burial spends is the same either way, which is why this survived: it is visible only under a budget that binds, and under a budget that binds is the case §6.4 exists for.
The alternative was to weaken §6.4 to what §6.2 supported — fuel is deterministic for one implementation, the way the frame and space limits three paragraphs below it already are. Rejected because those limits decide whether a burial finishes, and §6.4 goes on to say that two implementations "MUST NOT disagree about the result when both of them finish". Order is not like that. It is in the result.
What it costs. An implementation may no longer reorder evaluation for speed where the reordering could change which node is reached first, which is most reorderings. A parallel burial — 0204 — has to discover holes, keep spans, and charge fuel as though it had run sequentially, and produce the serial trace rather than whatever order the threads finished in. That was already true of the hole order; it is now also true of the budget.
The deposits as a set
§7.3.1 did not say whether a trace's deposit list could hold the same cairn twice, and a set was the cheaper reading: the deposits are the record of which values were deposited and where, a repeat adds nothing a reader did not already have, and a trace then does not grow with a loop's trip count.
Rejected because §8.4 calls lamp "how a program's output is read", and output that swallows repeats is not output. for (I64 i = 0; i < 1000; i += 1) { "tick\n"; } reading as one tick is a bug anybody would report, and the reason is the one §6.3 gives for not merging two identical sends: a trace that describes fewer things than the program did is a trace that lies about what was done. A set also means a program cannot deposit the same value from the same span twice, which is a surprising thing to forbid in a language whose only output channel this is.
Neither reading was obviously wrong, and leaving it unsaid was: the list is part of the Trace's encoding, so the two readings give the trace two different cairns, which is what §7.1 is frozen to prevent. The implementation had already chosen both — burial recorded four deposits for the loop above and lamp printed one tick — which is what an ambiguity looks like from inside.
What it costs. Thirty-two bytes in one list per turn of a loop that deposits. Not a node each: the Deposit is one node however many times the trace names it.
The disk root as the implementation's, and a reach that names a port
Two smaller choices in §8.3, which grew a fourth subsection when the disk turned out to be the one bounded capability the invocation could not bound.
Leave the root to the implementation. It is what every version of this document did, and there was a case for it: §09 talks about paths and not about filesystems, the bound is an operational concern, and the one implementation here already had a root that nothing may climb out of. Rejected because the bound existed and was undeclarable, so an operator could not say where a burial may read and two implementations could answer read("main.nc") differently while the hole's call was byte-identical. A reproducibility claim that touches a filesystem touches it exactly there.
A root that repeats, resolved as a search path. --load repeats and takes the first object that has the symbol, and reads could work the same way. Rejected because a write could not: a path does not name its root the way a URL names its host, so two roots leave every written path ambiguous and the invocation would need a second flag to say which one a write lands in — a flag to disambiguate a flag. One root, and a build that needs two things in one place puts them there.
A bare --reach host meaning the scheme's default port. Tighter, and it matches the standard the rest of the section keeps: a grant states its bound. Rejected because the thing being declared is a party rather than a service, and an operator who trusts example.com over 443 has said something about example.com rather than about 443. The cost is real and §8.3.2 now states it instead of implying it: a bare host permits every port on that host, and the program chooses which.
Leaving an undecided arm alone
§6.5 used to stop at a branch. An if whose condition waited on the world residualised with both arms untouched, on the grounds that reducing one would be evaluating something no demand requires and §6.2 forbids that.
It reads as the conservative choice and it is the expensive one. §6.2's reason is stated in §6.2: an undemanded expression could reach the world and leave a witness for something the program never asked for. That is a reason about reaching the world, not about reducing — and a partial evaluator that stops at the first branch on an unknown value stops immediately, because an interpreter's first act is to branch on the thing it was given. The projection this language is named for was being given up to protect a guarantee that folding arithmetic does not threaten.
Three ways to keep the branch sealed were considered.
Leave it. Defensible, and it makes §6.5's "what this is for" paragraph claim something the rule does not deliver: bury an interpreter and you get the interpreter back, specialised up to the first if. The first Futamura projection is the section's own stated purpose and this is the rule that prevented it.
Speculate under a separate, smaller budget, so that a divergent arm cannot exhaust the burial's. It removes the regression below — speculation could never turn a finished burial into a halt, because running out would simply leave the arm unreduced. It was rejected because the residue would then depend on the budget: how far an arm got would be a function of how much fuel was left, two budgets would give two residues, and §8.2 says a budget is not recorded in a trace precisely because it cannot have affected one. Buying safety with a trace that depends on the invocation is the wrong trade twice over.
A keyword that asks for it. opaque makes burial do less and nothing makes it do more, so the symmetric answer is a second keyword and speculation only where it is written. Rejected on size. It is a keyword to buy back behaviour that is correct by default, and this language already spends one of its eleven rules on the other direction.
What was taken instead is speculation with three things forbidden: a speculative reduction may not form a hole, may not deposit, and may not collapse. The first two are §6.2's reason turned into a rule. The third is subtler and is the one that would have been got wrong: an out-of-range slice in an arm the world never takes would otherwise cave in the burial, which makes whether a program buries depend on how far a specialiser got — the same objection that killed rescue earlier in this section, arriving from the other side.
What it cost. A program that buries today may stop burying, because an arm that never terminates is now reduced until the budget runs out. It is a smaller loss than it reads as: such a program only buried because the world answered the way that avoided the arm, and had it answered the other way the burial would not have finished either. Speculation turns a conditional non-termination into a certain one. opaque is the control for the case where it was meant.
Also paid: both arms are reduced and one is thrown away, so the work is charged for a path that may not exist and the residue carries both. That is the ordinary price of a polyvariant specialiser and it is why opaque is in §6.4 rather than here.
Stopping a block at the first statement that starved
§6.5 used to stop a block at the first statement that starved and leave every statement after it unreduced, even after undecided branches began reducing their arms in place.
Leave it stopped. On contact with lib/interpreter.nc, that rule undid branch speculation completely. An interpreter binds the result of evaluating a sub-expression before branching on it (Bytes r = expression(...); if (failed(found(r))) ...), so the statement before the branch starves first and the branch is never reached. Stopping at the binding meant the bootstrap residue was unchanged to the byte.
Reduce what follows without speculation, or reorder pure statements ahead of the starved one. The statements after a starved binding are not undecided in the way an if arm is — if the starved statement finishes, the next statement runs — so it is tempting to evaluate them ordinarily. Rejected because the starved statement has not happened yet: a deposit after it that was recorded now would appear in the trace before whatever the starved statement deposits when the world answers, and a return after it that left the block now would discard the starved statement and the hole inside it. And a statement after an if that branches on the starved binding may never be reached at all if the branch returns, so a collapse or a hole there has the same standing as one inside an undecided arm.
So the statements and tail after a starved one are reduced in place under the same three clauses as an undecided arm, with the starved binding held as an unknown local and statement order preserved.
What it cost. A statement that collapses or jumps out of a loop after a starved one has its speculative work rolled back and leaves the remainder of the block unreduced.
Depth as a monad stack
The obvious alternative to a lattice. Rejected because effects that compose by max need no lifting, no transformers, and no ordering decisions, and because max is a rule every programmer already holds in their head.
The cost is expressiveness: a lattice cannot distinguish reads the disk from reads the disk and the network except by taking the deeper of the two. Nether C accepts a coarser answer in exchange for one people will actually use.
Monotonicity, pointing the other way
§2.4 once required d′ ≥ d and explained it as evaluation can only ever learn that something is deeper than it looked. It reads well and no implementation can satisfy it. A conditional's depth is the maximum over its arms, and reducing it takes one arm and discards the other, so a branch whose deep arm is not taken reduces to something shallower than its own type says. The generative test in 0052 found it in forty-seven programs.
Keep ≥ and make the arms not count. Give a conditional the depth of its condition only, so reduction never lowers anything. Rejected outright: the arm that is taken carries its own depth into the result, and a rule that drops it hands back a disk-derived value typed as pure. That is laundering, and it is the one thing the lattice is for.
Keep ≥ and make reduction preserve the bound. Have burial stamp the unreduced expression's depth onto whatever the branch reduces to, so 1 becomes 1@3. The law holds and the language stops working: pure code that happens to sit beside a deep arm no longer disappears at burial, and everything downstream of it inherits a depth nothing ever reached.
What it cost. The shorter, more quotable sentence. d′ ≤ d is the direction that carries the guarantee — a value never escapes at a depth its type did not admit — and it costs the intuition that a depth is something already reached. It is a bound, and the number that was reached lives in the trace, which is now said explicitly in §2.4 because the two were being read as one.
Pretending an implementation has no limits
§6.4 said exhausting fuel was a diagnostic and not a crash, and left it there. Fuel bounds steps, so a recursion that never returns overflows whatever stack the implementation is using long before the budget runs out, and a stack overflow is a crash. The guarantee was true of the case it named and silent about the case that actually happens.
Bound depth with fuel. Charge more of the budget per frame, so that a deep program exhausts sooner. Rejected because it changes a constant and not a shape: for any per-frame charge there is a budget large enough to reach any depth, and picking one small enough to be safe makes fuel useless as a bound on work.
Say nothing and let implementations differ. Rejected because §6.4 already promises no crash, so saying nothing is not neutral — it is a promise no recursive evaluator can keep.
What it cost. An admission: two implementations with different limits can disagree about whether a program buries at all. The reproducibility claims in this document survive because none of them was ever about that. They are about what a trace is once it exists, and the sentence that says so is now written down beside the admission rather than assumed.
One number on an arrow
An arrow carried a single depth, and [ABS] took it from the body's value depth. The consequence was that a descent could be written and not named:
Bytes load(Str p) { descend disk { must(read(p)) } }
Bytes src = load("kernel.nc"); // rejected: dƒ was 3, δ was 0while §1.3 opens by accepting the identical expression written out at the same ambient depth. There was no way to put a descent behind a name, and the same rule failed in the other direction too: a function whose deep work was deposited rather than returned had a body of value depth 0, and so claimed a latent depth of 0 while touching the disk.
The decisive objection is about burial rather than taste. Burial reduces applications, so under that rule an application could be rejected where its own inlining was accepted, and the residue of a burial is supposed to be a program that checks. Two ways to keep the single number were considered.
Let the latent depth be what the body reaches, and let a descent inside a body not relieve the caller. A signature then reads as an audit: U0 stamp() @4 says it writes to the disk, and that is worth something. But a descend inside a function bounds nothing under this rule, so every caller up the chain holds what the leaf reached, and a program that reads one file writes descend disk at every level between the two. Encapsulating a capability becomes impossible, which is most of what a capability is for.
Carry three numbers — what it asks of the caller, what it hands back, and what it reaches — the third purely so a signature stays an audit. Rejected because the audit answer is already recorded somewhere better: a trace lists every stratum actually reached, with a witness for each, and nether strata reads it. A number in a signature that no rule consumes is a comment with a syntax.
What it cost. The chosen design has two numbers and a signature is no longer a complete account of what a function touches: U0 stamp() can write to the disk and say nothing about it in its type, because it descends for itself and hands back U0. What a program did is a question for the trace, and what a program needs from you is the question the type answers. That split is defensible and it is still a real loss for anyone reading signatures to decide whether to call something.
[APP]: the premise on all three terms
[APP] once required max(dƒ, d_f, d_a) ≤ δ, which reads well — everything about this application is within what you hold — and forbids §6.2's own example, where compile(src) is applied to a depth-3 value at ambient 0 and the comment beside it says the call is pure and merely starves. §9.2 does the same with given(a), and §2.5 says in prose that a shallow value combines with a deep one without coercion.
The stricter premise is not unsound; it is unusable. Under it a value carried out of a descent can be sealed, shaded and compared, and cannot be passed to len, so every use of a deep value has to happen inside the descent that produced it and staging buys nothing. That is close to deleting §1.3's one-way-out property.
What replaced it is the narrowest premise that still stops the thing capabilities exist to stop: the latent term, and only that one. A capability is required to reach a stratum, and dƒ is the only term that reaches one. It was written dƒ ≤ δ until δ became a set; it is dƒ ⊆ δ now, and the entry below is why.
Ambient soundness: two ways to keep the simpler statement
§2.4 once said d ≤ δ outright, which is shorter, easier to check and false: [DESCEND] carries a value out at the depth it reached, and Bytes@3 src = descend disk { read("kernel.nc") }; is depth 3 where δ is 0. Two ways to keep the shorter sentence were considered.
Let a descent forget. Conclude descend κ {e} : τ@δ instead of τ@d. The invariant then holds by construction, and so does nothing else: it lowers the depth of a value, which §1.2 forbids outright, and it turns the one expression in the language whose purpose is to reach the world into the one expression that launders what it found.
Let a descent stain. Keep δ raised for the remainder of the enclosing scope, so that anything holding a depth-3 value really is at ambient 3. The invariant holds, and the cost is that a capability's extent is no longer visible in the braces: a descend disk on line 4 silently grants the disk to line 90. This is the same re-staining already rejected for look earlier in this section, and it is no better here.
What was kept instead is a longer true statement. The cost is that ambient soundness now has a term in it that a reader has to evaluate — g(e), the deepest descent in the expression — where before it had two symbols. A rule that fits on one page is worth defending; a rule that fits on one page and is wrong is not.
One range for all three integer spellings
Every integer literal could hold the same range, which is easier to state and leaves −2⁶³ unwritable: - is an operator applied to a literal, so the literal it needs is 9223372036854775808, which is one past the top of the range. C has this wart and works around it with implementation-defined promotion; a language with one integer type and no promotion has nowhere to put the workaround.
The alternative considered was to let a decimal literal reach 2⁶³ — one higher than the type — on the grounds that it is only ever going to be read under a minus sign. Rejected because it makes a bare 9223372036854775808 a literal that is in range as a literal and out of range as a value, which is a distinction nothing else in the language makes and which every reader would have to be told about once.
What it cost. Three spellings with two ranges between them, and a sentence in §3.6 explaining why. The alternative is one range and a value that cannot be written, and a type with a value nobody can write is a type with a hole in it.
A declared set the trace does not hold
§9.4 used to say a trace records the declared set as well as the values read from it. §7.3.1 is frozen and a Trace has no field for one, so the sentence described an implementation that could not be written.
The alternative considered was to unfreeze the node encoding and give Trace a seventh member: the cairn of a canonical list of declared names. Rejected on what it buys. A name that was read is already a Witness — including one declared and unset, because §9.9 makes a refusal an answer and an answer is witnessed. A name that was never declared collapses and there is no trace to put anything in. So the only thing the field would record is a name that was declared and never read, and the only thing it would do is make two traces differ over something that changed neither of them. Content addressing is the claim that two identical programs have one name; a field that breaks that to describe the invocation is a field that makes the ledger worse.
What it cost. The invocation is not recoverable from the trace. Somebody holding a sealed trace can see every environment variable the program read and cannot see the ones it was offered and ignored, and no rite will tell them. That is the price of the cairn meaning what it says.
A cairn with no way to write it
§3.6 had no cairn literal, on the reasoning that a program never needs to write one: a cairn is something seal produces, and sealing is how you get one. That is true of a program somebody writes and false of a residue, and §6.5 makes a residue a program. Cairn c = seal b"hi"; demand c; buried to a residue whose second line read demand «a cairn has no syntax»;, which does not parse.
The alternative considered was sixty-four hex digits with no mark in front. Rejected because an identifier may begin with a letter and deadbeef is both a plausible cairn prefix and a plausible variable name; a lexer that has to count to sixty-four before it knows which token it is reading is a lexer whose error messages cannot be written.
Also rejected: allowing the short form the rites accept. nether lamp 76c4b655 works because a ledger is there to resolve the prefix. A program is read without one, and a literal that names one thing on this machine and two on the next is not a literal.
What it cost. A sixty-five character token, and the # that C programmers will read as a preprocessor directive for as long as anyone remembers what one was.
Deposits in source order
§8.4 used to render deposits grouped by the cairn of the source they came from, ordered by offset within each group, on the reasoning that a trace's sources were never written down in a sequence. They were: a sealed trace's deposit list is the order the deposits were made in, and the sort threw it away. Its key began with thirty-two bytes of hash, so which half of a program's output came first was decided by a digest, and a comment added to the top of a file reordered what lamp printed.
Ordering by offset within one source looked like the safe half and was the same mistake one level down. A function called from two places deposits in call order from one span, and offset cannot tell those apart.
What it cost. Nothing that was true. A reader who wanted the deposits of one source together, in the order the text has them, now has to ask for that rather than getting it by default — and nothing asks, because a program's output is read in the order it was made.
Grafting an answer that was already given
§8.7 used to accept an answer the trace had already been given as a thing to replace. It counted it, reported 1 recomputed, and returned a trace naming the substitute witness beside the deposits the original answer produced, because a sealed trace's residue no longer holds the work that consumed the answer and re-burying it produces nothing.
The alternative considered was to make it work: re-bury from the trace that still had the hole, which is the only thing that can produce the right deposits. Rejected because a sealed trace does not name the trace it was exhumed from — nothing in §7.3.1 points backwards — so graft would have to search the ledger for a parent, and a ledger may hold several or none. Re-burying the source from scratch instead would reach a trace with a different residue and a different name from the one exhuming the parent would have reached, which is two names for one result.
What it cost. A person holding only the sealed trace cannot ask "what if this file had said something else" of it. They need the trace from before it was answered, which they had, because they exhumed it.
A trace's depth without its holes
§7.3.2 used to make a trace's depth the join of its residue and its witnesses. A hole contributed nothing, on the reasoning that the residue already counts whatever the holes would reach. §1.5 makes that false: seal e is depth 0 whatever e is, so a program that demands a fetch only through a seal buried to depth 0 with a stratum-5 hole under it, and strata printed pure over a trace that could not take a step without the network.
The alternative considered was to leave the formula and make the residue carry the depth of what it seals. Rejected because it unsays §1.5: a seal is pure because naming a value does not touch the world, and a residue that counted sealed expressions would make every program that keeps a cairn as deep as the thing the cairn names. Counting holes instead of the residue was rejected already, by opaque, which hides a deep expression that never becomes a hole. Counting them as well is the only rule both cases agree with.
What it cost. A trace's depth is no longer a fact about its residue alone, so bury reads every hole it is about to write back out of the ledger, and a trace written before this rule may now be malformed by §8.6 without anything about it having changed.
A refusal that knows its own type
§9.2 gives a program answered and refused. refused(absent) carries no T, and the IR's types have no variables, so it takes T from the binding or return it is the whole value of and is an error anywhere else.
Three alternatives were considered.
No constructors. Leave every Answer to the prelude. Rejected because it made utf8 a pure function that does what no pure program function can, and a program that parses had two ways to say no: collapse, which forbids its caller from handling anything, or return a Bool beside a value, which is the shape Answer exists to replace.
Type variables in the IR. Leave refused's T unknown and solve for it. Rejected on what it costs: inference is a second type system beside the depth calculus, which is eleven rules on purpose, to type one function whose T is written down a few characters to its left in every program anybody would write.
A type argument. refused<Bytes>(absent). Rejected because it is new syntax for one call, and it says again what the declaration already says.
answered alone, without refused, was not considered seriously: a program that can say yes and not no is worse than one that can say neither.
What it cost. refused cannot be an argument. given(refused(absent)), first(refused(absent)) and a refused written as a function's tail value with no return are all errors, where a language with inference would accept them. Each has a one-line rewrite through a declaration, and the error says which. And refused sits one letter from refusal, which is the inspector pointing the other way; the types differ, so the typo is caught rather than believed.
Parenthesising every expression a residue prints
print, which writes a residue back out as source (§6.5), used to wrap every operator in parentheses. The reasoning was that the round trip is about meaning, and a printer that leaned on §4.6's table to rebuild the shape would prove the table rather than lowering. It also added a level of nesting the source never had for every operator it printed, and §6.4's limit on nesting reads the printed form like any other. A flat sum of 80 terms buried, and its residue came back 79 parentheses deep and could never be exhumed.
The alternative considered was to keep the principle and stop the damage: print a left-nested chain of one operator as one parenthesised run. Rejected because it is the precedence table again, used for associativity only, and it fixes the chain while leaving every other way an expression can be long.
The printer now parenthesises a child only when its level is looser than its place allows, and reads the levels from the table the parser climbs. Minimal parentheses never nest deeper than the source that lowered, so what lowers prints as something that lowers, and the fuzzer holds that over every input.
What it cost. The round trip now depends on the printer and the parser agreeing about §4.6. They read one table, so they cannot disagree by drifting, but a wrong table is now wrong in both places at once, and the round trip cannot see it. §4.6's own proof, which compares the table with §04, is what catches that.
Burial that holds the store
§8.2.1 lets bury remember a burial it already did. The first proposal was for burial itself to consult the store before evaluating, which makes burial hold stratum 1, which makes bury grant store by default. Rejected because it unsays §8.2: with no --grant, burial holds no capability, and that is the default precisely because it cannot surprise anyone. A burial that can read the store can read a node somebody else wrote, and then two stores give one source two traces.
The memo is the rite's, not the program's, and holds nothing the store does not.
Also rejected: reporting zero steps for a remembered burial. Steps are a fact about the burial, and §6.4 asks implementations to agree on them. An implementation that remembered would report a number one that did not could never reproduce, and the budget would mean something different on each. So the rite reports the steps the burial costs, says it remembered, and refuses the memo when the budget would not have covered them.
What it cost. A memo entry records the steps a burial spent, outside the trace, and that is a second place the number lives. It is never read except to compare with a budget, and an entry that disagrees with the trace it names is the same as no entry: the rite buries.
A newer release that replays older traces
§0.6.1 promises that an old trace can be replayed by the release that wrote it, not by every release after. The alternative considered was the stronger promise: each release carries what it needs to bury the residues of the ones before it, as a compatibility mode keyed on the trace.
Rejected on cost and on honesty. Every semantic change would leave a branch behind in the evaluator for as long as old traces exist, which in a ledger without garbage collection (§7.6) is forever. And a compatibility mode is a second implementation of the old release written by people who have since changed their minds about it, which is a worse witness to what the old release did than the old release itself. Reproducible builds make the old release recoverable, and recovering it is the honest way to ask what it would have done.
What it cost. Replaying a trace from two majors ago means fetching and running a two-majors-old binary. Somebody who only has the newest release cannot do it.
A parallel burial with an order of its own
§6.2.1 requires a parallel burial to leave the trace the serial order would. The alternative considered was to let each implementation order holes and deposits however its threads finished and to compare traces as sets.
Rejected because the order is not decoration. A hole list is read in order by exhume and by every person reading strata, a deposit list is a program's output in the order it was made, and which of two places asked a shared question first is the span the hole keeps. Comparing as sets would let two burials of one program disagree about all three and still be called the same, and the trace's cairn — which is built from those lists in order — would differ between them anyway.
What it cost. A parallel burial has to keep enough of the serial order to commit results in it, which is bookkeeping a free order would not need, and a collapse found early on another thread has to wait to be reported.
Answering every hole in a trace at once
§6.6 lets an exhumation overlap a contiguous run of read-stratum holes and keeps act-stratum holes sequential. Two broader rules were considered.
Overlap every hole in the trace, since §6.3 guarantees finished arguments. Rejected because finished arguments mean no hole waits on another hole's value; they do not mean the world is indifferent to the order in which it is touched. A read asked concurrently with a write to the same path sees one of two files depending on which thread won, and two posts in flight at once arrive in network order rather than demand order.
Record witnesses in completion order. Rejected for the same reason §6.2.1 rejected completion order for holes: the witnesses list is part of the Trace node, so its order is in the cairn, and §6.3 serves multiple answers to one call in list order.
What it cost. A write between two reads splits the exhumation into two sequential read batches around the write, even when the paths are disjoint, and a fast hole after a slow one waits to be committed in discovery order.
Walking the reverse index to find damaged traces
§7.5.2 derives affected traces by walking forward from verified Trace nodes rather than walking refs/ backwards from corrupt objects.
The alternative considered was to start at each corrupt object and follow referrers up to every Trace that names it. Rejected because an audit has to inspect objects/ anyway to find the corrupt objects, and refs/ is the very derived index the audit is checking: a missing reverse edge would make a damaged trace look healthy, and a corrupt object that was itself a Hole, Witness or Deposit has outgoing edges that cannot be decoded at all.
What it cost. An audit decodes every verified node in the store to read its forward references, even when only one object is corrupt.
Reconciling stores by whole-inventory diff or by shipping refs/
§7.5.3 reconciles two stores top-down from explicit root cairns $R$ in bounded want batches and exchanges only canonical objects. Three alternatives were rejected.
Whole-store inventory exchange — trading a full list of stored cairns, a Bloom filter, or a prefix trie over the whole store so the difference can be computed in one pass. Rejected because a store never shrinks (§7.6) and holds every unrelated burial that machine has ever run. An inventory exchange scales with the size of both stores rather than the size of the trace being asked for, and hands a stranger the names of every private trace in the store.
Shipping refs/ or memo/ alongside objects/. Rejected because both are derived indexes: a receiver that trusted a peer's refs/ would accept forged provenance edges without the peer having to forge a blake3 hash, and memo/ is keyed by a single machine's executable (§8.2.1).
Treating divergent witnesses for one call as a conflict. Rejected because a Witness node records what the world answered at one exhumation, not a mutable slot for "the current answer". Two exhumations that received different answers have different witness cairns and different trace cairns, and a store that holds both has lost nothing and contradicted nothing.
What it cost. Top-down reconciliation takes one round trip per level of the root's node graph instead of one round trip for the whole store, and the receiver decodes each object and rebuilds its own refs/ entries on arrival.
Moving a store by copying its directory
§7.5.4 exports a store as a dependency-ordered stream of verified objects with a whole-stream blake3 trailer and rebuilds refs/ on import.
The alternative was to document tar (or a directory copy) followed by an audit at the destination. Rejected because a directory copy transfers refs/, memo/ and leftover files in tmp/, trusts the source filesystem not to have corrupted an object silently before the copy, and leaves a truncated transfer with nodes in objects/ whose referenced children have not arrived yet.
What it cost. Exporting reads, decodes and hashes every object in the source store to order and frame the bundle, and importing decodes, hashes and indexes every object again at the destination.
Assigning distributed holes by Call or resolving conflicting witnesses by arrival
§6.6 assigns a trace's open questions across machines by their slot index 0..holes.len(), commits merged witnesses in ascending slot order, and rejects conflicting witnesses for the same slot. Two alternatives were rejected.
Assigning and merging by Call or by Hole cairn. Rejected because at act strata (4, 6, 7 and 8) two entries in holes are not merged (§6.3): they may share the same Call, and when written at one source span they share the same Hole cairn (§7.3.1). Keying a delivery by Call or by Hole cairn cannot tell whether two witnesses from two workers are answers to two distinct act slots or two competing answers to one slot.
Resolving conflicting witnesses by arrival order, worker rank or quorum. Rejected because at the store level two divergent witnesses are both valid historical records (§7.5.3), while a single trace can record only one witness per answered hole slot. Picking one silently discards a recorded observation of the world and makes the merged cairn depend on which worker answered first.
What it costs. Every worker delivery carries explicit slot indices against a specific base trace T, and a retried or overlapping assignment whose world changed between attempts fails the merge with an explicit conflict rather than producing a trace.
Version ranges, a central package registry, and a dedicated ledger tag for packages
§7.5.5 represents a package as a canonical Struct value ("Package" / "Dep") addressed by its cairn, pairs local aliases with exact dependency cairns, and resolves dependency closures offline. Three alternatives were rejected.
Version ranges and a solver. Rejected because a version range resolves to different bytes depending on when and against which index the solver runs. Two disconnected machines can only resolve a dependency to the same cairn offline if the dependency names the cairn directly.
A central registry for human names. Rejected because a global namespace reintroduces a mutable mapping from names to bytes outside the ledger. Scoping an alias to the "Package" struct that declares it gives humans a readable local name while keeping every cross-package edge an immutable 32-byte cairn.
A new value tag or node kind for packages. Rejected because a package is a record of existing ledger primitives (Str, Cairn, Array, Struct), and encoding it as an ordinary Struct under tag 0x10 requires no change to the frozen tag table (§7.1) or domain separator (§7.2).
What it costs. Updating a deep dependency changes its cairn and therefore the cairn of every package above it in the DAG, and offline resolution requires the dependency closure to be imported into the local store beforehand (§7.5.3, §7.5.4).
A stateful language server for editor hover and provenance
§8.4.1 serves editor hover, depth blame and provenance through a stateless nether lamp <cairn> --at <byte> [--source <path>] invocation backed by the trace already in the ledger, paired with a thin editor adapter (tools/vim/nether.vim).
The alternative was a long-running Language Server Protocol (LSP) daemon that maintains an in-memory workspace and re-checks unsaved buffers on every edit. Rejected because provenance, holes, witnesses and deposits only exist for a program that has been buried into a trace: an unsaved buffer that differs from trace.source has no recorded nodes at its edited byte offsets, and walking provenance on an unburied buffer either serves shifted spans from an older trace or silently buries on every cursor movement. Refusing when --source <path> disagrees with trace.source states the boundary between unburied text and a recorded burial.
What it costs. After editing a buffer, a programmer must run nether bury again before lamp --at will inspect the new trace, and the adapter covers hover depth, descend origin navigation and recorded-node provenance rather than general LSP features such as completions or rename.
https, and the one dependency exception
Beyond the Unicode tables above, CLAUDE.md permits cryptography — "do not write your own cryptography" — and refuses the rest. https is TLS, so §9.6 had to settle whether net means a TLS stack or means less than people will expect.
It settles neither, deliberately: the scheme set is the implementation's, and what §9.6 requires is that it be stated and that a scheme this build will not serve come back denied rather than unreachable. This implementation serves http and refuses https by name.
The alternative considered was a TLS dependency — rustls and a root store — on the grounds that a net capability that cannot reach most of the network is a capability nobody will grant. Rejected for now on what the stratum is for. The interesting content of strata 5 and 6 is the witness and the replay: a response sealed on arrival, served back from the ledger, with no socket opened. None of that is about TLS, and all of it can be demonstrated without it.
What it cost. nether exhume --grant net will not fetch from most of the web today, and anybody who needs it to has to build with a TLS stack this repository does not ship. That is a real exclusion and it is stated here rather than discovered.
The network's reach
§8.3.2 makes --grant net insufficient on its own: a host has to be named as well.
The alternative considered was the capability alone, on §9.1's reasoning — a capability is the audit point, and the whole apparatus exists so that a reader can see what a burial may touch by reading one line of the invocation. Rejected because it makes net the one capability with no bound on what. An implementation already roots the disk somewhere, for a reason it states in its own source: a burial able to read /etc/shadow because a program asked it to is a burial nobody can grant a capability to. A socket is that argument with a longer reach.
What it cost. A second flag, and an invocation that fails when somebody grants net and forgets --reach. The failure is the cheap one — the trace is not written, rather than written against a host nobody meant to allow.
Who frees what, across the foreign boundary
§9.8.1 makes the caller own both buffers and calls twice when the first is too small.
The alternative considered was the usual one: the callee allocates its answer and the caller frees it. Rejected because it makes the two sides share an allocator, which they do not — a Rust caller and a C callee linked against a different libc free from different heaps, and the failure is a corrupted heap at some later, unrelated moment. A protocol whose failure mode is "something else crashes an hour from now" is a bad protocol in any language and an unusable one in a language whose whole argument is that you can tell what happened afterwards.
What it cost. A callee that cannot size its answer in advance is called twice, and does its work twice or caches it itself.
A foreign call, and the one unsafe
The workspace sets unsafe_code = "forbid". A foreign call cannot be written under it, so §9.8 needs somewhere for the exception to live.
The alternative considered was relaxing the lint where it was needed — an allow on the module that does the call. Rejected because forbid exists precisely so that it cannot be locally undone, and downgrading it to deny to make one module possible makes every other module possible too.
So the exception is a crate, and nothing else in the workspace changes. §1.7 says this stratum is quarantined loudly; this is the same quarantine one layer down.
The rule that came out of it is narrower than "unsafe is allowed here": unsafe lives only where the language ends. There are two ends — the one where Nether C calls out, and the one where something else calls in — and each is a crate whose Cargo.toml says so.
What it cost. A crate boundary where a module would have done, and two Cargo.toml files that say unsafe_code = "allow" in exactly the places a reader will go looking for them.
A bound on reading, and why it is not ten
0219 set out to show that no input under a megabyte costs more than ten megabytes. Rejected, because no tree can meet it: a ; is a token and a statement, and a 0x00 inside an array is a 48-byte value, so one byte of either input is several dozen bytes of what it means. Meeting ten would mean not building the tree.
What was kept is the half of the claim that was about attack: what a reader allocates is linear in what it was given, with the multiple stated and asserted (SECURITY.md, boundaries 1 and 2). Measuring it found the case the claim was written against — an array nested in arrays, each believing a count against the same remaining bytes, reserved five gigabytes from one megabyte — and it was in the codec, which had been looked at twice.
What it costs. A megabyte of source can hold a quarter of a gigabyte while it is parsed. That is a large constant, and it is a constant: it cannot be bought with a cleverer megabyte.
Floating point
Excluded from §3.6 because IEEE 754 has platform-observable behaviour, and canonical encoding cannot be built on top of it. This makes Nether C unsuitable for numerical work today, which is a real and large exclusion.
90.3 Things Nether C is worse at
Stated plainly, because the roadmap requires at least one such statement and because they are all true.
- Interactive programs. A language whose central act happens before the program is delivered is the worst possible fit for anything that responds to a person. Nether C should not be used for a UI, a game, or a server that holds a connection.
- Numerics. No floats. See above.
- Debugging by print. Two commands instead of one, forever.
- Storage. The ledger never shrinks. §7.6 argues that this is affordable; it has not yet been measured, and until it is that argument is a hope.
- Keeping a secret. Depth is a claim about where a value has been, not about what it can be made to reveal, and the two get confused because a lattice is what a confidentiality type system looks like too. §1.5's
sealis the shortest demonstration: the cairn of a depth-3 file is at depth 0,hexmakes it text, and equality on it decides something about the file while holding nothing. A program that must not reveal a deep value cannot be checked by this type system, and nothing in the language is going to make it one. - Writing a container. A program cannot abstract over a type.
func_decl(§4.2) has no type parameters, §3.8 removed the preprocessor and §5.2 removed pointers, so there is no macro, novoid *and no generic to fall back on. The prelude's own signatures are generic inT—must,given,answered— and nothing a program writes can be. A C programmer reaches for a container on day two and this language has no way to write one: the answer is one type per element type, by hand, and that is the whole of it in this draft. - Learning curve. Depth is a genuinely new thing to learn, even for experienced C programmers.
90.4 Lineage
Nether C began with a respectful nod to Terry Davis's HolyC — specifically the discipline of building a small, self-contained system from one coherent idea (and reversing several of its central premises, from immediate execution and ambient authority to burial and explicit strata).
What endures from that nod is the engineering method: write the pieces yourself, keep the system small enough to hold in your head, refuse unnecessary dependencies, and state tradeoffs plainly. Beyond that origin, Nether C stands on its own specification.
90.5 Two rooms, one colour vocabulary
The interface uses indigo grounds and rose signals. Its light companion uses rose porcelain, lavender panels and plum ink. Both are authored in site/design.py; generated CSS, GIF colour tables and the cairn icon consume those roles. The nine depth colours follow a violet-to-rose path, but numbers and labels remain the authoritative cues.
Rejected: complementing the RGB values or applying a filter to the page. Neither preserves readable contrast or gives the light room a character of its own. The old VGA swatches also described colours the interface no longer used; swatches now show live semantic tokens.
What it costs. Two small colour tables and a second set of GIF files. The drawings, timing and encoders remain shared. Tests compare both shipped colour tables against the system and check text on plain and raised surfaces. The hero and descent have still counterparts for reduced-motion readers.
90.6 One face, and where the lettering is not type
Everything on the page that is text is Nether 8, the one 8×8 face site/font.py draws — the prose, the headings, the listings, the sign and the lamp. The headings are not a second face. They are the same letterforms at 24px and 16px against a body at 16px, and what makes a heading look like one is around the letters rather than in them: colour, uppercase and letter-spacing on h1, a filled bar on h2, and the ██, ■ and ▸ that precede the three of them.
That reads as deliberate. It is, and this is where it was decided rather than left.
The repository does hold a second alphabet, and it is not a counter-example. site/gfx.py has a 5×7 one of fifty-one characters — capitals, digits and a little punctuation — and it is drawn into GIF frames pixel by pixel at whatever scale the picture needs. It is lettering inside a drawing. It cannot be selected, searched, or read aloud, it has no lowercase, and nothing on the page sets text in it. Two alphabets, one of which is type and one of which is not.
Rejected: a display face for the headings, drawn on a bigger grid. It is the obvious other answer and it costs three things. A second set of a hundred and thirty-eight glyphs, which is the smallest of them. A second .woff for a few dozen words per page. And a second grid — the face is a pixel face on an eight-unit cell and the type scale is 8, 16, 24, 32, whole multiples of it, so every pixel of a glyph lands on whole pixels of the screen. A display face drawn on twelve or on sixteen either brings a scale that is not a multiple of the body's, or is the body face larger, which is what is already there.
The idiom settles the rest of it. These headings are DOS window title bars. A poster face would make them posters, and the front page would stop agreeing with the terminal it is describing.
What it costs. A heading carries no information in its letterforms that a paragraph does not, so all of the hierarchy is in colour, case, spacing and three block characters. A reader who cannot distinguish --accent from --ink has the prefix and the bar, and that is the whole of it. It is thinner than a display face would be and it is the price of one face.
A second weight is a different question, settled in item 0231 (site/nether-bold.woff): bold is the same letterforms drawn heavier, not a second face, and the browser is not allowed to invent one.
The four sizes it is read at, and where the grid gives way
Nether 8 is drawn on an 8×8 grid with a seven-unit fixed advance (six ink columns and one blank bearing column). site/design.py emits four sizes and no others (TYPE = {8, 16, 24, 32}), whole multiples of the drawing cell:
- 8px (
--type-fine, 1× cell, 7px advance): the ASCII door sign (pre.sign,line-height: 1= 8px), listing captions (figcaption), plaque title bars (.plaque > h3), the footer, badges, the hit counter, and the 8×8 drawing grids and metadata onsite/specimen.html(line-height: 1.375= 11px). - 16px (
--type-body, 2× cell, 14px advance):bodyprose, code listings (pre,code), tables, navigation and directory drawers, terminal status bars, controls (button,textarea), necropolis labels and previews, andh3/h4(line-height: 1.375= 22px;textareauses1.5= 24px).htmlsetsfont-size: 14pxsolely to scaleremmargins and padding;bodyrestores16pxbefore any text is drawn, and@media (max-width: 640px)tightens padding without lowering the body size. - 24px (
--type-head, 3× cell, 21px advance):h1,h2,.necropolis h2, and.box.covenant strong(line-height: 1.375= 33px). - 32px (
--type-sign, 4× cell, 28px advance):.necropolis h1(line-height: 1.25= 40px) and.nc-selected h2(line-height: 1.375= 44px), plus the 4× specimen row and glyph samples onsite/specimen.html.
Every line-height (1, 1.25, 1.375, 1.5) and every letter-spacing (.125em) in site/nether.css is a multiple of one eighth (1/8), and because every allowed font-size is a multiple of 8px, their products are always whole CSS pixels (8/11/16/22/24/32/33/40/44px leading; 1/2/3/4px tracking, bringing a tracked character's pitch from 7/8 em to 1em). An earlier .necropolis h1 rule at 48px with line-height: 1.2 (57.6px on desktop, 38.4px on mobile) and decimal tracking (.1em, .12em, .08em, .06em, which shifted characters by 0.64px–2.4px) were brought onto the eighth grid in 0234, and tests/css/run and tests/necropolis/browser.mjs refuse any element whose computed font-size, line-height, or letter-spacing leaves it.
Rejected: scaling body or code down to 12px or 14px on mobile, or using 8px for running text. At 12px or 14px (1.5× or 1.75× the grid) every second stem straddles a device pixel at scale 1; at 8px (1×) a bold stem is two pixels and a counter in B, 8, 0, a, e, or g is one pixel wide, which holds for short uppercase chrome and captions and is too tight for a paragraph or a code listing. Also rejected: retiring 8px from chrome and captions altogether, which would double the height of the door sign and make listing title bars as tall as the code they label.
What it costs. Three things CSS integer pixels cannot prevent:
- At
8pxand device scale 1, one drawing unit is one physical pixel. Closed counters remain open across both weights, but dense forms (@,%,#,§,m) have single-pixel gaps that only gain breathing room at device scale 2 (2×2physical pixels per unit) or at16pxand above. - Outline rasterisation on scanlines beside crossbars.
Nether 8ships as quadratic contours inglyfrather than embedded bitmap strikes (EBDT), so Chromium and CoreText still apply greyscale coverage antialiasing on rows immediately adjacent to horizontal bars even when-webkit-font-smoothing: noneis set. - Non-integer browser and display zoom. At
125%(1.25×) only32px(40physical pixels,5×the grid) lands on whole physical pixels;8px,16px, and24pxbecome1.25×,2.5×, and3.75×the grid, giving the two stems ofHasymmetric physical widths (1.62vs1.82pixels at8px). At150%(1.5×) the even CSS sizes (16pxand32px) land on whole physical pixels (3×and6×the grid) while the odd sizes (8pxand24px) fall on halves (1.5×and4.5×). Integer CSS pixels keep1×and2×screens exact and keep16pxbody text exact at150%, and cannot make every zoom factor an integer multiple of eight.
Mechanizing the metatheory: an in-tree LCF proof kernel versus an external proof assistant
§2.4 states two properties an implementation must preserve — soundness of the bound (reduction never raises depth) and ambient soundness (any derivable depth is bounded by max(δ ∪ g(e))) — and §1.6, §6.5 and §7.1 add three more: the necessity and sufficiency of the Orpheus premise d ∈ δ, the staging law bury(bury(e, A), B) = bury(e, A ∪ B), and the injectivity of the canonical encoding. Generative testing (0052) checks ten million random derivations and reduction steps, which is a strong regression net and not a proof.
Four families of proof environment were compared for proof/:
- External interactive proof assistants (Lean 4, Coq/Rocq, Agda, Isabelle/HOL). Foundational kernels with rich tactic languages and editor integration. Rejected: each brings a multi-hundred-megabyte toolchain outside the pinned CI image (
rust-toolchain.tomlpins Rust1.98and.github/workflows/ci.ymlpins Python3.12), version-locked standard libraries whose syntax and tactics churn across point releases, and a build step that contributors without the assistant installed would skip. A proof that only runs when an optional tool is present rots the way an optional lint does. - External SMT solvers (
z3,cvc5). Fast decision procedures for quantifier-free theories. Rejected: an SMT script asserts universal axioms for inductive relations (HasType,StepTyped,encode/decode) and asks whether their negation is unsatisfiable; if an axiom set is accidentally inconsistent,unsatis reported for every theorem without constructing an inductive derivation. - Generative sampling alone (
0052). Already in the tree and fast, and still finite sampling over an infinite family of terms. - An in-tree LCF-style proof kernel (
proof/kernel.py) under pinned Python 3.12. Following the same rule assite/bake,site/gfx.pyandsite/font.py— when a small self-contained tool can be written in the tree with zero dependencies, write it in the tree —proof/kernel.pydefines a sealedTheoremtype gated by a private kernel token (_KERNEL_TOKEN). No code outsideproof/kernel.pycan construct aTheoremexcept through the kernel's primitive inference rules (assume,mp,imp_intro,conj_intro,conj_elim_l,conj_elim_r,disj_intro_l,disj_intro_r,disj_elim,iff_intro,inst,gen,refl,sym,trans,cong,rewrite), its inductive derivation principles (apply_rule,rule_induction,structural_induction), and its complete finite-domain decision procedurelattice_decideoverDepth = {0..8}andHeld = P({0..8}).proof/check.pyscans every module inproof/with Python'stokenizeto reject admitted obligations (sorry,admit,admitted,axiom,unproved,postulate,todo,fixme), verifies negative kernel self-tests (forged theorems, missing induction cases, undischarged assumptions, invalid lattice formulas), and runs on everyscripts/task test,scripts/task proofsandscripts/task check.
What it cost. Two things. First, the trusted computing base of the proofs is proof/kernel.py (~1,677 lines of Python) plus the pinned Python 3.12 interpreter rather than Lean's or Coq's kernel; proof/check.py mitigates this by testing that forged theorems, missing cases, undischarged hypotheses, and false lattice claims are actively rejected on every run. Second, proofs are written as explicit combinator and induction scripts rather than interactive tactic blocks, which is noisier for large algebraic proofs and entirely manageable for an eleven-rule calculus and an eleven-tag wire format.
90.7 What is proved, what is tested, and what is believed
A project that mechanizes part of its metatheory and tests the rest owes a reader a boundary between the two. Differential testing (0226) and generative sampling (0052) are regression checks over finite samples, not proofs; a mechanized theorem in proof/ is a proof about the mathematical model in proof/, not a proof about the Rust compiler or the host kernel.
Every claim in this specification sits in exactly one of three mutually exclusive primary tiers below. A proved claim may also carry supporting tests in crates/, and a tested claim may be motivated by a proved model theorem, and no claim is counted in more than one tier.
Tier 1 — Proved (in the proof/ LCF model)
Reproduced by scripts/task proofs (and on every scripts/task test via python3 proof/check.py, which also token-scans proof/*.py to forbid sorry, admit, admitted, axiom, unproved, postulate, todo, and fixme, and to forbid any file but proof/kernel.py to name the kernel's seal). Each theorem below is a sealed proof.kernel.Theorem derived over the explicit inductive relations and finite-domain decision procedure in proof/:
- Ambient soundness of the eleven typing rules (§2.4, theorem
ambient_soundnessinproof/calculus.py): for every derivationHasType(Γ, δ, e, τ, d)built from the 12 rules ofHAS_TYPE(§2.2's 11 rules plusSELECT),d ≤ max(δ ∪ g(e)). Model scope and assumption: proved by rule induction overHAS_TYPEover the 9-element lattice0..8and capability subsetsP({0..8}). - Substitution depth monotonicity (§2.4, theorem
substitution_monotonicityinproof/calculus.py): for all 13 expression substitution formsSubstDepth(e, d_e, d_v, d′)representinge[x := v]withv : τ_v@d_v,d′ ≤ max(d_e, d_v), with equality tod_ewheneverd_v = 0. - Soundness of the depth bound under reduction (§1.2 and §2.4, theorem
soundness_of_boundinproof/calculus.py): for all 18 small-step reduction rules of §6 (StepTyped(e, e′, d, d′)),d′ ≤ d. Reduction can discard an untaken arm (if (true) a else b, whered = max(d_a, d_b)andd′ = d_a) or drop an unused deep argument, and never raises a depth. - Sufficiency, necessity, and non-interval separation of the Orpheus premise (§1.6 and §90.2, theorems
look_sufficiency_ambient,look_sufficiency_confinement,look_necessity_confinement,look_necessity_numeric,numeric_vs_membership_counterexample,binding_taint_violates_ambient, andscope_restain_shifts_obligation_to_callerinproof/orpheus.py):d ∈ δis sufficient for both §2.4 ambient soundness and{d} ⊆ δ ∪ g(s)capability confinement; necessary for capability confinement on closed shades ({d} ⊆ δif and only ifd ∈ δ); and strictly stronger than the numeric ceilingd ≤ max(δ)whenδis not a downward-closed interval (d = 3, δ = {0, 5}). - Core residual round-trip and the staging law (§6.5, theorems
roundtrip_identity,hole_set_union_law,staging_idempotence_set,staging_law,dependent_hole_non_monotone_counterexample, andcumulative_dependent_hole_lawinproof/staging.py): in the core calculus model,parse(print(r)) = rover all 12 residual constructors. The staging law is weaker than its name:StagedEvaldefines the two-stage reductionbury(bury(e, A), B)and the one-stage reductionbury(e, A ∪ B)rule by rule, side by side, andstaging_lawproves that every derivation gives both the same result. That the 17 rules ofStagedEvaldescribe whatnether-burydoes is believed, not proved.staging_idempotence_setis only the set identityA ∪ A = A, which turns the law into idempotence whenA = B. Dependent holes whose inner capability is gated by an outer answer require the cumulative hypothesisA ⊆ B(witnessed by the non-monotone counterexampleA = {0, 3}, B = {0, 5}). - Prefix-free stream round-trip and injectivity of the canonical wire model (§7.1, §7.2, and §7.3, theorems
value_decode_encode,node_decode_encode,injectivity_from_left_inverse, andcairn_preimage_injectivityinproof/encoding.py): for every well-formedValue(11 tags0x00..0x08,0x10,0x11, including unprefixed recursiveStruct,Array, andAnswer::Given) and every well-formedNode(0x20+ 6 kinds0x00..0x05, including unprefixedNode::Literal) paired with arbitrary trailing stream bytesrest,decode_stream(encode(x) ++ rest) = (x, rest). Settingrest = b""yieldsdecode(encode(x)) = x, which impliesencode(x) = encode(y) → x = yand injectivity of the domain-separated preimageb"netherc/cairn/v4\x00" ++ encode(x).
Tier 2 — Tested (in the Rust implementation)
These claims are about the Rust workspace (crates/), the CLI (nether), and the generated site (site/). None of them is proved by proof/; each is held by deterministic and generative test suites run by scripts/task test and scripts/task fuzz:
- Correspondence between
nether_core::checkand a Rust transcription of the 11 rules (0226,crates/nether-core/tests/calculus.rs):model_check, a clean-room transcription of the 11 rules, andnether_core::checkagree on50,000seeded valid and invalidUnits on everycargo test(the_implementation_agrees_with_the_mechanized_model) and on10,000,000seededUnits across all 8FaultKindvariants inscripts/task fuzz(ten_million_programs_agree_with_the_model).model_checkis Rust written fromproof/calculus.pyby hand. Nothing checks that the two agree, so this tests two Rust programs against each other, not the code against the proof. - Implementation burial monotonicity and residue well-typedness (
0052,crates/nether-bury/tests/monotone.rs): generative testing over10,000,000seeded programs checking thatnether_bury::burynever raises an expression's depth and always emits a residue accepted bynether_core::check. - Surface syntax print/parse/lower round-trip and staged burial on
UnitIR (§4 and §6.5,crates/nether-bury/tests/residue_is_source.rs,crates/nether-syntax/tests/lowering.rs, andcrates/nether-syntax/tests/fuzz.rs): surface printing, lexing, parsing, precedence parenthesisation, and two-stage burial through printed source. - Single-assignment aggregate construction and loop/branch freezing (§5.4,
crates/nether-syntax/tests/frozen.rsandcrates/nether-syntax/tests/aggregates.rs): checking that naming a local (seal,shade, deposit,return, argument) freezes subsequent assignments across blocks, exclusive branches, and loop back-edges while keeping loop-local declarations fresh each turn. - Production codec round-trip, truncation/trailing-byte rejection, and well-formedness guards (§7.1–§7.3,
crates/nether-ledger/src/codec.rsandcrates/nether-ledger/tests/fuzz.rs): cross-checking the 16 canonical fixtures againstproof/encoding.pyand fuzzingencode_value/decode_valueandencode_node/decode_node. - Crash-safe ledger storage, multi-thread/multi-process contention, audit, exchange, and packages (§7.5 and §8,
0205–0208,0213–0215,0220,0101incrates/nether-ledger/andcrates/nether-cli/tests/rites.rs): atomic rename, corrupt-object refusal, 16-thread and 16-process contention,nether stratachecking the depth a trace claims, export and import of a store, and two stores that each answer half of a trace's holes and seal byte-identically to one store that answers all of them. Every one of these runs on one machine. No test compares stores built on two architectures. - Refusal of
nether runand bounded evaluation fuel (§6.4 and §8.0,crates/nether-cli/tests/rites.rsandcrates/nether-bury/tests/collapse.rs).
Tier 3 — Believed or open (neither proved nor closed)
These claims are relied on as assumptions or tracked as open items in cairn/items/; none is claimed as proved or finished:
- Cryptographic collision resistance of BLAKE3 (§7.2):
proof/encoding.pyproves that the domain-separated preimageb"netherc/cairn/v4\x00" ++ encode(x)is injective; that distinct preimages produce distinct 32-byte cairns rests on the standard cryptographic assumption on BLAKE3 and is not proved here. - Making invalid in-memory
ValueandNodestates unrepresentable in Rust types (0115): until0115lands, well-formedness side conditions (such asorigin ≤ 8onValue::Shade, non-empty struct and callee names, andSpan.start ≤ Span.end) are enforced bycodec::encode_*andcodec::decode_*checks rather than private constructors. - Two-machine independent verification of a tagged release binary (
0221): the reproducible build recipe (scripts/task release:buildwith--remap-path-prefixand--locked) is in the tree, and the two-host tag attestation remains open until a release tag is built and compared across two independent machines. - A residue checks wherever its program checked. §6.5 states the rule that makes it so. The monotone soak in
crates/nether-bury/tests/monotone.rstests it over ten million programs. Nothing inproof/proves subject reduction for [LOOK] under burial. - Remaining open roadmap items, among them
0075(the trace graph browser),0078(a stranger explains a hole),0081and0082(the second and third projections),0103(a pilot),0104(an introduction),0105(a conformance suite),0106(a public store),0108(a 24-hour decoder soak),0210(a year of a real store), and0235(the face for other users).cairn listis the full list.