|
| 1 | +# Copyright 2024-2026 Tymofii Pidlisnyi. Apache-2.0 license. See LICENSE. |
| 2 | +"""Claim → Evidence types (Module 1 of the Evidentiary Type Safety set). |
| 3 | +
|
| 4 | +Mirrors src/v2/claim-evidence-types.ts in the TypeScript SDK at |
| 5 | +agent-passport-system 2.6.0-alpha.0. |
| 6 | +
|
| 7 | +Names a closed set of claims an APS receipt can substantiate, the |
| 8 | +record types the protocol can produce, and the mapping between |
| 9 | +them. Receipts substantiate specific claims; not every receipt |
| 10 | +can substitute for another. This module is the static surface of |
| 11 | +that mapping. Verification logic lives in claim_verifier. |
| 12 | +
|
| 13 | +Enum string values are byte-identical to the TypeScript SDK so |
| 14 | +any serialized form (registry export, audit-log entry, fixture |
| 15 | +JSON) interops across implementations. |
| 16 | +""" |
| 17 | + |
| 18 | +from dataclasses import dataclass, field |
| 19 | +from enum import Enum |
| 20 | +from typing import Dict, List, Optional |
| 21 | + |
| 22 | + |
| 23 | +class ClaimType(str, Enum): |
| 24 | + """Closed taxonomy of claims an evidence bundle can substantiate.""" |
| 25 | + |
| 26 | + IDENTITY_VERIFIED = "IDENTITY_VERIFIED" |
| 27 | + AUTHORITY_TO_EXECUTE = "AUTHORITY_TO_EXECUTE" |
| 28 | + ACTION_EXECUTED = "ACTION_EXECUTED" |
| 29 | + BINDING_COMMITMENT = "BINDING_COMMITMENT" |
| 30 | + EFFECT_SAFETY_ATTESTED = "EFFECT_SAFETY_ATTESTED" |
| 31 | + DERIVATION_TRACED = "DERIVATION_TRACED" |
| 32 | + CLAIM_CONTESTED = "CLAIM_CONTESTED" |
| 33 | + CLAIM_RESOLVED = "CLAIM_RESOLVED" |
| 34 | + BATCH_ATTESTED = "BATCH_ATTESTED" |
| 35 | + EVIDENCE_CUSTODY_HELD = "EVIDENCE_CUSTODY_HELD" |
| 36 | + |
| 37 | + |
| 38 | +class RecordType(str, Enum): |
| 39 | + """Mirrors the existing record-producing primitives the SDK ships. |
| 40 | +
|
| 41 | + Names match the TypeScript types in `src/index.ts`. Wave 1 |
| 42 | + accountability primitives (ActionReceipt, AuthorityBoundaryReceipt, |
| 43 | + CustodyReceipt, ContestabilityReceipt, APSBundle) are referenced |
| 44 | + here even though their full Python ports haven't shipped yet — the |
| 45 | + registry vocabulary is independent of which receipts the Python |
| 46 | + SDK can construct. |
| 47 | + """ |
| 48 | + |
| 49 | + ActionReceipt = "ActionReceipt" |
| 50 | + AuthorityBoundaryReceipt = "AuthorityBoundaryReceipt" |
| 51 | + CustodyReceipt = "CustodyReceipt" |
| 52 | + ContestabilityReceipt = "ContestabilityReceipt" |
| 53 | + APSBundle = "APSBundle" |
| 54 | + AccessReceipt = "AccessReceipt" |
| 55 | + DerivationReceipt = "DerivationReceipt" |
| 56 | + DecisionReceipt = "DecisionReceipt" |
| 57 | + ProvisionalStatement = "ProvisionalStatement" |
| 58 | + PromotionEvent = "PromotionEvent" |
| 59 | + Withdrawal = "Withdrawal" |
| 60 | + InstructionProvenanceReceipt = "InstructionProvenanceReceipt" |
| 61 | + CognitiveAttestation = "CognitiveAttestation" |
| 62 | + |
| 63 | + |
| 64 | +@dataclass(frozen=True) |
| 65 | +class EvidenceProfile: |
| 66 | + """Static schema for what evidence a given ClaimType requires. |
| 67 | +
|
| 68 | + `forbidden_substitutions` maps a RecordType to a human-readable |
| 69 | + rationale string. The rationale text is byte-identical across |
| 70 | + implementations so audit logs and paper appendices reference the |
| 71 | + same canonical wording. |
| 72 | + """ |
| 73 | + |
| 74 | + required: List[RecordType] |
| 75 | + forbidden_substitutions: Dict[RecordType, str] = field(default_factory=dict) |
| 76 | + optional: Optional[List[RecordType]] = None |
| 77 | + |
| 78 | + |
| 79 | +EvidenceProfiles: Dict[ClaimType, EvidenceProfile] = { |
| 80 | + ClaimType.AUTHORITY_TO_EXECUTE: EvidenceProfile( |
| 81 | + required=[RecordType.AuthorityBoundaryReceipt], |
| 82 | + optional=[RecordType.DecisionReceipt], |
| 83 | + forbidden_substitutions={ |
| 84 | + RecordType.ActionReceipt: ( |
| 85 | + "Action receipts prove execution, not authority. The boundary " |
| 86 | + "ruling is a separate signer (the gateway/evaluator), and " |
| 87 | + "conflating them collapses the trust split that makes the " |
| 88 | + "audit chain meaningful." |
| 89 | + ), |
| 90 | + }, |
| 91 | + ), |
| 92 | + |
| 93 | + ClaimType.BINDING_COMMITMENT: EvidenceProfile( |
| 94 | + required=[RecordType.PromotionEvent, RecordType.ProvisionalStatement], |
| 95 | + optional=[RecordType.DecisionReceipt], |
| 96 | + forbidden_substitutions={ |
| 97 | + RecordType.ActionReceipt: ( |
| 98 | + "Action receipts prove execution or communication, not " |
| 99 | + "binding commitment." |
| 100 | + ), |
| 101 | + }, |
| 102 | + ), |
| 103 | + |
| 104 | + # TODO: populate required/optional records and forbidden_substitutions. |
| 105 | + ClaimType.IDENTITY_VERIFIED: EvidenceProfile(required=[]), |
| 106 | + |
| 107 | + # TODO: populate required/optional records and forbidden_substitutions. |
| 108 | + ClaimType.ACTION_EXECUTED: EvidenceProfile(required=[]), |
| 109 | + |
| 110 | + # TODO: populate required/optional records and forbidden_substitutions. |
| 111 | + ClaimType.EFFECT_SAFETY_ATTESTED: EvidenceProfile(required=[]), |
| 112 | + |
| 113 | + # TODO: populate required/optional records and forbidden_substitutions. |
| 114 | + ClaimType.DERIVATION_TRACED: EvidenceProfile(required=[]), |
| 115 | + |
| 116 | + # TODO: populate required/optional records and forbidden_substitutions. |
| 117 | + ClaimType.CLAIM_CONTESTED: EvidenceProfile(required=[]), |
| 118 | + |
| 119 | + # TODO: populate required/optional records and forbidden_substitutions. |
| 120 | + ClaimType.CLAIM_RESOLVED: EvidenceProfile(required=[]), |
| 121 | + |
| 122 | + ClaimType.BATCH_ATTESTED: EvidenceProfile( |
| 123 | + required=[RecordType.APSBundle], |
| 124 | + ), |
| 125 | + |
| 126 | + ClaimType.EVIDENCE_CUSTODY_HELD: EvidenceProfile( |
| 127 | + required=[RecordType.CustodyReceipt], |
| 128 | + forbidden_substitutions={ |
| 129 | + RecordType.ActionReceipt: ( |
| 130 | + "Action receipts prove what was done, not who held the " |
| 131 | + "evidence afterward." |
| 132 | + ), |
| 133 | + }, |
| 134 | + ), |
| 135 | +} |
| 136 | + |
| 137 | + |
| 138 | +def required_evidence_for(claim_type: ClaimType) -> EvidenceProfile: |
| 139 | + """Return the EvidenceProfile registered for a claim type.""" |
| 140 | + return EvidenceProfiles[claim_type] |
0 commit comments