Agent Control as Code.
KedgeSpec: Declare once. Reason consistently. Enforce everywhere.
Autonomous AI systems scatter operational rules across system prompts, tool schemas, authorization gateways, coordination locks, and post-action monitors. Independent edits break the semantic link across those planes, causing authority drift (admitting unauthorized actions) or discretion loss (blocking delegated ones).
Agent Control as Code puts delegated permissions, mandatory safeguards, preferences, and follow-up duties into one versioned specification. KedgeSpec compiles that specification into agent harnesses, native Cedar policies, protected execution boundaries, and obligation monitors, then reconciles drift across deployments.
PROTOTYPE VALIDATEDEvidence, scope & assumptions+
Evidence: Evaluated across native Cedar 4.12.2 refinement (6,144 bounded states, 0 mismatches, 5/5 mutations caught) with per-policy Z3 SMT unbounded-integer checks in CI; Python BFS and TLA+/TLC model checking (61,539 generated / 11,114 distinct TLC states, 0 violations, 9/9 Python and 5/5 TLC mutants caught); deterministic suites E1–E4; four-process loopback RPC qualification E6 (F1–F8, 0 violations across SIGKILL restarts, 5.71 ms median latency); and replay of 720 live LLM episodes across Qwen3-8B, GPT-5.6, and claude-fable-5 showing structured preflight eliminated prose-only behavioral autonomy loss (19/25 and 6/25 to 0/25) and reached 60/60 E5b resolutions versus 11/60 baseline (10/59 excluding one Codex outlier).
Scope: Single-host SQLite, four-process loopback RPC with trusted experimental workload observations, finite-domain model checks, per-policy SMT over parsed Cedar ASTs, and Level B replay of retained cumulative LLM logs; geo-distributed consensus, cross-host single-use deduplication, OS-level non-bypassability, unbounded Lean/TLAPS proofs, and live equal-info Level C ablations remain open.
- Target mutations in scope pass through mediated NEC admission gates without unmodeled out-of-band writers.
- Provider capability contracts, trusted issuer keyrings, and consistency-domain ordering hold for the claimed profile.
- E6 loopback RPC relies on trusted experimental workload observations and logical evidence timestamps.
- Stochastic language models remain outside the trusted computing base and cannot be unconditionally bounded against escalation.
The systems discipline introduced by the paper: separating declarative governance intent from the heterogeneous planes that reason over and enforce it.
Implementation-independent NIR, NEC, and NRL semantics, provider capability contracts, and six conformance profiles (P1–P6) in SPEC.md.
kedgespecDeclare once. Reason consistently. Enforce everywhere. The open-source compiler, evaluator, and CLI engineers install and run.
How Agent Control as Code maps to Infrastructure as Code
Infrastructure engineers say they manage infrastructure with Terraform and define infrastructure as code. Teams adopting KedgeSpec follow the same structure: declare agent control as code in versioned source, compile it across planes, and manage lifecycle changes with kedgespec.
| Layer | Infrastructure Ecosystem | Agent Control Ecosystem |
|---|---|---|
| Paradigm | Infrastructure as Code | Agent Control as Code |
| Declarative language | HCL | KedgeSpec specification |
| Reference tool | Terraform | KedgeSpec |
| CLI | terraform | kedgespec |
| Authoring artifact | Terraform configuration | Agent control specification |
| Lifecycle | Plan, apply, refresh | Compile, plan, apply, reconcile |
Simplify the authoring experience, keep the four normative modalities
Conventional authorization answers binary permit-or-deny queries. Collapsing agent governance into allow, deny, and approve erases discretionary preferences, post-action temporal obligations, and unresolved execution prerequisites, introducing the exact Normative Modality Confusion the paper isolates.
Tenets guide choice strictly inside delegated authority. Mandatory rules count as covered only when enforced at the boundary where they apply. Valid projections preserve both safety and delegated discretion.
Mandates
What an agent is empowered to do.
Delegates scoped authority over principals, actions, resources, and guards. Without a satisfied MAY rule, conforming systems default to deny.
Hard Policies
What an agent must satisfy or never violate.
Non-compensable boundaries partitioned into pre-state admission rules, transition guards, and post-state invariants such as shared disruption caps.
Tenets
How an agent should exercise its legitimate discretion.
Defeasible contextual preferences that rank admissible plans via strongly connected component (SCC) condensation without creating or withdrawing authority.
Obligations
What duties arise after an action commits.
Event-time temporal duties anchored to durable commitment receipts. Separates actual fulfillment timeliness from telemetry arrival.
Recurring forms of Normative Modality Confusion
Discretion loss: blocks legitimately delegated plans
Authority expansion outside delegated scope
Fail-open authority drift on missing facts
Conflates missing evidence with permanent prohibition
Premature admission before target and budget checks
Corrupts capacity accounting and obligation triggers
Inspect how one declaration compiles, executes, and verifies
M1–M3, hard policies H1–H2, tenets T1–T2, and duty O1. Toggle defective mode to inspect CheckStaticCoverage (Listing 1b).Agent Plane
- Discovers delegated M1–M3 actions
- Computes conservative preflight envelopes (FEASIBLE / INFEASIBLE / UNDETERMINED)
- Ranks admissible plans via T1 (locality) and T2 (recovery speed)
- Discloses unresolved requirements R_N (fresh health, H2 hold, O1 duty)
{
"action": "restart_instance(i1)",
"feasibility": "FEASIBLE_AT_SNAPSHOT",
"assurance": "FORMAL_REFERENCE",
"matched_rules": ["M1-restart", "H2-disruption-limit"],
"preference_rank": { "rule": "T1", "status": "PREFERRED_LOCAL" },
"outstanding_requirements": [
{ "kind": "reservation", "rule": "H2-disruption-limit", "cost": 1 },
{ "kind": "fresh_evidence", "rule": "M1-restart", "fact": "instance_unhealthy" }
],
"post_commit_duties": ["O1: verify_health(i1) within 5m (authorized by M3)"]
}Twelve formal results across compilation, admission, draining, and reasoning
The paper builds a non-circular proof stack from base definitions through commitment-boundary coverage (Theorem 1), protected-effect preservation (Theorem 2), dynamic-capacity draining (Proposition 4), and mode-indexed global safety over modeled transitions (Corollary 4).
Modality Separation & Prose-Penalty Reduction
Tenet edits leave mandatory admissibility and compiled Cedar output invariant. Monotonic Strong Kleene evaluation produces sound conservative envelopes over partial observations, Tarjan SCC condensation keeps preferred choice sets nonempty without creating authority, and preflight envelopes collapse agent-side epistemic ambiguity for envelope-respecting policies.
Rely-Guarantee Compositional Coverage
Fourteen-field HMAC-signed coverage witnesses bind each mandatory clause to exact operation identity, composite mandatory semantic identity (msid), validated authority epochs, and seven operational preservation classes. Static coverage checks (Procedure 1a) reject unqualified or continuous-invariant gaps, while fail-closed commit admission (Procedure 1b) establishes commitment-boundary validity.
Protected Effects, Draining Safety & Global Composition
Mediated NEC admission composes with a twelve-transition serialized reservation automaton across normal and draining modes. Capacity contractions enter draining without admitting fresh load, and split-store single-use crashes reconcile safely via transactional co-location or three-step Verify-Fence-Reissue.
Justification Continuity & Scoped Reuse
The Normative Reasoning Ledger records typed judgments (J1–J7) with ATMS-style overlapping support sets and nine-condition scoped reuse. Historical receipts stay permanent for audit without granting current permission, and deterministic AST/NEC/coordinator diagnosis synthesizes contrastive J4 refusals.
Cross-plane justification chain (J1–J7) under shared disruption budget
i1, i2 unhealthy; concurrent plan faster
Concurrent plan ranked above sequential
NEC requires 2 disruption units
4 + 2 > 5 (1 left); J2 preference stays valid
Restart i1 first, recover, then i2
restart(i1) committed (history only)
verify_health(i1) due within 5m
Six modular conformance profiles and incremental adoption
Independent implementations can adopt conformance profiles P1 through P6 incrementally, backed by eleven observable conformance vectors (CV1–CV11) and portable kits (acac-spec/0.8-draft, acac-portable/0.1, acac-portable/0.2, acac-registered/0.1).
Semantic Core
N = (H, M, T, O) validation, canonical NIR digests, Strong Kleene evaluation, Tarjan SCC choice, event-time obligation transitions (CV1–CV3, CV10).
Cross-Plane Compilation
Capability-aware compiler Compile(N, C) -> (P, Gamma, Delta), deterministic Cedar/OPA projection, five-outcome static coverage, ANALYSIS_ONLY exit on gaps (CV4–CV6).
Governance Lifecycle
Deterministic plan, exact-ID approve, verified staged apply, independent refresh and drift detection with rollback guards.
Execution Assurance
NEC derivation, TrustedWitnessVerifier + ValidateRuntimeWitnesses, durable single-use fencing, Option A revocation barrier, atomic commit and receipt outbox (CV7, CV9).
Aggregate Governance
Eight-field twelve-transition reservation automaton, dynamic-capacity draining safety, conservative unknown-outcome holds, deduplicated obligations (CV8–CV10).
Normative Reasoning
Typed judgment records, overlapping support-set revalidation, permanent historical receipts, nine-condition scoped reuse (CV11).
Observe existing governance
Compare tools exposed to an agent against native Cedar authorization decisions and inspect concrete discrepancy evidence before changing production policies.
Compile one declaration
Generate native Cedar authorization and agent harness guidance from a single versioned file, review structural diffs with kedgespec plan, and surface uncovered requirements before deployment.
Assure protected execution
Run governed actions with authoritative target admission, shared occupancy limits, durable receipts, and post-commit recovery duties even after ambiguous timeouts.
Declarative source compiled onto a runtime control plane
KedgeSpec handles the declarative specification, static coverage gating, cross-plane compilation, and governance lifecycle. KedgeFlow enforces runtime action grants, target guards, and exposure conservation at the execution boundary.
KedgeSpec compiles portable action descriptors and source-bound Normative Execution Contracts targeting KedgeFlow (disposably qualified in CI for postgres.reservation.set.v1@1.0). Together they separate what an organization declares from how individual runtimes enforce it.
What the current prototype qualifies and what remains open
- Qualified today: Single-writer SQLite workspaces, single-host durable single-use evidence storage, four-process loopback RPC under an Option A revocation barrier, bounded Cedar/Z3 and TLA+/TLC checks, and a disposable KedgeFlow SQL leaf.
- Open work: Multi-region WAN consensus, cross-host single-use deduplication, adversarial production telemetry, OS-level eBPF/LSM mediation for uncooperative writers, unbounded Lean/TLAPS proofs, organizational multi-team policy composition, and live equal-info Level C LLM batches.
Agent Control as Code & KedgeSpec, explained
How do Agent Control as Code, the Reference Specification, and KedgeSpec relate?
Agent Control as Code is the engineering discipline introduced in arXiv:2612.03493, parallel to Infrastructure as Code. The Agent Control Reference Specification (SPEC.md) defines the open semantic contract, provider capability model, and conformance profiles P1–P6 that independent implementations can target. KedgeSpec is the open-source reference implementation, compiler, and CLI (kedgespec) that teams install and run.
Why keep four normative primitives instead of simplifying to allow, deny, and approve?
Collapsing agent governance into allow, deny, and approve erases discretionary preferences, post-action temporal obligations, and unresolved execution prerequisites. When preferences are compiled as prohibitions, systems suffer discretion loss; when missing facts are treated as denials or permits, systems either over-block or fail open. KedgeSpec simplifies authoring ergonomics while keeping MAY, MUST/MUST NOT, SHOULD/SHOULD NOT, and AFTER...MUST distinct.
What is the Prose Penalty observed in the paper?
In the 720-episode LLM study (E5/E5b), giving frontier models prose-only governance text (C2) caused severe Behavioral Autonomy Loss: GPT-5.6 escalated unnecessarily on 19/25 admissible tasks and claude-fable-5 on 6/25, because prose mentions prerequisites like shared disruption holds without evaluated truth values or boundary ownership. Replacing prose rules with deterministic Strong Kleene preflight envelopes (C3) eliminated those unnecessary escalations (0/25 on both models).
How does KedgeSpec work with Cedar, OPA, and KedgeFlow?
KedgeSpec compiles stateless mandates and hard policies into native Cedar (verified across 6,144 bounded states plus Z3 SMT checks in CI) and supports restricted Boolean OPA snapshots. When rules require shared reservations, durable single-use approvals, or post-commit duties, KedgeSpec compiles portable execution contracts targeting local protected providers or KedgeFlow (disposably qualified for postgres.reservation.set.v1@1.0).
What is verified today, and what remains outside current scope?
The 0.9.0a2 developer prerelease (and frozen v0.8.0a4 research artifact) verifies single-writer SQLite workspaces, single-host durable single-use storage, a four-process loopback RPC deployment under an acknowledged revocation barrier (E6 F1–F8, zero violations), finite-domain Cedar/Z3 and TLA+/TLC model checks, and verbatim replay of 720 historical LLM episodes. Geo-distributed consensus, cross-host single-use deduplication, OS-level eBPF mediation, unbounded Lean/TLAPS proofs, and live equal-info Level C LLM batches remain open work.
Can I try KedgeSpec locally without cloud credentials or LLM API keys?
Yes. KedgeSpec 0.9.0a2 targets CPython 3.11–3.13 under Apache 2.0, and all core examples (snapshot evaluation, cross-plane Cedar compilation, local governance lifecycle, protected SQLite execution, and shared reasoning) run locally without external model keys or production credentials. OpenAI Agents SDK and LangGraph integrations are optional.
Declare agent control once. Verify it across every plane.
Read the full 24-page manuscript on arXiv, inspect SPEC.md and the portable conformance kits, or run the local SRE examples with kedgespec.