Expand description
Reasoned Action Proofs and event-triggered intent recheck.
A standard credential answers who acted and under what authority. It says nothing about why. This module adds the missing “why” layer: before acting, an agent states a structured justification (an intent plus a set of evidence anchors, each a claim tied to a real artifact by that artifact’s hash). The justification is committed by digest, optionally deposited with a neutral escrow that timestamps it, and the executed action credential carries the commitment. Three properties then hold: no fabrication (each reason names an artifact a verifier re-resolves and hashes), no post-hoc rewrite (the credential carries the digest), and, with escrow, committed before execution (the deposit time is not after execution).
This is the canonical port of the Python reference vouch/reasoning.py. The
digest algorithm and every stable reason string match byte for byte, so a
seal built in one language verifies in another. Everything here is an ordinary
eddsa-jcs-2022 Verifiable Credential.
§Intent recheck (event-triggered)
A heartbeat proves the agent is alive across an interval; it does not prove the
agent’s intent is current at the moment of a sensitive action. A justification
sealed early in an interval still passes for an action executed much later in
the same interval, so a sophisticated actor can time a sensitive action to land
after a pulse boundary while reusing an intent sealed before it. The intent
recheck binds seal freshness to the action: for a sensitive consequence tier
the seal must post-date the last pulse boundary and be within a configurable
max age, not merely predate execution. See verify_intent_freshness and
reseal_intent.
Structs§
- Freshness
Requirement - The freshness requirement a consequence tier imposes on an intent seal.
- MaxAge
- An age limit as a caller wrote it: the limit in nanoseconds the elapsed
time is compared with (the floor of the reference’s
max_age * 1e9, which compares the same for a whole number of nanoseconds), and its text for the refusal. - Pulse
Window - Where an action’s execution time falls relative to the current pulse window
[last_pulse, last_pulse + interval). - Sign
Reasoned Action Options - Options for
sign_reasoned_action.
Constants§
- ESCROW_
RECEIPT_ TYPE - JUSTIFICATION_
ALGORITHM - REASONED_
ACTION_ TYPE - REASON_
ESCROW_ AFTER_ EXECUTION - REASON_
ESCROW_ AGENT_ MISMATCH - The receipt names another agent than the credential’s issuer.
- REASON_
ESCROW_ DIGEST_ MISMATCH - REASON_
ESCROW_ INVALID - REASON_
EVIDENCE_ HASH_ MISMATCH - REASON_
EVIDENCE_ UNRESOLVED - REASON_
INTENT_ EXECUTION_ NOT_ CURRENT - Intent recheck: the execution time is not within the verifier’s clock +/-
skew (carries
:valid_from=<validFrom>). - REASON_
INTENT_ SEAL_ EXPIRED - REASON_
INTENT_ SEAL_ FUTURE - Intent recheck: the witnessed seal is later than the verifier’s clock plus
skew (carries
:sealed_at=<depositedAt>). - REASON_
INTENT_ SEAL_ MISSING - REASON_
INTENT_ SEAL_ STALE - REASON_
INVALID_ PROOF - REASON_
JUSTIFICATION_ DIGEST_ MISMATCH - REASON_
MALFORMED_ TIME validFrom,sealedAtordepositedAtdoes not follow the time grammar.- REASON_
MISSING_ COMMITMENT - REASON_
MISSING_ ESCROW - REASON_
NOT_ REASONED_ ACTION - REASON_
SEAL_ AFTER_ DEPOSIT - The agent’s own
sealedAtis later than the escrow’sdepositedAt. - REASON_
SEAL_ AFTER_ EXECUTION - The agent’s own
sealedAtis later than the execution time (validFrom). - REASON_
SEAL_ IN_ FUTURE - A seal is later than the verifier’s clock plus skew.
- REASON_
UNANCHORED_ CLAIM - TIER_
CRITICAL - TIER_
HIGH - TIER_
LOW - TIER_
MEDIUM - TIER_
ROUTINE - Consequence tiers, aligned with PAD-017 commitment levels (0..4) and the trust-entropy stakes bands. Higher tiers demand a fresher seal.
- VC_
CONTEXT_ V2 - VOUCH_
CONTEXT_ V1
Functions§
- artifact_
digest - Multibase SHA-256 of an evidence artifact (JSON object or string).
- artifact_
digest_ bytes - Multibase SHA-256 of a raw-byte evidence artifact.
- build_
escrow_ receipt - Issue a signed
JustificationEscrowReceiptfixing a commitment in time. The escrow sees only the digest, never the plaintext justification. - build_
escrow_ receipt_ with build_escrow_receiptwith the seed optional (without one the receipt comes back unsigned, for a host whose key lives elsewhere to sign) and the proof’screated, the time of signing (None keepsdeposited_at).- build_
justification - Assemble a justification: the intent plus its evidence anchors.
intentmust carry at leastactionandtarget; at least one anchor is required. - check_
reasoned_ action - Verify a reasoned-action credential. Returns
Noneon success or a structured reason string on failure. Checks, in order: - check_
reasoned_ action_ at check_reasoned_actionwith the verifier’s clock: asealedAtor adepositedAtlater thannow_isoplus the skew is refused (seal_in_future). Errors on a malformednow_isoor a skew outside 0..120 seconds (a caller error, not a verdict).- check_
seal_ freshness - The core intent-recheck rule. Given a seal time, the action’s execution time,
the last pulse boundary, and a tier’s freshness requirement, return
Noneif the seal is fresh enough, else a stable reason string. - check_
unreadable_ reasoned_ action - The checks of
check_reasoned_action_at;clockis the verifier’s(now, skew)in nanoseconds, orNoneto skip the clock comparisons. The answer ofcheck_reasoned_actionfor a credential the host could not hand over as it is (a value with no JSON form): not a reasoned action when its type says so, elseinvalid_proof, the reference’s answer when it cannot compute the signing input. No signature is checked over the copy. - default_
requirement - Reference intent-freshness policy: routine/low/medium tiers inherit the last pulse’s assurance; high and critical tiers require a seal sealed after the last pulse boundary, within a tightening max age. Deployments substitute their own thresholds; these are reference values.
- evidence_
anchor - Build one evidence anchor: a claim tied to a verifiable artifact. Supply
evidence(its hash is computed) OR a precomputedevidence_hash. - justification_
digest - Multibase SHA-256 over the JCS-canonical justification.
- pulse_
window - Classify an action’s execution time against the pulse schedule.
last_pulseis the issue time of the most recent heartbeat;interval_secondsis the heartbeat period. - recheck_
intent_ freshness - The intent recheck a verifier runs at a consequence tier. A tier that
requires a fresh seal (high and critical in the reference policy) requires
an escrow receipt, because the agent’s own
sealedAtis only its word; the seal time is the receipt’s VERIFIEDdepositedAt. Checks, in order (the first failure is returned): - recheck_
intent_ freshness_ with recheck_intent_freshnessfor a host whose receipt had no JSON form (receipt_unreadable): the host sends the credential with those values as null, and the receipt never verifies (escrow_receipt_invalidat its step); its signature is never checked over the changed copy.- reseal_
intent - Execution-time reseal helper: seal the intent right now and issue a fresh
ReasonedActionCredentialwhosesealedAtandvalidFromare bothnow, so a sensitive action carries a seal made in the current pulse window. Reusesbuild_justificationandsign_reasoned_action; no new cryptography. - reseal_
intent_ with reseal_intentwith the seed optional (unsigned without one) and the proof’screated, the time of signing (None keepsnow).- seal_
timestamp - Read the seal timestamp from a reasoned-action credential: the attached
escrow receipt’s
depositedAtwhen there is a receipt (a neutral witness), else the justification’s ownsealedAt. - sign_
reasoned_ action - Issue a
ReasonedActionCredential: the action bound to its justification.valid_fromis the execution time and also the proofcreated. - sign_
reasoned_ action_ with sign_reasoned_actionwith the seed optional: without one the credential comes back unsigned, for a host whose key lives elsewhere to sign (proofcreated=valid_from, verificationMethod as given).- verify_
escrow_ receipt - Verify an escrow receipt’s proof and structure against the escrow’s raw
Ed25519 public key. The proof must be bound to the receipt’s issuer
(proofPurpose “assertionMethod”, a verificationMethod of the escrow’s DID),
the subject must name the
agentand carry thecommittedDigest, anddepositedAtmust be a protocol time. A proof that carries an@contextis refused: an escrow never writes one, and with one the same signed receipt would have a second form with different bytes. Returns(ok, subject). - verify_
intent_ freshness - Verify intent freshness for a reasoned-action credential at a given tier,
without an escrow key or a clock. A tier that requires a fresh seal needs a
verified escrow receipt, which this form cannot check, so it refuses
(
intent_seal_missing:tier=<n>with no receipt, elseescrow_receipt_invalid); a tier with no requirement returnsNone. A verifier callsrecheck_intent_freshness. - verify_
justification - Check a revealed justification against a verified credential’s commitment: the
justification must recompute to the committed digest, and every anchor must
resolve (via
resolver) to an artifact whose hash matches. Returns(true, None)on success, else(false, Some(reason)). - verify_
reasoned_ action - Convenience wrapper over
check_reasoned_actionreturning(ok, credentialSubject).