@mikeargento/bitgraph-verify 1.27.0 → 1.29.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 (66) hide show
  1. package/dist/__tests__/carrier6.test.d.ts +10 -0
  2. package/dist/__tests__/carrier6.test.d.ts.map +1 -0
  3. package/dist/__tests__/carrier6.test.js +82 -0
  4. package/dist/__tests__/carrier6.test.js.map +1 -0
  5. package/dist/__tests__/epoch-genesis.test.js +8 -1
  6. package/dist/__tests__/epoch-genesis.test.js.map +1 -1
  7. package/dist/__tests__/measurements-windows.test.d.ts +7 -0
  8. package/dist/__tests__/measurements-windows.test.d.ts.map +1 -0
  9. package/dist/__tests__/measurements-windows.test.js +27 -0
  10. package/dist/__tests__/measurements-windows.test.js.map +1 -0
  11. package/dist/__tests__/timeline-bundle.test.js +30 -2
  12. package/dist/__tests__/timeline-bundle.test.js.map +1 -1
  13. package/dist/attested.d.ts +4 -2
  14. package/dist/attested.d.ts.map +1 -1
  15. package/dist/attested.js +40 -6
  16. package/dist/attested.js.map +1 -1
  17. package/dist/carrier-verify.d.ts +1 -1
  18. package/dist/carrier-verify.d.ts.map +1 -1
  19. package/dist/carrier-verify.js +3 -3
  20. package/dist/carrier-verify.js.map +1 -1
  21. package/dist/carrier.d.ts +10 -2
  22. package/dist/carrier.d.ts.map +1 -1
  23. package/dist/carrier.js +19 -5
  24. package/dist/carrier.js.map +1 -1
  25. package/dist/carrier5.d.ts +22 -2
  26. package/dist/carrier5.d.ts.map +1 -1
  27. package/dist/carrier5.js +36 -2
  28. package/dist/carrier5.js.map +1 -1
  29. package/dist/ceiling.d.ts +2 -2
  30. package/dist/ceiling.d.ts.map +1 -1
  31. package/dist/ceiling.js +8 -4
  32. package/dist/ceiling.js.map +1 -1
  33. package/dist/epoch-genesis.d.ts +4 -0
  34. package/dist/epoch-genesis.d.ts.map +1 -1
  35. package/dist/epoch-genesis.js +7 -0
  36. package/dist/epoch-genesis.js.map +1 -1
  37. package/dist/index.d.ts +4 -4
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +3 -3
  40. package/dist/index.js.map +1 -1
  41. package/dist/measurements.d.ts +25 -0
  42. package/dist/measurements.d.ts.map +1 -1
  43. package/dist/measurements.js +34 -0
  44. package/dist/measurements.js.map +1 -1
  45. package/dist/timeline-export.d.ts +5 -0
  46. package/dist/timeline-export.d.ts.map +1 -1
  47. package/dist/timeline-export.js +4 -1
  48. package/dist/timeline-export.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/__tests__/carrier6.test.ts +86 -0
  51. package/src/__tests__/epoch-genesis.test.ts +9 -1
  52. package/src/__tests__/fixtures/carrier6/ceiling.json +73 -0
  53. package/src/__tests__/fixtures/carrier6/floor-block.json +9 -0
  54. package/src/__tests__/fixtures/carrier6/floor-proof.json +39 -0
  55. package/src/__tests__/fixtures/carrier6/proof.json +39 -0
  56. package/src/__tests__/measurements-windows.test.ts +31 -0
  57. package/src/__tests__/timeline-bundle.test.ts +34 -2
  58. package/src/attested.ts +39 -9
  59. package/src/carrier-verify.ts +5 -5
  60. package/src/carrier.ts +19 -6
  61. package/src/carrier5.ts +43 -3
  62. package/src/ceiling.ts +9 -6
  63. package/src/epoch-genesis.ts +8 -1
  64. package/src/index.ts +4 -4
  65. package/src/measurements.ts +51 -0
  66. package/src/timeline-export.ts +9 -2
package/src/carrier5.ts CHANGED
@@ -21,7 +21,9 @@
21
21
  */
22
22
 
23
23
  import { sha256 } from "@noble/hashes/sha256";
24
- import { CARRIER_VERSION_5, buildCarrier, type CarrierPayload, type CarrierBounds } from "./carrier.js";
24
+ import { CARRIER_VERSION_5, CARRIER_VERSION_6, buildCarrier, type CarrierPayload, type CarrierBounds } from "./carrier.js";
25
+ import { parseBlockReadFile } from "./block-read.js";
26
+ import { computeChainHash } from "./proof-hash.js";
25
27
  import { verifyAttested } from "./attested.js";
26
28
  import { verifyCeiling, type CeilingSidecar } from "./ceiling.js";
27
29
  import { checkTreeFloor, treeMemberOf } from "./tree-member.js";
@@ -32,16 +34,31 @@ export const BITGRAPH_CEILING_WRITER_V5 = "0xf3972408D853c975F86351C311f4310220b
32
34
  const BASE_CHAIN_ID = 8453;
33
35
 
34
36
  export interface CarrierV5Payload {
35
- carrier: typeof CARRIER_VERSION_5;
37
+ carrier: typeof CARRIER_VERSION_5 | typeof CARRIER_VERSION_6;
36
38
  proof: Record<string, unknown>;
37
39
  ceilingInTime: { status: "unfetched" } | { status: "present"; sidecar: Record<string, unknown> };
40
+ /** v6 only: the file's own Base floor, the block read bound on the counts right before it. */
41
+ floorInTime?: CarrierV6Floor;
38
42
  }
39
43
 
44
+ /** A drop's floor as v6 carries it: the block read's proof and the bitgraph-block-read/1 file it binds. */
45
+ export type CarrierV6Floor = { status: "none" } | { status: "present"; proof: Record<string, unknown>; blockFile: string };
46
+
40
47
  /** The v5 payload for a proof (as the ledger serves it for these bytes) and its ceiling sidecar, if written yet. */
41
48
  export function assembleCarrierV5Payload(proof: Record<string, unknown>, ceilingSidecar: Record<string, unknown> | null): CarrierV5Payload {
42
49
  return { carrier: CARRIER_VERSION_5, proof, ceilingInTime: ceilingSidecar ? { status: "present", sidecar: ceilingSidecar } : { status: "unfetched" } };
43
50
  }
44
51
 
52
+ /** The v6 payload: v5's, and the file's own floor (the block read before it), or none. */
53
+ export function assembleCarrierV6Payload(proof: Record<string, unknown>, ceilingSidecar: Record<string, unknown> | null, floor: { proof: Record<string, unknown>; blockFile: string } | null): CarrierV5Payload {
54
+ return { ...assembleCarrierV5Payload(proof, ceilingSidecar), carrier: CARRIER_VERSION_6, floorInTime: floor ? { status: "present", proof: floor.proof, blockFile: floor.blockFile } : { status: "none" } };
55
+ }
56
+
57
+ /** The BitGraphed file, v6: the bound bytes, unchanged, followed by the v6 block. */
58
+ export function buildBitGraphedFileV6(bytes: Uint8Array, proof: Record<string, unknown>, ceilingSidecar: Record<string, unknown> | null, floor: { proof: Record<string, unknown>; blockFile: string } | null): Uint8Array {
59
+ return buildCarrier(bytes, assembleCarrierV6Payload(proof, ceilingSidecar, floor) as unknown as CarrierPayload);
60
+ }
61
+
45
62
  /** The BitGraphed file: the bound bytes, unchanged, followed by the v5 block. */
46
63
  export function buildBitGraphedFileV5(bytes: Uint8Array, proof: Record<string, unknown>, ceilingSidecar: Record<string, unknown> | null): Uint8Array {
47
64
  return buildCarrier(bytes, assembleCarrierV5Payload(proof, ceilingSidecar) as unknown as CarrierPayload);
@@ -79,6 +96,29 @@ export async function verifyCarrierV5(payloadIn: CarrierPayload, inner: Uint8Arr
79
96
  }
80
97
  }
81
98
 
99
+ // 3b. v6: the file's own floor. The block read bound on the counts right before the file: its proof is BitGraph's,
100
+ // it binds its block file, and the file's signed prevB64 is its hash, so nothing was bound between them. The block's
101
+ // hash could not be known before the block, so the file was bound after it. Whether the block is on Base's canonical
102
+ // chain is a check against Base.
103
+ const fl = payload.floorInTime;
104
+ if (fl?.status === "present") {
105
+ const fp = fl.proof as unknown as BitGraphProof;
106
+ const text = new TextEncoder().encode(fl.blockFile);
107
+ const fr = await verifyAttested({ proof: fp, bytes: text, ...(opts.pcr0 ? { pcr0: opts.pcr0 } : {}), ...(opts.rootDer ? { rootDer: opts.rootDer } : {}) });
108
+ const f = parseBlockReadFile(fl.blockFile);
109
+ const sameEpoch = fp.commit?.epochId === proof.commit?.epochId && f?.epochId === proof.commit?.epochId;
110
+ const next = !!fp.commit?.counter && !!proof.commit?.slotCounter && BigInt(fp.commit.counter) + 1n === BigInt(proof.commit.slotCounter);
111
+ const chained = proof.commit?.prevB64 === computeChainHash(fp);
112
+ const ok = fr.valid && f !== null && f.chain === "base" && f.chainId === "eip155:8453" && sameEpoch && next && chained;
113
+ const why = !fr.valid ? `the floor's proof does not verify: ${fr.reason ?? "invalid"}` : f === null ? "the floor's block file is not a bitgraph-block-read/1 file" : f.chain !== "base" || f.chainId !== "eip155:8453" ? "the floor is not a Base mainnet block" : !sameEpoch ? "the floor is not of this file's epoch" : !next ? "the floor is not the record right before this file" : "this file's prevB64 is not the floor's hash";
114
+ add("floor.read", "The floor is the Base block read bound right before this file", ok ? "TRUE" : "FALSE", "BitGraph's previous record, chained by prevB64", ok ? `BitGraph #${fp.commit.counter} bound Base block ${f!.number} (${f!.hash.slice(0, 12)}…), and this file's signed prevB64 is that record's hash: the bind came after the block existed` : why);
115
+ if (ok) {
116
+ const after = r.attestedAtMs !== null && r.attestedAtMs >= f!.timestamp * 1000;
117
+ add("floor.time", "The bind came after the floor block's time", after ? "TRUE" : "FALSE", "the AWS Nitro attestation's time", after ? `bound ${iso(Math.floor(r.attestedAtMs! / 1000))}, block ${iso(f!.timestamp)}` : "the attested bind time is not after the block's time");
118
+ notBefore = { chain: "base", blockNumber: f!.number, blockHash: f!.hash, timestamp: f!.timestamp };
119
+ }
120
+ } else if (fl?.status === "none") add("floor.read", "A Base floor", "NOT_CARRIED", "", "this record was bound without a Base block read before it");
121
+
82
122
  // 4. The ceiling: this proof's hash is in the batch the Base transaction carries, and that transaction is in its block.
83
123
  let existedBy: CarrierBounds["existedBy"] = null;
84
124
  if (payload.ceilingInTime.status === "present") {
@@ -95,7 +135,7 @@ export async function verifyCarrierV5(payloadIn: CarrierPayload, inner: Uint8Arr
95
135
  ? `BitGraph #${proof.commit?.counter}: ${where}, bound by BitGraph's published enclave image ${r.image?.version ?? ""}${notBefore ? ` after Base block ${notBefore.blockNumber}` : ""}${existedBy ? ` and written to Base by block ${existedBy.blockNumber}` : ""}. Check those blocks on Base to place it in real time.`
96
136
  : `This BitGraphed file does not check: ${failed.map((c) => c.detail).join("; ") || "the proof did not verify"}.`;
97
137
  return {
98
- verdict, carrier: "ok", version: 5, reasons: claims.filter((c) => c.result !== "TRUE" && c.result !== "NOT_CARRIED").map((c) => c.detail),
138
+ verdict, carrier: "ok", version: payload.carrier === CARRIER_VERSION_6 ? 6 : 5, reasons: claims.filter((c) => c.result !== "TRUE" && c.result !== "NOT_CARRIED").map((c) => c.detail),
99
139
  bounds: notBefore ? { notBefore, notAfter: null, existedBy, settledBy: null } : null,
100
140
  ceiling: null, claims, reading, payload: payloadIn, inner,
101
141
  };
package/src/ceiling.ts CHANGED
@@ -26,13 +26,14 @@
26
26
  * What stays OUTSIDE this function, and is reported, not assumed:
27
27
  * - whether that header is really a Base block (check it against any Base
28
28
  * RPC; see checkCeilingOnline), and
29
- * - who the writer is (the caller names the address it trusts; BitGraph
30
- * publishes its own on bitgraph.ing).
29
+ * - who the writer is: the caller may name the address it trusts; by default
30
+ * only BitGraph's published writers (measurements.ts) are accepted.
31
31
  */
32
32
 
33
33
  import { sha256 } from "@noble/hashes/sha256";
34
34
  import { verifyProofIntegrity, createVerificationContext } from "./verifier.js";
35
35
  import { computeProofHash } from "./proof-hash.js";
36
+ import { isPublishedWriter } from "./measurements.js";
36
37
  import { merkleLeafHash, merkleRootFromPath } from "./fuse-merkle.js";
37
38
  import { base64ToBytes, signedFloorOf, type SignedFloor } from "./fuse.js";
38
39
  import {
@@ -159,8 +160,8 @@ export interface CeilingVerifyResult {
159
160
  }
160
161
 
161
162
  export interface CeilingVerifyOptions {
162
- /** The declared writer address. A sidecar from any other sender is refused. */
163
- writerAddress: string;
163
+ /** The writer address trusted. Omitted: BitGraph's published writers (PUBLISHED_WRITERS). Any other sender is refused. */
164
+ writerAddress?: string;
164
165
  /** 8453 Base mainnet, 84532 Base Sepolia. */
165
166
  chainId: number;
166
167
  /** Skip the proof's own signature check (only when the caller already ran verify()). */
@@ -280,8 +281,10 @@ async function verifyCeilingChecks(
280
281
  try {
281
282
  rawTx = hexToBytes(a.rawTx);
282
283
  const tx = decodeEip1559(rawTx);
283
- const writer = opts.writerAddress.toLowerCase();
284
- if (tx.from !== writer) return fail("sender", `the transaction was signed by ${tx.from}, not the declared writer ${writer}`);
284
+ const writer = opts.writerAddress !== undefined ? opts.writerAddress.toLowerCase() : tx.from;
285
+ if (opts.writerAddress !== undefined && tx.from !== writer) return fail("sender", `the transaction was signed by ${tx.from}, not the declared writer ${writer}`);
286
+ // The block number is the sidecar's here; the header step below refuses a sidecar whose number is not the header's.
287
+ if (opts.writerAddress === undefined && !isPublishedWriter(tx.from, opts.chainId, a.blockNumber)) return fail("sender", `the transaction was signed by ${tx.from}, which is not a BitGraph writer`);
285
288
  if (tx.to !== writer) return fail("sender", `the transaction is addressed to ${tx.to ?? "a contract creation"}, not to the writer`);
286
289
  if (tx.chainId !== BigInt(opts.chainId)) return fail("chain", `the transaction is for chain ${tx.chainId}, expected ${opts.chainId}`);
287
290
  if (a.chainId !== opts.chainId) return fail("chain", `the sidecar names chain ${a.chainId}, expected ${opts.chainId}`);
@@ -20,6 +20,7 @@
20
20
 
21
21
  import { sha256 } from "@noble/hashes/sha256";
22
22
  import type { BitGraphProof } from "./types.js";
23
+ import { isPublishedWriter } from "./measurements.js";
23
24
 
24
25
  export const EPOCH_GENESIS_FORMAT = "bitgraph-epoch-genesis/1" as const;
25
26
  export const EPOCH_GENESIS_REQUEST_FORMAT = "bitgraph-epoch-genesis-request/1" as const;
@@ -157,10 +158,13 @@ export interface EpochGenesisCheck {
157
158
  * epoch's id, mined in the block the file names; the block, when supplied, must be that block with that time.
158
159
  * Without `tx` and `block` only the file and the proof are checked (offline).
159
160
  *
161
+ * The writer must be one of BitGraph's published writers on Base mainnet, unless the caller names the writers it trusts
162
+ * (`writers`): an epoch opened from any other address is not BitGraph's, though its enclave image may be.
163
+ *
160
164
  * `position: "any"` drops the counts-1-and-2 rule, for a timeline epoch that read blocks and bound files while the
161
165
  * Base write was still pending: its genesis record is the first record that ends pre-genesis, wherever it falls.
162
166
  */
163
- export function checkEpochGenesis(args: { file: string; proof: BitGraphProof; tx?: EpochGenesisTx | null; block?: EpochGenesisBlock | null; position?: "first" | "any" }): EpochGenesisCheck {
167
+ export function checkEpochGenesis(args: { file: string; proof: BitGraphProof; tx?: EpochGenesisTx | null; block?: EpochGenesisBlock | null; position?: "first" | "any"; writers?: readonly string[] }): EpochGenesisCheck {
164
168
  const reasons: string[] = [];
165
169
  const genesis = parseEpochGenesisFile(args.file);
166
170
  if (!genesis) return { ok: false, reasons: ["the file is not a bitgraph-epoch-genesis/1 record"], genesis: null };
@@ -168,6 +172,9 @@ export function checkEpochGenesis(args: { file: string; proof: BitGraphProof; tx
168
172
  if (digest !== args.proof.artifact?.digestB64) reasons.push("the file does not hash to the proof's digest");
169
173
  const commit = args.proof.commit as { counter?: string; slotCounter?: string; epochId?: string };
170
174
  if (commit.epochId !== genesis.epochId) reasons.push("the proof is not of the epoch the file names");
175
+ if (args.writers ? !args.writers.map((w) => w.toLowerCase()).includes(genesis.writer) : genesis.chainId === 8453 && !isPublishedWriter(genesis.writer, 8453, genesis.blockNumber)) {
176
+ reasons.push(`the writer ${genesis.writer} is not ${args.writers ? "one this verifier trusts" : "a BitGraph writer"}`);
177
+ }
171
178
  if (args.position !== "any" && (commit.slotCounter !== "1" || commit.counter !== "2")) reasons.push("the proof is not the epoch's first BitGraph (counts 1 and 2)");
172
179
  if (args.tx) {
173
180
  const t = args.tx;
package/src/index.ts CHANGED
@@ -150,8 +150,8 @@ export type { CarrierV3Parts } from "./carrier-assemble.js";
150
150
  /* bitgraph-carrier/4 (2026-10-11): one member of a tree/1 BitGraph carries its own proof: the bytes are the leaf's, the block walks them to the signed root document. */
151
151
  export { CARRIER_VERSION_4, memberArtifactDigest } from "./carrier.js";
152
152
  // The BitGraphed file for atomic proofs: the proof (with its tree path and floor leaf) and its Base ceiling (2026-10-20).
153
- export { CARRIER_VERSION_5 } from "./carrier.js";
154
- export { assembleCarrierV5Payload, buildBitGraphedFileV5, verifyCarrierV5, type CarrierV5Payload } from "./carrier5.js";
153
+ export { CARRIER_VERSION_5, CARRIER_VERSION_6 } from "./carrier.js";
154
+ export { assembleCarrierV5Payload, buildBitGraphedFileV5, assembleCarrierV6Payload, buildBitGraphedFileV6, verifyCarrierV5, type CarrierV5Payload, type CarrierV6Floor } from "./carrier5.js";
155
155
  export { checkTreeFloor, BASE_BLOCK_FORMAT, type TreeFloor, type TreeFloorBlock } from "./tree-member.js";
156
156
  export type { CarrierTree } from "./carrier.js";
157
157
  export { assembleCarrierV4Payload } from "./carrier-assemble.js";
@@ -204,8 +204,8 @@ export { baseTimeIsBound, BASE_STAMP_TOLERANCE_SECONDS } from "./ceiling.js";
204
204
  export { checkFloorHeader, floorTimeIsBound, onBaseSchedule, headerRlpFromRpc, BASE_MAINNET_GENESIS_TIME, BASE_BLOCK_TIME_SECONDS } from "./ceiling.js";
205
205
  export type { RpcBlockHeader } from "./ceiling.js";
206
206
  /* The enclave images BitGraph has published: the default measurement policy (SPEC section 16). */
207
- export { PUBLISHED_ENCLAVE_MEASUREMENTS, PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
208
- export type { PublishedMeasurement } from "./measurements.js";
207
+ export { PUBLISHED_ENCLAVE_MEASUREMENTS, PUBLISHED_PCR0S, publishedMeasurement, imageIsAtomic, imageRetiredAfterMs, IMAGE_RETIREMENT_GRACE_DAYS, PUBLISHED_WRITERS, isPublishedWriter } from "./measurements.js";
208
+ export type { PublishedMeasurement, PublishedWriter } from "./measurements.js";
209
209
  export type { BitGraphExport, ExportClaim, ExportClaimResult, ExportLookups, ExportVerifyOptions, ExportVerifyResult } from "./export.js";
210
210
  /* bitgraph-epoch-genesis/1 (2026-10-23): an epoch opens with a Base write carrying its id; the epoch's first BitGraph binds the mined transaction's record. */
211
211
  export { EPOCH_GENESIS_FORMAT, EPOCH_GENESIS_REQUEST_FORMAT, EPOCH_GENESIS_MAGIC, epochGenesisCalldata, epochGenesisCalldataHex, epochIdOfCalldata, epochGenesisFileText, parseEpochGenesisFile, checkEpochGenesis } from "./epoch-genesis.js";
@@ -50,3 +50,54 @@ export function publishedMeasurement(pcr0: unknown): PublishedMeasurement | null
50
50
  const want = pcr0.toLowerCase();
51
51
  return PUBLISHED_ENCLAVE_MEASUREMENTS.find((m) => m.pcr0 === want) ?? null;
52
52
  }
53
+
54
+ /** Images from v11 on bind atomically: the nonce at N and the digest at N+1 in one action. Earlier images could hand
55
+ * out a position before its content arrived. */
56
+ const ATOMIC_IMAGES: ReadonlySet<string> = new Set(["v11", "v12", "v13"]);
57
+
58
+ export function imageIsAtomic(version: string): boolean {
59
+ return ATOMIC_IMAGES.has(version);
60
+ }
61
+
62
+ /**
63
+ * Days an image stays accepted after the next image went live. A switch was never instant, so an image's last proofs
64
+ * can trail its successor's first by a little; past that, a proof attested by the older image is refused. Anyone can
65
+ * still boot a retired image on their own AWS account, and without this its new proofs would pass.
66
+ */
67
+ export const IMAGE_RETIREMENT_GRACE_DAYS = 7;
68
+
69
+ /** The last instant (ms since the epoch) at which a proof attested by this image is accepted; null for the newest. */
70
+ export function imageRetiredAfterMs(pcr0: unknown): number | null {
71
+ const m = publishedMeasurement(pcr0);
72
+ if (!m) return null;
73
+ const i = PUBLISHED_ENCLAVE_MEASUREMENTS.indexOf(m);
74
+ const next = PUBLISHED_ENCLAVE_MEASUREMENTS[i + 1];
75
+ if (!next) return null;
76
+ return Date.parse(`${next.since}T00:00:00Z`) + (IMAGE_RETIREMENT_GRACE_DAYS + 1) * 86_400_000 - 1;
77
+ }
78
+
79
+ /**
80
+ * The Base addresses BitGraph writes from: every Base write of a proof (bitgraph-ceiling/1) and every epoch genesis
81
+ * transaction. A write from any other address is not BitGraph's, though the enclave image that made the proof may be
82
+ * the published one: the image says what code ran, the writer says who ran it. A leaked key gets `untilBlock`, the
83
+ * last block its writes are accepted in, and a new address is added; older writes stay valid.
84
+ */
85
+ export interface PublishedWriter {
86
+ /** Lowercase 0x hex. */
87
+ address: string;
88
+ /** 8453, Base mainnet. */
89
+ chainId: number;
90
+ untilBlock?: number;
91
+ }
92
+
93
+ export const PUBLISHED_WRITERS: readonly PublishedWriter[] = Object.freeze([
94
+ { address: "0xf3972408d853c975f86351c311f4310220bbf2a3", chainId: 8453 },
95
+ ].map((w) => Object.freeze(w)));
96
+
97
+ /** Whether a write from `address` on `chainId` in block `blockNumber` (when known) is one of BitGraph's. */
98
+ export function isPublishedWriter(address: unknown, chainId: number, blockNumber?: number | null): boolean {
99
+ if (typeof address !== "string") return false;
100
+ const a = address.toLowerCase();
101
+ return PUBLISHED_WRITERS.some((w) => w.address === a && w.chainId === chainId
102
+ && (w.untilBlock === undefined || blockNumber === undefined || blockNumber === null || blockNumber <= w.untilBlock));
103
+ }
@@ -12,6 +12,11 @@
12
12
  * Not ready yet (retryable) when the file has no qualifying ceiling read after it in the records given: a ceiling
13
13
  * needs a block stamped after the file, read within the lag limits, so a bundle can be made a few seconds after the
14
14
  * file is bound. A gap in the records (a lost record) cannot be bridged and is not retryable.
15
+ *
16
+ * A drop's own floor (2026-11-02): when the record right before the file is a Base block read, it is the floor the
17
+ * host bound for that drop, and the file's prevB64 is that read's hash. Such a file needs no ceiling read (its
18
+ * ceiling is its own Base write, ceiling.ts): the bundle is the read and the file, and verifyTimelineBundle reports it
19
+ * unconfirmed only for the missing ceiling read, with the floor checked.
15
20
  */
16
21
 
17
22
  import type { BitGraphProof } from "./types.js";
@@ -92,17 +97,19 @@ export function buildTimelineBundle(args: {
92
97
  };
93
98
 
94
99
  const notes: string[] = [];
95
- let chosen: { chain: BlockReadChain; floor: number; ceiling: number } | null = null;
100
+ let chosen: { chain: BlockReadChain; floor: number; ceiling: number | null } | null = null;
96
101
  for (const chain of ["base", "ethereum"] as const) {
97
102
  const p = pick(chain);
98
103
  if (p.ceiling !== null) { chosen = { chain, floor: p.floor!, ceiling: p.ceiling }; break; }
99
104
  notes.push(p.floor === null ? `no ${chain} read before the file in these records` : `no qualifying ${chain} ceiling after the file yet`);
100
105
  }
106
+ const own = reads.get(t - 1);
107
+ if (!chosen && own && own.chain === "base" && own.timestamp * 1000 <= fileMs) chosen = { chain: "base", floor: t - 1, ceiling: null };
101
108
  if (!chosen) return { ok: false, retryable: true, reason: `not ready: ${notes.join("; ")}` };
102
109
  if (chosen.chain !== "base") notes.unshift("bracketed on Ethereum: Base had no qualifying ceiling");
103
110
  else notes.length = 0;
104
111
 
105
- const run = lines.slice(chosen.floor, chosen.ceiling + 1);
112
+ const run = lines.slice(chosen.floor, (chosen.ceiling ?? t) + 1);
106
113
  const s = verifyStretch(run.map((l) => l.proof));
107
114
  if (!s.ok) return { ok: false, retryable: false, reason: `the records are not one unbroken run: ${s.reasons[0]}` };
108
115