@emilia-protocol/gate 0.11.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +310 -0
- package/action-control-manifest.js +3 -268
- package/action-escrow-custodian.js +3 -394
- package/action-escrow-evidence.js +3 -858
- package/action-escrow-package.js +3 -1668
- package/action-escrow-postgres.js +3 -337
- package/action-escrow-state.js +3 -396
- package/action-escrow-verifiers.js +3 -331
- package/action-escrow.js +3 -2447
- package/action-packs.js +3 -140
- package/adapters/_kit.js +3 -104
- package/adapters/aws.js +3 -108
- package/adapters/cloudflare.js +3 -54
- package/adapters/gcp.js +3 -70
- package/adapters/github.js +3 -109
- package/adapters/jira.js +3 -55
- package/adapters/k8s.js +3 -70
- package/adapters/linear.js +3 -55
- package/adapters/salesforce.js +3 -55
- package/adapters/stripe.js +3 -81
- package/adapters/supabase.js +3 -121
- package/adapters/terraform.js +3 -59
- package/adapters/vercel.js +3 -84
- package/aec-execution.js +3 -312
- package/breakglass.js +3 -582
- package/capability-receipt.js +4 -0
- package/cf1-conformance.js +3 -106
- package/challenge-store.js +3 -69
- package/control-plane.js +3 -340
- package/coverage.js +3 -721
- package/demo.mjs +1 -1
- package/deployment-attestation.js +3 -247
- package/dist/action-control-manifest.d.ts +82 -0
- package/dist/action-control-manifest.d.ts.map +1 -0
- package/dist/action-control-manifest.js +422 -0
- package/dist/action-control-manifest.js.map +1 -0
- package/dist/action-escrow-custodian.d.ts +74 -0
- package/dist/action-escrow-custodian.d.ts.map +1 -0
- package/dist/action-escrow-custodian.js +363 -0
- package/dist/action-escrow-custodian.js.map +1 -0
- package/dist/action-escrow-evidence.d.ts +130 -0
- package/dist/action-escrow-evidence.d.ts.map +1 -0
- package/dist/action-escrow-evidence.js +1012 -0
- package/dist/action-escrow-evidence.js.map +1 -0
- package/dist/action-escrow-package.d.ts +10 -0
- package/dist/action-escrow-package.d.ts.map +1 -0
- package/dist/action-escrow-package.js +1583 -0
- package/dist/action-escrow-package.js.map +1 -0
- package/dist/action-escrow-postgres.d.ts +62 -0
- package/dist/action-escrow-postgres.d.ts.map +1 -0
- package/dist/action-escrow-postgres.js +339 -0
- package/dist/action-escrow-postgres.js.map +1 -0
- package/dist/action-escrow-state.d.ts +141 -0
- package/dist/action-escrow-state.d.ts.map +1 -0
- package/dist/action-escrow-state.js +413 -0
- package/dist/action-escrow-state.js.map +1 -0
- package/dist/action-escrow-verifiers.d.ts +65 -0
- package/dist/action-escrow-verifiers.d.ts.map +1 -0
- package/dist/action-escrow-verifiers.js +421 -0
- package/dist/action-escrow-verifiers.js.map +1 -0
- package/dist/action-escrow.d.ts +112 -0
- package/dist/action-escrow.d.ts.map +1 -0
- package/dist/action-escrow.js +2661 -0
- package/dist/action-escrow.js.map +1 -0
- package/dist/action-packs.d.ts +54 -0
- package/dist/action-packs.d.ts.map +1 -0
- package/dist/action-packs.js +143 -0
- package/dist/action-packs.js.map +1 -0
- package/dist/adapters/_kit.d.ts +50 -0
- package/dist/adapters/_kit.d.ts.map +1 -0
- package/dist/adapters/_kit.js +98 -0
- package/dist/adapters/_kit.js.map +1 -0
- package/dist/adapters/aws.d.ts +158 -0
- package/dist/adapters/aws.d.ts.map +1 -0
- package/dist/adapters/aws.js +136 -0
- package/dist/adapters/aws.js.map +1 -0
- package/dist/adapters/cloudflare.d.ts +116 -0
- package/dist/adapters/cloudflare.d.ts.map +1 -0
- package/dist/adapters/cloudflare.js +75 -0
- package/dist/adapters/cloudflare.js.map +1 -0
- package/dist/adapters/gcp.d.ts +139 -0
- package/dist/adapters/gcp.d.ts.map +1 -0
- package/dist/adapters/gcp.js +69 -0
- package/dist/adapters/gcp.js.map +1 -0
- package/dist/adapters/github.d.ts +123 -0
- package/dist/adapters/github.d.ts.map +1 -0
- package/dist/adapters/github.js +105 -0
- package/dist/adapters/github.js.map +1 -0
- package/dist/adapters/jira.d.ts +109 -0
- package/dist/adapters/jira.d.ts.map +1 -0
- package/dist/adapters/jira.js +54 -0
- package/dist/adapters/jira.js.map +1 -0
- package/dist/adapters/k8s.d.ts +139 -0
- package/dist/adapters/k8s.d.ts.map +1 -0
- package/dist/adapters/k8s.js +69 -0
- package/dist/adapters/k8s.js.map +1 -0
- package/dist/adapters/linear.d.ts +109 -0
- package/dist/adapters/linear.d.ts.map +1 -0
- package/dist/adapters/linear.js +54 -0
- package/dist/adapters/linear.js.map +1 -0
- package/dist/adapters/salesforce.d.ts +109 -0
- package/dist/adapters/salesforce.d.ts.map +1 -0
- package/dist/adapters/salesforce.js +54 -0
- package/dist/adapters/salesforce.js.map +1 -0
- package/dist/adapters/stripe.d.ts +116 -0
- package/dist/adapters/stripe.d.ts.map +1 -0
- package/dist/adapters/stripe.js +77 -0
- package/dist/adapters/stripe.js.map +1 -0
- package/dist/adapters/supabase.d.ts +127 -0
- package/dist/adapters/supabase.d.ts.map +1 -0
- package/dist/adapters/supabase.js +112 -0
- package/dist/adapters/supabase.js.map +1 -0
- package/dist/adapters/terraform.d.ts +109 -0
- package/dist/adapters/terraform.d.ts.map +1 -0
- package/dist/adapters/terraform.js +58 -0
- package/dist/adapters/terraform.js.map +1 -0
- package/dist/adapters/vercel.d.ts +114 -0
- package/dist/adapters/vercel.d.ts.map +1 -0
- package/dist/adapters/vercel.js +81 -0
- package/dist/adapters/vercel.js.map +1 -0
- package/dist/aec-execution.d.ts +107 -0
- package/dist/aec-execution.d.ts.map +1 -0
- package/dist/aec-execution.js +334 -0
- package/dist/aec-execution.js.map +1 -0
- package/dist/breakglass.d.ts +205 -0
- package/dist/breakglass.d.ts.map +1 -0
- package/dist/breakglass.js +627 -0
- package/dist/breakglass.js.map +1 -0
- package/dist/capability-receipt.d.ts +601 -0
- package/dist/capability-receipt.d.ts.map +1 -0
- package/dist/capability-receipt.js +1177 -0
- package/dist/capability-receipt.js.map +1 -0
- package/dist/cf1-conformance.d.ts +83 -0
- package/dist/cf1-conformance.d.ts.map +1 -0
- package/dist/cf1-conformance.js +94 -0
- package/dist/cf1-conformance.js.map +1 -0
- package/dist/challenge-store.d.ts +20 -0
- package/dist/challenge-store.d.ts.map +1 -0
- package/dist/challenge-store.js +62 -0
- package/dist/challenge-store.js.map +1 -0
- package/dist/control-plane.d.ts +136 -0
- package/dist/control-plane.d.ts.map +1 -0
- package/dist/control-plane.js +349 -0
- package/dist/control-plane.js.map +1 -0
- package/dist/coverage.d.ts +156 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +768 -0
- package/dist/coverage.js.map +1 -0
- package/dist/deployment-attestation.d.ts +93 -0
- package/dist/deployment-attestation.d.ts.map +1 -0
- package/dist/deployment-attestation.js +262 -0
- package/dist/deployment-attestation.js.map +1 -0
- package/dist/eg1-conformance.d.ts +286 -0
- package/dist/eg1-conformance.d.ts.map +1 -0
- package/dist/eg1-conformance.js +379 -0
- package/dist/eg1-conformance.js.map +1 -0
- package/dist/enterprise.d.ts +88 -0
- package/dist/enterprise.d.ts.map +1 -0
- package/dist/enterprise.js +194 -0
- package/dist/enterprise.js.map +1 -0
- package/dist/evidence-postgres.d.ts +123 -0
- package/dist/evidence-postgres.d.ts.map +1 -0
- package/dist/evidence-postgres.js +343 -0
- package/dist/evidence-postgres.js.map +1 -0
- package/dist/evidence.d.ts +113 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +369 -0
- package/dist/evidence.js.map +1 -0
- package/dist/execution-binding.d.ts +49 -0
- package/dist/execution-binding.d.ts.map +1 -0
- package/dist/execution-binding.js +243 -0
- package/dist/execution-binding.js.map +1 -0
- package/dist/formal-runtime-map.d.ts +42 -0
- package/dist/formal-runtime-map.d.ts.map +1 -0
- package/dist/formal-runtime-map.js +23 -0
- package/dist/formal-runtime-map.js.map +1 -0
- package/dist/index.d.ts +1003 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1737 -0
- package/dist/index.js.map +1 -0
- package/dist/key-registry.d.ts +60 -0
- package/dist/key-registry.d.ts.map +1 -0
- package/dist/key-registry.js +144 -0
- package/dist/key-registry.js.map +1 -0
- package/dist/mcp.d.ts +53 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +112 -0
- package/dist/mcp.js.map +1 -0
- package/dist/metering.d.ts +80 -0
- package/dist/metering.d.ts.map +1 -0
- package/dist/metering.js +227 -0
- package/dist/metering.js.map +1 -0
- package/dist/metrics.d.ts +68 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +242 -0
- package/dist/metrics.js.map +1 -0
- package/dist/network-witness.d.ts +167 -0
- package/dist/network-witness.d.ts.map +1 -0
- package/dist/network-witness.js +520 -0
- package/dist/network-witness.js.map +1 -0
- package/dist/proposal-to-effect.d.ts +146 -0
- package/dist/proposal-to-effect.d.ts.map +1 -0
- package/dist/proposal-to-effect.js +427 -0
- package/dist/proposal-to-effect.js.map +1 -0
- package/dist/protocol-state.d.ts +141 -0
- package/dist/protocol-state.d.ts.map +1 -0
- package/dist/protocol-state.js +106 -0
- package/dist/protocol-state.js.map +1 -0
- package/dist/receipt-program.d.ts +59 -0
- package/dist/receipt-program.d.ts.map +1 -0
- package/dist/receipt-program.js +1053 -0
- package/dist/receipt-program.js.map +1 -0
- package/dist/reliance-kernel.d.ts +66 -0
- package/dist/reliance-kernel.d.ts.map +1 -0
- package/dist/reliance-kernel.js +103 -0
- package/dist/reliance-kernel.js.map +1 -0
- package/dist/reliance-packet.d.ts +67 -0
- package/dist/reliance-packet.d.ts.map +1 -0
- package/dist/reliance-packet.js +176 -0
- package/dist/reliance-packet.js.map +1 -0
- package/dist/remedy-program-postgres.d.ts +37 -0
- package/dist/remedy-program-postgres.d.ts.map +1 -0
- package/dist/remedy-program-postgres.js +291 -0
- package/dist/remedy-program-postgres.js.map +1 -0
- package/dist/remedy-program-receipt.d.ts +97 -0
- package/dist/remedy-program-receipt.d.ts.map +1 -0
- package/dist/remedy-program-receipt.js +817 -0
- package/dist/remedy-program-receipt.js.map +1 -0
- package/dist/remedy-program.d.ts +76 -0
- package/dist/remedy-program.d.ts.map +1 -0
- package/dist/remedy-program.js +1346 -0
- package/dist/remedy-program.js.map +1 -0
- package/dist/reports/art14.d.ts +101 -0
- package/dist/reports/art14.d.ts.map +1 -0
- package/dist/reports/art14.js +340 -0
- package/dist/reports/art14.js.map +1 -0
- package/dist/reports/assurance-package.d.ts +197 -0
- package/dist/reports/assurance-package.d.ts.map +1 -0
- package/dist/reports/assurance-package.js +313 -0
- package/dist/reports/assurance-package.js.map +1 -0
- package/dist/reports/auditor-workpaper.d.ts +194 -0
- package/dist/reports/auditor-workpaper.d.ts.map +1 -0
- package/dist/reports/auditor-workpaper.js +545 -0
- package/dist/reports/auditor-workpaper.js.map +1 -0
- package/dist/reports/external-verification.d.ts +76 -0
- package/dist/reports/external-verification.d.ts.map +1 -0
- package/dist/reports/external-verification.js +209 -0
- package/dist/reports/external-verification.js.map +1 -0
- package/dist/reports/reperform.d.ts +122 -0
- package/dist/reports/reperform.d.ts.map +1 -0
- package/dist/reports/reperform.js +432 -0
- package/dist/reports/reperform.js.map +1 -0
- package/dist/reports/underwriter.d.ts +127 -0
- package/dist/reports/underwriter.d.ts.map +1 -0
- package/dist/reports/underwriter.js +348 -0
- package/dist/reports/underwriter.js.map +1 -0
- package/dist/retention.d.ts +88 -0
- package/dist/retention.d.ts.map +1 -0
- package/dist/retention.js +90 -0
- package/dist/retention.js.map +1 -0
- package/dist/roster.d.ts +113 -0
- package/dist/roster.d.ts.map +1 -0
- package/dist/roster.js +261 -0
- package/dist/roster.js.map +1 -0
- package/dist/runtime-monitor.d.ts +132 -0
- package/dist/runtime-monitor.d.ts.map +1 -0
- package/dist/runtime-monitor.js +197 -0
- package/dist/runtime-monitor.js.map +1 -0
- package/dist/settlement.d.ts +68 -0
- package/dist/settlement.d.ts.map +1 -0
- package/dist/settlement.js +306 -0
- package/dist/settlement.js.map +1 -0
- package/dist/siem.d.ts +261 -0
- package/dist/siem.d.ts.map +1 -0
- package/dist/siem.js +247 -0
- package/dist/siem.js.map +1 -0
- package/dist/store-postgres.d.ts +107 -0
- package/dist/store-postgres.d.ts.map +1 -0
- package/dist/store-postgres.js +152 -0
- package/dist/store-postgres.js.map +1 -0
- package/dist/store.d.ts +95 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +202 -0
- package/dist/store.js.map +1 -0
- package/dist/strict-json.d.ts +14 -0
- package/dist/strict-json.d.ts.map +1 -0
- package/dist/strict-json.js +132 -0
- package/dist/strict-json.js.map +1 -0
- package/dist/trust-program-adapters.d.ts +122 -0
- package/dist/trust-program-adapters.d.ts.map +1 -0
- package/dist/trust-program-adapters.js +802 -0
- package/dist/trust-program-adapters.js.map +1 -0
- package/dist/trust-program-postgres.d.ts +41 -0
- package/dist/trust-program-postgres.d.ts.map +1 -0
- package/dist/trust-program-postgres.js +346 -0
- package/dist/trust-program-postgres.js.map +1 -0
- package/dist/trust-program-revocation.d.ts +206 -0
- package/dist/trust-program-revocation.d.ts.map +1 -0
- package/dist/trust-program-revocation.js +600 -0
- package/dist/trust-program-revocation.js.map +1 -0
- package/dist/trust-program.d.ts +197 -0
- package/dist/trust-program.d.ts.map +1 -0
- package/dist/trust-program.js +1351 -0
- package/dist/trust-program.js.map +1 -0
- package/dist/witness-postgres.d.ts +43 -0
- package/dist/witness-postgres.d.ts.map +1 -0
- package/dist/witness-postgres.js +92 -0
- package/dist/witness-postgres.js.map +1 -0
- package/dist/zk-range-proof.d.ts +78 -0
- package/dist/zk-range-proof.d.ts.map +1 -0
- package/dist/zk-range-proof.js +228 -0
- package/dist/zk-range-proof.js.map +1 -0
- package/eg1-conformance.js +3 -404
- package/enterprise.js +3 -180
- package/ep-assure.mjs +1 -0
- package/evidence-postgres.js +3 -356
- package/evidence.js +4 -360
- package/execution-binding.js +3 -212
- package/formal-runtime-map.js +4 -0
- package/index.js +4 -1249
- package/key-registry.js +3 -134
- package/mcp.js +3 -109
- package/metering.js +3 -226
- package/metrics.js +3 -231
- package/network-witness.js +3 -499
- package/package.json +35 -4
- package/proposal-to-effect.js +4 -0
- package/receipt-program.js +4 -0
- package/reliance-kernel.js +3 -112
- package/reliance-packet.js +3 -175
- package/remedy-program-postgres.js +4 -0
- package/remedy-program-receipt.js +4 -0
- package/remedy-program.js +4 -0
- package/reports/art14.js +0 -0
- package/reports/assurance-package.js +2 -312
- package/reports/auditor-workpaper.js +3 -537
- package/reports/external-verification.js +3 -222
- package/reports/reperform.js +3 -424
- package/reports/underwriter.js +3 -339
- package/retention.js +3 -84
- package/roster.js +3 -264
- package/runtime-monitor.js +4 -0
- package/settlement.js +3 -299
- package/siem.js +3 -235
- package/src/action-control-manifest.ts +424 -0
- package/src/action-escrow-custodian.ts +427 -0
- package/src/action-escrow-evidence.ts +1178 -0
- package/src/action-escrow-package.ts +1821 -0
- package/src/action-escrow-postgres.ts +366 -0
- package/src/action-escrow-state.ts +498 -0
- package/src/action-escrow-verifiers.ts +484 -0
- package/src/action-escrow.ts +3039 -0
- package/src/action-packs.ts +170 -0
- package/src/adapters/_kit.ts +117 -0
- package/src/adapters/aws.ts +142 -0
- package/src/adapters/cloudflare.ts +78 -0
- package/src/adapters/gcp.ts +71 -0
- package/src/adapters/github.ts +110 -0
- package/src/adapters/jira.ts +56 -0
- package/src/adapters/k8s.ts +71 -0
- package/src/adapters/linear.ts +56 -0
- package/src/adapters/salesforce.ts +56 -0
- package/src/adapters/stripe.ts +82 -0
- package/src/adapters/supabase.ts +122 -0
- package/src/adapters/terraform.ts +60 -0
- package/src/adapters/vercel.ts +85 -0
- package/src/aec-execution.ts +354 -0
- package/src/breakglass.ts +647 -0
- package/src/capability-receipt.ts +1258 -0
- package/src/cf1-conformance.ts +120 -0
- package/src/challenge-store.ts +70 -0
- package/src/control-plane.ts +374 -0
- package/src/coverage.ts +832 -0
- package/src/deployment-attestation.ts +259 -0
- package/src/eg1-conformance.ts +471 -0
- package/src/enterprise.ts +195 -0
- package/src/evidence-postgres.ts +374 -0
- package/src/evidence.ts +367 -0
- package/src/execution-binding.ts +236 -0
- package/src/formal-runtime-map.ts +24 -0
- package/src/index.ts +2127 -0
- package/src/key-registry.ts +150 -0
- package/src/mcp.ts +120 -0
- package/src/metering.ts +237 -0
- package/src/metrics.ts +232 -0
- package/src/network-witness.ts +585 -0
- package/src/proposal-to-effect.ts +571 -0
- package/src/protocol-state.ts +143 -0
- package/src/protocol-state.typecheck.ts +94 -0
- package/src/receipt-program.ts +1105 -0
- package/src/reliance-kernel.ts +119 -0
- package/src/reliance-packet.ts +206 -0
- package/src/remedy-program-postgres.ts +367 -0
- package/src/remedy-program-receipt.ts +891 -0
- package/src/remedy-program.ts +1388 -0
- package/src/reports/art14.ts +361 -0
- package/src/reports/assurance-package.ts +330 -0
- package/src/reports/auditor-workpaper.ts +558 -0
- package/src/reports/external-verification.ts +232 -0
- package/src/reports/reperform.ts +441 -0
- package/src/reports/underwriter.ts +356 -0
- package/src/retention.ts +100 -0
- package/src/roster.ts +273 -0
- package/src/runtime-monitor.ts +217 -0
- package/src/settlement.ts +313 -0
- package/src/siem.ts +247 -0
- package/src/store-postgres.ts +167 -0
- package/src/store.ts +214 -0
- package/src/strict-json.ts +115 -0
- package/src/trust-program-adapters.ts +847 -0
- package/src/trust-program-postgres.ts +429 -0
- package/src/trust-program-revocation.ts +751 -0
- package/src/trust-program.ts +1460 -0
- package/src/witness-postgres.ts +106 -0
- package/src/zk-range-proof.ts +250 -0
- package/store-postgres.js +3 -161
- package/store.js +4 -198
- package/strict-json.js +3 -102
- package/trust-program-adapters.js +4 -0
- package/trust-program-postgres.js +4 -0
- package/trust-program-revocation.js +4 -0
- package/trust-program.js +4 -0
- package/witness-postgres.js +3 -96
- package/zk-range-proof.js +4 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* EP-ASSURANCE-PACKAGE-v1 — the reliance assurance layer.
|
|
4
|
+
*
|
|
5
|
+
* The layer above the reliance kernel. The kernel answers "may this party rely on
|
|
6
|
+
* this action?" The assurance package answers the question an INDEPENDENT assurer
|
|
7
|
+
* (an audit firm, a regulator, an insurer) asks: "can I reproduce, test, and
|
|
8
|
+
* attest that an organization's automated actions were governed by admissible
|
|
9
|
+
* evidence under the organization's OWN pinned rule?"
|
|
10
|
+
*
|
|
11
|
+
* Two halves, mirroring the re-performance discipline of reperform.js:
|
|
12
|
+
* buildAssurancePackage(decisions, ...) the organization bundles its
|
|
13
|
+
* automated decisions + the evidence each relied on into ONE portable,
|
|
14
|
+
* content-addressed package (action, receipt, profile, authority proof,
|
|
15
|
+
* revocation check, consumption, denial/exception history, policy hash).
|
|
16
|
+
* reperformAssurancePackage(pkg, ...) the assurer RE-PERFORMS every
|
|
17
|
+
* reliance verdict offline from that evidence, TRUSTING NOTHING the package
|
|
18
|
+
* asserts: it recomputes each verdict with evaluateReliance, compares to the
|
|
19
|
+
* verdict the org's runtime CLAIMED (drift = a control failure the assurer
|
|
20
|
+
* caught), maps every verdict to a control objective, and emits an
|
|
21
|
+
* auditor-style workpaper. It does not conclude; the assurer concludes.
|
|
22
|
+
*
|
|
23
|
+
* PCAOB AS 1105 alignment (why this is audit evidence): the source is
|
|
24
|
+
* cryptographic, the decision trail is immutable and content-addressed, the rule
|
|
25
|
+
* is a pinned profile, and the verdict is re-performable directly. This module
|
|
26
|
+
* SUPPORTS a re-performance procedure; it never issues an opinion.
|
|
27
|
+
*/
|
|
28
|
+
import { hashCanonical } from '../execution-binding.js';
|
|
29
|
+
import { evaluateReliance, RELIANCE_VERDICTS } from '@emilia-protocol/verify/reliance';
|
|
30
|
+
|
|
31
|
+
export const ASSURANCE_PACKAGE_VERSION = 'EP-ASSURANCE-PACKAGE-v1';
|
|
32
|
+
export const ASSURANCE_REPERFORMANCE_VERSION = 'EP-ASSURANCE-REPERFORMANCE-v1';
|
|
33
|
+
|
|
34
|
+
export { RELIANCE_VERDICTS };
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The reliance control catalog: every reliance verdict maps to the control
|
|
38
|
+
* objective it exercises. A `rely` shows the control PASSING; every do_not_rely_*
|
|
39
|
+
* shows the control OPERATING (it refused a non-admissible action). Denials are
|
|
40
|
+
* the control working, not the control failing.
|
|
41
|
+
*/
|
|
42
|
+
export const RELIANCE_CONTROL_CATALOG = Object.freeze({
|
|
43
|
+
'RC-1': { objective: 'Only a human with valid organization-bound, scoped authority for THIS exact action may authorize it', verdicts: ['do_not_rely_authority_missing', 'do_not_rely_authority_subject_mismatch', 'do_not_rely_authority_organization_mismatch', 'do_not_rely_authority_revoked', 'do_not_rely_authority_expired', 'do_not_rely_scope_mismatch', 'do_not_rely_amount_exceeded', 'do_not_rely_registry_unavailable'] },
|
|
44
|
+
'RC-2': { objective: 'Authorization uses a device-bound named-human ceremony (Class-A or quorum)', verdicts: ['do_not_rely_no_class_a', 'do_not_rely_quorum_unsatisfied'] },
|
|
45
|
+
'RC-3': { objective: 'The action conforms to a pinned, accepted policy', verdicts: ['do_not_rely_policy_mismatch'] },
|
|
46
|
+
'RC-4': { objective: 'Authorization is consumed exactly once (no replay)', verdicts: ['do_not_rely_already_consumed'] },
|
|
47
|
+
'RC-5': { objective: 'Reliance is evaluated against fresh revocation state', verdicts: ['do_not_rely_stale_revocation'] },
|
|
48
|
+
'RC-6': { objective: 'Evidence is signed by a trusted issuer and evaluated under a pinned rule', verdicts: ['do_not_rely_unsigned', 'do_not_rely_untrusted_issuer', 'do_not_rely_no_profile'] },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const VERDICT_TO_CONTROL = Object.freeze(
|
|
52
|
+
Object.entries(RELIANCE_CONTROL_CATALOG).reduce((m, [cid, c]) => {
|
|
53
|
+
for (const v of c.verdicts) m[v] = cid;
|
|
54
|
+
return m;
|
|
55
|
+
}, {}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
/** Which control objective a verdict exercises (rely passes ALL, so returns null). */
|
|
59
|
+
function controlForVerdict(verdict) {
|
|
60
|
+
if (verdict === 'rely') return null;
|
|
61
|
+
return VERDICT_TO_CONTROL[verdict] || null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function toIso(now) {
|
|
65
|
+
const ms = typeof now === 'function' ? now() : now;
|
|
66
|
+
return new Date(ms == null ? 0 : ms).toISOString();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function portableJsonCopy(value, active = new Set()) {
|
|
70
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean') return value;
|
|
71
|
+
if (typeof value === 'number') {
|
|
72
|
+
if (!Number.isFinite(value) || Object.is(value, -0)) {
|
|
73
|
+
throw new TypeError('assurance-package: value is not canonical JSON');
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
if (typeof value !== 'object') {
|
|
78
|
+
throw new TypeError('assurance-package: value is not JSON');
|
|
79
|
+
}
|
|
80
|
+
if (active.has(value)) throw new TypeError('assurance-package: cyclic value');
|
|
81
|
+
active.add(value);
|
|
82
|
+
try {
|
|
83
|
+
if (Array.isArray(value)) return value.map((entry) => portableJsonCopy(entry, active));
|
|
84
|
+
const prototype = Object.getPrototypeOf(value);
|
|
85
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
86
|
+
throw new TypeError('assurance-package: value must use plain JSON objects');
|
|
87
|
+
}
|
|
88
|
+
return Object.fromEntries(
|
|
89
|
+
Object.entries(value).map(([key, entry]) => [key, portableJsonCopy(entry, active)]),
|
|
90
|
+
);
|
|
91
|
+
} finally {
|
|
92
|
+
active.delete(value);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Bundle N automated reliance decisions + the evidence each relied on into one
|
|
98
|
+
* portable, content-addressed assurance package. Does NOT re-perform (that is the
|
|
99
|
+
* assurer's independent step); it packages faithfully, including the verdict the
|
|
100
|
+
* org's runtime CLAIMED, so drift is checkable later.
|
|
101
|
+
*
|
|
102
|
+
* @param {Array<object>} decisions each: { decision_id, action, receipt, quorum?,
|
|
103
|
+
* authority_proof?, revocation_state?, consumption?, stated_verdict? }
|
|
104
|
+
* @param {object} [opts]
|
|
105
|
+
* @param {object} [opts.profile] the pinned EP-RELIANCE-PROFILE-v1 the org operated under
|
|
106
|
+
* @param {object} [opts.organization] { id, name } (no PHI)
|
|
107
|
+
* @param {number|Function} [opts.now]
|
|
108
|
+
* @returns {object} EP-ASSURANCE-PACKAGE-v1
|
|
109
|
+
*/
|
|
110
|
+
export function buildAssurancePackage(decisions: any[] = [], {
|
|
111
|
+
profile, organization = null, now = 0,
|
|
112
|
+
}: {
|
|
113
|
+
profile?: Record<string, any> | null;
|
|
114
|
+
organization?: Record<string, any> | null;
|
|
115
|
+
now?: number | (() => number);
|
|
116
|
+
} = {}) {
|
|
117
|
+
if (!Array.isArray(decisions)) throw new Error('assurance-package: decisions must be an array');
|
|
118
|
+
const items = decisions.map((d, i) => {
|
|
119
|
+
const source = portableJsonCopy(d ?? {});
|
|
120
|
+
const decision_id = source.decision_id ?? `decision-${i}`;
|
|
121
|
+
return {
|
|
122
|
+
decision_id,
|
|
123
|
+
action: source.action ?? null,
|
|
124
|
+
policy_hash: source.action?.policy_hash ?? null,
|
|
125
|
+
stated_verdict: typeof source.stated_verdict === 'string' ? source.stated_verdict : null,
|
|
126
|
+
evidence: {
|
|
127
|
+
receipt: source.receipt ?? null,
|
|
128
|
+
quorum: source.quorum ?? null,
|
|
129
|
+
authority_proof: source.authority_proof ?? null,
|
|
130
|
+
revocation_state: source.revocation_state ?? null,
|
|
131
|
+
consumption: source.consumption ?? null,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
// Denial/exception history = the decisions the org itself recorded as refused.
|
|
136
|
+
const exceptions = items.filter((it) => it.stated_verdict && it.stated_verdict !== 'rely')
|
|
137
|
+
.map((it) => ({ decision_id: it.decision_id, stated_verdict: it.stated_verdict, control_id: controlForVerdict(it.stated_verdict) }));
|
|
138
|
+
|
|
139
|
+
const profileCopy = profile == null ? null : portableJsonCopy(profile);
|
|
140
|
+
const body = {
|
|
141
|
+
'@version': ASSURANCE_PACKAGE_VERSION,
|
|
142
|
+
organization: organization == null ? null : portableJsonCopy(organization),
|
|
143
|
+
reliance_profile: profileCopy,
|
|
144
|
+
profile_hash: profileCopy ? hashCanonical(profileCopy) : null,
|
|
145
|
+
control_catalog: RELIANCE_CONTROL_CATALOG,
|
|
146
|
+
decisions: items,
|
|
147
|
+
exception_history: exceptions,
|
|
148
|
+
counts: {
|
|
149
|
+
decisions: items.length,
|
|
150
|
+
stated_admissible: items.filter((it) => it.stated_verdict === 'rely').length,
|
|
151
|
+
stated_refused: items.filter((it) => it.stated_verdict && it.stated_verdict !== 'rely').length,
|
|
152
|
+
stated_unknown: items.filter((it) => !it.stated_verdict).length,
|
|
153
|
+
},
|
|
154
|
+
assembled_at: toIso(now),
|
|
155
|
+
};
|
|
156
|
+
// Content address over everything EXCEPT the timestamp (so the same evidence
|
|
157
|
+
// yields the same digest regardless of when it was packaged).
|
|
158
|
+
const { assembled_at: _t, ...digestScope } = body;
|
|
159
|
+
return { ...body, package_digest: hashCanonical(digestScope) };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* INDEPENDENT re-performance. Recompute every reliance verdict offline from the
|
|
164
|
+
* packaged evidence under the package's pinned profile and AUDITOR-supplied keys,
|
|
165
|
+
* trusting nothing the package asserts. Detect drift (recomputed ≠ stated), map
|
|
166
|
+
* to control objectives, and emit an auditor-style workpaper. Conclusion fields
|
|
167
|
+
* are ALWAYS null: the assurer concludes, not this tool.
|
|
168
|
+
*
|
|
169
|
+
* @param {object} pkg an EP-ASSURANCE-PACKAGE-v1
|
|
170
|
+
* @param {object} opts
|
|
171
|
+
* @param {object} [opts.approverKeys] auditor-pinned approver keys (out of band)
|
|
172
|
+
* @param {string|null} [opts.logPublicKey] auditor-pinned transparency-log key
|
|
173
|
+
* @param {string|null} [opts.rpId]
|
|
174
|
+
* @param {string[]} [opts.allowedOrigins]
|
|
175
|
+
* @param {object} [opts.revokerKeys]
|
|
176
|
+
* @param {(key:object)=>boolean} [opts.isConsumed] auditor-owned consumption lookup
|
|
177
|
+
* @param {number|string|Date|Function} [opts.now] reliance-evaluation clock (pin for determinism)
|
|
178
|
+
* @returns {object} EP-ASSURANCE-REPERFORMANCE-v1
|
|
179
|
+
*/
|
|
180
|
+
export function reperformAssurancePackage(pkg, {
|
|
181
|
+
approverKeys = {}, logPublicKey = null, rpId = null, allowedOrigins = [], revokerKeys = {}, isConsumed, now = 0,
|
|
182
|
+
}: {
|
|
183
|
+
approverKeys?: Record<string, any>;
|
|
184
|
+
logPublicKey?: string | null;
|
|
185
|
+
rpId?: string | null;
|
|
186
|
+
allowedOrigins?: string[];
|
|
187
|
+
revokerKeys?: Record<string, any>;
|
|
188
|
+
isConsumed?: (key: any) => boolean;
|
|
189
|
+
now?: number | (() => number);
|
|
190
|
+
} = {}) {
|
|
191
|
+
if (!pkg || pkg['@version'] !== ASSURANCE_PACKAGE_VERSION) throw new Error('assurance-reperform: not an EP-ASSURANCE-PACKAGE-v1');
|
|
192
|
+
const profile = pkg.reliance_profile;
|
|
193
|
+
const evalOpts = { approverKeys, logPublicKey, rpId, allowedOrigins, revokerKeys, ...(typeof isConsumed === 'function' ? { isConsumed } : {}) };
|
|
194
|
+
const relianceNow = typeof now === 'function' ? now() : now;
|
|
195
|
+
|
|
196
|
+
const results = (Array.isArray(pkg.decisions) ? pkg.decisions : []).map((it) => {
|
|
197
|
+
const ev = it.evidence || {};
|
|
198
|
+
const input = {
|
|
199
|
+
action: it.action || {},
|
|
200
|
+
receipt: ev.receipt,
|
|
201
|
+
quorum: ev.quorum || undefined,
|
|
202
|
+
authority_proof: ev.authority_proof || undefined,
|
|
203
|
+
revocation_state: ev.revocation_state || undefined,
|
|
204
|
+
consumption: ev.consumption || undefined,
|
|
205
|
+
relying_party_profile: profile,
|
|
206
|
+
now: relianceNow,
|
|
207
|
+
};
|
|
208
|
+
let recomputed;
|
|
209
|
+
try {
|
|
210
|
+
recomputed = evaluateReliance(input, evalOpts);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
const message = (err as { message?: unknown } | null | undefined)?.message;
|
|
213
|
+
recomputed = { verdict: 'do_not_rely_unsigned', rely: false, reasons: [`reperform_error:${message || 'threw'}`] };
|
|
214
|
+
}
|
|
215
|
+
const recomputed_verdict = recomputed.verdict;
|
|
216
|
+
const stated_verdict = it.stated_verdict ?? null;
|
|
217
|
+
// Drift: the org's runtime claimed one outcome, independent re-performance
|
|
218
|
+
// computed another. A claimed `rely` that recomputes to a refusal is the
|
|
219
|
+
// material finding — the org relied on evidence that does not support reliance.
|
|
220
|
+
const drift = stated_verdict !== null && stated_verdict !== recomputed_verdict;
|
|
221
|
+
return {
|
|
222
|
+
decision_id: it.decision_id,
|
|
223
|
+
action_type: it.action?.action_type ?? null,
|
|
224
|
+
stated_verdict,
|
|
225
|
+
recomputed_verdict,
|
|
226
|
+
admissible: recomputed_verdict === 'rely',
|
|
227
|
+
drift,
|
|
228
|
+
drift_severity: drift ? (stated_verdict === 'rely' ? 'relied_on_inadmissible_evidence' : 'refused_admissible_or_reclassified') : null,
|
|
229
|
+
control_id: controlForVerdict(recomputed_verdict),
|
|
230
|
+
reasons: recomputed.reasons || [],
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const byVerdict = Object.create(null);
|
|
235
|
+
const byControl = Object.create(null);
|
|
236
|
+
let admissible = 0;
|
|
237
|
+
let refused = 0;
|
|
238
|
+
let drift = 0;
|
|
239
|
+
for (const r of results) {
|
|
240
|
+
byVerdict[r.recomputed_verdict] = (byVerdict[r.recomputed_verdict] || 0) + 1;
|
|
241
|
+
if (r.admissible) admissible += 1; else refused += 1;
|
|
242
|
+
if (r.drift) drift += 1;
|
|
243
|
+
if (r.control_id) byControl[r.control_id] = (byControl[r.control_id] || 0) + 1;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Recompute the package digest from the package's OWN contents rather than
|
|
247
|
+
// trusting pkg.package_digest. "No value the package asserts is trusted" has to
|
|
248
|
+
// include the digest: copying the stated one verbatim would let a tampered
|
|
249
|
+
// package carry a lying content-address through re-performance unchecked. Mirror
|
|
250
|
+
// buildAssurancePackage's digestScope exactly (body minus assembled_at and the
|
|
251
|
+
// digest field itself), then compare.
|
|
252
|
+
const { assembled_at: _statedAt, package_digest: _statedDigest, ...digestScope } = pkg;
|
|
253
|
+
const recomputedPackageDigest = hashCanonical(digestScope);
|
|
254
|
+
const packageDigestVerified = pkg.package_digest != null && recomputedPackageDigest === pkg.package_digest;
|
|
255
|
+
|
|
256
|
+
const doc = {
|
|
257
|
+
'@version': ASSURANCE_REPERFORMANCE_VERSION,
|
|
258
|
+
product: 'EMILIA Reliance Assurance',
|
|
259
|
+
package_digest: recomputedPackageDigest,
|
|
260
|
+
stated_package_digest: pkg.package_digest ?? null,
|
|
261
|
+
package_digest_verified: packageDigestVerified,
|
|
262
|
+
profile_hash: pkg.profile_hash ?? null,
|
|
263
|
+
generated_at: toIso(now),
|
|
264
|
+
honesty: {
|
|
265
|
+
reperforms:
|
|
266
|
+
'Independent recomputation of every reliance verdict from the packaged evidence, under the package\'s pinned '
|
|
267
|
+
+ 'EP-RELIANCE-PROFILE-v1 and auditor-supplied keys, using the offline reliance kernel. No value the package '
|
|
268
|
+
+ 'asserts (including the stated verdict) is trusted; the stated verdict is compared, never relied on.',
|
|
269
|
+
does_not_establish: [
|
|
270
|
+
'Completeness of the decision population: decisions withheld before packaging are not detectable from the package alone. Bind the population to an externally anchored count to close this.',
|
|
271
|
+
'Runtime freshness or one-time consumption AT THE MOMENT OF DECISION: those were live properties; re-performance checks the evidence as packaged, not the runtime state that existed then.',
|
|
272
|
+
'Issuer, approver, and registrar key custody, enrollment, or identity proofing, which remain external trust roots the auditor supplies out of band.',
|
|
273
|
+
'The business correctness or wisdom of any authorized action.',
|
|
274
|
+
],
|
|
275
|
+
status: 'Support for an audit re-performance procedure. This document does not conclude, opine, or certify; any conclusion is the auditor\'s.',
|
|
276
|
+
},
|
|
277
|
+
population: {
|
|
278
|
+
decisions: results.length,
|
|
279
|
+
admissible,
|
|
280
|
+
refused,
|
|
281
|
+
drift,
|
|
282
|
+
relied_on_inadmissible_evidence: results.filter((r) => r.drift_severity === 'relied_on_inadmissible_evidence').length,
|
|
283
|
+
by_recomputed_verdict: byVerdict,
|
|
284
|
+
by_control: byControl,
|
|
285
|
+
},
|
|
286
|
+
control_catalog: RELIANCE_CONTROL_CATALOG,
|
|
287
|
+
results,
|
|
288
|
+
reperformance_digest: null as string | null, // filled below
|
|
289
|
+
// Conclusion fields are ALWAYS null: a machine may support re-performance, it
|
|
290
|
+
// may never fill in the auditor's sign-off. A renderer must refuse to print a
|
|
291
|
+
// non-null conclusion here.
|
|
292
|
+
conclusion: { supportable: null, opinion: null, signed_off_by: null },
|
|
293
|
+
};
|
|
294
|
+
// Deterministic re-performance digest over the recomputed results + population
|
|
295
|
+
// (excludes timestamps), so a second assurer reproduces it byte-for-byte.
|
|
296
|
+
doc.reperformance_digest = hashCanonical({ package_digest: doc.package_digest, population: doc.population, results });
|
|
297
|
+
return doc;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Render a plain-text auditor workpaper. Refuses to print a filled conclusion. */
|
|
301
|
+
export function renderAssuranceWorkpaper(doc) {
|
|
302
|
+
if (!doc || doc['@version'] !== ASSURANCE_REPERFORMANCE_VERSION) throw new Error('render: not an EP-ASSURANCE-REPERFORMANCE-v1');
|
|
303
|
+
if (doc.conclusion && (doc.conclusion.supportable !== null || doc.conclusion.opinion !== null || doc.conclusion.signed_off_by !== null)) {
|
|
304
|
+
throw new Error('render refused: conclusion fields must be null (the auditor concludes, not the tool)');
|
|
305
|
+
}
|
|
306
|
+
const p = doc.population;
|
|
307
|
+
const lines: string[] = [];
|
|
308
|
+
lines.push(`EMILIA Reliance Assurance — re-performance workpaper (${doc['@version']})`);
|
|
309
|
+
lines.push(`package_digest: ${doc.package_digest} (recomputed)`);
|
|
310
|
+
lines.push(`package_digest match: ${doc.package_digest_verified ? 'YES — recomputed digest equals the package\'s stated digest' : 'NO — stated digest does NOT match recomputed contents (tamper or drift)'}`);
|
|
311
|
+
lines.push(`reperformance_digest: ${doc.reperformance_digest}`);
|
|
312
|
+
lines.push('');
|
|
313
|
+
lines.push(`Population: ${p.decisions} decisions | admissible(rely): ${p.admissible} | refused: ${p.refused} | drift: ${p.drift}`);
|
|
314
|
+
lines.push(`Relied on INADMISSIBLE evidence (claimed rely, recomputed refusal): ${p.relied_on_inadmissible_evidence}`);
|
|
315
|
+
lines.push('');
|
|
316
|
+
lines.push('By recomputed verdict:');
|
|
317
|
+
for (const [v, n] of Object.entries(p.by_recomputed_verdict)) lines.push(` ${v}: ${n}`);
|
|
318
|
+
lines.push('');
|
|
319
|
+
lines.push('Control objectives exercised (denials are the control operating):');
|
|
320
|
+
for (const [cid, n] of Object.entries(p.by_control)) lines.push(` ${cid} (${RELIANCE_CONTROL_CATALOG[cid].objective}): ${n}`);
|
|
321
|
+
lines.push('');
|
|
322
|
+
const drifts = doc.results.filter((r) => r.drift);
|
|
323
|
+
if (drifts.length) {
|
|
324
|
+
lines.push('DRIFT (independent re-performance disagrees with the runtime\'s stated verdict):');
|
|
325
|
+
for (const r of drifts) lines.push(` ${r.decision_id}: stated=${r.stated_verdict} recomputed=${r.recomputed_verdict} [${r.drift_severity}]`);
|
|
326
|
+
lines.push('');
|
|
327
|
+
}
|
|
328
|
+
lines.push('Conclusion: NULL by construction. The auditor concludes; this workpaper only supports the procedure.');
|
|
329
|
+
return lines.join('\n');
|
|
330
|
+
}
|