Skip to content

trust_engine: add a formally verified derivation kernel - #172

Closed
KerneyJ wants to merge 1 commit into
NetSys:mainfrom
KerneyJ:verify-trust-engine
Closed

KerneyJ wants to merge 1 commit into
NetSys:mainfrom
KerneyJ:verify-trust-engine

Conversation

@KerneyJ

@KerneyJ KerneyJ commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Replaces the trust engine's pure core with a formally verified kernel, behind the verified-kernel cargo feature. Feature off (default): the native engine is unchanged. Feature on: derive routes through the kernel and the existing unit + e2e tests run against it.

The kernel is written as a spec in the Veri DSL (src/trust_engine.veri.md), compiled to Dafny. The correctness invariants (monotonicity, commutativity, and termination) are proven at build time. Dafny then transpiles the proven program to Rust. Most of the added lines are the Dafny runtime the transpiled Rust links against. The hand-written code to review is the spec, plus the marshalling (marshal.rs) and runner (runner.rs) that wire the kernel into derive.

Replace the trust engine's pure core with a Dafny-verified kernel,
extracted to Rust and dropped in behind the `verified-kernel` cargo
feature. With the feature off (default) the native fixed-point engine is
unchanged; with it on, Derivation::derive routes through the kernel and
the existing unit and e2e tests run against it.

The kernel is built with Veri, an experimental verification system: the
spec is written in the Veri DSL and compiled through its Dafny -> Rust
toolchain.

- src/trust_engine.veri.md: the Veri DSL spec of the derivation core
  (believed names + constraint delegation, IPs, authz, pattern-resolved
  endorser/target), carrying the types and contracts.
- src/trust_engine/kernel/: the verified TrustEngine.dfy and its
  Dafny -> Rust extraction, as a self-contained crate excluded from the
  workspace (its own vendored dafny_runtime).
- src/trust_engine/{marshal,runner}.rs: intern intermesh types into the
  kernel's relations, run it, and marshal results back into Derivation,
  keeping derive's signature identical.
- finalize/expand_authz_side/imids_in_pattern move out of the native-only
  impl so both paths share them; MAX_DERIVATION_ITERATIONS is localized
  to the native loop.
- .veri/veri.toml maps the spec to its committed output dir; xtask
  forwards INTERMESH_FEATURES so the e2e binary can build the kernel.
@KerneyJ
KerneyJ force-pushed the verify-trust-engine branch from db084bb to d90142b Compare June 30, 2026 19:31
@KerneyJ
KerneyJ marked this pull request as ready for review June 30, 2026 22:44
@ejj ejj closed this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants