@mikeargento/bitgraph-player 0.3.0 → 0.5.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.
@@ -0,0 +1,156 @@
1
+ /**
2
+ * `check`: what a bundle establishes about the recordings it holds, said
3
+ * plainly, offline, in the Player's three values.
4
+ *
5
+ * This is a SPEC section 8 convenience: a distinct subcommand that never
6
+ * touches evaluation semantics. It asks no rule-author question ("was A
7
+ * before B"); it asks the reader's question ("is this recording sound, and
8
+ * what bounds it"), over the audit pipeline's canonical interpretation of
9
+ * the bundle, and answers per line with TRUE, FALSE, or UNDETERMINED.
10
+ *
11
+ * The vocabulary, and the line it lives or dies on:
12
+ *
13
+ * TRUE evidence in hand establishes the property.
14
+ * FALSE evidence in hand CONTRADICTS the property: bytes that do
15
+ * not hash to the digest they sit beside, a signature that
16
+ * fails, an attestation whose user_data is not this proof, a
17
+ * block header that does not hash to its anchor's block hash,
18
+ * two recordings that cannot both be right.
19
+ * UNDETERMINED the evidence does not decide. Missing bytes, a missing
20
+ * witness, an environment that cannot run a check, a
21
+ * measurement this verifier does not know. Absence is never
22
+ * a verdict, and this command never degrades a failed or
23
+ * missing check into a FALSE (project rule: a failed read is
24
+ * never a verdict).
25
+ *
26
+ * The overall result is the strong-Kleene `all` over every line the report
27
+ * emits: each recording's lines, each anchor's lines, and each structural
28
+ * contradiction. Ethereum BOUNDS are reported descriptively per recording
29
+ * and never enter the conjunction: a bundle without an anchor has an
30
+ * unbounded recording, not an unsound one. A witness that is PRESENT and
31
+ * fails is a contradiction and does enter.
32
+ *
33
+ * Excerpt honesty. A single export is an excerpt of a chain: its recording
34
+ * links to a predecessor that is not in the bundle, and the counter
35
+ * positions between its anchors are absent. The audit reports those as
36
+ * anomalies because it is built to audit whole epochs; here they are
37
+ * expected and are reported as notes, never as verdicts. Real
38
+ * contradictions (collisions, forks, malformed links, signer changes)
39
+ * still surface as FALSE.
40
+ *
41
+ * Enclave identity. An attestation proves that SOME AWS Nitro enclave
42
+ * running code with the attested PCR0 signed this proof's key. Whether
43
+ * that PCR0 is a published BitGraph enclave measurement is a fact this
44
+ * verifier carries as DECLARED knowledge (KNOWN_ENCLAVE_MEASUREMENTS, from
45
+ * server/commit-service/reproducible-build/PINS.md). A measurement outside
46
+ * that list is UNDETERMINED, never FALSE: it is beyond what this build of
47
+ * the verifier knows, which is exactly how an offline verifier should age.
48
+ *
49
+ * Determinism. The report contains no wall-clock time, no machine path, and
50
+ * no run-local value; bundle-relative entry paths are bundle content and
51
+ * are allowed. Same bundle bytes, same report bytes.
52
+ */
53
+ import type { AuditResult, IngestResult } from "@mikeargento/bitgraph-audit";
54
+ import type { ThreeValued } from "./types.js";
55
+ /**
56
+ * Published BitGraph enclave PCR0 measurements, per PINS.md, oldest first.
57
+ * Each remains correct for proofs minted during its own period; a proof
58
+ * carries its own measurement, so nothing here needs to be "current" for
59
+ * an old proof to check. Lowercase hex, exactly as attestations report.
60
+ */
61
+ export declare const KNOWN_ENCLAVE_MEASUREMENTS: ReadonlyArray<{
62
+ pcr0: string;
63
+ label: string;
64
+ period: string;
65
+ }>;
66
+ /** One checked property, three-valued, with a plain-language reason. */
67
+ export interface CheckLine {
68
+ name: "file" | "signature" | "attestation" | "enclave" | "witness" | "contradiction";
69
+ result: ThreeValued;
70
+ detail: string;
71
+ }
72
+ /** A verified Ethereum bound on a recording, from a witness in the bundle. */
73
+ export interface CheckBound {
74
+ blockNumber?: string;
75
+ blockHash: string;
76
+ /** Unix seconds from the verified block header. */
77
+ timestamp: number;
78
+ anchorProofHash: string;
79
+ evidence: "chain-link" | "counter-order";
80
+ weaker: boolean;
81
+ }
82
+ export interface CheckBounds {
83
+ status: "bracketed" | "lower-bounded" | "upper-bounded" | "unanchored";
84
+ notBefore?: CheckBound;
85
+ notAfter?: CheckBound;
86
+ detail: string;
87
+ }
88
+ /** A non-anchor recording in the bundle. */
89
+ export interface CheckRecording {
90
+ proofHash: string;
91
+ digestB64: string;
92
+ epochId?: string;
93
+ chainId: string;
94
+ counter?: string;
95
+ slotCounter?: string;
96
+ publicKeyB64?: string;
97
+ /** Bundle-relative path of the matched artifact, when its bytes were present. */
98
+ filePath?: string;
99
+ lines: CheckLine[];
100
+ /** Kleene all over `lines`. */
101
+ result: ThreeValued;
102
+ bounds: CheckBounds;
103
+ }
104
+ /** An Ethereum anchor recording in the bundle. */
105
+ export interface CheckAnchor {
106
+ proofHash: string;
107
+ epochId?: string;
108
+ chainId: string;
109
+ counter?: string;
110
+ blockNumber?: string;
111
+ blockHash?: string;
112
+ /** Bundle-relative path of the witness file, when one matched this anchor. */
113
+ witnessPath?: string;
114
+ lines: CheckLine[];
115
+ result: ThreeValued;
116
+ }
117
+ export interface CheckReport {
118
+ check: "bitgraph-check/1";
119
+ result: ThreeValued;
120
+ /** One-sentence plain-language conclusion, deterministic. */
121
+ summary: string;
122
+ recordings: CheckRecording[];
123
+ anchors: CheckAnchor[];
124
+ /** Structural findings the bundle contradicts itself on. Every entry is FALSE. */
125
+ contradictions: CheckLine[];
126
+ /** Informational: excerpt gaps, unmatched files, duplicates. Never verdicts. */
127
+ notes: string[];
128
+ /** What no offline check can establish, stated rather than implied. */
129
+ notChecked: string[];
130
+ evaluator: {
131
+ name: "bitgraph-player";
132
+ version: string;
133
+ audit: string;
134
+ };
135
+ network: "none";
136
+ }
137
+ export interface CheckOptions {
138
+ /**
139
+ * False when the environment cannot run the attestation's ECDSA P-384
140
+ * verification (no WebCrypto). Attestation lines are then UNDETERMINED
141
+ * with that reason instead of a false FALSE. Defaults to true.
142
+ */
143
+ webCryptoAvailable?: boolean;
144
+ }
145
+ /**
146
+ * Check an already-ingested bundle: runs the audit's pure tail (no
147
+ * filesystem, no network) and builds the report. Both the CLI and the
148
+ * browser page call this, so they cannot drift.
149
+ */
150
+ export declare function checkIngest(ingest: IngestResult, options?: CheckOptions): Promise<CheckReport>;
151
+ /** The pure report builder over an AuditResult. */
152
+ export declare function buildCheckReport(audit: AuditResult, options?: CheckOptions): CheckReport;
153
+ export declare function renderCheckText(report: CheckReport): string;
154
+ /** Deterministic JSON bytes for the report: two-space indent, one trailing newline. */
155
+ export declare function serializeCheckReport(report: CheckReport): string;
156
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EAEV,WAAW,EAEX,YAAY,EAKb,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQ9C;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAqBrG,CAAC;AAMF,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,eAAe,CAAC;IACrF,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,YAAY,GAAG,eAAe,CAAC;IACzC,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,WAAW,GAAG,eAAe,GAAG,eAAe,GAAG,YAAY,CAAC;IACvE,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,MAAM,EAAE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