@seanhogg/builderforce-memory 2026.10.46 → 2026.10.47

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 (86) 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 +1 -1
  10. package/dist/knowledge/pack/decode.d.ts.map +1 -1
  11. package/dist/knowledge/pack/decode.js +7 -5
  12. package/dist/knowledge/pack/decode.js.map +1 -1
  13. package/dist/knowledge/pack/encode.d.ts +9 -0
  14. package/dist/knowledge/pack/encode.d.ts.map +1 -1
  15. package/dist/knowledge/pack/encode.js +7 -0
  16. package/dist/knowledge/pack/encode.js.map +1 -1
  17. package/dist/knowledge/pack/extrDiff.d.ts +4 -1
  18. package/dist/knowledge/pack/extrDiff.d.ts.map +1 -1
  19. package/dist/knowledge/pack/extrDiff.js +0 -0
  20. package/dist/knowledge/pack/extrDiff.js.map +1 -1
  21. package/dist/knowledge/pack/frame.d.ts +9 -1
  22. package/dist/knowledge/pack/frame.d.ts.map +1 -1
  23. package/dist/knowledge/pack/frame.js +20 -13
  24. package/dist/knowledge/pack/frame.js.map +1 -1
  25. package/dist/knowledge/pack/hex.d.ts +7 -0
  26. package/dist/knowledge/pack/hex.d.ts.map +1 -0
  27. package/dist/knowledge/pack/hex.js +17 -0
  28. package/dist/knowledge/pack/hex.js.map +1 -0
  29. package/dist/knowledge/pack/sections/columns.d.ts +2 -2
  30. package/dist/knowledge/pack/sections/extr.js +8 -8
  31. package/dist/knowledge/pack/sections/extr.js.map +1 -1
  32. package/dist/knowledge/pack/sections/extrLists.d.ts +4 -4
  33. package/dist/knowledge/pack/sections/extrLists.d.ts.map +1 -1
  34. package/dist/knowledge/pack/sections/extrLists.js +14 -8
  35. package/dist/knowledge/pack/sections/extrLists.js.map +1 -1
  36. package/dist/knowledge/pack/sections/facts.d.ts.map +1 -1
  37. package/dist/knowledge/pack/sections/facts.js +11 -6
  38. package/dist/knowledge/pack/sections/facts.js.map +1 -1
  39. package/dist/knowledge/pack/sections/rows.d.ts.map +1 -1
  40. package/dist/knowledge/pack/sections/rows.js +20 -19
  41. package/dist/knowledge/pack/sections/rows.js.map +1 -1
  42. package/dist/knowledge/pack/strings.d.ts +5 -1
  43. package/dist/knowledge/pack/strings.d.ts.map +1 -1
  44. package/dist/knowledge/pack/strings.js +16 -14
  45. package/dist/knowledge/pack/strings.js.map +1 -1
  46. package/dist/knowledge/pack/types.d.ts +9 -0
  47. package/dist/knowledge/pack/types.d.ts.map +1 -1
  48. package/dist/knowledge/pack/types.js.map +1 -1
  49. package/dist/knowledge/pack/varint.d.ts +9 -2
  50. package/dist/knowledge/pack/varint.d.ts.map +1 -1
  51. package/dist/knowledge/pack/varint.js +8 -4
  52. package/dist/knowledge/pack/varint.js.map +1 -1
  53. package/dist/knowledge/reviewModel.d.ts +6 -0
  54. package/dist/knowledge/reviewModel.d.ts.map +1 -1
  55. package/dist/knowledge/reviewPrefetch.d.ts +2 -0
  56. package/dist/knowledge/reviewPrefetch.d.ts.map +1 -1
  57. package/dist/knowledge/reviewPrefetch.js +11 -1
  58. package/dist/knowledge/reviewPrefetch.js.map +1 -1
  59. package/package.json +4 -3
  60. package/src/contract/dist.contract.test.ts +44 -0
  61. package/src/contract/exports.contract.test.ts +90 -0
  62. package/src/contract/exports.snapshot.json +605 -0
  63. package/src/contract/pack.contract.test.ts +31 -0
  64. package/src/contract/regression.review.test.ts +236 -0
  65. package/src/contract/regression.store.test.ts +84 -0
  66. package/src/contract/types.contract.test.ts +183 -0
  67. package/src/knowledge/extractFile.ts +2 -0
  68. package/src/knowledge/pack/crc32.ts +7 -3
  69. package/src/knowledge/pack/decode.ts +8 -6
  70. package/src/knowledge/pack/encode.ts +8 -0
  71. package/src/knowledge/pack/extrDiff.ts +0 -0
  72. package/src/knowledge/pack/frame.ts +21 -13
  73. package/src/knowledge/pack/hex.ts +17 -0
  74. package/src/knowledge/pack/pack.guards.test.ts +33 -1
  75. package/src/knowledge/pack/pack.roundtrip.test.ts +1 -1
  76. package/src/knowledge/pack/sections/columns.ts +2 -2
  77. package/src/knowledge/pack/sections/extr.ts +9 -9
  78. package/src/knowledge/pack/sections/extrLists.ts +13 -9
  79. package/src/knowledge/pack/sections/facts.ts +7 -4
  80. package/src/knowledge/pack/sections/rows.ts +17 -17
  81. package/src/knowledge/pack/strings.ts +15 -12
  82. package/src/knowledge/pack/types.ts +8 -0
  83. package/src/knowledge/pack/varint.ts +10 -3
  84. package/src/knowledge/reviewModel.ts +6 -0
  85. package/src/knowledge/reviewPrefetch.ts +10 -1
  86. package/src/knowledge/testkit.test-util.ts +13 -2
@@ -0,0 +1,236 @@
1
+ /**
2
+ * src/contract/regression.review.test.ts — bugs fixed in the review pipeline, each pinned by one test named
3
+ * `regression: <what broke>`. A failing one means a fixed bug came back. (Bugs already pinned elsewhere are
4
+ * listed in the CHANGELOG entry of the contract tests, not repeated here.)
5
+ */
6
+
7
+ import { hashText } from '../ingest/hash.js';
8
+ import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
9
+ import type { ReviewStep } from '../knowledge/reviewRunModel.js';
10
+ import { extractJob, type ExtractJob, type ExtractPool } from '../knowledge/extractJob.js';
11
+ import type { JudgementRequest, KnowledgePack, KnowledgeStore } from '../knowledge/model.js';
12
+ import { DOCS_PACK } from '../knowledge/packs/docs.js';
13
+ import { planReview } from '../knowledge/plan.js';
14
+ import { srcRef } from '../knowledge/refs.js';
15
+ import { reviewDirectory } from '../knowledge/review.js';
16
+ import { applyRunEvent, failuresOf, failureTotal, REVIEW_RUN_FAILURE_CHUNK, startRun } from '../knowledge/reviewRun.js';
17
+ import { extractorManifestKey, filesManifestKey, judgedManifestKey, manifestMap } from '../knowledge/sources.js';
18
+ import {
19
+ ALL, args, fakeJudge, FILES, memSource, memStore, quietPack, ROOT, stateOf, type SpySource,
20
+ } from '../knowledge/testkit.test-util.js';
21
+
22
+ const sixFiles = () => Object.fromEntries(Array.from({ length: 6 }, (_, i) => [`d${i}.md`, `# T${i}\nbody ${i}\n`]));
23
+
24
+ /** A pool that reads each file itself (`deferRead`), optionally slowly, as the worker pool of a host does. */
25
+ function readingPool(source: SpySource, onJob: (path: string) => void = () => undefined, delayMs = 0): ExtractPool {
26
+ return async (job) => {
27
+ onJob(job.path);
28
+ const doc = await source.read(job.path);
29
+ if (delayMs > 0 && job.path !== 'd0.md') await new Promise((r) => setTimeout(r, delayMs));
30
+ return extractJob({ ...job, doc } as ExtractJob, [DOCS_PACK]);
31
+ };
32
+ }
33
+
34
+ describe('regression: judging', () => {
35
+ it('regression: a judge call that times out is not recorded as judged, and the next run judges the section again', async () => {
36
+ const source = memSource({ 'a.md': '# A\nalpha\n' });
37
+ const store = memStore();
38
+ const manifest = new InMemoryIngestManifest();
39
+ const timingOut = { async judge(_req: JudgementRequest): Promise<never> { throw new Error('judge: timeout after 60s'); } };
40
+
41
+ const report = await reviewDirectory(args(source, store, manifest, { judgement: timingOut, packs: [quietPack] }));
42
+ expect(report).toMatchObject({ judged: 0, unjudged: 1 });
43
+ expect(await manifestMap(manifest, judgedManifestKey(ROOT))).toEqual(new Map()); // no section recorded as judged
44
+ expect(await store.facts({ rootId: ROOT })).toEqual([]);
45
+ expect((await planReview(source, manifest, [quietPack])).changed).toEqual(['a.md']); // still owed
46
+
47
+ const judge = fakeJudge();
48
+ const again = await reviewDirectory(args(source, store, manifest, { judgement: judge, packs: [quietPack] }));
49
+ expect(judge.requests.filter((r) => r.kind === 'extract')).toHaveLength(1);
50
+ expect(again.judged).toBe(1);
51
+ expect((await manifestMap(manifest, judgedManifestKey(ROOT))).size).toBe(1);
52
+ });
53
+ });
54
+
55
+ describe('regression: abort', () => {
56
+ it('regression: an abort mid-read through a deferRead pool with read-ahead keeps the finished files clear and owes the unreached ones', async () => {
57
+ const source = memSource(sixFiles());
58
+ const store = memStore();
59
+ const manifest = new InMemoryIngestManifest();
60
+ await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge() }));
61
+ await manifest.delete(extractorManifestKey(ROOT)); // the next review is an upgrade run: every file is owed until it is finished
62
+
63
+ const controller = new AbortController();
64
+ const pool = readingPool(source, (path) => { if (path === 'd1.md') controller.abort(); }, 25);
65
+ const report = await reviewDirectory(args(source, store, manifest, {
66
+ judgement: fakeJudge(), signal: controller.signal,
67
+ extractPool: pool, deferRead: true, concurrency: 3, readAhead: 6,
68
+ }));
69
+ expect(report.aborted).toBe(true);
70
+
71
+ const owed = (await stateOf(manifest)).owed;
72
+ expect(owed).toContain('d5.md'); // never reached
73
+ expect(owed.every((p) => p in sixFiles())).toBe(true);
74
+
75
+ source.reads.length = 0;
76
+ await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge() }));
77
+ expect([...source.reads].sort()).toEqual(owed); // only what was owed is read again
78
+ expect((await stateOf(manifest)).owed).toEqual([]);
79
+ }, 30_000);
80
+ });
81
+
82
+ describe('regression: abort listeners', () => {
83
+ /** Counts the live 'abort' listeners per AbortSignal while a run goes. */
84
+ function trackAbortListeners() {
85
+ const proto = EventTarget.prototype;
86
+ const add = proto.addEventListener;
87
+ const remove = proto.removeEventListener;
88
+ const live = new WeakMap<object, Set<unknown>>();
89
+ let peak = 0;
90
+ proto.addEventListener = function (this: EventTarget, type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions) {
91
+ if (type === 'abort' && this instanceof AbortSignal) {
92
+ const set = live.get(this) ?? new Set<unknown>();
93
+ live.set(this, set);
94
+ set.add(listener);
95
+ peak = Math.max(peak, set.size);
96
+ }
97
+ return add.call(this, type, listener, options);
98
+ } as typeof proto.addEventListener;
99
+ proto.removeEventListener = function (this: EventTarget, type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions) {
100
+ if (type === 'abort' && this instanceof AbortSignal) live.get(this)?.delete(listener);
101
+ return remove.call(this, type, listener, options);
102
+ } as typeof proto.removeEventListener;
103
+ return { peak: () => peak, restore: () => { proto.addEventListener = add; proto.removeEventListener = remove; } };
104
+ }
105
+
106
+ it('regression: the run signal never carries more than a small constant number of abort listeners while 20,000 jobs run', async () => {
107
+ const N = 20_000;
108
+ const files = Object.fromEntries(Array.from({ length: N }, (_, i) => [`d${Math.floor(i / 100)}/f${i}.md`, `# T${i}\nbody ${i}\n`]));
109
+ const source = memSource(files);
110
+ const tracker = trackAbortListeners();
111
+ try {
112
+ const report = await reviewDirectory(args(source, memStore(), new InMemoryIngestManifest(), {
113
+ mechanical: true, judgement: fakeJudge(), signal: new AbortController().signal,
114
+ extractPool: readingPool(source), deferRead: true, concurrency: 8,
115
+ }));
116
+ expect(report.extracted).toBe(N);
117
+ expect(report.failures).toEqual([]);
118
+ expect(tracker.peak()).toBeLessThanOrEqual(8);
119
+ } finally {
120
+ tracker.restore();
121
+ }
122
+ }, 120_000);
123
+ });
124
+
125
+ describe('regression: pass 2 and pass 1', () => {
126
+ /** A store that records the retirements (markStale at no hash) it is asked for. */
127
+ function spyStore(retired: string[]): KnowledgeStore {
128
+ const local = memStore();
129
+ return {
130
+ scopes: () => local.scopes(), facts: (s) => local.facts(s), relations: (s) => local.relations(s),
131
+ write: (b) => local.write(b),
132
+ markStale: (scope, ref, hash) => { if (hash === '') retired.push(ref); return local.markStale(scope, ref, hash); },
133
+ getExtracted: (h) => local.getExtracted(h), putExtracted: (h, e) => local.putExtracted(h, e),
134
+ batched: (work) => local.batched(work),
135
+ };
136
+ }
137
+
138
+ it('regression: pass 2 (only) runs no analyzers and retires nothing; the map pass does both', async () => {
139
+ let analysed = 0;
140
+ const pack: KnowledgePack = { ...quietPack, analyzers: { async analyse() { analysed += 1; return []; } } };
141
+ const retired: string[] = [];
142
+ const store = spyStore(retired);
143
+ const manifest = new InMemoryIngestManifest();
144
+ const source = memSource({ ...FILES });
145
+ await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge(), packs: [pack] }));
146
+ expect(analysed).toBe(1);
147
+
148
+ delete source.files['c.md'];
149
+ source.files['a.md'] = '# A\nalpha two\n';
150
+ await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge(), packs: [pack], only: ['a.md'] }));
151
+ expect(analysed).toBe(1);
152
+ expect(retired).toEqual([]);
153
+ expect((await manifestMap(manifest, filesManifestKey(ROOT))).has('c.md')).toBe(true); // still known: the map pass retires it
154
+
155
+ await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge(), packs: [pack] }));
156
+ expect(analysed).toBe(2);
157
+ expect(retired).toEqual([srcRef(ROOT, 'c.md')]);
158
+ });
159
+
160
+ it('regression: pass 1 neither owes nor stale-marks a file whose sections are all reused', async () => {
161
+ const store = memStore();
162
+ const manifest = new InMemoryIngestManifest();
163
+ const source = memSource({ ...FILES });
164
+ await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge(), packs: [quietPack] }));
165
+ source.files['a.md'] = '# A\nalpha changed\n'; // a.md's section needs the model again; b.md and c.md only get re-read (force)
166
+
167
+ const judge = fakeJudge();
168
+ const report = await reviewDirectory(args(source, store, manifest, { judgement: judge, packs: [quietPack], mechanical: true, force: true }));
169
+ expect(judge.requests).toHaveLength(0);
170
+ expect(report.awaitingJudge).toEqual(['a.md']); // b.md and c.md owe nothing
171
+ expect((await stateOf(manifest)).owed).toEqual(['a.md']);
172
+ expect(ALL.filter((p) => !report.awaitingJudge.includes(p))).toEqual(['b.md', 'c.md']);
173
+ // Nothing is stale: the reused files were refreshed, and the owed one keeps its old judgement current until pass 2.
174
+ expect((await store.relations({ rootId: ROOT })).filter((r) => r.staleAt)).toEqual([]);
175
+ });
176
+ });
177
+
178
+ describe('regression: review run failures', () => {
179
+ it('regression: failure chunks append in constant work and failuresOf reads the flat list in order', () => {
180
+ const N = REVIEW_RUN_FAILURE_CHUNK * 3 + 7;
181
+ let run = startRun({ id: 'r', root: 'r', kind: 'review', at: 0 });
182
+ const fail = (i: number) => ({ type: 'step' as const, step: { path: `f${i}.md`, phase: 'extract' as const, ms: 1, outcome: 'failed' as const, reason: `r${i}` } });
183
+ for (let i = 0; i < N; i++) run = applyRunEvent(run, fail(i), i);
184
+
185
+ expect(failureTotal(run)).toBe(N);
186
+ expect(run.failures.map((c) => c.length)).toEqual([REVIEW_RUN_FAILURE_CHUNK, REVIEW_RUN_FAILURE_CHUNK, REVIEW_RUN_FAILURE_CHUNK, 7]);
187
+ expect(failuresOf(run).map((f) => f.path)).toEqual(Array.from({ length: N }, (_, i) => `f${i}.md`));
188
+
189
+ // Linear: a full chunk is shared by reference with every later run, never copied again.
190
+ const before = run.failures;
191
+ run = applyRunEvent(run, fail(N), N);
192
+ expect(run.failures[0]).toBe(before[0]);
193
+ expect(run.failures[2]).toBe(before[2]);
194
+ expect(failureTotal(run)).toBe(N + 1);
195
+ });
196
+ });
197
+
198
+ describe('regression: changed since plan', () => {
199
+ const EDITED = '# A\nedited after the plan\n';
200
+
201
+ it('regression: a file whose bytes changed between plan and read is a failed step "changed since plan", stores nothing under the planned hash, and is extracted by the next run', async () => {
202
+ const source = memSource({ ...FILES });
203
+ const store = memStore();
204
+ const manifest = new InMemoryIngestManifest();
205
+ const planned = hashText(FILES['a.md']);
206
+ const read = source.read.bind(source);
207
+ source.read = async (p) => (p === 'a.md' ? { id: p, tenantId: 't', content: { kind: 'text', text: EDITED } } : read(p));
208
+ const steps: ReviewStep[] = [];
209
+
210
+ const report = await reviewDirectory(args(source, store, manifest, { onStep: (s) => steps.push(s) }));
211
+ expect(report.failures).toEqual([{ path: 'a.md', phase: 'extract', reason: 'changed since plan' }]);
212
+ expect(report.extractErrors).toBe(1);
213
+ expect(steps.filter((s) => s.path === 'a.md' && s.phase === 'extract')).toMatchObject([{ outcome: 'failed', reason: 'changed since plan' }]);
214
+ expect(await store.getExtracted(planned)).toBeUndefined();
215
+ expect((await manifestMap(manifest, filesManifestKey(ROOT))).has('a.md')).toBe(false); // still owed
216
+
217
+ source.read = read;
218
+ source.files['a.md'] = EDITED; // the fresh plan sees the new bytes
219
+ const next = await reviewDirectory(args(source, store, manifest));
220
+ expect(next.failures).toEqual([]);
221
+ expect(await store.getExtracted(hashText(EDITED))).toBeDefined();
222
+ expect((await manifestMap(manifest, filesManifestKey(ROOT))).get('a.md')).toBe(hashText(EDITED));
223
+ });
224
+
225
+ it('regression: a pool result whose own hash differs from the plan is a failed step "changed since plan"', async () => {
226
+ const source = memSource({ ...FILES });
227
+ const store = memStore();
228
+ const pool: ExtractPool = async (job) => {
229
+ const out = extractJob({ ...job, doc: await source.read(job.path) } as ExtractJob, [DOCS_PACK]);
230
+ return job.path === 'a.md' ? { ...out, extracted: out.extracted.map((e) => ({ ...e, sourceHash: 'other' })) } : out;
231
+ };
232
+ const report = await reviewDirectory(args(source, store, new InMemoryIngestManifest(), { extractPool: pool, deferRead: true }));
233
+ expect(report.failures).toEqual([{ path: 'a.md', phase: 'extract', reason: 'changed since plan' }]);
234
+ expect(await store.getExtracted(hashText(FILES['a.md']))).toBeUndefined();
235
+ });
236
+ });
@@ -0,0 +1,84 @@
1
+ /**
2
+ * src/contract/regression.store.test.ts — bugs fixed in LocalSnapshotStore and its extract log, each pinned by
3
+ * one test named `regression: <what broke>`.
4
+ */
5
+
6
+ import type { Extracted } from '../knowledge/model.js';
7
+ import { LocalSnapshotStore } from '../knowledge/stores/localSnapshotStore.js';
8
+ import { memLog, memPersistence } from '../knowledge/testkit.test-util.js';
9
+
10
+ const SCOPE = { rootId: 'r', title: 'R', packs: ['docs'] };
11
+ const ex = (name: string) => [{ name }] as unknown as Extracted[];
12
+ const line = (h: string, name: string) => `${JSON.stringify({ h, e: ex(name) })}\n`;
13
+ const legacySnapshot = (extracted: Record<string, Extracted[]>) => JSON.stringify({ version: 1, scopes: [], facts: {}, relations: {}, extracted });
14
+ const countOf = (text: string | undefined, hash: string) => (text?.match(new RegExp(`"h":"${hash}"`, 'g')) ?? []).length;
15
+
16
+ describe('regression: extract log', () => {
17
+ it('regression: checkpoints append to the extract log and never rewrite it or put it back in the snapshot', async () => {
18
+ const snap = memPersistence();
19
+ let snapshotWrites = 0;
20
+ const write = snap.write;
21
+ snap.write = async (s) => { snapshotWrites += 1; await write(s); };
22
+ const log = memLog();
23
+ const store = new LocalSnapshotStore(snap, { extractedLog: log, checkpointMs: 1_000 });
24
+
25
+ const N = 6;
26
+ await store.batched(async (flush) => {
27
+ for (let i = 0; i < N; i++) {
28
+ await store.putExtracted(`h${i}`, ex(`e${i}`));
29
+ await store.write({ scope: SCOPE, facts: [{ key: `claim:${i}`, content: 'c', source: 's', importance: 0.5, origin: 'model', fileAnchors: [] }], relations: [] });
30
+ await flush(); // a checkpoint
31
+ }
32
+ });
33
+
34
+ expect(log.replaces).toBe(0); // the whole log is never rewritten
35
+ expect(log.appends).toHaveLength(N); // one append per checkpoint…
36
+ expect(log.appends.every((a) => a.trim().split('\n').length === 1)).toBe(true); // …carrying only the entry that was new
37
+ expect(log.text).toBe(log.appends.join('')); // the log is exactly its appends, in order
38
+ expect(snapshotWrites).toBeGreaterThanOrEqual(N);
39
+ expect(snap.value).not.toContain('"extracted"'); // the cache never rides in the snapshot
40
+ });
41
+ });
42
+
43
+ describe('regression: snapshot migration', () => {
44
+ it('regression: after an old snapshot is migrated, extractedEntries still returns every entry, and a second store loads it without migrating again', async () => {
45
+ const snap = memPersistence();
46
+ snap.value = legacySnapshot({ old1: ex('o1'), old2: ex('o2') });
47
+ const log = memLog();
48
+
49
+ const first = new LocalSnapshotStore(snap, { extractedLog: log });
50
+ expect(await first.extractedEntries()).toEqual({ old1: ex('o1'), old2: ex('o2') }); // readable before anything persisted
51
+ await first.putExtracted('new', ex('n')); // persists: the legacy entries move into the log
52
+ expect(await first.extractedEntries()).toEqual({ old1: ex('o1'), old2: ex('o2'), new: ex('n') });
53
+ expect(snap.value).not.toContain('"extracted"');
54
+ const appended = log.appends.length;
55
+
56
+ const second = new LocalSnapshotStore(snap, { extractedLog: log });
57
+ expect(await second.extractedEntries()).toEqual({ old1: ex('o1'), old2: ex('o2'), new: ex('n') });
58
+ await second.putExtracted('later', ex('l'));
59
+ expect(log.appends).toHaveLength(appended + 1); // only `later`
60
+ expect(countOf(log.text, 'old1')).toBe(1);
61
+ expect(countOf(log.text, 'old2')).toBe(1);
62
+ });
63
+
64
+ it('regression: an old snapshot whose entries the log already holds is migrated once, not appended twice', async () => {
65
+ const snap = memPersistence();
66
+ snap.value = legacySnapshot({ old: ex('stale-copy') });
67
+ const log = memLog();
68
+ log.text = line('old', 'logged-copy');
69
+
70
+ const store = new LocalSnapshotStore(snap, { extractedLog: log });
71
+ await store.putExtracted('new', ex('n'));
72
+ expect(countOf(log.text, 'old')).toBe(1);
73
+ expect((await store.extractedEntries()).old).toEqual(ex('logged-copy')); // the log's line wins
74
+ });
75
+
76
+ it('regression: a store without a log keeps reading and writing the snapshot\'s own extracted', async () => {
77
+ const snap = memPersistence();
78
+ snap.value = legacySnapshot({ old: ex('o') });
79
+ const store = new LocalSnapshotStore(snap);
80
+ await store.putExtracted('new', ex('n'));
81
+ expect(await store.extractedEntries()).toEqual({ old: ex('o'), new: ex('n') });
82
+ expect(Object.keys(JSON.parse(snap.value!).extracted).sort()).toEqual(['new', 'old']);
83
+ });
84
+ });
@@ -0,0 +1,183 @@
1
+ /**
2
+ * src/contract/types.contract.test.ts — the COMPILE-TIME contract of the shapes consumers depend on
3
+ * (agent-tools `packGraph.ts` / `portablePack.ts`, the VS Code run tests, the API worker).
4
+ *
5
+ * There is nothing to run: the checks are types, and a failing one is a `tsc` error on a line whose alias
6
+ * NAMES what changed (e.g. `KnowledgeSnapshot_extracted_is_optional`). The package build excludes test files,
7
+ * so `npm run check:contract-types` type-checks this file through `tsconfig.contract.json`; CI runs it after
8
+ * the build. A failure means a consumer-visible change: update the check deliberately, note it in the
9
+ * CHANGELOG ("Breaking" when a consumer must change) and bump the consumers.
10
+ *
11
+ * No type-test dependency: `Equal` / `Expect` below are the usual two-line helpers.
12
+ */
13
+
14
+ import type { ParsedSection, SourceDocument } from '../ingest/types.js';
15
+ import type {
16
+ Extracted, ExtractJob, ExtractJobResult, GraphApp, GraphOutline, GraphReadSkip, GraphSystem, KEdge, KNode, KnowledgeGraph, KnowledgeStore,
17
+ OutlineFile, ReviewFailure, ReviewFailureChunks, ReviewPhase, ReviewReport, ReviewRun, ReviewRunPhase, ReviewStep, ScopeRecord,
18
+ StoredFact, StoredRelation, ExtractedLogPersistence, KnowledgeSnapshot, LocalSnapshotStoreOptions, SnapshotPersistence,
19
+ } from '../knowledge/index.js';
20
+ import { failuresOf, failureTotal, LocalSnapshotStore, localSnapshotStore } from '../knowledge/index.js';
21
+
22
+ type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
23
+ type Expect<T extends true> = T;
24
+ /** True when `K` of `T` may be omitted. */
25
+ type IsOptional<T, K extends keyof T> = Record<never, never> extends Pick<T, K> ? true : false;
26
+
27
+ /* ── KnowledgeSnapshot ─────────────────────────────────────────────────────────────────────────────────────── */
28
+ // `extracted` became optional (the extract cache moved to the log); consumers read it ONLY through `extractedEntries()`.
29
+ export type KnowledgeSnapshot_keys = Expect<Equal<keyof KnowledgeSnapshot, 'version' | 'scopes' | 'facts' | 'relations' | 'extracted'>>;
30
+ export type KnowledgeSnapshot_extracted_is_optional = Expect<Equal<IsOptional<KnowledgeSnapshot, 'extracted'>, true>>;
31
+ export type KnowledgeSnapshot_extracted_shape = Expect<Equal<KnowledgeSnapshot['extracted'], Record<string, Extracted[]> | undefined>>;
32
+ export type KnowledgeSnapshot_rows_are_required = Expect<Equal<
33
+ Pick<KnowledgeSnapshot, 'version' | 'scopes' | 'facts' | 'relations'>,
34
+ { version: 1; scopes: ScopeRecord[]; facts: Record<string, StoredFact[]>; relations: Record<string, StoredRelation[]> }
35
+ >>;
36
+ export const snapshotWithoutExtracted = { version: 1, scopes: [], facts: {}, relations: {} } satisfies KnowledgeSnapshot;
37
+ export const readsThroughTheEntriesPort = (store: LocalSnapshotStore): Promise<Record<string, Extracted[]>> => store.extractedEntries();
38
+
39
+ /* ── ReviewReport ──────────────────────────────────────────────────────────────────────────────────────────── */
40
+ export type ReviewReport_judging_fields = Expect<Equal<
41
+ Pick<ReviewReport, 'awaitingJudge' | 'awaitingJudgeCount' | 'judgedFiles' | 'judgeStopped' | 'failures'>,
42
+ {
43
+ awaitingJudge: string[]; awaitingJudgeCount?: number; judgedFiles?: number; judgeStopped?: string;
44
+ failures: ReviewFailure[];
45
+ }
46
+ >>;
47
+ export type ReviewReport_counters = Expect<Equal<
48
+ Pick<ReviewReport, 'extracted' | 'judged' | 'unjudged' | 'readErrors' | 'extractErrors' | 'aborted' | 'digest' | 'durationMs'>,
49
+ { extracted: number; judged: number; unjudged: number; readErrors: number; extractErrors: number; aborted: boolean; digest: string; durationMs: number }
50
+ >>;
51
+ export type ReviewFailure_shape = Expect<Equal<ReviewFailure, { path: string; phase: ReviewPhase; reason: string }>>;
52
+
53
+ /* ── ReviewRun: failures are CHUNKS, read through failuresOf / failureTotal ─────────────────────────────────── */
54
+ export type ReviewRun_failures_are_chunks = Expect<Equal<ReviewRun['failures'], readonly (readonly ReviewFailure[])[]>>;
55
+ export type ReviewFailureChunks_shape = Expect<Equal<ReviewFailureChunks, readonly (readonly ReviewFailure[])[]>>;
56
+ export type ReviewRun_failures_is_not_a_flat_list = Expect<Equal<ReviewFailure[] extends ReviewRun['failures'] ? true : false, false>>;
57
+ export type failuresOf_signature = Expect<Equal<typeof failuresOf, (run: Pick<ReviewRun, 'failures'>) => ReviewFailure[]>>;
58
+ export type failureTotal_signature = Expect<Equal<typeof failureTotal, (run: Pick<ReviewRun, 'failures'>) => number>>;
59
+ export type ReviewRun_fields = Expect<Equal<
60
+ Pick<ReviewRun, 'id' | 'root' | 'startedAt' | 'updatedAt' | 'phases' | 'steps' | 'endedAt' | 'outcome' | 'report'>,
61
+ {
62
+ id: string; root: string; startedAt: number; updatedAt: number; phases: ReviewRunPhase[]; steps: ReviewStep[];
63
+ endedAt?: number; outcome?: 'done' | 'stopped' | 'failed'; report?: ReviewReport;
64
+ }
65
+ >>;
66
+
67
+ /* ── ReviewStep.parts, ReviewPhase ─────────────────────────────────────────────────────────────────────────── */
68
+ export type ReviewStep_parts = Expect<Equal<ReviewStep['parts'], { readMs?: number; lookupMs?: number; poolMs?: number } | undefined>>;
69
+ export type ReviewStep_outcome = Expect<Equal<ReviewStep['outcome'], 'ok' | 'cached' | 'skipped' | 'failed'>>;
70
+ export type ReviewStep_fields = Expect<Equal<
71
+ Pick<ReviewStep, 'path' | 'phase' | 'ms' | 'reason' | 'lane'>,
72
+ { path: string; phase: ReviewPhase; ms: number; reason?: string; lane?: number }
73
+ >>;
74
+ // `mapped` is the end of the mechanical pass: a view that switches on phases must know it.
75
+ export type ReviewPhase_values = Expect<Equal<ReviewPhase, 'plan' | 'extract' | 'resolve' | 'judge' | 'compare' | 'write' | 'index' | 'mapped' | 'done'>>;
76
+
77
+ /* ── ExtractJob: a union of "the review read it" (doc) and "the pool reads it" (readByPool) ──────────────────── */
78
+ const aDocument: SourceDocument = { id: 'a.md', tenantId: 't', content: { kind: 'text', text: '# A\n' } };
79
+ const someSections: ParsedSection[] = [{ text: '# A\n' }];
80
+ const anExtract: Extracted = { sourceRef: 'src:r::a.md', sourceHash: 'h', nodes: [], edges: [], keys: [] };
81
+ const base = { rootId: 'r', path: 'a.md', hash: 'h', knownKeys: [] as ReadonlyArray<readonly [string, KNode['ref']]> };
82
+ export const jobCarryingTheDocument = { ...base, doc: aDocument } satisfies ExtractJob;
83
+ export const jobTheWorkerReads = { ...base, readByPool: { path: 'a.md', hash: 'h' } } satisfies ExtractJob;
84
+ export const jobWithSectionFlags = { ...base, doc: aDocument, needSections: true, sectionsOnly: true } satisfies ExtractJob;
85
+ // @ts-expect-error ExtractJob: a job carries `doc` OR `readByPool`, never both
86
+ export const jobWithBoth: ExtractJob = { ...base, doc: aDocument, readByPool: { path: 'a.md', hash: 'h' } };
87
+ // @ts-expect-error ExtractJob: a job carries one of `doc` / `readByPool`
88
+ export const jobWithNeither: ExtractJob = { ...base };
89
+ export type ExtractJob_readByPool_shape = Expect<Equal<NonNullable<Extract<ExtractJob, { readByPool: unknown }>['readByPool']>, { path: string; hash: string }>>;
90
+ export const resultShape = { binary: true, extracted: [anExtract], sections: someSections } satisfies ExtractJobResult;
91
+ export type ExtractJobResult_fields = Expect<Equal<ExtractJobResult, { binary?: true; extracted: Extracted[]; sections?: ParsedSection[] }>>;
92
+
93
+ /* ── KnowledgeStore: the port hosts implement ──────────────────────────────────────────────────────────────── */
94
+ export type KnowledgeStore_methods = Expect<Equal<
95
+ keyof KnowledgeStore,
96
+ 'scopes' | 'facts' | 'relations' | 'write' | 'markStale' | 'getExtracted' | 'putExtracted' | 'preloadExtracted' | 'batched'
97
+ >>;
98
+ export type KnowledgeStore_optional_methods = Expect<Equal<
99
+ [IsOptional<KnowledgeStore, 'getExtracted'>, IsOptional<KnowledgeStore, 'putExtracted'>, IsOptional<KnowledgeStore, 'preloadExtracted'>, IsOptional<KnowledgeStore, 'batched'>],
100
+ [true, true, true, true]
101
+ >>;
102
+ export type KnowledgeStore_required_methods = Expect<Equal<
103
+ [IsOptional<KnowledgeStore, 'scopes'>, IsOptional<KnowledgeStore, 'facts'>, IsOptional<KnowledgeStore, 'relations'>, IsOptional<KnowledgeStore, 'write'>, IsOptional<KnowledgeStore, 'markStale'>],
104
+ [false, false, false, false, false]
105
+ >>;
106
+ export type KnowledgeStore_signatures = Expect<Equal<
107
+ Pick<KnowledgeStore, 'scopes' | 'facts' | 'relations' | 'write' | 'markStale' | 'getExtracted' | 'putExtracted' | 'preloadExtracted'>,
108
+ {
109
+ scopes(): Promise<ScopeRecord[]>;
110
+ facts(scope: { rootId: string }): Promise<StoredFact[]>;
111
+ relations(scope: { rootId: string }): Promise<StoredRelation[]>;
112
+ write(batch: { scope: ScopeRecord; facts: StoredFact[]; relations: StoredRelation[] }): Promise<void>;
113
+ markStale(scope: { rootId: string }, sourceRef: KNode['ref'], currentHash: string): Promise<void>;
114
+ getExtracted?(hash: string): Promise<Extracted[] | undefined>;
115
+ putExtracted?(hash: string, extracted: Extracted[]): Promise<void>;
116
+ preloadExtracted?(hashes: readonly string[]): Promise<void>;
117
+ }
118
+ >>;
119
+ // A host store with only the required methods is still a KnowledgeStore (the optional ones stay optional).
120
+ export const minimalHostStore = {
121
+ async scopes() { return [] as ScopeRecord[]; },
122
+ async facts() { return [] as StoredFact[]; },
123
+ async relations() { return [] as StoredRelation[]; },
124
+ async write() {},
125
+ async markStale() {},
126
+ } satisfies KnowledgeStore;
127
+ export const batchedHostStore = {
128
+ ...minimalHostStore,
129
+ batched: <T>(work: (flush: () => Promise<void>) => Promise<T>): Promise<T> => work(async () => {}),
130
+ } satisfies KnowledgeStore;
131
+
132
+ /* ── LocalSnapshotStore: the shipped KnowledgeStore ────────────────────────────────────────────────────────── */
133
+ export type LocalSnapshotStore_is_a_KnowledgeStore = Expect<Equal<LocalSnapshotStore extends KnowledgeStore ? true : false, true>>;
134
+ export type LocalSnapshotStore_public_methods = Expect<Equal<
135
+ keyof LocalSnapshotStore,
136
+ 'batched' | 'scopes' | 'facts' | 'relations' | 'write' | 'markStale' | 'getExtracted' | 'extractedEntries' | 'putExtracted'
137
+ >>;
138
+ export type LocalSnapshotStore_extractedEntries = Expect<Equal<LocalSnapshotStore['extractedEntries'], () => Promise<Record<string, Extracted[]>>>>;
139
+ export type LocalSnapshotStore_constructor = Expect<Equal<
140
+ ConstructorParameters<typeof LocalSnapshotStore>, [persistence: SnapshotPersistence, opts?: LocalSnapshotStoreOptions]
141
+ >>;
142
+ export type localSnapshotStore_factory = Expect<Equal<typeof localSnapshotStore, (persistence: SnapshotPersistence, opts?: LocalSnapshotStoreOptions) => LocalSnapshotStore>>;
143
+ export type LocalSnapshotStoreOptions_keys = Expect<Equal<keyof LocalSnapshotStoreOptions, 'extractedLog' | 'now' | 'checkpointMs' | 'nowMs'>>;
144
+ export type SnapshotPersistence_ports = Expect<Equal<
145
+ SnapshotPersistence,
146
+ { read(): Promise<string | undefined>; write(snapshot: string): Promise<void>; keepAside?(text: string): Promise<void> }
147
+ >>;
148
+ export type ExtractedLogPersistence_ports = Expect<Equal<
149
+ ExtractedLogPersistence,
150
+ { read(): Promise<string | undefined>; append(text: string): Promise<void>; replace?(text: string): Promise<void> }
151
+ >>;
152
+
153
+ /* ── GraphSystem / KNode system fields ─────────────────────────────────────────────────────────────────────── */
154
+ export type KNode_system_fields = Expect<Equal<
155
+ Pick<KNode, 'system' | 'app' | 'copyOf'>,
156
+ { system?: string; app?: string; copyOf?: string }
157
+ >>;
158
+ export type GraphSystem_fields = Expect<Equal<
159
+ GraphSystem,
160
+ {
161
+ path: string; name: string; files: number; apps: GraphApp[]; truncated?: boolean; copyOf?: string; copySimilarity?: number;
162
+ copyReason?: 'no-git' | 'name-mismatch' | 'later-name'; graphRead?: { read: number; skipped: GraphReadSkip[] };
163
+ }
164
+ >>;
165
+ export type GraphApp_fields = Expect<Equal<GraphApp, { path: string; name: string }>>;
166
+ export type GraphReadSkip_fields = Expect<Equal<GraphReadSkip, { reason: string; count: number }>>;
167
+ export type KnowledgeGraph_systems = Expect<Equal<NonNullable<KnowledgeGraph['meta']>['systems'], GraphSystem[] | undefined>>;
168
+ export type GraphOutline_systems = Expect<Equal<
169
+ Pick<GraphOutline, 'systems' | 'apps' | 'systemInfo'>,
170
+ { systems?: string[]; apps?: string[]; systemInfo?: GraphSystem[] }
171
+ >>;
172
+ export type OutlineFile_system_indexes = Expect<Equal<Pick<OutlineFile, 'system' | 'app' | 'copyOf'>, { system?: number; app?: number; copyOf?: number }>>;
173
+ export type KEdge_verdict = Expect<Equal<KEdge['verdict'], 'allowed' | 'same' | 'skips' | 'upward' | undefined>>;
174
+
175
+ describe('type contract', () => {
176
+ it('is enforced by `npm run check:contract-types` (tsc over tsconfig.contract.json), not at run time', () => {
177
+ // The values above only exist so the `satisfies` / `@ts-expect-error` lines are real code; this proves the file loads.
178
+ expect(snapshotWithoutExtracted.version).toBe(1);
179
+ expect(typeof readsThroughTheEntriesPort).toBe('function');
180
+ expect(typeof jobWithBoth).toBe('object');
181
+ expect(Object.keys(batchedHostStore)).toContain('batched');
182
+ });
183
+ });
@@ -107,6 +107,8 @@ export async function extractFileDetailed(a: ExtractFileArgs): Promise<FileExtra
107
107
  // Exact match only: a result for another file, or none although the packs accept this one, is a failure.
108
108
  const mine = out.extracted.find((e) => e.sourceRef === ref);
109
109
  if (!mine) throw new Error(`extract pool returned no extract for ${a.path}`);
110
+ // The pool read other bytes than the plan hashed: nothing is stored under the planned hash.
111
+ if (mine.sourceHash !== a.hash) throw new Error('changed since plan');
110
112
  if (wants) {
111
113
  if (!out.sections) throw new Error(`extract pool returned no sections for ${a.path}`);
112
114
  sections = out.sections;
@@ -1,4 +1,7 @@
1
- /** knowledge/pack/crc32.ts — CRC-32 (IEEE 802.3) of a byte range; the trailer of a BFKP frame (PRD 41 A11). */
1
+ /**
2
+ * knowledge/pack/crc32.ts — CRC-32 (IEEE 802.3) of a byte range; the trailer of a BFKP frame (PRD 41 A11).
3
+ * `crc32(b, crc32(a))` equals `crc32(a ++ b)`, so a frame's CRC covers its header and its body without a copy.
4
+ */
2
5
 
3
6
  const TABLE: Uint32Array = (() => {
4
7
  const t = new Uint32Array(256);
@@ -10,8 +13,9 @@ const TABLE: Uint32Array = (() => {
10
13
  return t;
11
14
  })();
12
15
 
13
- export function crc32(data: Uint8Array): number {
14
- let c = 0xffffffff;
16
+ /** The CRC-32 of `data`, continuing from `previous` (the CRC of what came before; 0 to start). */
17
+ export function crc32(data: Uint8Array, previous = 0): number {
18
+ let c = (previous ^ 0xffffffff) >>> 0;
15
19
  for (let i = 0; i < data.length; i++) c = TABLE[(c ^ data[i]!) & 0xff]! ^ (c >>> 8);
16
20
  return (c ^ 0xffffffff) >>> 0;
17
21
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * knowledge/pack/decode.ts — `decodePack` (PRD 41 A11). Guards run before any row is built: the
3
- * magic and version, the CRC-32 of the decoded body, the inflate cap (`PackTooLargeError` past
3
+ * magic and version, the CRC-32 of the header and the decoded body, the inflate cap (`PackTooLargeError` past
4
4
  * `maxDecodedBytes`) and the string/row counts. A malformed pack is a `PackFormatError`.
5
5
  */
6
6
 
@@ -9,7 +9,7 @@ import { inflateRaw } from './deflate.js';
9
9
  import { FLAG_DEFLATED, readFrame, readSections } from './frame.js';
10
10
  import { ROW_SECTIONS, TAG } from './sections/index.js';
11
11
  import { readHashTable, readStringTable, readTables } from './strings.js';
12
- import { DEFAULT_PACK_LIMITS, PackTooLargeError, type Pack, type PackLimits } from './types.js';
12
+ import { DEFAULT_PACK_LIMITS, PackTooLargeError, type Pack, type PackLimits, type ReadLimits } from './types.js';
13
13
  import { PackFormatError } from './varint.js';
14
14
 
15
15
  const NONE = new Uint8Array([0]);
@@ -21,8 +21,10 @@ export function peekPack(bytes: Uint8Array): { rootId: string; baseGeneration: n
21
21
  }
22
22
 
23
23
  export async function decodePack(bytes: Uint8Array, limits: Partial<PackLimits> = {}): Promise<Pack> {
24
- const lim: PackLimits = { ...DEFAULT_PACK_LIMITS, ...limits };
25
- const { header, stored, crc } = readFrame(bytes);
24
+ const base0: PackLimits = { ...DEFAULT_PACK_LIMITS, ...limits };
25
+ // ONE row budget for the whole pack: every list of every section draws from it.
26
+ const lim: ReadLimits = { ...base0, budget: { left: base0.maxRows } };
27
+ const { header, headerBytes, stored, crc } = readFrame(bytes);
26
28
  let body: Uint8Array;
27
29
  if (header.flags & FLAG_DEFLATED) {
28
30
  try {
@@ -35,10 +37,10 @@ export async function decodePack(bytes: Uint8Array, limits: Partial<PackLimits>
35
37
  if (stored.length > lim.maxDecodedBytes) throw new PackTooLargeError(lim.maxDecodedBytes);
36
38
  body = stored;
37
39
  }
38
- if (crc32(body) !== crc) throw new PackFormatError('CRC-32 mismatch');
40
+ if (crc32(body, crc32(headerBytes)) !== crc) throw new PackFormatError('CRC-32 mismatch');
39
41
  try {
40
42
  const sections = readSections(body);
41
- const strings = readStringTable(sections.get(TAG.STR) ?? NONE, lim.maxStrings);
43
+ const strings = readStringTable(sections.get(TAG.STR) ?? NONE, lim.maxStrings, lim.maxDecodedBytes);
42
44
  const hashes = readHashTable(sections.get(TAG.HASH) ?? NONE, lim.maxStrings);
43
45
  const used = new Set<string>();
44
46
  const base = readTables(strings, hashes);
@@ -5,6 +5,11 @@
5
5
  * is written from the same normalized pack, so equal input (in any row order) gives equal bytes.
6
6
  * Two passes over the section writers: the first collects every string and hash they use, the
7
7
  * second writes real table indexes.
8
+ *
9
+ * NORMALISATION (lossless for every value the model produces, documented where it is not): rows are sorted and
10
+ * empty parts dropped; object keys of badges and of the analysis document are written in sorted order; a
11
+ * negative zero is written as zero; a string holding a lone UTF-16 surrogate is written with U+FFFD in its place
12
+ * (UTF-8 cannot carry it). Equal normalised input gives equal bytes.
8
13
  */
9
14
 
10
15
  import { deflateRaw } from './deflate.js';
@@ -56,6 +61,8 @@ export function normalizePack(pack: Pack): Pack {
56
61
  export interface EncodeOptions {
57
62
  /** Deflate the body (default true). Off, the bytes are the plain columnar form (tests, size comparisons). */
58
63
  deflate?: boolean;
64
+ /** Filled with the size of the DECODED body: a client cuts a pack by it before the server's cap refuses it. */
65
+ stats?: { decodedBytes: number };
59
66
  }
60
67
 
61
68
  export async function encodePack(input: Pack, opts: EncodeOptions = {}): Promise<Uint8Array> {
@@ -72,6 +79,7 @@ export async function encodePack(input: Pack, opts: EncodeOptions = {}): Promise
72
79
  if (bytes) writeSection(body, s.tag, bytes);
73
80
  }
74
81
  const plain = body.finish();
82
+ if (opts.stats) opts.stats.decodedBytes = plain.length;
75
83
  const deflate = opts.deflate ?? true;
76
84
  return writeFrame(
77
85
  { flags: deflate ? FLAG_DEFLATED : 0, rootId: pack.rootId, baseGeneration: pack.baseGeneration, targetDigest: pack.targetDigest },
Binary file