@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.
Files changed (98) hide show
  1. package/README.md +30 -29
  2. package/dist/agent-record.d.ts +62 -0
  3. package/dist/agent-record.js +527 -0
  4. package/dist/agent-schemas.generated.d.ts +15 -0
  5. package/dist/agent-schemas.generated.js +5759 -0
  6. package/dist/case-file.d.ts +32 -89
  7. package/dist/case-file.js +41 -93
  8. package/dist/case.d.ts +339 -822
  9. package/dist/case.js +667 -1160
  10. package/dist/chain.d.ts +19 -47
  11. package/dist/chain.js +78 -205
  12. package/dist/claims.d.ts +211 -0
  13. package/dist/claims.js +1081 -0
  14. package/dist/cli.d.ts +45 -68
  15. package/dist/cli.js +618 -1022
  16. package/dist/compose.js +23 -65
  17. package/dist/crypto.d.ts +7 -8
  18. package/dist/crypto.js +60 -147
  19. package/dist/declaration.d.ts +68 -194
  20. package/dist/declaration.js +175 -518
  21. package/dist/environment.d.ts +9 -30
  22. package/dist/environment.js +17 -66
  23. package/dist/evidence.d.ts +119 -160
  24. package/dist/evidence.js +744 -1103
  25. package/dist/exit-codes.d.ts +11 -27
  26. package/dist/exit-codes.js +24 -59
  27. package/dist/file-match.d.ts +33 -79
  28. package/dist/file-match.js +33 -69
  29. package/dist/grading.d.ts +98 -135
  30. package/dist/grading.js +224 -380
  31. package/dist/handoff.d.ts +62 -160
  32. package/dist/handoff.js +153 -393
  33. package/dist/index.d.ts +14 -10
  34. package/dist/index.js +60 -167
  35. package/dist/json-schema.d.ts +29 -0
  36. package/dist/json-schema.js +298 -0
  37. package/dist/merkle.js +16 -28
  38. package/dist/message-parts.d.ts +56 -212
  39. package/dist/message-parts.js +142 -502
  40. package/dist/side-content.d.ts +11 -22
  41. package/dist/side-content.js +22 -65
  42. package/dist/types.d.ts +17 -0
  43. package/dist/types.js +19 -5
  44. package/dist/verifier.d.ts +40 -114
  45. package/dist/verifier.js +196 -535
  46. package/dist/witness-cache.d.ts +24 -45
  47. package/dist/witness-cache.js +38 -81
  48. package/dist/witness-lookup.d.ts +36 -57
  49. package/dist/witness-lookup.js +89 -139
  50. package/dist/zip-reader.d.ts +18 -33
  51. package/dist/zip-reader.js +19 -34
  52. package/package.json +11 -3
  53. package/src/agent-record.ts +608 -0
  54. package/src/agent-schemas.generated.ts +5764 -0
  55. package/src/case-file.ts +45 -109
  56. package/src/case.ts +814 -1328
  57. package/src/chain.ts +85 -224
  58. package/src/claims.ts +1253 -0
  59. package/src/cli.ts +714 -1176
  60. package/src/compose.ts +33 -79
  61. package/src/crypto.ts +60 -147
  62. package/src/declaration.ts +219 -656
  63. package/src/environment.ts +17 -65
  64. package/src/evidence.ts +958 -1381
  65. package/src/exit-codes.ts +24 -63
  66. package/src/file-match.ts +40 -89
  67. package/src/grading.ts +287 -421
  68. package/src/handoff.ts +175 -427
  69. package/src/index.ts +131 -177
  70. package/src/json-schema.ts +295 -0
  71. package/src/merkle.ts +16 -28
  72. package/src/message-parts.ts +155 -533
  73. package/src/side-content.ts +25 -68
  74. package/src/types.ts +55 -36
  75. package/src/verifier.ts +202 -526
  76. package/src/witness-cache.ts +45 -94
  77. package/src/witness-lookup.ts +107 -177
  78. package/src/zip-reader.ts +20 -38
  79. package/vectors/README.md +52 -34
  80. package/vectors/agent-record.json +2175 -0
  81. package/vectors/case-file-index.json +1 -1
  82. package/vectors/case-split.json +2 -2
  83. package/vectors/chain-reading.json +3 -3
  84. package/vectors/file-match.json +285 -148
  85. package/vectors/jcs-reader.json +6 -6
  86. package/vectors/pack-grading.json +102 -25
  87. package/vectors/sandbox-evidence.json +573 -581
  88. package/vectors/stamp-on-chain.json +18 -18
  89. package/vectors/witness-cache.json +49 -49
  90. package/dist/agent-proof.d.ts +0 -28
  91. package/dist/agent-proof.js +0 -226
  92. package/dist/run-adapters.d.ts +0 -10
  93. package/dist/run-adapters.js +0 -35
  94. package/dist/run.d.ts +0 -209
  95. package/dist/run.js +0 -1405
  96. package/src/agent-proof.ts +0 -264
  97. package/src/run-adapters.ts +0 -44
  98. package/src/run.ts +0 -1598
package/dist/cli.d.ts CHANGED
@@ -6,9 +6,10 @@ interface Cli {
6
6
  err: (s: string) => void;
7
7
  fetchImpl?: typeof fetch;
8
8
  }
9
- /** Each control character in `text` as a visible escape: `\x1b` for ESC,
10
- * `\u202e` for RIGHT-TO-LEFT OVERRIDE. Every other character is unchanged, a
11
- * backslash included, so a line with none is printed as it was. */
9
+ /**
10
+ * Each control character in `text` as a visible escape (`\x1b`, `‮`).
11
+ * Every other character, a backslash included, is unchanged.
12
+ */
12
13
  export declare function escapeControl(text: string): string;
13
14
  export declare function runCli(argv: string[], stream: Cli): Promise<number>;
14
15
  export declare const MAX_FOLDER_BYTES: number;
@@ -48,7 +49,7 @@ export declare const MAX_WALK_ENTRIES = 50000;
48
49
  export declare const MAX_JSON_DEPTH = 512;
49
50
  /**
50
51
  * The input could not be read as a case. The message is the whole report,
51
- * identical in both kernels, and the command exits 2 on it. `hint` is an
52
+ * identical in both kernels, and the command exits 4 on it. `hint` is an
52
53
  * optional second line naming a way through.
53
54
  */
54
55
  export declare class CaseInputError extends Error {
@@ -64,11 +65,10 @@ export declare class CaseInputError extends Error {
64
65
  export declare class WholeReadRefused extends CaseInputError {
65
66
  }
66
67
  /**
67
- * `bundle.json` bytes that `readBundleBytes` will not read. `tooDeep` separates
68
- * the one refusal that is not a parse error; `detail` is the parser's own words,
69
- * which differ by kernel and are printed by `verify` only. `duplicate` marks the
70
- * one parse refusal whose `detail` is kernel wording, identical in both kernels
71
- * (`duplicate key "<name>"`, proof#144), so both commands print it.
68
+ * `bundle.json` bytes `readBundleBytes` will not read. `tooDeep` marks the one
69
+ * refusal that is not a parse error. `detail` is the parser's words, which
70
+ * differ by kernel, so only `verify` prints it; `duplicate` marks the one
71
+ * `detail` both kernels word identically.
72
72
  */
73
73
  export declare class BundleReadError extends Error {
74
74
  readonly tooDeep: boolean;
@@ -78,12 +78,12 @@ export declare class BundleReadError extends Error {
78
78
  }
79
79
  export declare const NOT_I_JSON = "is not I-JSON (RFC 7493)";
80
80
  /**
81
- * How both `verify` and `case` turn `bundle.json` bytes into JSON, in both
82
- * kernels (`read_bundle_bytes` in the Python twin). UTF-8 with each ill-formed
83
- * sequence read as U+FFFD, and a byte-order mark kept; then nesting deeper than
84
- * MAX_JSON_DEPTH is refused before any parser walks into it; then `JSON.parse`,
85
- * refusing an object that repeats a member name (I-JSON, RFC 7493; proof#144).
86
- * Throws `BundleReadError`.
81
+ * How `verify` and `case` turn `bundle.json` bytes into JSON, in both kernels:
82
+ * UTF-8 with ill-formed sequences as U+FFFD and a BOM kept; nesting past
83
+ * MAX_JSON_DEPTH refused before parsing; then `JSON.parse`, refusing a repeated
84
+ * member name.
85
+ *
86
+ * @throws BundleReadError
87
87
  */
88
88
  export declare function readBundleBytes(bytes: Uint8Array): unknown;
89
89
  export interface SplitPack {
@@ -91,16 +91,15 @@ export interface SplitPack {
91
91
  bundlePath: string;
92
92
  bundleBytes: Uint8Array;
93
93
  /**
94
- * `logs/<event_id>.json` bytes by event id. A `Map` and not an object: an
95
- * event id is written by the audited party, and `obj["__proto__"] = bytes`
96
- * replaces the prototype instead of storing the disclosure.
94
+ * `logs/<event_id>.json` bytes by event id. A `Map`, because an event id is
95
+ * written by the audited party and `obj["__proto__"]` would not store it.
97
96
  */
98
97
  content: Map<string, Uint8Array>;
99
98
  unaccounted: string[];
100
99
  }
101
100
  export interface SplitCase {
102
101
  packs: SplitPack[];
103
- /** Paths that belong to no pack, sorted. Never read as part of a pack; a regular one is hashed, and nothing else is read of it (A41). */
102
+ /** Paths that belong to no pack, sorted. Never read as part of a pack; a regular one is hashed. */
104
103
  outside: string[];
105
104
  /** The part of `outside` that is not a regular file. Never followed, never opened. */
106
105
  notRegular: string[];
@@ -116,47 +115,35 @@ export interface TreeEntry {
116
115
  regular: boolean;
117
116
  /** The bytes of an entry read out of a case-file `.zip`. */
118
117
  data?: Uint8Array | null;
119
- /**
120
- * `true` for a symbolic link, on disk or an entry of a `.zip`: the one reason
121
- * a link is skipped under, here and under `--files`.
122
- */
118
+ /** `true` for a symbolic link, on disk or in a `.zip`. */
123
119
  link?: boolean;
124
120
  /** The `.zip` reader's own words for an entry it refused (not a link). */
125
121
  refused?: string;
126
122
  }
127
123
  /**
128
- * The page's `splitCase` followed by its `assemble` per pack, over the walk's
129
- * tree. `read` opens a file; it is called for the files a pack owns and for
130
- * nothing else.
124
+ * The page's `splitCase` then `assemble` per pack, over the walk's tree. `read`
125
+ * is called only for the files a pack owns.
131
126
  */
132
127
  export declare function splitCase(tree: Map<string, TreeEntry>, read: (entry: TreeEntry, key: string) => Promise<Uint8Array>): Promise<SplitCase>;
133
128
  /**
134
129
  * The bytes of the `witness-cache.json` beside a pack's `bundle.json`
135
- * (evidence-bundle 5.6.6, v1.25, A30), or `null`.
136
- *
137
- * The split rule is not changed for it: the file stays outside every pack,
138
- * listed as such, and is read here, for its contents, and hashed with the other
139
- * outside files (A41). It is read as a cache only where it is a regular file the split left outside every pack, so a file under another
140
- * pack's `logs/` is that pack's, and a link is never followed. A file that
141
- * cannot be read is no cache, never a refusal of the drop. One the run's
142
- * whole-read total has no room for is pushed onto `refused` when it is given,
143
- * so the output says so.
130
+ * (evidence-bundle.md §5.6.6), or `null`. Read only where it is a regular file
131
+ * the split left outside every pack, and it stays outside. An unreadable file
132
+ * is no cache, never a refusal; one the whole-read total has no room for is
133
+ * pushed onto `refused` when given.
144
134
  */
145
135
  export declare function witnessCacheBytes(tree: Map<string, TreeEntry>, split: SplitCase, pack: SplitPack, budget?: {
146
136
  n: number;
147
137
  }, refused?: string[]): Promise<Uint8Array | null>;
148
- /** `verify`'s reader, with the refusal named by the pack's path. */
149
- export declare function loadBundle(pack: SplitPack): unknown;
150
138
  /**
151
- * The refusal for a file `case` would hold whole that does not fit in what is
152
- * left of the 1 GiB a run reads whole. The same words in both kernels.
139
+ * `verify`'s reader over one pack's `bundle.json`: the bundle, or an empty object and why
140
+ * it could not be read. One pack that cannot be read is that pack's problem, never the
141
+ * case's: every other pack is still read.
153
142
  */
143
+ export declare function loadBundle(pack: SplitPack): [unknown, string | null];
144
+ /** The refusal for a file `case` would read whole past the run's 1 GiB. Same words in both kernels. */
154
145
  export declare const wholeReadRefusal: (key: string) => string;
155
- /**
156
- * Why `contents.json` reads as an unreadable index when the run's whole-read
157
- * total has no room for it, and when it cannot be read. The same words in both
158
- * kernels.
159
- */
146
+ /** Why `contents.json` reads as unreadable when it is over budget or cannot be read. */
160
147
  export declare const INDEX_OVER_BUDGET = "it would take case past the 1 GiB it reads whole in one run, so it was not read";
161
148
  export declare const INDEX_NOT_READ = "it could not be read";
162
149
  /** The note for a `witness-cache.json` the whole-read total had no room for. */
@@ -164,15 +151,13 @@ export declare const witnessCacheRefusedNote: (path: string) => string;
164
151
  /** The refusal for an archive file larger than MAX_ZIP_ARCHIVE_BYTES. */
165
152
  export declare const zipFileRefusal: (arg: string) => string;
166
153
  /**
167
- * A regular file's bytes. Opened without following a link and without
168
- * blocking, then checked again, so a file swapped for a link or a pipe after
169
- * the walk listed it is refused rather than followed or waited on.
154
+ * A regular file's bytes, opened without following a link or blocking, then
155
+ * rechecked, so a swapped-in link or pipe is refused.
170
156
  *
171
- * `budget` is the bytes a run may still hold whole from files on disk
172
- * (MAX_FOLDER_BYTES at the start). A file larger than what is left, or that
173
- * grows past it while it is read, is refused before it is held, so a file of a
174
- * terabyte under a pack's own names cannot exhaust memory. A `.zip` entry is
175
- * already in memory, inside the archive's own cap, and is not charged.
157
+ * `budget` is the bytes a run may still hold whole (MAX_FOLDER_BYTES at the
158
+ * start). A file larger than that, or that grows past it, is refused before it
159
+ * is held. A `.zip` entry is already in memory under the archive cap and is not
160
+ * charged.
176
161
  */
177
162
  export declare function readFileEntry(entry: TreeEntry, key: string, budget?: {
178
163
  n: number;
@@ -184,36 +169,28 @@ export declare function readFileEntry(entry: TreeEntry, key: string, budget?: {
184
169
  */
185
170
  export declare function treeFromArguments(paths: readonly string[]): Promise<Map<string, TreeEntry>>;
186
171
  export declare const CASE_USAGE: string;
187
- /**
188
- * The case verdict's code, moved only by an on-chain half that was asked for:
189
- * a witness that does not match is a failure whatever the reading said, and an
190
- * on-chain half that could not be settled is never a clean 0.
191
- */
192
- export declare function caseExitCode(verdict: string, onChainVerdict: string): number;
193
172
  export interface CaseFileData {
194
173
  root: string;
195
174
  index: string;
196
175
  case_id: string | null;
197
176
  findings: {
177
+ kind: string;
198
178
  rendered: string;
199
179
  }[];
200
180
  }
201
181
  /**
202
- * The index comparison, once per argument (5.6.3): each folder or case file
203
- * whose root holds `contents.json`. Every file under `packs/` and `report/` is
204
- * hashed for it, in pieces, as bytes, and nothing is parsed but the index. The
205
- * files share one total of 1 GiB across the run, charged in path order; a file
206
- * larger than what is left is reported as too large to hash, never as a match
207
- * and never as absent. It is never an input to the reading.
182
+ * The index comparison, once per argument with a `contents.json` at its root
183
+ * (§5.6.3). Files under `packs/` and `report/` are hashed in pieces, sharing a
184
+ * 1 GiB total in path order; a file past what is left reports as too large,
185
+ * never as a match or absent. Never an input to the reading.
208
186
  */
209
187
  export declare function caseFileReadings(tree: Map<string, TreeEntry>, whole?: {
210
188
  n: number;
211
189
  }, cap?: number): Promise<CaseFileData[]>;
212
190
  /**
213
- * `proof case <folder>... [--gateways <urls>] [--json]`. Every path out of the
214
- * command is an exit code from the table: an exception nobody expected exits 2,
215
- * never 1, because 1 would name the evidence failed over a defect in this
216
- * command.
191
+ * `proof case <folder>... [--gateways <urls>] [--json]`. An unexpected
192
+ * exception exits 4, never 1: 1 would call the evidence failed over a defect in
193
+ * this command.
217
194
  */
218
195
  export declare function runCase(argv: readonly string[], stream: Cli): Promise<number>;
219
196
  export declare function looseFiles(tree: Map<string, TreeEntry>, split: SplitCase, cap?: number): Promise<{