@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
@@ -1,26 +1,18 @@
1
1
  /**
2
- * The last second a block time can name and still be printed the same way by
3
- * both kernels: 9999-12-31T23:59:59Z. A larger value is a cache entry this
4
- * reader cannot print, and reads as none.
2
+ * The largest printable block time, 9999-12-31T23:59:59Z. A larger value reads
3
+ * as no entry.
5
4
  */
6
5
  export declare const MAX_BLOCK_TIME = 253402300799;
7
- /** The file's name, beside `bundle.json` in the pack's folder (5.6.1). */
6
+ /** The file's name, beside `bundle.json` (§5.6.1). */
8
7
  export declare const WITNESS_CACHE_NAME = "witness-cache.json";
9
- /**
10
- * The dispatch key: a file whose `cache_version` is absent or any other value
11
- * reads as no cache.
12
- */
8
+ /** Any other or absent `cache_version` reads as no cache. */
13
9
  export declare const WITNESS_CACHE_VERSION = "sanning.witness-cache/v1";
14
- /**
15
- * How deep `[` and `{` may nest in the file before it is refused unread: the
16
- * limit `bundle.json` and `contents.json` are read under.
17
- */
10
+ /** Nesting limit for the file, the same as for `bundle.json` and `contents.json`. */
18
11
  export declare const MAX_WITNESS_CACHE_DEPTH = 512;
19
12
  /**
20
- * One `cache.witnessed[]` entry that reads, joined to the stamp it names.
21
- * `witnessKind` and `witnessId` are the stamp's own `anchor_ref`, read from the
22
- * signed body, never from the cache: the cache says WHEN, and the body alone
23
- * says WHICH witness it is about.
13
+ * One readable `cache.witnessed[]` entry joined to its stamp. `witnessKind` and
14
+ * `witnessId` come from the signed body, never the cache: the cache says when,
15
+ * the body alone says which witness.
24
16
  */
25
17
  export interface CachedWitnessTime {
26
18
  stampRef: string;
@@ -30,11 +22,8 @@ export interface CachedWitnessTime {
30
22
  witnessId: string;
31
23
  }
32
24
  /**
33
- * One gateway's answer for one cached time. `matches`: the gateway named the
34
- * cached block height and block time. `differs`: it named a block, and the
35
- * block is not the cached one. `unreachable`: it named no block (a transport
36
- * failure, a refusal, an answer that is not one, or a witness not yet in a
37
- * block).
25
+ * One gateway's answer for one cached time. `unreachable` means it named no
26
+ * block: transport failure, refusal, malformed answer, or not yet mined.
38
27
  */
39
28
  export interface WitnessTimeAnswer {
40
29
  gateway: string;
@@ -43,10 +32,8 @@ export interface WitnessTimeAnswer {
43
32
  blockTime: number | null;
44
33
  }
45
34
  /**
46
- * One cached time, and what the public record said about it: `differs` when
47
- * any gateway named a different block, otherwise `matches` when any gateway
48
- * named the cached one, otherwise `not_checked`. The same worst-answer-wins
49
- * order as the byte lookup.
35
+ * One cached time and the public record's answer: `differs` if any gateway
36
+ * named another block, else `matches` if any named this one, else `not_checked`.
50
37
  */
51
38
  export interface WitnessTimeCheck {
52
39
  cached: CachedWitnessTime;
@@ -54,32 +41,24 @@ export interface WitnessTimeCheck {
54
41
  answers: WitnessTimeAnswer[];
55
42
  }
56
43
  /**
57
- * The cached witness times the `witness-cache.json` bytes `raw` give for the
58
- * signed `bundle` beside them, in the order the file lists them. `raw` is
59
- * `null` where the pack has no such file. Pure, and never throws. The file
60
- * reads only where it is a JSON object whose `cache_version` is
61
- * `WITNESS_CACHE_VERSION` and whose `witnessed` is a list. An entry reads only
62
- * where it is an object whose `stamp_ref` is 64 lowercase hex characters naming
63
- * exactly one stamp of the signed body that has an `anchor_ref`, whose
64
- * `block_height` is a non-negative safe integer, and whose `block_time` is a
65
- * whole number of seconds since 1970-01-01T00:00:00Z from 0 to
66
- * `MAX_BLOCK_TIME`. A `stamp_ref` two entries name reads for neither.
67
- * Everything else reads as no cache for the stamp it would have spoken for.
44
+ * The cached witness times `raw` gives for the signed `bundle`, in file order.
45
+ * `raw` is `null` where the pack has no cache file. Pure; never throws.
46
+ *
47
+ * An entry reads only if its `stamp_ref` names exactly one signed stamp with an
48
+ * `anchor_ref`, `block_height` is a non-negative safe integer, and `block_time`
49
+ * is Unix seconds from 0 to `MAX_BLOCK_TIME`. A `stamp_ref` named twice reads
50
+ * for neither.
68
51
  */
69
52
  export declare function readWitnessCache(bundle: unknown, raw: Uint8Array | null | undefined): CachedWitnessTime[];
70
- /** A block time as RFC 3339 UTC to the second, the way both kernels print it: `2026-09-08T12:10:07Z`. */
53
+ /** A block time as RFC 3339 UTC to the second: `2026-09-08T12:10:07Z`. */
71
54
  export declare function formatBlockTime(seconds: number): string;
72
55
  /** `block 1996701 at 2026-09-08T12:10:07Z`. */
73
56
  export declare function renderWitnessTime(blockHeight: number, blockTime: number): string;
74
- /**
75
- * The request body the lookup sends: one GraphQL query for one transaction's
76
- * block, as JCS, so both kernels send the same bytes.
77
- */
57
+ /** The lookup's request body: one GraphQL query as JCS, so the bytes are fixed. */
78
58
  export declare function witnessTimeQuery(witnessId: string): string;
79
59
  /**
80
- * Look each cached time up on every gateway, in order. With no gateways or no
81
- * `fetchImpl`, nothing is looked up and every time is `not_checked`. A witness
82
- * that is not `arweave`, or whose id is not a 43-character base64url
83
- * transaction id, is never looked up.
60
+ * Looks each cached time up on every gateway, in order. With no gateways or no
61
+ * `fetchImpl`, every time is `not_checked`. Only `arweave` witnesses with a
62
+ * 43-character base64url id are looked up.
84
63
  */
85
64
  export declare function checkWitnessCache(cached: readonly CachedWitnessTime[], gateways: readonly string[], fetchImpl: typeof fetch | undefined): Promise<WitnessTimeCheck[]>;
@@ -1,77 +1,44 @@
1
- // The witnessed-time cache: what a pack remembers about its witness, unverified
2
- // (evidence-bundle.md 5.6.6, v1.25, A30, proof#24).
1
+ // The witnessed-time cache (evidence-bundle.md §5.6.6): `witness-cache.json`
2
+ // beside a pack's `bundle.json`, giving the block height and time of each
3
+ // stamp's witness transaction as the pack builder fetched them. Nobody signs it
4
+ // and anyone can edit it, so every member is unverified.
3
5
  //
4
- // The TypeScript half of `src/sanning_proof/witness_cache.py`. Both kernels are
5
- // held to one table, `ts/vectors/witness-cache.json`, so neither can pass by
6
- // agreeing with the other.
6
+ // Trust rules:
7
+ // - `readWitnessCache` is never an input to the bundle verdict, the pack grade
8
+ // or the case reading.
9
+ // - `checkWitnessCache` asks the public record. A different block is a finding
10
+ // (`differs`); an unsettled lookup leaves the value `not_checked`.
11
+ // - Nothing here returns a time a reader may rely on. A gateway is named, never
12
+ // trusted.
7
13
  //
8
- // WHAT THE CACHE IS. A file beside the pack's `bundle.json`,
9
- // `witness-cache.json`, and never a member of the bundle. Its one list today,
10
- // `witnessed`, gives for each stamp the block height and block time of the
11
- // witness transaction, as the builder of the pack fetched them. Nobody signs
12
- // it, and anyone holding the pack can edit it. EVERY MEMBER OF THE FILE IS
13
- // UNVERIFIED BY CONSTRUCTION, and the name carries that warning to every field
14
- // added to it later.
15
- //
16
- // Because it is a separate file, a reader before v1.25 never opens it: it lists
17
- // it as a file outside every pack and reads the pack exactly as it would
18
- // without it. A `cache` member written INSIDE `bundle.json` is an unknown
19
- // wrapper field, counted in the signed scope by every reader, this one
20
- // included.
21
- //
22
- // WHAT THIS MODULE DOES, AND WHAT IT MUST NEVER DO.
23
- //
24
- // - `readWitnessCache` reads the file's bytes against the signed bundle beside
25
- // it. It is pure, and it is never an input to the bundle verdict, the pack
26
- // grade or the case reading: neither `verifyEvidenceBundle` nor `readCase` is
27
- // ever handed the file.
28
- // - `checkWitnessCache` looks each cached time up on the public record, where a
29
- // caller asked for a lookup. A lookup that answers with a different block is
30
- // a finding, reported on the witness line as `differs`. A lookup that does
31
- // not settle leaves the cached value labelled not checked.
32
- // - Nothing here returns a time a reader may rely on. The only time this module
33
- // ever reports as the public record's is one a gateway returned, and a
34
- // gateway is named, never trusted (6).
35
- //
36
- // A file that is absent, that is not JSON under the reader's rule, whose
37
- // `cache_version` is not `WITNESS_CACHE_VERSION`, whose `witnessed` is not a
38
- // list, or whose entry is not well formed, reads as no cache for what it could
39
- // not say. It is never a finding and never moves anything.
14
+ // A file that is absent, malformed, of another `cache_version`, or with a bad
15
+ // entry reads as no cache for what it could not say. It is never a finding.
40
16
  import { jsonDepthExceeds } from "./case-file.js";
41
17
  import { jcs, jcsParse } from "./verifier.js";
42
18
  /**
43
- * The last second a block time can name and still be printed the same way by
44
- * both kernels: 9999-12-31T23:59:59Z. A larger value is a cache entry this
45
- * reader cannot print, and reads as none.
19
+ * The largest printable block time, 9999-12-31T23:59:59Z. A larger value reads
20
+ * as no entry.
46
21
  */
47
22
  export const MAX_BLOCK_TIME = 253402300799;
48
- /** The file's name, beside `bundle.json` in the pack's folder (5.6.1). */
23
+ /** The file's name, beside `bundle.json` (§5.6.1). */
49
24
  export const WITNESS_CACHE_NAME = "witness-cache.json";
50
- /**
51
- * The dispatch key: a file whose `cache_version` is absent or any other value
52
- * reads as no cache.
53
- */
25
+ /** Any other or absent `cache_version` reads as no cache. */
54
26
  export const WITNESS_CACHE_VERSION = "sanning.witness-cache/v1";
55
- /**
56
- * How deep `[` and `{` may nest in the file before it is refused unread: the
57
- * limit `bundle.json` and `contents.json` are read under.
58
- */
27
+ /** Nesting limit for the file, the same as for `bundle.json` and `contents.json`. */
59
28
  export const MAX_WITNESS_CACHE_DEPTH = 512;
60
29
  // The bodies that carry `stamps[]`, the only witnesses the cache speaks for.
61
30
  const STAMP_BODIES = new Set(["sanning.stamp.trace/v1", "sanning.stamp.evidence/v2"]);
62
31
  const STAMP_REF = /^[0-9a-f]{64}$/;
63
- // The one witness kind a time is looked up for, and the only ids the lookup
64
- // sends: the same rule the byte lookup applies (evidence-bundle 5.1.1, v1.6).
32
+ // The only witness kind and id shape a lookup sends, as for the byte lookup
33
+ // (evidence-bundle §5.1.1).
65
34
  const ADAPTER_KIND = "arweave";
66
35
  const ARWEAVE_ID = /^[A-Za-z0-9_-]{43}$/;
67
- // A GraphQL answer to one query for one transaction is a few hundred bytes. A
68
- // deeper answer is not one, and refusing it before any parser recurses keeps
69
- // the two kernels on one reading of it.
36
+ // An answer for one transaction is a few hundred bytes. Refusing a deeper one
37
+ // before parsing keeps every reader on the same result.
70
38
  const MAX_ANSWER_DEPTH = 16;
71
39
  function isObject(v) {
72
40
  return v !== null && typeof v === "object" && !Array.isArray(v);
73
41
  }
74
- // A member the object itself holds, never one inherited from its prototype.
75
42
  function own(o, key) {
76
43
  return Object.prototype.hasOwnProperty.call(o, key) ? o[key] : undefined;
77
44
  }
@@ -82,8 +49,8 @@ function blockNumber(value, upper) {
82
49
  return null;
83
50
  return value;
84
51
  }
85
- // `stamp_ref` to `[kind, id]` for every stamp in the signed body that names a
86
- // witness. A `stamp_ref` spelled on two stamps names neither.
52
+ // `stamp_ref` to `[kind, id]` for each signed stamp that names a witness. A
53
+ // `stamp_ref` on two stamps names neither.
87
54
  function stampWitnesses(bundle) {
88
55
  const out = new Map();
89
56
  if (typeof bundle.body_type !== "string" || !STAMP_BODIES.has(bundle.body_type))
@@ -113,10 +80,8 @@ function stampWitnesses(bundle) {
113
80
  }
114
81
  return out;
115
82
  }
116
- // The file's JSON, read under the rule `contents.json` is read under (5.6.2):
117
- // strict UTF-8, no byte-order mark, no `NaN` or `Infinity`, no member named
118
- // twice, and nothing nested past `MAX_WITNESS_CACHE_DEPTH`. `undefined` for
119
- // anything else.
83
+ // Strict JSON as for `contents.json` (§5.6.2), within `MAX_WITNESS_CACHE_DEPTH`.
84
+ // `undefined` for anything else.
120
85
  function readFile(raw) {
121
86
  if (!(raw instanceof Uint8Array))
122
87
  return undefined;
@@ -130,17 +95,13 @@ function readFile(raw) {
130
95
  }
131
96
  }
132
97
  /**
133
- * The cached witness times the `witness-cache.json` bytes `raw` give for the
134
- * signed `bundle` beside them, in the order the file lists them. `raw` is
135
- * `null` where the pack has no such file. Pure, and never throws. The file
136
- * reads only where it is a JSON object whose `cache_version` is
137
- * `WITNESS_CACHE_VERSION` and whose `witnessed` is a list. An entry reads only
138
- * where it is an object whose `stamp_ref` is 64 lowercase hex characters naming
139
- * exactly one stamp of the signed body that has an `anchor_ref`, whose
140
- * `block_height` is a non-negative safe integer, and whose `block_time` is a
141
- * whole number of seconds since 1970-01-01T00:00:00Z from 0 to
142
- * `MAX_BLOCK_TIME`. A `stamp_ref` two entries name reads for neither.
143
- * Everything else reads as no cache for the stamp it would have spoken for.
98
+ * The cached witness times `raw` gives for the signed `bundle`, in file order.
99
+ * `raw` is `null` where the pack has no cache file. Pure; never throws.
100
+ *
101
+ * An entry reads only if its `stamp_ref` names exactly one signed stamp with an
102
+ * `anchor_ref`, `block_height` is a non-negative safe integer, and `block_time`
103
+ * is Unix seconds from 0 to `MAX_BLOCK_TIME`. A `stamp_ref` named twice reads
104
+ * for neither.
144
105
  */
145
106
  export function readWitnessCache(bundle, raw) {
146
107
  if (!isObject(bundle))
@@ -172,7 +133,7 @@ export function readWitnessCache(bundle, raw) {
172
133
  }
173
134
  return read.filter((c) => named.get(c.stampRef) === 1);
174
135
  }
175
- /** A block time as RFC 3339 UTC to the second, the way both kernels print it: `2026-09-08T12:10:07Z`. */
136
+ /** A block time as RFC 3339 UTC to the second: `2026-09-08T12:10:07Z`. */
176
137
  export function formatBlockTime(seconds) {
177
138
  return new Date(seconds * 1000).toISOString().replace(/\.\d{3}Z$/, "Z");
178
139
  }
@@ -180,10 +141,7 @@ export function formatBlockTime(seconds) {
180
141
  export function renderWitnessTime(blockHeight, blockTime) {
181
142
  return `block ${blockHeight} at ${formatBlockTime(blockTime)}`;
182
143
  }
183
- /**
184
- * The request body the lookup sends: one GraphQL query for one transaction's
185
- * block, as JCS, so both kernels send the same bytes.
186
- */
144
+ /** The lookup's request body: one GraphQL query as JCS, so the bytes are fixed. */
187
145
  export function witnessTimeQuery(witnessId) {
188
146
  return jcs({ query: `query{transaction(id:"${witnessId}"){block{height timestamp}}}` });
189
147
  }
@@ -235,10 +193,9 @@ async function ask(cached, gateway, fetchImpl) {
235
193
  return { gateway, outcome: same ? "matches" : "differs", blockHeight: height, blockTime: time };
236
194
  }
237
195
  /**
238
- * Look each cached time up on every gateway, in order. With no gateways or no
239
- * `fetchImpl`, nothing is looked up and every time is `not_checked`. A witness
240
- * that is not `arweave`, or whose id is not a 43-character base64url
241
- * transaction id, is never looked up.
196
+ * Looks each cached time up on every gateway, in order. With no gateways or no
197
+ * `fetchImpl`, every time is `not_checked`. Only `arweave` witnesses with a
198
+ * 43-character base64url id are looked up.
242
199
  */
243
200
  export async function checkWitnessCache(cached, gateways, fetchImpl) {
244
201
  const out = [];
@@ -1,6 +1,7 @@
1
+ import type { EvidenceBundleResult } from "./evidence.js";
1
2
  import type { WitnessLine, WitnessState } from "./case.js";
2
3
  import { type CachedWitnessTime, type WitnessTimeAnswer, type WitnessTimeCheck } from "./witness-cache.js";
3
- /** The seam every network call in this module goes through: used where given, else the ambient global `fetch`. */
4
+ /** The seam every network call goes through: the caller's `fetch` if given, else the ambient global. */
4
5
  export interface WitnessLookupOptions {
5
6
  fetchImpl?: typeof fetch;
6
7
  }
@@ -11,13 +12,9 @@ export interface OnChainRow {
11
12
  mismatched: number;
12
13
  unreachable: number;
13
14
  not_checked: number;
14
- /**
15
- * How many of the `not_checked` witnesses are simulated: a sandbox plane's
16
- * stand-in for a chain, never looked up. Present only where there
17
- * is one, so a production pack's row is unchanged.
18
- */
15
+ /** How many of the `not_checked` witnesses are simulated (a sandbox plane's stand-in for a chain, never looked up). Present only where there is one. */
19
16
  simulated?: number;
20
- /** Present only where the pack caches a witness time (5.6.6, v1.25, A30). */
17
+ /** Present only where the pack caches a witness time (5.6.6). */
21
18
  witness_times?: WitnessTimeRow[];
22
19
  }
23
20
  export interface WitnessTimeRow {
@@ -40,46 +37,37 @@ export interface OnChainHalf {
40
37
  checked: boolean;
41
38
  gateways: string[];
42
39
  packs: OnChainRow[];
43
- verdict: "not_checked" | "confirmed" | "failed" | "undetermined";
40
+ verdict: "not_checked" | "confirmed" | "differs" | "not_settled";
44
41
  }
42
+ /** One pack's witnesses as a lookup left them: how many, and each one's rollup. */
43
+ export declare function onChainRow(ref: string, result: EvidenceBundleResult): {
44
+ row: OnChainRow;
45
+ answered: Set<string>;
46
+ };
45
47
  /**
46
- * Each pack's witnesses, re-fetched through `verifyEvidenceBundle`. Outside
47
- * the case reading on purpose: `readCase` makes no network call, and neither
48
- * does the verify page's case reading, so the case verdict stays the one both
49
- * surfaces compute. This adds the half the reading names as not checked.
50
- *
51
- * Moved from `cli.ts` unchanged, apart from taking `fetchImpl` directly
52
- * instead of a `Cli` stream (`io.fetchImpl ?? fetch`, the same fallback the
53
- * CLI already applied at its own call site).
48
+ * `differs` where a lookup found other bytes or another time, `not_settled` where one
49
+ * did not settle, `confirmed` otherwise. Only `differs` moves a verdict.
54
50
  */
55
- export declare function onChainHalf(packs: readonly (readonly [string, unknown, readonly CachedWitnessTime[]])[], gateways: readonly string[], options?: WitnessLookupOptions,
51
+ export declare function onChainOutcome(rows: readonly OnChainRow[]): "differs" | "not_settled" | "confirmed";
56
52
  /**
57
- * Where given, receives for each pack the `stamp_ref` of every stamp whose
58
- * witness this lookup confirmed: the run reading evaluates an enclave token
59
- * at a stamp's interval end only there.
53
+ * Each pack's witnesses, re-fetched through `verifyEvidenceBundle`. Outside the
54
+ * case reading on purpose: `readCase` makes no network call, so the case verdict
55
+ * is the same on every surface. This adds the half the reading names as not checked.
60
56
  */
61
- witnessed?: string[][]): Promise<OnChainHalf>;
57
+ export declare function onChainHalf(packs: readonly (readonly [string, unknown, readonly CachedWitnessTime[]])[], gateways: readonly string[], options?: WitnessLookupOptions): Promise<OnChainHalf>;
62
58
  /**
63
- * `cached` is every witness time the packs cache (5.6.6, v1.25, A30). Where no
64
- * lookup ran, each is printed labelled not checked. Where one ran, each time
65
- * the public record matched is printed as the record's, each time no lookup
66
- * settled stays labelled not checked, and a time the record contradicts is the
67
- * reason the line reads `differs`.
68
- *
69
- * Moved from `cli.ts` unchanged: same inputs, same three states
70
- * (`WitnessState`), same rendering. The CLI's `case` command still calls this
71
- * exact function, so its witness line is unchanged.
59
+ * `cached` is every witness time the packs cache (5.6.6). Where no lookup ran,
60
+ * each is printed labelled not checked. Where one ran, each time the public
61
+ * record matched is printed as the record's, each time no lookup settled stays
62
+ * labelled not checked, and a time the record contradicts makes the line read
63
+ * `differs`.
72
64
  */
73
65
  export declare function witnessLine(onChain: OnChainHalf, cached?: readonly CachedWitnessTime[]): WitnessLine;
74
- /** The four states this export's result can carry. The CLI's own `WitnessState` plus `no_public_record`. */
66
+ /** The states a lookup can carry: the CLI's `WitnessState` plus `no_public_record`. */
75
67
  export type PublicRecordState = WitnessState | "no_public_record";
76
68
  /**
77
- * One pack, as this lookup needs it: the parsed `bundle.json` and, where the
78
- * pack carries one, the RAW BYTES of its `witness-cache.json`, read as part
79
- * of the pack, per proof#200's acceptance criteria, rather than as a
80
- * separately-loaded side file. `null` and `undefined` both mean "this pack has
81
- * no witness-cache.json", the same reading `readWitnessCache` gives a missing
82
- * file.
69
+ * One pack: the parsed `bundle.json` and, where it has one, the raw bytes of its
70
+ * `witness-cache.json`. `null` and `undefined` both mean no cache file.
83
71
  */
84
72
  export interface PublicRecordPack {
85
73
  /** How this pack is named in the result; carries no meaning beyond that. */
@@ -91,34 +79,25 @@ export interface PublicRecordResult {
91
79
  state: PublicRecordState;
92
80
  reasons: string[];
93
81
  services: string[];
94
- /** Witness times a pack caches that no lookup settled (5.6.6, v1.25, A30). */
82
+ /** Witness times a pack caches that no lookup settled (5.6.6). */
95
83
  cached?: [number, number][];
96
84
  /** Witness times the public record returned that matched a pack's cache. */
97
85
  recorded?: [number, number][];
98
- /** The line as both the CLI and a page print it, one string, kernel words. */
86
+ /** The line as the CLI and a page print it. */
99
87
  rendered: string;
100
88
  }
101
89
  /**
102
- * The public-record lookup the CLI runs with `--gateways`, exported so a
103
- * consumer that is not the CLI can run the SAME lookup rather than copy it
104
- * (proof#200; the copy this closes is verify-page#70's `src/lib/verify.ts`).
90
+ * The public-record lookup the CLI runs with `--gateways`, for non-CLI callers.
105
91
  *
106
- * `packs` is every pack in the drop being read; `gateways` is empty for an
107
- * offline reading, which never makes a network call and always answers
108
- * `not_checked` or `no_public_record`. `options.fetchImpl` is the one seam a
109
- * network call goes through, a browser page supplies its own `fetchImpl`;
110
- * with none given this falls back to the ambient global `fetch`, so a
111
- * browser page and a test can each supply their own and Node's `fetch` is
112
- * never assumed where a caller passed something else.
92
+ * `packs` is every pack in the drop; `gateways` is empty for an offline reading,
93
+ * which makes no network call and answers `not_checked` or `no_public_record`.
113
94
  *
114
- * `state` is `confirmed` only about the BYTES: the public record holds what a
115
- * pack names. It says nothing about whether the pack itself verifies (its
116
- * wrapper signature, its `body_hash`), and a caller must never show
117
- * `confirmed` apart from the pack's own verdict (proof#201).
95
+ * `state` is `confirmed` only about the bytes: the public record holds what a
96
+ * pack names. It says nothing about whether the pack itself verifies, so a
97
+ * caller must never show `confirmed` apart from the pack's own verdict.
118
98
  *
119
- * Never throws. Every input, including a malformed pack, a non-string
120
- * gateway, or a `fetchImpl` that itself misbehaves, is read as untrusted, and
121
- * anything this function or what it calls cannot make sense of settles as
122
- * `not_checked` rather than escape as an exception.
99
+ * Never throws. Every input (a malformed pack, a non-string gateway, a
100
+ * misbehaving `fetchImpl`) is untrusted, and anything it cannot make sense of
101
+ * settles as `not_checked`.
123
102
  */
124
103
  export declare function lookupPublicRecord(packs: readonly PublicRecordPack[], gateways: readonly string[], options?: WitnessLookupOptions): Promise<PublicRecordResult>;