<!-- description: Read HoldFast's qualification criteria for authoring software, proofs, machine semantics, and hardware in one language, including native self-hosting. -->

# HoldFast Whole-System Authoring Contract

> Qualification criteria for optional HoldFast-authored software, proofs,
> machine semantics and hardware.
> [Whole-system plan](../../plan/#holdfast-whole-system-authoring-proposal)

## Authoring end state

Whole-system authorship extends the [first-release subset](../../language/first-release/#release-boundary).
Apply the extension selection criteria to each proposed replacement. Qualified
replacements can author artifacts that the selected backend emits as Rocq terms,
Clight, machine code or RTL. Proved libraries can remain dependencies behind
HoldFast interfaces.

Declare the source closure for a whole-system authorship claim. Include firmware,
kernel, storage, services, bootstrap and ISA/ABI primitives. A toolchain claim also
covers compilers, proof automation and generators. Identify any first-party C,
Gallina, VST or Sail that still requires handwritten maintenance. Generated instruction/assembly stubs are permitted, with
primitive meaning from the admitted machine and required source/binary evidence;
inline assembly and foreign stubs grant no semantic exception. Retained libraries
and imported RTL need explicit dependency boundaries and qualification records.

Each accepted component has one maintained operational definition, reviewed
contract, representation and proofs. Its software reference and production
executable derive from that definition with exact-final-image correspondence;
manual optimized rewrites and generated-output repairs are excluded. Authored
algorithm/layout choices need refinement evidence. Arbitrary Gallina computations
are not presumed efficiently lowerable.

The initial software and proof surface uses admitted interpretations. Selected
machine and hardware extensions add architectural transitions and cycle-level
hardware under their own admission and replacement criteria. Module interfaces
state phase and target restrictions. A runtime use of unbounded mathematics
requires a proved finite representation, and runtime control, allocation, encoding
and circuit state require represented inputs.

The [metaprogramming contract](../metaprogramming/) supplies explicit static
computation first and constrains separately selected structural-description and
hygienic-generation extensions. Generated definitions, proof terms,
specialization inputs and descriptor dictionaries belong to the declared
source/dependency closure.
Generator removal and final-code cost have separate acceptance predicates;
static generation supplies no software, machine or hardware refinement theorem.
Compiler services expose the same source identities and elaborated meanings to
tools without adding an admission path or runtime evaluator.

Contracts retain independent review and telling rejected behaviors. Architecture
and processor implementation remain distinct theorem subjects even when sharing
arithmetic/decoding definitions; an implementation cannot define its own correctness.

## Software and proof boundary

Initially elaborate into admitted interpretations, reconstruct evidence in
Rocq/CIC and lower supported explicit-memory code through the selected compiler;
generated Clight is permitted. A replacement for a required verified-C or Rust producer must satisfy the
[compiler replacement contract](../../assurance/compiler-route-contract/#conditional-amendment-and-reviewer-requirements).
Language unification and source-neutral admission alone retire neither.

The following evidence is needed before handwritten C and component VST scripts
can retire:

- Checked correspondence from the authored source closure through parsing,
  resolution, implicit insertion, elaboration and erasure to the interpreted
  program and contract. A valid proof about another program is insufficient.
- Concrete representation and ownership laws for layout, initialization, CHERI
  tags, bounds, provenance, permissions, frame preservation and every supported
  exit, including failure, cancellation and device quiescence where applicable.
- Composed lowering, optimization, ABI, assembly, linking and image evidence for
  the final bytes. Hidden allocation or runtime support must meet the same
  declared resource and admission obligations as explicit code.
- Separate statements and proofs for functional behavior, termination or reactive
  progress, adversarial-context isolation, permitted leakage and resource bounds
  wherever the component's accepted claim includes them.

The [foundation map](https://github.com/symbiogenesis/VerifiedOS/blob/main/docs/hardware/cheri-foundation-map.md#required-connections)
owns missing concrete laws; generic separation logic or surface syntax supplies
no CHERI instance. VST may remain internal. Its replacement needs sound rules and
connections to the admitted machine logic, preserving every discharged obligation.

A full proof-authoring replacement must cover the selected proofs, including
inductive reasoning, universes, quantified mathematics, logical relations and
compiler and hardware metatheory. Reactive proofs need an encoding within the
accepted kernel profile, such as guarded interaction trees. Keep Rocq-authored
proofs until the selected clients express and replay their replacements in
HoldFast. Kernel replay and assumption audits apply to reconstructed evidence,
including evidence proposed by automation. [Guarded interaction trees](../credits-reactive-layouts/#guarded-interaction-trees)

The long-term default is a proof kernel written in HoldFast. Rocq remains the
checker until the HoldFast kernel qualifies for the proof rules and assumptions
that the supported programs use. Maintain the Gallina backend after that
transition so developers can opt into independent Rocq replay of the same
statements and audit their assumptions. The
[frontend disposition](../full-language-review/#frontend-admission)
governs the calculus's interpretation commitment and admission.

## Native verified compiler and self-hosting

Full self-hosting is HoldFast's long-term goal. The default toolchain must
build itself, check its proofs and emit target binaries directly from
HoldFast-owned IRs using tools written in HoldFast. Demonstrate the post-seed
rebuild and proof checks with Rocq and external SMT solvers unavailable.
The first software release uses one retained compiler route. Qualify the
native compiler on a concrete consumer and compare it with
extending that route, accounting for compiler proofs, bootstrap, maintenance
and licensing. Consumers can use the retained producer throughout qualification.

Development uses the [Menhir route](../../assurance/verification-strategy/#development-parser-and-grammar)
with a reviewed grammar and located AST, preserving separate lexer, parsing,
elaboration and source-correspondence duties. The selected native compiler includes
a HoldFast-authored parser qualified against the reviewed grammar and corpus.
Adopting a general-purpose parser generator requires its own consumer and
qualification decision.

Select [LSP, DAP and DWARF interoperability](../../tooling/tooling-protocols/) according to
actual compiler/editor and execution-backend consumers. The initial software
release requires useful diagnostics, navigation, formatting and proof inspection;
it does not wait for every debugger or export adapter.
Editor services consume the compiler's located and resolved source state and
preserve batch-only proof acceptance. Native compilation carries source, type,
scope, variable-location and unwind mappings through optimization and final
image construction into separately stored DWARF information. DAP consumes a
matching debug artifact and a qualified execution backend, preserving lifecycle
authorization and CHERI authority. These interfaces have separate plan owners;
compiler correctness and self-hosting alone do not qualify them.

### Optimization stages and evidence

Native compilation uses intermediate representations suited to each optimization
stage and can emit target code directly. Keep structured control flow and proved
type, alias, effect and contract facts available for specialization, inlining and
justified check elimination.
Selected loop, layout and vector transformations need concrete memory and target
information; instruction selection, allocation, scheduling and local rewrites
use the appropriate target representations. The scoped compiler package selects
and qualifies its IRs and pass families.

Runtime erasure may remove proof values while retaining checked compiler facts.
Each later transformation must transport or re-establish the premises it uses
in its current IR; an earlier source annotation alone supplies no such premise.
An interim C/Clight backend may consume already optimized output, with checked
representation transport and backend evidence through to the final artifact.
Bypassing C alone establishes no optimization benefit.

Each IR has a reviewed interpretation and retains or discharges later passes'
ownership, CHERI authority, layout, initialization, effect, protocol, leakage and
resource premises. Compiler/hardware proofs resolve the generation's canonical
machine, Sail or its qualified successor; native compilation adds no private ISA.

Compose reusable correctness theorems for elaboration, erasure, representation,
optimization, instruction selection, allocation, calling conventions, assembly,
linking and image construction, carrying source evidence to exact bytes without
reproving each transform from its output. Functional refinement, termination/progress,
authority, robust isolation, relational leakage and resource bounds remain distinct
where claimed; functional optimization correctness supplies neither CT nor cost.

Independently kernel-check evidence, audit dependencies/assumptions and bind source
and final image. Pass-theorem reuse needs the checked revision, premises and actual
application. Use R-05-023a decompilation and final validation or an admitted composition of
checked substitute evidence.

The [Plinth/Plutus design comparison](../../assurance/verification-strategy/#compilation-and-executable-models)
informs this separation of pass implementation, relation and proof, while
**Verified E-Graphs in Pyrosome** (Jamner, Askerbekov, Chlipala, accepted POPL 2027,
[chlipala.net](https://chlipala.net)), [Slotted E-Graphs](https://doi.org/10.1145/3729326)
(PLDI 2025), and [Versioned E-Graphs](https://doi.org/10.1145/3808249) (PLDI 2026)
chart reflective and binder-aware certificate-producing equality-saturation paradigms
for native IR optimization passes. Similarly, [Two-Level Staged Closure Elimination](https://doi.org/10.1145/3674648)
(Kovács, ICFP 2024) informs eliminating higher-order abstractions into closure-free
first-order IR pre-lowering, and [Exo 2](https://doi.org/10.1145/3669940.3707218)
(ASPLOS 2025) provides a reference for user-schedulable loop/SIMD/layout schedules
whose every step must still discharge CHERI authority, leakage, and resource
preservation in the qualified proof kernel.

To eliminate per-pass simulation duplication across `Q25df`–`Q25di` without
weakening guarantees or admitting non-commercial code, the native compiler pipeline
combines four complementary mechanisms:

- **First-class semantic IR dialects & reflective verified e-graphs:** Embed
  operational semantics directly into IR dialect definitions (PLDI 2025 pattern)
  and drive representation, erasure, and algebraic/peephole rewrites through a
  single reflective verified e-graph inside Rocq (POPL 2027 Pyrosome pattern) so
  each rewrite requires only a local soundness lemma.
- **Clean-room BTL translation validation with spatial/temporal slicing:** Run
  untrusted heuristic mid-end optimizers (CSE, LICM, loop rotation, scheduling)
  and check outputs with a clean-room Apache-2.0 block symbolic-execution
  validator (inspired by Chamois-CompCert's BTL architecture without CompCert's
  non-commercial code), accelerated by OOPSLA 2026 spatial and temporal
  decomposition over compiler pass provenance.
- **Proved linear-time allocation & declarative Sail-checked selection:** Use an
  untrusted register allocator paired with a compact proved `regalloc2`-style
  symbolic checker verifying capability tags, bounds, spills, reloads, and
  parallel moves, and express CHERI-RISC-V instruction selection in a
  declarative VeriISLE-style DSL whose rule chains emit Rocq-checked certificates
  against pinned Sail.
- **Single-copy omnisemantics & Octal-style TAL:** Use PLDI 2025 omnisemantics
  ([arXiv:2504.15550](https://arxiv.org/abs/2504.15550)) to prove functional
  refinement and constant-time leakage preservation simultaneously across
  nondeterministic passes without duplicating compiler proofs into 2-execution
  self-composition, paired with CCS 2025 Octal-style secret/public stack
  separation in TAL.

A composed record identifies each pass, its inputs and outputs, and the checked
theorem application that justifies it. Each pass interface preserves the facts
later passes consume. Acceptance requires semantic preservation for every step
and every claimed property.

AI/search/scheduling heuristics may propose transforms, but a proved checker or
reconstructed proof establishes their premises and required preservation. Missing
support/certificates or failed checks admit no optimized artifact; any fallback
independently meets the same contract. Search implementations remain untrusted.

### Bootstrap and qualification

Verified self-hosting connects executable compiler bytes to the proved definition.
Record the seed compiler, interpreter or proof-grounded evaluation route, exact
sources/tools, target/ABI, bootstrap stages, assumptions and final compiler image.
The compiler must compile its declared HoldFast closure into a successor with checked
compiler correspondence; reproducible stages are an additional check. Resident
compiler/helpers meet storage, runtime and admission rules. Declare initial
checker/bootstrap trust boundaries; self-compilation alone proves no soundness.

Record any Menhir dependency used by the seed. Qualify the successor's resident
rebuild of the declared compiler closure with Menhir unavailable, including any
parser generation the rebuild requires. Before retiring Menhir from development,
establish the successor grammar as the syntax owner, preserve accepted syntax and
source meaning, and qualify required [syntax campaigns](../../tooling/parser/#generated-syntax-campaigns)
and [editor assets](../../tooling/tooling-protocols/#syntax-grammars-and-highlighting)
against the successor grammar and shared corpus. Historical seed replay and
optional parser comparisons may use pinned Menhir outside the required rebuild.

Replay retained proofs with search off wherever they cover the declared
bootstrap closure. If resident rebuilding needs additional proof automation,
compare a bounded certificate checker or targeted arithmetic procedure written
in HoldFast with replay of retained proofs and host-side proof discovery.
Qualify any selected resident helper against its semantics and exact executable
under the same closure rules. Any SMT solver used by the fully self-hosted
toolchain must itself be implemented in HoldFast. The solver searches for a
proof and the kernel checks evidence for the original source obligation.
External solvers can serve as references during development.
[Certificate-producing SMT](../../assurance/verification-strategy/#certificate-producing-smt)

Bootstrap uses a two-stage strategy so commercial rebuildability and CompCert
retirement do not block on the full optimization suite: Stage 0/1 qualifies a
minimal **unoptimized** direct CHERI-RISC-V backend using the proved
register-allocation checker and declarative ISLE-style instruction-selection
rules first, then layers validated optimizations on top via the translation
validator. Similarly, the Stage-1 resident proof kernel self-hosts HoldFast's
compact standalone minimal-CIC kernel (`minicic_spec.v` / `minicic_checker`)
together with the clean-room Apache-2.0 reflective arithmetic/e-graph/Alethe
certificate checker rather than porting general tactic machinery.

Qualify competitive optimization separately on representative systems/compute
clients, including held-out ones, at identical semantics, security, target and
resources. Measure final code size, stack, allocation, traffic, target cost,
compile/proof cost and maintenance. Aim to match/improve qualified routes where
their optimizations are admissible. Native/self-hosting compilation implies no
LLVM-wide parity or universal superiority; scope and price optimization machinery
and proofs before implementation.

Qualify commercial use, distribution and resident rebuilding for the complete
source/proof/helper/runtime closure. Independent infrastructure may use project
terms; adapted passes retain their terms. CompCert/LLVM independence and removal
of non-commercial dependencies require closure audit and consumer retirement under
the [compiler replacement duties](../../assurance/compiler-route-contract/#conditional-amendment-and-reviewer-requirements).

## Machine model

The selected machine subset would replace Sail as the maintained architecture
source and supply its required consumers. Selection requires a consumer and a
feasibility decision. The independently reviewed architecture elaborates into
the accepted kernel theory and supplies the semantics used to judge compiler
and hardware output.

Its scope covers the frozen profile's architectural state and all operations
reachable in a shipped composition: finite-width integer and floating-point
behavior, instruction encoding/decoding, register and memory effects, traps,
misalignment and invalid instructions, CHERI metadata and authority, atomics and
memory ordering, device interactions, interrupts, reset and boot behavior. Its
trace interface also carries the applicable timing, cost and leakage observations.
Unsupported operations and configurations require explicit refusal or a separately
reviewed scope decision; silently omitting a difficult operation is no replacement.

Supply one admitted machine closure, parameterized by actual platform variation,
with explicit configuration, core class and hart identities. Every consumer resolves
that closure and declared instances, without private transcriptions. Resolve the
[canonical term's open configuration question](https://github.com/symbiogenesis/VerifiedOS/blob/main/docs/assurance/canonical-machine-term.md#2-generation-identity)
before admission. A one-hart term covers only that configuration.

Prove agreement across the entire selected scope against the pinned Sail
definitions. Give explicit state and observation maps and preserve behavior in
both directions, including failures, nondeterminism, termination and required
progress. A stuttering simulation must preserve progress, timing and leakage
observations where claimed. Review architecture changes independently of the
semantics-preserving migration.

Separately transport relational security, preserving public/secret entries,
admissible contexts, independent executions and permitted observations. Coupling
choices to hide leakage is invalid. Cost bounds and hardware refinement also need
checked transport at their claimed scope. Immediate stopping fails required progress.

Reference-emulator compilation needs correspondence evidence and a recorded
host-runtime boundary. Differential/litmus/mutation samples establish no model
equivalence. Resolve unavailable Sail definitions/external operations or explicitly
review them as premises; neither side may hide missing semantics.

To reduce manual transcription and per-instruction proof effort in `Q25dl`,
mechanical generators emit both the HoldFast machine closure and skeleton
per-instruction bisimulation lemmas directly from the pinned Sail AST. Those
skeletons are then discharged using BSD-2-Clause `Katamaran` symbolic execution,
the `Q25fp` agentic replay loop, and `Q25fe` reflective certificates under the
same full-scope agreement and explicit-refusal gates.

## Hardware

A separately selected hardware subset may author state, registers, concurrent
rules and cycles/schedules.
Its semantics/compiler need checked connections to the admitted hardware interpretation
and exact synthesis input. Initial Kami/Kôika elaboration or RTL generation is
permitted; generation alone meets neither connection. The
[RTL boundary](https://github.com/symbiogenesis/VerifiedOS/blob/main/docs/assurance/rtl-correspondence-boundary.md) distinguishes source
circuit theorems from synthesized artifacts.

Because `mit-plv/koika` is LGPL-2.1, HoldFast vendors no Kôika source; its
rule-based hardware semantics are authored clean-room under Apache-2.0, drawing
modular LTS refinement patterns from MIT-licensed `mit-plv/kami`. Cycle-to-ISA
refinement pairs `CHERIoT-Ibex`-style unbounded observational equivalence and
liveness ([arXiv:2502.04738](https://arxiv.org/abs/2502.04738)) with
certificate-producing SMT discharge and `Q25fp` agentic replay.

Simulator/RTL may share hardware definitions, and architecture/hardware may share
pure helpers. Processor refinement still connects cycles to architecture through
explicit state maps, commits, progress and applicable timing/leakage. Shared
generation supplies neither that theorem nor independent executor checks. Imported
cores retain their qualification path until replacement covers the actual artifact.

Physical implementation, fabrication and device measurement remain separate, with
claims bounded by their artifacts' evidence/theorem tier. Structural-absence and
netlist audits keep independent artifact checks; circuit theorems imply no physical absence.

<a id="migration-and-retirement"></a>

## Replacement admission

A replacement route qualifies under these criteria.

1. Establish the software/proof route over the existing machine term. Qualify
   representative systems and mathematical clients, including a held-out client,
   before claiming the general authoring endpoint. Keep required current routes
   available until each consumer has an accepted replacement.
2. Construct and kernel-check the candidate machine definition and its full-scope
   agreement evidence under a reviewed comparison scope. The
   pinned Sail term is authoritative until the replacement is admitted.
3. Rebind and recheck every affected consumer: compiler/primitive meanings, binary
   refinement and admission, TAL soundness, the machine logic and its relational
   and cost theories, emulator/oracle and generated tooling, and hardware evidence
   and refinement. Generate the consumer inventory from actual dependencies,
   check completeness and record each consumer's revision and verdict.
4. Promote the replacement and retire Sail only when all required destination
   artifacts are admitted, all consumers use the replacement closure, and no
   accepted claim still depends on an unqualified route. Rebuild and revalidate
   affected images and evidence for the promoted semantics and update provenance, admission gates and the trust-base
   inventory.

Replacement admission covers anchor identity and provenance under R-05-019
through R-05-019c, R-05-020's conditions and all affected compiler, primitive,
binary-validation and hardware obligations, including R-05-023 through
R-05-023b, R-05-026, R-13-017 and R-15-090 through R-15-092. The
[VerifiedOS admission process](https://github.com/symbiogenesis/VerifiedOS/blob/main/docs/spec.md#r-18-034)
governs the change to the accepted route.

## Qualification cases

Use independently reviewed expected behavior and inhabited premises. These
well-formed changes must fail at their intended obligations:

| Candidate change | Evidence that must fail |
| --- | --- |
| An elaborator resolves a source operation or contract to the wrong definition | Authored-source correspondence, even if the resulting kernel term checks |
| Erasure removes a runtime discriminant or lowering changes failure cleanup | Phase, operational or all-exits refinement |
| A spill loses a capability tag, or bounds/provenance/permissions change | Concrete representation, machine execution or binary admission relation |
| A widened or vectorized load crosses the readable or initialized extent while preserving returned values on nontrapping inputs | Concrete access, initialization and trap preservation, including admitted inputs on which the widened access newly faults |
| An optimizer preserves outputs but changes a required leakage observation or resource bound | The composed security or resource obligation for that transformation |
| An optimization certificate names another pass revision, source or output image | Transformation-premise checking and source/final-image binding |
| A self-compiled binary reproduces stage output but lacks a connection to the proved compiler definition | Verified-bootstrap acceptance; reproducibility alone earns no compiler-correctness claim |
| A decoder changes an exceptional result, admits an excluded encoding or drops a device event | Full-scope model agreement and the affected consumer theorem |
| A comparison omits one core configuration or changes allowed concurrent traces | Configuration coverage or behavioral agreement |
| Functional values agree but a secret changes branches, addresses or permitted latency | Relational leakage or cost/timing agreement |
| A processor or generated RTL retains correct outputs while violating its commit/progress relation | Hardware refinement or synthesis-input correspondence |
| A model change leaves an old binary or hardware certificate marked current | Dependency invalidation and exact-revision evidence binding |

Separate malformed, noncompiling and unsupported variants from semantic rejections.
A required survivor blocks replacement. Independent contracts, distinguishing
inputs and alternative paths address shared-definition errors; generated-artifact
agreement alone is insufficient.
