CADL: Contract Architecture Description Language
English | 日本語
CADL is a domain-specific language for formally describing, verifying, and deploying institutional designs in Systems of Systems (SoS). It enables stakeholders — from engineers to citizens — to define governance rules, contracts, protocols, and incentive structures in a machine-readable, verifiable format.
CADL is developed at ERTL, Graduate School of Informatics, Nagoya University.
Documentation
- Specification and language reference (日本語) — start with Chapter 5 for the language and Appendix A for the complete syntax
- Hands-on course — a guided walkthrough of the toolchain
- This README — installation, commands, and the bundled examples
- CHANGELOG · Contributing · Security policy · Issues
Motivation
In SoS environments, independently operated systems must coordinate under shared rules. Today, these rules exist mostly as natural-language contracts and tacit agreements, making them prone to ambiguity, contradiction, and drift between design intent and implementation.
CADL addresses three core goals:
- Make institutions computable — Model real-world rules (authority structures, information-sharing policies, incentive mechanisms) as first-class data objects that can be copied, composed, versioned, and searched.
- Detect contradictions and violations — Enable automated consistency checking (via SMT solvers and model checkers) and runtime monitoring of institutional constraints.
- Generate executable artifacts — Translate verified institutional designs into control logic, monitoring code, and smart contracts for target platforms.
Language Overview
A CADL file (.cadl) uses a YAML-like declarative syntax. Each file describes one SoS definition containing:
| Section | Purpose |
|---|---|
actors |
Constituent systems with roles, autonomy levels, and capabilities |
contracts |
Assume-guarantee contracts with authority (beta), information sharing (alpha), and incentive (lambda) parameters |
protocols |
Coordination procedures with message passing, timing constraints, and fallback behaviors |
algorithms |
References to central/local algorithms |
transitions |
Regime transitions with safety invariants |
metrics |
Performance indicators with formulas and targets |
verification |
Properties to check, with the method to use (only smt is implemented) |
A contract may also carry lifecycle: and monitors: blocks (the SoS-DSL extension), which describe the states a contract instance goes through and the conditions watched while it runs. The complete list of keys is in Appendix A and Appendix E of the specification.
Institutional Parameters
CADL quantifies institutional characteristics using three continuous parameters in [0, 1]:
- alpha — Information sharing degree (0 = local only, 1 = full sharing)
- beta — Decision centralization (0 = fully distributed, 1 = centralized)
- lambda — Incentive strength (0 = directive-based, 1 = market mechanism)
Example
sos:
name: "RobotDeliverySystem"
type: Acknowledged
version: "1.0.0"
actors:
- id: DISPATCHER
role: "global_planner"
autonomy: low
- id: "ROBOT[1..N]"
role: "delivery_vehicle"
autonomy: high
contracts:
- id: DELIVERY_SLA
parties:
- DISPATCHER
- "ROBOT[*]"
assume:
- "DISPATCHER.is_operational == true"
- "network_latency <= 200ms"
guarantee:
- "all_routes_conflict_free()"
- "delivery_time <= promised_time * 1.2"
authority:
decision_holder: DISPATCHER
beta: 0.8
information:
alpha: 0.8
incentives:
type: reputation
lambda: 0.5
rules:
- "reward(ROBOT[i], 10) when on_time_delivery"
- "penalty(ROBOT[i], -5) when route_deviation"
duration: indefinite
protocols:
- id: FAILURE_REPLAN
trigger: "road_failure_detected_by(ROBOT[i])"
steps:
- "ROBOT[i] -> DISPATCHER : failure_report"
- "DISPATCHER : recompute_routes"
- "DISPATCHER -> ROBOT[*] : new_route"
timing:
max_total: 500ms
postcondition: "all_routes_conflict_free()"
transitions:
- from: IDLE
to: ACTIVE
condition: "delivery_request_pending == true"
safety_invariant: "all_routes_conflict_free()"
- from: ACTIVE
to: IDLE
condition: "all_deliveries_complete == true"
safety_invariant: "all_robots_at_base == true"
Installation
Requires Python 3.9+.
pip install cadl-lang
# With AI features (requires Anthropic API key)
pip install "cadl-lang[ai]"
The distribution is named cadl-lang on PyPI; the import package and the command are both cadl.
To work on CADL itself, install from source:
git clone https://github.com/ertlnagoya/cadl
cd cadl
pip install -e ".[dev]"
pytest
Usage
# Parse a CADL file and display summary
cadl parse examples/robot_delivery.cadl
# Parse and run type checks
cadl check examples/robot_delivery.cadl
# Full verification (type check + SMT + deadlock detection)
cadl verify examples/robot_delivery.cadl
# Generate Python runtime code
cadl codegen examples/robot_delivery.cadl -o /tmp/robot_delivery
# Generate Solidity smart contracts
cadl codegen examples/robot_delivery.cadl --target solidity -o /tmp/solidity_out
# Generate OPA/Rego policies
cadl codegen examples/robot_delivery.cadl --target opa -o /tmp/rego_out
# Generate Unity C# for SoS-DSL contracts (lifecycle / monitors)
cadl codegen examples/sos_dsl_robot_delivery.cadl --target unity-csharp -o /tmp/unity_out
# Agent governance extension (agents 0.1): decide one message at the boundary,
# replay a recorded sequence of messages (holds, delegations, audit records),
# verify the hash chain of the audit log, and generate the boundary policy as
# Rego or Cedar (an MCP gateway is described under Agent Governance below)
cadl agents-decide examples/agents_tool_governance.cadl --input examples/agents_inputs/delete_file.json
cadl agents-run examples/agents_tool_governance.cadl --trace examples/traces/agents_tool_governance_a_approved.jsonl --audit /tmp/audit.jsonl
cadl audit-verify /tmp/audit.jsonl --source examples/agents_tool_governance.cadl
cadl codegen examples/agents_tool_governance.cadl --target agent-rego -o /tmp/agent_rego
cadl codegen examples/agents_tool_governance.cadl --target agent-cedar -o /tmp/agent_cedar
# Analyze regime transitions
cadl regime-map examples/smart_city_traffic.cadl
cadl regime-map examples/smart_city_traffic.cadl --format dot -o regime.dot
# IEC 62853-oriented dependability summary
cadl iec62853 examples/robot_delivery.cadl
cadl iec62853 examples/smart_city_traffic.cadl --format json
# Verdicts of the norms extension on a recorded trace
cadl norms-eval examples/norms_robot_delivery.cadl --trace examples/traces/norms_robot_delivery_a_fulfilled.jsonl
# The same verdicts from the monitor in the generated Python package (it runs without cadl)
cadl codegen examples/norms_robot_delivery.cadl -o /tmp/gen/robot_delivery_norms
(cd /tmp/gen && python -m robot_delivery_norms.norms_monitor "$OLDPWD/examples/traces/norms_robot_delivery_a_fulfilled.jsonl" --format text)
# What an amendment from one version to the next does to the norms
cadl norms-diff examples/norms_amendment_v1.cadl examples/norms_amendment_v2.cadl
# Amendment extension: which parameters changed between two versions of the
# rules, and whether each change stays within the declared amendability
cadl amend-diff examples/amendment_robot_town_v1.cadl examples/amendment_robot_town_v2.cadl
# Design-time check of the norms of one contract instance over all behaviours
# (needs PRISM on PATH): violable norms, conflicts, powers never exercised, with witness traces
cadl norms-check examples/norms_check_conflict.cadl --bindings i=1 --export /tmp/norms-check
# Grounding extension: the derived indices of information sharing and of the
# concentration of powers, and the incentive coverage, of each contract
cadl norms-indices examples/grounding_robot_delivery.cadl
cadl norms-indices examples/grounding_robot_delivery.cadl --format json
# Stochastic model extension: export the model: block to PRISM, one model
# file and one properties file per design
cadl model-export examples/stochastic_robot_delivery.cadl -o prism_out/
# Evaluate its properties with the internal reference evaluator (exact arithmetic)
cadl model-check examples/stochastic_robot_delivery.cadl
cadl model-check examples/stochastic_robot_delivery.cadl --regime-map best_for_delivery --grid 5
# Certified regime map: which regime is best in which cell of the parameter space
cadl model-check examples/stochastic_robot_delivery.cadl --regime-map best_for_delivery --certify
# Strategic model extension (games 0.1): is the compliance profile a Nash
# equilibrium, and in which cells of a parameter region is it one?
cadl game-check examples/games_robot_delivery.cadl
cadl game-check examples/games_robot_delivery.cadl --certify --equilibrium comply_by_lambda
# Generate CADL from natural language (requires ANTHROPIC_API_KEY)
cadl ai "A fleet of 5 autonomous drones surveying farmland, coordinated by a ground station"
cadl ai -f requirements.txt -o output.cadl
Architecture
The CADL toolchain follows a standard compiler pipeline:
.cadl file
|
v
+------------------+
| Parser | YAML structure + Lark expression grammar
| (parser.py) | -> Abstract Syntax Tree
+--------+---------+
|
v
+------------------+
| Type Checker | Actor reference resolution, parameter range
| (type_checker) | validation, contract party consistency
+--------+---------+
|
v
[Checked AST]
|
+----+----+----------+-----------+
v v v v
SMT Code Regime IEC 62853
Verify Generate Map Summary
(Z3) (codegen/) (regime_map) (iec62853)
|
+-----+-----+--------+
v v v v
Python Solidity OPA/Rego Unity C#
Code Generation
cadl codegen generates executable code from a CADL definition. It runs the type check but not the verifier, so run cadl verify first. Four targets are supported:
Python (--target python, default):
| Generated Module | Content |
|---|---|
actors.py |
Actor base classes with role, autonomy, and capability stubs |
contracts.py |
Contract monitor classes with assume/guarantee checks |
protocols.py |
Async protocol state machines with timeout handling |
transitions.py |
Regime controller with transition conditions |
metrics.py |
Metrics collector with formula computation |
runtime.py |
Top-level orchestrator wiring all components |
norms_monitor.py |
Only for a file that declares norms: 0.1: an online monitor of the norms, counts-as rules and temporal items of its contracts (below) |
Generated code inherits from base classes in cadl.codegen.runtime_support; norms_monitor.py does not import cadl.
Solidity (--target solidity):
Generates Ethereum smart contracts (.sol):
- One contract per CADL
ContractDefwithcheckAssumptions(),checkGuarantees(),runMonitorCycle() RegimeController.solwith enum-based state machine for transitions- Main orchestrator contract importing all sub-contracts
- Institutional parameters (alpha, beta, lambda) as scaled
uint256constants - For a file that declares
norms: 0.1:<Contract>NormsMonitor.solper contract, a monitor of its norms (below)
OPA/Rego (--target opa):
Generates Open Policy Agent policies (.rego):
- One package per CADL
ContractDefwithassumptions_hold,guarantees_hold,allow, andviolationrules - Main policy package aggregating all contracts
- Information sharing and authority policy rules
- For a file that declares
norms: 0.1:norms_monitor_<contract>.regoper contract, the step function of a monitor of its norms (below)
Unity C# (--target unity-csharp):
Generates C# for contracts that use the SoS-DSL extension (lifecycle: / monitors:):
Generated/<Contract>State.cs,<Contract>Contract.cs,<Contract>Monitors.csper contractRuntime/support classes (contract runtime, event bus, predicate evaluator)
Chapter 7 of the textbook runs this target end to end.
Agent boundary policy (--target agent-rego, --target agent-cedar):
Generates the boundary policy of the agent governance extension (see below) from the enforced contracts of a file that declares agents: 0.1; without the declaration cadl codegen reports an error. Both are independent of the opa target.
agent-regowritesagent_policy.rego, one Rego package (cadl.agent_policy) that takes the policy input asinputand returns the whole result object asresult(anddecision), for static and non-static norms alike; the in-force flags of non-static norms and the derived instances are read frominput.instances. The header lists the norms that are not staticagent-cedarwritesagent_policy.cedarandagent_policy_table.json. The policies cover the statically decidable part:forbidfor undeclared tools and static prohibitions,permitfor static permissions, and Cedar's default denial for tool calls without a permission. Cedar has two outcomes, so an escalation is a denial that the runtime resolves from the table (per prohibition:escalate_to,timeout,fallback,notify). The README comment at the top of the file states what is not covered (non-static norms, derived permissions, contract instances) and the cases of G.10 in which the Cedar answer is the decision for a policy input; no policy reads an attribute, so none can be skipped because of an evaluation error
Agent Governance (agents 0.1)
The agent governance extension (Appendix G of the specification) builds on the norms extension. A file declares both norms: 0.1 and agents: 0.1; then agent: binds an actor to a kind (llm_agent, tool_server, human, service), a protocol, and for a tool server its tools:; enforcement: makes a contract enforced; on_denied: on a prohibition names an approver (escalate_to:), a timeout:, a fallback: message, and an actor to notify:; and delegations: makes a permission delegable. examples/agents_tool_governance.cadl is the example of the appendix.
cadl agents-decide <file.cadl> --input <input.json> [--format text|json] is the reference decision function (G.5): for one message it returns allow, deny, or escalate, with the reason, the determining contracts, the norms, the provenance chains of derived permissions, and the escalation data.
$ cadl agents-decide examples/agents_tool_governance.cadl --input examples/agents_inputs/delete_file.json
decision: escalate
reason: prohibition
contracts: ASSISTED_REPORTING
norms: ASSISTED_REPORTING.no_delete
provenance: -
escalate_to: OPERATOR
timeout: 600000 ms
fallback: PLANNER -> TICKETS : create_ticket
notify: OPERATOR
The input is a JSON object with message (from, to, name) and optionally now and instances (per running contract instance: bindings, in_force flags of the norms that are not static, and the valid derived instances with their chains); examples/agents_inputs/ has the sample calls of the appendix. The exit status is 0 for allow, 1 for deny, 3 for escalate, and 2 for a usage error. A message to a tool server that is a party of an enforced contract is governed whatever its sender, so an actor that is not a party, or not declared at all, is denied by the tool default. Matching is three-valued, and an unknown is resolved fail-closed: an unknown prohibition applies, an unknown permission does not.
The command is stateless: the in-force flags and the valid derived instances come in through the input. cadl agents-run (below) keeps that state and calls the same decision function for every message of a recorded trace.
Runtime on a Recorded Trace
cadl agents-run is the reference runtime of the appendix (G.5 to G.8). It replays a recorded sequence of messages through one logical enforcement point over all enforced contracts of the file and computes the decision for every message, the holds and how they end, the delegation state, and the audit records. It is deterministic (apart from the random run id of the audit header when the trace gives none) and offline: it does not run agents or tools, and its only clock is t of the trace.
cadl agents-run examples/agents_tool_governance.cadl \
--trace examples/traces/agents_tool_governance_a_approved.jsonl
cadl agents-run FILE --trace TRACE [--format text|json] [--audit OUT.jsonl [--audit-key FILE]]
For each message, in the order of the trace, the runtime (a) derives the state: the in-force flags of the norms that are not static from the verdict engine of cadl norms-eval, the valid derived instances from the grants and revocations seen so far, and the running contract instances with their bindings; (b) calls the decision function of cadl agents-decide on the policy input built from that state; (c) applies the decision: an allowed message becomes an observation of the norms engine for the instances of the contracts that govern it, a denied message does not, and an escalate creates a hold (h-1, h-2, ... in the order of creation); (d) appends the audit records. A hold ends when the approver's message creates approval or rejection through a counts_as: rule with the hold id as first argument (approve("h-1")), when its timeout passes, or when a contract instance of one of its grounds ends or its contract is amended. An approved message is decided again at the time of the approval and, if nothing denies it, released as the next observation; it does not violate the prohibitions it was held on. In that second decision the approval stands in for the permission and for the grounds only in the contract instances of the grounds: a prohibition that applies anywhere else, a contract instance of a ground that has ended, or another governing contract that no longer allows the message (a revoked delegation, an ended instance, an amendment) denies the release. The file must declare norms: 0.1 and agents: 0.1 and pass cadl check. The exit status is 0 when the trace was replayed, whatever the decisions are, and 2 on a usage error.
Trace. The JSON Lines format of cadl norms-eval (t, bindings, request, values, messages, state, amend, end; see Norm Verdicts on a Trace), read for the whole enforcement point instead of one contract instance, with two more keys:
{"t": 0, "quantities": [], "epoch": "2026-11-10T09:00:00Z", "messages": [{"from": "OPERATOR", "to": "PLANNER", "name": "grant_read"}]}
{"t": 180, "messages": [{"from": "PLANNER", "to": "FILES", "name": "delete_file"}]}
{"t": 220, "messages": [{"from": "OPERATOR", "to": "PLANNER", "name": "approve", "args": ["h-1"]}]}
| Key | Meaning |
|---|---|
epoch |
First line only: the time of t = 0 as an ISO 8601 time stamp. With it, the times of the audit records and now of the policy input are time stamps; without it they are the numbers of t |
quantities |
First line only: the quantity names of the run, as a list (["limit", "target"]). With it exactly these bare names are quantities from the start; a predicate that reads one before it has a value is undefined. Without it a bare name is a quantity from the first line on that gives it a value and a symbolic value before, so that no decision depends on a later line; the run warns when such a name gets its first value after a message was decided. Giving the key is the recommended form; a contract without bare names in its predicates, like the bundled examples, gives []. A trace should also give the initial values on its first line: while a quantity that the trigger: of a prohibition or the until: of a permission reads has no value, messages are denied or escalated (see Readings) |
host_instances |
First line only: the ids of the contracts whose instances a host creates, when the first instance comes on a later line (["DELIVERY"]). Whether a contract has host-created instances is fixed on the first line |
instances |
Host-created contract instances: a list of entries with contract, instance, and optionally bindings, request, state, "end": true. An entry that names a new instance creates it at this line; a later entry sets its lifecycle state or ends it. A contract that the first line neither names here with an instance other than default nor lists under host_instances has the single instance default, from the first line to the end, with the bindings and request of the first line; a later entry that creates an instance of it is a trace error. Every instance must bind the index variables of the parties of its contract ("bindings": {"i": 2} for a party ROBOT[i]); otherwise the trace is rejected |
t |
A finite number of at most 2**53 in absolute value, so epoch seconds and epoch milliseconds both fit; NaN, Infinity and larger values are trace errors, also in cadl norms-eval. Durations of the file (timeout:, deadline:) are counted in the unit of seconds. With epoch, every time of the trace and every deadline of a hold must be an instant that an ISO 8601 time stamp can express; otherwise the trace is rejected with the line number |
messages |
Decided one at a time, in the order written; from and to are concrete actors (PLANNER, ROBOT[2]) and name is an identifier, written without extra whitespace ("PLAN NER" is a trace error) |
state |
Applies to every running instance of a contract with a lifecycle:; an entry of instances sets it for one instance. A terminal state ends the instance |
amend |
A new version of the file. Each enforced contract whose definition changed is amended as in cadl norms-eval; its held holds are cancelled and its derived instances are tested against the new version (G.7). The set of enforced contracts must stay the same |
end |
true ends every running instance; so does the last line, unless it says "end": false (holds that are still held then stay held). Messages on later lines are still decided and recorded: an ended instance does not come back, so a tool call of its contract is denied with no_instance |
run_id |
First line only: the run id of the audit log (32 lowercase hex digits). Without it --audit draws a random one |
approvals |
First line only: how the host read approvals, authenticated, insecure or none; copied into the audit header |
withdraw |
Hold ids whose held message the host withdraws at this line (the client cancelled the call): a hold that is still held closes as withdrawn (closing record deny, reason withdrawn), and a later approval of it is not_held |
host_events |
Event records of the host at this line, written before the line is processed: entries with event (method_refused, unsolicited_response, unauthorised_approval, unauthorised_rejection, unauthorised_message, approval_evidence, approval_unauthenticated, forward_failed, and from 0.3.25 unauthenticated_request, task_refused, invalid_response, task_cancel, overloaded, read_timeout, and from 0.3.28 handshake_failed, push_config, push_refused, push_sent, push_failed, push_dropped) and optional reason, hold_id, message. They change no decision; the MCP and A2A gateways write them |
One line is processed in this order: holds whose deadline lies before t expire; the holds of withdraw close; the host_events are recorded; instances are created; the time and the values of the line (and an amend) are one observation without message, so that a deadline or a window that has passed is settled before a message is decided; each message is decided, and an allowed one is one observation; a state change and an end are a last observation without message.
Output. The text report shows the audit log, the holds, the derived instances and the final state of the norms of every contract instance. --format json gives one object:
| Key | Content |
|---|---|
file, trace, agents_version, contracts |
What was replayed; the enforced contracts |
summary |
messages, allow, deny, escalate (decisions of the messages), holds (count per final state and held), released, audit_records |
audit[] |
The audit log (below) |
steps[] |
Per message of the trace: time, message (with args), input (the policy input the runtime built, as for agents-decide), result, hold_id |
releases[] |
Per approved hold: time, hold_id, message, input (the policy input at the approval), grounds (contract, norm, instance), released |
holds[] |
hold_id, state (held, approved, rejected, expired, cancelled), message, time, approver, deadline, contracts, norms, closed, released (whether the message took effect) |
delegations[] |
Every derived instance: contract, instance, norm, holder, chain, state (active, discharged), valid, granted, ended, end_reason |
instances[] |
Per contract instance: contract, instance, bindings, running, start, end, state, and from the norms engine norms[] (as in norms-eval, plus in_force), violations[], institutional_events[], unauthorised[], ok |
amendments[], warnings[] |
Amendments applied (time, file, contracts); warnings |
Audit log. --audit OUT.jsonl writes the records as JSON Lines, in the order in which the enforcement point writes them; the same file and trace always give the same bytes. A decision record is the audit record of G.8: the result of the decision (decision, reason, contracts, norms, provenance, escalate_to, timeout, fallback, notify) with time, message (from, to, name), instances (the running instances of the governing contracts; in a closing record the contract instances of the grounds of the hold, running or not), hold_id, and outcome. An escalate gives two records with the same hold_id: the decision, and a closing record whose outcome is the final state of the hold and whose reason is approved, rejected, expired (with the deadline as time), or cancelled, or the reason of the denial when the second decision denies. An event record has event instead of decision, and the fields time, event, message, instances, norm, chain, holders, hold_id, reason:
event |
Written when | reason |
|---|---|---|
grant |
A grant message was observed and conditions 1 to 4 of G.7 hold; chain and holders give the new derived instance |
null, or holder_exists for the no-op of condition 5 |
revoke |
A revoke message was observed; holders lists the discharged holders |
null, or no_effect |
unauthorised_grant |
A grant message failed one of the conditions 1 to 4 | The first that failed: no_authority, not_in_to, in_chain, max_depth |
delegation_end |
A derived instance ended for another cause than a revoke message; one record per instance, with its chain and holder |
until, original_discharged, instance_end, amendment |
instance_start, instance_end |
A contract instance started or ended (message is null) |
null; for the end end or terminal_state |
amendment |
A new version took effect; instances lists the running instances of the amended contracts |
The name of the new version as the trace gives it |
unauthorised_approval, unauthorised_rejection |
An approval or rejection changed no hold |
unknown_hold, not_held, not_approver, other_instance (not created in a contract instance of a ground) |
unauthorised_act |
The norms engine recorded an unauthorised act (F.5, item 7) | no_power |
{"time": "2026-11-10T09:03:00Z", "message": {"from": "PLANNER", "to": "FILES", "name": "delete_file"}, "instances": [{"contract": "ASSISTED_REPORTING", "instance": "default"}], "decision": "escalate", "reason": "prohibition", "contracts": ["ASSISTED_REPORTING"], "norms": ["ASSISTED_REPORTING.no_delete"], "provenance": [], "escalate_to": "OPERATOR", "timeout": 600000, "fallback": ["PLANNER -> TICKETS : create_ticket"], "notify": ["OPERATOR"], "hold_id": "h-1", "outcome": null}
{"time": "2026-11-10T09:03:40Z", "message": {"from": "PLANNER", "to": "FILES", "name": "delete_file"}, "instances": [{"contract": "ASSISTED_REPORTING", "instance": "default"}], "decision": "allow", "reason": "approved", "contracts": ["ASSISTED_REPORTING"], "norms": ["ASSISTED_REPORTING.no_delete"], "provenance": [], "escalate_to": "OPERATOR", "timeout": null, "fallback": [], "notify": [], "hold_id": "h-1", "outcome": "approved"}
The audit file is written only after the whole trace was replayed: when a run fails, no file is written and the error message says so. Changes of the in-force flag of a norm have no record of their own; they follow from the recorded messages, the times, and the values of the trace.
Integrity of the log. The audit file is a hash chain (G.8, "Integrity of the log"). Its first line is a header record, {"audit_format": "cadl-audit/1", "hash": "sha256", "key_id": null, "run_id": ..., "approvals": ..., "source_sha256": ..., "epoch": ...}: the run id (32 hex digits; the run_id of the first line of the trace, or a random one), how the host read approvals (authenticated, insecure, none, or null when the trace does not say), the SHA-256 of the bytes of the CADL file, and the epoch of the trace or null. Then come the records above, with their fields and values unchanged; a complete log ends with {"audit_end": true, "records": N}. Every line carries three more fields after its own: seq (0 for the header), prev (the digest of the previous line; 64 zeros in the header) and digest, the SHA-256 of the canonical JSON of the line without digest. Canonical JSON: keys sorted by code point, separators , and : without spaces, strings in UTF-8 with only the escapes JSON requires (\", \\, \b, \f, \n, \r, \t, \u00xx for other characters below U+0020), integral numbers as integers (at most 2**53 in absolute value), other numbers as the shortest decimal that reads back to the same binary64 value, without exponent (0.0000001), no NaN, no lone surrogate, no duplicate key. A line is written in the same way with the fields in their order and the separators , and : , and a verifier also requires that form, so a change of whitespace, of an escape or of the form of a number is found too. With --audit-key FILE the digests are HMAC-SHA256 with the key in FILE (at least 16 bytes, one trailing line end ignored; never on the command line), the header says hmac-sha256, and key_id is the first 16 hex digits of HMAC-SHA256(key, cadl-audit key id).
What this protects. Without a key: a change of any byte, a deleted, inserted or reordered line, and a cut tail (the end record is missing) are detected; a line from a log of another run does not fit, because the run id in the header changes every digest after it. Not detected without a key: a rewrite of the log from a changed line on, end record included, because anyone can recompute SHA-256. Keep the last digest elsewhere and give it to audit-verify --anchor, or use a key. With a key, only a holder of the key can rewrite the log. The hash field of the header is not authenticated: a keyed log rewritten as an unkeyed one verifies without --key, so the verifier has to know from outside the log whether it is keyed, and give the key. cadl.audit_log.read_records(path) gives the records without header, end record and integrity fields. agents-run accepts withdraw and host_events from any trace, so the host's event records in a log replayed from an unkeyed trace prove nothing by themselves; and a replay of a trace without run_id draws a new run id, so its log is not byte-reproducible: give run_id on the first line of the trace to reproduce it.
cadl audit-verify AUDIT.jsonl [--key FILE] [--source FILE.cadl] [--run-id HEX] [--anchor DIGEST] [--open] [--format text|json]
cadl audit-verify checks every line and reports the first one that does not verify, with what was expected and found (--format json: valid, error with line, what, expected, found, and lines, records, hash, key_id, run_id, source_sha256, epoch, complete, last_digest). --source also requires that the log was written for that CADL file, --run-id that it is the log of that run, --anchor that its last digest is the one kept elsewhere. A log without end record is invalid unless --open is given (the log of a gateway that is still running). A keyed log without --key is a usage error; --key on a log that is not keyed is invalid. Exit status: 0 valid, 1 invalid, 2 usage error.
Online use. The same engine can be driven one line at a time: rt = AgentsRuntime.open(FILE), then rt.observe(line) for each trace line as a dict (it returns the steps, audit records and changed holds of that line), and rt.close(t) at the end, which is the last line {"t": t}. agents-run is a loop over the same steps, and feeding a trace to observe and then close gives exactly the result of agents-run on the trace followed by {"t": t}. After an error, the online runtime refuses every further line.
Readings. Where G.5 to G.8 leave a choice, the runtime reads them as follows.
- A message is an observation only for the instances of the enforced contracts that govern it (G.5); a message that no enforced contract governs is allowed as
ungovernedand observed by none of them. - A denied or held message is not an observation: the norms engine never sees it, so it triggers no norm, creates no institutional event, fulfils no obligation, violates no prohibition, and is no grant, revocation, approval or rejection. Time still passes: every line is first observed without its messages.
- The time of a line is observed before its messages are decided, so a prohibition whose window has closed no longer applies, and an obligation whose deadline has passed is already
violated, when a message of that time is decided. - Every contract instance binds the index variables of the parties of its contract: the
bindingsof the first line for the instancedefault, thebindingsof its entry for a host-created instance. An instance without such a binding, or with a value that is not the index of a member of the set the party names, is a trace error that names the contract, the instance, the variable and the value. A binding of a variable that no party has is ignored, with a warning. Together with G-18 this means that no index of an enforced contract is ever unbound incadl agents-run. - Every decision depends only on the lines up to it: the decisions on a prefix of a trace are the first decisions on the whole trace. For the reading of a bare name in a predicate (
AG.mode == locked) this means that the runtime does not look ahead ascadl norms-evaldoes:lockedis a symbolic value until a line gives it a value, unlessquantitiesnames it. Nothing after the end of an instance changes its verdicts. - Missing data is unknown, without latching: while the predicate
trigger:of an inactive prohibition is undefined because a quantity it reads has no value, the prohibition applies; while the predicateuntil:of an active permission is undefined, the permission does not apply. The norm states are those ofcadl norms-eval(an undefined predicate does not occur); only the in-force flag of the policy input is left out, and it follows the state again as soon as the value is there. The same holds when thattrigger:oruntil:is an institutional event that acounts_as:rule creates from a predicatewhen:, while thewhen:orif:of such a rule is undefined. The run warns once per norm and names the quantity. A denial on an unknown flag has the reasonprohibitionlike any other; the flag is then absent fromin_forceinsteps[].input. Not covered: a rule with a messagewhen:and anif:creates its event at that message or never, so a message that arrives while theif:has no value creates nothing (cadl checkwarns about such an event when it triggers a prohibition or ends a permission, G-19, and the run warns when it happens); and an obligation whose predicatetrigger:has no value is not activated, so a prohibition that is its reparation does not arise. A grant sent while theuntil:of the permission is undefined isunauthorised_grant/no_authorityand has to be repeated. - A binding has to be the index of a member of every declared set that the variable indexes in the contract (
SUP[i]in an event beside a partyW[i]). - Quantified predicates and aggregates are evaluated as in
cadl norms-eval. One that is undefined because the domain of a set with a symbolic bound is open (no value forN) is missing data: anexiststrigger of a prohibition makes it apply, afor alluntil:of a permission applies it only while a known member falsifies it. A wildcard or range reference outside a quantifier (W[*].alarm == true) is rewritten as incadl norms-eval(F.5, "Wildcard and range references") and judged asfor all j in W[*]: W[j].alarm == true. A norm whose predicate cannot be evaluated (an aggregate over two sets,sum(W[*].x * R[*].y), a function other than the aggregates and the temporal operators, a text that is not a predicate) is an error ofcadl checkfrom 0.3.30 (N-16), so the gateways do not start with it; up to 0.3.29 such a norm was not judged and its in-force flag was unknown for the whole run, so such a prohibition always applied and such a permission never did. - A trace error on a later line is reported before anything is printed or written; the earlier lines have then been decided in memory only.
cadl.agents_runtime.runandrun_filesrefuse a file, or a version it is amended to, that has errors ofcadl check.run(..., check=False)switches that test and the test of the bindings off; it is unsafe and exists for the tests of the next point.- Defence in depth, reachable only with
check=False: an occurrence or a predicate that depends on an unbound index is unknown, and an unknown occurrence never has an effect that lets a message through (it does not activate or resume a permission, end, suspend or discharge a prohibition, create an institutional event, exercise a power, or fulfil an obligation) and always has the effects that block (it activates a prohibition and ends a permission or a derived instance). - The grounds of a hold are kept per contract instance. An
approvalorrejectioncloses a hold only when it was created in a contract instance of a ground; one is enough. The same message creating the event in several instances counts once. - A closing record with the reason
rejected,expiredorcancelledkeeps thecontracts,norms,escalate_to,fallbackandnotifyof the hold;timeoutisnullin every closing record. When the second decision denies an approved message, the record has the result of that denial and the outcomeapproved. - The second decision of an approved message never creates a second hold: a contract that would escalate denies. Its record lists every contract that denies, with the first of the reasons
no_instance,prohibition,default. - The
until:of a delegation ends the derived instances that are active when it occurs; a later grant creates a new one. - A violated obligation is
excusedwhen a matching message of its bearer was denied by its own contract, or held on a ground of it and not released, between its activation and its deadline (or, without a deadline, the violation). Matching is that of the boundary: sender, receiver and name. - After a violation, the window clock of a prohibition stops while it is suspended, as before the violation.
- An amendment applies to the enforced contracts whose definition differs between the two versions.
examples/traces/ has three traces for examples/agents_tool_governance.cadl: the three calls of G.12, with a call through a delegation chain, an escalation that is approved, and a denial after a revocation (a); a rejection, the fallback, and a hold cancelled at the end (b); an undeclared tool, a timeout, and a late approval (c). examples/agents_change_control.cadl has a prohibition that is in force only between a trigger and an until:, and a delegation with max_depth: 1 and an until:; its traces show approval, rejection and expiry during a freeze (a), and the depth limit and the end of a delegation (b).
MCP Gateway
cadl mcp-gateway puts the enforcement point between an MCP client (the agent) and an MCP server (a tool server of the file), over the stdio transport of MCP: JSON-RPC 2.0, one message per line, no embedded newlines (MCP specification 2026-07-28, stdio). The client starts the gateway as if it were the server; the gateway starts the server.
cadl mcp-gateway FILE --agent ACTOR --server-actor TOOLSERVER --audit OUT.jsonl \
[--audit-key FILE] [--approvals DIR --approver-keys KEYS.json] [--trace-out TRACE.jsonl] \
[--init FIRST.json] [--allow-method NAME ...] [--no-filter-tools] [--hold-key FILE] \
[--poll SECONDS] -- SERVER_COMMAND [ARGS...]
cadl mcp-approve DIR HOLD_ID approve|reject --as ACTOR --key ACTOR.key [--hold-key FILE] [--require-signed-hold]
cadl mcp-message DIR 'FROM -> TO : name' [--arg VALUE ...] --key FROM.key
TOOLSERVER is an actor of the file with agent: { kind: tool_server, protocol: mcp, tools: [...] }.
What passes. Every line, in both directions, is parsed strictly before anything is done with it. A line with a carriage return other than one trailing CRLF, invalid UTF-8, a duplicate key at any depth, NaN, an infinity or a number that overflows to one (1e999), nesting deeper than 100 arrays or objects, or a lone surrogate is refused (-32700 for a line that is not JSON, -32600 otherwise) and never forwarded. Nothing is forwarded as it was received: the gateway sends the compact JSON of the parsed object with every non-ASCII character escaped, so no reader can split it at a character that it takes as a line end. Methods pass by a list, in both directions:
| Message | What the gateway does |
|---|---|
tools/call |
The only method that the norms decide. It becomes the message ACTOR -> TOOLSERVER : name at the time of its arrival. allow: forwarded, and the server's response goes back. deny: answered with a tool result with isError: true and a text that names the reason, the norms, the hold, the fallback and notify (MCP calls this a tool execution error, which a client gives to the model so that it can correct itself). escalate: held; the client gets no answer yet, and other requests go on. When the hold closes, an approved and released call is forwarded; a rejected, expired or cancelled call, or one whose release is denied (G.6), is answered with a denial |
initialize, notifications/initialized, ping, server/discover, notifications/cancelled, notifications/progress, tools/list |
Passed without a decision: the lifecycle and discovery of MCP 2026-07-28 (server/discover) and of the earlier revisions. A tools/list result is reduced to the tools that the file declares for TOOLSERVER (keep all with --no-filter-tools) |
| Any other method of the client | Refused with -32601 and recorded as the event method_refused, unless --allow-method NAME names it; an allowed method is passed without a decision |
| Requests of the server | Refused with -32601 to the server and recorded as method_refused (MCP 2026-07-28 does not let a server send requests on stdio; the earlier revisions did, for sampling and elicitation), unless --allow-method names them. Notifications of the server pass when they are notifications/progress, notifications/message, notifications/cancelled or notifications/tools/list_changed |
| Responses | Passed only for a request in flight in the other direction; any other response (for a held call, a denied call, an id answered before, or an unknown id) is dropped and recorded as unsolicited_response |
notifications/cancelled for a held call |
Withdraws it: the trace gets withdraw, the hold closes as withdrawn, the call is never sent, and a later approval is not_held. For a call that was already sent, the cancellation is passed on and the id stays in flight, because the server may still answer |
Decisions are taken in the order of arrival, one at a time; several calls may be in flight, and a held call does not block the others. Everything that can fail is done before a call is decided: the line that will be sent and the SHA-256 of the canonical JSON (G.8) of its params; arguments that have no canonical form (an integer beyond 2**53) are refused with -32602. If sending still fails after an allow or a release, the client gets -32603 and the log the event forward_failed. Tool arguments are not decided on and not written to the trace or the log (G.8 has no arguments). The gateway fails closed: when the decision step raises, or the trace or the log cannot be written, the call is denied and so is every later call, held calls are answered with a denial, and the log gets no end record. When the server exits, requests in flight and held calls get the error -32603 and the gateway exits with status 1; when the client closes its input, the gateway stops the server and exits with 0, and held calls stay unanswered.
Approvals and other messages. With --approvals DIR, the gateway reads JSON files from the inbox directory DIR in the order of their names. DIR must be a directory of the user of the gateway that its group and others cannot write (the gateway creates it with mode 0700 and refuses to start otherwise), and only regular files with one link, owned by that user, are read; a symbolic link, a hard link or a file of another user moves to DIR/invalid. The approvals are authenticated: --approver-keys KEYS.json maps each actor that may speak through the inbox to its key ({"OPERATOR": "operator.key"}, paths relative to KEYS.json, or {"hex": "..."}; at least 16 bytes; never the key of the audit log). For every held call the gateway publishes DIR/holds/h-N.json with the run id, the held message, the time of the hold, and the arguments of the call (params) with their SHA-256, and DIR/run.json with the run id. The decision does not depend on the arguments (G.4); they are there for the approver. cadl mcp-approve DIR h-1 approve --as OPERATOR --key operator.key shows the held call and its arguments (--show only shows them) and writes a file with the hold id, the decision, the actor, the run id, the held message, the time of the hold, the SHA-256 of the arguments, a fresh nonce, and an HMAC-SHA256 with the actor's key over the canonical JSON (G.8) of the rest. The gateway accepts it only when the MAC verifies with the key of that actor, the run id is that of the run, the held message, its time and the digest of its arguments are those of the hold, and the nonce was not used before; otherwise it records unauthorised_approval (or unauthorised_rejection) with the reason unauthenticated, wrong_run, wrong_message or replayed, and the call stays held. An accepted file becomes the approver's message that the file's counts_as: rule maps to approval (here OPERATOR -> PLANNER : approve("h-1")), with the event record approval_evidence before its decision, whose reason is file=sha256:…;params=sha256:…;key_id=…;nonce=… (the file, the arguments, the approver's key id and the nonce); whether it closes the hold is decided by G.6. cadl mcp-message writes any other message, such as a grant between agents (OPERATOR -> PLANNER : grant_read), authenticated with the key of its sender; an approval or rejection sent that way is refused (unauthorised_message, approval_as_message). Without --approver-keys the gateway refuses --approvals; --insecure-approvals reads the inbox without authentication and is meant for tests only, and an approval accepted that way is recorded as approval_unauthenticated. The trace's first line and the audit header say which mode the run used (approvals: authenticated, insecure, none). The keys separate approvers only if they cannot read each other's key files: approvers who share the user account of the gateway can read the whole keyring, so each approver needs an account of their own (with the key readable only there and by the gateway), the agent must not run under the gateway's account, or approvals have to come through a channel that authenticates the approver in another way. The inbox protects only against parties that do not have the key files. A file that cannot be read moves to DIR/invalid with a .why file and is never an approval.
Time, trace and replay. The time t is the time since the start of the gateway on a monotonic clock, in seconds rounded to milliseconds; the first line of the trace gives a random run_id, the wall-clock time of t = 0 as epoch and "quantities": [], plus the keys of --init FIRST.json (bindings, request, values, quantities, instances, host_instances, state). Every step is written to the trace (--trace-out, by default the audit path with .trace.jsonl) before it is decided: each decided message, a line {"t": t} when the deadline of a hold has passed, withdraw and host_events lines, and a last line {"t": t} when the gateway stops. cadl agents-run FILE --trace TRACE --audit A.jsonl on that trace makes the same decisions and writes the same audit log, byte for byte (with the same --audit-key). The gateway refuses to start when the audit log or the trace exists. A hold whose timeout is longer than the client's request timeout ends at the client first; choose timeout: accordingly.
Not covered: the gateway does not observe values (a norm that reads a quantity sees it as missing data, G.5), and it does not create or end host-created contract instances after the first line. Under MCP 2026-07-28 a tools/call that a server answers with input_required is retried by the client as a new request, which is decided again. The approver's tool trusts the held message that the gateway publishes.
A2A Gateway
cadl a2a-gateway (from 0.3.25) puts the enforcement point in front of one A2A agent, the actor ACTOR of the file. It is an HTTP server for the JSON-RPC binding of A2A 1.0.0: JSON-RPC 2.0 over HTTP POST to the path /, Content-Type: application/json, and the header A2A-Version: 1.0, with Server-Sent Events for the streamed methods (from 0.3.26). From 0.3.28 it also serves the HTTP+JSON binding at the routes of A2A 11.3 on the same port, and, with the extra pip install 'cadl-lang[grpc]', the gRPC binding on --grpc-listen; it can require client certificates (mutual TLS, --client-ca) and relay push notifications under an allowlist (--push-allow). Allowed requests go to the agent at --upstream URL, over JSON-RPC or, with --upstream-binding rest, over the HTTP+JSON binding.
cadl a2a-gateway FILE --agent-actor ACTOR --upstream URL --client-keys CLIENTS.json \
--audit OUT.jsonl [--audit-key FILE] [--approvals DIR --approver-keys KEYS.json] \
[--trace-out TRACE.jsonl] [--init FIRST.json] [--listen HOST:PORT] [--port-file FILE] \
[--tls-cert CERT.pem --tls-key KEY.pem [--client-ca CA.pem] [--max-handshakes N]] \
[--agent-card CARD.json] [--upstream-binding jsonrpc|rest] \
[--push-allow ENTRY ... [--push-url URL] [--push-timeout SECONDS] [--push-ca CA.pem]] \
[--grpc-listen HOST:PORT [--grpc-port-file FILE] [--max-grpc-connections N] \
[--max-grpc-connections-per-address N] [--max-grpc-connections-per-prefix N]] \
[--upstream-token FILE] [--upstream-timeout SECONDS] [--read-timeout SECONDS] \
[--max-readers N] [--max-readers-per-address N] [--max-readers-per-prefix N] \
[--max-handlers N] [--max-handlers-per-actor N] [--max-holds-per-actor N] \
[--hold-key FILE] [--poll SECONDS]
ACTOR is an actor of the file with agent: { kind: llm_agent, protocol: a2a }; it is the receiver of every message. The gateway listens on 127.0.0.1:8470 by default; an address other than loopback needs --tls-cert and --tls-key.
Sender. Every request is authenticated before its body is read as JSON. --client-keys CLIENTS.json maps each actor that may send to its key (the same format as --approver-keys; every actor has to be an actor of the file). A request carries Authorization: CADL-HMAC actor="PLANNER", nonce="<32 hex>", mac="<64 hex>", where mac is the HMAC-SHA256, under the actor's key, of the canonical JSON (G.8) of {"scheme": "cadl-a2a-request/1", "actor", "run_id", "nonce", "method": "POST", "path": "/", "body_sha256"}. cadl.a2a_gateway.authorization(key, actor, run_id, body) computes the header. Every response carries the run id of the gateway in the header CADL-Run-Id, and a 401 response names it in WWW-Authenticate: CADL-HMAC run="...". A nonce is accepted once per run, and the run id binds the request to one run; the nonces of a run are kept in memory for each actor, and after 1 000 000 authenticated requests of one actor the gateway refuses that actor's further requests (nonce_limit) until it is started again; the other actors are not affected. The headers A2A-Version and Content-Type are not covered by the MAC. A request without a valid header gets HTTP 401 and is recorded as unauthenticated_request with the reason missing, malformed, unknown_actor, bad_mac or replayed (at most 20 records a second; the next record counts the requests that were not recorded, as ;not_recorded_before=N). Without an authenticated sender there is no message and nothing is decided. The client's Authorization header is not passed on; --upstream-token FILE gives the gateway's own bearer token for the agent; it is refused with an http:// agent that is not on a loopback address.
Message. A2A messages have no name of an operation. The name and the arguments of the CADL message come from an extension: the message lists https://www.ertl.jp/cadl-spec/a2a/agents-message/v0.1 in extensions and carries {"name": "summarize", "args": ["..."]} under that URI in metadata (a name of at most 64 characters, at most 16 string arguments of at most 256 characters). A SendMessage of the actor X is then the message X -> ACTOR : summarize at the time of its arrival. An agent card given with --agent-card (served at /.well-known/agent-card.json) has to declare this extension under capabilities.extensions, or the gateway does not start.
| Request | What the gateway does |
|---|---|
SendMessage |
allow: passed on, re-serialised, with a JSON-RPC id of the gateway; the agent's answer goes back with the client's id. deny: answered with a task of the gateway in TASK_STATE_REJECTED whose status message names the reason, the norms, the hold, the fallback and notify (also as metadata under the extension URI). escalate: held. A blocking request waits until the hold closes; with configuration.returnImmediately the client gets a task of the gateway in TASK_STATE_SUBMITTED at once, and GetTask shows it settled later. A released request is passed on; a rejected, expired or cancelled one, or one whose release is denied, gets a rejected task. A message without the extension, or one named like an approval or a rejection of a counts_as: rule, is rejected without a decision and recorded as unauthorised_message (no_name, approval_as_message) |
SendStreamingMessage (from 0.3.26) |
Decided once, as SendMessage, before anything is passed on; the answer is a stream of Server-Sent Events, each one JSON-RPC response re-serialised by the gateway. allow: the agent's events are relayed one by one; each has to answer this request and belong to one task or message of the same client, or the stream ends with InvalidAgentResponseError (-32006, invalid_response); the agent's comments and lines with a bare carriage return are not passed on. deny: one event, the rejected task. escalate: SSE comments once a second until the hold closes, then the released request's events or a rejected task; a client that closes the connection withdraws the request; with returnImmediately, one event, the submitted task of the gateway. While the agent is silent the gateway watches the client's connection and sends a comment once a second; a client that has gone ends the stream and the request to the agent. A plain JSON answer of the agent is read with the 16 MiB cap and strict UTF-8 |
SubscribeToTask (from 0.3.26) |
For the client's own tasks only, without a decision and without a record: the agent's stream of the task; for a held task of the gateway, comments until the hold closes, then the agent's stream under the gateway's task id, or the final task |
GetTask, CancelTask |
Passed on for the client's own tasks only, without a decision; CancelTask is recorded as task_cancel before it is passed on, GetTask is not recorded; a task of another client, or of an earlier run, is TaskNotFoundError (-32001) and recorded as task_refused. CancelTask of a held request withdraws it (G.6) and answers TASK_STATE_CANCELED, or a rejected task when the deadline of the hold had already passed. The task of a released returnImmediately request keeps the gateway's id: the gateway asks the agent for its task and shows it under that id |
ListTasks, GetExtendedAgentCard |
Refused with UnsupportedOperationError (-32004) and recorded as method_refused |
Push notification methods, or configuration.taskPushNotificationConfig |
Without --push-allow: refused with PushNotificationNotSupportedError (-32003) and recorded as method_refused, since the gateway would send requests to URLs that its clients choose, from inside the network it protects (server-side request forgery). With it (from 0.3.28): see Push notifications below |
| Any other method | Refused with -32601 and recorded as method_refused |
A SendMessage may name only tasks (taskId, referenceTaskIds) and contexts (contextId) that the agent or the gateway gave to the same actor in this run; anything else is TaskNotFoundError and task_refused. tenant is refused (-32602), because the tasks of a client are kept by their id alone. A task or context that the agent gives to a second actor is not shown to it (InvalidAgentResponseError, -32006, recorded as invalid_response).
What passes. HTTP: one Content-Length of at most 1 MiB, no Transfer-Encoding, one request per connection. A header line with whitespace before its colon (which the standard library's parser takes as the end of the headers), a folded line or a bare carriage return gets 400 (from 0.3.26). The body is parsed as strictly as a line of the MCP gateway (duplicate keys, NaN, 1e999, deep nesting, lone surrogates and invalid UTF-8 are refused) and passed on as the compact JSON of the parsed object with every non-ASCII character escaped. A2A-Version has to be 1.0 or 1.0.N (surrounding spaces removed); a missing or other value is VersionNotSupportedError (-32009), since an absent header means 0.3 in A2A 1.0.0. Everything that can fail is done before the decision; if the request still cannot be sent after an allow or a release, the client gets -32603 and the log forward_failed; if it was sent and no valid answer came back, the client gets -32006 and the log invalid_response. When the client closes the connection of a blocking held request, or shuts down its sending side, the request is withdrawn; bytes it sends while the request is held are read and dropped. If a released returnImmediately request cannot be passed on, its task becomes TASK_STATE_FAILED and the log gets forward_failed. The request line, the headers and the body have to arrive within --read-timeout seconds in all (10 by default); otherwise the connection is closed and recorded as read_timeout. Before authentication, at most --max-readers-per-address connections (4) of one remote address (an IPv4 address, or the /64 prefix of an IPv6 address; an IPv4-mapped address counts as its IPv4 address) at most --max-readers-per-prefix (16) of one IPv4 /24 or IPv6 /48 (from 0.3.26), and --max-readers (64) in all are read at the same time; a further connection of that address or prefix gets HTTP 503 at once (overloaded, address or prefix), and when all readers are busy a connection waits up to one second, then gets HTTP 503 (overloaded, readers). A request counts against --max-handlers (64) only after it is authenticated, and while it is held; beyond that HTTP 503 (overloaded, handlers). One actor may have at most --max-handlers-per-actor (16) requests handled at the same time, held blocking requests and requests to a slow agent included, and at most --max-holds-per-actor (64) holds, blocking or not; a further request of that actor gets HTTP 503 before its decision (overloaded, handlers_per_actor ACTOR or holds_per_actor ACTOR); at the cap on holds this refuses also messages that would not be held. The records of unauthenticated_request, overloaded and read_timeout are kept to at most 20 a second for each event. The read deadlines of all connections are kept in one thread. What remains: hosts in at least four /24 (or /48) networks, 16 connections each, can still keep the 64 readers busy and make the gateway refuse every new connection for as long as they go on; one process cannot tell them from clients before they authenticate, so where that matters, run it behind a proxy or firewall that limits connections. Behind a proxy every client has the proxy's address, so raise --max-readers-per-address there, or use a proxy that buffers requests before passing them on. On SIGTERM or SIGINT the gateway answers held blocking requests with -32603 and writes the end of the trace and the log; it exits with 1 when the enforcement point failed.
Mutual TLS (from 0.3.28). With --client-ca CA.pem (and --tls-cert, --tls-key) a client presents a certificate of that CA whose subject has exactly one common name, an actor of --client-keys (CN=PLANNER, CN=WORKER[2]). The TLS handshake runs before the connection takes a reader slot, within the read deadline and at most --max-handshakes (256) at the same time (beyond that the connection waits up to a second and is closed, overloaded, handshakes); a failed handshake, or a certificate that names no such actor, closes the connection and is recorded as handshake_failed (capped at 20 a second). So peers without a certificate never hold a reader. The certificate does not replace the CADL-HMAC header: the header has to name the same actor (certificate_mismatch otherwise), and its MAC, its nonce and the run id keep the replay protection and bind each request to its body and to the run, which a TLS session does not do. What remains is a handshake that is slow but valid: before its handshake has ended a peer is not known, so a slow handshake holds a thread and one of the places for handshakes until the read deadline, within the caps per address and per prefix; hosts in at least 16 /24 (or /48) networks can keep all 256 places busy for as long as they go on. With push notifications the agent's actor may also present a certificate, which only delivers notifications.
HTTP+JSON binding (from 0.3.28). POST /message:send, POST /message:stream, GET /tasks/{id} (query historyLength), POST /tasks/{id}:cancel, POST or GET /tasks/{id}:subscribe, and with --push-allow the routes of /tasks/{id}/pushNotificationConfigs, on the same port as JSON-RPC. A request is authenticated like a JSON-RPC one, with the HTTP method and the whole request target (path and query, as sent) as method and path of the MAC (authorization(..., path=target, method=...)); then it is turned into the JSON-RPC request that the gateway decides, holds, records and passes on, so the trace and the log are the same as for JSON-RPC. Bodies are application/json or application/a2a+json; GET and DELETE have no body; unknown routes (also /{tenant}/...), unknown query parameters and a body that disagrees with the path are refused. Errors are google.rpc.Status objects with the HTTP status of A2A 5.4 and an ErrorInfo (reason such as TASK_NOT_FOUND, domain a2a-protocol.org); streams carry StreamResponse objects as data and an error as an error event. GET /tasks and GET /extendedAgentCard are refused (UNSUPPORTED_OPERATION). With --upstream-binding rest the gateway speaks this binding to the agent (--upstream is the base of its routes) and checks the answers as strictly as JSON-RPC ones; an error answer without an ErrorInfo of A2A is invalid_response.
Push notifications (from 0.3.28). With --push-allow ENTRY (repeatable) the gateway accepts push notification configurations, with SendMessage or with the methods of A2A 3.1.7 to 3.1.10, for the client's own tasks. An entry is a URL (a path that ends in / is a prefix), HOST[:PORT] (without a port: every port and path of that host), or an IP address or network (which allows the addresses that a matching host resolves to, and a single address as a host, but no host name by itself). A callback path with a . or .. segment, a backslash, or a percent-encoded dot, slash, backslash or percent sign (also %252e) is refused. A configuration whose SendMessage got an error or an answer without a task is removed (push_dropped, no_task). The agent never sees the client's URL: it gets a configuration of the gateway whose URL is --push-url (default: the --listen address, which then has to be loopback) plus /cadl-push/<id>, with a secret token and credentials of the gateway. A notification there is checked (the secret, one StreamResponse of the configuration's task, whose owner is the client of the configuration) and relayed to the client's URL with the client's token and credentials. A configuration given with SendMessage is bound to the task that the agent's answer names (the result, or the first event of a stream); notifications that come before are dropped, and a notification never makes a task or a context the client's. The client's URL has to match an entry, be https unless its host is loopback, and resolve only to global unicast addresses, or to addresses inside an IP entry (a cloud metadata address only when an entry names that address itself); it is checked when the configuration is given and again at every notification, and the request goes to the checked address, follows no redirect, ends within --push-timeout (10 s) from connect to answer, and reads at most 64 KiB of the answer; --push-ca gives the CAs for https callbacks. Records: push_config (a configuration given to the agent, or deleted), push_refused, push_sent, push_failed, push_dropped (capped). The token and the credentials of a configuration in a SendMessage are not shown in the published hold. Get and List are answered by the gateway; Delete stops the relay at once and is passed on.
gRPC (from 0.3.28, extra). pip install 'cadl-lang[grpc]' installs a2a-sdk[grpc], whose a2a.types.a2a_pb2 is generated from the normative a2a.proto; --grpc-listen HOST:PORT serves its lf.a2a.v1.A2AService (TLS and mutual TLS with the options of --listen; an address other than loopback needs TLS). The metadata authorization: CADL-HMAC ... covers POST, the path of the RPC (/lf.a2a.v1.A2AService/SendMessage) and the SHA-256 of the serialized request as it arrived; the metadata a2a-version has to be 1.0. A message with fields that a2a.proto does not define is refused; errors are gRPC statuses with an ErrorInfo in grpc-status-details-bin; streams are server-streaming RPCs. gRPC hands a call to a worker before its message has arrived, so the gateway receives the message itself: a call without a header of the right form (an actor with a key, and with mutual TLS the certificate's actor) is refused before its message is awaited; until its message arrives a call takes one of the places of calls not yet authenticated (4 per remote address, 16 per /24 or /48, 64 in all, as for HTTP) and is cancelled at --read-timeout; there are workers for these next to --max-handlers + 16 authenticated calls. HTTP/2 allows 16 concurrent streams per connection and 16 KiB of metadata, limits pings and closes idle connections after 2 minutes; a request message is at most 1 MiB. grpcio has no hook where a connection could be counted or refused, so the gateway accepts the connections of --grpc-listen itself, in a front listener (one thread, standard library), and passes the bytes of each one unchanged to the gRPC server, which listens on a Unix socket in a directory of mode 0700 (on 127.0.0.1 where there are no Unix sockets); TLS and mutual TLS still end in gRPC. The front listener keeps at most --max-grpc-connections-per-address (4) open connections of one remote address, --max-grpc-connections-per-prefix (16) of one /24 or /48, and --max-grpc-connections (64) in all; a further connection of an address or a prefix at its cap is reset at once (overloaded, connections). From 0.3.31, a connection that finds only the cap in all reached waits up to --grpc-connection-wait (10 s; 0 resets it at once) for a place: at most 64 connections wait, a waiting connection counts against the caps of its address and prefix, and a place that comes back goes to the waiting connection whose address, then whose /24 or /48, holds the fewest connections (then to the one that came first), before any new connection; one that gets no place is reset (overloaded, connections). A connection that has carried no call within --read-timeout of its accept (or of the end of its wait) (silent, no TLS, a slow handshake, half-open) is reset (read_timeout, grpc handshake); after a call, gRPC closes a connection without calls for 2 minutes, and one whose peer does not answer a keepalive ping within 20 seconds; the front listener reads gRPC on while up to 256 KiB wait for the client, so it sees that close also when the client reads nothing, and resets the client's side 5 seconds later at most. When more waits, or gRPC does not take the client's bytes, and the backlog does not drain within 30 seconds, both sides are reset (read_timeout, grpc stalled). A connection counts until its sockets are closed. With localhost the front listener listens on 127.0.0.1 and ::1, as gRPC did (an address that cannot be bound is logged and left out); without Unix sockets, other local processes can reach the loopback port of gRPC without the caps, and their calls are refused. From 0.3.31 a call that gRPC refuses itself before a handler runs (an unknown method, UNIMPLEMENTED; no free worker, RESOURCE_EXHAUSTED) counts as a call of its connection, with TLS as without: grpcio has no public hook there, so the gateway wraps its internal function that refuses the call (grpc._server._reject_rpc, used only when it has the expected parameters) and looks up the peer of the call; with a grpcio that does not have it, these calls do not count, as before. A client that opens its channel early and waits past the deadline is still reset, and connects again. From 0.3.31 gRPC sends GOAWAY to each connection at --grpc-max-connection-age (300 s, at least 1 s, with a jitter of 10 %). The GOAWAY is staged: a first GOAWAY and a PING, and the final GOAWAY when the PING is answered or at the ping timeout (20 s); from then on the connection takes no new call, and the client's channel opens a new connection for its next calls (which may wait for a place). By default the calls under way on the old connection go on to their end, and gRPC closes it when the last one has ended; the front listener then closes the client's side within 5 s. A connection on which no authenticated call has run (the gateway marks the connection of each call that authenticates) is reset by the front listener when its calls without a key must have ended, at --read-timeout + 1.1 × age + 20 s + --read-timeout + 10 s after the end of its wait (read_timeout, grpc age); this also ends a client that keeps gRPC's answers pending by reading slowly. One case is not covered: when the first authenticated call of a connection starts between the first and the final GOAWAY (its earlier calls had no key or were refused), its handler starts more than 10 s after the call reached gRPC (for example behind a backlog of calls without a key), and the call lasts long, the connection can be reset before it is marked, which cuts that call. With --grpc-max-connection-age-grace SECONDS, gRPC closes every connection at most SECONDS after the final GOAWAY, and the front listener resets one still open at --read-timeout + 1.1 × age + 20 s + grace + 10 s after the end of its wait. That gives every connection a hard bound, at a cost: a call still under way at the end of the grace is cut with UNAVAILABLE, so a blocking SendMessage held for approval is withdrawn, a unary call that the agent has already processed gets no answer (sent again, it is a second request), and a stream (SendStreamingMessage, SubscribeToTask) ends and is subscribed to again. Each connection to the gRPC server comes from an address of its own, which the gateway maps back to the client, so the caps on calls not yet authenticated count the real client address. One address thus has at most 4 connections and 64 concurrent calls. What remains: without mutual TLS, hosts with 16 addresses in 4 networks can still hold the 64 connections. A call without a key ends within --read-timeout (it waits at most that long for its message and is refused when it does not authenticate), so with the defaults gRPC closes a connection without a key at most 1.1 × 300 + 20 + 10 = 360 s after its handshake, its client's side is closed within 365 s when the client reads, and the front listener resets it at the latest 10 + 330 + 20 + 10 + 10 = 380 s after the end of its wait, 390 s after its accept, which also ends a client that does not read. A client with a key keeps a connection past its age for as long as one of its calls is under way: a blocking SendMessage held for approval (G.6) until the decision, a call whose agent answers within --upstream-timeout (300 s), or a stream until its task ends. Operators who want a hard bound for these too give a finite grace; with 60 s every connection ends at most 10 + 10 + 330 + 20 + 60 + 10 = 440 s after its accept. When a place comes back, a client that waits for one at that moment gets it before those hosts can connect again, if its address and its /24 or /48 hold fewer connections than those of the other waiting connections. A client that is not waiting when a place comes back (it waited 10 s in vain, and its channel backs off before it tries again) can be kept out for as long as the hosts connect again at once, and other hosts, with 16 other addresses in 4 other networks, can also fill the 64 places to wait and come before it when they came first. Behind a proxy, raise the caps per address and per prefix.
Approvals. Approvals and other messages come through the inbox, as for the MCP gateway (--approvals DIR --approver-keys KEYS.json, cadl mcp-approve, cadl mcp-message). The held message's params (the whole SendMessage request) are published in DIR/holds/h-N.json, and an approval is bound to their SHA-256. An approval does not come as an A2A message. An inbox approval is only given to the runtime, so when the receiver of the approval rule is a set, a range or an index variable (OPERATOR -> SUMMARIZER[*] : approve), it is resolved to a concrete actor: an index variable takes its value from the bindings of the contract instance of the hold's grounds (from 0.3.26); otherwise ACTOR when the reference can match it (at the MCP gateway: the tool server, then --agent), else the first declared member of the set. A gateway does not start when a contract of its actor escalates and has no rule that creates approval (G-9 already makes that an error). The time, the trace and the replay are those of the MCP gateway: cadl agents-run on the trace writes the same audit log, byte for byte.
Signed holds (from 0.3.26). With --hold-key FILE (both gateways), every published hold carries "kind": "hold" and hold_mac, the HMAC-SHA256 under that key of the canonical JSON of the hold (the held message, the times, the arguments and their SHA-256), and run.json says "holds_signed": true. cadl mcp-approve --hold-key FILE verifies it before it shows or signs the hold and refuses an unsigned or mis-signed one; without --hold-key it refuses a signed hold and warns for an unsigned one, unless run.json of the inbox says holds_signed or it gets --require-signed-hold (which does not depend on the inbox): then it refuses an unsigned hold. In every case it refuses a hold whose shown arguments do not have the SHA-256 it names, and it shows the arguments with every invisible character escaped as \uXXXX (controls, bidirectional overrides, zero-width and other format characters, private use, surrogates, unassigned code points, line and paragraph separators). The hold key is the gateway's: it must differ from the audit key, from every approver key and from every client key of the A2A gateway, and the approvers hold it to verify. With it the approver detects a hold that was changed by whoever can write the inbox but cannot read the key; the authentication of the approvals does not depend on it, and without the hold key the gateway still refuses an approval of other arguments than those held (wrong_message). The option is optional, for backward compatibility; a hold is authenticated for the approver only when mcp-approve gets --hold-key.
SDKs. tests/test_sdk_interop.py runs the gateways against the official SDKs: an MCP server of mcp 2.3.0 behind cadl mcp-gateway with the SDK's ClientSession (revision 2025-11-25) and Client (2026-07-28, server/discover), and an a2a-sdk 1.3.0 agent behind cadl a2a-gateway with the a2a-sdk client, streaming and not, which adds the CADL-HMAC header through an httpx event hook. From 0.3.28 also over mutual TLS, over the HTTP+JSON binding (with the agent spoken to over JSON-RPC and over the HTTP+JSON binding), with push notifications sent by the SDK agent's push sender, and over gRPC (with interceptors of grpc.aio that sign the serialized request). The tests are skipped without the SDKs; the CI job sdk-interop installs them on Python 3.12. They are not dependencies of cadl.
Not covered: ListTasks, GetExtendedAgentCard, tenants, the header A2A-Extensions and ExtensionSupportRequiredError (-32008), A2A-Version as a query parameter, a check that a raw part is base64, authentication schemes of A2A other than CADL-HMAC (an A2A client has to compute the header; a client certificate comes in addition), a configuration for a held task of the gateway created with CreateTaskPushNotificationConfig (give it with the SendMessage), retries of a failed notification, and a client that asks for an unknown context id. The gateway does not keep the owners of tasks or the push configurations across runs. It has been tested with a fake A2A agent and client, and with a2a-sdk 1.3.0.
Regime Transitions
cadl regime-map analyzes the regime transition graph:
- Builds a directed graph of regime states from
transitions:definitions - Reachability analysis — BFS from initial state to find unreachable regimes
- Dead-state detection — identifies states with no outgoing transitions
- Cycle detection — Tarjan's SCC algorithm to find cyclic regime patterns
- Shortest path — BFS-based shortest path between any two regimes
- Export formats: text summary, Graphviz DOT, JSON
IEC 62853-oriented Summary
cadl iec62853 summarises a CADL definition around the themes of IEC 62853 (Open Systems Dependability). The indicator names are defined by CADL, not by the standard, and the report does not assess conformance to IEC 62853.
| CADL Concept | CADL-defined indicator |
|---|---|
| alpha (information sharing) | Information Transparency Level |
| beta (authority centralization) | Governance Centralization Index |
| lambda (incentive strength) | Stakeholder Alignment Metric |
| ContractDef | Service Level Agreement (SLA) |
| ViolationBlock | Failure Response Specification |
| TransitionDef | Operational State Machine |
| SoS type (D/A/C/V) | System Integration Level |
Simulator Config Generation
cadl sim-* commands lower a CADL definition to a 3-layer Intermediate Representation (IR) and generate simulator-specific configuration files:
CADL YAML ─── Parser ──► AST ─── Lowering ──► 3-Layer IR ─── Generator ──► Simulator Config
│
┌────────────┼────────────┐
▼ ▼ ▼
Layer 1 Layer 2 Layer 3
Institution Protocol Algorithm
/Governance /Interaction /Operational
| Layer | Research Concern | IR Types | Example |
|---|---|---|---|
| Layer 1: Institution | Who decides? Who knows? Who benefits? | ActorSpec, ContractSpec, GovernanceParams |
beta=0.8 → DISPATCHER holds authority |
| Layer 2: Protocol | How do they interact? What on timeout? | ProtocolSpec, StepSpec |
message: ROBOT→DISPATCHER : failure_report |
| Layer 3: Algorithm | What runs centrally vs locally? | AlgorithmSpec |
central=ECBS, local=tracking_only |
Three simulator targets:
| Target | Format | Key Convention | Use Case |
|---|---|---|---|
python |
YAML | snake_case, planner bindings | Python-based MAPF/MAS simulator |
unity |
JSON | camelCase, prefab hints | Unity3D visualization |
go |
JSON | snake_case, interface spec | Go concurrent simulator |
# Validate IR
cadl sim-validate examples/a_sos_robot_delivery.cadl
# Print IR (YAML or JSON)
cadl sim-ir examples/a_sos_robot_delivery.cadl
cadl sim-ir examples/c_sos_taxi_fleet.cadl --format json
# Generate simulator configs
cadl sim-gen examples/a_sos_robot_delivery.cadl --target python -o sim_config.yaml
cadl sim-gen examples/a_sos_robot_delivery.cadl --target unity -o sim_config.json
cadl sim-gen examples/c_sos_taxi_fleet.cadl --target go -o sim_config.json
From cadl 0.3.32 each transition in the IR carries its safety_invariant as written (like condition; the key is absent when the transition has none), and the three simulator targets pass it on.
Regime bindings. From cadl 0.3.32 regimes: under sos: binds, per regime of transitions:, parameter values and the contracts in force (Appendix A, A.7.1 of the specification):
regimes:
DISTRIBUTED:
contracts: { suspended: [BAY_ASSIGNMENT] }
CENTRALIZED:
parameters: { ROUTING.beta: 0.9, environment.bays: 3 }
contracts: { active: [ROUTING, BAY_ASSIGNMENT] }
A parameter is C.alpha, C.beta or C.lambda of a contract that writes it, or environment.X of context.environment; a regime without an entry, or a parameter a regime does not bind, keeps the declared value, and a contract is in force unless the regime suspends it. cadl sim-ir writes the resolved bindings of every regime under regimes (parameters, active_contracts, suspended_contracts), and cadl sim-gen passes them to the three targets. cadl verify still checks the consistency of every pair of contracts that share a party; when no regime has both in force, a conflict is a WARN line instead of a failure, a consistent pair gets an INFO line, and an undecided pair stays UNKNOWN. The Python code from cadl codegen publishes the values of the current regime in ctx.parameters (the generated monitors do not read them) and runs the monitor of a contract only in the regimes in which it is in force. In a file with stochastic: 0.1, a bound value is the value of the model parameter bound to the same source under the design of that regime; model.regimes: may repeat it but not give another value (R-7). A file without regimes: gives the same results as before, apart from safety_invariant in the IR.
A-SoS vs C-SoS Comparison
| Property | A-SoS (robot delivery) | C-SoS (taxi fleet) |
|---|---|---|
| SoS Type | Acknowledged | Collaborative |
| Decision Authority | DISPATCHER (central) | TAXI[*] (each taxi) |
| beta (per contract) | 0.8, 0.9 (centralized) | 0.1, 0.05 (decentralized) |
| Central Planner | ECBS | aggregation_only |
| Local Planner | tracking_only | LRA* + conflict avoidance |
| Sharing Mode | uplink + broadcast | peer-to-peer broadcast |
Raspimouse Swarm Simulator — D-SoS / C-SoS / MCP-SoS Comparison
Three CADL definitions model the same 5-robot swarm on an 11-node graph network under different SoS paradigms. These connect to the raspimouse-swarm-simulator (a research repository that is not public; the part needed for the hands-on course is published as cadl-raspimouse-simulator) via the Unity config generator (cadl sim-gen --target unity).
| Property | D-SoS (Directed) | C-SoS (Collaborative) | MCP-SoS (Acknowledged) |
|---|---|---|---|
| Decision Authority | ARBITRATOR | ROBOT[*] (propose) + ARBITRATOR (verify) | LLM_AGENT |
| beta | 0.9 | 0.3 | 0.6 |
| alpha | 0.2 | 0.7 | 0.9 |
| Central Planner | NaiveDijkstra | DirectionDijkstra | LLM_Dijkstra |
| Local Planner | none | DirectionDijkstra | NaiveDijkstra + OccupancyAware |
| Communication | NATS req/res | NATS req/res + resource query | MCP tools |
| Regimes | NORMAL ↔ CONGESTED | NORMAL ↔ CONGESTED | NORMAL ↔ COLLISION_RESOLUTION ↔ DEADLOCK |
The beta and alpha rows show the values of the main contract of each definition; the C-SoS and MCP-SoS files contain a second contract with its own values.
# Generate Unity configs for all three modes
cadl sim-gen examples/raspimouse_d_sos.cadl --target unity -o output/raspimouse_d_sos_unity.json
cadl sim-gen examples/raspimouse_c_sos.cadl --target unity -o output/raspimouse_c_sos_unity.json
cadl sim-gen examples/raspimouse_mcp_sos.cadl --target unity -o output/raspimouse_mcp_sos_unity.json
Norm Verdicts on a Trace
cadl norms-eval computes the verdicts of the norms extension (Appendix F, F.4 and F.5 of the specification) for one contract instance on a recorded trace. It is an offline monitor: it does not run the system, and it does not run the lifecycle state machine.
cadl norms-eval examples/norms_robot_delivery.cadl \
--trace examples/traces/norms_robot_delivery_b_reparation.jsonl
cadl norms-eval FILE --trace TRACE [--contract ID] [--format text|json]
The file must declare norms: 0.1 and pass cadl check. --contract is needed only when several contracts have norms: or counts_as:. The exit status is 0 when no norm and no guarantee has the verdict violated (excused and pending do not fail), 1 otherwise, and 2 on a usage error (no norms: 0.1, type-check errors, a malformed trace).
Trace. JSON Lines, one observation per line, in non-decreasing time. One trace is one contract instance.
{"t": 0.0, "bindings": {"i": 2}, "values": {"DISPATCHER.is_operational": true, "ROBOT[2].status": "Idle"}}
{"t": 1.0, "messages": [{"from": "DISPATCHER", "to": "ROBOT[2]", "name": "route_assignment"}], "state": "Assigned"}
{"t": 2.5, "messages": [{"from": "ROBOT[2]", "to": "DISPATCHER", "name": "ack", "args": ["accepted"]}]}
{"t": 120.0, "values": {"ROBOT[2].status": "Delivered"}, "state": "Completed"}
| Key | Meaning |
|---|---|
t |
Time in seconds (required); now in predicates. A finite number of at most 2**53 in absolute value |
Numbers are exact (F.5): a number of the trace is the decimal number it is written as (1700000000.123 is that number, not the nearest float), times are compared without tolerance, and +, -, *, / and avg compute with rational numbers, so 0.1 + 0.2 == 0.3 holds. A number of the trace with more than 400 significant digits, more than 400 decimals or an absolute value above 1.7976931348623157e308 (the largest finite double) is a trace error with its line (the generated monitor and cadl agents-run do the same), and an item with such a literal is not evaluated; in a norm or a counts-as rule it is an error of cadl check (N-16). A numeric deadline: is exact as well (0.0005 is half a millisecond). The JSON result writes times and numbers as floats. Up to 0.3.25 numbers were floats and times were compared with a tolerance of 1e-9 s.
| bindings | First line only: the indices the instance binds (ROBOT[i] is read as ROBOT[2]) |
| request | First line only: the fields of request |
| values | Updates of the snapshot, keyed by the name as written in predicates (ROBOT[2].battery, delivery_time); a value stays until it changes |
| messages | Messages sent at this observation: from, to, name, optional args; from and to are concrete actors (DISPATCHER, ROBOT[2]) and name an identifier, written without extra whitespace. A message event matches on sender, receiver and name; when the CADL text gives arguments (ack(accepted)), they must equal args. An actor reference matches as F.3 says: ROBOT[1..2] only ROBOT[1] and ROBOT[2], ROBOT[*] and an unbound ROBOT[i] only members of the declared set, an undeclared actor never |
| state | Lifecycle state of the instance after this observation; it stays until it changes and starts as lifecycle.initial. Predicates of an observation read the state before it (step 6 of F.5 comes last) |
| amend | Path of a new version of the CADL file, relative to the trace file: the contract is amended at this observation (see below) |
| end | true ends the instance here. It also ends at the first terminal state, and otherwise at the last line, unless that line says "end": false: the trace is then a prefix and nothing is settled |
Output. The text report has a timeline and tables of norms, violations, institutional events, unauthorised acts, assumptions and guarantees. --format json gives the same as one object:
| Key | Content |
|---|---|
file, trace, contract, norms_version |
What was evaluated |
instance |
bindings, start, end (null for a prefix), ended, end_reason, state (last lifecycle state), observations |
norms[] |
id, kind, bearer, state (the six states of F.5), verdict, activated_at, time and reason of the last change, evaluable, history[] (t, from, state, reason) |
violations[] |
t, norm, severity, verdict (violated or excused), sanction, reparation, reparation_activated, transition (the requested lifecycle state; it is reported, not applied) |
institutional_events[] |
t, name, performer (the sender of the message; null for a predicate), source |
unauthorised[] |
t, act, performer, reason: the content of a power performed while no matching power of the performer is active |
amendments[] |
t, file, effects[] (norm, effect, from_state, to_state, reason); effect is carry_over, discharge, transform, activated, new_definition, removed or added |
assumptions[] |
index, text, temporal, status (holds, failed, pending), time, reason |
guarantees[] |
index, text, temporal, verdict, time, reason |
timeline[] |
t, kind (start, norm, violation, event, power, unauthorised, ignored, amend, assume, guarantee, end), text |
warnings[], violated[], ok |
Warnings; the norms and guarantees with verdict violated; whether there are none |
Readings. Where F.4 and F.5 leave a choice, the command reads them as follows.
- Every change carries the time of the observation at which it is decided. A missed deadline is detected, and judged
violatedorexcused, at the first observation after it; the reason gives the time the deadline passed. - An
assume:orguarantee:item with a temporal operator is evaluated once, at the start of the instance. An item without one is a state predicate and is judged at every observation: it fails at the first observation at which it is false, and isholds/fulfilledwhen the instance ends without that. - A temporal operator is decided false (
within,until) or true (throughout) only by an observation after its interval. If the instance ends first, the item stayspending, and so does a norm whose temporal content is not decided. - A predicate that uses a name without a value in the trace is undefined: it does not hold, it does not make an assumption or a guarantee fail, and the name is reported once. A bare name without a value is an enum-like literal only when
==,!=orINcompares it with a string value (status == Delivered); anywhere else (ok == true,flagalone) it is undefined. A function call other than a temporal operator or an aggregate of a comprehension is not evaluable: anassume:orguarantee:item stayspendingwith that reason, and in a norm or a counts-as rule it is an error ofcadl check(N-16), whichcadl norms-evalalso refuses in a file that was not checked (up to 0.3.29 the norm stayedinactive). - Quantifiers (
exists j in ROBOT: ...,for all r in ROBOT[*]: ...) and the aggregatessum,count,min,max,avgof a comprehension are evaluated as F.5 ("Quantifiers and aggregates") defines. The domain is a declared set (A,A[*],A[lo..hi]; for a comprehension alsolo..hi); the variable is the index of a member (ROBOT[j],r.load,j != k); a reference such asROBOT[j+1]whose index is not a member is undefined.countcounts the elements that are true or a nonzero number. With integer bounds the domain is closed and the quantifiers follow Kleene's logic. A symbolic bound (ROBOT[1..N]) has a value when the trace bindsN(bindings) orNis a quantity with an integer value at that observation; a quantifier variable namedNdoes not hide it (andcadl checkwarns, N-14). The domain is closed only when the bound has a value and no member beyond it (ROBOT[5]withN= 3) has been named so far, which F.3 makes a member (a warning says so), and when it has at most 10 000 members; a larger one is evaluated as an open domain, with a warning, so that a largeNin a trace cannot make the evaluation slow. Otherwise the domain is open, its known members are those the trace has named so far (value keys such asROBOT[3].delivery, senders and receivers, and a bindingiwhere the contract writesROBOT[i]),existsis true only by a known witness,for allfalse only by a known counterexample, and everything else, including every aggregate, is undefined (a warning says so). - Monotone aggregates in a comparison (F.5):
count,maxandminof a comprehension compared (<,<=,>,>=,==,!=, either side) with an operand that has no quantifier and no comprehension are decided from the known members when every completion agrees.countlies between the members where the element is true and that plus the undefined ones (no upper end on an open domain),maxfrom the largest defined value up,minfrom the smallest down. Socount(ROBOT[*].delivery == request.id) >= 2is true as soon as two known robots carry the delivery, also whileNhas no value, andcount(...) <= 1is false then;count(...) == 2is never true over an open domain. On a closed domain with every element defined the value is exact, as before. An element with a value of the wrong kind (a text formax, a text or symbolic value forcount) still makes the aggregate undefined.sum,avg, an aggregate inside arithmetic, and a comparison of two aggregates are not refined. - A wildcard or range reference outside a domain is shorthand (F.5, "Wildcard and range references"), rewritten when the contract is read and then evaluated as the quantifier or comprehension it stands for. In the argument of
sum,count,min,maxoravgit ranges over the members:count(ROBOT[*].status == Collision)iscount(ROBOT[j].status == Collision for j in ROBOT[*]). Anywhere else the smallest comparison that contains it (or, outside every comparison, the smallest operand ofAND,OR,NOT, quantifier body or temporal argument) must hold for every member:ROBOT[*].battery > 10isfor all j in ROBOT[*]: ROBOT[j].battery > 10;ROBOT[*].x > ROBOT[*].ycompares each member with itself;ROBOT[*].x == BASE[*].ymust hold for every pair;NOT ROBOT[*].stoppedisNOT (for all ...), true when some robot has not stopped.ROBOT[2..N]ranges over that range, with the open-domain rules above.cadl checkwarns where the reading may surprise (N-15), naming the quantified form that was probably meant: underNOT, two sets in one comparison, the same set in both operands ofOR, the same set on both sides of one comparison (ROBOT[*].pos != ROBOT[*].poscompares each robot with itself; also inside an aggregate), a set insidewithin/throughout/until(all members at one observation), and, in anassume:orguarantee:item, an aggregate over two sets, which is not evaluated. In a norm or a counts-as rule an aggregate over two sets is an error (N-16). A file without such references gives the results of 0.3.23.cadl.norms_eval.desugar_wildcards(expr)returns the rewritten predicate. - Trigger-less norms become active before step 1 of the first observation. Within step 4 the order is deadline, content,
until:. Content while a norm is suspended does not count. A violation found when the instance ends is reported, but activates no reparation and requests no transition. A norm activated at the observation at which the instance ends isdischarged.
Amendments. A line with "amend": "new_version.cadl" replaces the contract by the contract with the same id in that file, before the other steps of the observation, and treats the norm instances as F.6 says. An active or suspended instance follows the on_amendment: of the old version: carry_over keeps its state and elapsed time under the new definition (it is discharged when the id is gone or the kind differs; when the elapsed time exceeds the new deadline, an obligation is violated and a prohibition fulfilled at once, also a suspended one, unless a pending candidate of a temporal content remains, which then decides it at step 4 as under the new version from the start), discharge discharges it, and transform: X discharges it and activates an inactive X with the elapsed time counted. An inactive instance takes the new definition or is removed, a new norm without trigger is active at once, and final instances are not affected. The counts_as: rules and the lifecycle: of the new version apply from then on. The new file must declare norms: 0.1, pass cadl check, have the contract, and have the current lifecycle state; otherwise the exit status is 2. Where F.6 is silent: an assume: / guarantee: item whose text is unchanged continues, a new item is evaluated from the amendment on, and an undecided item that is gone stays pending.
cadl norms-diff OLD NEW [--contract ID] [--format text|json] reports, without a trace, what such an amendment does: norms removed, added or of a changed kind, norms whose on_amendment: is discharge or transform: (with the target and its kind), every norm that carries over with a changed content or deadline: (the report F.6 asks for; deadlines are compared exactly, and a shorter deadline says what happens to an obligation or a prohibition whose elapsed time exceeds it), transform: targets the new version lacks, and changed counts_as: rules. A test compares these findings with what cadl norms-eval does at an amendment on random traces (tests/test_norms_amend_diff.py). Each finding has a level (error, warning, info); JSON has old, new, contracts[] (id, findings[] with level, kind, text and details), errors[] and ok. The exit status is 0 when nothing prevents the amendment, 1 on an error (a missing transform target, an invalid new version), and 2 on a usage error.
examples/traces/ has five traces for examples/norms_robot_delivery.cadl: all norms fulfilled (a), a missed acknowledgement repaired by a failure report (b), both missed (c), a late delivery excused because the dispatcher stopped operating (d), and a reassignment that discharges the obligations (e). norms_amendment_v1_to_v2.jsonl is a trace of examples/norms_amendment_v1.cadl that is amended to examples/norms_amendment_v2.cadl while a failure report is due.
examples/norms_no_double_assignment.cadl adds to that contract a prohibition quantified over the robots: the same delivery must not be assigned to two robots at once (exists j in ROBOT: exists k in ROBOT: j != k AND ROBOT[j].delivery == request.id AND ROBOT[k].delivery == request.id). Its traces: no double assignment (a, fulfilled), ROBOT[3] also gets the delivery at t=3 (b, violated at t=3), and a reassignment to the same robot (c, fulfilled). N has no value in them, so the domain is open: the content is true once two named robots carry the delivery, and undefined, which does not violate, while no two do.
Design-Time Checking of Norms (Model Checking)
cadl norms-check FILE [--contract ID] [--bindings i=2] [--members ROBOT=2] [--step 1s] [--horizon N] [--export DIR] [--domain Q=lo..hi] [--instance i=n ... | --instances N] [--starts any|together] [--version FILE ...] [--timeout SECONDS] [--require-checker] [--format text|json] translates the norms of one contract instance into a Markov decision process in the PRISM language (Appendix F, F.12) and asks PRISM questions over all behaviours of the instance, before any trace exists. At each observation the environment chooses which message events occur, a class of values for each quantity (one value per class that the literals of the predicates cut the domain into, plus "no value"), and whether the instance ends. One observation every --step (default: the greatest common divisor of the deadlines and intervals), at most --horizon + 1 observations (default from the deadlines and intervals); the model is exact for traces with an observation at every step. The classes cover every JSON value a trace can give (no value, booleans, numbers, texts, lists and objects), and every predicate is evaluated on their representatives by the evaluator of cadl norms-eval, so a comparison of values of different types (a text with a number, a boolean with a number) has in the model the value it has in a trace.
cadl norms-check examples/norms_check_conflict.cadl --bindings i=1
# report_status / radio_silence: after 1 observation(s) keeping one violates the other
# apologise can be activated in a state from which every continuation violates it
# the power audit is never exercised
For every translated norm it reports whether it can be activated, violated and fulfilled (the instance may end at any observation), whether it is violated in every instance that runs to the horizon, and whether every activation can be kept; for every pair of obligations and prohibitions whether they are in conflict (a reachable state where each can still be kept alone but every continuation violates one of them); for every power whether it can be exercised; and whether a reparation can be activated. Every "possible" answer comes with a witness: a trace in the cadl norms-eval format that the command itself evaluates with the engine of cadl norms-eval and marks as confirmed (a conflict has two, one keeping each norm). --export DIR writes the model (<contract>.prism), the properties (<contract>_any.props with -const early_end=true, <contract>_full.props with early_end=false) and the witnesses (witness_<norm>_<question>.jsonl). JSON has instance, model, norms[] (per question answer and witness with trace, choices, confirmed), conflicts[], findings[], unconfirmed[], assumptions[], rules[] and notes[].
Translated: message events, counts-as rules, predicates that compare quantities with literals or with count (==, !=, <, <=, >, >=, IN, a quantity alone) with AND, OR, NOT, the quantifiers exists and for all, the aggregates count, min and max, comparisons of two quantities (ROBOT[1].load == ROBOT[2].load; the classes then hold the literals of the whole group, enough values between them for every order, and lists that realise every pattern of comparable and not comparable lists), linear arithmetic, sum and avg without a domain (every product has a literal factor and every divisor is a literal: sum(r.load for r in ROBOT) + 2 * DEPOT.reserve > DEPOT.capacity; the numbers are one finite decimal point in every face of the linear arrangement of the comparisons, found exactly, so the model is exact for every trace, and a face that holds no finite decimal, such as 3 * x == 1, is left out; the JSON lists these quantities under linear), other arithmetic over quantities with an integer domain given by --domain Q=lo..hi (--domain "ROBOT[*].load=0..3"; the answers then hold for traces whose numbers for these quantities are integers in the domain, and the report says so) or, without --domain, over the integers from one below the smallest to one above the largest literal of the predicate, which the report states as an assumed domain (assumed_domains in the JSON; each norm whose answers depend on it carries assumed_domains and a * in the text, and each finding about it says "only under the assumed domain"), and wildcard and range references (ROBOT[*].battery > 5), expanded over the members of the instance (--members; a symbolic bound such as N is bound to the last member, so the domain is closed), a content that is one within / throughout / until, deadlines, until:, powers and their effects, reparations, and assume: items of these forms. Not translated, with the reason in the report: request, now, state, and every norm that depends on a norm that is not translated. Refused: more than 1,000 observations, 16 message events, 8,192 choices per observation, or 50,000 combinations of classes of values in one group of predicates. A group of quantities compared with each other whose classes exceed this limit, and every group of four or more quantities ordered (<, <=, >, >=) against each other, takes its valuations by types and patterns instead (F.12): a type for each quantity and, per type, the literal or gap of each number or text and their order within a gap, which objects are equal, and the pattern of pairwise outcomes of the lists (lists are not always comparable, [1, "a"] < [1, 2] is undefined; n lists have the series-parallel patterns, 331 for four and 5,262 for five). Four ordered quantities without other literals have 26,035 valuations (about 2 s), 46,285 with one more numeric literal. A group of five or more quantities compared with each other, ordered or only tested for equality, has at least 424,213. From 0.3.31, when these valuations exceed 50,000 (the number is computed before any is built), when four or more ordered quantities do not all have the same classes (one has a domain, given by --domain or assumed, keeps only the classes its comparisons tell apart, or has other literals), and, in a component with linear arithmetic, for four or more ordered quantities (within the limit on face points) or when the classes and the points of the faces exceed 50,000 (cases that 0.3.30 refused), the vectors of predicate values are found by elimination instead (F.12): each predicate is split into leaves (a comparison, a quantity as a condition, IN, an aggregate) joined by AND, OR, NOT, exists and for all, the quantities are added one at a time, and a state keeps what remains of each predicate and the pattern of the added quantities that a remaining leaf still reads; equal states are merged. Every leaf is evaluated by the evaluator of cadl norms-eval on values of the classes, and every vector comes with a valuation that the evaluator confirms; every vector of a trace is found, since the value of a leaf depends only on the types, literals and relations of the quantities it reads (arithmetic has a value only on numbers) and the domains of the quantifiers do not depend on the values. The members of a set are added in sorted order when the component reads one field of the set, with the same classes for every member, and every predicate uses the members only through variables of quantifiers and aggregates over the whole set (ROBOT or ROBOT[*]), compared with each other only by == and !=; with linear arithmetic the numbers are points of the faces of the arrangement of the leaves that read them. A chain of 5, 6, 8 or 12 ordered quantities (R[1].q0 < R[1].q1 AND ...) is built in less than a second; exists j in ROBOT: exists k in ROBOT: ROBOT[j].load < ROBOT[k].load over 6 members in about 1 s and over 8 in about 12 s. From 0.3.32, when the elimination needs more than 50,000 states at one step, it runs again keeping fewer states (a group within that limit gets the same combinations and valuations as with 0.3.31), each reduction leaving the combinations the same: states that a permutation of members maps to each other (the leaves then use the members only through variables, and the remainders are the same up to the order of AND and OR) are merged; a state whose remainders can only give combinations already found, by a few runs that add the quantities along one extension at a time, is left out; and a leaf that reads a set only through min and max of one field keeps, instead of every member, one member of each sort of element (a number, a value of a wrong kind, no value) and the members with the smallest and largest number. Every pair of 6, 7 or 8 members ordered by their indices (for all j in ROBOT: for all k in ROBOT: j >= k OR ROBOT[j].load <= ROBOT[k].load, refused by 0.3.31) is now built in less than a second, and so is max(r.load for r in ROBOT) > DEPOT.load over 8 members (5 members took about 40 s). Refused, with the numbers of valuations by types and patterns, the limit, and the hints about --members and --max-states: more than 50,000 states at one step (--max-states N raises the limit up to 1,000,000), which still happens when a leaf reads many quantities through count and one of its values never occurs (count(r.load > DEPOT.load for r in ROBOT) >= 0 over 6 members), with linear arithmetic over many ordered quantities, and when predicates read the same members both through max and by their indices. examples/norms_check_linear.cadl (--members ROBOT=2) has linear arithmetic, a comparison that no decimal satisfies, and a product of two quantities with an assumed domain. An activation cannot be kept when, before an observation, some choice activates the norm and every activating choice leads to a state from which every continuation violates it (a reparation with a deadline of 0 s; an obligation with a deadline of 0 s triggered by a message can be kept, since the content may come in the same observation); the witness confirms with cadl norms-eval every choice at that observation and an idle continuation of each activating one, and the report says that the rest rests on the model checker. The time grows with the number of commands of the model (four per choice) and of reachable states: 12 message events (4,096 choices) took more than ten minutes. --timeout SECONDS bounds building the model and all runs of PRISM together (default 600) and exits with status 2 when it is exceeded; PRISM runs with a Java heap of 4g, or half the physical memory when that is smaller (CADL_PRISM_JAVAMAXMEM=8g changes it); --export writes the model before PRISM runs. The exit status is 0 without findings (also when PRISM is not on PATH; the report says nothing was checked, and --export still writes the model; with --require-checker a missing PRISM exits with status 2), 1 on a finding (a conflict, a norm never activated or violated in every instance, an activation that cannot be kept, a power never exercised), 2 on a usage error, a refusal or a timeout, 3 when a witness is not confirmed by cadl norms-eval (an error of norms-check), and 4 on an internal error.
Several instances. --instance i=1 --instance i=2 (or --instances 2, which binds the one open index to the first members of its set) checks instances of the contract together over the same observations: they share the message events and the quantities, and each has its own norms, assumptions, start and end. The environment chooses the observation at which each instance starts, in any order (--starts any, the default); before its start and after its end an instance does not change, and its trace runs from its start to its end, with the times of the shared observations. --starts together lets all instances start at the first observation, as before, with fewer commands (per choice, 2n patterns of starts and ends instead of 4n). Since --starts any is the default from 0.3.28, a run with --instances that 0.3.27 accepted may be refused for too many commands; --starts together checks it as before. The horizon is shared, so an instance that starts at observation s has at most H − s + 1 observations (the report says so; a larger --horizon covers longer ones). Norms are named id@k, conflicts are asked for every pair across the instances (one bearer obliged in one instance to do what another instance forbids; examples/norms_check_instances.cadl with --members ROBOT=2 --instances 2), and every witness holds the trace of each instance (witness_..._instance<k>.jsonl with --export). Some conflicts need instances that start at different observations: in examples/norms_check_starts.cadl (--members ROBOT=2 --instances 2) the reparation of one instance forbids the gate to grant access while another instance, started later, obliges it to; with --starts together there is no conflict. At most 4 instances.
Amendments. --version FILE (repeated for a sequence) lets the environment amend the contract to the next version at any observation, before the other steps of the observation, as F.6 and cadl norms-eval apply it (on_amendment: carry_over with the elapsed time and, for an unchanged content, the pending candidates, discharge, transform:; removed and added norms; assumptions that continue, start anew or close). The questions are asked across the amendment for every norm id of any version (the JSON lists the versions of each), and a witness that needs an amendment names the version file in its amend line, so cadl norms-eval reads it as the trace of an amended instance. Versions with other actors or another lifecycle, a norm whose kind changes, and an untranslated norm or counts-as rule in some version are refused. With several instances (--instances N --version FILE) one amendment applies at the same observation to every instance that runs there, as the amend line of each trace does in cadl norms-eval; an instance that has ended is not amended, and an instance that starts after an amendment is an instance of the new version (its witness trace is evaluated with that file, which the JSON names under files). cadl norms-check examples/norms_check_amend_v1.cadl --members ROBOT=2 --instances 2 --version examples/norms_check_amend_v2.cadl finds that a request of one robot pending at the amendment conflicts with the curfew that version 2 adds in the other robot's instance. cadl norms-check examples/norms_amendment_v1.cadl --bindings i=2 --version examples/norms_amendment_v2.cadl finds that request_help, a norm of the second version, can be activated and violated after the amendment (a few minutes: the commands are multiplied by the versions).
The translation is tested against cadl norms-eval: the tests run the generated PRISM text with an interpreter of the subset it uses on random paths of environment choices and on every path of at most two observations of one contract and compare the state of every norm after every observation, the verdicts, the exercises of powers and the activations of reparations (CADL_NORMS_CHECK_PATHS raises the number of random paths); the interpreter is compared with paths that the PRISM simulator generates, and the answers of PRISM with explicit fixpoints over the reachable states.
Norms Monitor in Generated Python Code
For a file that declares norms: 0.1, cadl codegen -t python also writes norms_monitor.py: an online monitor of one contract instance (Appendix F, F.5). A running system feeds it observations as they happen and gets back the changes of the norm states and of the four-valued verdicts, including those of assume: / guarantee: items with temporal operators, which contracts.py leaves out.
from robot_delivery_norms.norms_monitor import NormsMonitor # the generated package
m = NormsMonitor("DELIVERY_SLA", bindings={"i": 2})
m.observe({"t": 0.0, "values": {"DISPATCHER.is_operational": True, "ROBOT[2].status": "Idle"}})
m.observe({"t": 1.0, "state": "Assigned",
"messages": [{"from": "DISPATCHER", "to": "ROBOT[2]", "name": "route_assignment"}]})
# -> [{"t": 1.0, "kind": "norm", "id": "acknowledge", "state": "active", "verdict": "pending",
# "previous_state": "inactive", "previous_verdict": "pending", "reason": "trigger occurred: ..."}]
m.next_deadline() # 6.0: acknowledge is due 5 s after its activation
m.next_check() # 6.000000002: the first time stamp at which that is detected
m.observe({"t": 6.5}) # -> acknowledge violated, report_failure active
m.verdicts() # current state and verdict of every norm and item
m.end() # the instance has ended: settle the norms
m.result() # everything, with the keys of `cadl norms-eval --format json`
| Call | Meaning |
|---|---|
NormsMonitor(contract=None, bindings=None, request=None, quantities=None, versions=None) |
A monitor of one contract instance. contract may be left out when one contract has norms: or counts_as: |
observe(observation) |
Process one observation: a dict with the keys of one trace line of cadl norms-eval (t required; values, messages, state, end; bindings and request in the first one). Returns the changes of this step |
end() |
End the instance at the last observation received and settle its norms (F.5, item 6). An observation with "end": True or with a terminal state ends it too |
verdicts() |
norms (state, verdict per id), assumptions (status), guarantees (verdict), ok |
result() |
The result of cadl norms-eval --format json for the observations so far, without file; before the end it is the result of a prefix |
next_deadline() |
The earliest time at which a deadline of an active obligation or the window of an active prohibition is over, or None. An observation at exactly this time is still in time |
next_check() |
The earliest time stamp at which an observation is certain to decide something that only waits for time: such a deadline, or a temporal operator whose interval is over (also nested ones, and those in the content of a norm). None when nothing waits |
started, ended, contract |
State of the monitor |
A change is a dict: for a norm t, kind: "norm", id, state, verdict, previous_state, previous_verdict, reason (one per norm and step, with the state the step left it in); for an item t, kind: "guarantee" or "assumption", index, text, verdict (or status: holds, failed), previous, reason.
One implementation. norms_monitor.py does not import cadl; it needs only the standard library of Python 3.9 or later and can be copied on its own. It holds the declared actors and the contracts of the file as data and, copied verbatim, the engine of cadl norms-eval (the part of cadl/norms_eval.py between its monitor-runtime marks) with the AST classes and helpers it uses. Where the engine calls the parser of cadl, the monitor looks up what the parser returned at generation time. Before the module is written, the generator compiles it and checks that every global name it uses is defined in it; if the copied code needs something that was not copied, cadl codegen fails with that message and writes nothing. The generated package can be imported where cadl is not installed; its other modules still need cadl.codegen.runtime_support, and their names raise the import error when used. A recorded trace is replayed with
python -m robot_delivery_norms.norms_monitor TRACE.jsonl [--contract ID] [--format json|text]
which prints what cadl norms-eval prints for the same file and trace (JSON without the key file), with the same exit status. The tests compare the two on the example traces, on every case of tests/test_norms_eval.py, and on 1,500 random traces (with actor ranges, members outside a range and undeclared actors), in a process in which cadl cannot be imported.
What an online monitor knows. The monitor decides each observation with the observations received so far, so result() after an observation is the result of cadl norms-eval on the trace up to it as a prefix ("end": false), given the same names of quantities (third point). Three points differ from reading a whole trace:
- A missed deadline, and a temporal operator that is false (
within,until) or true (throughout) because its interval is over, is detected at the first observation after that time, and a violation is judgedviolatedorexcusedthen. A host with nothing to report sends a time-only observation{"t": m.next_check()}when that time has come.next_check()is the smallest float whose decimal value is later than the deadline or the end of the interval: times are compared exactly, and content at the deadline itself is in time. A norm without deadline whose content has a temporal operator is evaluated at every observation, so every observation gives it a new time to check. - The instance does not end "at the last line": call
end(), or send an observation with"end": Trueor a terminalstate. An observation after the end has no effect: it is checked for its form, counted in a warning ofresult(), and nothing of it is kept. - A name written without an actor (
load, notROBOT[1].load) that has no value yet cannot be told from a symbolic value such asDelivered.cadl norms-evaltakes the names of the quantities from the observations of the instance in the trace; the monitor takes them fromquantities=[...], and a name that is not given there is a quantity only from its first value on. This is the one way in which the verdicts can differ, and only for such a name compared with a text value before its first value (mode == target, wheretargetgets its value later): give the names withquantities=. Warnings about names without a value are given when they are first met, and astatefor a contract withoutlifecycle:is reported when it arrives, also when a later observation amends the contract (cadl norms-evalthen says nothing).
A refused observation leaves the monitor exactly as it was, and the monitor stays usable. observe raises TraceError for an observation that is malformed (a wrong type, a time that goes back, is not finite or is larger than 2**53, an actor that is not written as NAME or NAME[2], a state the lifecycle does not have) and ObservationError (a MonitorError) for an amendment that cannot be applied. The monitor copies what it is given. It keeps the observations of its instance (temporal operators and "becomes true" need them): make one monitor per contract instance and drop it after the end. It is not thread-safe, and, like cadl norms-eval, it reads the lifecycle state from the observations and reports a requested transition: without applying it.
Amendments. An observation with "amend": "NAME" needs the model of the new version: generate the monitor of the new file too and pass its MODEL, NormsMonitor(..., versions={"NAME": new_package.norms_monitor.MODEL}); on the command line --model-version NAME=MODEL.json, where the file is written by python -m NEW_PACKAGE.norms_monitor --dump-model. A value of versions that is not such a model is refused by the constructor. An observation that names a version the monitor does not have, a version without the contract, or one whose lifecycle lacks the current state is refused (ObservationError). Loading a .cadl file at run time is not possible, since the monitor has no parser. At an observation with amend, a norm that is new in the new version is reported with previous_state None and a removed one with state None; the index of an item is its position in the current version, so identify an item across an amendment by its text.
Strings and numbers of the file. Everything the monitor takes from the .cadl file is in MODEL: one JSON text (ASCII, no NaN or Infinity) in one Python string literal, read with json.loads; none of it is formatted into code. A model with a number that is not finite is not generated (cadl codegen reports where it is and writes nothing); a predicate with a number that overflows, such as 1e999, is not a predicate for cadl at all: an item is kept as text, and a norm or counts-as rule with it is an error of cadl check (N-16), for which no monitor is generated. The input check of cadl codegen still applies to the whole file, so a string with a quote, a backslash or a control character is refused before anything is generated.
Norms Monitors in Generated Rego and Solidity
For a file that declares norms: 0.1, cadl codegen -t opa writes norms_monitor_<contract>.rego and cadl codegen -t solidity writes <Contract>NormsMonitor.sol for each contract (Appendix D and F.5 of the specification). They monitor the norms, the counts-as rules and the assume: / guarantee: items, also those with within, throughout and until, which the contract policy (<contract>.rego, <Contract>.sol) leaves out. Each step follows the order of F.5 as cadl norms-eval implements it, and the tests compare both with the engine of cadl norms-eval after every observation.
What they support. Message events (actor patterns with [*], ranges and bound indices, arguments), institutional events, predicates with the three-valued reading of F.5 (bare names, A[i].x, request.x, now, state, comparisons, + - * /, IN, AND, OR, NOT), triggers, until:, deadlines, reparations, powers (activate, suspend, resume, discharge), counts-as rules with if:, and the temporal operators, nested too. Not supported: quantifiers, aggregates and wildcard or range references in predicates, an index that is an expression (A[i+1]), and amendments (F.6; an observation with amend is refused). A contract that uses one of them in a norm, a counts-as rule or an assume: item gets no monitor, and cadl codegen says so in a warning with the reason (the other files are still generated; the python target monitors such a contract); a guarantee: item that uses one is left out of the monitor, with a warning, since nothing else depends on it. The Solidity monitor also refuses * and /, numbers with more than 6 decimals, a temporal operator inside another one outside the content of a norm (there it scans each window once, as the observations arrive), six or more temporal operators in the content of a norm (five or more before 0.3.31), nested temporal operators in a content other than a within or throughout whose operand is another within or throughout, or its negation, over an operand without one or over such a nesting again (so until in a nesting and within(5s, throughout(2s, p) AND r) are refused; three and more levels are monitored from 0.3.31), and a monitor whose creation code would exceed the 49152 bytes of EIP-3860 (estimated from the generated constructor); in a guarantee: item these leave out only the item.
Rego: a step function. OPA keeps no state, so the policy computes the next state of the monitor from the previous one and one observation:
echo '{"state": null, "observation": {"t": 0, "bindings": {"i": 2}}}' > input.json
opa eval -d norms_monitor_delivery_sla.rego -i input.json 'data.cadl.norms_monitor.delivery_sla.result'
The input is {"state": S, "observation": O} (S null or absent for the first observation; O one trace line of cadl norms-eval) or {"state": S, "finish": true} (the end of the instance at its last observation, end() of the Python monitor); bindings, request and quantities may be given next to the first observation. result has state (the host stores it and passes it with the next observation), changes (as observe() of the Python monitor, without reason), violations, institutional_events, powers_exercised, unauthorised, verdicts, ended and next_deadline; for a refused observation it has error and the unchanged state. The state is plain JSON (Appendix D lists its keys): the bindings, the request, the known names, the current values, the lifecycle state, the norm instances with their activation, active time and pending candidates, the items, and a buffer of the observations that a temporal operator or a pending candidate still reads (older ones are dropped). The contract is in the policy as one JSON text (model, read with json.unmarshal); the predicates are Rego functions whose literals are JSON strings, so no text of the .cadl file is Rego code.
Solidity: a contract with the state. The constructor takes the address of the reporter (address(0): the deployer); only the reporter may call begin(bindings, request, quantities) (optional, before the first observation), observe(t, values, messages, hasState, state, end), addQuantities(names) and finish(), which record the instance. verdicts() (in the order of normIds()), ok(), nextDeadline(), contractId(), observations(), lastT(), ended(), ignored() and the events NormChanged, ItemChanged, Violation, InstitutionalEvent, PowerExercised and Unauthorised report it. A malformed observation reverts, which leaves the contract as it was. Numbers, including the time t, are fixed-point with 6 decimals (int256 times 10**6); t is an argument, so a recorded trace can be replayed, and a deployment may pass block.timestamp * 10**6. A value is (name, kind, n, s) with kind 0 (null), 2 (boolean), 3 (number) or 4 (string). The file has the base contract, an interpreter of the contract that its constructor stores as data (texts as hex literals), and six libraries, CadlNormsValues, CadlNormsEval, CadlNormsWindows, CadlNormsMulti, CadlNormsItems and CadlNormsActs, that are deployed separately (in this order) and linked; the model and the state are one struct in storage that the libraries read and change, so that the runtime code of each stays below the 24 KB limit of EIP-170 (cadl codegen estimates the sizes from above, the main contract at 17 250 bytes and CadlNormsMulti at 16 270 from 0.3.32, and refuses a contract whose estimate exceeds the limit). The cost of an observation does not grow with the number of earlier observations: each window of a temporal operator is scanned once, values are found by binary search, and values no later step reads are deleted (a few per new value). In the tests an observation of the example costs about 6.4 × 10^5 gas over 320 observations at one per second, while the 300 s window of its assumption is open and after it; observations of the richest test contract cost from 3 × 10^4 to 3.3 × 10^6 gas (median 1.3 × 10^6). A norm whose content has a temporal operator keeps its candidates in a queue and decides them together from what the observations say about the operands (the first time within's operand is true, throughout's is false or undefined, until's q is true or p is not), with binary searches and a few deletions per observation, so its cost does not grow with the observations inside a window: a throughout(1000s, …) content at one observation per second costs 4.4 × 10^5 gas at the 320th observation and 4.5 × 10^5 at the 1000th (1.3 × 10^7 at the 320th in 0.3.25). The rest of such a content is decided when the candidate is created, so the candidate holds at once, is not created, or waits for the operator (within(3s, p) OR q with q true holds at once); the content is read there with the operator undecided, true and false, so a candidate may also hold exactly when the operator is false, or when it is true or false. Such candidates are in a queue of the dual operator on the negated operands (NOT within(d, p) is throughout(d, NOT p), and NOT until(p, q, d) is the release of ¬p and ¬q, Appendix D, D.5), which covers an operator under NOT, inside a comparison (within(3s, p) == flag) and in IN. A content with two to five temporal operators (also within(…) == throughout(…); five from 0.3.31) is decided with CadlNormsMulti: its candidates are the leaves of a segment tree in storage whose nodes record, for each of the 5^m combinations of operator states (decided, or undecided with one of four future values), whether a candidate holds and whether one is undecided, in one storage word up to three operators, in five for four and in 25 for five; an observation decides each operator for a few ranges of candidates, in steps that grow with the logarithm of their number. A within or throughout whose operand is another within or throughout (or its negation) over an operand without a temporal operator, such as within(5s, throughout(2s, p)), or from 0.3.31 over such a nesting again (within(5s, throughout(3s, NOT within(1s, p))), any number of levels), is one operator of that tree: each inner level is decided per observation, the decided values of a level are always those of the first observations, and they are fed to the level above, and the last to the outer operator, in that order and in runs of equal values (at most three runs per level at any depth, so the gas per level does not depend on the depth), which Appendix D, D.5 proves equal to F.5. From 0.3.32 the contents the tree does not decide are decided per observation (General): six or more temporal operators, until in a nesting (within(5s, until(p, q, 3s)), until(p, within(2s, q), 3s)), whose later values can be decided before earlier ones, and an operand that combines a nested operator with other parts (within(5s, throughout(2s, p) AND r)). From the first candidate of an activation on, each temporal operator of such a content keeps the truth values of its operands and its own value at every observation (two bits each, 128 to a storage word), inner operators first; its value at an observation is that of F.4 over the operand values of its window, found with a few masks per word, and an observation reads again only the operands whose inner values it decided, the windows that hold an operand decided now or that it ends, and the windows that waited for an operand it decided. The gas of an observation does not grow with the number of earlier observations; it grows linearly with the operators and can grow with the number of observations inside a window (after a gap in time one observation can decide a whole window). The tree is not pruned: each activation of such a norm adds at least three storage slots per candidate, which are not deleted (General likewise keeps two bits per operand and per value of each operator for each observation from the first candidate on), and every monitor keeps two array entries per observation (its time and lifecycle state); the gas of an observation stays the same. Gas figures here are measured with one value per observation (about 20 % more with two). At one observation per second into 1000 s windows, NOT until(…) costs 5.2 × 10^5 gas at the 320th and at the 1000th observation, throughout(1000s, …) == true 5.1 × 10^5, within(1000s, …) OR throughout(1000s, …) 6.1 × 10^5 and 6.2 × 10^5, three operators 8.4 × 10^5 and 8.5 × 10^5, four operators 1.9 × 10^6 and 2.0 × 10^6 (five storage words per node; 1.8 × 10^6 and 1.9 × 10^6 before 0.3.31), five operators 6.7 × 10^6 and 6.9 × 10^6 (at most 1.0 × 10^7; 25 words per node), within(1000s, throughout(500s, …)) 5.1 × 10^5 and 5.2 × 10^5, throughout(1000s, within(10s, …)) 6.2 × 10^5 and 6.5 × 10^5 (its inner values are decided from the eleventh second on), and three levels, within(1000s, throughout(500s, within(10s, …))), 5.5 × 10^5 and 5.6 × 10^5. Decided per observation, within(1000s, throughout(500s, …) AND …) costs 5.4 × 10^5 and 6.4 × 10^5 gas at the 320th and the 1000th observation, within(1000s, until(…, …, 500s)) 5.3 × 10^5 and 6.8 × 10^5 (each rises once, when the inner windows end), six operators 9.8 × 10^5 and 9.9 × 10^5 (at most 1.3 × 10^6), and within(100s, NOT throughout(50s, …) OR …), whose windows end before their operands are decided, 7.4 × 10^5 from the 150th second on. A content with many operators is limited by the deployment, whose constructor stores the model: about 5.5 × 10^5 gas per operator of the form within(1s, A.x > k) (7.4 × 10^6 gas for 6 operators, 1.7 × 10^7 for 24, 3.1 × 10^7 for 48), and by the creation code (42 760 bytes for 48 operators; the estimate refuses a monitor above EIP-3860). A monitor whose observation would exceed the block gas limit cannot record it and does not recover, and neither can one whose reporter key is lost. A bare name read inside a temporal operator that is a quantity (flag in throughout(10s, A.s == flag)) must be given in begin or observed at the first observation; an observe or addQuantities that makes it known later reverts, since the scans keep the values they have read. Compile with solc 0.8.24 to 0.8.37 (checked; the pragma is >=0.8.24 <=0.8.37) and --optimize --optimize-runs 1 (the header of the file says so; without the optimizer the runtime code exceeds EIP-170).
What differs from cadl norms-eval. As for the Python monitor, a deadline is detected at the first observation after it, the instance ends with finish or an observation that ends it, and the names of quantities written without an actor come from quantities and the observations so far. Numbers and times are exact in all three, as in cadl norms-eval: the Rego monitor reads every number as the decimal it is written as (its state keeps them as {"$q": [n, k]}, the number n / 10^k) and refuses / (a quotient is not always a decimal number), a product that could have more than 4095 decimals, and a number outside the range of cadl norms-eval (above); the Solidity monitor holds six decimals and refuses *, / and more decimals. For the inputs that meet these limits they agree with cadl norms-eval. A binding must be an integer written as one (1.0 is refused) or a string, and a value of values null, a boolean, a number or a string (a list is refused, in request too, and so are two keys of values that differ only in whitespace); the Solidity monitor wants the request as leaves ("a.b") and ASCII names of values. The Rego monitor trusts the state it is given (it checks its format and contract only): the host keeps the stored states intact. Reasons, warnings and the timeline of cadl norms-eval are not reported.
The tests (tests/test_norms_monitor_targets.py) run the Rego with opa eval and the Solidity on an EVM (eth-tester with py-evm, in a separate Python named by CADL_EVM_PYTHON; solc from CADL_SOLC, the PATH or ~/.solcx) and skip what is not installed. They compare the state and verdict of every norm, the items, the violations, the institutional events and the unauthorised acts after every observation of the example traces, of the traces of tests/test_norms_eval.py (OPA) and of random traces; CADL_NORMS_TARGET_TRACES sets the number of random traces, and CADL_NORMS_EVM_CASES the number of traces of tests/test_norms_eval.py run on the EVM (all by default). The CI job for Python 3.12 builds the EVM venv (eth-tester and py-evm) and gets solc 0.8.24 with py-solc-x, so the EVM tests run there with 40 of those traces; the versions of the EVM venv are pinned by tests/evm-constraints.txt, and CADL_REQUIRE_EVM=1 (set in CI) makes a missing EVM a failure instead of a skip; cadl itself does not depend on them. They also check that strings of the file that would end a string literal or a comment stay data. scripts/norms_monitor_mutations.py runs mutants of the temporal parts of the Solidity monitor against the traces of its temporal contents and reports those that give the same verdicts as cadl norms-eval (none, for its 31 mutants).
Grounding of the Institutional Parameters (grounding 0.1)
The grounding extension (Appendix J of the specification) relates the declared alpha, beta and lambda of a contract to its norms. A file declares grounding: 0.1 together with norms: 0.1, which it requires, and may then use four keys:
contracts:
- id: DELIVERY_SLA
parties: [DISPATCHER, "ROBOT[*]", "CUSTOMER[*]"]
authority: { decision_holder: DISPATCHER, beta: 0.9 }
information:
alpha: 0.6
sharing: ["DISPATCHER -> ROBOT[*] : route"]
incentives: { lambda: 0.5 }
grounding:
items: { route: DISPATCHER, battery: "ROBOT[*]" } # information item: its origin
tolerance: 0.25 # default 0.25
norms:
- id: may_return_to_charge
kind: permission
bearer: "ROBOT[i]"
content: "ROBOT[i] -> DISPATCHER : charging_request"
shares: [battery] # the message conveys these items
- id: no_low_battery_driving
kind: prohibition
bearer: "ROBOT[i]"
content: "ROBOT[i].battery < 10 AND ROBOT[i].status == InTransit"
on_violation: { sanction: "removed from the pool", magnitude: 4 }
on_fulfilment: { reward: "bonus", magnitude: 1 }
cadl norms-indices FILE [--contract ID] [--format text|json] computes three quantities for every contract, each an exact ratio of two counts, or undefined when its denominator is zero (J.4):
| Quantity | Ratio | Reported with it |
|---|---|---|
| alpha^, information sharing | pairs (item, party other than its origin) that a sharing entry, an obligation or a permission gives to the whole party / all such pairs | the pairs given in each of the three ways, the pairs not given, and the entries and norms whose target is member-specific (ROBOT[3]), which give no pair |
| beta^, concentration of powers | largest number of powers borne by one single actor / powers | the powers per bearer, the number of norms each power names in effects:, and the share of the decision_holder |
| chi, incentive coverage | obligations and prohibitions with a sanction text, a reward text or a magnitude greater than zero / obligations and prohibitions | the norms with a reparation only, and the norms with a transition: |
$ cadl norms-indices examples/grounding_robot_delivery.cadl
Contract DELIVERY_SLA (tolerance 0.25)
alpha^ (information sharing) = 5/8 = 0.625 given pairs / pairs
declared alpha: 0.6, declared - index = -0.025
pairs given by a sharing entry: 3, by an obligation: 1, by a permission: 1
...
beta^ (concentration of powers) = 1/2 = 0.5 largest number of powers of one single actor / powers
declared beta: 0.9, declared - index = 0.4
...
chi (incentive coverage) = 1/3 = 0.333333 norms that carry an incentive / obligations and prohibitions
declared lambda: 0.5 (a scale; not compared with chi)
...
warning contract 'DELIVERY_SLA' declares beta: 0.9, but the index of concentration of powers is 1/2 = 0.5 ...; they differ by 0.4, more than the tolerance 0.25 (J-7)
JSON has file, grounding, contracts[] (id, items, tolerance, and alpha, beta, coverage, each with defined, numerator, denominator, exact, value or undefined with the reason, and the counts above; diagnostics[]) and designs[] (the diagnostics of J-9).
The SoS. For a file with two or more contracts (and no --contract), a last section SoS: all N contracts and the JSON key sos give the same three quantities over all contracts (J.4, "The quantities of the SoS"): alpha^_SoS = the given pairs of all contracts / their pairs, an item being qualified by its contract (an item declared in two contracts gives pairs in each, and an entry of one contract gives no pair of another); beta^_SoS = the largest number of powers that one single actor bears in all contracts together / all powers; chi_SoS = the obligations and prohibitions with an incentive / all of them. sos has contracts, and alpha, beta, coverage in the form above with the summed counts (bearers and single_actors sum the powers per bearer; largest_bearers names every single actor with the largest count, sorted; the whole section does not depend on the order of the contracts). Nothing compares them with a declared value (v0.3 declares α, β, λ per contract only), and they are not weighted. alpha^_SoS and chi_SoS lie between the values of the contracts; beta^_SoS is at most the mean of the contracts' beta^ weighted by their powers and can be smaller than all of them (two contracts whose only powers are borne by X and by Y: 1 and 1, SoS 1/2). The IR carries them as institution.grounding (J.10). The output for each contract is unchanged. The exit status is 0 when the indices were reported, whatever the warnings, and 2 on a usage error (no file, a type-check error, or a file that does not declare grounding: 0.1 with norms: 0.1).
The indices are evidence about the norms, not the meaning of the parameters: cadl check compares the declared alpha and beta with them and only warns (item 15 under Type Checks). lambda is a scale and is not compared with a number. Declaring grounding: 0.1 never makes a file invalid that declares norms: 0.1 and uses none of the new keys.
Annotations only. shares:, on_fulfilment: and the magnitudes change no verdict: cadl norms-eval, cadl agents-run and the generated norms_monitor.py give the same results with and without them, and the generated monitor does not carry them. The code generators do not write them either, so a reward text may contain a quote. The IR (cadl sim-ir) carries them for a file that declares the extension: each contract gains grounding (items, tolerance, and indices with the counts of alpha, beta and coverage, null for an undefined quantity) and each norm shares, on_violation_magnitude, on_fulfilment_reward and on_fulfilment_magnitude (J.10); with two or more contracts the institution layer gains grounding with the quantities of the SoS. The IR of a file that does not declare the extension is unchanged.
Two versions. cadl norms-diff OLD NEW also reports a changed on_violation.magnitude, on_fulfilment:, shares:, grounding.items and grounding.tolerance and each changed index, lists the magnitude, on_fulfilment: and shares: of a norm added in the new version, and warns when a declared alpha or beta and its index move in opposite directions between the versions (J-13); when only one version declares the extension, the indices are not compared and the report says so, for example when beta is raised while the amendment gives a power to the robots.
For strategic models. In a strategic model (Appendix I; see Strategic Model below), a payoff term may name a norm instead of giving a weight: { reward: shortcuts, sanction_of: "DELIVERY.no_shortcut" }. Its weight is then −m · ℓ (reward_of:: +m′ · ℓ), with m the on_violation.magnitude (m′ the on_fulfilment.magnitude) of the norm and ℓ the parameter bound by from: "C.lambda" (J.7). cadl.grounding.norm_payoff_link(sos, "C.n", "sanction_of" | "reward_of") resolves the reference: the magnitude (exact), the bearer, the source name C.lambda, or a description of why the reference cannot be used. See examples/games_grounding_robot_delivery.cadl.
Amendable Parameters, Versions and Measured Metrics (amendment 0.1)
From 0.3.32, the amendment extension (Appendix K of the specification) states in the model what the Course D hands-on keeps in constitution.yaml, # @amend: comments, kpi.md and gsn.yaml. A file declares amendment: 0.1 and gives sos.version:
amendment:
previous: "1" # the version this one replaces
effective: { period: 2 } # or { at: 2026-12-01T09:00:00+09:00 }
transitional: # contract instances running at that time
default: keep # finish under the version they started in
contracts:
- { contract: ROAD_USE, rule: switch } # follow the new version at once
decisions: # records of human decisions
- { id: D1, ref: "decisions.md#d1", kind: record }
layers:
rule: { decided_by: COUNCIL, procedure: vote, quorum: 2 }
contract: { decided_by: OPERATOR }
parameters:
- id: block_k
layer: rule
value: 2
min: 1
max: 4
step: 1 # one amendment moves it by at most max_steps (1) steps
decision: D1
at: [contracts.ROAD_USE.monitors.blocking_guard.rule]
metrics:
- id: on_time_deliveries
formula: "count(Delivered)"
target: ">= 0.9 * count(orders)"
measure: { window: 3600s, runs: 5, across_runs: mean }
schedule:
- { from: { period: 5 }, target: ">= 0.85 * count(orders)", decision: K5 }
cadl check applies the rules K-1 to K-13: a decided_by: that is no actor and no role of the model, a voter that is no actor, a value outside min–max or off the steps, a location of at: that does not exist or does not hold the value, a decision that is not declared, a schedule whose entries are not in order, a transitional rule for an unknown contract or in a terminal state, and malformed values are errors. cadl sim-ir adds the top-level key amendment to the IR (only for a file that declares the extension). cadl amend-diff OLD NEW lists the parameters that changed and the contracts they changed, and checks each change against the declaration of the old version (range, steps, at most max_steps steps). All changed parameters are put into the old version at once; a location that holds the old value more than once, or two parameters that change the same value at one place differently, is an error. Any other change of the rules (actors, contracts, protocols, transitions, regimes, verification, and the order of the actors and of the norms of a contract) is an error; a change of the metrics, codegen or texts, or of the order of other lists, is a warning. A previous: that is not the old version, the same version on both sides, and an effective time that is not later are errors. For every contract with norms whose running instances switch, it also reports what F.6 does to the norms (on_amendment:, as cadl norms-diff), and it warns when a switching instance could be in a state the new version removed. An old version that does not declare the extension declares no parameter. Exit status 0 when the changes respect the declaration, 1 when they do not or the new version does not pass cadl check, 2 for a usage problem (a missing file, or an old version that does not pass cadl check). The keys are declarations: no verdict depends on them, and a file without them gives the same results as in 0.3.31.
Stochastic Model (PRISM Export)
A file that declares stochastic: 0.1 under extensions: may carry a model: block (Appendix H of the specification): a parametric discrete-time Markov chain written as guarded probabilistic commands over finite state variables, in which parameters can be bound to alpha, beta, or lambda of a contract. Each regime of transitions: is a design with its own parameter values and commands. See examples/stochastic_robot_delivery.cadl.
# One PRISM model file and one properties file per design:
# <sos name>_<design>.prism and <sos name>_<design>.props
cadl model-export examples/stochastic_robot_delivery.cadl --output prism_out/
cadl model-export examples/stochastic_robot_delivery.cadl --output prism_out/ --regime CENTRALIZED
# Evaluate model.properties for every design at the fixed parameter values
cadl model-check examples/stochastic_robot_delivery.cadl
cadl model-check examples/stochastic_robot_delivery.cadl --regime CENTRALIZED --set p_fail=0.2 --set p_loss=1/6 --format json
# Evaluate a regime map query at the corner points of a uniform grid
cadl model-check examples/stochastic_robot_delivery.cadl --regime-map best_for_delivery --grid 5
# Compute the certified regime map of the query (cells decided by parameter lifting)
cadl model-check examples/stochastic_robot_delivery.cadl --regime-map best_for_delivery --certify
cadl model-check examples/stochastic_robot_delivery.cadl --regime-map best_for_delivery --certify --max-cells 500 --format json
cadl model-exportfollows the export rules of H.11. Parameters listed in theover:of a regime map are written as undefined constants (const double p;), so the files can be given to PRISM or Storm for model checking, region verification, and parameter synthesis. A name equal to a PRISM keyword or built-in function name (floor,ceil,round,pow,mod,log) gets a trailing underscore; a name collision after that is an error.cadlruns no external model checker. Without--certify,cadl model-checkis a small internal reference evaluator for checking the export and for tests: it builds the Markov chain of one design by explicit enumeration, with every parameter fixed, and evaluatesPwithF,F<=k,U,U<=kandR{"r"}withFin exact rational arithmetic. It reports the value and, for a threshold,satisfiedorviolated. The exit status is 0 when every threshold property evaluated is satisfied (queries do not count), 1 when at least one is violated, and 2 when nothing could be evaluated (a usage error, or a file without an interpreted model).--regime-map ID --grid Nprints, for each sample point, the objective of each compared regime and which regime is best there. These are estimates at sample points, not a certified regime map: no cell is decided, and the exit status is 0.--regime-map ID --certifycomputes the certified regime map of H.9: a set of cells (boxes of the open parameters) that cover the region, eachdecidedwith the setbestof regimes that are optimal at every valuation of the cell,infeasible(no regime satisfies the constraint anywhere in the cell), orundecided. The method is parameter lifting with exact rational arithmetic, insidecadland without an external tool: on a cell, each design is relaxed to a Markov decision process in which every state chooses a corner of the cell for the parameters in its outgoing probabilities; the minimal and maximal values of that process are lower and upper bounds of the design's value on the whole cell. A cell isdecidedfor a regime when the bounds prove that it satisfies the constraint everywhere in the cell and that every other regime either violates the constraint everywhere or is nowhere better; otherwise the cell is bisected, the largest undecided cell first, until the undecided fraction of the volume is at mostresolution:.--max-depth N(default 24) bounds the bisections of one cell and--max-cells N(default 20000) the size of the partition; when a budget stops the refinement first, the map is still printed and says that the resolution is not reached. The output lists the method, the counts, the undecided fraction (exact and rounded) and every cell with its box, status andbest; halves with the same claim are joined. The exit status is 0 when the resolution is reached, 1 when it is not, and 2 on an error.--certifycannot be combined with--gridor--regime;--setmay fix a parameter that is not open in the map. For the example the map has 95 cells (60 decided, 35 undecided, undecided fraction 51/1024) and is computed in about 0.1 s.- Limits of the certified map: the bounds of the designs are compared with each other, not the difference of their values, so cells next to a boundary stay
undecidedalthough no boundary crosses them, and regimes that tie are listed together only when the bounds prove it (equal constant bounds, or designs with the same model). A probability that is not multi-affine in the open parameters (p * p) is enclosed by interval arithmetic, which is coarser and decides well-definedness on a cell only where the intervals stay within[0, 1]. Cells that are not graph-preserving are analysed, not declined; there an expected reward has a finite upper bound only when every choice of corners reaches the target with probability 1. The cost grows with the number of open parameters, cells and states (exact linear solves, at most 2 000 unknowns). - Limits of this implementation: rules S-7 and S-9 are decided by enumerating the full state space, and a model with more than 200 000 states is refused; the evaluator refuses a linear system with more than 2 000 unknowns and a grid with more than 10 000 points.
cadl model-exportleaves out a transition reward whose action label no command of the design has (PRISM and Storm reject such an item) and writestrue : (0);in a reward structure that would otherwise be empty.
Strategic Model (Equilibrium Checks and Maps)
A file that declares stochastic: 0.1 and games: 0.1 may give its model: block kind: smg (Appendix I of the specification): a turn-based stochastic game on the model of Appendix H. players: declares the players, owner: on a command says who chooses it, profiles: names profiles of memoryless deterministic strategies as ordered rules {guard, choose}, compliance: names the profile the contracts ask for, payoffs: gives every player a signed weighted sum of expected rewards accumulated until a target, and equilibria: asks whether a profile is a Nash equilibrium (or an ε-equilibrium) against unilateral deviations. See examples/games_robot_delivery.cadl (a robot that may skip the handling procedure, sanctioned in proportion to λ) and examples/games_two_players.cadl (the dispatcher also chooses whether to monitor).
# Equilibrium checks at the fixed parameter values (entries of model.equilibria without over:)
cadl game-check examples/games_robot_delivery.cadl
cadl game-check examples/games_robot_delivery.cadl --equilibrium comply_nash --regime CENTRALIZED --set lambda=0.2 --format json
# Equilibrium maps (entries with over:): cells certified as equilibrium / not_equilibrium, or undecided
cadl game-check examples/games_robot_delivery.cadl --certify
cadl game-check examples/games_robot_delivery.cadl --certify --equilibrium comply_by_lambda --max-cells 500 --format json
# Start from a uniform partition and report the cells as analysed (the 16 cells of I.12)
cadl game-check examples/games_two_players.cadl --certify --equilibrium watched_map --partition 4 --no-merge
# Properties and regime maps of a strategic model are evaluated under a profile (default: compliance)
cadl model-check examples/games_robot_delivery.cadl
# The game in the model language of PRISM-games (model file only)
cadl model-export examples/games_robot_delivery.cadl --output prism_out/
- An equilibrium check reports, per design and player, the payoff under the profile, the best-response value, the deviation gain, and the canonical best response (the profile's command wherever it is optimal, otherwise the first optimal command in declaration order), as exact rational numbers; then the
status(equilibriumornot_equilibriumwith thedeviators), andfrom_every_state(whether no player gains from any state it can reach; only withequilibriumand ε = 0). The best response is computed by policy iteration with exact linear solves on the Markov decision process of one player against the others' fixed strategies; because a profile must be admissible (no single player can keep the game away from the target of its payoff), a memoryless deterministic best response is optimal among all strategies, also those with memory and randomisation (I.7). - An equilibrium map covers the region of
over:with cells.equilibriumandnot_equilibriumare claims about every valuation of a cell and are certified: on a cell, the game of each player against the profile is relaxed (every state chooses, per allowed command, a distribution at a corner of the cell; for a probability that is not multi-affine, a distribution within the range of each probability on the cell, found from Bernstein coefficients, by fixing a parameter in which the polynomial is monotone at an end, and by bisecting only the enclosure, not the cell; the range is exact unless the search is cut off after 16 bisections), and the cell is decided by the sufficient conditions N, E1 and E2 of I.9 from the exact optimal values of the relaxed processes, and by PD+ and PD−, which bound a gain through the one-step advantages Q_p(s, c) − V_p(s) of the deviating commands (the performance-difference identity, I.9); where these bounds are too wide, an advantage is bounded through the Bellman equations of the profile, which keep the dependence of the successors' values on the valuation (in an acyclic game, a polynomial when the expansion fits its limits of 16 steps, 64 monomials and degree 6), and then by running the two plays together, with the same corner of the cell in each step (coupled bounds, I.9); a probability that is not multi-affine (p * p,4 * p * (1 - p)) is written a + b · R and R becomes a new coordinate with the interval of its enclosure on the cell (probabilities with the same R share it), and the corners are those of this lifted cell. A design whose lifted cell would have more than 10 coordinates, and a bound that needs a corner whose distribution the relaxation does not allow, keep the bounds without coupling. A cell is decided only when every policy of every player's relaxed process reaches the target with probability 1 and the design is shown to be well-defined on the cell; anything else isundecided, with areason(bounds,not_admissible,not_well_defined). The largest undecided cell is bisected until the undecided fraction is at mostresolution:or a budget (--max-depth, default 24;--max-cells, default 20 000) is exhausted; cells that carry the same claim are then joined (--no-mergekeeps them as analysed). No floating-point number is used. - Exit status of
cadl game-check(I.13): 0 when every requested result was computed, whatever the answers; 1 when a map did not reach its resolution or a query was not evaluated; 2 when nothing can be claimed (a static error, a usage error, a design that is not well-defined or a profile that is not admissible at the values used).--setrechecks these conditions at the values it uses and cannot set a parameter that an evaluated map opens. Without--certifythe maps are not computed, and the output says so. cadl model-checkon a strategic model evaluates each property, and each regime map, in the Markov chain of itsprofile:(default: the compliance profile).cadl model-exportwrites one model file per design withsmgand oneplayer … endplayerconstruct per player (without actions for a player that owns no command of the design), and no properties file (I.11). The exported files were run through PRISM-games 3.2.4;tests/test_games_prism_games.pycompares its payoffs, best-response values and verdicts withcadl game-checkwhen PRISM-games is installed (CADL_PRISM_GAMES, theprismscript of a PRISM-games distribution).cadl sim-ircarries the game instochastic_model(I.13).- The link to norms (Appendix J, J.7). In a file that also declares
norms: 0.1andgrounding: 0.1, a payoff termsanction_of: "C.n"has the weight −m · ℓ and a termreward_of: "C.n"the weight m′ · ℓ, with m (m′) theon_violation.magnitude(on_fulfilment.magnitude) of the norm and ℓ the parameter bound byfrom: "C.lambda";cadl sim-irwrites the defined weight ("-2 * lambda") with the fieldssanction_ofandreward_of. Every result computed with such a term carries the assumption of J.7 ("the reward structure r is taken to count the violations of C.n"), in the text and in the JSON (assumptions).cadl checkreports, per design, the expected count of eachsanction_of:andreward_of:term under the compliance profile at the fixed values (J-12): for asanction_of:term, 0 means that compliance incurs no sanction of the term, which is condition (ii) of J.7; areward_of:term breaks condition (ii) by the sign of its weight whatever its count. Withoutgrounding: 0.1such a term is an error (I-7); a term whose weight is not defined is never read with a default weight, and its queries reportnot_evaluated(exit status 1). - End-point certification (I.9). For an equilibrium map with one open parameter ℓ that occurs in no probability and no reward value and with a power of at most one in every weight, counted on the text (the powers of the factors of a product add up, no cancellation) — condition A — a cell [a, b] that the conditions N, E1 and E2 leave undecided is
equilibriumwhen the profile is an ε-equilibrium at a and at b (exact evaluations; every gain is convex in ℓ). A player p is a deviator on it when condition B holds for p and its gain exceeds ε at the right end: B− (every term of p whose weight has a non-zero coefficient c of ℓ at the values used for the other parameters has c < 0, and its reward structure has the expected value 0 under the profile; the gain is then non-increasing, and the gain at b decides) or B+ (the same with c > 0; non-decreasing, the gain at a decides). Any strategic model may use it; J-14 of Appendix J refers to it. Such cells carrymethod: "end points (I.9)"; the map reports, per design, whether condition A holds and for which players the gain is non-increasing or non-decreasing (endpoints), or why the end points are not used. They decide only cells that the bounds leave undecided (and may add deviators to anot_equilibriumcell): every claim of the bounds is kept. No other claim follows from the end points. - Equilibrium from every reachable state.
concept: every_reachable_stateon an entry ofequilibria:asks that no player gain by deviating alone from any state of Reach_p (the states it can reach by its own deviations while the others follow the profile), not only from the initial state (concept: nash, the default). A check then also reports, per player, the largest gain from a state of Reach_p (state_gain), the first state that attains it (state), and the canonical best response from there. On a map, a cell isequilibriumby E2, by E1 at every state of the relaxed process, or from the end points; a player is a deviator by N or by N_s: a state s that is in Reach_p at every valuation of the cell (a path of transitions whose probabilities are positive on the whole cell: at every corner when multi-affine, by exact interval arithmetic otherwise) and a deviation whose payoff from s exceeds the profile's by more than ε at every valuation (deviation_states: s and a lower bound of the gain). This is weaker than subgame perfection: a threat of another player in a state that only p's deviation reaches is never tested against that player's own interest.concept: subgame_perfectandcorrelatedare reserved (I-11 information and an I-9 error). - Limits. Strategies named in a file are memoryless and deterministic; there are no mixed equilibria, no concurrent moves, and no partial observation (I.1). The conditions of a map are sufficient, not necessary: cells next to the boundary of the equilibrium region stay
undecidedhowever fine the partition; a cell on which the relaxed process of some player has a policy that never reaches the target (for example a cell that contains a valuation at which a probability becomes 0 and a cycle closes) staysundecidedalthough the profile is admissible on it; the deviation tried fornot_equilibriumis the canonical best response at the centre of the cell. A cell lists the deviators that are established for the whole cell, so a coarse cell may list fewer than its parts would. I-3 forbids a player id that is a keyword of Appendix H, but the examples of I.12 name a playerR; this processor admitsF,U,P, andRas player ids (they are renamed in the export, as H.11 says).
AI Integration
cadl ai generates CADL from natural language descriptions via Claude API:
- User provides an NL description (Japanese or English)
- Claude generates a CADL definition using few-shot examples
- The generated CADL is parsed and type-checked
- With
--verify, it also goes through the SMT and deadlock checks ofcadl verify; a check that fails counts as a validation error - On validation errors, the system retries with error feedback
Requires ANTHROPIC_API_KEY environment variable and pip install "cadl-lang[ai]".
Type Checks
The type checker (cadl check) validates:
-
Actor reference existence — Actors referenced in parties, authority, information sharing, protocol steps, and
assume:/guarantee:predicates are defined. In a predicate a name is treated as an actor when it is indexed (ROBOT[i]) or is the object of a member access (ROBOT.battery); a bare name is taken as a state variable -
Contract party consistency — Every contract has parties, and no party is listed twice
-
Protocol step validity — Senders and receivers match actor definitions
-
Information sharing coherence — Sharing declarations reference valid actors
-
Parameter range constraints —
0 <= alpha, beta, lambda <= 1 -
Unique ids and known severities — No duplicate actor, contract, protocol, or metric ids;
severity:isMinor,Major, orCritical -
Identifiers — Actor, contract, protocol, and metric ids and regime names are ASCII identifiers and are not reserved words (
AND,OR,NOT,IN,in,exists,true,false) -
Sharing entries — Each
sharing:entry is a quoted string"SOURCE -> TARGET : item"; an unquoted or malformed entry is an error, and an item with arguments is accepted with a warning -
Autonomy —
autonomy:islow,medium, orhigh -
SoS-DSL static semantics (Appendix E, E.4) — in a
lifecycle:, the initial, terminal,from,to, andon_violation.transitionstates are listed instates, and a terminal state exists and is reachable (L-1, L-2, L-3, L-5); theon_match.transitionof a monitor is a state of the same contract (M-3); states, transition ids, and monitor ids are identifiers and the ids are unique; the actors of a message event inon:are declared, and so is the object of eachobserve:entry (M-1). Adeadline:is a duration (an integer withms,s,min, orh) and asampling:iseventorperiodic(<duration>); a value that cannot be read is an error. As lenient forms, a non-negative number of seconds (2.5), a space before the unit (5 s,periodic( 500ms )), and the mapping{kind: periodic, period_ms: <integer>}are accepted. Warnings: adeadline:withouton_violation:(L-4) and anon:,when:, orrule:that is not a rule of Appendix E -
Norms static semantics (Appendix F, F.7; only when the file declares
norms: 0.1) — norm ids are identifiers, unique in the contract, and differ from the institutional events named bycreates:(N-1);kind:isobligation,permission,prohibition, orpower(N-2);bearer:andcounterparty:are declared actors without a wildcard or range (N-3);deadline:is a duration, anddeadline:andon_violation:belong to obligations and prohibitions (N-4);effects:belong to powers, which need at least one, and name other norms of the contract (N-5); areparation:is an obligation or prohibition withouttrigger:, and reparations form no cycle (N-6);on_violation.transitionis a state of the contract'slifecycle:(N-7); the actors of a message event are declared, and a power is exercised by an institutional event created from a message or by a message its bearer sends (N-9);within(d, p),throughout(d, p), anduntil(p, q, d)have a duration literald > 0and appear only inassume:,guarantee:, and a norm'scontent:(N-10);on_amendment: {transform: X}names an identifier (N-11); atrigger:,until:,content:,when:,if:or delegationuntil:that is not a message event or an institutional event is a predicate of A.10 that the engine can evaluate: no fractional duration (2.5s; write2500ms), no single-quoted string ('k'; write"k"), no function other than the aggregates of a comprehension and the temporal operators, a quantifier, comprehension, wildcard, range or index variable over a set declared asA[lo..hi](not over an undeclared name or a single actor), an aggregate argument over one set, no+,-,*,/on a text or a truth value and no division by the literal 0, numbers in the exact range, and the message of a message event is a name or a call with arguments that can be evaluated (N-16; from 0.3.30, which reported a text that is not a predicate as a warning, "kept as text", and the rest not at all, so the norm was never judged).cadl norms-eval, the monitors andnorms-checkrefuse such a norm when they are given a file that was not checked. Warnings: a norm id used as a wholetrigger:/until:/content:(N-8), a permission and a prohibition with the same bearer and content (N-12), a prohibition whose message trigger is also an occurrence of its message content, which violates it when it activates it, also through a counts_as event (N-13, best effort), a quantifier or comprehension variable named like a symbolic bound (N-14), a wildcard or range reference whose reading may surprise: underNOT, two sets in one comparison, one set in both operands ofOR, an aggregate over two sets in anassume:orguarantee:item (N-15), a bearer or counterparty that is not a party (N-3), and an obligation or prohibition whose message is not sent by its bearer (N-9). Without the declaration,norms:andcounts_as:get one warning as undeclared extension keys and are neither checked nor lowered to the IR -
Stochastic model static semantics (Appendix H, H.10; only when the file declares
stochastic: 0.1) —model:hasvariables:andcommands:, andkind:isdtmc(S-1); ids, label names, enumeration literals, and action labels are identifiers, are no keywords, and are declared once in their namespace, a label is not namedinitordeadlock, and the exported namesx_Lof enumeration literals are distinct from every declared name and from each other (S-2);from:namesalpha,beta, orlambdaof a declared contract or a numeric entry ofcontext.environment(S-3);range:is[lo, hi], required except for a parameter bound to a contract, and every value lies in it (S-4); a variable isbool,"[lo..hi]", or"{A, B}"with aninit:of its domain (S-5); every state predicate conforms to the grammar and is well typed (S-6); an update assigns declared variables values of their type that stay in the domain wherever the guard is true (S-7); probabilities are numbers, expressions over parameters, orrest, at most onerestper command, and they sum to exactly 1 (S-8); at most one command is enabled in any state of any design (S-9);model.regimes:andwhen:name regimes of the file, and needtransitions:(S-10); every parameter has a fixed value under every design, where probabilities lie in[0, 1]and rewards are not negative (S-11); a reward structure has items whoseaction:labels a command and whosevalue:mentions no parameter opened by a regime map (S-12); a property conforms to the property grammar, withRonly overFwithout a step bound and thresholds in range (S-13); a regime map has one to four open parameters, at least two regimes, one objective that is a query, a threshold constraint, a resolution in(0, 1), and designs that are well-defined at the corner points of its region (S-14). S-7 and S-9 enumerate the state space (at most 200 000 states). Warnings: two parameters with the same source (S-3) and a regime without an entry inmodel.regimes:(S-10). Informational: the keys and values reserved for a later version (S-15). Without the declaration,model:gets one warning as an undeclared extension key and is not checked, lowered to the IR, or exported -
Agent governance static semantics (Appendix G, G.9; only when the file declares
agents: 0.1) — the file also declaresnorms: 0.1(G-1);agent:has akind:ofllm_agent,tool_server,human, orserviceand aprotocol:that is a name (G-2);tools:belongs to a tool server, which lists at least one, and tool names are unique identifiers (G-3); a message event whose receiver is a tool server names one of its tools (G-4; a warning for a protocol step);enforcement.defaultisdenyorallowandenforcement.pointiscaller,receiver, orgateway(G-5); in an enforced contract the sender of the message content of a permission or prohibition is its bearer (G-6);on_denied:belongs to a prohibition with a message content in an enforced contract, has at least one key, and itstimeout:is a duration greater than zero that requiresescalate_to:(G-7);escalate_to:andnotify:name single declared actors, andescalate_to:names a party other than the bearer (G-8); a contract withescalate_to: Ahas acounts_as:rule that createsapprovalfrom a message ofA, andapprovalandrejectionare reserved in an enforced contract (G-9); afallback:is a message event of the bearer to a declared actor that differs from the prohibited message (G-10);delegations:belongs to an enforced contract, and each entry names one permission with a message content whose bearer has no bound index (G-11), lists declared actors other than tool servers underto:, and has amax_depth:of at least 1 (G-12);grant:andrevoke:are identifiers that differ from each other, fromapprovalandrejection, and from the tools of the parties (G-13); in an enforced contract the sender and the receiver of every message event (trigger:,until:andcontent:of a norm,when:of acounts_as:rule,until:of a delegation) are covered by one reference in the parties, because the contract observes only the messages it governs, and name only declared members (G-17), and every index variable of the contract (in bearers, counterparties,escalate_to:,notify:,fallback:, the senders, receivers and arguments of its message events, and its predicates, also inside an index expression such asROBOT[j+1]) is bound: by a party (ifor a partyROBOT[i]), by a quantifier, or by a comprehension (G-18). Warnings: an institutional event created under anif:that is the trigger of a prohibition or theuntil:of a permission (G-19),escalate_to:withouttimeout:(G-7), an approver that is nothuman(G-8), no rule forrejection(G-9), the bearer listed underto:(G-12), a permission or prohibition whose content is not a message event or has arguments (G-14), tools left open bydefault: allowand a tool server that is a party of no enforced contract (G-15), and a message the contract needs but would itself deny (G-16). Without the declaration,agent:,enforcement:,delegations:, andon_denied:get one warning as undeclared extension keys and are neither checked nor lowered to the IR -
Strategic model static semantics (Appendix I, I.10; only when the file declares
games: 0.1) — the file also declaresstochastic: 0.1(I-1);kind:isdtmcorsmg, a model withkind: smghasplayers:,profiles:,compliance:, andpayoffs:, and any other model has none of the keys of the extension (I-2); player ids are unique identifiers and every player lists declared actors, none of which stands behind two players (I-3);owner:names a player, an owned command has an action label, and the commands with one label have one owner or none (I-4); in every state of every design the enabled commands are at most one, or all belong to one player and have different labels (I-5, which replaces S-9); profile names are unique identifiers, a rule chooses the label of an owned command under a guard without labels, every profile selects a command wherever two or more are enabled, andcompliance:names a profile (I-6); every player has exactly one payoff, with a boolean target, at least one term, declared reward structures used at most once, and weights over declared parameters; a term withsanction_of:orreward_of:needsgrounding: 0.1(I-7); every profile is admissible in every design at the fixed values (I-8); an entry ofequilibria:has an id that is unique among properties and regime maps, a profile, designs, anepsilon:that is not negative, and, for a map, one to four open parameters within their ranges that no regime assigns and no reward value mentions, aresolution:in(0, 1), designs that are well-defined at the corners of the region, and a profile that is admissible at the centre of every face of the region (I-9);profile:of a property or regime map names a profile (I-10). I-5 and I-6 are decided by enumerating the state space, I-8 and I-9 on the reachable game. Warnings: a profile rule that is the first applicable rule in no state (I-6); a payoff whose target holds in the initial state (I-7). Informational: reserved keys and values (I-11); the keys of the extension in a file that does not declaregames: 0.1, which is then read by Appendix H (I.15). A file that declaresgames: 0.1withoutstochastic: 0.1gets the error of I-1 -
Grounding static semantics (Appendix J, J.8; only when the file declares
grounding: 0.1) — the file also declaresnorms: 0.1(J-1); the keys ofgrounding.itemsare identifiers, not reserved words, and their values actor references to a party of the contract, andtolerance:is a number in[0, 1](J-2);shares:belongs to an obligation or a permission whose content is a message event and lists at least one declared item, each once (J-3); a magnitude is a finite number that is not negative, andon_fulfilment:belongs to an obligation or a prohibition and has areward:(a text) or amagnitude:(J-4). Warnings, never errors: a sharing norm that gives an item to its origin, a target that is not a party or is the bare name of an actor set, a sharing entry with an undeclared item, and a sharing entry with more than one item or with arguments, which gives no pair (J-3); a magnitude of zero next to a sanction or reward text (J-4);alpha: 0with a given pair or, when the index is undefined, with a sharing entry,alpha: 1with a pair that is not given,beta: 1with a power that the single actor with the most powers does not bear,beta: 0with a single actor that bears more than an even share (J-6); a declaredalphaorbetaother than 0 and 1 farther from its index than the tolerance, and a decision holder with fewer powers than another actor (J-7); for a contract with norms,lambdagreater than zero while no obligation or prohibition carries a sanction or a reward, andlambda: 0while one does (J-8). Informational, in a file that also declaresstochastic: 0.1: a design in which a parameter bound toC.alphaorC.betais farther from the index than the tolerance, unless J-6 or J-7 already reports the same declared value (J-9). The comparisons are exact (decimals as written, ratios as fractions). Without the declaration,grounding:,shares:,on_fulfilment:andon_violation.magnitudeget one warning as undeclared extension keys, are not interpreted, and no index is computed (J.12). In a strategic model (Appendix I): a term has at most one ofweight:,sanction_of:,reward_of:; the reference names an obligation or a prohibition of a declared contract with a magnitude greater than zero for the key; the model has exactly one parameter bound toC.lambda; a player that stands for the bearer of the norm owns the payoff (an actor reference that covers the bearer); and a norm is named at most once per key (J-10, errors). Warnings: a norm of a linked contract with a magnitude, a bearer that a player stands for, and no term that names it; a written weight with the parameter bound toC.lambda(J-11). Informational: the expected count of eachsanction_of:andreward_of:term under the compliance profile, per design (J-12). J-14 is used bycadl game-check --certify -
Regime bindings (Appendix A, A.7.1; from
cadl0.3.32) — the keys ofregimes:are regimes oftransitions:(R-1); an entry has onlyparameters:andcontracts:(R-2); a parameter isC.alpha,C.betaorC.lambdaof a declared contract that writes it, orenvironment.Xof an entry ofcontext.environment(R-3); an institutional value is a number in[0, 1]and an environment value has the type of the entry (boolean, integer, number or string) (R-4);contracts:gives one ofactive:andsuspended:, which list declared contracts once (R-5); a regime binds a parameter once and binds no parameter of a contract it suspends (R-6); withstochastic: 0.1,model.regimes:gives a parameter bound to the same source the same value (R-7) -
Amendment static semantics (Appendix K, K.6; only when the file declares
amendment: 0.1) — the file givessos.version(K-2);effective:has one ofperiod:(a positive integer) andat:(an ISO 8601 date or date-time) (K-3); a transitional rule names a contract of the file,keeporswitch, andin_states:only non-terminal states of its lifecycle (K-4); decision ids are unique identifiers with a URI reference (K-5);decided_by:names an actor or a role of the model andvoters:actors, andprocedure: votehas aquorum:(K-6); a parameter has a layer (rule,contract,regulation) and a number or duration value (K-7) withinmin–maxand on the steps frommin(K-8); each location ofat:exists and holds the value or the name of the parameter, and two parameters with the same value at the same place are warned about (K-9);decision:names a declared decision (K-10); aschedule:has entries of one form offrom:in order (K-11);measure:has positive durations, an aggregate from the list, andevery:no longer thanwindow:(K-12). Keys of the extension in a file that does not declare it get one warning (K-13).
It also reports, without failing the check, a codegen: target that cadl codegen cannot emit (warning), an extension name it does not know, and a motivation: block, which it keeps and passes on in cadl sim-ir but does not interpret (informational).
Hands-on
A self-contained textbook, followed in about 95 minutes on your own or as a 5-session class, walks you through the complete CADL toolchain end-to-end on a robot delivery System of Systems: CADL modelling → SoS-DSL contracts (lifecycle + monitors) → visualisation → code generation → live simulation.
The hands-on materials include:
- Textbook (Course A) — eleven chapters and four appendices in English and Japanese: the SoS background and the essentials of CADL, then six 15-minute procedures using a runnable end-to-end script (
scripts/sos_dsl_handson_e2e.sh). Chapters 4–9 end with graded ★ / ★★ / ★★★ exercises for a 5-session class (a compact 3-session plan and a rubric are in Appendix C). - Further courses — Course B (urban mobility with SUMO), Course D (a town that amends its own rules) and Course C (your own SoS).
- Academic background — Maier's five SoS criteria, the ISO/IEC/IEEE 21839 / 21840 / 21841 standards, related research (ADLs, Normative MAS, Runtime Verification), and an annotated bibliography.
| Audience | Entry point |
|---|---|
| Self-learner — quick tour | Textbook — Course A: Robot Delivery (EN) / JA |
| Student in a class | Textbook, Appendix C — Using this textbook in a class (EN) / JA |
| Researcher needing citations | Why SoS-DSL? (academic background) (EN) / JA |
The materials are hosted in the cadl-spec repository — English sources under docs/handson/, Japanese under i18n/ja/docusaurus-plugin-content-docs/current/handson/ — and rendered on the Hands-on section of the spec website.
To run the full pipeline locally on the bundled robot-delivery example:
./scripts/sos_dsl_handson_e2e.sh
This generates the IR JSON, the Unity C# tree, and drops the latter into the Unity project of cadl-raspimouse-simulator when it is cloned next to this repository (otherwise pass --unity "" to stop after code generation). See the hands-on textbook for the rest of the walkthrough.
Examples
CADL Definitions
| File | Description | SoS Type | Key Features |
|---|---|---|---|
robot_delivery.cadl |
Autonomous delivery fleet | Acknowledged | Route coordination, failure replanning, 2 regimes |
smart_city_traffic.cadl |
Traffic signal management | Collaborative | 3 regimes (NORMAL/CONGESTED/EMERGENCY), emergency override |
supply_chain.cadl |
Manufacturing supply chain | Collaborative | 4-actor chain, quality recall protocol, 4 regimes |
iot_data_sharing.cadl |
IoT sensor aggregation | Virtual | Data freshness contracts, privacy policy, anomaly detection |
household_chores.cadl |
Family chore sharing | Collaborative | Human-centric, monetary incentives, dispute resolution |
a_sos_robot_delivery.cadl |
MAPF robot delivery (A-SoS) | Acknowledged | Central ECBS planner, 3 regimes, fleet safety |
c_sos_taxi_fleet.cadl |
Autonomous taxi fleet (C-SoS) | Collaborative | Decentralized LRA*, peer conflict resolution, 3 regimes |
raspimouse_d_sos.cadl |
Raspimouse swarm (D-SoS) | Directed | Centralized arbitration via NATS, NaiveDijkstra, beta=0.9 |
raspimouse_c_sos.cadl |
Raspimouse swarm (C-SoS) | Collaborative | Local DirectionDijkstra + central verification, discrete-time sync |
raspimouse_mcp_sos.cadl |
Raspimouse swarm (MCP-SoS) | Acknowledged | LLM-controlled via MCP tools, Static/Dynamic path modes, 3 regimes |
sos_dsl_robot_delivery.cadl |
Robot delivery with the SoS-DSL extension | Acknowledged | Contract lifecycle (7 states), 3 monitors; the example used by the hands-on course |
agents_tool_governance.cadl |
LLM planner, sub-agent and two tool servers (agents 0.1) | — | Enforced contract, escalation to a human, delegation with provenance; sample inputs in agents_inputs/, traces for cadl agents-run in traces/ |
grounding_robot_delivery.cadl |
Robot delivery with norms and the grounding extension (grounding 0.1) | Acknowledged | The example of Appendix J, J.9: information items, shares:, a sanction magnitude; indices 5/8, 1/2 and coverage 1/3 with cadl norms-indices |
amendment_robot_town_v1.cadl, amendment_robot_town_v2.cadl |
The robot town of the Course D hands-on, two versions of its rules (amendment 0.1) | Collaborative | Amendable parameters by layer, decided by a council vote or by the operator; transitional rules; a KPI measured over five runs with a target by period; cadl amend-diff shows block_k 3 → 2 |
agents_change_control.cadl |
Owner, lead agent, two workers and a repository (agents 0.1) | — | A prohibition in force between a trigger and an until:, delegation with max_depth: 1 and until:; traces for cadl agents-run in traces/ |
Demo Scripts
Run the demo scripts to see the full toolchain in action:
# End-to-end workflow: parse -> verify -> codegen (Python/Solidity/Rego) -> regime map -> IEC 62853
python examples/demo_robot_delivery.py
# Regime transitions, dependability summary, and multi-target generation
python examples/demo_smart_city.py
# Side-by-side comparison of Python, Solidity, and Rego output
python examples/demo_codegen_targets.py
# 3-layer simulator IR and A-SoS / C-SoS comparison
python examples/demo_sim_ir.py
Project Structure
src/cadl/
__init__.py Package root
ast_nodes.py AST node definitions (30+ dataclasses)
grammar.lark Lark grammar for the expression sub-language
parser.py Hybrid parser (YAML structure + Lark expressions)
type_checker.py Static semantic checks
verifier.py SMT-based contract verification (Z3)
deadlock.py Protocol deadlock detection
regime_map.py Regime transition graph analysis
iec62853.py IEC 62853-oriented dependability summary
unparse.py Expression AST back to CADL source text
norms_eval.py Verdicts of the norms extension on a recorded trace
norms_check.py Design-time checking of norms: translation to PRISM, questions, witnesses
agents_runtime.py Runtime of the agent governance extension: decisions, holds, delegations and audit records on a trace, offline or one line at a time
audit_log.py Hash chain of the audit log (SHA-256 or HMAC-SHA256) and its verification (`cadl audit-verify`)
gateway_core.py What the gateways share: enforcement point, trace, audit log, holds, inbox, `mcp-approve`, `mcp-message`
mcp_gateway.py MCP stdio gateway that decides tool calls with the runtime (`cadl mcp-gateway`, `mcp-approve`, `mcp-message`)
a2a_gateway.py A2A gateway (JSON-RPC and HTTP+JSON) that decides SendMessage with the runtime (`cadl a2a-gateway`)
a2a_rest.py HTTP+JSON binding of A2A for the gateway: routes, errors, translation to and from JSON-RPC
a2a_push.py Push notifications of the A2A gateway: allowlist, address checks, delivery
a2a_grpc.py gRPC binding of the A2A gateway (extra cadl-lang[grpc])
a2a_grpc_front.py Front listener of the gRPC binding: caps on connections, deadline to the first call, splice
norms_diff.py Effect of an amendment on the norms (two versions compared)
grounding.py Grounding extension: derived indices, rules J-1 to J-9 and J-13
amendment.py Amendment extension: rules K-1 to K-13, IR, comparison of two versions
cli.py Command-line interface
codegen/
__init__.py Public generate() API (multi-target dispatch)
runtime_support.py Base classes for generated code
expr_compiler.py Expression AST -> Python source
emitter.py Code emission utilities
actor_gen.py Actor class generation
contract_gen.py Contract monitor generation
protocol_gen.py Protocol state machine generation
transition_gen.py Regime controller generation
metric_gen.py Metrics collector generation
runtime_gen.py Orchestrator generation
norms_monitor_gen.py Norms monitor generation (norms_monitor.py of the Python target)
norms_monitor_template.py Text copied into the generated norms monitor (not imported)
norms_ir.py The norms of a contract as data, for the OPA and Solidity monitors
solidity/
solidity_expr.py Expression AST -> Solidity source
solidity_gen.py Solidity smart contract generation
norms_monitor_sol.py Norms monitor of the Solidity target
norms_monitor_base.sol Its base contract and libraries (copied verbatim)
opa/
rego_expr.py Expression AST -> Rego source
rego_gen.py OPA/Rego policy generation
norms_monitor_rego.py Norms monitor of the OPA target
norms_monitor_lib.rego Its step function (copied verbatim)
agent_policy/
rego_gen.py Boundary policy as Rego (agents 0.1)
cedar_gen.py Boundary policy as Cedar, with the side table (agents 0.1)
unity_csharp/
contract_emitter.py Per-contract C# (state enum, contract, monitors)
runtime_template.py C# runtime support emitted with every generation
safety.py Input checks applied before code generation
ai/
__init__.py Public generate_cadl() API
prompts.py System prompts and few-shot examples
llm_client.py Claude API client wrapper
nl_to_cadl.py NL-to-CADL generation pipeline
sim/
__init__.py Public API: lower_to_ir, validate_ir, generate_config
ir.py 3-layer IR dataclasses (SimIR, InstitutionLayer, etc.)
lower.py AST -> IR lowering
validate.py IR-level validation
gen_python.py IR -> Python simulator YAML config
gen_unity.py IR -> Unity JSON config
gen_go.py IR -> Go JSON config
tests/
test_parser.py Parser tests
test_type_checker.py Type checker tests
test_verifier.py SMT verifier tests
test_deadlock.py Deadlock detector tests
test_codegen.py Python code generation tests
test_ai.py AI integration tests
test_runtime.py Runtime base class tests
test_regime_map.py Regime map graph analysis tests
test_solidity_gen.py Solidity code generation tests
test_opa_gen.py OPA/Rego code generation tests
test_iec62853.py IEC 62853-oriented summary tests
test_sim_ir.py Simulator IR lowering and validation tests
test_sim_gen.py Simulator config generator tests
test_sim_ir_sos_dsl.py SoS-DSL lifecycle / monitors in the simulator IR
test_sos_dsl_extension.py SoS-DSL parser tests
test_unity_csharp_codegen.py Unity C# generation tests
test_unity_csharp_structural.py Structural checks on the generated C#
test_expr_parser.py Expression grammar tests
test_unparse.py Expression round-trip tests
test_norms_eval.py Norm verdicts on a trace (`cadl norms-eval`)
test_norms_check.py Design-time checking of norms, differential tests (`cadl norms-check`)
test_norms_amend_diff.py Amendments: `cadl norms-diff` against `cadl norms-eval` on random pairs of versions, with mutation checks
norms_amend_diff.py Pairs of versions and traces for test_norms_amend_diff.py
test_grounding_extension.py Grounding extension: indices, rules, IR, `cadl norms-indices`
test_grounding_sos.py Grounding extension: the quantities of the SoS over all contracts
test_norms_wildcards.py Wildcard and range references in predicates (F.5): rewriting, equivalence with the quantified forms, N-15
test_norms_monitor.py Generated norms monitor against `cadl norms-eval` (examples, recorded and random traces)
norms_monitor_cases.py pytest plugin that records the cases of test_norms_eval.py for it
test_norms_monitor_targets.py Norms monitors of the OPA and Solidity targets against `cadl norms-eval`
norms_targets_support.py Its reference, OPA driver and EVM conversion
norms_evm_driver.py Runs the Solidity monitor on an EVM (separate Python, no cadl)
conftest.py The cases of test_norms_eval.py, recorded once per session
test_name_resolution.py Actor vs state-variable resolution in generated code
test_method_dispatch.py Verification method dispatch tests
test_codegen_safety.py Code generation input-safety tests
test_examples_verify.py Every example passes `cadl verify`
test_actor_reference_check.py Which names `cadl check` treats as actors
test_conformance_checks.py Identifier rules, sharing entries, codegen targets, extensions
test_codegen_deterministic.py Generated code is identical across runs
test_keyword_boundaries.py Keywords are not split out of longer names
test_agents_extension.py Agent governance extension: G-1 to G-19, decisions, agent-rego / agent-cedar
test_agent_policy_diff.py agent-cedar with the cedar CLI and agent-rego with OPA against `cadl agents-decide` on one input space (G.10, G.13)
agent_policy_diff.py Inputs, random files and the rule of G.10 for test_agent_policy_diff.py
test_agents_runtime.py Runtime of the agent governance extension (`cadl agents-run`): holds, delegations, audit records
test_audit_log.py Hash chain of the audit log: every single-byte change, deletion, insertion, reordering, keyed and unkeyed (`cadl audit-verify`)
test_mcp_gateway.py MCP gateway with a fake server and client: scenarios replayed through `cadl agents-run`, malformed input, crashes, concurrency
mcp_fake_server.py Fake MCP server (stdio) for test_mcp_gateway.py
test_a2a_gateway.py A2A gateway with a fake agent and client: scenarios replayed through `cadl agents-run`, authentication, malformed input, task isolation
a2a_fake_agent.py Fake A2A agent (JSON-RPC and HTTP+JSON, push notifications) for the A2A gateway tests
test_a2a_bindings.py A2A gateway: mutual TLS, HTTP+JSON, push notifications and their SSRF checks, gRPC
a2a_certs.py Test CA and certificates (openssl) for test_a2a_bindings.py
test_a2a_grpc_front.py Front listener of the gRPC binding: connection floods, slow and silent handshakes, half-open connections, the client address
test_sdk_interop.py The gateways against the official MCP and A2A SDKs (skipped without them)
sdk_mcp_server.py MCP server of the mcp SDK for test_sdk_interop.py
sdk_a2a_agent.py A2A agent of a2a-sdk for test_sdk_interop.py
examples/
robot_delivery.cadl Robot delivery SoS (Acknowledged type)
smart_city_traffic.cadl Smart city traffic management (Collaborative type)
supply_chain.cadl Supply chain management (Collaborative type)
iot_data_sharing.cadl IoT data sharing (Virtual type)
household_chores.cadl Family chore sharing (Collaborative type)
demo_robot_delivery.py End-to-end workflow demo
demo_smart_city.py Regime map & IEC 62853 demo
demo_codegen_targets.py Multi-target code generation demo
a_sos_robot_delivery.cadl A-SoS MAPF robot delivery sample
c_sos_taxi_fleet.cadl C-SoS autonomous taxi fleet sample
raspimouse_d_sos.cadl Raspimouse swarm D-SoS (Directed)
raspimouse_c_sos.cadl Raspimouse swarm C-SoS (Collaborative)
raspimouse_mcp_sos.cadl Raspimouse swarm MCP-SoS (LLM-controlled)
test_raspimouse.sh Parse, validate, and generate Unity configs for Raspimouse
sos_dsl_robot_delivery.cadl Robot delivery with SoS-DSL lifecycle and monitors
demo_sim_ir.py 3-layer simulator IR and A-SoS / C-SoS comparison demo
scripts/
sos_dsl_handson_e2e.sh Hands-on pipeline: check -> Sim-IR -> Unity C# -> Unity project
Status
CADL is alpha software (see CHANGELOG.md); the language and the generated output may change between releases.
| Feature | Status |
|---|---|
| Core language, parser, type checker | Available |
| Verification (SMT-based consistency, deadlock detection) | Available |
| Python runtime code generation | Available |
| Natural language to CADL via Claude API | Available |
| Regime transitions and regime map | Available |
| IEC 62853 report, Solidity and OPA/Rego generation | Available |
| Simulator IR and config generation (Python, Unity, Go) | Available |
SoS-DSL extension (lifecycle: / monitors:) and Unity C# generation |
Available |
Norms extension: static checks, and verdicts and amendments on a recorded trace (cadl norms-eval, cadl norms-diff) |
Available |
Norms extension: online monitor in the generated Python package (norms_monitor.py) |
Available |
| Norms extension: monitors in generated Rego (step function) and Solidity | Available without quantifiers, aggregates, wildcard references and amendments (refused at generation, with a warning); Unity C# does not monitor norms |
Norms extension: design-time checking of one contract instance with PRISM (cadl norms-check) |
Available (groups of compared quantities beyond 50,000 states of the elimination, or --max-states up to 1,000,000, are refused) |
Grounding extension (grounding 0.1), norms side: derived indices and incentive coverage (cadl norms-indices), rules J-1 to J-9, IR, comparison of two versions (J-13 in cadl norms-diff) |
Available |
Amendment extension (amendment 0.1): amendable parameters with layer, deciding actor, range and steps; version, effective time and transitional rule; measured and scheduled metrics; decision records (rules K-1 to K-13, IR, cadl amend-diff) |
Available (declarations; no runtime applies the versions) |
Strategic model extension (games 0.1): equilibrium checks and certified equilibrium maps (cadl game-check), with the link to norms of Appendix J (sanction_of: / reward_of:, J-10 to J-12, J-14) |
Available (the export is compared with PRISM-games 3.2.4) |
Agent governance extension (agents 0.1): checks, decision function, runtime on a recorded trace (holds, delegations, hash-chained audit records; cadl agents-run, cadl audit-verify), MCP stdio gateway (cadl mcp-gateway), A2A gateway over JSON-RPC, HTTP+JSON and gRPC (cadl a2a-gateway), Rego / Cedar boundary policies |
Available (the gateways are references, tested with fake servers, agents and clients and with the official MCP and A2A SDKs) |
model_check / simulation / proof verification methods |
Not supported yet (reported explicitly) |
Related Projects
- cadl-spec — The specification and the hands-on course, published at https://www.ertl.jp/cadl-spec/.
- cadl-explorer — A Streamlit application that draws the contract lifecycle from the IR that
cadl sim-irproduces and explores governance settings on a synthetic model. - cadl-raspimouse-simulator — The simulator used by the hands-on course: Unity project, Go arbitrator and Python reference runtime for the C-SoS robot-delivery scenario.
- raspimouse-swarm-simulator (research repository, not public; public export: cadl-raspimouse-simulator) — Multi-agent swarm robotics simulation platform. CADL files in
examples/raspimouse_*.cadldescribe its three SoS modes, and the Unity config generator produces configuration JSON for the simulator.
References
- Benveniste et al., "Contracts for System Design," Foundations and Trends in EDA, 2018.
- ISO/IEC/IEEE 21841:2019, Taxonomy of Systems of Systems.
- Saoud et al., "Assume-guarantee contracts for continuous-time systems," Automatica, 2021.
- IEC 62853:2018, Open Systems Dependability.
- C. Shimoyama and Y. Matsubara, "Governance as a Structural Design Variable: An Empirical Study of Performance-Autonomy Value Spaces in Systems of Systems," in Proc. 21st International Conference on System of Systems Engineering (SoSE), 2026.
License
Apache License 2.0. Releases up to and including 0.3.2 were published under the MIT License.
Metadata
Release files for cadl-lang 0.3.32
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cadl_lang-0.3.32.tar.gz | 1.3 MB | With provenance | Details for cadl_lang-0.3.32.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cadl_lang-0.3.32-py3-none-any.whl | Python 3 | none | any | Details for cadl_lang-0.3.32-py3-none-any.whl |
Total release size: 2.0 MB
Release files / cadl_lang-0.3.32.tar.gz
| Download URL | cadl_lang-0.3.32.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e68931107c51d0962c39bbb46d6a5745f67118a06a98f0a4e954f63d4bcce804
|
|
BLAKE2b-256 checksum How to use checksums |
820deecfccbad98c8ef156099483d98527e9171b54cd6c78cf80af18e6ca13ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / cadl_lang-0.3.32-py3-none-any.whl
| Download URL | cadl_lang-0.3.32-py3-none-any.whl |
|---|---|
| Size | 676.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
274bc7c15c493caeb7d2c7ea84de6805f4f72360b5bccf36c72d10b3f34f0b17
|
|
BLAKE2b-256 checksum How to use checksums |
9659152723bcb8f3c5ae91ea902dc97ea5ff54222a01fbb8fee0d64db2d46d1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for cadl-lang 0.3.32
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cadl_lang-0.3.32.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.