OpenKedge Research & ToolingarXiv:2612.03493KedgeSpec 0.9.0a2 · Apache-2.0

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.

Paper Authors:Jun He, Deying Yu (OpenKedge Research · Dec 2026)
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.

Assumptions:
  • 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.
Three-Layer ArchitectureDiscipline · Contract · Tool
01 · Engineering Paradigm (optional shorthand: AgC)
Agent Control as Code

The systems discipline introduced by the paper: separating declarative governance intent from the heterogeneous planes that reason over and enforce it.

02 · Open Semantic Contract
Agent Control Reference Specification

Implementation-independent NIR, NEC, and NRL semantics, provider capability contracts, and six conformance profiles (P1–P6) in SPEC.md.

03 · Reference Implementation & Developer Tool
KedgeSpeckedgespec

Declare once. Reason consistently. Enforce everywhere. The open-source compiler, evaluator, and CLI engineers install and run.

Goal: Agent Control as Code as the discipline, and KedgeSpec as its Terraform.
Ecosystem Organization

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.

LayerInfrastructure EcosystemAgent Control Ecosystem
ParadigmInfrastructure as CodeAgent Control as Code
Declarative languageHCLKedgeSpec specification
Reference toolTerraformKedgeSpec
CLIterraformkedgespec
Authoring artifactTerraform configurationAgent control specification
LifecyclePlan, apply, refreshCompile, plan, apply, reconcile
Four Normative Primitives · N = (H, M, T, O)

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.

Core Design Rule

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.

MAYM

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.

Conflict behaviorUnion of applicable grants; overridden by any matching MUST NOT or failed MUST.
MUST / MUST NOTH

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.

Conflict behaviorMUST NOT overrides every mandate and tenet; MUST clauses conjoin strictly.
SHOULD / SHOULD NOTT

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.

Conflict behaviorCycles and ties emit explicit diagnostics; choosing another admissible option is auditable discretion.
AFTER ... MUSTO

Obligations

What duties arise after an action commits.

Event-time temporal duties anchored to durable commitment receipts. Separates actual fulfillment timeliness from telemetry arrival.

Conflict behaviorCumulative per trigger; obligations never silently grant fulfillment authority.
Failure Modes Prevented

Recurring forms of Normative Modality Confusion

Paper Table 2 · Partial-Observability Dual Correctness
SHOULD (tenet)MUST (hard policy)

Discretion loss: blocks legitimately delegated plans

SHOULD (tenet)MAY (mandate)

Authority expansion outside delegated scope

UNDETERMINEDPERMITTED

Fail-open authority drift on missing facts

UNDETERMINEDDefinitive DENIED

Conflates missing evidence with permanent prohibition

Snapshot feasibilityExecution authorization

Premature admission before target and budget checks

Signed execution grantCommitted effect

Corrupts capacity accounting and obligation triggers

AD
Authority Drift
Projected permit outside authoritative admissible set
DL
Discretion Loss
Definitive denial blocking a delegated action
I_adm
Indeterminacy
Admissible action missing required observation
OAL
Operational Autonomy Loss
Fail-closed runtime rejection on missing facts
BAL
Behavioral Autonomy Loss
Agent escalates despite admissible options (prose penalty)
Interactive Architecture & Evidence Workbench

Inspect how one declaration compiles, executes, and verifies

production_sre declares mandates M1–M3, hard policies H1–H2, tenets T1–T2, and duty O1. Toggle defective mode to inspect CheckStaticCoverage (Listing 1b).
Compiled Output · Plane 01

Agent Plane

CompatibleAndQualified
  • 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)
Harness Preflight Envelope (JSON)
{
  "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)"]
}
Boundary Guarantee:Advisory ranking stays inside delegated authority; preflight removes the prose penalty.
Formal Contract · NIR, NEC, NRL

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).

Semantics · Cor. 1–3, Prop. 1–3

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.

Compilation · Lemma 1 & Theorem 1

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.

Execution · Theorem 2, Prop. 4, Cor. 4

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.

Reasoning · Prop. 5 & Automated J4

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.

Normative Reasoning Ledger (NRL) · Paper Figure 2

Cross-plane justification chain (J1–J7) under shared disruption budget

4 of 5 disruption units occupied · i1, i2 unhealthy
J1
Observation

i1, i2 unhealthy; concurrent plan faster

J2
Preference (T2)

Concurrent plan ranked above sequential

J3
Requirement (H2)

NEC requires 2 disruption units

J4
Refusal (Contrastive)

4 + 2 > 5 (1 left); J2 preference stays valid

J5
Revised Plan

Restart i1 first, recover, then i2

J6
Receipt (M1)

restart(i1) committed (history only)

J7
Duty (O1 / M3)

verify_health(i1) due within 5m

Agent Control Reference Specification

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).

P1Deps: none

Semantic Core

N = (H, M, T, O) validation, canonical NIR digests, Strong Kleene evaluation, Tarjan SCC choice, event-time obligation transitions (CV1–CV3, CV10).

P2Deps: P1

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).

P3Deps: P2

Governance Lifecycle

Deterministic plan, exact-ID approve, verified staged apply, independent refresh and drift detection with rollback guards.

P4Deps: P2

Execution Assurance

NEC derivation, TrustedWitnessVerifier + ValidateRuntimeWitnesses, durable single-use fencing, Option A revocation barrier, atomic commit and receipt outbox (CV7, CV9).

P5Deps: P4

Aggregate Governance

Eight-field twelve-transition reservation automaton, dynamic-capacity draining safety, conservative unknown-outcome holds, deduplicated obligations (CV8–CV10).

P6Deps: P1

Normative Reasoning

Typed judgment records, overlapping support-set revalidation, permanent historical receipts, nine-condition scoped reuse (CV11).

How KedgeSpec Connects to KedgeFlow

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.

Audited Scope & Open Research Agenda

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.
Frequently Asked Questions

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.

Inspect the Paper, Specification & Code

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.