@mikeargento/bitgraph-audit 0.6.4 → 0.8.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 (42) hide show
  1. package/dist/audit.d.ts +1 -1
  2. package/dist/audit.d.ts.map +1 -1
  3. package/dist/audit.js +9 -2
  4. package/dist/audit.js.map +1 -1
  5. package/dist/ceilings.d.ts +41 -0
  6. package/dist/ceilings.d.ts.map +1 -0
  7. package/dist/ceilings.js +198 -0
  8. package/dist/ceilings.js.map +1 -0
  9. package/dist/cli.js +48 -4
  10. package/dist/cli.js.map +1 -1
  11. package/dist/index.d.ts +4 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/ingest.d.ts.map +1 -1
  16. package/dist/ingest.js +17 -0
  17. package/dist/ingest.js.map +1 -1
  18. package/dist/report-json.d.ts.map +1 -1
  19. package/dist/report-json.js +3 -0
  20. package/dist/report-json.js.map +1 -1
  21. package/dist/report-md.js +24 -0
  22. package/dist/report-md.js.map +1 -1
  23. package/dist/settlement-blobs.d.ts +131 -0
  24. package/dist/settlement-blobs.d.ts.map +1 -0
  25. package/dist/settlement-blobs.js +682 -0
  26. package/dist/settlement-blobs.js.map +1 -0
  27. package/dist/types.d.ts +96 -0
  28. package/dist/types.d.ts.map +1 -1
  29. package/package.json +5 -3
  30. package/src/__tests__/fixtures/settlement/0x018efc046e94610e2530344caf1574e507a3182e1a975fb25b032ec1434a3f5c.bin +0 -0
  31. package/src/__tests__/fixtures/settlement/ceiling-51979918.json +101 -0
  32. package/src/__tests__/fixtures/settlement/pointer-51979918.json +69 -0
  33. package/src/__tests__/settlement.test.ts +254 -0
  34. package/src/audit.ts +8 -1
  35. package/src/ceilings.ts +219 -0
  36. package/src/cli.ts +47 -7
  37. package/src/index.ts +6 -0
  38. package/src/ingest.ts +19 -0
  39. package/src/report-json.ts +3 -0
  40. package/src/report-md.ts +22 -0
  41. package/src/settlement-blobs.ts +689 -0
  42. package/src/types.ts +85 -0
package/src/ingest.ts CHANGED
@@ -43,6 +43,7 @@ import { readTarEntries } from "./tar.js";
43
43
  import { combineEntryDigests } from "./contents-hash.js";
44
44
  import type {
45
45
  AnchorWitnessFile,
46
+ CeilingFile,
46
47
  ArtifactRecord,
47
48
  AuditFinding,
48
49
  BundleManifest,
@@ -82,6 +83,8 @@ const NUL = new Uint8Array([0]);
82
83
  const MANIFEST_PATH = "manifest.json";
83
84
  const BUNDLE_VERSION = "bitgraph-bundle/1";
84
85
  const WITNESS_VERSION = "bitgraph-anchor-witness/1";
86
+ const CEILING_VERSION_TAG = "bitgraph-ceiling/1";
87
+ const CEILING_STATUS_VERSION_TAG = "bitgraph-ceiling-status/1";
85
88
 
86
89
  // ---------------------------------------------------------------------------
87
90
  // Public API
@@ -336,6 +339,8 @@ function finalizeIngest(params: FinalizeParams): IngestResult {
336
339
  const proofsByHash = new Map<string, ObservedProof>();
337
340
  const unsupportedVersions: UnsupportedVersionRecord[] = [];
338
341
  const witnesses: AnchorWitnessFile[] = [];
342
+ const ceilings: CeilingFile[] = [];
343
+ const ceilingStatuses: CeilingFile[] = [];
339
344
  const artifactsByHex = new Map<string, ArtifactRecord>();
340
345
  let manifest: ManifestReport | undefined;
341
346
  let proofFiles = 0;
@@ -393,6 +398,17 @@ function finalizeIngest(params: FinalizeParams): IngestResult {
393
398
  continue;
394
399
  }
395
400
 
401
+ // A ceiling in time travels beside its proof: evidence, never an artifact.
402
+ const pv = parsed !== undefined ? (parsed as Record<string, unknown>)["version"] : undefined;
403
+ if (pv === CEILING_VERSION_TAG || pv === CEILING_STATUS_VERSION_TAG) {
404
+ (pv === CEILING_VERSION_TAG ? ceilings : ceilingStatuses).push({
405
+ path: entry.path,
406
+ fileSha256Hex: entry.sha256Hex,
407
+ json: parsed as Record<string, unknown>,
408
+ });
409
+ continue;
410
+ }
411
+
396
412
  indexArtifact(entry, artifactsByHex);
397
413
  }
398
414
 
@@ -420,6 +436,7 @@ function finalizeIngest(params: FinalizeParams): IngestResult {
420
436
  unsupportedVersion: unsupportedVersions.length,
421
437
  artifacts: artifacts.length,
422
438
  witnesses: witnesses.length,
439
+ ceilings: ceilings.length + ceilingStatuses.length,
423
440
  skippedUnsafePaths,
424
441
  };
425
442
 
@@ -432,6 +449,8 @@ function finalizeIngest(params: FinalizeParams): IngestResult {
432
449
  unsupportedVersions,
433
450
  artifacts,
434
451
  witnesses,
452
+ ceilings,
453
+ ceilingStatuses,
435
454
  ...(manifest !== undefined ? { manifest } : {}),
436
455
  computedContentsHashB64,
437
456
  findings,
@@ -109,6 +109,9 @@ export function buildJsonReport(result: AuditResult): AuditJsonReport {
109
109
  groups: result.authorities.groups,
110
110
  sharedSignersAcrossEpochs: result.authorities.sharedSignersAcrossEpochs,
111
111
  },
112
+ ...(result.ceilings && (result.ceilings.checks.length > 0 || result.ceilings.statuses.length > 0)
113
+ ? { ceilings: result.ceilings }
114
+ : {}),
112
115
  attestations: {
113
116
  records: result.attestations.records,
114
117
  counts: result.attestations.counts,
package/src/report-md.ts CHANGED
@@ -333,6 +333,28 @@ function executiveSummary(
333
333
  );
334
334
  lines.push("");
335
335
 
336
+ // Ceilings in time (bitgraph-ceiling/1), only when the bundle carries any.
337
+ const cl = report.ceilings;
338
+ if (cl && (cl.checks.length > 0 || cl.statuses.length > 0)) {
339
+ lines.push("### Ceilings in time (Base)");
340
+ lines.push("");
341
+ lines.push(`Checked against writer ${inlineCode(cl.writer)} on chain ${cl.chainId}.`);
342
+ lines.push("");
343
+ for (const c of cl.checks) {
344
+ if (c.status === "verified") {
345
+ const w = c.window!;
346
+ const width = w.widthSeconds != null ? `, ${w.widthSeconds} s after the floor block` : "";
347
+ lines.push(`- VERIFIED ${inlineCode(c.path)}: ${c.label ?? ""}${width}. ${c.onChainDetail ?? ""}.`);
348
+ } else {
349
+ lines.push(`- ${c.status.toUpperCase()} ${inlineCode(c.path)}: ${c.reason ?? ""}`);
350
+ }
351
+ // Settlement on Ethereum (bitgraph-settlement/1), one line per layer.
352
+ for (const line of c.settlement?.lines ?? []) lines.push(` - ${line}`);
353
+ }
354
+ for (const st of cl.statuses) lines.push(`- ${st.status} ${inlineCode(st.path)}: ${st.note}`);
355
+ lines.push("");
356
+ }
357
+
336
358
  // External time evidence.
337
359
  lines.push("### External time evidence");
338
360
  lines.push("");