@sanning/proof 0.19.1 → 0.20.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/README.md +30 -29
- package/dist/agent-record.d.ts +62 -0
- package/dist/agent-record.js +527 -0
- package/dist/agent-schemas.generated.d.ts +15 -0
- package/dist/agent-schemas.generated.js +5759 -0
- package/dist/case-file.d.ts +32 -89
- package/dist/case-file.js +41 -93
- package/dist/case.d.ts +339 -822
- package/dist/case.js +667 -1160
- package/dist/chain.d.ts +19 -47
- package/dist/chain.js +78 -205
- package/dist/claims.d.ts +211 -0
- package/dist/claims.js +1081 -0
- package/dist/cli.d.ts +45 -68
- package/dist/cli.js +618 -1022
- package/dist/compose.js +23 -65
- package/dist/crypto.d.ts +7 -8
- package/dist/crypto.js +60 -147
- package/dist/declaration.d.ts +68 -194
- package/dist/declaration.js +175 -518
- package/dist/environment.d.ts +9 -30
- package/dist/environment.js +17 -66
- package/dist/evidence.d.ts +119 -160
- package/dist/evidence.js +744 -1103
- package/dist/exit-codes.d.ts +11 -27
- package/dist/exit-codes.js +24 -59
- package/dist/file-match.d.ts +33 -79
- package/dist/file-match.js +33 -69
- package/dist/grading.d.ts +98 -135
- package/dist/grading.js +224 -380
- package/dist/handoff.d.ts +62 -160
- package/dist/handoff.js +153 -393
- package/dist/index.d.ts +14 -10
- package/dist/index.js +60 -167
- package/dist/json-schema.d.ts +29 -0
- package/dist/json-schema.js +298 -0
- package/dist/merkle.js +16 -28
- package/dist/message-parts.d.ts +56 -212
- package/dist/message-parts.js +142 -502
- package/dist/side-content.d.ts +11 -22
- package/dist/side-content.js +22 -65
- package/dist/types.d.ts +17 -0
- package/dist/types.js +19 -5
- package/dist/verifier.d.ts +40 -114
- package/dist/verifier.js +196 -535
- package/dist/witness-cache.d.ts +24 -45
- package/dist/witness-cache.js +38 -81
- package/dist/witness-lookup.d.ts +36 -57
- package/dist/witness-lookup.js +89 -139
- package/dist/zip-reader.d.ts +18 -33
- package/dist/zip-reader.js +19 -34
- package/package.json +11 -3
- package/src/agent-record.ts +608 -0
- package/src/agent-schemas.generated.ts +5764 -0
- package/src/case-file.ts +45 -109
- package/src/case.ts +814 -1328
- package/src/chain.ts +85 -224
- package/src/claims.ts +1253 -0
- package/src/cli.ts +714 -1176
- package/src/compose.ts +33 -79
- package/src/crypto.ts +60 -147
- package/src/declaration.ts +219 -656
- package/src/environment.ts +17 -65
- package/src/evidence.ts +958 -1381
- package/src/exit-codes.ts +24 -63
- package/src/file-match.ts +40 -89
- package/src/grading.ts +287 -421
- package/src/handoff.ts +175 -427
- package/src/index.ts +131 -177
- package/src/json-schema.ts +295 -0
- package/src/merkle.ts +16 -28
- package/src/message-parts.ts +155 -533
- package/src/side-content.ts +25 -68
- package/src/types.ts +55 -36
- package/src/verifier.ts +202 -526
- package/src/witness-cache.ts +45 -94
- package/src/witness-lookup.ts +107 -177
- package/src/zip-reader.ts +20 -38
- package/vectors/README.md +52 -34
- package/vectors/agent-record.json +2175 -0
- package/vectors/case-file-index.json +1 -1
- package/vectors/case-split.json +2 -2
- package/vectors/chain-reading.json +3 -3
- package/vectors/file-match.json +285 -148
- package/vectors/jcs-reader.json +6 -6
- package/vectors/pack-grading.json +102 -25
- package/vectors/sandbox-evidence.json +573 -581
- package/vectors/stamp-on-chain.json +18 -18
- package/vectors/witness-cache.json +49 -49
- package/dist/agent-proof.d.ts +0 -28
- package/dist/agent-proof.js +0 -226
- package/dist/run-adapters.d.ts +0 -10
- package/dist/run-adapters.js +0 -35
- package/dist/run.d.ts +0 -209
- package/dist/run.js +0 -1405
- package/src/agent-proof.ts +0 -264
- package/src/run-adapters.ts +0 -44
- package/src/run.ts +0 -1598
package/src/environment.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
// The environment marker:
|
|
1
|
+
// The environment marker: whether a pack holds sandbox evidence.
|
|
2
2
|
//
|
|
3
|
-
// `environment` is an
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// The marker is read from the signed envelopes the pack holds, never from a
|
|
11
|
-
// wrapper field, a pack name or anything else the holder could write without a
|
|
12
|
-
// key. It never moves the verdict word: a sandbox pack that verifies is still
|
|
13
|
-
// `verified`, and the commands map that to the headline `SANDBOX` and exit 5
|
|
14
|
-
// (`sandboxExit` in `./exit-codes.ts`). The Python twin is
|
|
15
|
-
// `src/sanning_proof/environment.py`.
|
|
3
|
+
// `environment` is an optional field inside every envelope's signed scope,
|
|
4
|
+
// `"dev"` or `"production"` (envelope-spec section 2). It is read from the signed
|
|
5
|
+
// envelopes a pack holds, never from a wrapper field, a pack name or anything
|
|
6
|
+
// else the holder could write without a key. It is a label, never a claim or a
|
|
7
|
+
// verdict: a sandbox pack that verifies is still `verified`, prints the sandbox
|
|
8
|
+
// line, and exits 3 (`exitCodeFor`).
|
|
16
9
|
|
|
17
|
-
import { isAgentProofSpec } from "./agent-proof.js";
|
|
18
10
|
import {
|
|
19
11
|
ANCHOR_TRACE_BODY_TYPE,
|
|
20
12
|
EXPORT_BODY_TYPE,
|
|
@@ -26,16 +18,7 @@ import {
|
|
|
26
18
|
/** `"dev"` when every envelope is signed `dev`, `"mixed"` when only some are. */
|
|
27
19
|
export type EnvironmentMarker = "dev" | "mixed";
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
export const SANDBOX_HEADLINE = "SANDBOX";
|
|
31
|
-
|
|
32
|
-
/** The title `case` prints for sandbox evidence in place of `Verified` (case titles are title case). */
|
|
33
|
-
export const SANDBOX_TITLE = "Sandbox";
|
|
34
|
-
|
|
35
|
-
/** The one line printed with it, and with any other headline, wherever the marker is present. */
|
|
36
|
-
export const SANDBOX_LINE = "Sandbox evidence (environment dev): not production evidence";
|
|
37
|
-
|
|
38
|
-
// The same bound `resolveTraceEvents` puts on unwrapping export wrappers.
|
|
21
|
+
// Same bound as `resolveTraceEvents` puts on unwrapping export wrappers.
|
|
39
22
|
const MAX_EXPORT_UNWRAP = 4;
|
|
40
23
|
|
|
41
24
|
function isObject(v: unknown): v is Record<string, unknown> {
|
|
@@ -56,19 +39,12 @@ function entryEnvelopes(list: unknown, out: Record<string, unknown>[]): void {
|
|
|
56
39
|
}
|
|
57
40
|
|
|
58
41
|
/**
|
|
59
|
-
* The signed envelopes a pack holds:
|
|
60
|
-
* anchor-trace body,
|
|
61
|
-
*
|
|
62
|
-
* envelope. A stamp-trace body holds none. A value that is not an object is
|
|
63
|
-
* not an envelope and is not counted.
|
|
42
|
+
* The signed envelopes a pack holds: checkpoint and event envelopes of an
|
|
43
|
+
* anchor-trace body, event envelopes of a stamp-evidence body (also inside an
|
|
44
|
+
* export's inline source bundle). Non-objects are not counted.
|
|
64
45
|
*/
|
|
65
46
|
export function packEnvelopes(bundle: unknown): Record<string, unknown>[] {
|
|
66
47
|
const out: Record<string, unknown>[] = [];
|
|
67
|
-
if (isObject(bundle) && isAgentProofSpec(own(bundle, "spec_version"))) {
|
|
68
|
-
const env = own(bundle, "checkpoint_envelope");
|
|
69
|
-
if (isObject(env)) out.push(env);
|
|
70
|
-
return out;
|
|
71
|
-
}
|
|
72
48
|
let cur: unknown = bundle;
|
|
73
49
|
for (let depth = 0; depth < MAX_EXPORT_UNWRAP; depth++) {
|
|
74
50
|
if (!isObject(cur)) return out;
|
|
@@ -91,10 +67,9 @@ export function packEnvelopes(bundle: unknown): Record<string, unknown>[] {
|
|
|
91
67
|
}
|
|
92
68
|
|
|
93
69
|
/**
|
|
94
|
-
* The
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* is, which is every production pack and every pack that holds no envelope.
|
|
70
|
+
* The marker over one or more packs: `"dev"` where every envelope is signed
|
|
71
|
+
* `environment: "dev"`, `"mixed"` where only some are, `null` where none is
|
|
72
|
+
* (including a pack that holds no envelope).
|
|
98
73
|
*/
|
|
99
74
|
export function environmentMarker(bundles: readonly unknown[]): EnvironmentMarker | null {
|
|
100
75
|
let total = 0;
|
|
@@ -110,32 +85,9 @@ export function environmentMarker(bundles: readonly unknown[]): EnvironmentMarke
|
|
|
110
85
|
}
|
|
111
86
|
|
|
112
87
|
/**
|
|
113
|
-
* Whether a
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* one thing that keeps the bundle from `verified` is a simulated witness
|
|
117
|
-
* nobody can look up: no mismatch, no unreachable gateway, no witness of
|
|
118
|
-
* another kind, no checkpoint or stamp witnessed by nobody.
|
|
119
|
-
*/
|
|
120
|
-
export function onlySimulatedUnsettled(result: EvidenceBundleResult): boolean {
|
|
121
|
-
const witnesses = [...result.checkpoints, ...(result.stamps ?? [])];
|
|
122
|
-
if (witnesses.length === 0 || result.events.length === 0) return false;
|
|
123
|
-
let simulated = 0;
|
|
124
|
-
for (const w of witnesses) {
|
|
125
|
-
if (w.anchorRef === null) return false;
|
|
126
|
-
if (w.anchorRef.kind === SIMULATED_WITNESS_KIND) simulated++;
|
|
127
|
-
else if (w.onChain?.rollup !== "confirm") return false;
|
|
128
|
-
}
|
|
129
|
-
return simulated > 0;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Whether a run with gateways counted only simulated witnesses, so nothing
|
|
134
|
-
* was looked up on a chain: gateways were passed, the run is not counted as
|
|
135
|
-
* checked on a chain, and it holds a simulated witness. A run that stopped
|
|
136
|
-
* before its witnesses were read (a bad wrapper signature or `body_hash`, an
|
|
137
|
-
* unknown `body_type`, an export whose source is not inline) holds none, so it
|
|
138
|
-
* is not one, and prints what it printed before simulated witnesses existed.
|
|
88
|
+
* Whether a run with gateways counted only simulated witnesses, so nothing was
|
|
89
|
+
* looked up on a chain. A run that stopped before reading its witnesses holds
|
|
90
|
+
* none and is not one.
|
|
139
91
|
*/
|
|
140
92
|
export function simulatedOnlyRun(result: EvidenceBundleResult, gateways: readonly string[]): boolean {
|
|
141
93
|
if (gateways.length === 0 || result.onChainChecked) return false;
|