mirror of
https://github.com/hanzoai/proofs.git
synced 2026-10-30 18:23:34 +00:00
87 lines
2.6 KiB
Lean4
87 lines
2.6 KiB
Lean4
/-
|
|
Deployment Correctness
|
|
|
|
Verified builds produce deployment artifacts.
|
|
Deployment requires attestation + authorization.
|
|
|
|
Maps to:
|
|
- hanzo/platform: PaaS deployment API
|
|
- hanzo/universe: K8s manifests
|
|
- hanzo/docker: container image configs
|
|
|
|
Properties:
|
|
- Only attested builds can be deployed
|
|
- Deployment is idempotent (same hash → same result)
|
|
- Rollback preserves prior attestation
|
|
-/
|
|
|
|
import Mathlib.Data.Nat.Defs
|
|
import Mathlib.Tactic
|
|
|
|
namespace Platform.Deploy
|
|
|
|
/-- Deployment target environment -/
|
|
inductive Environment where
|
|
| development
|
|
| staging
|
|
| production
|
|
deriving DecidableEq, Repr
|
|
|
|
/-- Environment risk ordering -/
|
|
def Environment.risk : Environment → Nat
|
|
| .development => 0
|
|
| .staging => 1
|
|
| .production => 2
|
|
|
|
/-- Build artifact with attestation -/
|
|
structure Artifact where
|
|
hash : Nat -- content hash
|
|
attested : Bool -- has discharge proof
|
|
attestedBy : Nat -- builder's public key
|
|
deriving DecidableEq, Repr
|
|
|
|
/-- Deployment request -/
|
|
structure DeployRequest where
|
|
artifact : Artifact
|
|
target : Environment
|
|
deployer : Nat -- deployer identity
|
|
authorized : Bool -- passed IAM check
|
|
|
|
/-- Deployment check: only attested + authorized deploys proceed -/
|
|
def canDeploy (req : DeployRequest) : Bool :=
|
|
req.artifact.attested && req.authorized
|
|
|
|
/-- Unattested artifacts cannot be deployed -/
|
|
theorem unattested_blocked (req : DeployRequest) (h : req.artifact.attested = false) :
|
|
canDeploy req = false := by
|
|
simp [canDeploy, h]
|
|
|
|
/-- Unauthorized deployers are blocked -/
|
|
theorem unauthorized_blocked (req : DeployRequest) (h : req.authorized = false) :
|
|
canDeploy req = false := by
|
|
simp [canDeploy, h]
|
|
|
|
/-- Both attestation AND authorization required -/
|
|
theorem both_required (req : DeployRequest) (h : canDeploy req = true) :
|
|
req.artifact.attested = true ∧ req.authorized = true := by
|
|
simp [canDeploy, Bool.and_eq_true] at h
|
|
exact h
|
|
|
|
/-- Idempotency: same artifact hash → same deployment outcome -/
|
|
theorem deploy_idempotent (a1 a2 : Artifact) (h : a1.hash = a2.hash)
|
|
(h_att : a1.attested = a2.attested) (h_by : a1.attestedBy = a2.attestedBy) :
|
|
a1 = a2 := by
|
|
cases a1; cases a2; simp_all
|
|
|
|
/-- Production requires strictly more authorization than staging -/
|
|
theorem production_higher_risk :
|
|
Environment.risk .production > Environment.risk .staging := by
|
|
simp [Environment.risk]
|
|
|
|
/-- Development has lowest risk -/
|
|
theorem dev_lowest_risk (e : Environment) :
|
|
Environment.risk .development ≤ Environment.risk e := by
|
|
cases e <;> simp [Environment.risk]
|
|
|
|
end Platform.Deploy
|