Skip to main content

Module inputs

Module inputs 

Source
Expand description

Build inputs — the macro phase’s only channel to the outside world.

Closes theory/BLUE.md §VI OPEN #6, which the spec names as gating “blue’s whole ‘stronger than Ruby’s metaprogramming’ claim”: tenet 2 installs a NoLoader, so a macro could read nothing, which also meant it could not generate code from a schema — the thing that would make blue’s metaprogramming exceed Ruby’s rather than merely match it.

definput("schema", "b3:1d9e…")     # the DECLARATION: name + content hash

defmacro columns()
  quote
    unquote(input("schema"))       # the macro receives the BYTES
  end
end

§Why this is stronger than what Ruby or Elixir can express

Both have compile-time/load-time I/O, and in both it is ambient authority:

  • Ruby runs arbitrary code at load time with the whole filesystem open. A gem’s metaprogramming can read anything the process can read.
  • Elixir’s @external_resource plus File.read!/1 is the same authority, and its recompilation tracking keys on mtime, not content — so the same bytes at a new timestamp force a rebuild, and different bytes at the same timestamp do not.

blue’s channel is capability-restricted and content-addressed:

  1. There is no path anywhere in the API. A macro names an input, never a file, so it cannot reach something the author did not declare — and the restriction is the absence of a primitive, not a policy consulted at call time.
  2. Bytes are verified against the declared BLAKE3 hash before anything can read them. Wrong bytes are refused, not silently used.
  3. Because the declaration is the hash, “did the input change” is a content question. mtime cannot make it lie in either direction.

§What is deliberately still impossible

A macro cannot enumerate inputs, cannot read a path, cannot fetch a URL, and cannot see an input the program did not declare. Adding any of those would return the ambient authority this exists to remove.

Structs§

Declaration
One declared input: a name bound to a content hash.
Inputs
The verified inputs a macro phase may read.

Enums§

InputError

Constants§

HASH_PREFIX
The hash prefix a declaration must carry. Explicit so the algorithm is part of the contract rather than an assumption — a bare hex string would silently become un-migratable the day a second algorithm is wanted.

Functions§

declarations
Collect definput("name", "b3:…") declarations from a program.
install_input_primitives
Install the reading primitives against inputs.