IR Schema¶
This document describes the current persisted IR contract implemented under src/akc/ir/ and the way compile/runtime surfaces consume it.
The IR is a versioned, tenant-scoped structural graph that sits between plan/intent compilation and later artifact passes such as orchestration, coordination, delivery projection, and runtime-bundle emission.
Overview¶
The root object is IRDocument.
Current top-level fields:
schema_kind— alwaysakc_irschema_version— current default2format_version— current default2.0tenant_idrepo_idnodes
Supported version pairs are currently:
(1, "1.0")(2, "2.0")
Construction and loading fail closed for unsupported pairs.
Core invariants:
- all nodes must share the document
tenant_id - node ids must be unique within the document
- JSON serialization is deterministic
- document and node fingerprints are SHA-256 over canonical JSON via
stable_json_fingerprint
Document model¶
IRDocument is defined in src/akc/ir/schema.py.
Important behavior:
to_json_obj()sorts nodes byidto_json_file()writes deterministic JSON with sorted keysfrom_json_obj()requiresschema_kind == "akc_ir"from_json_file()is the stable loader for persisted.jsonIR artifacts
The persisted compile-time IR sidecar is written at:
.akc/ir/<run_id>.json
That same IR is also fingerprinted into the run manifest and referenced from runtime bundles through system_ir_ref.
Node model¶
IRNode is the typed graph node unit.
Current fields:
idtenant_idkindnamepropertiesdepends_on- optional
effects - optional
provenance - optional
contract
Stable ids are typically built with stable_node_id(kind=..., name=...).
Current allowed node kinds:
serviceworkflowintententityknowledgeintegrationpolicyagentinfrastructureother
Important serialization rules:
depends_onis normalized and sorted- provenance rows are sorted deterministically
nulloptional fields are omitted from the persisted JSON
Effects and provenance¶
effects is an EffectAnnotation and captures runtime/policy-relevant capability boundaries:
networkfs_readfs_writesecretstools
provenance is a list of ProvenancePointer rows.
Current allowed provenance kinds:
doc_chunkmessageopenapi_operationfileother
Each provenance pointer carries an explicit tenant_id, and node construction rejects provenance rows whose tenant does not match the enclosing node.
Operational contracts¶
Nodes may carry a typed contract instead of burying operational meaning in opaque properties.
OperationalContract currently supports:
contract_idcontract_categorytriggersio_contract- optional
state_machine - optional
runtime_budget - optional
acceptance
Current allowed contract categories:
runtimedeploymentauthorizationacceptance
Supporting contract types:
ContractTriggerIOContractStateMachineContractStateTransitionOperationalBudget
Important invariants:
- contracts must have at least one trigger
- contracts must always have an
io_contract - trigger ids must be unique within a contract
state_machineis only valid forcontract_category="runtime"- transition ids must be unique within a state machine
- when a transition has
trigger_id, it must reference a declared contract trigger OperationalBudgetmust set at least one ofmax_seconds,max_steps, ormax_tokens
Compile-time IR emission¶
The shared PlanState-to-IR builder lives in:
src/akc/compile/ir_builder.py
Current compile behavior:
- compile emits a first-class
intentnode when intent context is available - each plan step becomes a
workflownode - workflow nodes carry runtime contracts derived from
(plan_id, step_id) - intent nodes carry acceptance contracts derived from active success criteria
- knowledge-layer compilation can emit a
knowledgehub node plus linked constraint/decision entities
The IR is not just prompt context. It is a shared structural spine used by multiple later passes.
Runtime-facing linkage¶
The runtime bundle is a separate artifact contract, but it directly references the persisted IR.
Current linkage points:
system_ir_ref- optional inline
system_ir referenced_ir_nodesreferenced_contractsdeployment_intents
Current runtime-bundle schema versions supported by compile are 1 through 4, with 4 as the default.
Important current expectations:
system_ir_ref.pathpoints at.akc/ir/<run_id>.jsonsystem_ir_ref.fingerprintmust match the IR document fingerprintsystem_ir_ref.format_versionandschema_versionmust match the referenced IRreferenced_ir_nodesis a filtered runtime-facing projection of the full IRdeployment_intentsis a denormalized deployable projection used by adapters and reconciliation paths- when enabled, compile can embed the full IR inline with
embed_system_ir=true
Current runtime-bundle additions in v4¶
Runtime-bundle v4 is the current default and adds more IR-adjacent control data, including:
coordination_ref- optional
coordination_spec reconcile_desired_state_sourcereconcile_deploy_targets_from_ir_onlydeployment_intents_ir_alignmentdeployment_provider_contractworkflow_execution_contractcoordination_execution_contract
Those fields live on the runtime bundle, not on IRDocument itself, but they assume the IR remains the structural source of truth.
Validation and policy hooks¶
IR structure is not treated as best-effort metadata.
Current compile-time checks include:
- graph/version validation in
src/akc/ir/schema.py - operational-structure validation in
src/akc/compile/ir_operational_validate.py - runtime-bundle consistency checks in
src/akc/compile/artifact_consistency.py - optional deployment-intent alignment checks between
deployment_intentsand deployablereferenced_ir_nodes
Relevant controller policies:
ir_operational_structure_policydeployment_intents_ir_alignment_policy
These checks are what keep runtime bundles, reconciliation, and delivery projection aligned with the emitted IR rather than drifting into separate ad-hoc shapes.
Minimal example¶
{
"schema_kind": "akc_ir",
"schema_version": 2,
"format_version": "2.0",
"tenant_id": "tenant_1",
"repo_id": "repo_1",
"nodes": [
{
"id": "irn_example",
"tenant_id": "tenant_1",
"kind": "workflow",
"name": "CompileStep",
"properties": {},
"depends_on": [],
"contract": {
"contract_id": "opc_rt_example",
"contract_category": "runtime",
"triggers": [
{
"trigger_id": "t_compile_runtime_start",
"source": "compile.runtime.start",
"details": {}
}
],
"io_contract": {
"input_keys": ["objective"],
"output_keys": ["step_status"]
}
}
}
]
}