Home / Skills / indexable-inc/blaze

compiler-correctness

What blaze must compile and how: never rustc, every program the pinned nightly builds behaves the same (except rustc soundness holes), usefulness over parity with rustc and cargo, semantics in the front end's query crates (blaze-query, derived from salsa), keys that cover every input, deterministic output, proc macros on wasm and Cranelift's place, sandboxed build scripts and proc macros. Load bef

skillLicense: Apache-2.0 Source: indexable-inc/blaze

Install

Copy this folder into your Claude Code project (needs Node.js):

npx degit indexable-inc/blaze/.agents/skills/compiler-correctness .claude/skills/compiler-correctness

Or install it for every project:

npx degit indexable-inc/blaze/.agents/skills/compiler-correctness ~/.claude/skills/compiler-correctness

File content

Made by its original authors and shared under Apache-2.0. We show it unchanged, with credit and a link to the source. Source ↗

---
name: compiler-correctness
description: "What blaze must compile and how: never rustc, every program the pinned nightly builds behaves the same (except rustc soundness holes), usefulness over parity with rustc and cargo, semantics in the front end's query crates (blaze-query, derived from salsa), keys that cover every input, deterministic output, proc macros on wasm and Cranelift's place, sandboxed build scripts and proc macros. Load before changing the front end, codegen, the linker, caching or store keys, diagnostics, proc-macro or build-script execution, or the sandbox."
---

# Compiler correctness

<!-- Generated by `bun tools/agents/rules.ts --write` from tools/agents/rules.ts, down to the end marker; edit the rules there. AGENTS.md carries each rule as one line. -->

## no-rustc (rule 1)

blaze never runs rustc: no function, crate, std, build script, proc macro, test or link step goes to
rustc, rustdoc or a cargo that runs them. Each place that still does is a bug with a `no-rustc`
issue, to be removed, never extended.

See [docs/no-rustc.md](../../../docs/no-rustc.md).

## superset-of-rust (rule 4)

Own every layer from source to running code, never by narrowing what blaze accepts: every program
the pinned nightly builds must build and behave the same under blaze, with the real std, C
dependencies, build scripts and proc macros. The allowed differences are sandboxing and soundness:
where rustc accepts a program because of an objective bug in rustc (a soundness hole that lets safe
code cause undefined behavior, such as rust-lang/rust#25860, or another clear safety defect), blaze
refuses it with a hard error naming the hole, never by default copying the bug; a mere disagreement
with rustc's design is not such a bug. Superset means blaze may also accept more than Rust: an
extension (new syntax, attributes, semantics) only has to work under blaze, never under rustc, as
long as it is opt-in and every program that doesn't use it behaves exactly as under rustc.

See [docs/no-rustc.md](../../../docs/no-rustc.md).

## useful-not-parity (rule 5)

rustc and cargo are references, never specs. Judge everything blaze does by how useful it is to the
person or agent using it, not by how closely it matches them: errors, warnings, lints, CLI commands
and flags, printed and JSON output, progress, the target directory's layout, file formats, caches,
symbol names, debug info, what a build or test run does and in what order. Match them only where
real code or tools depend on it (a program's behavior, a published crate's manifest, an editor
reading the JSON); everywhere else pick the better design and delete the copy. Their style is no
constraint either: how cargo or rustc words, colours, lays out or orders a message, a progress line,
a summary or a flag is not a reason for blaze to do the same; design it as blaze would from scratch
(structured data first, rendered for a person on a terminal and as data for an agent) and change it
freely when a better way is found. Tests check what makes the result useful and correct, never that
it equals rustc's or cargo's. `superset-of-rust` is unchanged: every program the pinned nightly
builds still builds and runs as it does under rustc, except one that only builds through a rustc
soundness bug.

## blaze-uses-its-extensions (rule 6)

Only blaze builds blaze, so blaze's own source is blaze-only Rust: use its extensions
(`#[blaze::pure]`, `nopanic`/`noalloc`/`nonblocking`, `#[blaze::linear]`, contracts, comptime,
sealed traits) wherever they make blaze more correct or more incremental, and rely on them being
checked. No `cfg_attr` guard, no rustc-compatible copy, no inert-under-rustc fallback: an extension
blaze can't check yet is an error to fix in blaze. The one limit is stage 0: an extension blaze's
source uses must be one the stage-0 blaze (`.github/blaze-version`) already reads, so a new
extension lands in a release before blaze's source depends on it.

See [docs/future/bootstrap.md](../../../docs/future/bootstrap.md).

## sandbox-everything (rule 9)

Build scripts and proc macros always run sandboxed, on every platform; where no sandbox can be made,
blaze stops. Sandboxed tests are an opt-in experiment. The only ways out are the documented manifest
opt-outs and `BLAZE_SANDBOX=off`; nothing new that runs user code runs outside by default.

See [docs/cargo.md#build-scripts-and-proc-macros-run-in-a-sandbox](../../../docs/cargo.md#build-scripts-and-proc-macros-run-in-a-sandbox).

## proc-macros-on-wasm (rule 10)

A proc macro runs as a WebAssembly module: blaze compiles the macro crate to `wasm32-wasip1` with
its own front end and code generator (never rustc), and Wasmtime runs it in process, Cranelift as
its compiler, behind the `proc_macro` bridge, whose shims are its only imports. Cranelift's code
generator runs only there, inside Wasmtime for wasm. Native code (every target blaze builds for,
debug or release) is never generated by Cranelift: it is copy-and-patch stencils or LLVM, a function
with no stencil is a typed error naming it, and there is no Cranelift tier between them. Cranelift's
IR types (`cranelift_codegen::ir`) may stay as the stencils' input until blaze has its own IR. The
MIR evaluator stays for const eval and as the reference a macro's wasm output is tested against;
nothing hand-rolls a wasm-style sandbox (`blaze-macro-eval`'s `tier.rs` is replaced by this).

See [docs/v2/plan/lanes/usercode/macros.md](../../../docs/v2/plan/lanes/usercode/macros.md).

## keys-cover-every-input (rule 21)

A query key, store key, fold key or template key covers every input its value depends on, including
the data a constant points to and the identity of a closure callee. Two different values under one
key is a refusal with a typed error, never an overwrite, and the fix is the key, never the check.

## deterministic-output (rule 25)

No output (an object, a diagnostic's order, a store key, a profile row's identity) depends on
hash-map iteration order, thread timing, addresses or the wall clock. Hashers have fixed seeds,
except a table whose keys an attacker may pick (names, paths, literals), which is keyed by a
`blaze_hash::SipKey`: random when nothing persists its layout and nothing output depends on where a
key lands, or `blaze_ids::index_key` of its content when an image lays it out; a hot one may instead
be adaptive (`blaze_hash::adaptive`): the fixed hash until a lookup walks a run no honest keys make,
then a random `SipKey` for good. Anything iterated into output is sorted or ordered by construction;
a test builds twice and compares bytes.

## semantics-in-front-end (rule 31)

Language semantics (MIR building and passes, borrow checking, const eval, layout, code-identity
hashes) go in the front end's crates in `crates/` (`hir-ty`, `hir-def` and the rest, derived from
rust-analyzer but no longer synced with it), whose queries run on blaze's own engine
(`blaze_query::db`, crates/blaze-query: derived from salsa but not salsa; dense ids, in memory, one
view at a time; persisted, shared results go through blaze-kernel), in a crate of their own where
possible. Codegen, the store, the daemon, cargo integration and the runtime stay outside the front
end.

See [docs/contributing.md#where-new-code-goes](../../../docs/contributing.md#where-new-code-goes).

## library-over-language (rule 32)

Before adding an attribute, intrinsic or special case to the compiler, write the feature as library
code on what the language already has: traits, generics, const eval, compile-time reflection
(`core::mem::type_info`), allocators, effects and the purity proof. When it cannot be written that
way, the language is missing a primitive: add the smallest general one that makes the library
possible (nightly's API where one exists, otherwise an opt-in blaze extension), and keep the set of
primitives small. The compiler proves and exposes facts (purity, code identity, layout, reflection);
policy (caching, storage, hash formats, how code is executed) lives in libraries anyone can read or
replace. Example: `Canonical` is library code over `type_info`, and `#[blaze::cache]` lowers to a
call on a library `Executor`; the compiler generates neither the hashing nor the caching.

See [docs/contributing.md#where-new-code-goes](../../../docs/contributing.md#where-new-code-goes).

<!-- End of the generated rules. Hand-written notes follow. -->