|
| 1 | +# Receipt Rails Operational Flow |
| 2 | + |
| 3 | +This document outlines the fundamental operational flow of the Polykey |
| 4 | +ecosystem, which we call the Receipt Rails. It illustrates the complete |
| 5 | +lifecycle of a verifiable event, from the initial grant of authority to the |
| 6 | +final acceptance of a cryptographic receipt by a third party. |
| 7 | + |
| 8 | +The core principle of the Receipt Rails is to create a standardized, secure, and |
| 9 | +auditable process for proving that a specific action was performed or a specific |
| 10 | +outcome was achieved. This is accomplished through a sequence of interactions |
| 11 | +between four key actors: the Principal (who grants authority), the Subject (who |
| 12 | +performs the action), the Resource (the target of the action), and the Verifier |
| 13 | +(who accepts the proof). |
| 14 | + |
| 15 | +Below are two diagrams. The first provides a high-level, summary view of the |
| 16 | +entire flow. The second diagram is a detailed, technical zoom-in on the most |
| 17 | +critical and complex step: the Enforcement of a capability. Understanding both |
| 18 | +is key to grasping the full power and flexibility of the system. |
| 19 | + |
| 20 | +## Core Operational Flow (Summary View) |
| 21 | + |
| 22 | +This diagram shows the end-to-end lifecycle. It begins with a Principal issuing |
| 23 | +a Grant, which authorizes a Subject to perform an action. The Subject then |
| 24 | +presents this authority to an Enforcement Point, which results in the minting of |
| 25 | +verifiable receipts. These receipts are then assembled into a View for a |
| 26 | +Verifier, who can accept them for settlement, compliance, or payment. |
| 27 | + |
| 28 | +```mermaid |
| 29 | +--- |
| 30 | +title: The Receipt Rails - Core Operational Flow |
| 31 | +config: |
| 32 | + theme: redux-color |
| 33 | +--- |
| 34 | +sequenceDiagram |
| 35 | + participant P as Principal (P)<br>- Sigchain (P)<br>- Vault (leases/policy) |
| 36 | + participant S as Subject (S)<br>- Sigchain (S) |
| 37 | + participant R as Resource / ToA / SoA<br>(e.g., API, Power Grid, Door Lock) |
| 38 | + participant V as Verifier / Auditor / Escrow<br>(TAP/RAM acceptance) |
| 39 | +
|
| 40 | + autonumber |
| 41 | + Note over P: Issue Grant G<br>[write G to P’s Sigchain] |
| 42 | + P ->> S: notify/ref (push or pull) for G |
| 43 | +
|
| 44 | + rect rgba(0,0,0,0.04) |
| 45 | + note left of P: Enforcement Variants |
| 46 | + alt Principal-side CEP (placement=P, bridging=true) [PS-BA] |
| 47 | + S ->> P: Present capability (Presentation) |
| 48 | + Note over P: Enforce at P CEP (mediate / derive / reveal)<br>Write Access PoAR on P's sigchain<br>Deliver PoAR to S |
| 49 | + else Resource-side CEP (placement=R, bridging=false) [native] |
| 50 | + S ->> R: Present capability (Presentation) |
| 51 | + Note over S,R: Enforce at Resource CEP<br>Write Access PoAR on R's sigchain<br>Deliver PoAR to S |
| 52 | + else Subject-side CEP (placement=S, bridging=false) [SSA wallet/session] |
| 53 | + S ->> S: Present capability (internal Presentation) |
| 54 | + S ->> S: Derive short-scope token |
| 55 | + S ->> R: ToA API call (using token) |
| 56 | + Note over S: Write Access PoAR on S's sigchain |
| 57 | + else Subject-side CEP (placement=S, bridging=true) [SS-BA, rare] |
| 58 | + S ->> S: Present capability (internal Presentation) |
| 59 | + S ->> S: Derive or reveal using S-owned lease |
| 60 | + S ->> R: ToA API call |
| 61 | + Note over S: Write Access PoAR on S's sigchain |
| 62 | + end |
| 63 | + end |
| 64 | +
|
| 65 | + opt UseReceipt (optional, TAP may require) |
| 66 | + S ->> S: Write UseReceipt (ref G & PoAR P) |
| 67 | + end |
| 68 | +
|
| 69 | + opt Outcome measurable |
| 70 | + Note over S,R: Measuring agent writes VOR where observed |
| 71 | + alt Subject-side measurer |
| 72 | + S ->> S: Write VOR |
| 73 | + else Resource-native measurer |
| 74 | + R ->> R: Write VOR |
| 75 | + end |
| 76 | + end |
| 77 | +
|
| 78 | + par Either P or S assembles View |
| 79 | + P ->> V: ViewReceipt {G, PoAR, Use?, VOR?} (with lens & tapProfile) |
| 80 | + S ->> V: ViewReceipt {G, PoAR, Use?, VOR?} (with lens & tapProfile) |
| 81 | + end |
| 82 | +
|
| 83 | + V ->> V: Accept/Settle (per TAP/RAM) |
| 84 | + Note right of V: Accept / Pay / Comply |
| 85 | +
|
| 86 | + Note over P,S: Storage/Durability:<br>- Hot: recent envelopes + index<br>- Seal: Merkle segments + SegmentReceipt<br>- Cold: Custody (S3/MinIO/IPFS, E2E enc)<br>- Escrow: PinningReceipt<br>- Anchors: AnchorReceipt (hash-only) |
| 87 | +``` |
| 88 | + |
| 89 | +### How to Read This Diagram |
| 90 | + |
| 91 | +- Participants: |
| 92 | + - P (Principal): The entity granting authority (e.g., a DevOps lead, a |
| 93 | + homeowner). |
| 94 | + - S (Subject): The entity performing the action (e.g., a CI/CD runner, a smart |
| 95 | + lock app). |
| 96 | + - R (Resource): The target of the action (e.g., a Kubernetes API, a Power |
| 97 | + Grid, a Door Lock). |
| 98 | + - V (Verifier): The entity that needs proof (e.g., an Auditor, an Insurer, an |
| 99 | + Escrow agent). |
| 100 | +- The Happy Path: The numbered steps show the ideal flow from Issue Grant G to |
| 101 | + Accept/Settle. |
| 102 | +- Enforcement Variants (The `alt` block): This block is a high-level summary of |
| 103 | + the four ways that authority can be enforced, depending on where the |
| 104 | + "gatekeeper" (the CEP) is located. This is the most complex part of the |
| 105 | + system, and it is expanded in full detail in the second diagram. |
| 106 | +- Receipts (`opt` blocks): The flow generates several types of receipts. The |
| 107 | + Access PoAR (Proof of Action) is the primary receipt proving the action was |
| 108 | + authorized. The UseReceipt is an optional acknowledgment from the Subject, and |
| 109 | + the VOR (Verifiable Outcome Receipt) is a separate proof of the result. |
| 110 | +- Durability (Bottom Note): This note shows the layered approach to storage, |
| 111 | + ensuring receipts are both readily available ("Hot") and securely archived for |
| 112 | + the long term ("Cold"), with options for independent verification |
| 113 | + ("Escrow/Anchors"). |
| 114 | + |
| 115 | +## Enforcement Variants - Detailed View |
| 116 | + |
| 117 | +This diagram is a detailed zoom-in of the "Enforcement Variants" block from the |
| 118 | +first diagram. It shows the precise mechanics of how a capability is verified |
| 119 | +and enforced in each of the four possible architectural patterns. The choice of |
| 120 | +pattern depends on whether the Resource is a modern, PK-native system or a |
| 121 | +legacy one, and on the security requirements of the transaction. |
| 122 | + |
| 123 | +```mermaid |
| 124 | +--- |
| 125 | +title: Enforcement Variants - Detailed View of CEP Placements and Modes |
| 126 | +config: |
| 127 | + theme: redux-color |
| 128 | +--- |
| 129 | +sequenceDiagram |
| 130 | + participant P as Principal (P)<br>- Sigchain (P)<br>- Vault (leases/policy) |
| 131 | + participant S as Subject (S)<br>- Sigchain (S) |
| 132 | + participant R as Resource / ToA / SoA<br>(e.g., API, Power Grid, Door Lock) |
| 133 | + participant V as Verifier / Auditor / Escrow<br>(TAP/RAM acceptance) |
| 134 | +
|
| 135 | + autonumber |
| 136 | +
|
| 137 | + alt Principal-side CEP (placement=P, bridging=true) [PS-BA] |
| 138 | + Note over P: If P and R are the same trust boundary<br>this is effectively native (colocated)<br>bridging=false, PoAR still on P's sigchain |
| 139 | + S ->> P: Present capability (Presentation) |
| 140 | + break Verification fails at P |
| 141 | + Note over P: Deny path<br>Mint DenyReceipt with reason code<br>(binding_mismatch, lease_stale, surface_violation, rate_limit) |
| 142 | + Note over P: Write DenyReceipt on P's sigchain |
| 143 | + P ->> S: Deliver DenyReceipt |
| 144 | + end |
| 145 | + alt Mediate at P |
| 146 | + Note over P: Verify Presentation + Bind + fresh LeaseRef<br>Record requestDigest vs Allowed-Surface |
| 147 | + P ->> R: ToA API call |
| 148 | + R -->> P: Result |
| 149 | + P -->> S: Result (if requester expects data) |
| 150 | + else Derive at P |
| 151 | + Note over P: Verify Presentation + Bind + fresh LeaseRef |
| 152 | + P ->> S: Short-scope token (session-bound) |
| 153 | + S ->> R: ToA API call (using token) |
| 154 | + R -->> S: Result |
| 155 | + else Reveal at P (last resort) |
| 156 | + Note over P: Break-glass<br>dual-control, tiny ttl/scope, audit correlation, immediate revoke |
| 157 | + P ->> S: Raw secret |
| 158 | + S ->> R: ToA API call (bearer) |
| 159 | + R -->> S: Result |
| 160 | + end |
| 161 | + Note over P: Write Access PoAR on P's sigchain<br>exposureMode = mediate/derive/reveal |
| 162 | + P ->> S: Deliver PoAR |
| 163 | +
|
| 164 | + else Resource-side CEP (placement=R, bridging=false) [native] |
| 165 | + S ->> R: Present capability (Presentation) |
| 166 | + break Verification fails at R |
| 167 | + Note over R: Deny path<br>Mint DenyReceipt with reason code<br>(binding_mismatch, lease_stale, surface_violation, rate_limit) |
| 168 | + Note over R: Write DenyReceipt on R's sigchain |
| 169 | + R ->> S: Deliver DenyReceipt |
| 170 | + end |
| 171 | + Note over R: Enforce at Resource CEP |
| 172 | + R -->> S: Result (if requester expects data) |
| 173 | + Note over R: Write Access PoAR on R's sigchain |
| 174 | + R ->> S: Deliver PoAR |
| 175 | +
|
| 176 | + else Subject-side CEP (placement=S, bridging=false) [SSA wallet/session] |
| 177 | + Note over S: S does not hold long-lived upstream lease. |
| 178 | + S ->> S: Present capability (internal Presentation) |
| 179 | + break Verification fails at S |
| 180 | + Note over S: Deny path<br>Mint DenyReceipt with reason code<br>(binding_mismatch, lease_stale, surface_violation, rate_limit) |
| 181 | + Note over S: Write DenyReceipt on S's sigchain |
| 182 | + %% Optional notify P for audit |
| 183 | + S -->> P: Notify DenyReceipt (policy-dependent) |
| 184 | + end |
| 185 | + S ->> S: Derive short-scope token (federated/workload identity) |
| 186 | + S ->> R: ToA API call (using token) |
| 187 | + R -->> S: Result |
| 188 | + Note over S: Write Access PoAR on S's sigchain |
| 189 | +
|
| 190 | + else Subject-side CEP (placement=S, bridging=true) [SS-BA, rare] |
| 191 | + S ->> S: Present capability (internal Presentation) |
| 192 | + break Verification fails at S |
| 193 | + Note over S: Deny path<br>Mint DenyReceipt with reason code<br>(binding_mismatch, lease_stale, surface_violation, rate_limit) |
| 194 | + Note over S: Write DenyReceipt on S's sigchain |
| 195 | + %% Optional notify P for audit |
| 196 | + S -->> P: Notify DenyReceipt (policy-dependent) |
| 197 | + end |
| 198 | + alt Mediate at S (no token egress) |
| 199 | + Note over S: Mediate only when S wants to ensure that no token ever leaves the CEP |
| 200 | + S ->> R: ToA API call using S-held lease (or short-scope token retained at S) |
| 201 | + R -->> S: Result |
| 202 | + else Derive at S (preferred) |
| 203 | + S ->> S: Derive short-scope token from S-held lease |
| 204 | + S ->> R: ToA API call (using token) |
| 205 | + R -->> S: Result |
| 206 | + else Reveal at S (last resort) |
| 207 | + Note over S: Break-glass only when S owns upstream<br>tiny ttl/scope, dual-control, audit correlation, immediate revoke |
| 208 | + S ->> S: Reveal raw secret to caller |
| 209 | + S ->> R: ToA API call (bearer) |
| 210 | + R -->> S: Result |
| 211 | + end |
| 212 | + Note over S: Write Access PoAR on S's sigchain |
| 213 | + end |
| 214 | +``` |
| 215 | + |
| 216 | +### How to Read This Diagram |
| 217 | + |
| 218 | +- The Four Variants (`alt` blocks): |
| 219 | + - Principal-side CEP [PS-BA]: This is the default pattern for bridging to |
| 220 | + legacy systems. The Principal's agent acts as a secure "butler" (a Bridge |
| 221 | + Adapter), holding the master key and interacting with the legacy Resource on |
| 222 | + the Subject's behalf. It details the three modes: Mediate, Derive, and |
| 223 | + Reveal. |
| 224 | + - Resource-side CEP [native]: This is the ideal, end-state pattern for modern, |
| 225 | + PK-native systems. The Resource itself has a built-in enforcement point. It |
| 226 | + can verify the Subject's capability directly, without an intermediary. |
| 227 | + - Subject-side CEP [SSA wallet/session]: This pattern is for federated |
| 228 | + identity scenarios. The Subject's agent uses its own strong identity (e.g., |
| 229 | + a cloud workload identity) to Derive a temporary credential directly from |
| 230 | + the Resource. |
| 231 | + - Subject-side CEP [SS-BA, rare]: This is a rare pattern used only when the |
| 232 | + Subject itself owns the master key to a legacy system it needs to bridge. |
| 233 | +- The Deny Path (`break` blocks): Each variant includes an explicit flow for |
| 234 | + what happens when verification fails. The enforcing CEP mints a DenyReceipt |
| 235 | + with a reason code, providing a verifiable audit trail of failed attempts. |
| 236 | +- PoAR Provenance: Crucially, this diagram shows who mints the Access PoAR in |
| 237 | + each case. The rule is simple: the enforcer mints the proof. This means the |
| 238 | + PoAR is written to the sigchain of P, R, or S, depending on the variant used. |
| 239 | + This is fundamental to the system's distributed and verifiable nature. |
0 commit comments