Proof-carrying effect plans and least-authority runtime for AI agents
realized effect <= approved effect
child permit <= parent permitstructured plan -> compile minimum permit -> approve once
-> check each tool call -> allow / deny / request expansion
-> emit receipt + proof -> audit realized effectsmoon run cmd/mainmoon run cmd/main -- compile docs-reader --calls 2 \
read-tree:docs exec:moon,test,--deny-warnmoon run cmd/main -- check --calls 1 --repeat 2 \
read-tree:docs read:docs/guide.mdmoon run cmd/main -- explain --calls 2 --bytes 10 --expires 20 \
--cost 4 --now 5 read-tree:docs read:docs/guide.md///|
test {
let permit = @moonpermit.compile_plan("docs", [
@moonpermit.effect_request(
@moonpermit.FileRead(@moonpermit.path_tree("docs")),
@moonpermit.budget(max_calls=1),
),
])
let runtime = @moonpermit.runtime(permit)
let receipt = runtime.check(
"read-1",
@moonpermit.FileRead(@moonpermit.path_exact("docs/guide.md")),
0L,
)
assert_true(receipt.allowed())
let explained = @moonpermit.runtime(permit).check_with_proof(
"read-with-proof",
@moonpermit.FileRead(@moonpermit.path_exact("docs/guide.md")),
0L,
)
assert_true(explained.receipt.allowed())
assert_eq(explained.proof.reason, @moonpermit.ReasonCode::Granted)
}moon check --deny-warn
moon test --deny-warn
moon fmt --check
moon infopub(all) struct AuditFinding {
receipt_index : Int
code : AuditIssueCode
message : String
} derive(Eq, ToJson, Debug)pub(all) struct AuthorizationProof {
sequence : Int
invocation_id : String
permit_id : String
requested : EffectScope
effect : String
verdict : Verdict
decision_grant_id : String?
reason : ReasonCode
checks : Array[ProofCheck]
} derive(Eq, ToJson, Debug)pub(all) struct CheckedAuthorization {
receipt : Receipt
proof : AuthorizationProof
} derive(Eq, ToJson, Debug)pub(all) enum EffectScope {
FileRead(PathScope)
FileWrite(PathScope)
FileDelete(PathScope)
ProcessExec(CommandScope)
NetworkSend(NetworkScope)
SecretRead(String)
} derive(Eq, ToJson, Debug)pub(all) struct ProofCheck {
kind : ProofCheckKind
status : ProofCheckStatus
grant_id : String?
explanation : String
} derive(Eq, ToJson, Debug)pub(all) struct Receipt {
sequence : Int
invocation_id : String
permit_id : String
verdict : Verdict
grant_id : String?
requested : EffectScope
effect : String
logical_time : Int64
byte_cost : Int64
reason : ReasonCode
message : String
remaining_calls : Int?
remaining_bytes : Int64?
} derive(Eq, ToJson, Debug)pub struct Runtime {
permit_id : String
states : Array[GrantState]
seen_invocations : Set[String]
receipts : Array[Receipt]
sequence : Int
}fn Runtime::check(self : Runtime, invocation_id : String, requested : EffectScope, now : Int64, byte_cost? : Int64) -> Receipt raise PermitErrorfn Runtime::check_with_proof(self : Runtime, invocation_id : String, requested : EffectScope, now : Int64, byte_cost? : Int64) -> CheckedAuthorization raise PermitErrorfn Runtime::delegate(self : Runtime, child_id : String, requests : Array[EffectRequest], now : Int64) -> Permit raise PermitErrorfn network_scope(host : HostScope, methods : Array[String], max_data_class : DataClass) -> NetworkScope raise ScopeErrorInstall
Download zipProof-carrying effect plans and least-authority runtime for AI agents