Behavioral Contracts

A Behavioral Contract consolidates an agent's behavioral expectations into a single, versioned, cryptographically sealed, machine-enforceable artifact. It declares what the agent should do, how often, in what patterns, with what outcomes — and the Behavioral Control Plane holds it accountable to that declaration continuously.

Overview

Contracts bridge the gap between an agent's identity (birth certificate) and its runtime governance. Where a certificate says who an agent is, a contract says what it should do.

Contracts bundle:

  • Identity binding — links to the agent's birth certificate and archetype

  • Behavioral DNA — expected action, target, and outcome distributions derived from the archetype prior

  • Authorized scope — what actions and targets the agent is permitted to use

  • Trust parameters — initial trust score, floor, and ceiling

  • Behavioral invariants — declarative rules the agent must never violate, compiled into runtime checks by the invariant compiler

  • Semantic anchors — expected meaning-to-behavior mappings (consumed by the Semantic Drift system)

  • Drift thresholds — per-distribution maximum allowed drift before alert/intervention

Core Concepts

Immutability and Versioning

Contracts are frozen dataclasses — once created, they cannot be modified. Changing an agent's expectations requires issuing a new contract version. The ContractStore maintains the full version history for audit purposes.

from nomotic import BehavioralContract, ContractStore

store = ContractStore()
store.store(contract_v1)  # version=1
store.store(contract_v2)  # version=2, must be > 1

active = store.get_active("agent-1")       # returns v2
v1 = store.get_version("agent-1", 1)       # returns v1
history = store.get_history("agent-1")      # returns [v1, v2]

Cryptographic Sealing

Every contract can be sealed with a SigningKey and verified with the corresponding VerifyKey. The seal covers all contract fields except signature and signed_by, so any tampering invalidates the seal.

Contract Generation

The generate_contract() function creates a contract from an archetype prior, automatically populating expected distributions:

If the archetype has a known prior (e.g., customer-experience), the expected distributions are populated from it. Unknown archetypes produce empty distributions — the agent starts with no behavioral baseline and builds one from observations.

Runtime Integration

Drift Threshold Enforcement

When a contract specifies drift_thresholds, the runtime compares the agent's current drift score against those thresholds after every evaluation. If any threshold is exceeded, the violation is recorded in the verdict metadata:

Configuration

Contract support is enabled by default in RuntimeConfig:

To use a shared store across components, pass an explicit ContractStore instance.

API Endpoints

Method
Path
Description

POST

/v1/contracts

Generate and store a contract

GET

/v1/contracts/{agent_id}

Get active contract

GET

/v1/contracts/{agent_id}/history

Get version history

GET

/v1/contracts/{agent_id}/diff?v1=X&v2=Y

Diff between versions

POST /v1/contracts

GET /v1/contracts/{agent_id}/diff?v1=1&v2=2

Returns per-field changes between two versions:

CLI Commands

Contract Fields Reference

Field
Type
Description

contract_id

str

Unique identifier (UUID)

version

int

Monotonically increasing version number

agent_id

str

Agent this contract governs

created_at

float

Unix timestamp of creation

certificate_id

str | None

Linked birth certificate

archetype

str

Archetype name (default: "general")

expected_action_distribution

dict[str, float]

Expected action type ratios (~1.0)

expected_target_distribution

dict[str, float]

Expected target ratios (~1.0)

expected_outcome_distribution

dict[str, float]

Expected verdict ratios (~1.0)

authorized_scope

dict[str, Any]

Authorized actions and targets

initial_trust

float

Starting trust score (default: 0.5)

trust_floor

float

Minimum trust (default: 0.0)

trust_ceiling

float

Maximum trust (default: 1.0)

invariants

list[dict]

Behavioral invariant specs

semantic_anchors

list[dict]

Semantic anchor definitions

drift_thresholds

dict[str, float]

Max drift per distribution (0.0–1.0)

signature

str

Hex-encoded cryptographic signature

signed_by

str

Signer identity

Drift Threshold Keys

Key
Distribution
What It Measures

action

Action

Shift in what types of actions the agent performs

target

Target

Shift in what resources the agent operates on

temporal

Temporal

Shift in when/how frequently the agent acts

outcome

Outcome

Shift in governance evaluation outcomes

semantic

Semantic

Shift in the intent/meaning of actions

overall

Composite

Weighted combination of all distributions

Example: Full Lifecycle

Last updated