@agent-ix/quoin 0.22.5 → 0.23.1
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/dist/{advisor-BkgwDKvQ.js → advisor-B0rESCx1.js} +1 -1
- package/dist/{auditor-C3bSmPD_.js → auditor-Dd3i9Aqx.js} +2 -2
- package/dist/{base-CqKNs2Kd.js → base-gAClyCNd.js} +1 -1
- package/dist/change-assurance/attestations.d.ts +7 -0
- package/dist/change-assurance/attestations.d.ts.map +1 -0
- package/dist/change-assurance/index.d.ts +14 -0
- package/dist/change-assurance/index.d.ts.map +1 -0
- package/dist/change-assurance/integrity.d.ts +11 -0
- package/dist/change-assurance/integrity.d.ts.map +1 -0
- package/dist/change-assurance/records.d.ts +22 -0
- package/dist/change-assurance/records.d.ts.map +1 -0
- package/dist/change-assurance/schema-assets.d.ts +8 -0
- package/dist/change-assurance/schema-assets.d.ts.map +1 -0
- package/dist/change-assurance/store.d.ts +18 -0
- package/dist/change-assurance/store.d.ts.map +1 -0
- package/dist/change-assurance/types.d.ts +180 -0
- package/dist/change-assurance/types.d.ts.map +1 -0
- package/dist/change-assurance/verify.d.ts +4 -0
- package/dist/change-assurance/verify.d.ts.map +1 -0
- package/dist/change-assurance-CyKLPeKa.js +1236 -0
- package/dist/cli.js +1 -1
- package/dist/commands/advise.js +19 -19
- package/dist/commands/assurance.js +20 -20
- package/dist/commands/catalog/list.js +2 -2
- package/dist/commands/catalog/methods.js +3 -3
- package/dist/commands/catalog/show.js +2 -2
- package/dist/commands/catalog/validate.js +2 -2
- package/dist/commands/change-assurance/common.d.ts +37 -0
- package/dist/commands/change-assurance/common.d.ts.map +1 -0
- package/dist/commands/change-assurance/index.d.ts +8 -0
- package/dist/commands/change-assurance/index.d.ts.map +1 -0
- package/dist/commands/change-assurance/index.js +12 -0
- package/dist/commands/change-assurance/intake.d.ts +15 -0
- package/dist/commands/change-assurance/intake.d.ts.map +1 -0
- package/dist/commands/change-assurance/intake.js +53 -0
- package/dist/commands/change-assurance/receipt.d.ts +21 -0
- package/dist/commands/change-assurance/receipt.d.ts.map +1 -0
- package/dist/commands/change-assurance/receipt.js +99 -0
- package/dist/commands/change-assurance/recover.d.ts +13 -0
- package/dist/commands/change-assurance/recover.d.ts.map +1 -0
- package/dist/commands/change-assurance/recover.js +29 -0
- package/dist/commands/change-assurance/schema.d.ts +13 -0
- package/dist/commands/change-assurance/schema.d.ts.map +1 -0
- package/dist/commands/change-assurance/schema.js +40 -0
- package/dist/commands/change-assurance/seal-attestation.d.ts +15 -0
- package/dist/commands/change-assurance/seal-attestation.d.ts.map +1 -0
- package/dist/commands/change-assurance/seal-attestation.js +58 -0
- package/dist/commands/change-assurance/seal-record.d.ts +14 -0
- package/dist/commands/change-assurance/seal-record.d.ts.map +1 -0
- package/dist/commands/change-assurance/seal-record.js +53 -0
- package/dist/commands/change-assurance/verify-receipt.d.ts +13 -0
- package/dist/commands/change-assurance/verify-receipt.d.ts.map +1 -0
- package/dist/commands/change-assurance/verify-receipt.js +41 -0
- package/dist/commands/completeness.js +2 -2
- package/dist/commands/config/doctor.js +1 -1
- package/dist/commands/config/edit.js +1 -1
- package/dist/commands/config/get.js +1 -1
- package/dist/commands/config/set.js +1 -1
- package/dist/commands/evidence/affirm.js +19 -19
- package/dist/commands/evidence/audit.js +26 -26
- package/dist/commands/evidence/baseline.js +21 -21
- package/dist/commands/evidence/gc.js +3 -3
- package/dist/commands/evidence/index.js +1 -1
- package/dist/commands/evidence/inspect-mocks.js +4 -4
- package/dist/commands/evidence/record.d.ts.map +1 -1
- package/dist/commands/evidence/record.js +28 -24
- package/dist/commands/graph/change-impact.d.ts +16 -0
- package/dist/commands/graph/change-impact.d.ts.map +1 -0
- package/dist/commands/graph/change-impact.js +29 -0
- package/dist/commands/graph/churn.d.ts +14 -0
- package/dist/commands/graph/churn.d.ts.map +1 -0
- package/dist/commands/graph/churn.js +15 -0
- package/dist/commands/graph/common.d.ts +16 -0
- package/dist/commands/graph/common.d.ts.map +1 -0
- package/dist/commands/graph/fan-out.d.ts +14 -0
- package/dist/commands/graph/fan-out.d.ts.map +1 -0
- package/dist/commands/graph/fan-out.js +15 -0
- package/dist/commands/graph/index.d.ts +8 -0
- package/dist/commands/graph/index.d.ts.map +1 -0
- package/dist/commands/graph/index.js +12 -0
- package/dist/commands/matrix.js +1 -1
- package/dist/commands/measurement/index.js +1 -1
- package/dist/commands/measurement/intervention.d.ts +11 -0
- package/dist/commands/measurement/intervention.d.ts.map +1 -0
- package/dist/commands/measurement/intervention.js +31 -0
- package/dist/commands/measurement/operational-release.d.ts +11 -0
- package/dist/commands/measurement/operational-release.d.ts.map +1 -0
- package/dist/commands/measurement/operational-release.js +31 -0
- package/dist/commands/measurement/record.d.ts.map +1 -1
- package/dist/commands/measurement/record.js +12 -11
- package/dist/commands/module/ensure-defaults.js +3 -3
- package/dist/commands/module/install.js +2 -2
- package/dist/commands/module/list.js +2 -2
- package/dist/commands/module/remove.js +2 -2
- package/dist/commands/report.d.ts +4 -0
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +49 -23
- package/dist/commands/review.js +1 -1
- package/dist/commands/to-plan.js +1 -1
- package/dist/commands/update.js +2 -2
- package/dist/commands/validate.js +1 -1
- package/dist/commands/write.js +3 -3
- package/dist/common-B1ZJ8CSO.js +36 -0
- package/dist/common-DTrmnvL-.js +35 -0
- package/dist/{completeness-DamWradt.js → completeness-BzBuNq6w.js} +1 -1
- package/dist/evidence/adapters/contract-conformance.d.ts +16 -0
- package/dist/evidence/adapters/contract-conformance.d.ts.map +1 -0
- package/dist/evidence/adapters/differential-report.d.ts +18 -0
- package/dist/evidence/adapters/differential-report.d.ts.map +1 -0
- package/dist/evidence/adapters/registry.d.ts.map +1 -1
- package/dist/evidence/adapters/types.d.ts +31 -0
- package/dist/evidence/adapters/types.d.ts.map +1 -1
- package/dist/evidence/index.d.ts +5 -2
- package/dist/evidence/index.d.ts.map +1 -1
- package/dist/{evidence-DD0CHzJ0.js → evidence-OyqpqHLS.js} +191 -110
- package/dist/{flow-command-BfFNY0Rv.js → flow-command-CCRTE5Oe.js} +7 -7
- package/dist/graph-analysis/analysis.d.ts +106 -0
- package/dist/graph-analysis/analysis.d.ts.map +1 -0
- package/dist/graph-analysis/index.d.ts +6 -0
- package/dist/graph-analysis/index.d.ts.map +1 -0
- package/dist/graph-analysis/input.d.ts +33 -0
- package/dist/graph-analysis/input.d.ts.map +1 -0
- package/dist/graph-analysis/load.d.ts +21 -0
- package/dist/graph-analysis/load.d.ts.map +1 -0
- package/dist/graph-analysis/render.d.ts +4 -0
- package/dist/graph-analysis/render.d.ts.map +1 -0
- package/dist/graph-analysis-IWaoJJSN.js +657 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -9
- package/dist/measurement/agent-eval-intervention.d.ts +6 -0
- package/dist/measurement/agent-eval-intervention.d.ts.map +1 -0
- package/dist/measurement/atomic-file.d.ts +5 -0
- package/dist/measurement/atomic-file.d.ts.map +1 -0
- package/dist/measurement/date-time.d.ts +3 -0
- package/dist/measurement/date-time.d.ts.map +1 -0
- package/dist/measurement/github-release-operational.d.ts +7 -0
- package/dist/measurement/github-release-operational.d.ts.map +1 -0
- package/dist/measurement/graph-adapters.d.ts +304 -0
- package/dist/measurement/graph-adapters.d.ts.map +1 -0
- package/dist/measurement/graph-portfolio-load.d.ts +3 -0
- package/dist/measurement/graph-portfolio-load.d.ts.map +1 -0
- package/dist/measurement/graph-portfolio.d.ts +158 -0
- package/dist/measurement/graph-portfolio.d.ts.map +1 -0
- package/dist/measurement/index.d.ts +15 -2
- package/dist/measurement/index.d.ts.map +1 -1
- package/dist/measurement/intervention-report.d.ts +24 -0
- package/dist/measurement/intervention-report.d.ts.map +1 -0
- package/dist/measurement/intervention-schema.d.ts +144 -0
- package/dist/measurement/intervention-schema.d.ts.map +1 -0
- package/dist/measurement/intervention-types.d.ts +105 -0
- package/dist/measurement/intervention-types.d.ts.map +1 -0
- package/dist/measurement/intervention.d.ts +16 -0
- package/dist/measurement/intervention.d.ts.map +1 -0
- package/dist/measurement/operational-report.d.ts +17 -0
- package/dist/measurement/operational-report.d.ts.map +1 -0
- package/dist/measurement/operational-schema.d.ts +461 -0
- package/dist/measurement/operational-schema.d.ts.map +1 -0
- package/dist/measurement/operational-types.d.ts +121 -0
- package/dist/measurement/operational-types.d.ts.map +1 -0
- package/dist/measurement/operational.d.ts +13 -0
- package/dist/measurement/operational.d.ts.map +1 -0
- package/dist/measurement/plans.d.ts +3 -1
- package/dist/measurement/plans.d.ts.map +1 -1
- package/dist/measurement/portfolio.d.ts +7 -1
- package/dist/measurement/portfolio.d.ts.map +1 -1
- package/dist/measurement/report.d.ts +4 -0
- package/dist/measurement/report.d.ts.map +1 -1
- package/dist/measurement/schemas/operational-evidence-v1.schema.json.d.ts +384 -0
- package/dist/measurement/store.d.ts +7 -0
- package/dist/measurement/store.d.ts.map +1 -1
- package/dist/measurement/types.d.ts +2 -0
- package/dist/measurement/types.d.ts.map +1 -1
- package/dist/measurement-j8sDSqx5.js +2980 -0
- package/dist/{modules-ez9httBA.js → modules-DDQkKC4l.js} +2 -2
- package/dist/{plugins-C-ta0llj.js → plugins-CHpYhpEI.js} +1 -1
- package/dist/quire/assurance.d.ts +109 -0
- package/dist/quire/assurance.d.ts.map +1 -0
- package/dist/quire/contract.d.ts +2 -1
- package/dist/quire/contract.d.ts.map +1 -1
- package/dist/quire/index.d.ts +3 -2
- package/dist/quire/index.d.ts.map +1 -1
- package/dist/quire/validate.d.ts +5 -0
- package/dist/quire/validate.d.ts.map +1 -1
- package/dist/{quire-D8tCpgyA.js → quire-BsVj1xIR.js} +54 -47
- package/dist/schema-assets-HZWo_iFN.js +233 -0
- package/dist/schemas/assurance-v1.schema.json +225 -0
- package/dist/schemas/change-assurance-record-v1.schema.json +234 -0
- package/dist/schemas/operational-evidence-v1.schema.json +381 -0
- package/dist/schemas/proof-attestation-v1.schema.json +96 -0
- package/dist/schemas/verification-receipt-v1.schema.json +208 -0
- package/dist/{version-Dg0e6CZU.js → version-CMxMIh5g.js} +1 -1
- package/dist/{write-DElwS9xc.js → write-CGTI0dRO.js} +1 -1
- package/package.json +5 -1
- package/skills/gap-analysis/references/step-4-underspecified-code.md +36 -7
- package/skills/gap-analysis/references/step-5-semantic-review.md +2 -2
- package/skills/gap-analysis/references/step-6-specreview-artifact.md +6 -5
- package/skills/spec-fuzz/SKILL.md +7 -6
- package/dist/measurement-CzB74Q07.js +0 -595
- package/dist/store--2sAv12X.js +0 -219
|
@@ -0,0 +1,1236 @@
|
|
|
1
|
+
import { y as e } from "./schema-assets-HZWo_iFN.js";
|
|
2
|
+
import { closeSync as t, existsSync as n, fsyncSync as r, mkdirSync as i, mkdtempSync as a, openSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, writeSync as d } from "node:fs";
|
|
3
|
+
import { dirname as f, join as p } from "node:path";
|
|
4
|
+
import { createHash as m } from "node:crypto";
|
|
5
|
+
//#region node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/utils.js
|
|
6
|
+
function h(e) {
|
|
7
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1;
|
|
8
|
+
}
|
|
9
|
+
function g(e, t = "") {
|
|
10
|
+
if (typeof e != "number") {
|
|
11
|
+
let n = t && `"${t}" `;
|
|
12
|
+
throw TypeError(`${n}expected number, got ${typeof e}`);
|
|
13
|
+
}
|
|
14
|
+
if (!Number.isSafeInteger(e) || e < 0) {
|
|
15
|
+
let n = t && `"${t}" `;
|
|
16
|
+
throw RangeError(`${n}expected integer >= 0, got ${e}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function _(e, t, n = "") {
|
|
20
|
+
let r = h(e), i = e?.length, a = t !== void 0;
|
|
21
|
+
if (!r || a && i !== t) {
|
|
22
|
+
let o = n && `"${n}" `, s = a ? ` of length ${t}` : "", c = r ? `length=${i}` : `type=${typeof e}`, l = o + "expected Uint8Array" + s + ", got " + c;
|
|
23
|
+
throw r ? RangeError(l) : TypeError(l);
|
|
24
|
+
}
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
function v(e) {
|
|
28
|
+
return Uint8Array.from(_(e));
|
|
29
|
+
}
|
|
30
|
+
function y(e, t = !0) {
|
|
31
|
+
if (e.destroyed) throw Error("Hash instance has been destroyed");
|
|
32
|
+
if (t && e.finished) throw Error("Hash#digest() has already been called");
|
|
33
|
+
}
|
|
34
|
+
function b(e, t) {
|
|
35
|
+
_(e, void 0, "digestInto() output");
|
|
36
|
+
let n = t.outputLen;
|
|
37
|
+
if (e.length < n) throw RangeError("\"digestInto() output\" expected to be of length >=" + n);
|
|
38
|
+
}
|
|
39
|
+
function x(e) {
|
|
40
|
+
return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
41
|
+
}
|
|
42
|
+
function S(e) {
|
|
43
|
+
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
44
|
+
}
|
|
45
|
+
function C(...e) {
|
|
46
|
+
for (let t = 0; t < e.length; t++) e[t].fill(0);
|
|
47
|
+
}
|
|
48
|
+
function w(e, t) {
|
|
49
|
+
return e << 32 - t | e >>> t;
|
|
50
|
+
}
|
|
51
|
+
var ee = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
52
|
+
function te(e) {
|
|
53
|
+
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
54
|
+
}
|
|
55
|
+
var ne = ee ? (e) => e : (e) => te(e) >>> 0;
|
|
56
|
+
function re(e) {
|
|
57
|
+
for (let t = 0; t < e.length; t++) e[t] = te(e[t]);
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
60
|
+
var T = ee ? (e) => e : re, ie = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ae = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
61
|
+
function oe(e) {
|
|
62
|
+
if (_(e), ie) return e.toHex();
|
|
63
|
+
let t = "";
|
|
64
|
+
for (let n = 0; n < e.length; n++) t += ae[e[n]];
|
|
65
|
+
return t;
|
|
66
|
+
}
|
|
67
|
+
function se(e, t = {}) {
|
|
68
|
+
let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
|
|
69
|
+
return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js
|
|
73
|
+
var ce = /* @__PURE__ */ Uint32Array.from([
|
|
74
|
+
1779033703,
|
|
75
|
+
3144134277,
|
|
76
|
+
1013904242,
|
|
77
|
+
2773480762,
|
|
78
|
+
1359893119,
|
|
79
|
+
2600822924,
|
|
80
|
+
528734635,
|
|
81
|
+
1541459225
|
|
82
|
+
]), E = /* @__PURE__ */ BigInt(2 ** 32 - 1), le = /* @__PURE__ */ BigInt(32);
|
|
83
|
+
function ue(e, t = !1) {
|
|
84
|
+
return t ? {
|
|
85
|
+
h: Number(e & E),
|
|
86
|
+
l: Number(e >> le & E)
|
|
87
|
+
} : {
|
|
88
|
+
h: Number(e >> le & E) | 0,
|
|
89
|
+
l: Number(e & E) | 0
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_blake.js
|
|
94
|
+
function D(e, t, n, r, i) {
|
|
95
|
+
return e = e + t + i | 0, r = w(r ^ e, 16), n = n + r | 0, t = w(t ^ n, 12), {
|
|
96
|
+
a: e,
|
|
97
|
+
b: t,
|
|
98
|
+
c: n,
|
|
99
|
+
d: r
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function O(e, t, n, r, i) {
|
|
103
|
+
return e = e + t + i | 0, r = w(r ^ e, 8), n = n + r | 0, t = w(t ^ n, 7), {
|
|
104
|
+
a: e,
|
|
105
|
+
b: t,
|
|
106
|
+
c: n,
|
|
107
|
+
d: r
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/blake2.js
|
|
112
|
+
var de = class {
|
|
113
|
+
buffer;
|
|
114
|
+
buffer32;
|
|
115
|
+
finished = !1;
|
|
116
|
+
destroyed = !1;
|
|
117
|
+
length = 0;
|
|
118
|
+
pos = 0;
|
|
119
|
+
blockLen;
|
|
120
|
+
outputLen;
|
|
121
|
+
canXOF = !1;
|
|
122
|
+
constructor(e, t) {
|
|
123
|
+
g(e), g(t), this.blockLen = e, this.outputLen = t, this.buffer = new Uint8Array(e), this.buffer32 = S(this.buffer);
|
|
124
|
+
}
|
|
125
|
+
update(e) {
|
|
126
|
+
y(this), _(e);
|
|
127
|
+
let { blockLen: t, buffer: n, buffer32: r } = this, i = e.length, a = e.byteOffset, o = e.buffer;
|
|
128
|
+
for (let s = 0; s < i;) {
|
|
129
|
+
this.pos === t && (T(r), this.compress(r, 0, !1), T(r), this.pos = 0);
|
|
130
|
+
let c = Math.min(t - this.pos, i - s), l = a + s;
|
|
131
|
+
if (c === t && !(l % 4) && s + c < i) {
|
|
132
|
+
let e = new Uint32Array(o, l, Math.floor((i - s) / 4));
|
|
133
|
+
T(e);
|
|
134
|
+
for (let n = 0; s + t < i; n += r.length, s += t) this.length += t, this.compress(e, n, !1);
|
|
135
|
+
T(e);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
n.set(e.subarray(s, s + c), this.pos), this.pos += c, this.length += c, s += c;
|
|
139
|
+
}
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
digestInto(e) {
|
|
143
|
+
y(this), b(e, this);
|
|
144
|
+
let { pos: t, buffer32: n } = this;
|
|
145
|
+
if (this.finished = !0, C(this.buffer.subarray(t)), T(n), this.compress(n, 0, !0), T(n), e.byteOffset & 3) throw RangeError("\"digestInto() output\" expected 4-byte aligned byteOffset, got " + e.byteOffset);
|
|
146
|
+
let r = this.get(), i = S(e), a = Math.floor(this.outputLen / 4);
|
|
147
|
+
for (let e = 0; e < a; e++) i[e] = ne(r[e]);
|
|
148
|
+
let o = this.outputLen % 4;
|
|
149
|
+
if (!o) return;
|
|
150
|
+
let s = a * 4, c = r[a];
|
|
151
|
+
for (let t = 0; t < o; t++) e[s + t] = c >>> 8 * t;
|
|
152
|
+
}
|
|
153
|
+
digest() {
|
|
154
|
+
let { buffer: e, outputLen: t } = this;
|
|
155
|
+
this.digestInto(e);
|
|
156
|
+
let n = e.slice(0, t);
|
|
157
|
+
return this.destroy(), n;
|
|
158
|
+
}
|
|
159
|
+
_cloneInto(e) {
|
|
160
|
+
let { buffer: t, length: n, finished: r, destroyed: i, outputLen: a, pos: o } = this;
|
|
161
|
+
return e ||= new this.constructor({ dkLen: a }), e.set(...this.get()), e.buffer.set(t), e.destroyed = i, e.finished = r, e.length = n, e.pos = o, e.outputLen = a, e;
|
|
162
|
+
}
|
|
163
|
+
clone() {
|
|
164
|
+
return this._cloneInto();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
function fe(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y) {
|
|
168
|
+
let b = 0;
|
|
169
|
+
for (let x = 0; x < r; x++) ({a: i, b: c, c: f, d: g} = D(i, c, f, g, n[t + e[b++]])), {a: i, b: c, c: f, d: g} = O(i, c, f, g, n[t + e[b++]]), {a: a, b: l, c: p, d: _} = D(a, l, p, _, n[t + e[b++]]), {a: a, b: l, c: p, d: _} = O(a, l, p, _, n[t + e[b++]]), {a: o, b: u, c: m, d: v} = D(o, u, m, v, n[t + e[b++]]), {a: o, b: u, c: m, d: v} = O(o, u, m, v, n[t + e[b++]]), {a: s, b: d, c: h, d: y} = D(s, d, h, y, n[t + e[b++]]), {a: s, b: d, c: h, d: y} = O(s, d, h, y, n[t + e[b++]]), {a: i, b: l, c: m, d: y} = D(i, l, m, y, n[t + e[b++]]), {a: i, b: l, c: m, d: y} = O(i, l, m, y, n[t + e[b++]]), {a: a, b: u, c: h, d: g} = D(a, u, h, g, n[t + e[b++]]), {a: a, b: u, c: h, d: g} = O(a, u, h, g, n[t + e[b++]]), {a: o, b: d, c: f, d: _} = D(o, d, f, _, n[t + e[b++]]), {a: o, b: d, c: f, d: _} = O(o, d, f, _, n[t + e[b++]]), {a: s, b: c, c: p, d: v} = D(s, c, p, v, n[t + e[b++]]), {a: s, b: c, c: p, d: v} = O(s, c, p, v, n[t + e[b++]]);
|
|
170
|
+
return {
|
|
171
|
+
v0: i,
|
|
172
|
+
v1: a,
|
|
173
|
+
v2: o,
|
|
174
|
+
v3: s,
|
|
175
|
+
v4: c,
|
|
176
|
+
v5: l,
|
|
177
|
+
v6: u,
|
|
178
|
+
v7: d,
|
|
179
|
+
v8: f,
|
|
180
|
+
v9: p,
|
|
181
|
+
v10: m,
|
|
182
|
+
v11: h,
|
|
183
|
+
v12: g,
|
|
184
|
+
v13: _,
|
|
185
|
+
v14: v,
|
|
186
|
+
v15: y
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/blake3.js
|
|
191
|
+
var k = {
|
|
192
|
+
CHUNK_START: 1,
|
|
193
|
+
CHUNK_END: 2,
|
|
194
|
+
PARENT: 4,
|
|
195
|
+
ROOT: 8,
|
|
196
|
+
KEYED_HASH: 16,
|
|
197
|
+
DERIVE_KEY_CONTEXT: 32,
|
|
198
|
+
DERIVE_KEY_MATERIAL: 64
|
|
199
|
+
}, A = /* @__PURE__ */ ce.slice(), pe = /* @__PURE__ */ (() => {
|
|
200
|
+
let e = Array.from({ length: 16 }, (e, t) => t), t = (e) => [
|
|
201
|
+
2,
|
|
202
|
+
6,
|
|
203
|
+
3,
|
|
204
|
+
10,
|
|
205
|
+
7,
|
|
206
|
+
0,
|
|
207
|
+
4,
|
|
208
|
+
13,
|
|
209
|
+
1,
|
|
210
|
+
11,
|
|
211
|
+
12,
|
|
212
|
+
5,
|
|
213
|
+
9,
|
|
214
|
+
14,
|
|
215
|
+
15,
|
|
216
|
+
8
|
|
217
|
+
].map((t) => e[t]), n = [];
|
|
218
|
+
for (let r = 0, i = e; r < 7; r++, i = t(i)) n.push(...i);
|
|
219
|
+
return Uint8Array.from(n);
|
|
220
|
+
})(), me = class e extends de {
|
|
221
|
+
canXOF = !0;
|
|
222
|
+
chunkPos = 0;
|
|
223
|
+
chunksDone = 0;
|
|
224
|
+
flags = 0;
|
|
225
|
+
IV;
|
|
226
|
+
state;
|
|
227
|
+
stack = [];
|
|
228
|
+
posOut = 0;
|
|
229
|
+
bufferOut32 = /* @__PURE__ */ new Uint32Array(16);
|
|
230
|
+
bufferOut;
|
|
231
|
+
chunkOut = 0;
|
|
232
|
+
enableXOF = !0;
|
|
233
|
+
constructor(t = {}, n = 0) {
|
|
234
|
+
super(64, t.dkLen === void 0 ? 32 : t.dkLen);
|
|
235
|
+
let { key: r, context: i } = t, a = i !== void 0;
|
|
236
|
+
if (r !== void 0) {
|
|
237
|
+
if (a) throw Error("Only \"key\" or \"context\" can be specified at same time");
|
|
238
|
+
_(r, 32, "key");
|
|
239
|
+
let e = v(r);
|
|
240
|
+
this.IV = S(e), T(this.IV), this.flags = n | k.KEYED_HASH;
|
|
241
|
+
} else if (a) {
|
|
242
|
+
_(i, void 0, "context");
|
|
243
|
+
let t = i, r = new e({ dkLen: 32 }, k.DERIVE_KEY_CONTEXT).update(t).digest();
|
|
244
|
+
this.IV = S(r), T(this.IV), this.flags = n | k.DERIVE_KEY_MATERIAL;
|
|
245
|
+
} else this.IV = A.slice(), this.flags = n;
|
|
246
|
+
this.state = this.IV.slice(), this.bufferOut = x(this.bufferOut32);
|
|
247
|
+
}
|
|
248
|
+
get() {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
set() {}
|
|
252
|
+
b2Compress(e, t, n, r = 0) {
|
|
253
|
+
let { state: i, pos: a } = this, { h: o, l: s } = ue(BigInt(e), !0), { v0: c, v1: l, v2: u, v3: d, v4: f, v5: p, v6: m, v7: h, v8: g, v9: _, v10: v, v11: y, v12: b, v13: x, v14: S, v15: C } = fe(pe, r, n, 7, i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], A[0], A[1], A[2], A[3], o, s, a, t);
|
|
254
|
+
i[0] = c ^ g, i[1] = l ^ _, i[2] = u ^ v, i[3] = d ^ y, i[4] = f ^ b, i[5] = p ^ x, i[6] = m ^ S, i[7] = h ^ C;
|
|
255
|
+
}
|
|
256
|
+
compress(e, t = 0, n = !1) {
|
|
257
|
+
let r = this.flags;
|
|
258
|
+
if (this.chunkPos || (r |= k.CHUNK_START), (this.chunkPos === 15 || n) && (r |= k.CHUNK_END), n || (this.pos = this.blockLen), this.b2Compress(this.chunksDone, r, e, t), this.chunkPos += 1, this.chunkPos === 16 || n) {
|
|
259
|
+
let e = this.state;
|
|
260
|
+
this.state = this.IV.slice();
|
|
261
|
+
for (let t, r = this.chunksDone + 1; (n || !(r & 1)) && (t = this.stack.pop()); r >>= 1) this.buffer32.set(t, 0), this.buffer32.set(e, 8), this.pos = this.blockLen, this.b2Compress(0, this.flags | k.PARENT, this.buffer32, 0), e = this.state, this.state = this.IV.slice();
|
|
262
|
+
this.chunksDone++, this.chunkPos = 0, this.stack.push(e);
|
|
263
|
+
}
|
|
264
|
+
this.pos = 0;
|
|
265
|
+
}
|
|
266
|
+
_cloneInto(e) {
|
|
267
|
+
e = super._cloneInto(e);
|
|
268
|
+
let { IV: t, flags: n, state: r, chunkPos: i, posOut: a, chunkOut: o, stack: s, chunksDone: c } = this;
|
|
269
|
+
return e.state.set(r.slice()), e.stack = s.map((e) => Uint32Array.from(e)), e.IV.set(t), e.flags = n, e.chunkPos = i, e.chunksDone = c, e.posOut = a, e.chunkOut = o, e.enableXOF = this.enableXOF, e.bufferOut32.set(this.bufferOut32), e;
|
|
270
|
+
}
|
|
271
|
+
destroy() {
|
|
272
|
+
this.destroyed = !0, C(this.state, this.buffer32, this.IV, this.bufferOut32), C(...this.stack);
|
|
273
|
+
}
|
|
274
|
+
b2CompressOut() {
|
|
275
|
+
let { state: e, pos: t, flags: n, buffer32: r, bufferOut32: i } = this, { h: a, l: o } = ue(BigInt(this.chunkOut++));
|
|
276
|
+
T(r);
|
|
277
|
+
let { v0: s, v1: c, v2: l, v3: u, v4: d, v5: f, v6: p, v7: m, v8: h, v9: g, v10: _, v11: v, v12: y, v13: b, v14: x, v15: S } = fe(pe, 0, r, 7, e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], A[0], A[1], A[2], A[3], o, a, t, n);
|
|
278
|
+
i[0] = s ^ h, i[1] = c ^ g, i[2] = l ^ _, i[3] = u ^ v, i[4] = d ^ y, i[5] = f ^ b, i[6] = p ^ x, i[7] = m ^ S, i[8] = e[0] ^ h, i[9] = e[1] ^ g, i[10] = e[2] ^ _, i[11] = e[3] ^ v, i[12] = e[4] ^ y, i[13] = e[5] ^ b, i[14] = e[6] ^ x, i[15] = e[7] ^ S, T(r), T(i), this.posOut = 0;
|
|
279
|
+
}
|
|
280
|
+
finish() {
|
|
281
|
+
if (this.finished) return;
|
|
282
|
+
this.finished = !0, C(this.buffer.subarray(this.pos));
|
|
283
|
+
let e = this.flags | k.ROOT;
|
|
284
|
+
this.stack.length ? (e |= k.PARENT, T(this.buffer32), this.compress(this.buffer32, 0, !0), T(this.buffer32), this.chunksDone = 0, this.pos = this.blockLen) : e |= (this.chunkPos ? 0 : k.CHUNK_START) | k.CHUNK_END, this.flags = e, this.b2CompressOut();
|
|
285
|
+
}
|
|
286
|
+
writeInto(e) {
|
|
287
|
+
y(this, !1), _(e), this.finish();
|
|
288
|
+
let { blockLen: t, bufferOut: n } = this;
|
|
289
|
+
for (let r = 0, i = e.length; r < i;) {
|
|
290
|
+
this.posOut >= t && this.b2CompressOut();
|
|
291
|
+
let a = Math.min(t - this.posOut, i - r);
|
|
292
|
+
e.set(n.subarray(this.posOut, this.posOut + a), r), this.posOut += a, r += a;
|
|
293
|
+
}
|
|
294
|
+
return e;
|
|
295
|
+
}
|
|
296
|
+
xofInto(e) {
|
|
297
|
+
if (!this.enableXOF) throw Error("XOF is not possible after digest call");
|
|
298
|
+
return this.writeInto(e);
|
|
299
|
+
}
|
|
300
|
+
xof(e) {
|
|
301
|
+
return g(e), this.xofInto(new Uint8Array(e));
|
|
302
|
+
}
|
|
303
|
+
digestInto(e) {
|
|
304
|
+
if (b(e, this), this.finished) throw Error("digest() was already called");
|
|
305
|
+
this.enableXOF = !1, this.writeInto(e.subarray(0, this.outputLen)), this.destroy();
|
|
306
|
+
}
|
|
307
|
+
digest() {
|
|
308
|
+
let e = new Uint8Array(this.outputLen);
|
|
309
|
+
return this.digestInto(e), e;
|
|
310
|
+
}
|
|
311
|
+
}, he = /* @__PURE__ */ se((e = {}) => new me(e)), ge = new TextEncoder(), j = class extends Error {
|
|
312
|
+
constructor(e) {
|
|
313
|
+
super(e), this.name = "IntegrityError";
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
function M(e) {
|
|
317
|
+
return oe(he(e));
|
|
318
|
+
}
|
|
319
|
+
function N(e) {
|
|
320
|
+
let t;
|
|
321
|
+
if (typeof e == "string") t = e;
|
|
322
|
+
else try {
|
|
323
|
+
t = new TextDecoder("utf-8", { fatal: !0 }).decode(e);
|
|
324
|
+
} catch {
|
|
325
|
+
throw new j("input is not valid UTF-8");
|
|
326
|
+
}
|
|
327
|
+
if (t.charCodeAt(0) === 65279) throw new j("a byte-order mark is not permitted");
|
|
328
|
+
return new _e(t).parse();
|
|
329
|
+
}
|
|
330
|
+
var _e = class {
|
|
331
|
+
text;
|
|
332
|
+
offset = 0;
|
|
333
|
+
constructor(e) {
|
|
334
|
+
this.text = e;
|
|
335
|
+
}
|
|
336
|
+
parse() {
|
|
337
|
+
let e = this.value();
|
|
338
|
+
return this.space(), this.offset !== this.text.length && this.fail("trailing JSON content"), e;
|
|
339
|
+
}
|
|
340
|
+
value() {
|
|
341
|
+
this.space();
|
|
342
|
+
let e = this.text[this.offset];
|
|
343
|
+
return e === "{" ? this.object() : e === "[" ? this.array() : e === "\"" ? this.string() : e === "t" ? this.literal("true", !0) : e === "f" ? this.literal("false", !1) : e === "n" ? this.literal("null", null) : this.number();
|
|
344
|
+
}
|
|
345
|
+
object() {
|
|
346
|
+
this.offset++, this.space();
|
|
347
|
+
let e = Object.create(null), t = /* @__PURE__ */ new Set();
|
|
348
|
+
if (this.take("}")) return e;
|
|
349
|
+
for (;;) {
|
|
350
|
+
this.space(), this.text[this.offset] !== "\"" && this.fail("object key must be a string");
|
|
351
|
+
let n = this.string();
|
|
352
|
+
if (t.has(n) && this.fail(`duplicate object name ${JSON.stringify(n)}`), t.add(n), this.space(), this.take(":") || this.fail("expected ':' after object key"), e[n] = this.value(), this.space(), this.take("}")) return e;
|
|
353
|
+
this.take(",") || this.fail("expected ',' or '}' in object");
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
array() {
|
|
357
|
+
this.offset++, this.space();
|
|
358
|
+
let e = [];
|
|
359
|
+
if (this.take("]")) return e;
|
|
360
|
+
for (;;) {
|
|
361
|
+
if (e.push(this.value()), this.space(), this.take("]")) return e;
|
|
362
|
+
this.take(",") || this.fail("expected ',' or ']' in array");
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
string() {
|
|
366
|
+
let e = this.offset;
|
|
367
|
+
this.offset++;
|
|
368
|
+
let t = !1;
|
|
369
|
+
for (; this.offset < this.text.length;) {
|
|
370
|
+
let n = this.text.charCodeAt(this.offset);
|
|
371
|
+
if (!t && n === 34) {
|
|
372
|
+
this.offset++;
|
|
373
|
+
let t;
|
|
374
|
+
try {
|
|
375
|
+
t = JSON.parse(this.text.slice(e, this.offset));
|
|
376
|
+
} catch {
|
|
377
|
+
this.fail("invalid JSON string");
|
|
378
|
+
}
|
|
379
|
+
return ye(t), t;
|
|
380
|
+
}
|
|
381
|
+
!t && n < 32 && this.fail("unescaped control character"), t = !t && n === 92, this.offset++;
|
|
382
|
+
}
|
|
383
|
+
this.fail("unterminated JSON string");
|
|
384
|
+
}
|
|
385
|
+
number() {
|
|
386
|
+
let e = this.text.slice(this.offset), t = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e);
|
|
387
|
+
t || this.fail("expected a JSON value"), this.offset += t[0].length;
|
|
388
|
+
let n = Number(t[0]);
|
|
389
|
+
return Number.isFinite(n) || this.fail("number is not finite I-JSON"), n;
|
|
390
|
+
}
|
|
391
|
+
literal(e, t) {
|
|
392
|
+
return this.text.slice(this.offset, this.offset + e.length) !== e && this.fail(`expected ${e}`), this.offset += e.length, t;
|
|
393
|
+
}
|
|
394
|
+
take(e) {
|
|
395
|
+
return this.text[this.offset] === e && (this.offset++, !0);
|
|
396
|
+
}
|
|
397
|
+
space() {
|
|
398
|
+
for (; [
|
|
399
|
+
" ",
|
|
400
|
+
" ",
|
|
401
|
+
"\r",
|
|
402
|
+
"\n"
|
|
403
|
+
].includes(this.text[this.offset] ?? "");) this.offset++;
|
|
404
|
+
}
|
|
405
|
+
fail(e) {
|
|
406
|
+
throw new j(`${e} at byte ${this.offset}`);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
function P(e) {
|
|
410
|
+
if (e === null) return "null";
|
|
411
|
+
if (typeof e == "boolean") return e ? "true" : "false";
|
|
412
|
+
if (typeof e == "number") {
|
|
413
|
+
if (!Number.isFinite(e)) throw new j("non-finite I-JSON number");
|
|
414
|
+
return JSON.stringify(e);
|
|
415
|
+
}
|
|
416
|
+
if (typeof e == "string") return ye(e), JSON.stringify(e);
|
|
417
|
+
if (Array.isArray(e)) return `[${e.map(P).join(",")}]`;
|
|
418
|
+
if (typeof e != "object" || e === void 0) throw new j(`unsupported JSON value: ${typeof e}`);
|
|
419
|
+
let t = e;
|
|
420
|
+
return `{${Object.keys(t).sort().map((e) => {
|
|
421
|
+
if (t[e] === void 0) throw new j(`undefined member ${e}`);
|
|
422
|
+
return ye(e), `${JSON.stringify(e)}:${P(t[e])}`;
|
|
423
|
+
}).join(",")}}`;
|
|
424
|
+
}
|
|
425
|
+
function F(e) {
|
|
426
|
+
return ge.encode(P(e));
|
|
427
|
+
}
|
|
428
|
+
function I(e) {
|
|
429
|
+
let t = { ...e };
|
|
430
|
+
return delete t.digest, M(F(t));
|
|
431
|
+
}
|
|
432
|
+
function ve(e) {
|
|
433
|
+
let t = e.digest;
|
|
434
|
+
if (typeof t != "string" || !/^[a-f0-9]{64}$/.test(t)) throw new j("digest must be exactly 64 lowercase hexadecimal characters");
|
|
435
|
+
if (I(e) !== t) throw new j("digest mismatch");
|
|
436
|
+
}
|
|
437
|
+
function ye(e) {
|
|
438
|
+
for (let t = 0; t < e.length; t++) {
|
|
439
|
+
let n = e.charCodeAt(t);
|
|
440
|
+
if (n >= 55296 && n <= 56319) {
|
|
441
|
+
let n = e.charCodeAt(t + 1);
|
|
442
|
+
if (!(n >= 56320 && n <= 57343)) throw new j("invalid Unicode lone high surrogate");
|
|
443
|
+
t++;
|
|
444
|
+
} else if (n >= 56320 && n <= 57343) throw new j("invalid Unicode lone low surrogate");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/change-assurance/records.ts
|
|
449
|
+
var be = /^[a-f0-9]{64}$/, xe = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}$/;
|
|
450
|
+
function Se(e) {
|
|
451
|
+
let t = { ...e };
|
|
452
|
+
delete t.digest;
|
|
453
|
+
let n = Ee(t);
|
|
454
|
+
De(n, !1);
|
|
455
|
+
let r = I(n);
|
|
456
|
+
return L({
|
|
457
|
+
...n,
|
|
458
|
+
digest: r
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
function L(e) {
|
|
462
|
+
return De(e, !0), ve(e), e;
|
|
463
|
+
}
|
|
464
|
+
function Ce(e) {
|
|
465
|
+
return F(L(e));
|
|
466
|
+
}
|
|
467
|
+
function we(e, t) {
|
|
468
|
+
L(e);
|
|
469
|
+
let n = t.slice().sort((e, t) => e.revision - t.revision);
|
|
470
|
+
if (e.revision === 1) {
|
|
471
|
+
if (e.parent_digest !== null || n.length !== 0) throw Error("revision 1 must have a null parent and no parent chain");
|
|
472
|
+
return [];
|
|
473
|
+
}
|
|
474
|
+
if (n.length !== e.revision - 1) throw Error("revision gap in parent chain");
|
|
475
|
+
let r = null;
|
|
476
|
+
for (let t = 0; t < n.length; t++) {
|
|
477
|
+
let i = L(n[t]);
|
|
478
|
+
if (i.record_id !== e.record_id) throw Error("cross-record parent");
|
|
479
|
+
if (i.revision !== t + 1) throw Error("revision gap in parent chain");
|
|
480
|
+
if (i.parent_digest !== r) throw Error("parent digest mismatch");
|
|
481
|
+
r = i.digest;
|
|
482
|
+
}
|
|
483
|
+
if (e.parent_digest !== r) throw Error("immediate parent mismatch");
|
|
484
|
+
return n.map((e) => e.digest);
|
|
485
|
+
}
|
|
486
|
+
function Te(e, t) {
|
|
487
|
+
if (!t) return {
|
|
488
|
+
outcome: "incomplete",
|
|
489
|
+
reasons: ["event_chain_missing"],
|
|
490
|
+
event: null
|
|
491
|
+
};
|
|
492
|
+
try {
|
|
493
|
+
let e = R(t, "decision history");
|
|
494
|
+
z(e, ["run_id", "events"]), H(e.run_id, "decision history run_id"), B(e.events, "decision history events", !1);
|
|
495
|
+
} catch {
|
|
496
|
+
return {
|
|
497
|
+
outcome: "invalid",
|
|
498
|
+
reasons: ["event_chain_invalid"],
|
|
499
|
+
event: null
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (!Me(t.events)) return {
|
|
503
|
+
outcome: "invalid",
|
|
504
|
+
reasons: ["event_chain_invalid"],
|
|
505
|
+
event: null
|
|
506
|
+
};
|
|
507
|
+
if (t.run_id !== e.review_workflow.run_id) return {
|
|
508
|
+
outcome: "invalid",
|
|
509
|
+
reasons: ["decision_mismatch"],
|
|
510
|
+
event: null
|
|
511
|
+
};
|
|
512
|
+
if (t.events.length === 0) return {
|
|
513
|
+
outcome: "incomplete",
|
|
514
|
+
reasons: ["decision_missing"],
|
|
515
|
+
event: null
|
|
516
|
+
};
|
|
517
|
+
let n = t.events.filter((t) => t.kind === e.review_workflow.decision_event_kind);
|
|
518
|
+
if (n.length === 0) return {
|
|
519
|
+
outcome: "incomplete",
|
|
520
|
+
reasons: ["decision_missing"],
|
|
521
|
+
event: null
|
|
522
|
+
};
|
|
523
|
+
let r = n.filter((t) => {
|
|
524
|
+
try {
|
|
525
|
+
z(R(t, "decision event"), [
|
|
526
|
+
"id",
|
|
527
|
+
"ts",
|
|
528
|
+
"actor",
|
|
529
|
+
"kind",
|
|
530
|
+
"payload",
|
|
531
|
+
"prevHash",
|
|
532
|
+
"hash"
|
|
533
|
+
]), H(t.id, "decision event id"), V(t.ts, "decision event timestamp"), U(t.prevHash, "decision previous hash"), U(t.hash, "decision event hash"), z(R(t.actor, "decision actor"), [
|
|
534
|
+
"kind",
|
|
535
|
+
"id",
|
|
536
|
+
...t.actor.ackToken === void 0 ? [] : ["ackToken"]
|
|
537
|
+
]), q(t.actor.kind, [
|
|
538
|
+
"agent",
|
|
539
|
+
"human",
|
|
540
|
+
"service"
|
|
541
|
+
], "decision actor kind"), V(t.actor.id, "decision actor id"), t.actor.ackToken !== void 0 && V(t.actor.ackToken, "decision actor ackToken");
|
|
542
|
+
let n = R(t.payload, "decision payload");
|
|
543
|
+
z(n, [
|
|
544
|
+
"schema_version",
|
|
545
|
+
"record_id",
|
|
546
|
+
"revision",
|
|
547
|
+
"record_digest",
|
|
548
|
+
"decision",
|
|
549
|
+
...n.note === void 0 ? [] : ["note"]
|
|
550
|
+
]);
|
|
551
|
+
let r = n;
|
|
552
|
+
return r.note !== void 0 && V(r.note, "decision note"), t.actor.kind === "human" && r.schema_version === 1 && r.record_id === e.record_id && r.revision === e.revision && r.record_digest === e.digest && [
|
|
553
|
+
"approved",
|
|
554
|
+
"rejected",
|
|
555
|
+
"revise"
|
|
556
|
+
].includes(r.decision);
|
|
557
|
+
} catch {
|
|
558
|
+
return !1;
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
if (r.length !== 1 || r.length !== n.length) return {
|
|
562
|
+
outcome: "invalid",
|
|
563
|
+
reasons: ["decision_mismatch"],
|
|
564
|
+
event: null
|
|
565
|
+
};
|
|
566
|
+
let i = r[0], a = i.payload, o = {
|
|
567
|
+
run_id: t.run_id,
|
|
568
|
+
event_id: i.id,
|
|
569
|
+
event_hash: i.hash,
|
|
570
|
+
chain_tail_hash: t.events.at(-1)?.hash ?? i.hash,
|
|
571
|
+
recorded_actor: i.actor.id,
|
|
572
|
+
decision: a.decision
|
|
573
|
+
};
|
|
574
|
+
return a.decision === "rejected" ? {
|
|
575
|
+
outcome: "invalid",
|
|
576
|
+
reasons: ["review_rejected"],
|
|
577
|
+
event: o
|
|
578
|
+
} : a.decision === "revise" ? {
|
|
579
|
+
outcome: "invalid",
|
|
580
|
+
reasons: ["review_revision_requested"],
|
|
581
|
+
event: o
|
|
582
|
+
} : {
|
|
583
|
+
outcome: "valid",
|
|
584
|
+
reasons: [],
|
|
585
|
+
event: o
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
function Ee(e) {
|
|
589
|
+
let t = structuredClone(e);
|
|
590
|
+
t.subject.scope.sort(), t.source_connections.sort((e, t) => Y(e.source_id, t.source_id)), t.impact_snapshot.gaps.sort(), t.definition.requirements.sort((e, t) => Y(e.id, t.id)), t.definition.preservation_constraints.sort((e, t) => Y(e.id, t.id)), t.definition.proof_obligations.sort((e, t) => Y(e.proof_id, t.proof_id)), t.definition.unknowns.sort((e, t) => Y(e.id, t.id));
|
|
591
|
+
for (let e of t.definition.requirements) e.source_ids.sort();
|
|
592
|
+
for (let e of t.definition.preservation_constraints) e.source_ids.sort();
|
|
593
|
+
for (let e of t.definition.proof_obligations) e.obligation_ids.sort();
|
|
594
|
+
return t;
|
|
595
|
+
}
|
|
596
|
+
function De(e, t) {
|
|
597
|
+
let n = R(e, "record");
|
|
598
|
+
z(n, [
|
|
599
|
+
"schema_version",
|
|
600
|
+
"record_type",
|
|
601
|
+
"record_id",
|
|
602
|
+
"revision",
|
|
603
|
+
"parent_digest",
|
|
604
|
+
...t ? ["digest"] : [],
|
|
605
|
+
"subject",
|
|
606
|
+
"source_connections",
|
|
607
|
+
"impact_snapshot",
|
|
608
|
+
"definition",
|
|
609
|
+
"review_workflow"
|
|
610
|
+
]), Pe(n.schema_version, 1, "schema_version"), Pe(n.record_type, "change_assurance", "record_type"), H(n.record_id, "record_id"), (!Number.isInteger(n.revision) || n.revision < 1) && J("revision"), n.parent_digest !== null && U(n.parent_digest, "parent_digest"), n.revision === 1 && n.parent_digest !== null && J("revision 1 parent_digest"), n.revision > 1 && n.parent_digest === null && J("successor parent_digest"), t && U(n.digest, "digest");
|
|
611
|
+
let r = R(n.subject, "subject");
|
|
612
|
+
z(r, [
|
|
613
|
+
"repository",
|
|
614
|
+
"base_revision",
|
|
615
|
+
"scope"
|
|
616
|
+
]), V(r.repository, "subject.repository"), V(r.base_revision, "subject.base_revision"), W(r.scope, "subject.scope", !0, !0), K(r.scope, (e) => e, "subject.scope");
|
|
617
|
+
let i = B(n.source_connections, "source_connections", !0);
|
|
618
|
+
G(i.map((e, t) => {
|
|
619
|
+
let n = R(e, `source_connections[${t}]`);
|
|
620
|
+
return z(n, [
|
|
621
|
+
"source_id",
|
|
622
|
+
"kind",
|
|
623
|
+
"revision",
|
|
624
|
+
"digest"
|
|
625
|
+
]), H(n.source_id, "source_id"), q(n.kind, [
|
|
626
|
+
"requirement",
|
|
627
|
+
"test",
|
|
628
|
+
"api",
|
|
629
|
+
"architecture",
|
|
630
|
+
"impact_evidence",
|
|
631
|
+
"recovery_evidence",
|
|
632
|
+
"other"
|
|
633
|
+
], "source kind"), V(n.revision, "source revision"), U(n.digest, "source digest"), n.source_id;
|
|
634
|
+
}), "duplicate source identity"), K(i, (e) => e.source_id, "source_connections");
|
|
635
|
+
let a = R(n.impact_snapshot, "impact_snapshot");
|
|
636
|
+
z(a, [
|
|
637
|
+
"identity",
|
|
638
|
+
"revision",
|
|
639
|
+
"digest",
|
|
640
|
+
"completeness",
|
|
641
|
+
"truncated",
|
|
642
|
+
"gaps"
|
|
643
|
+
]), H(a.identity, "impact identity"), V(a.revision, "impact revision"), U(a.digest, "impact digest"), q(a.completeness, ["complete", "incomplete"], "impact completeness"), typeof a.truncated != "boolean" && J("impact truncated"), W(a.gaps, "impact gaps", !1, !1), K(a.gaps, (e) => e, "impact gaps");
|
|
644
|
+
let o = R(n.definition, "definition");
|
|
645
|
+
z(o, [
|
|
646
|
+
"requirements",
|
|
647
|
+
"preservation_constraints",
|
|
648
|
+
"proof_obligations",
|
|
649
|
+
"unknowns"
|
|
650
|
+
]), G(Oe(o.requirements, "requirements", !0), "duplicate requirement identity"), K(B(o.requirements, "requirements", !0), (e) => e.id, "requirements"), G(Oe(o.preservation_constraints, "preservation_constraints", !1), "duplicate constraint identity"), K(B(o.preservation_constraints, "preservation_constraints", !1), (e) => e.id, "preservation_constraints");
|
|
651
|
+
let s = B(o.proof_obligations, "proof_obligations", !0);
|
|
652
|
+
G(s.map((e, t) => {
|
|
653
|
+
let n = R(e, `proof_obligations[${t}]`);
|
|
654
|
+
return z(n, [
|
|
655
|
+
"proof_id",
|
|
656
|
+
"statement",
|
|
657
|
+
"obligation_ids",
|
|
658
|
+
"evidence_kind",
|
|
659
|
+
"command",
|
|
660
|
+
"tool_identity",
|
|
661
|
+
"configuration_digest"
|
|
662
|
+
]), H(n.proof_id, "proof_id"), V(n.statement, "proof statement"), W(n.obligation_ids, "obligation_ids", !0, !0), K(n.obligation_ids, (e) => e, "obligation_ids"), V(n.evidence_kind, "evidence_kind"), ke(n.command), V(n.tool_identity, "tool_identity"), U(n.configuration_digest, "configuration_digest"), n.proof_id;
|
|
663
|
+
}), "duplicate proof identity"), K(s, (e) => e.proof_id, "proof_obligations");
|
|
664
|
+
let c = B(o.unknowns, "unknowns", !1);
|
|
665
|
+
G(c.map((e, t) => {
|
|
666
|
+
let n = R(e, `unknowns[${t}]`);
|
|
667
|
+
return z(n, [
|
|
668
|
+
"id",
|
|
669
|
+
"statement",
|
|
670
|
+
"disposition",
|
|
671
|
+
"owner",
|
|
672
|
+
...n.resolution === void 0 ? [] : ["resolution"]
|
|
673
|
+
]), H(n.id, "unknown id"), V(n.statement, "unknown statement"), V(n.owner, "unknown owner"), q(n.disposition, [
|
|
674
|
+
"open",
|
|
675
|
+
"accepted",
|
|
676
|
+
"deferred",
|
|
677
|
+
"resolved"
|
|
678
|
+
], "unknown disposition"), n.disposition === "resolved" ? V(n.resolution, "unknown resolution") : n.resolution !== void 0 && J("non-resolved unknown resolution"), n.id;
|
|
679
|
+
}), "duplicate unknown identity"), K(c, (e) => e.id, "unknowns");
|
|
680
|
+
let l = R(n.review_workflow, "review_workflow");
|
|
681
|
+
z(l, ["run_id", "decision_event_kind"]), H(l.run_id, "run_id"), Pe(l.decision_event_kind, "change_assurance.review_decided", "decision_event_kind");
|
|
682
|
+
}
|
|
683
|
+
function Oe(e, t, n) {
|
|
684
|
+
return B(e, t, n).map((e, n) => {
|
|
685
|
+
let r = R(e, `${t}[${n}]`);
|
|
686
|
+
return z(r, [
|
|
687
|
+
"id",
|
|
688
|
+
"statement",
|
|
689
|
+
"source_ids"
|
|
690
|
+
]), H(r.id, `${t} id`), V(r.statement, `${t} statement`), W(r.source_ids, `${t} source_ids`, !0, !0), K(r.source_ids, (e) => e, `${t} source_ids`), r.id;
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
function ke(e) {
|
|
694
|
+
let t = R(e, "command");
|
|
695
|
+
z(t, ["argv", "working_directory"]);
|
|
696
|
+
let n = B(t.argv, "argv", !0);
|
|
697
|
+
for (let e of n) typeof e != "string" && J("argv");
|
|
698
|
+
let r = V(t.working_directory, "working_directory"), i = r.split("/");
|
|
699
|
+
r !== "." && (r.startsWith("/") || r.includes("\\") || r.endsWith("/") || i.some((e) => e === "" || e === ".." || e === ".")) && J("working_directory must be normalized repository-relative POSIX path");
|
|
700
|
+
}
|
|
701
|
+
var Ae = "0".repeat(64);
|
|
702
|
+
function je(e) {
|
|
703
|
+
return m("sha256").update(Ne({
|
|
704
|
+
id: e.id,
|
|
705
|
+
ts: e.ts,
|
|
706
|
+
actor: e.actor,
|
|
707
|
+
kind: e.kind,
|
|
708
|
+
payload: e.payload,
|
|
709
|
+
prevHash: e.prevHash
|
|
710
|
+
})).digest("hex");
|
|
711
|
+
}
|
|
712
|
+
function Me(e) {
|
|
713
|
+
let t = Ae;
|
|
714
|
+
for (let n of e) {
|
|
715
|
+
try {
|
|
716
|
+
if (z(R(n, "ix-flow event"), [
|
|
717
|
+
"id",
|
|
718
|
+
"ts",
|
|
719
|
+
"actor",
|
|
720
|
+
"kind",
|
|
721
|
+
"payload",
|
|
722
|
+
"prevHash",
|
|
723
|
+
"hash"
|
|
724
|
+
]), n.prevHash !== t || n.hash !== je(n)) return !1;
|
|
725
|
+
} catch {
|
|
726
|
+
return !1;
|
|
727
|
+
}
|
|
728
|
+
t = n.hash;
|
|
729
|
+
}
|
|
730
|
+
return !0;
|
|
731
|
+
}
|
|
732
|
+
function Ne(e) {
|
|
733
|
+
if (Array.isArray(e)) return `[${e.map(Ne).join(",")}]`;
|
|
734
|
+
if (typeof e == "object" && e) {
|
|
735
|
+
let t = e;
|
|
736
|
+
return `{${Object.keys(t).sort().map((e) => `${JSON.stringify(e)}:${Ne(t[e])}`).join(",")}}`;
|
|
737
|
+
}
|
|
738
|
+
return JSON.stringify(e);
|
|
739
|
+
}
|
|
740
|
+
function R(e, t) {
|
|
741
|
+
(typeof e != "object" || !e || Array.isArray(e)) && J(`${t} object`);
|
|
742
|
+
let n = Object.getPrototypeOf(e);
|
|
743
|
+
return n !== Object.prototype && n !== null && J(`${t} plain object`), e;
|
|
744
|
+
}
|
|
745
|
+
function z(e, t) {
|
|
746
|
+
let n = new Set(t);
|
|
747
|
+
for (let t of Object.keys(e)) n.has(t) || J(`extra field ${t}`);
|
|
748
|
+
for (let t of n) Object.hasOwn(e, t) || J(`missing field ${t}`);
|
|
749
|
+
}
|
|
750
|
+
function B(e, t, n) {
|
|
751
|
+
return (!Array.isArray(e) || n && e.length === 0) && J(t), e;
|
|
752
|
+
}
|
|
753
|
+
function V(e, t) {
|
|
754
|
+
return (typeof e != "string" || e.length === 0) && J(t), e;
|
|
755
|
+
}
|
|
756
|
+
function H(e, t) {
|
|
757
|
+
(typeof e != "string" || !xe.test(e)) && J(t);
|
|
758
|
+
}
|
|
759
|
+
function U(e, t) {
|
|
760
|
+
(typeof e != "string" || !be.test(e)) && J(t);
|
|
761
|
+
}
|
|
762
|
+
function W(e, t, n, r) {
|
|
763
|
+
let i = B(e, t, n);
|
|
764
|
+
for (let e of i) (typeof e != "string" || e.length === 0) && J(t);
|
|
765
|
+
r && G(i, `duplicate ${t}`);
|
|
766
|
+
}
|
|
767
|
+
function G(e, t) {
|
|
768
|
+
new Set(e).size !== e.length && J(t);
|
|
769
|
+
}
|
|
770
|
+
function K(e, t, n) {
|
|
771
|
+
for (let r = 1; r < e.length; r++) Y(t(e[r - 1]), t(e[r])) > 0 && J(`${n} order`);
|
|
772
|
+
}
|
|
773
|
+
function q(e, t, n) {
|
|
774
|
+
t.includes(e) || J(n);
|
|
775
|
+
}
|
|
776
|
+
function Pe(e, t, n) {
|
|
777
|
+
e !== t && J(n);
|
|
778
|
+
}
|
|
779
|
+
function J(e) {
|
|
780
|
+
throw Error(`invalid change assurance record: ${e}`);
|
|
781
|
+
}
|
|
782
|
+
function Y(e, t) {
|
|
783
|
+
return e < t ? -1 : +(e > t);
|
|
784
|
+
}
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/change-assurance/attestations.ts
|
|
787
|
+
function Fe(e) {
|
|
788
|
+
let t = { ...e };
|
|
789
|
+
delete t.digest;
|
|
790
|
+
let n = Le(t);
|
|
791
|
+
Re(n, !1);
|
|
792
|
+
let r = I(n);
|
|
793
|
+
return X({
|
|
794
|
+
...n,
|
|
795
|
+
digest: r
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
function X(e) {
|
|
799
|
+
return Re(e, !0), ve(e), e;
|
|
800
|
+
}
|
|
801
|
+
function Ie(e) {
|
|
802
|
+
return F(X(e));
|
|
803
|
+
}
|
|
804
|
+
function Le(e) {
|
|
805
|
+
let t = structuredClone(e), n = Object.fromEntries(Object.entries(t.environment).sort(([e], [t]) => Y(e, t)));
|
|
806
|
+
return {
|
|
807
|
+
...t,
|
|
808
|
+
environment: n
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
function Re(e, t) {
|
|
812
|
+
let n = R(e, "attestation");
|
|
813
|
+
z(n, [
|
|
814
|
+
"schema_version",
|
|
815
|
+
"record_type",
|
|
816
|
+
"attestation_id",
|
|
817
|
+
...t ? ["digest"] : [],
|
|
818
|
+
"record_digest",
|
|
819
|
+
"candidate_revision",
|
|
820
|
+
"proof_id",
|
|
821
|
+
"command",
|
|
822
|
+
"tool",
|
|
823
|
+
"environment",
|
|
824
|
+
"observed_at",
|
|
825
|
+
"result",
|
|
826
|
+
"retained_output"
|
|
827
|
+
]), n.schema_version !== 1 && Z("schema_version"), n.record_type !== "proof_attestation" && Z("record_type"), H(n.attestation_id, "attestation_id"), t && U(n.digest, "digest"), U(n.record_digest, "record_digest"), V(n.candidate_revision, "candidate_revision"), H(n.proof_id, "proof_id"), ke(n.command);
|
|
828
|
+
let r = R(n.tool, "tool");
|
|
829
|
+
z(r, [
|
|
830
|
+
"identity",
|
|
831
|
+
"version",
|
|
832
|
+
"configuration_digest"
|
|
833
|
+
]), V(r.identity, "tool.identity");
|
|
834
|
+
let i = V(r.version, "tool.version");
|
|
835
|
+
/^(?:v?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?|[a-f0-9]{40}|[a-f0-9]{64})$/.test(i) || Z("tool.version is not immutable"), U(r.configuration_digest, "tool.configuration_digest");
|
|
836
|
+
let a = R(n.environment, "environment");
|
|
837
|
+
Object.keys(a).length === 0 && Z("environment");
|
|
838
|
+
for (let [e, t] of Object.entries(a)) t !== null && ![
|
|
839
|
+
"string",
|
|
840
|
+
"number",
|
|
841
|
+
"boolean"
|
|
842
|
+
].includes(typeof t) && Z(`environment.${e}`), typeof t == "number" && !Number.isFinite(t) && Z(`environment.${e}`);
|
|
843
|
+
let o = V(n.observed_at, "observed_at");
|
|
844
|
+
(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(o) || Number.isNaN(Date.parse(o))) && Z("observed_at"), [
|
|
845
|
+
"passed",
|
|
846
|
+
"failed",
|
|
847
|
+
"unavailable",
|
|
848
|
+
"not_computed"
|
|
849
|
+
].includes(n.result) || Z("result");
|
|
850
|
+
let s = R(n.retained_output, "retained_output");
|
|
851
|
+
z(s, [
|
|
852
|
+
"media_type",
|
|
853
|
+
"digest",
|
|
854
|
+
"size_bytes"
|
|
855
|
+
]), V(s.media_type, "retained_output.media_type"), U(s.digest, "retained_output.digest"), (!Number.isInteger(s.size_bytes) || s.size_bytes < 0) && Z("retained_output.size_bytes"), Array.isArray(n.environment) && B(n.environment, "environment", !0);
|
|
856
|
+
}
|
|
857
|
+
function Z(e) {
|
|
858
|
+
throw Error(`invalid proof attestation: ${e}`);
|
|
859
|
+
}
|
|
860
|
+
//#endregion
|
|
861
|
+
//#region src/change-assurance/store.ts
|
|
862
|
+
var ze = "change-assurance";
|
|
863
|
+
function Q(t) {
|
|
864
|
+
return p(e(t), ze);
|
|
865
|
+
}
|
|
866
|
+
function Be(e, t) {
|
|
867
|
+
return Xe(t), p(Q(e), "records", `${t}.json`);
|
|
868
|
+
}
|
|
869
|
+
function Ve(e, t) {
|
|
870
|
+
return Xe(t), p(Q(e), "attestations", t);
|
|
871
|
+
}
|
|
872
|
+
function He(e, t) {
|
|
873
|
+
let r = Ce(t), a = Be(e, t.digest);
|
|
874
|
+
if (i(f(a), { recursive: !0 }), n(a)) {
|
|
875
|
+
if (!Ye(s(a), r)) throw Error("record digest collision");
|
|
876
|
+
return a;
|
|
877
|
+
}
|
|
878
|
+
let o = `${a}.tmp-${process.pid}-${Date.now()}`;
|
|
879
|
+
return qe(o, r), l(o, a), Je(f(a)), a;
|
|
880
|
+
}
|
|
881
|
+
function Ue(e, t) {
|
|
882
|
+
let r = Be(e, t);
|
|
883
|
+
if (!n(r)) return null;
|
|
884
|
+
let i = L(N(s(r)));
|
|
885
|
+
if (i.digest !== t) throw Error("record path digest mismatch");
|
|
886
|
+
return i;
|
|
887
|
+
}
|
|
888
|
+
function We(e, t, r, o = {}) {
|
|
889
|
+
let c = X(N(t)), u = Ie(c);
|
|
890
|
+
if (c.retained_output.size_bytes !== r.byteLength || c.retained_output.digest !== M(r)) throw Error("retained output digest or size mismatch");
|
|
891
|
+
let d = Ve(e, c.digest), m = f(d);
|
|
892
|
+
if (i(m, { recursive: !0 }), n(d)) {
|
|
893
|
+
let e = s(p(d, "attestation.json")), t = s(p(d, "output.bin"));
|
|
894
|
+
if (!Ye(e, u) || !Ye(t, r)) throw Error("attestation digest collision");
|
|
895
|
+
return d;
|
|
896
|
+
}
|
|
897
|
+
let h = a(p(m, ".tmp-attestation-"));
|
|
898
|
+
try {
|
|
899
|
+
qe(p(h, "attestation.json"), u), qe(p(h, "output.bin"), r), Je(h), o.beforeRename?.(), l(h, d), Je(m);
|
|
900
|
+
} catch (e) {
|
|
901
|
+
throw e;
|
|
902
|
+
}
|
|
903
|
+
return d;
|
|
904
|
+
}
|
|
905
|
+
function Ge(e, t) {
|
|
906
|
+
let r = Ve(e, t);
|
|
907
|
+
if (!n(r)) return null;
|
|
908
|
+
let i = X(N(s(p(r, "attestation.json")))), a = s(p(r, "output.bin"));
|
|
909
|
+
if (i.digest !== t) throw Error("attestation path digest mismatch");
|
|
910
|
+
if (i.retained_output.size_bytes !== a.byteLength || i.retained_output.digest !== M(a)) throw Error("stored output integrity mismatch");
|
|
911
|
+
return {
|
|
912
|
+
attestation: i,
|
|
913
|
+
output: a
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
function Ke(e) {
|
|
917
|
+
let t = p(Q(e), "attestations");
|
|
918
|
+
if (!n(t)) return 0;
|
|
919
|
+
let r = c(t).filter((e) => e.startsWith(".tmp-attestation-"));
|
|
920
|
+
for (let e of r) u(p(t, e), {
|
|
921
|
+
recursive: !0,
|
|
922
|
+
force: !0
|
|
923
|
+
});
|
|
924
|
+
return r.length;
|
|
925
|
+
}
|
|
926
|
+
function qe(e, n) {
|
|
927
|
+
let i = o(e, "wx");
|
|
928
|
+
try {
|
|
929
|
+
let e = 0;
|
|
930
|
+
for (; e < n.byteLength;) {
|
|
931
|
+
let t = d(i, n, e, n.byteLength - e);
|
|
932
|
+
if (t === 0) throw Error("short write while retaining change assurance evidence");
|
|
933
|
+
e += t;
|
|
934
|
+
}
|
|
935
|
+
r(i);
|
|
936
|
+
} finally {
|
|
937
|
+
t(i);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
function Je(e) {
|
|
941
|
+
let n = o(e, "r");
|
|
942
|
+
try {
|
|
943
|
+
r(n);
|
|
944
|
+
} finally {
|
|
945
|
+
t(n);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
function Ye(e, t) {
|
|
949
|
+
return e.byteLength === t.byteLength && e.every((e, n) => e === t[n]);
|
|
950
|
+
}
|
|
951
|
+
function Xe(e) {
|
|
952
|
+
if (!/^[a-f0-9]{64}$/.test(e)) throw Error("change-assurance path requires a lowercase hexadecimal digest");
|
|
953
|
+
}
|
|
954
|
+
var Ze = P({ claim: "content integrity and recorded attribution only" });
|
|
955
|
+
//#endregion
|
|
956
|
+
//#region src/change-assurance/verify.ts
|
|
957
|
+
function Qe(e) {
|
|
958
|
+
let t = [];
|
|
959
|
+
try {
|
|
960
|
+
L(e.record);
|
|
961
|
+
} catch (n) {
|
|
962
|
+
let r = n instanceof Error ? n.message : String(n);
|
|
963
|
+
if (/digest mismatch/i.test(r)) t.push("record_digest_mismatch");
|
|
964
|
+
else return et(e);
|
|
965
|
+
}
|
|
966
|
+
let n = ot(t, "invalid"), r = [], i = [];
|
|
967
|
+
try {
|
|
968
|
+
i = we(e.record, e.parents);
|
|
969
|
+
} catch (e) {
|
|
970
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
971
|
+
/missing|no parent/i.test(t) ? r.push("parent_missing") : /revision gap/i.test(t) ? r.push("revision_gap") : /mismatch|cross-record/i.test(t) ? r.push("parent_mismatch") : r.push("parent_invalid");
|
|
972
|
+
}
|
|
973
|
+
let a = ot(r, "invalid"), o = Te(e.record, e.decision_history), s = {
|
|
974
|
+
outcome: o.outcome,
|
|
975
|
+
reasons: o.reasons
|
|
976
|
+
}, c = [];
|
|
977
|
+
e.record.impact_snapshot.completeness === "incomplete" && c.push("impact_incomplete"), e.record.impact_snapshot.truncated && c.push("impact_truncated"), e.record.definition.unknowns.some((e) => e.disposition !== "resolved") && c.push("unresolved_unknown");
|
|
978
|
+
let l = ot(c, "incomplete"), u = at(e.selections, (e) => e.proof_id), d = at(e.attestations, (e) => e.attestation?.digest ?? ""), f = at(e.audits, (e) => e.proof_id), p = new Set(e.record.definition.proof_obligations.map((e) => e.proof_id)), m = [];
|
|
979
|
+
e.selections.some((e) => !p.has(e.proof_id)) && m.push("proof_id_mismatch");
|
|
980
|
+
let h = e.record.definition.proof_obligations.slice().sort((e, t) => Y(e.proof_id, t.proof_id)).map((t) => {
|
|
981
|
+
let n = u.get(t.proof_id) ?? [], r = [];
|
|
982
|
+
n.length === 0 && r.push("attestation_missing"), n.length > 1 && r.push("attestation_schema_invalid");
|
|
983
|
+
let i = n.length === 1 ? d.get(n[0].attestation_digest) ?? [] : [];
|
|
984
|
+
i.length > 1 && r.push("attestation_schema_invalid");
|
|
985
|
+
let a = i.length === 1 ? i[0] : void 0;
|
|
986
|
+
if (n.length === 1 && i.length === 0 && r.push("attestation_missing"), a) {
|
|
987
|
+
let n = !0;
|
|
988
|
+
try {
|
|
989
|
+
X(a.attestation);
|
|
990
|
+
} catch (e) {
|
|
991
|
+
n = !1, /digest/i.test(e instanceof Error ? e.message : String(e)) ? r.push("attestation_digest_mismatch") : r.push("attestation_schema_invalid");
|
|
992
|
+
}
|
|
993
|
+
n && (a.attestation.record_digest !== e.record.digest && r.push("record_binding_mismatch"), a.attestation.candidate_revision !== e.candidate_revision && r.push("candidate_revision_mismatch"), a.attestation.proof_id !== t.proof_id && r.push("proof_id_mismatch"), (JSON.stringify(a.attestation.command.argv) !== JSON.stringify(t.command.argv) || a.attestation.command.working_directory !== t.command.working_directory) && r.push("command_mismatch"), a.attestation.tool.identity !== t.tool_identity && r.push("tool_identity_mismatch"), a.attestation.tool.configuration_digest !== t.configuration_digest && r.push("configuration_mismatch"), a.output === null ? r.push("output_missing") : (a.attestation.retained_output.size_bytes !== a.output.byteLength || a.attestation.retained_output.digest !== M(a.output)) && r.push("output_digest_mismatch"), a.attestation.result === "failed" && r.push("result_failed"), a.attestation.result === "unavailable" && r.push("result_unavailable"), a.attestation.result === "not_computed" && r.push("result_not_computed"));
|
|
994
|
+
}
|
|
995
|
+
let o = f.get(t.proof_id) ?? [], s = null;
|
|
996
|
+
if (o.length === 1) try {
|
|
997
|
+
s = $e(o[0], t.obligation_ids);
|
|
998
|
+
} catch {
|
|
999
|
+
r.push("audit_finding");
|
|
1000
|
+
}
|
|
1001
|
+
if (o.length > 1 && r.push("audit_finding"), !s || s.state === "not_evaluated") r.push("audit_not_evaluated");
|
|
1002
|
+
else {
|
|
1003
|
+
for (let e of t.obligation_ids) s.healthy_obligation_ids.includes(e) || r.push("audit_finding");
|
|
1004
|
+
for (let e of s.findings) r.push(it(e.kind));
|
|
1005
|
+
}
|
|
1006
|
+
let c = ut(r);
|
|
1007
|
+
return {
|
|
1008
|
+
proof_id: t.proof_id,
|
|
1009
|
+
obligation_ids: t.obligation_ids.slice().sort(),
|
|
1010
|
+
attestation_digest: a?.attestation.digest ?? n[0]?.attestation_digest ?? null,
|
|
1011
|
+
retained_output_digest: a?.attestation?.retained_output?.digest ?? null,
|
|
1012
|
+
audit_report_digest: s?.report_digest ?? null,
|
|
1013
|
+
audit_findings: (s?.findings ?? []).slice().sort((e, t) => Y(e.obligation_id, t.obligation_id) || Y(e.kind, t.kind)),
|
|
1014
|
+
outcome: lt(c),
|
|
1015
|
+
reasons: c
|
|
1016
|
+
};
|
|
1017
|
+
}), g = ut([
|
|
1018
|
+
...m,
|
|
1019
|
+
...n.reasons,
|
|
1020
|
+
...a.reasons,
|
|
1021
|
+
...s.reasons,
|
|
1022
|
+
...l.reasons,
|
|
1023
|
+
...h.flatMap((e) => e.reasons)
|
|
1024
|
+
]), _ = {
|
|
1025
|
+
schema_version: 1,
|
|
1026
|
+
record_type: "verification_receipt",
|
|
1027
|
+
record_digest: e.record.digest,
|
|
1028
|
+
candidate_revision: e.candidate_revision,
|
|
1029
|
+
decision_event: o.event,
|
|
1030
|
+
parent_digests: i,
|
|
1031
|
+
checks: {
|
|
1032
|
+
record: n,
|
|
1033
|
+
lineage: a,
|
|
1034
|
+
review: s,
|
|
1035
|
+
impact: l
|
|
1036
|
+
},
|
|
1037
|
+
proofs: h,
|
|
1038
|
+
unknowns: e.record.definition.unknowns.map(({ id: e, disposition: t }) => ({
|
|
1039
|
+
id: e,
|
|
1040
|
+
disposition: t
|
|
1041
|
+
})).sort((e, t) => Y(e.id, t.id)),
|
|
1042
|
+
outcome: lt(g),
|
|
1043
|
+
reasons: g
|
|
1044
|
+
};
|
|
1045
|
+
return tt({
|
|
1046
|
+
..._,
|
|
1047
|
+
digest: I(_)
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
function $e(e, t) {
|
|
1051
|
+
if (U(e.report_digest, "FR-032 report digest"), !e.report || !Array.isArray(e.report.findings) || !Array.isArray(e.report.healthy) || !Array.isArray(e.report.unevaluated)) throw Error("invalid retained FR-032 report");
|
|
1052
|
+
for (let t of e.report.findings) V(t.obligation, "FR-032 finding obligation"), V(t.kind, "FR-032 finding kind");
|
|
1053
|
+
for (let t of e.report.healthy) V(t, "FR-032 healthy obligation");
|
|
1054
|
+
let n = new Set(t);
|
|
1055
|
+
return {
|
|
1056
|
+
report_digest: e.report_digest,
|
|
1057
|
+
state: e.report.unevaluated.some((e) => n.has(e.obligation)) ? "not_evaluated" : "evaluated",
|
|
1058
|
+
findings: e.report.findings.filter((e) => n.has(e.obligation)).map((e) => ({
|
|
1059
|
+
obligation_id: e.obligation,
|
|
1060
|
+
kind: e.kind
|
|
1061
|
+
})),
|
|
1062
|
+
healthy_obligation_ids: e.report.healthy.filter((e) => n.has(e))
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function et(e) {
|
|
1066
|
+
let t = e?.record, n = typeof t == "object" && t && !Array.isArray(t) ? t : { retained_record: t }, r = n.digest, i = {
|
|
1067
|
+
schema_version: 1,
|
|
1068
|
+
record_type: "verification_receipt",
|
|
1069
|
+
record_digest: typeof r == "string" && /^[a-f0-9]{64}$/.test(r) ? r : I({ retained_record: n }),
|
|
1070
|
+
candidate_revision: typeof e?.candidate_revision == "string" && e.candidate_revision.length > 0 ? e.candidate_revision : "invalid",
|
|
1071
|
+
decision_event: null,
|
|
1072
|
+
parent_digests: [],
|
|
1073
|
+
checks: {
|
|
1074
|
+
record: {
|
|
1075
|
+
outcome: "invalid",
|
|
1076
|
+
reasons: ["schema_invalid"]
|
|
1077
|
+
},
|
|
1078
|
+
lineage: {
|
|
1079
|
+
outcome: "valid",
|
|
1080
|
+
reasons: []
|
|
1081
|
+
},
|
|
1082
|
+
review: {
|
|
1083
|
+
outcome: "valid",
|
|
1084
|
+
reasons: []
|
|
1085
|
+
},
|
|
1086
|
+
impact: {
|
|
1087
|
+
outcome: "valid",
|
|
1088
|
+
reasons: []
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
proofs: [],
|
|
1092
|
+
unknowns: [],
|
|
1093
|
+
outcome: "invalid",
|
|
1094
|
+
reasons: ["schema_invalid"]
|
|
1095
|
+
};
|
|
1096
|
+
return tt({
|
|
1097
|
+
...i,
|
|
1098
|
+
digest: I(i)
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
function tt(e) {
|
|
1102
|
+
let t = R(e, "verification receipt");
|
|
1103
|
+
if (z(t, [
|
|
1104
|
+
"schema_version",
|
|
1105
|
+
"record_type",
|
|
1106
|
+
"digest",
|
|
1107
|
+
"record_digest",
|
|
1108
|
+
"candidate_revision",
|
|
1109
|
+
"decision_event",
|
|
1110
|
+
"parent_digests",
|
|
1111
|
+
"checks",
|
|
1112
|
+
"proofs",
|
|
1113
|
+
"unknowns",
|
|
1114
|
+
"outcome",
|
|
1115
|
+
"reasons"
|
|
1116
|
+
]), t.schema_version !== 1 || t.record_type !== "verification_receipt") throw Error("invalid verification receipt schema identity");
|
|
1117
|
+
if (U(t.digest, "receipt digest"), U(t.record_digest, "record digest"), V(t.candidate_revision, "candidate revision"), t.decision_event !== null) {
|
|
1118
|
+
let e = R(t.decision_event, "decision event");
|
|
1119
|
+
z(e, [
|
|
1120
|
+
"run_id",
|
|
1121
|
+
"event_id",
|
|
1122
|
+
"event_hash",
|
|
1123
|
+
"chain_tail_hash",
|
|
1124
|
+
"recorded_actor",
|
|
1125
|
+
"decision"
|
|
1126
|
+
]), H(e.run_id, "decision run_id"), H(e.event_id, "decision event_id"), U(e.event_hash, "decision event_hash"), U(e.chain_tail_hash, "decision chain_tail_hash"), V(e.recorded_actor, "decision recorded_actor"), $(e.decision, [
|
|
1127
|
+
"approved",
|
|
1128
|
+
"rejected",
|
|
1129
|
+
"revise"
|
|
1130
|
+
], "decision");
|
|
1131
|
+
}
|
|
1132
|
+
for (let e of B(t.parent_digests, "parent digests", !1)) U(e, "parent digest");
|
|
1133
|
+
let n = R(t.checks, "checks");
|
|
1134
|
+
z(n, [
|
|
1135
|
+
"record",
|
|
1136
|
+
"lineage",
|
|
1137
|
+
"review",
|
|
1138
|
+
"impact"
|
|
1139
|
+
]);
|
|
1140
|
+
for (let e of [
|
|
1141
|
+
"record",
|
|
1142
|
+
"lineage",
|
|
1143
|
+
"review",
|
|
1144
|
+
"impact"
|
|
1145
|
+
]) nt(n[e], `checks.${e}`);
|
|
1146
|
+
for (let [e, n] of B(t.proofs, "proofs", !1).entries()) {
|
|
1147
|
+
let t = R(n, `proofs[${e}]`);
|
|
1148
|
+
z(t, [
|
|
1149
|
+
"proof_id",
|
|
1150
|
+
"obligation_ids",
|
|
1151
|
+
"attestation_digest",
|
|
1152
|
+
"retained_output_digest",
|
|
1153
|
+
"audit_report_digest",
|
|
1154
|
+
"audit_findings",
|
|
1155
|
+
"outcome",
|
|
1156
|
+
"reasons"
|
|
1157
|
+
]), H(t.proof_id, "proof_id");
|
|
1158
|
+
for (let e of B(t.obligation_ids, "obligation_ids", !0)) H(e, "obligation_id");
|
|
1159
|
+
for (let e of [
|
|
1160
|
+
"attestation_digest",
|
|
1161
|
+
"retained_output_digest",
|
|
1162
|
+
"audit_report_digest"
|
|
1163
|
+
]) t[e] !== null && U(t[e], e);
|
|
1164
|
+
for (let e of B(t.audit_findings, "audit_findings", !1)) {
|
|
1165
|
+
let t = R(e, "audit finding");
|
|
1166
|
+
z(t, ["obligation_id", "kind"]), H(t.obligation_id, "audit obligation_id"), V(t.kind, "audit finding kind");
|
|
1167
|
+
}
|
|
1168
|
+
rt(t);
|
|
1169
|
+
}
|
|
1170
|
+
for (let e of B(t.unknowns, "unknowns", !1)) {
|
|
1171
|
+
let t = R(e, "receipt unknown");
|
|
1172
|
+
z(t, ["id", "disposition"]), H(t.id, "unknown id"), $(t.disposition, [
|
|
1173
|
+
"open",
|
|
1174
|
+
"accepted",
|
|
1175
|
+
"deferred",
|
|
1176
|
+
"resolved"
|
|
1177
|
+
], "unknown disposition");
|
|
1178
|
+
}
|
|
1179
|
+
if (rt(t), t.digest !== I(t)) throw Error("verification receipt digest mismatch");
|
|
1180
|
+
return e;
|
|
1181
|
+
}
|
|
1182
|
+
function nt(e, t) {
|
|
1183
|
+
let n = R(e, t);
|
|
1184
|
+
z(n, ["outcome", "reasons"]), rt(n);
|
|
1185
|
+
}
|
|
1186
|
+
function rt(e) {
|
|
1187
|
+
$(e.outcome, [
|
|
1188
|
+
"valid",
|
|
1189
|
+
"invalid",
|
|
1190
|
+
"incomplete"
|
|
1191
|
+
], "outcome");
|
|
1192
|
+
let t = B(e.reasons, "reasons", !1);
|
|
1193
|
+
for (let e of t) $(e, st, "reason");
|
|
1194
|
+
let n = ut(t);
|
|
1195
|
+
if (n.length !== t.length || n.some((e, n) => e !== t[n])) throw Error("verification receipt reasons must be unique and lexicographically ordered");
|
|
1196
|
+
if (e.outcome !== lt(n)) throw Error("verification receipt outcome disagrees with reason precedence");
|
|
1197
|
+
}
|
|
1198
|
+
function $(e, t, n) {
|
|
1199
|
+
if (!t.includes(e)) throw Error(`invalid verification receipt ${n}`);
|
|
1200
|
+
}
|
|
1201
|
+
function it(e) {
|
|
1202
|
+
return e === "stale-evidence" ? "evidence_stale" : e === "suspect-link" ? "evidence_suspect" : e === "vacuous-evidence" ? "evidence_vacuous" : e === "undischarged" ? "evidence_unrelated" : "audit_finding";
|
|
1203
|
+
}
|
|
1204
|
+
function at(e, t) {
|
|
1205
|
+
let n = /* @__PURE__ */ new Map();
|
|
1206
|
+
for (let r of e) n.set(t(r), [...n.get(t(r)) ?? [], r]);
|
|
1207
|
+
return n;
|
|
1208
|
+
}
|
|
1209
|
+
function ot(e, t = "valid") {
|
|
1210
|
+
let n = ut(e);
|
|
1211
|
+
return {
|
|
1212
|
+
outcome: n.length === 0 ? "valid" : t,
|
|
1213
|
+
reasons: n
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
var st = /* @__PURE__ */ "schema_invalid.record_digest_mismatch.parent_missing.parent_invalid.parent_mismatch.revision_gap.impact_incomplete.impact_truncated.unresolved_unknown.decision_missing.event_chain_missing.event_chain_invalid.decision_mismatch.review_rejected.review_revision_requested.attestation_missing.attestation_schema_invalid.attestation_digest_mismatch.output_missing.output_digest_mismatch.record_binding_mismatch.candidate_revision_mismatch.proof_id_mismatch.command_mismatch.tool_identity_mismatch.configuration_mismatch.result_failed.result_unavailable.result_not_computed.evidence_stale.evidence_suspect.evidence_vacuous.evidence_unrelated.audit_finding.audit_not_evaluated".split("."), ct = /* @__PURE__ */ new Set([
|
|
1217
|
+
"parent_missing",
|
|
1218
|
+
"impact_incomplete",
|
|
1219
|
+
"impact_truncated",
|
|
1220
|
+
"unresolved_unknown",
|
|
1221
|
+
"decision_missing",
|
|
1222
|
+
"event_chain_missing",
|
|
1223
|
+
"attestation_missing",
|
|
1224
|
+
"output_missing",
|
|
1225
|
+
"result_unavailable",
|
|
1226
|
+
"result_not_computed",
|
|
1227
|
+
"audit_not_evaluated"
|
|
1228
|
+
]);
|
|
1229
|
+
function lt(e) {
|
|
1230
|
+
return e.length === 0 ? "valid" : e.every((e) => ct.has(e)) ? "incomplete" : "invalid";
|
|
1231
|
+
}
|
|
1232
|
+
function ut(e) {
|
|
1233
|
+
return [...new Set(e)].sort();
|
|
1234
|
+
}
|
|
1235
|
+
//#endregion
|
|
1236
|
+
export { ve as C, I as D, P as E, N as O, j as S, F as T, Se as _, Q as a, Me as b, Ue as c, He as d, Ie as f, Ce as g, je as h, Ve as i, Be as l, X as m, tt as n, We as o, Fe as p, Ze as r, Ge as s, Qe as t, Ke as u, Te as v, M as w, we as x, L as y };
|