@seanhogg/builderforce-memory 2026.10.46 → 2026.10.48

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 (103) hide show
  1. package/README.md +21 -0
  2. package/dist/knowledge/extractFile.d.ts.map +1 -1
  3. package/dist/knowledge/extractFile.js +3 -0
  4. package/dist/knowledge/extractFile.js.map +1 -1
  5. package/dist/knowledge/pack/crc32.d.ts +6 -2
  6. package/dist/knowledge/pack/crc32.d.ts.map +1 -1
  7. package/dist/knowledge/pack/crc32.js +7 -3
  8. package/dist/knowledge/pack/crc32.js.map +1 -1
  9. package/dist/knowledge/pack/decode.d.ts +7 -3
  10. package/dist/knowledge/pack/decode.d.ts.map +1 -1
  11. package/dist/knowledge/pack/decode.js +21 -13
  12. package/dist/knowledge/pack/decode.js.map +1 -1
  13. package/dist/knowledge/pack/deflate.d.ts +1 -0
  14. package/dist/knowledge/pack/deflate.d.ts.map +1 -1
  15. package/dist/knowledge/pack/deflate.js +17 -0
  16. package/dist/knowledge/pack/deflate.js.map +1 -1
  17. package/dist/knowledge/pack/encode.d.ts +9 -0
  18. package/dist/knowledge/pack/encode.d.ts.map +1 -1
  19. package/dist/knowledge/pack/encode.js +7 -0
  20. package/dist/knowledge/pack/encode.js.map +1 -1
  21. package/dist/knowledge/pack/extrDiff.d.ts +4 -1
  22. package/dist/knowledge/pack/extrDiff.d.ts.map +1 -1
  23. package/dist/knowledge/pack/extrDiff.js +0 -0
  24. package/dist/knowledge/pack/extrDiff.js.map +1 -1
  25. package/dist/knowledge/pack/frame.d.ts +20 -1
  26. package/dist/knowledge/pack/frame.d.ts.map +1 -1
  27. package/dist/knowledge/pack/frame.js +50 -16
  28. package/dist/knowledge/pack/frame.js.map +1 -1
  29. package/dist/knowledge/pack/hex.d.ts +7 -0
  30. package/dist/knowledge/pack/hex.d.ts.map +1 -0
  31. package/dist/knowledge/pack/hex.js +17 -0
  32. package/dist/knowledge/pack/hex.js.map +1 -0
  33. package/dist/knowledge/pack/index.d.ts +1 -1
  34. package/dist/knowledge/pack/index.d.ts.map +1 -1
  35. package/dist/knowledge/pack/index.js +1 -1
  36. package/dist/knowledge/pack/index.js.map +1 -1
  37. package/dist/knowledge/pack/manifest.d.ts +17 -0
  38. package/dist/knowledge/pack/manifest.d.ts.map +1 -1
  39. package/dist/knowledge/pack/manifest.js +37 -8
  40. package/dist/knowledge/pack/manifest.js.map +1 -1
  41. package/dist/knowledge/pack/sections/columns.d.ts +2 -2
  42. package/dist/knowledge/pack/sections/extr.js +8 -8
  43. package/dist/knowledge/pack/sections/extr.js.map +1 -1
  44. package/dist/knowledge/pack/sections/extrLists.d.ts +4 -4
  45. package/dist/knowledge/pack/sections/extrLists.d.ts.map +1 -1
  46. package/dist/knowledge/pack/sections/extrLists.js +14 -8
  47. package/dist/knowledge/pack/sections/extrLists.js.map +1 -1
  48. package/dist/knowledge/pack/sections/facts.d.ts.map +1 -1
  49. package/dist/knowledge/pack/sections/facts.js +11 -6
  50. package/dist/knowledge/pack/sections/facts.js.map +1 -1
  51. package/dist/knowledge/pack/sections/rows.d.ts.map +1 -1
  52. package/dist/knowledge/pack/sections/rows.js +20 -19
  53. package/dist/knowledge/pack/sections/rows.js.map +1 -1
  54. package/dist/knowledge/pack/strings.d.ts +5 -1
  55. package/dist/knowledge/pack/strings.d.ts.map +1 -1
  56. package/dist/knowledge/pack/strings.js +16 -14
  57. package/dist/knowledge/pack/strings.js.map +1 -1
  58. package/dist/knowledge/pack/types.d.ts +13 -3
  59. package/dist/knowledge/pack/types.d.ts.map +1 -1
  60. package/dist/knowledge/pack/types.js +2 -1
  61. package/dist/knowledge/pack/types.js.map +1 -1
  62. package/dist/knowledge/pack/varint.d.ts +9 -2
  63. package/dist/knowledge/pack/varint.d.ts.map +1 -1
  64. package/dist/knowledge/pack/varint.js +8 -4
  65. package/dist/knowledge/pack/varint.js.map +1 -1
  66. package/dist/knowledge/reviewModel.d.ts +6 -0
  67. package/dist/knowledge/reviewModel.d.ts.map +1 -1
  68. package/dist/knowledge/reviewPrefetch.d.ts +2 -0
  69. package/dist/knowledge/reviewPrefetch.d.ts.map +1 -1
  70. package/dist/knowledge/reviewPrefetch.js +11 -1
  71. package/dist/knowledge/reviewPrefetch.js.map +1 -1
  72. package/package.json +4 -3
  73. package/src/contract/dist.contract.test.ts +44 -0
  74. package/src/contract/exports.contract.test.ts +90 -0
  75. package/src/contract/exports.snapshot.json +608 -0
  76. package/src/contract/pack.contract.test.ts +31 -0
  77. package/src/contract/regression.pack.test.ts +94 -0
  78. package/src/contract/regression.review.test.ts +236 -0
  79. package/src/contract/regression.store.test.ts +84 -0
  80. package/src/contract/types.contract.test.ts +183 -0
  81. package/src/knowledge/extractFile.ts +2 -0
  82. package/src/knowledge/pack/crc32.ts +7 -3
  83. package/src/knowledge/pack/decode.ts +22 -14
  84. package/src/knowledge/pack/deflate.ts +19 -1
  85. package/src/knowledge/pack/encode.ts +8 -0
  86. package/src/knowledge/pack/extrDiff.ts +0 -0
  87. package/src/knowledge/pack/frame.ts +52 -14
  88. package/src/knowledge/pack/hex.ts +17 -0
  89. package/src/knowledge/pack/index.ts +1 -1
  90. package/src/knowledge/pack/manifest.ts +35 -5
  91. package/src/knowledge/pack/pack.guards.test.ts +35 -3
  92. package/src/knowledge/pack/pack.roundtrip.test.ts +1 -1
  93. package/src/knowledge/pack/sections/columns.ts +2 -2
  94. package/src/knowledge/pack/sections/extr.ts +9 -9
  95. package/src/knowledge/pack/sections/extrLists.ts +13 -9
  96. package/src/knowledge/pack/sections/facts.ts +8 -5
  97. package/src/knowledge/pack/sections/rows.ts +17 -17
  98. package/src/knowledge/pack/strings.ts +15 -12
  99. package/src/knowledge/pack/types.ts +13 -4
  100. package/src/knowledge/pack/varint.ts +10 -3
  101. package/src/knowledge/reviewModel.ts +6 -0
  102. package/src/knowledge/reviewPrefetch.ts +10 -1
  103. package/src/knowledge/testkit.test-util.ts +13 -2
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { boundedCount, ByteReader, ByteWriter, PackFormatError } from '../varint.js';
9
+ import { fromHex64, toHex } from '../hex.js';
9
10
  import type { Pack } from '../types.js';
10
11
  import type { SectionCodec } from './columns.js';
11
12
  import { MANIFEST_BUCKETS } from '../manifest.js';
@@ -27,7 +28,7 @@ export const fileSection: SectionCodec = {
27
28
  },
28
29
  read(bytes, t, limits, into) {
29
30
  const r = new ByteReader(bytes);
30
- const n = boundedCount(r, limits.maxRows, 'files');
31
+ const n = boundedCount(r, limits.budget, 'files');
31
32
  const paths: string[] = [];
32
33
  let prev = 0;
33
34
  for (let i = 0; i < n; i++) { prev += r.varint(); paths.push(t.str(prev)); }
@@ -50,7 +51,7 @@ export const staleSection: SectionCodec = {
50
51
  },
51
52
  read(bytes, t, limits, into) {
52
53
  const r = new ByteReader(bytes);
53
- const n = boundedCount(r, limits.maxRows, 'stale');
54
+ const n = boundedCount(r, limits.budget, 'stale');
54
55
  const refs: string[] = [];
55
56
  let prev = 0;
56
57
  for (let i = 0; i < n; i++) { prev += r.varint(); refs.push(t.str(prev)); }
@@ -79,13 +80,13 @@ export const deleteSection: SectionCodec = {
79
80
  const r = new ByteReader(bytes);
80
81
  const lists: string[][] = [];
81
82
  for (let k = 0; k < 2; k++) {
82
- const n = boundedCount(r, limits.maxRows, 'tombstones');
83
+ const n = boundedCount(r, limits.budget, 'tombstones');
83
84
  const out: string[] = [];
84
85
  let prev = 0;
85
86
  for (let i = 0; i < n; i++) { prev += r.varint(); out.push(t.str(prev)); }
86
87
  lists.push(out);
87
88
  }
88
- const n = boundedCount(r, limits.maxRows, 'relation tombstones');
89
+ const n = boundedCount(r, limits.budget, 'relation tombstones');
89
90
  const from = Array.from({ length: n }, () => t.str(r.varint()));
90
91
  const to = Array.from({ length: n }, () => t.str(r.varint()));
91
92
  const kind = Array.from({ length: n }, () => t.str(r.varint()));
@@ -111,7 +112,7 @@ export const scopeSection: SectionCodec = {
111
112
  read(bytes, t, limits, into) {
112
113
  const r = new ByteReader(bytes);
113
114
  const scope: NonNullable<Pack['scope']> = { rootId: t.str(r.varint()), title: t.str(r.varint()), packs: [] };
114
- const n = boundedCount(r, limits.maxRows, 'packs');
115
+ const n = boundedCount(r, limits.budget, 'packs');
115
116
  for (let i = 0; i < n; i++) scope.packs.push(t.str(r.varint()));
116
117
  const flags = r.u8();
117
118
  if (flags & 1) scope.lastDigest = t.str(r.varint());
@@ -120,13 +121,20 @@ export const scopeSection: SectionCodec = {
120
121
  },
121
122
  };
122
123
 
124
+ /** Object keys in sorted order, recursively: equal documents become equal bytes however their keys were built. */
125
+ const canonical = (v: unknown): unknown => {
126
+ if (Array.isArray(v)) return v.map(canonical);
127
+ if (v && typeof v === 'object') return Object.fromEntries(Object.keys(v).sort().map((k) => [k, canonical((v as Record<string, unknown>)[k])]));
128
+ return v;
129
+ };
130
+
123
131
  /** The analysis snapshot is one JSON-compatible document with no row structure; it travels as one string (deflate does the rest). */
124
132
  export const analysisSection: SectionCodec = {
125
133
  tag: TAG.ANALYSIS,
126
134
  write(pack, t) {
127
135
  if (pack.analysis === undefined) return undefined;
128
136
  const w = new ByteWriter();
129
- w.varint(t.str(JSON.stringify(pack.analysis)));
137
+ w.varint(t.str(JSON.stringify(canonical(pack.analysis))));
130
138
  return w.finish();
131
139
  },
132
140
  read(bytes, t, _limits, into) {
@@ -148,7 +156,7 @@ export const leafSection: SectionCodec = {
148
156
  },
149
157
  read(bytes, t, limits, into) {
150
158
  const r = new ByteReader(bytes);
151
- const n = boundedCount(r, limits.maxRows, 'leaves');
159
+ const n = boundedCount(r, limits.budget, 'leaves');
152
160
  const keys: string[] = [];
153
161
  let prev = 0;
154
162
  for (let i = 0; i < n; i++) { prev += r.varint(); keys.push(t.str(prev)); }
@@ -164,21 +172,13 @@ export const bucketSection: SectionCodec = {
164
172
  if (!b) return undefined;
165
173
  if (b.length !== MANIFEST_BUCKETS) throw new PackFormatError(`a bucket list holds ${MANIFEST_BUCKETS} digests`);
166
174
  const w = new ByteWriter();
167
- for (const hex of b) {
168
- const raw = new Uint8Array(32);
169
- for (let i = 0; i < 32; i++) raw[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
170
- w.bytes(raw);
171
- }
175
+ for (const hex of b) w.bytes(fromHex64(hex));
172
176
  return w.finish();
173
177
  },
174
178
  read(bytes, _t, _limits, into) {
175
179
  if (bytes.length !== MANIFEST_BUCKETS * 32) throw new PackFormatError('bucket section has the wrong size');
176
180
  const out: string[] = [];
177
- for (let i = 0; i < MANIFEST_BUCKETS; i++) {
178
- let hex = '';
179
- for (const b of bytes.subarray(i * 32, i * 32 + 32)) hex += (b < 16 ? '0' : '') + b.toString(16);
180
- out.push(hex);
181
- }
181
+ for (let i = 0; i < MANIFEST_BUCKETS; i++) out.push(toHex(bytes.subarray(i * 32, i * 32 + 32)));
182
182
  into.buckets = out;
183
183
  },
184
184
  };
@@ -10,6 +10,8 @@
10
10
  * first pass with {@link collector} gathers what is used, a second with {@link tablesOf} writes real indexes.
11
11
  */
12
12
 
13
+ import { fromHex64, HEX64, toHex } from './hex.js';
14
+ import { PackTooLargeError } from './types.js';
13
15
  import { boundedCount, ByteReader, ByteWriter, PackFormatError, utf8 } from './varint.js';
14
16
 
15
17
  /** What a section encoder needs: the index of a string and of a hash. */
@@ -24,7 +26,6 @@ export interface ReadTables {
24
26
  hash(i: number): string;
25
27
  }
26
28
 
27
- const HEX64 = /^[0-9a-f]{64}$/;
28
29
 
29
30
  /** A pass-1 `Tables` that records every string and hash it is asked for. */
30
31
  export function collector(): Tables & { strings: Set<string>; hashes: Set<string> } {
@@ -63,15 +64,22 @@ export function writeStringTable(strings: readonly string[]): Uint8Array {
63
64
  return w.finish();
64
65
  }
65
66
 
66
- export function readStringTable(bytes: Uint8Array, maxStrings: number): string[] {
67
+ /**
68
+ * Reads the front-coded string table. `maxBytes` bounds the table's TOTAL decoded bytes: front coding lets a few
69
+ * input bytes name a very long string many times over, so the cap is on what is built, not on what was sent.
70
+ */
71
+ export function readStringTable(bytes: Uint8Array, maxStrings: number, maxBytes: number): string[] {
67
72
  const r = new ByteReader(bytes);
68
- const n = boundedCount(r, maxStrings, 'string table');
73
+ const n = boundedCount(r, { left: maxStrings }, 'string table');
69
74
  const dec = new TextDecoder('utf-8', { fatal: true });
70
75
  const out: string[] = [];
71
76
  let prev: Uint8Array = new Uint8Array(0);
77
+ let total = 0;
72
78
  for (let i = 0; i < n; i++) {
73
79
  const shared = r.varint(), rest = r.varint();
74
80
  if (shared > prev.length) throw new PackFormatError('string table: prefix longer than the previous string');
81
+ total += shared + rest;
82
+ if (total > maxBytes) throw new PackTooLargeError(maxBytes);
75
83
  const b = new Uint8Array(shared + rest);
76
84
  b.set(prev.subarray(0, shared));
77
85
  b.set(r.bytes(rest), shared);
@@ -87,9 +95,7 @@ export function writeHashTable(hashes: readonly string[]): Uint8Array {
87
95
  for (const h of hashes) {
88
96
  if (HEX64.test(h)) {
89
97
  w.u8(0);
90
- const raw = new Uint8Array(32);
91
- for (let i = 0; i < 32; i++) raw[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
92
- w.bytes(raw);
98
+ w.bytes(fromHex64(h));
93
99
  } else {
94
100
  w.u8(1);
95
101
  w.str(h);
@@ -100,15 +106,12 @@ export function writeHashTable(hashes: readonly string[]): Uint8Array {
100
106
 
101
107
  export function readHashTable(bytes: Uint8Array, maxHashes: number): string[] {
102
108
  const r = new ByteReader(bytes);
103
- const n = boundedCount(r, maxHashes, 'hash table');
109
+ const n = boundedCount(r, { left: maxHashes }, 'hash table');
104
110
  const out: string[] = [];
105
111
  for (let i = 0; i < n; i++) {
106
112
  const flag = r.u8();
107
- if (flag === 0) {
108
- let hex = '';
109
- for (const b of r.bytes(32)) hex += (b < 16 ? '0' : '') + b.toString(16);
110
- out.push(hex);
111
- } else if (flag === 1) out.push(r.str());
113
+ if (flag === 0) out.push(toHex(r.bytes(32)));
114
+ else if (flag === 1) out.push(r.str());
112
115
  else throw new PackFormatError('hash table: unknown entry flag');
113
116
  }
114
117
  return out;
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import type { Extracted, KEdge, KNode, NodeRef, ScopeRecord, StoredFact, StoredOrigin, StoredRelation } from '../model.js';
8
+ import type { Budget } from './varint.js';
8
9
 
9
10
  /** A reviewed file: its root-relative path, the hash its extracted output is keyed under, and its size. */
10
11
  export interface PackFileRow { path: string; hash: string; bytes: number }
@@ -71,15 +72,23 @@ export const ZERO_DIGEST = '0'.repeat(64);
71
72
 
72
73
  /** A pack's decoded counts, for guards before any work. */
73
74
  export interface PackLimits {
74
- /** Bytes the body may inflate to (default 64 MB). */
75
+ /** Bytes the body may inflate to (default 24 MB). */
75
76
  maxDecodedBytes: number;
76
- /** Strings in the table (default 2,000,000). */
77
+ /** Strings in the table (default 400,000). */
77
78
  maxStrings: number;
78
- /** Rows in any one section (default 1,000,000). */
79
+ /** Rows in the whole pack (default 200,000). */
79
80
  maxRows: number;
80
81
  }
81
82
 
82
- export const DEFAULT_PACK_LIMITS: PackLimits = { maxDecodedBytes: 64 * 1024 * 1024, maxStrings: 2_000_000, maxRows: 1_000_000 };
83
+ /**
84
+ * The limits a decode reads under. `maxRows` is CUMULATIVE: one `budget` is drawn down by every list of every
85
+ * section, so a pack of many small lists is bounded as a whole. `maxDecodedBytes` bounds the inflated body AND the
86
+ * total bytes of the string table.
87
+ */
88
+ export interface ReadLimits extends PackLimits { budget: Budget }
89
+
90
+ /** Sized for a 128 MB Worker: the decoded pack, its string table and its rows all live in memory at once. A client cuts a pack below these. */
91
+ export const DEFAULT_PACK_LIMITS: PackLimits = { maxDecodedBytes: 24 * 1024 * 1024, maxStrings: 400_000, maxRows: 200_000 };
83
92
 
84
93
  /** The decoded body inflated past `maxDecodedBytes`: the server answers 413 `pack_too_large`. */
85
94
  export class PackTooLargeError extends Error {
@@ -130,9 +130,16 @@ export class ByteReader {
130
130
  }
131
131
  }
132
132
 
133
- /** A count that is bounded before anything is allocated for it. */
134
- export function boundedCount(r: ByteReader, max: number, what: string): number {
133
+ /** What a whole pack may still hold: every list a decode reads draws its count from ONE budget. */
134
+ export interface Budget { left: number }
135
+
136
+ /**
137
+ * A count that is bounded before anything is allocated for it, and drawn from the pack's cumulative budget, so
138
+ * many lists that are each small cannot add up to a memory bomb.
139
+ */
140
+ export function boundedCount(r: ByteReader, budget: Budget, what: string): number {
135
141
  const n = r.varint();
136
- if (n > max) throw new PackFormatError(`${what}: ${n} exceeds the bound ${max}`);
142
+ if (n > budget.left) throw new PackFormatError(`${what}: ${n} exceeds the pack's row budget (${budget.left} left)`);
143
+ budget.left -= n;
137
144
  return n;
138
145
  }
@@ -18,6 +18,12 @@ export interface DirectorySource {
18
18
  /** `signal` aborts the read when the review gives up on it (a per-job timeout, a stop); a source that cannot cancel may ignore it. */
19
19
  read(path: string, signal?: AbortSignal): Promise<SourceDocument>;
20
20
  watch?(cb: (paths: string[]) => void): () => void;
21
+ /**
22
+ * The function that produced the `hash` of `list()` entries, over a text file's content. When given, the review hashes the
23
+ * text it read (once) and a file whose bytes no longer match the planned hash fails with "changed since plan" and stays owed.
24
+ * Optional: a source whose hash is not a pure function of the text (or that cannot say) is not checked in-thread.
25
+ */
26
+ hashOf?(text: string): string;
21
27
  }
22
28
 
23
29
  export interface ReviewPlan {
@@ -58,6 +58,9 @@ export function extractStepOf(path: string, job: Prefetch): ReviewStep {
58
58
  }
59
59
  }
60
60
 
61
+ /** The failure reason of a file whose bytes no longer match the planned hash. */
62
+ export const CHANGED_SINCE_PLAN = 'changed since plan';
63
+
61
64
  /** Per-job ceilings of the extract path (PRD 41 A10 rule 2). */
62
65
  export const DEFAULT_READ_TIMEOUT_MS = 5_000;
63
66
  export const DEFAULT_EXTRACT_TIMEOUT_MS = 10_000;
@@ -94,7 +97,13 @@ export function createPrefetch(c: PrefetchContext): (f: { path: string; hash: st
94
97
  ...(c.args.extractPool ? { pool: c.args.extractPool, signal, wantsSections, ...(byPool ? { readByPool: true } : {}) } : {}),
95
98
  })); } finally { lanes.free(held.lane); }
96
99
  });
97
- return extraction ? { kind: 'extracted', ...(doc ? { doc } : {}), extraction } : { kind: 'none' };
100
+ if (!extraction) return { kind: 'none' };
101
+ // Binary and no-pack files are decided above and never hash-checked (as in the host worker). For a file that WILL be
102
+ // stored, the bytes read must be the bytes planned: hashed once, from the text already in hand. The review writes the
103
+ // extract cache only for an 'extracted' job, so nothing is stored under the stale hash.
104
+ const hashOf = c.args.source.hashOf;
105
+ if (hashOf && doc && doc.content.kind === 'text' && hashOf(doc.content.text) !== f.hash) return { kind: 'failed', reason: CHANGED_SINCE_PLAN };
106
+ return { kind: 'extracted', ...(doc ? { doc } : {}), extraction };
98
107
  } catch (error) {
99
108
  if (error instanceof BinaryContent) return { kind: 'binary' };
100
109
  return { kind: 'failed', reason: reasonOf(error) };
@@ -11,7 +11,7 @@ import type {
11
11
  } from './model.js';
12
12
  import { loadExtractorState } from './owedFiles.js';
13
13
  import { DOCS_PACK } from './packs/docs.js';
14
- import { LocalSnapshotStore, type SnapshotPersistence } from './stores/localSnapshotStore.js';
14
+ import { LocalSnapshotStore, type ExtractedLogPersistence, type SnapshotPersistence } from './stores/localSnapshotStore.js';
15
15
  import { srcRef } from './refs.js';
16
16
 
17
17
  export const ROOT = 'r';
@@ -23,7 +23,7 @@ export interface SpySource extends DirectorySource {
23
23
 
24
24
  export function memSource(files: Record<string, string>, rootId = ROOT): SpySource {
25
25
  const src: SpySource = {
26
- rootId, title: 'Fixture', files, reads: [],
26
+ rootId, title: 'Fixture', files, reads: [], hashOf: hashText,
27
27
  async *list() {
28
28
  for (const path of Object.keys(src.files)) {
29
29
  const text = src.files[path]!;
@@ -46,6 +46,17 @@ export function memPersistence(): SnapshotPersistence & { value?: string } {
46
46
  return p;
47
47
  }
48
48
 
49
+ /** An in-memory extract log: records every `append` and `replace` so a test can prove the log is only ever appended to. */
50
+ export function memLog(): ExtractedLogPersistence & { text?: string; appends: string[]; replaces: number } {
51
+ const log: ExtractedLogPersistence & { text?: string; appends: string[]; replaces: number } = {
52
+ appends: [], replaces: 0,
53
+ async read() { return log.text; },
54
+ async append(t: string) { log.appends.push(t); log.text = (log.text ?? '') + t; },
55
+ async replace(t: string) { log.replaces += 1; log.text = t; },
56
+ };
57
+ return log;
58
+ }
59
+
49
60
  export function memStore(): LocalSnapshotStore {
50
61
  return new LocalSnapshotStore(memPersistence(), { now: () => '2026-10-28T00:00:00.000Z' });
51
62
  }