Cross-object invariants
The rules a complete record of one contract revision must satisfy beyond each object's shape, with the exact checks, error codes and paths, and what they leave unchecked.
Each object can be valid on its own and the work can still be wrong: an approval for another revision, an action in another client’s workspace, a cost over the limit, an acceptance before the work finished. This section defines thirteen invariants over a complete record, plus one rule about time. They are what turns five valid objects into evidence that can be checked.
9.1 The record and who checks it
A record is the complete set of objects for one revision of a work contract: exactly one revision of the contract, and any number of context manifests, authority bindings, execution receipts and evaluation results that serve it. A record may hold several revisions of one manifest, binding or evaluation. It never holds the same object twice, where the same object means the same type, id and revision.
A record is checked as a closed world: it is assumed complete, so a reference that does not resolve inside it is an error. An envelope, by contrast, assumes an open world (section 8.1).
Checking a record takes these inputs besides the objects:
| Input | Meaning |
|---|---|
| The current time | Used only to reject records that describe the future (9.15). |
| The assurance level | essential, controlled or assured (section 13); essential when not given. Separation of duties (9.6) and the rules of 9.16 apply at controlled and assured. |
| The separation-of-duties threshold | Money, optional: the checking party’s own. A binding’s policy applies instead only where it is lower (section 5.7). Without a threshold, every grant needs an approver other than the requester. |
| The live revocation status | The revoked binding and approval identifiers, each with the time it was revoked, fetched where each binding’s revocation points. |
| The supported extensions | Extensions the checking party supports, beyond the core pap extension. |
A check proceeds in this order:
- The record, one JSON document, passes decoding (section 2.1) and is an array; otherwise the decoding error, or
schema_violationat"". - Every object is valid on its own (section 8.2), with its errors reported under
/<i>, its index in the record. If any object is invalid, the check stops there. - The record holds exactly one work contract: none is a
schema_violationat"", and every contract after the first is aschema_violationat/<i>/type. If not exactly one, the check stops there. - No object appears twice; a repetition is a
schema_violationat/<i>/id, and the check stops there. - The invariants of 9.2 to 9.15, and the rules of the level (9.16), are checked, and all of their errors are reported together. Each invariant applies on its own: a stop inside an invariant, such as “nothing else is checked for this effect” or “the approvals are not examined”, ends that invariant’s checks for that object or effect only, and the other invariants still apply.
A check that stopped at steps 1 to 4 has not checked any invariant, so its errors say nothing about the invariants; the reference implementation marks such a result (stopped: "shape"). An Enforcement point MUST refuse every action over a record that fails steps 1 to 4, whichever object fails them.
The reference implementation treats a current time that is not a UTC timestamp, or a threshold that is not valid money, as a mistake by the caller: it throws instead of reporting an error about the record.
Time-dependent invariants are checked at each action’s own start time, never at the current time. A record of past work stays valid when it is checked again later.
Who checks. A Consumer that verifies a record MUST apply every rule of this section. An Enforcement point MUST NOT start an effect that would make its record break 9.4 to 9.11, or the rules 9.16 adds at its level: it applies those rules before each action, as section 11.1 describes, rather than discovering the breach afterwards. It MUST refuse every action over a record that already breaks 9.15, or a rule 9.16 adds at its level, wherever in the record the break lies, as it does over a record that fails steps 1 to 4; the one exception is the rule that only verified approvals authorize an effect, which bears on the action it would authorize. An Evaluator MUST NOT issue an evaluation that breaks 9.12 or 9.13, and a Producer of receipts MUST NOT issue a chain that breaks 9.14.
An effect, in this section, is a receipt whose decision is permit and whose outcome is not replayed.
9.2 Invariant 1: references resolve
- The
contractof every manifest, binding, receipt and evaluation names the record’s contract. Anotheridisreference_unresolvedat/<i>/contract. - A receipt’s
authorityandcontext, and a binding’sdelegation.parent, resolve to an object in the record with thatidandrevision. If theidis present only at another revision, it isrevision_mismatch; if it is absent, it isreference_unresolved. Either is reported at the reference. - Every receipt an evaluation cites is in the record (
reference_unresolvedat/<i>/receipts/<j>) and has the cited digest (digest_mismatchat the same path).
9.3 Invariant 2: revisions match
- The
contractof every manifest, binding, receipt and evaluation names the record’s contract revision. Another revision isrevision_mismatchat/<i>/contract. - The binding and the manifest a receipt cites serve the same contract revision as the receipt. Otherwise it is
revision_mismatchat/<i>/authorityor/<i>/context.
9.4 Invariant 3: tenant boundaries hold
The tenant boundary is the organization plus the workspace (section 2.10). The record’s allowed scopes are the contract’s scope and the resource scope of every grant, in any binding of the record, that names the contract’s organization and has approved, unrevoked authority behind it: its binding holds approvals that are current, approve, are in scope and count for that grant, by approver and by role (section 5.4), that are not PAP confirmations, and that were not revoked, nor was the binding or any binding it was delegated from, when they were decided; and those approvals come from at least as many distinct people as the grant’s conditions.min_approvals, or from one when it states none. A later revocation stops new effects, but does not shrink the boundary of work already recorded. Each allowed scope is reduced to its organization and workspace; projects do not count. A scope is inside the boundary when it lies within at least one allowed scope.
- The
scopeof every manifest, binding, receipt and evaluation is inside the boundary; otherwisetenant_mismatchat/<i>/scope. - Every grant’s resource scope names the contract’s organization; otherwise
tenant_mismatchat/<i>/grants/<k>/resource/scope. A grant can never reach another organization. - An effect uses only context its own authority reaches: every item of the manifest an effect cites lies within the contract’s scope or the resource scope of a grant of the effect’s own binding that has approved authority behind it, as above, each reduced to its organization and workspace; otherwise
context_out_of_scopeat the effect’s/<i>/context. Another agent’s grant does not let this effect read a workspace, and neither does a grant of its own binding that lacks the approvals it needs. An effect whose binding is not in the record reaches the contract’s scope alone. - Every item of a manifest that no effect cites is inside the boundary; otherwise
context_out_of_scopeat/<i>/items/<k>/scope. - The resource scope of every receipt whose decision is
permitis inside the boundary; otherwisetenant_mismatchat/<i>/action/resource/scope.
A receipt whose decision is deny may name any scope. An attempt on another tenant that was refused is a valid record, and a useful one.
A grant that names another workspace of the same organization extends the boundary to that workspace, and a grant that names no workspace extends it to the whole organization, once approved authority stands behind it. Every such extension is therefore visible in a binding, next to the approvals that make it count, and a binding nobody approved extends nothing.
9.5 Invariant 4: approvals bind the revision and the binding
For every approval in every binding, whether it approves or denies:
covers.contractnames the record’s contractidand revision; otherwiseapproval_staleat/<i>/approvals/<k>/covers/contract.covers.binding_digestequals that binding’s digest (section 5.3); otherwiseapproval_staleat/<i>/approvals/<k>/covers/binding_digest.
An approval that passes both checks is current.
9.6 Invariant 5: approvers are in scope
- Every approval’s approver is in scope for the contract: its owner, a stakeholder whose role is
approver, or, for an approval whosemethodispap_confirmation, its requester. Otherwiseapprover_out_of_scopeat/<i>/approvals/<k>/approver. A PAP confirmation counts only for grants whose resource scope lies within the contract’s own scope (section 5.4). - Separation of duties, at the
controlledandassuredlevels only. For each binding, take its approvals that areapproved, current and in scope. If there are none, or if any of them comes from someone other than the contract’s requester, the binding passes. Otherwise every one of them is the requester’s own, and each grant of the binding that is over the threshold isseparation_of_dutiesat/<i>/grants/<k>. The threshold is the one given to the check, or the binding’spolicy.sod_thresholdwhere that is lower and in the same currency (another currency iscurrency_mismatchat/<i>/policy/sod_threshold, and the given threshold applies). A grant is over the threshold when its cost limit is greater than the threshold, or it has no cost limit, or there is no threshold. A cost limit equal to the threshold is not over. A cost limit in another currency than the threshold iscurrency_mismatchat/<i>/grants/<k>/limits/costand is not counted as over. - Separation of duties also holds when each effect starts (9.7, step 4.2): once a binding holds a current approval in scope from someone other than the requester, the requester’s own approvals no longer authorize effects under its grants over the threshold, so they cannot stand in when that approval expires or is revoked.
- At the
essentiallevel the owner may approve their own contract within its limits, even when the owner is also the requester.
9.7 Invariant 6: no effect without authority
Each effect is checked at its started_at, written t below, against the binding its authority names. (If the binding is not in the record, 9.2 has already reported it.)
- The receipt’s
actor.principalis the binding’sgrantee, compared as in section 2.11; otherwiseauthority_insufficientat/<i>/actor/principal, and nothing else is checked for this effect. Authority belongs to the agent it was granted to, and a person who operates that agent acts as it (performed_byhuman). tis inside the binding’s window,valid_from <= t < expires_at; otherwiseauthority_expiredat/<i>/started_at.- The live status shows neither the binding nor any binding it was delegated from revoked at or before
t, followingdelegation.parentthrough the record; otherwiseauthority_revokedat/<i>/authority. Revoking a binding revokes every binding delegated from it (section 5.6). - A grant of the binding covers the action (section 5.2); otherwise
authority_insufficientat/<i>/action, and the approvals are not examined. - Approvals, with every result reported at
/<i>/authority:- If a denial that is current, in scope, decided at or before
t, unexpired attand not revoked attexists, the result isapproval_denied. - Otherwise, take the approvals that approve and are in scope for this grant, by approver, by role (a role the grant requires counts only when the contract gives it to the approver, section 5.4) and, for a PAP confirmation, by scope (the grant’s resource scope lies within the contract’s scope) (excluding
standingones forproduction.deploywhen the contract, the binding or the receipt follows the software-delivery profile). Where separation of duties covers the grant (9.6) and the binding holds a current approval in scope from someone other than the requester, leave out the requester’s own: separation of duties holds when each effect starts. Of the approvals left, the valid ones are current, decided at or beforet, unexpired attand not revoked att. If the valid approvals come from at least the grant’sconditions.min_approvalsdistinct people, or from at least one when the grant states none, the effect passes (section 5.4). - Otherwise, if there are valid approvals, from fewer people, the result is
quorum_not_met. - Otherwise, if the binding holds approvals that approve but none of them is in scope for this grant, because of who gave it or the role it was given under, the result is
approver_out_of_scope. An approval that step 2 leaves out by its kind, a PAP confirmation for a grant whose resource scope lies outside the contract’s scope or a standing approval for a production deploy, is not out of scope by who gave it, so step 5 applies. - Otherwise, take the most recently decided of the approvals left in step 2. If there is none, or it was decided after
t, the result isapproval_missing. If it is not current,approval_stale. If it had expired att,approval_expired. Otherwise it was revoked, and the result isapproval_revoked.
- If a denial that is current, in scope, decided at or before
A replay is not an effect: it needs no live authority, because nothing happens again (section 11.2).
9.8 Invariant 7: context is fresh when used
For each effect that cites a context manifest, every item of that manifest is fresh at t (section 4.3). An item that is stale, or of unknown age, makes the effect context_stale at /<i>/context. An effect that cites no manifest is not checked for freshness.
9.9 Invariant 8: money is consistent
All amounts are compared exactly (section 2.8). Where two amounts are in different currencies, the result is currency_mismatch at the path given and the amount is left out of that comparison or sum.
- If the contract states
limits.cost, no grant’s cost limit is greater than it; otherwiselimit_exceededat/<i>/grants/<k>/limits/cost. - If the contract states
limits.cost, the costs of the record’s receipts, replays excluded, are added in creation order (bycreated_at, ties in record order). At the first receipt where the total passes the limit, the result islimit_exceededat/<i>/cost, reported once. - For each grant, among the effects it covers, in creation order:
- when the number of distinct idempotency keys passes the grant’s
count, the result islimit_exceededat/<i>/action, at each receipt from the one that passes it; - when the total cost passes the grant’s cost limit, the result is
limit_exceededat/<i>/cost, at each receipt from the one that passes it.
- when the number of distinct idempotency keys passes the grant’s
A denied attempt uses none of a grant’s count. Replays cost nothing new.
A record holds one revision, so this check adds up that revision’s costs only. A new revision does not reset the contract’s budget: the Enforcement point counts what earlier revisions spent against the limit before each action (section 11.1), which the record check cannot.
9.10 Invariant 9: delegation attenuates
For each binding whose delegation names a parent present in the record:
- If the parent has no
delegationmember, or itssubdelegationisforbidden:subdelegation_forbiddenat/<i>/delegation/parent, and nothing else is checked for this binding. - If the binding’s
depthis not the parent’sdepthplus one:attenuation_violatedat/<i>/delegation/depth. - If the binding’s
depthis greater than the parent’smax_depth:subdelegation_forbiddenat/<i>/delegation/depth. - If the binding’s
max_depthis greater than the parent’s:attenuation_violatedat/<i>/delegation/max_depth. - If the binding’s
expires_atis later than the parent’s:attenuation_violatedat/<i>/expires_at. If itsvalid_fromis earlier than the parent’s:attenuation_violatedat/<i>/valid_from. - If the parent declares
policy.sod_thresholdand the binding declares none, a higher one, or one in another currency:attenuation_violatedat/<i>/policy/sod_threshold. - Each grant that narrows no grant of the parent (section 5.6) is
attenuation_violatedat/<i>/grants/<k>.
9.11 Invariant 10: idempotency holds
Take the receipts whose decision is permit, in creation order, grouped by action.idempotency_key:
- Every receipt with a key carries the action name, resource and payload digest of the first receipt with that key. Otherwise the receipt is one
idempotency_conflict, reported at the first member that differs, in the order name, resource, payload digest: at/<i>/action/namewhen the name differs, else at/<i>/action/resourcewhen the resource differs, else at/<i>/action/payload_digest. - While a key’s last outcome is
unknown, the only receipt that may follow under it is the one that records the known outcome (succeeded,failedorcancelled); that reconciles it, and is not a second effect (section 11.3). Any other receipt under the key, anotherunknownattempt or a replay, isidempotency_conflictat/<i>/action/idempotency_key: the action was used again before anyone knew what it did. - Once a key’s outcome is known, only replays may follow under it. Another known or
unknownoutcome means the action took effect, or may have, a second time:idempotency_conflictat/<i>/action/idempotency_key. - Denied receipts are not part of this check: an attempt the Enforcement point refused, for reusing a key or for any other reason, is a valid record, and reserves nothing (section 11.2).
9.12 Invariant 11: evidence matches criteria
For each evaluation in the record:
- Every criterion it names exists in the contract; otherwise
criterion_unknownat/<i>/criteria/<k>/criterion_id. - Every required criterion of the contract appears in it; otherwise
evidence_missingat/<i>/criteria. - Every
passorfailcarries evidence; otherwiseevidence_missingat/<i>/criteria/<k>/evidence(an object-level rule, section 7.2). technical_resultequals the value derived from the contract’s required criteria (section 7.4); otherwisetechnical_result_mismatchat/<i>/technical_result.
9.13 Invariant 12: acceptance comes last and from the owner
For each evaluation whose acceptance is decided (accepted or rejected):
- It is not in revision 1; otherwise
acceptance_prematureat/<i>/acceptance/decision(an object-level rule, section 7.5). - Its
execution.statusis notincomplete; no idempotency key among the record’s receipts, cited or not, has a final outcome ofunknown;acceptance.atis no earlier than the end of every effect of the record (itsfinished_at, or itsstarted_atwhen it has none), nor than thecreated_atof every earlier revision of the same evaluation in the record; and anaccepteddecision needs at least one effect in the record, while a rejection needs none. Otherwiseacceptance_prematureat/<i>/acceptance. - A key’s final receipt is, in creation order, its last receipt that records the outcome of an effect (
succeeded,failed,cancelledorunknown); for a key with none, its last replay; otherwise its last denial. A later known outcome therefore settles an earlierunknownunder the same key, and a laterunknownreopens it. Refusals and replays change nothing, so neither makes acceptance premature, however late they come. The PAP rollup uses the same final receipts (section 15.1). acceptance.byis the contract’s owner, a stakeholder of the contract whose role isacceptor, or a principal the owner delegated acceptance to atacceptance.at: the grantee of a binding in the record whose grantor’spersonis the owner, which grantsacceptance.decideon a resource of typework_contractwith the contract’sidor noid, which holds an approval by the owner that is current,approvedand live at that time (section 5.4, conditions 1 to 4) and no such denial by an approver in scope, and which is inside its window at that time, with neither it nor any binding it was delegated from revoked. Otherwiseacceptance_not_ownerat/<i>/acceptance/by.
9.14 Invariant 13: receipts chain
- Every receipt’s
integrity.digestequals the digest recomputed from the receipt (section 6.6); otherwisedigest_mismatchat/<i>/integrity/digest. - The receipts form one chain, using the digests the receipts state. A record holds one contract revision, so the chain it checks is that revision’s, and it restarts at every revision (section 6.6). The receipts are taken in creation order, by
created_atwith ties in record order, as in 9.9, whatever order the record lists them in, so “a second receipt”, “already names” and “the first receipt” below follow that order:- a second receipt with no
previous_digestischain_brokenat/<i>/integrity; - a
previous_digestthat is no receipt’s digest, one that another receipt already names (a fork), or one naming a receipt created later than this one (a link backwards in time) ischain_brokenat/<i>/integrity/previous_digest; - receipts with no first receipt among them are
chain_brokenat the first receipt’s/<i>/integrity.
- a second receipt with no
A receipt that was changed and given a recomputed digest passes the first check, but the next receipt’s previous_digest no longer names it, so the chain shows the change. A record edited and resealed from the change onwards, every later digest and link recomputed, is consistent again: the change then shows only against a digest the verifier already trusts, and so does a change to the last receipt (section 6.6).
9.15 Records describe the past
Each of these timestamps is no later than the current time; otherwise timestamp_in_future at its path:
- every object’s
created_at; - each context item’s
provenance.retrieved_atandfreshness.as_of; - each approval’s
decided_atandexternal.confirmed_at; - each receipt’s
action.requested_at,decision.evaluated_at,started_atandfinished_at; - each evaluation’s
acceptance.at.
Expiries, deadlines and window starts (expires_at, valid_from, deadline_at, a business impact window’s starts_at) may lie in the future.
9.16 What the assurance levels add
At the controlled and assured levels a record check also applies the rules below, which section 13.2 states for those levels; at essential it applies none of them. They are the parts of a level that a record can show. The rest of a level, such as durable idempotency, a live revocation status, an external policy decision point or enforced residency, is a property of the systems that produced the record, and no record check can verify it.
At controlled and assured:
- Every approval carries an
expires_at; otherwiseschema_violationat/<i>/approvals/<k>/expires_at. - When an evaluation’s
evaluator.principalis theactor.principalof an effect in the record, every requiredautomated_checkcriterion it judgespassorfailstates a limitation in its ownlimitations(section 7.7); otherwiseschema_violationat/<i>/criteria/<k>/limitations. The check sees that a limitation is stated, not what it says.
At assured only:
- Every receipt is attested: its
integrity.attestation.kindis notnone; otherwiseschema_violationat/<i>/integrity/attestation/kind. The check sees the attestation’s kind and reference; it does not verify a signature (section 6.6). - Every receipt names the policy decision it rests on in
decision.policy_ref; otherwiseschema_violationat/<i>/decision/policy_ref. - Only
verifiedapprovals authorize an effect (9.7, step 4.2). An effect that onlyassertedapprovals cover isapproval_missingat/<i>/authority. A PAP confirmation is always asserted, so at this level it never authorizes an effect alone. - Every binding with a
delegation.parentrecords the token exchange behind its hop: acredential_refsentry whosekindistoken_exchange; otherwiseschema_violationat/<i>/credential_refs.
A record that passes these rules carries what the level asks of a record. It does not show that the systems behind it meet the level, and a Consumer MUST NOT describe a passing record check as a conformance claim (section 13.4).
9.17 What the invariants do not check
This section is informative. The invariants check consistency and authority on record; they do not check that the record is true or complete. In particular, they do not check:
- that the actions a receipt describes happened as described, or that every action was recorded;
- the contract’s
constraints,limits.riskordeadline_at(section 3.4); - disclosure, redactions, classification, residency or retention (section 4.5);
- that a binding’s
grantor.organizationis the contract’s organization; - that an evaluation cites each action’s final receipt (section 7.1): acceptance is checked against every receipt of the record, whatever the evaluation cites;
- that an effect cites a context manifest at all;
- that spending across the contract’s revisions stays within its cost limit, or that idempotency keys stay closed across revisions: the record holds one revision, and the Enforcement point checks both (section 11.1, section 11.2).
Section 17 lists these among the limitations and open questions.
9.18 Examples
At the Controlled level with a threshold of USD 120.00, a record in which the requester, Dana, approved her own grants fails separation of duties. Five grants are over the threshold: four have no cost limit, and CI may cost up to USD 150.00. The preview grant, capped at USD 100.00, is not over.
{
"error": "invalid_bundle",
"error_description": "The bundle breaks a cross-object invariant.",
"details": [
{
"code": "separation_of_duties",
"path": "/2/grants/0",
"message": "needs an approver other than the requester"
},
{
"code": "separation_of_duties",
"path": "/2/grants/1",
"message": "needs an approver other than the requester"
},
{
"code": "separation_of_duties",
"path": "/2/grants/2",
"message": "needs an approver other than the requester"
},
{
"code": "separation_of_duties",
"path": "/2/grants/3",
"message": "needs an approver other than the requester"
},
{
"code": "separation_of_duties",
"path": "/2/grants/4",
"message": "needs an approver other than the requester"
}
]
}
A record in which a grant changed after Priya approved the binding: the approval covers the old binding digest, so it is stale, and every effect under it is reported.
{
"error": "invalid_bundle",
"error_description": "The bundle breaks a cross-object invariant.",
"details": [
{
"code": "approval_stale",
"path": "/2/approvals/0/covers/binding_digest",
"message": "covers another binding"
},
{
"code": "approval_stale",
"path": "/3/authority",
"message": "no valid approval covered this action when it started"
},
{
"code": "approval_stale",
"path": "/5/authority",
"message": "no valid approval covered this action when it started"
},
{
"code": "approval_stale",
"path": "/6/authority",
"message": "no valid approval covered this action when it started"
},
{
"code": "approval_stale",
"path": "/7/authority",
"message": "no valid approval covered this action when it started"
},
{
"code": "approval_stale",
"path": "/8/authority",
"message": "no valid approval covered this action when it started"
}
]
}