@sanning/proof 0.19.0 → 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 +343 -810
  9. package/dist/case.js +693 -1151
  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 +848 -1322
  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 +132 -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 +597 -580
  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
@@ -0,0 +1,211 @@
1
+ import type { EnvelopeFault } from "./types.js";
2
+ export declare const CLAIMS: readonly ["signed", "unchanged", "witnessed", "complete", "agreed", "follows_rules"];
3
+ export type Claim = (typeof CLAIMS)[number];
4
+ export declare const CLAIM_LABELS: Readonly<Record<Claim, string>>;
5
+ /** The question each claim answers, as a page prints it beside the label. */
6
+ export declare const CLAIM_QUESTIONS: Readonly<Record<Claim, string>>;
7
+ export declare const CLAIM_STATES: readonly ["proven", "disproven", "not_proven", "not_in_scope"];
8
+ export type ClaimState = (typeof CLAIM_STATES)[number];
9
+ export declare const NOT_PROVEN_REASONS: readonly ["missing", "unreadable", "not_checked"];
10
+ export type NotProvenReason = (typeof NOT_PROVEN_REASONS)[number];
11
+ /** Why a claim is `not_in_scope`: nothing in the pack or case is about it. */
12
+ export declare const NOT_IN_SCOPE_REASONS: readonly ["no_declaration", "no_declaration_and_no_handoff", "no_handoff", "no_agent_records", "no_agent_or_handoff_records"];
13
+ export type NotInScopeReason = (typeof NOT_IN_SCOPE_REASONS)[number];
14
+ export declare const VERDICTS: readonly ["verified", "failed", "incomplete"];
15
+ export type Verdict = (typeof VERDICTS)[number];
16
+ export declare const REASON_KINDS: readonly ["changed", "nonconforming"];
17
+ export type ReasonKind = (typeof REASON_KINDS)[number];
18
+ export declare const VERDICT_TITLES: Readonly<Record<Verdict, string>>;
19
+ export declare const VERDICT_COLOURS: Readonly<Record<Verdict, string>>;
20
+ /** The headline the person layer prints, by verdict and reason kind (`status:reason_kind`). */
21
+ export declare const PERSON_TITLES: Readonly<Record<string, string>>;
22
+ /** The same headline as a word and a sentence, for a surface that sets them apart. */
23
+ export declare const PERSON_TITLE_PARTS: Readonly<Record<string, {
24
+ word: string;
25
+ sentence: string | null;
26
+ }>>;
27
+ export declare const SANDBOX_PERSON_LINE = "these records are sandbox records, not production evidence.";
28
+ type Mapping = readonly [Claim, ClaimState, NotProvenReason | null];
29
+ /** kind -> [claim, state, reason]. The reason is set only on `not_proven`. */
30
+ export declare const KIND_CLAIMS: Readonly<Record<string, Mapping>>;
31
+ export declare const RECORD_REASON_CLAIMS: Readonly<Record<string, Mapping>>;
32
+ /** One plain line per record-layer rule. */
33
+ export declare const RECORD_REASON_LINES: Readonly<Record<string, string>>;
34
+ /** Every record-layer finding is a note (agent-events.md section 10.1). One plain sentence each. */
35
+ export declare const NOTE_FINDINGS: Readonly<Record<string, string>>;
36
+ /**
37
+ * Why a record's envelope does not verify (`ENVELOPE_FAULTS`), to the kind that says so.
38
+ * Read from the envelope layer's own classification, never from its prose.
39
+ */
40
+ export declare const ENVELOPE_FAULT_KINDS: Readonly<Record<EnvelopeFault, string>>;
41
+ /**
42
+ * What a problem is about: `[pack, record]` by position. `[p, null]` is a pack, `[null, null]`
43
+ * the case, and `[p, null, eventId]` a record pack `p` names and does not hold.
44
+ */
45
+ export type ProblemItem = readonly [number | null, number | null] | readonly [number | null, null, string];
46
+ /**
47
+ * One detailed kind, mapped to its claim and state. The optional values are what the
48
+ * person line reads; an absent one is `undefined`.
49
+ */
50
+ export interface Problem {
51
+ readonly kind: string;
52
+ readonly claim: Claim;
53
+ readonly state: ClaimState;
54
+ readonly reason: NotProvenReason | null;
55
+ readonly items: readonly ProblemItem[];
56
+ readonly count?: number;
57
+ readonly of?: number;
58
+ readonly presented?: number;
59
+ readonly key?: string;
60
+ readonly rule?: string;
61
+ }
62
+ /** A problem as the machine layer carries it. */
63
+ export interface ProblemJson {
64
+ kind: string;
65
+ claim: Claim;
66
+ state: ClaimState;
67
+ items: {
68
+ pack: number | null;
69
+ record: number | null;
70
+ event_id?: string;
71
+ }[];
72
+ reason?: NotProvenReason;
73
+ count?: number;
74
+ of?: number;
75
+ presented?: number;
76
+ key?: string;
77
+ rule?: string;
78
+ }
79
+ export declare function problemToJson(p: Problem): ProblemJson;
80
+ export interface ProblemValues {
81
+ rule?: string | null;
82
+ count?: number | null;
83
+ of?: number | null;
84
+ presented?: number | null;
85
+ key?: string | null;
86
+ }
87
+ /**
88
+ * The `Problem` of a detailed kind. A kind with no mapping throws: a new kind is a
89
+ * decision, never a quiet `verified`. `rule` is a record-layer reason; for
90
+ * `agent_record_incomplete` it decides the claim.
91
+ */
92
+ export declare function problem(kind: string, items?: readonly ProblemItem[], values?: ProblemValues): Problem;
93
+ /** The same problem about other items. */
94
+ export declare function withItems(p: Problem, items: readonly ProblemItem[]): Problem;
95
+ /**
96
+ * A disproof that rests on bytes nobody signed: the claim is `not_proven`
97
+ * (`not_checked`), never `disproven`.
98
+ */
99
+ export declare function downgraded(p: Problem): Problem;
100
+ /**
101
+ * The problems of a pack read with the bytes handed in beside it (`full`), where each
102
+ * disproof the same pack read without them (`signed`) does not also make is `downgraded`.
103
+ * A disproof only the signed reading makes is kept, and so is one the public record makes.
104
+ */
105
+ export declare function restOnSigned(full: readonly Problem[], signed: readonly Problem[]): Problem[];
106
+ /** One item a claim is about, with the names a person reads. */
107
+ export interface ClaimItem {
108
+ pack: number | null;
109
+ record: number | null;
110
+ pack_ref: string | null;
111
+ event_id: string | null;
112
+ }
113
+ /** One claim as the machine layer carries it. */
114
+ export interface ClaimEntry {
115
+ claim: Claim;
116
+ label: string;
117
+ question: string;
118
+ state: ClaimState;
119
+ items: ClaimItem[];
120
+ problems: ProblemJson[];
121
+ /** Why it is not proven, or, for `not_in_scope`, why nothing is about it. */
122
+ reason?: NotProvenReason | NotInScopeReason;
123
+ }
124
+ /** An item's `[pack_ref, event_id]`, the names a person reads. */
125
+ export type Labels = (pack: number | null, record: number | null) => readonly [string | null, string | null];
126
+ /**
127
+ * The claims, in claim order, as the machine layer carries them, each with its label and
128
+ * its question. A claim is in scope when it is named in `inScope` or a problem is about
129
+ * it; `signed`, `unchanged` and `witnessed` always are. A claim not in scope is left out,
130
+ * unless `notInScope` gives the reason, which it then carries as `not_in_scope`.
131
+ *
132
+ * `labels(pack, record)` gives an item's `[pack_ref, event_id]`; a record a pack names and
133
+ * does not hold carries its own `event_id`.
134
+ */
135
+ export declare function claimsOf(problems: readonly Problem[], inScope?: Iterable<string>, options?: {
136
+ notInScope?: Readonly<Partial<Record<Claim, NotInScopeReason>>>;
137
+ labels?: Labels;
138
+ }): ClaimEntry[];
139
+ /** A verdict: `reason_kind` only on `failed`. */
140
+ export interface VerdictJson {
141
+ status: Verdict;
142
+ reason_kind?: ReasonKind;
143
+ }
144
+ /** The verdict of a set of claims: failed, then incomplete, then verified. */
145
+ export declare function verdictOf(claims: readonly {
146
+ claim: string;
147
+ state: string;
148
+ }[]): VerdictJson;
149
+ /** One note for a record-layer finding carried by `records` records. */
150
+ export declare function renderFindingNote(finding: string, records: number): string;
151
+ /** One note as the machine layer carries it: its kind and its sentence. */
152
+ export interface NoteEntry {
153
+ kind: string;
154
+ text: string;
155
+ }
156
+ /** One person line, laid out: the claim, its state, what it is about and why. */
157
+ export interface LinePart {
158
+ claim: Claim;
159
+ state: ClaimState;
160
+ reason: NotProvenReason | NotInScopeReason | null;
161
+ count: number | null;
162
+ noun: string;
163
+ scope: string;
164
+ why: string;
165
+ text: string;
166
+ }
167
+ /** The person layer: what a reader is told, from the machine layer alone. */
168
+ export interface Person {
169
+ title: string;
170
+ title_parts: {
171
+ word: string;
172
+ sentence: string | null;
173
+ };
174
+ lines: string[];
175
+ line_parts: LinePart[];
176
+ next: string | null;
177
+ notes: string[];
178
+ note_parts: NoteEntry[];
179
+ sandbox: string | null;
180
+ witness: string;
181
+ witness_state: string;
182
+ }
183
+ export declare const NOTE_ORDER: readonly string[];
184
+ /**
185
+ * One note as the machine layer carries it. A kind with no place in `NOTE_ORDER` throws:
186
+ * a new note is a decision about where it is printed.
187
+ */
188
+ export declare function note(kind: string, text: string): NoteEntry;
189
+ /** The notes in `NOTE_ORDER`, each kind's notes in the order they came. */
190
+ export declare function orderedNotes(notes: readonly NoteEntry[]): NoteEntry[];
191
+ /**
192
+ * The person layer, from the machine layer alone: the title, one line per claim that is
193
+ * disproven or not proven (disproven first, then the claim order), one next action from the
194
+ * first line, the notes, the sandbox line and the witness line.
195
+ *
196
+ * Each string member has a structured twin for a surface that lays the words out:
197
+ * `title_parts` (the verdict word and the sentence), `line_parts` (each line's claim,
198
+ * state, reason, what it is about and why), `note_parts` (each note's kind) and
199
+ * `witness_state`. The text in a twin is the string member's, word for word.
200
+ */
201
+ export declare function renderPerson(verdict: VerdictJson, claims: readonly ClaimEntry[], notes: readonly NoteEntry[], environmentMarker: string | null, witness: string, witnessState: string): Person;
202
+ /** The person layer as the text report prints it, first, before the detail. */
203
+ export declare function personText(person: Person): string[];
204
+ /**
205
+ * Every problem the bundle verifier found, mapped. `pack` is the pack's position in a
206
+ * case (`null` for a single pack read on its own). The result is read structurally, so a
207
+ * field a result does not carry is never read as a failure; a result whose status is not
208
+ * `verified` always yields at least one problem, and a `failed` one a disproof.
209
+ */
210
+ export declare function bundleProblems(result: unknown, pack?: number | null): Problem[];
211
+ export {};