@seanhogg/builderforce-memory 2026.10.79 → 2026.10.81

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 (80) hide show
  1. package/dist/knowledge/build.d.ts.map +1 -1
  2. package/dist/knowledge/build.js +45 -5
  3. package/dist/knowledge/build.js.map +1 -1
  4. package/dist/knowledge/cooperative.d.ts +51 -0
  5. package/dist/knowledge/cooperative.d.ts.map +1 -0
  6. package/dist/knowledge/cooperative.js +58 -0
  7. package/dist/knowledge/cooperative.js.map +1 -0
  8. package/dist/knowledge/findings.d.ts +7 -1
  9. package/dist/knowledge/findings.d.ts.map +1 -1
  10. package/dist/knowledge/findings.js +39 -14
  11. package/dist/knowledge/findings.js.map +1 -1
  12. package/dist/knowledge/ignoreMatcher.d.ts +25 -0
  13. package/dist/knowledge/ignoreMatcher.d.ts.map +1 -0
  14. package/dist/knowledge/ignoreMatcher.js +121 -0
  15. package/dist/knowledge/ignoreMatcher.js.map +1 -0
  16. package/dist/knowledge/index.d.ts +6 -2
  17. package/dist/knowledge/index.d.ts.map +1 -1
  18. package/dist/knowledge/index.js +4 -1
  19. package/dist/knowledge/index.js.map +1 -1
  20. package/dist/knowledge/model.d.ts +26 -0
  21. package/dist/knowledge/model.d.ts.map +1 -1
  22. package/dist/knowledge/plan.d.ts +6 -0
  23. package/dist/knowledge/plan.d.ts.map +1 -1
  24. package/dist/knowledge/plan.js +17 -1
  25. package/dist/knowledge/plan.js.map +1 -1
  26. package/dist/knowledge/reviewAnalyse.d.ts.map +1 -1
  27. package/dist/knowledge/reviewAnalyse.js +6 -1
  28. package/dist/knowledge/reviewAnalyse.js.map +1 -1
  29. package/dist/knowledge/reviewFinish.d.ts.map +1 -1
  30. package/dist/knowledge/reviewFinish.js +7 -1
  31. package/dist/knowledge/reviewFinish.js.map +1 -1
  32. package/dist/knowledge/reviewModel.d.ts +10 -0
  33. package/dist/knowledge/reviewModel.d.ts.map +1 -1
  34. package/dist/knowledge/rules/factStore.d.ts +11 -4
  35. package/dist/knowledge/rules/factStore.d.ts.map +1 -1
  36. package/dist/knowledge/rules/factStore.js +57 -25
  37. package/dist/knowledge/rules/factStore.js.map +1 -1
  38. package/dist/knowledge/rules/fixpointRules.d.ts +68 -0
  39. package/dist/knowledge/rules/fixpointRules.d.ts.map +1 -0
  40. package/dist/knowledge/rules/fixpointRules.js +0 -0
  41. package/dist/knowledge/rules/fixpointRules.js.map +1 -0
  42. package/dist/knowledge/sources.d.ts +9 -9
  43. package/dist/knowledge/sources.d.ts.map +1 -1
  44. package/dist/knowledge/sources.js +11 -50
  45. package/dist/knowledge/sources.js.map +1 -1
  46. package/dist/knowledge/statManifest.d.ts +89 -0
  47. package/dist/knowledge/statManifest.d.ts.map +1 -0
  48. package/dist/knowledge/statManifest.js +125 -0
  49. package/dist/knowledge/statManifest.js.map +1 -0
  50. package/dist/stats/estimators.d.ts +8 -1
  51. package/dist/stats/estimators.d.ts.map +1 -1
  52. package/dist/stats/estimators.js +18 -7
  53. package/dist/stats/estimators.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/contract/exports.snapshot.json +12 -0
  56. package/src/contract/regression.assets.test.ts +2 -2
  57. package/src/contract/regression.factStoreBatchedLoad.test.ts +62 -0
  58. package/src/contract/regression.factStoreFastPath.test.ts +116 -0
  59. package/src/contract/regression.findingsProvider.test.ts +80 -0
  60. package/src/contract/regression.ignoreMatcher.test.ts +116 -0
  61. package/src/contract/types.contract.test.ts +9 -1
  62. package/src/knowledge/build.ts +37 -5
  63. package/src/knowledge/cooperative.test.ts +57 -0
  64. package/src/knowledge/cooperative.ts +76 -0
  65. package/src/knowledge/docs.test.ts +30 -0
  66. package/src/knowledge/findings.ts +55 -14
  67. package/src/knowledge/ignoreMatcher.ts +143 -0
  68. package/src/knowledge/index.ts +9 -2
  69. package/src/knowledge/model.ts +24 -0
  70. package/src/knowledge/plan.ts +20 -1
  71. package/src/knowledge/reviewAnalyse.ts +6 -1
  72. package/src/knowledge/reviewFinish.ts +7 -1
  73. package/src/knowledge/reviewModel.ts +6 -0
  74. package/src/knowledge/rules/factStore.ts +59 -21
  75. package/src/knowledge/rules/fixpointRules.test.ts +94 -0
  76. package/src/knowledge/rules/fixpointRules.ts +0 -0
  77. package/src/knowledge/sources.ts +12 -46
  78. package/src/knowledge/statManifest.test.ts +122 -0
  79. package/src/knowledge/statManifest.ts +176 -0
  80. package/src/stats/estimators.ts +18 -7
@@ -11,7 +11,7 @@ export type {
11
11
  PartitionRule, PartitionRegistry, JudgementSpec, JudgementRequest, JudgedClaim, JudgedEntity, JudgementResult,
12
12
  JudgementPort, AnalyzerPort, AnalyzerProgress, KnowledgeParser, KnowledgePack, StoredFact, StoredRelation, Scope, ScopeRecord, MeasuredWith,
13
13
  KnowledgeStore, DirectorySource, LiveOverlay, KnowledgeGraph, ReviewPlan, ReviewProgress, ReviewReport,
14
- ReviewArgs, BuildGraphInput, BuildGraphOptions, TraceStep, Trace, GraphOutline, OutlineFile, OutlineCommunity,
14
+ ReviewArgs, BuildGraphInput, BuildGraphOptions, FindingsProvider, TraceStep, Trace, GraphOutline, OutlineFile, OutlineCommunity,
15
15
  GraphSystem, GraphApp, GraphReadSkip, CallSite,
16
16
  } from './model.js';
17
17
  export {
@@ -48,7 +48,7 @@ export {
48
48
  } from './trace.js';
49
49
  export type { LanedTrace, TraceOptions } from './trace.js';
50
50
  export {
51
- computeFindings, genericFindings, finding, findingId, partitionSeverity, requestKeyFor, components, CLONE_GROUP_BADGE, MAX_FINDING_NODES,
51
+ computeFindings, computeFindingsWith, genericFindings, finding, findingId, partitionSeverity, requestKeyFor, components, CLONE_GROUP_BADGE, MAX_FINDING_NODES,
52
52
  GENERIC_FINDING_RULES, KNOWLEDGE_FINDING_RULES,
53
53
  } from './findings.js';
54
54
  // PRD 41 §B1/§B3/§B5: FileFacts v3, the composite extractor version, FactRule + the incremental evaluator, the fact graph.
@@ -66,6 +66,8 @@ export { defineRule, DEFAULT_RULE_HOPS, MAX_RULE_HOPS } from './rules/factRule.j
66
66
  export type { FactRule, RuleInput, RuleScope } from './rules/factRule.js';
67
67
  export { evaluateRules, importNeighbours, derivedRowKey } from './rules/evaluateRules.js';
68
68
  export type { RuleWorld, DerivedRow, DerivedRows, RuleTraceEntry, RuleEvaluation } from './rules/evaluateRules.js';
69
+ export { evaluateRulesFixpoint, isRowSourceInput, MAX_FIXPOINT_ITERATIONS } from './rules/fixpointRules.js';
70
+ export type { FixpointResult, RowSourceInput } from './rules/fixpointRules.js';
69
71
  export { emptyFactGraph, updateFactGraph, buildFactGraph, factGraphDump, FACT_GRAPH_DUMP_VERSION } from './rules/factGraph.js';
70
72
  export type { FactGraph, FactManifestEntry, FactChange, FactGraphOptions, FactGraphUpdate } from './rules/factGraph.js';
71
73
  export { knowledgeFacts, knowledgeInputHash, runKnowledgeRules, packOfRef, KNOWLEDGE_INPUT } from './rules/knowledgeInput.js';
@@ -107,6 +109,11 @@ export type { ExtractorState } from './owedFiles.js';
107
109
  export { contentHash, CONTENT_HASH_RULE, BASELINE_CONTENT_HASH_RULE, contentHashRuleOf } from './contentHash.js';
108
110
  export { merkleTree, changedPaths, canonicalListing } from './merkle.js';
109
111
  export type { MerkleTree, MerkleEntry, MerkleKind, ListingSkipReason } from './merkle.js';
112
+ // PRD 41 §B2 steps 1–2: the stat prefilter (size + mtimeNs + fileId, BigInt) with git's racy-file rule.
113
+ export {
114
+ RACY_WINDOW_MS, statManifestKey, statMatches, isRacy, prefilterStats, createStatPrefilter, loadStatManifest, saveStatManifest,
115
+ } from './statManifest.js';
116
+ export type { StatRecord, StatManifestEntry, PrefilterDecision } from './statManifest.js';
110
117
  export { normalizePath, isRootFilePath } from './refs.js';
111
118
  export { reviewDirectory, assertStoredBatch } from './review.js';
112
119
  export { orderForJudging } from './judgePriority.js';
@@ -13,6 +13,7 @@
13
13
  import type { SourceDocument, ParsedSection } from '../ingest/types.js';
14
14
  import type { IndexDoc, SimilarPair } from '../retrieval/knowledge-index/types.js';
15
15
  import type { Finding, FindingRule } from './findingModel.js';
16
+ import type { KnowledgeFacts } from './rules/knowledgeInput.js';
16
17
 
17
18
  /** The finding types live beside the rules (findingModel.ts); re-exported so one import serves. */
18
19
  export type { Finding, FindingRule } from './findingModel.js';
@@ -410,6 +411,29 @@ export interface BuildGraphOptions {
410
411
  /** Default 400; cap 2000. */
411
412
  maxNodes?: number;
412
413
  focus?: NodeRef[];
414
+ /**
415
+ * Replaces the built-in and pack findings of the kinds it owns with its own, computed over the WHOLE graph (before
416
+ * truncation). Absent ⇒ output identical to before. See {@link FindingsProvider}.
417
+ */
418
+ findings?: FindingsProvider;
419
+ }
420
+
421
+ /**
422
+ * A host's own source of findings for some kinds (e.g. the VS Code fact index serving incremental rule rows): `buildGraph`
423
+ * calls `findings` ONCE with the whole, untruncated graph (its `findings` still empty) and the knowledge-rule input built
424
+ * from it, and keeps the result only for `kinds`. Truncation then keeps those findings' nodes like any other finding's.
425
+ *
426
+ * Contract:
427
+ * - Ids: return findings built with `finding()` (findingBuilder.ts), so their ids match the built-in rules' ids for the
428
+ * same finding. An empty id still falls back to `findingId(kind, nodes)`, as for a pack finding.
429
+ * - Read-only: `graph` is the LIVE full graph `buildGraph` is assembling (and `knowledge` indexes it); never mutate either.
430
+ * - Errors: a provider that throws makes `buildGraph` throw. Pass a provider only once the host's index has synced;
431
+ * until then omit it, and the built-in findings stand.
432
+ */
433
+ export interface FindingsProvider {
434
+ /** The finding kinds the provider owns (a generic rule whose id is owned is not run). */
435
+ kinds: readonly string[];
436
+ findings(input: { graph: KnowledgeGraph; knowledge: KnowledgeFacts }): Finding[];
413
437
  }
414
438
 
415
439
  export interface TraceStep {
@@ -18,6 +18,7 @@ import {
18
18
  isAssetPath, isDocumentPath, manifestMap, resolveDocument, stubSource,
19
19
  } from './sources.js';
20
20
  import { compareStr, FALLBACK_PACK_ID, sortBy } from './refs.js';
21
+ import { cooperativeBudget } from './cooperative.js';
21
22
 
22
23
  /** ≈ bytes per judged section, for the estimate (the plan does not read changed files). */
23
24
  export const AVG_SECTION_BYTES = 1500;
@@ -94,6 +95,12 @@ export interface PlanDetail {
94
95
  carried: string[];
95
96
  /** The directory Merkle tree over `files` (PRD 41 §B2 step 4): `plan.merkleRoot` is its root. Optional so a hand-built detail stays valid. */
96
97
  merkle?: MerkleTree;
98
+ /**
99
+ * Bumped whenever the manifest or PlanDetail shape changes (PRD 41 §B8: a result built from a mixed generation is
100
+ * discarded). The plan digest (`ReviewReport.digest`) includes it, so a shape change moves every scope's digest and
101
+ * the two sides of a run delta never compare across a shape change.
102
+ */
103
+ planShapeVersion: number;
97
104
  }
98
105
 
99
106
  /** The ONE classification of a listed file: did its content move, is it owed, is it re-processed. */
@@ -119,11 +126,17 @@ export async function planDetail(
119
126
  opts: PlanOptions = {},
120
127
  ): Promise<PlanDetail> {
121
128
  const maxBytes = opts.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES;
129
+ // A host may plan on its UI thread over tens of thousands of files: every long loop hands the event loop back (cooperative.ts).
130
+ const budget = cooperativeBudget();
122
131
  const listed: Array<{ path: string; hash: string; size: number }> = [];
123
- for await (const entry of source.list()) listed.push(entry);
132
+ for await (const entry of source.list()) {
133
+ listed.push(entry);
134
+ if (budget.due()) await budget.pause();
135
+ }
124
136
  // The ONE normalization (POSIX, NFC) — so plan paths are Merkle paths — and a listing that cannot break the plan: invalid and
125
137
  // colliding paths are skipped with a reason (merkle.ts canonicalListing), never thrown.
126
138
  const listing = canonicalListing(listed);
139
+ if (budget.due()) await budget.pause();
127
140
  const entries = sortBy(listing.kept, (e) => e.path);
128
141
  const listedOf = new Map(entries.filter((e) => e.listedPath !== undefined).map((e) => [e.path, e.listedPath!] as const));
129
142
 
@@ -153,6 +166,7 @@ export async function planDetail(
153
166
  let estimatedSections = 0;
154
167
  let compareSections = 0;
155
168
  for (const e of entries) {
169
+ if (budget.due()) await budget.pause();
156
170
  if (ignored(e.path)) { skipped.push({ path: e.path, reason: 'ignored' }); continue; }
157
171
  const document = isDocumentPath(e.path) ? resolveDocument(composed, e.path) : undefined;
158
172
  // An asset is never read, so the size cap does not apply: it is planned, hashed and diffed, and costs no model call.
@@ -196,7 +210,9 @@ export async function planDetail(
196
210
  const awaiting = compares ? (await manifestMap(manifest, compareManifestKey(source.rootId))).size : 0;
197
211
  const compareCalls = compares ? Math.ceil((compareSections + awaiting) / SECTIONS_PER_COMPARE) : 0;
198
212
  const sortedByPack = Object.fromEntries(Object.keys(byPack).sort(compareStr).map((k) => [k, byPack[k]!]));
213
+ if (budget.due()) await budget.pause();
199
214
  const merkle = merkleTree(files);
215
+ const planShapeVersion = 2; // 2 (2026-11-14, PRD 41 B2): the plan gained the stat-manifest identity; bump on any PlanDetail/manifest-shape change
200
216
  return {
201
217
  plan: {
202
218
  rootId: source.rootId,
@@ -215,6 +231,7 @@ export async function planDetail(
215
231
  extractor,
216
232
  carried: carriedOwed(extractor, prior, files.map((f) => f.path)),
217
233
  merkle,
234
+ planShapeVersion,
218
235
  };
219
236
  }
220
237
 
@@ -244,5 +261,7 @@ export async function refreshPlan(detail: PlanDetail, manifest: IngestManifest,
244
261
  extractor,
245
262
  carried: carriedOwed(extractor, prior, files.map((f) => f.path)),
246
263
  ...(detail.merkle ? { merkle: detail.merkle } : {}),
264
+ // *Continue* is the same manifest generation: the shape of what it continues is the shape it had.
265
+ planShapeVersion: detail.planShapeVersion,
247
266
  };
248
267
  }
@@ -38,7 +38,12 @@ export async function runAnalyzers(c: ReviewContext): Promise<void> {
38
38
  try {
39
39
  return await p.analyzers!.analyse(c.rootId, signal, onProgress);
40
40
  } catch (error) {
41
- c.report.failures.push({ kind: 'analyzer', path: analyzerFailurePath(p.id), phase: 'analyse', reason: reasonOf(error) });
41
+ // Never silent, never zero-findings: the run records the failure AND flags the pack's analysis as not
42
+ // measured, so the compare marks its findings `not_comparable` (`analyzer-failed:<id>`) instead of
43
+ // presenting a missing run as a fix (PRD 41 §8 Part B, §C9).
44
+ const reason = reasonOf(error);
45
+ c.report.failures.push({ kind: 'analyzer', path: analyzerFailurePath(p.id), phase: 'analyse', reason });
46
+ (c.report.analyzerStatus ??= []).push({ id: p.id, status: 'failed', reason });
42
47
  return [];
43
48
  } finally { settled = true; }
44
49
  }),
@@ -47,7 +47,13 @@ export async function finishReview(c: ReviewContext, flush: () => Promise<void>)
47
47
  report.judged = c.batch.judged;
48
48
  report.unjudged = c.batch.unjudged;
49
49
  report.invalidJudgements = c.batch.invalid;
50
- report.digest = sha256Hex(canonicalJson({ rootId: c.rootId, packs: c.packIds, files: [...c.filesNow].sort((a, b) => compareStr(a[0], b[0])) }));
50
+ // The digest covers the root, the packs, the files manifest AND the plan/manifest shape version (PRD 41 §B8.4): a shape
51
+ // change moves every scope's digest, so two sides of a run delta never compare across one.
52
+ report.digest = sha256Hex(canonicalJson({
53
+ rootId: c.rootId, packs: c.packIds,
54
+ files: [...c.filesNow].sort((a, b) => compareStr(a[0], b[0])),
55
+ planShapeVersion: c.detail.planShapeVersion ?? 1,
56
+ }));
51
57
  await saveManifestMap(manifest, filesManifestKey(c.rootId), c.filesNow);
52
58
  await saveManifestMap(manifest, judgedManifestKey(c.rootId), c.judgedNow);
53
59
  // After every run: today's version and every file still owed a re-extraction — the unfinished ones,
@@ -99,6 +99,12 @@ export interface ReviewReport {
99
99
  awaitingJudgeCount?: number;
100
100
  /** Pass 2 (`only`): files of the slice judged to completion. */
101
101
  judgedFiles?: number;
102
+ /**
103
+ * Analyzers that did not complete (PRD 41 §8, C9): status `'failed'` when it ran and errored, `'not_measured'` when it did
104
+ * not run at all. A failed analyzer is NEVER presented as zero findings — the compare marks that tool's findings
105
+ * `not_comparable` (reason `analyzer-failed:<tool>`) rather than resolving them.
106
+ */
107
+ analyzerStatus?: Array<{ id: string; status: 'failed' | 'not_measured'; reason?: string }>;
102
108
  /** Judging was stopped for this run after consecutive provider failures (A10 rule 9); the files stay owed. */
103
109
  judgeStopped?: string;
104
110
  aborted: boolean;
@@ -33,6 +33,7 @@
33
33
  */
34
34
 
35
35
  import { canonicalJson, compareStr } from '../refs.js';
36
+ import { cooperativeBudget, type CooperativeBudget } from '../cooperative.js';
36
37
  import { readFileFacts, type FileFacts } from '../facts/fileFacts.js';
37
38
  import { factKindHashes, factsHash, factsJson } from '../facts/factsHash.js';
38
39
  import { derivedRowKey, type DerivedRow } from './evaluateRules.js';
@@ -109,17 +110,41 @@ const conflict = (why: string) => new Error(`fact_store_generation_conflict:${wh
109
110
 
110
111
  /**
111
112
  * Persists `graph`, writing ONLY the delta against what the store holds: the objects of new or changed manifest entries,
112
- * the manifest entries that moved, the derived rows that moved and the keys that went away. Derived rows are diffed by
113
- * identity against `previous.graph` (a reused row is the same object) ONLY when `previous` is at the stored epoch and
114
- * generation; otherwise against the stored rows. Rejects `fact_store_generation_conflict` when another writer committed
115
- * in between (see the recovery contract in the header).
113
+ * the manifest entries that moved, the derived rows that moved and the keys that went away.
114
+ *
115
+ * FAST PATH: with `previous`, the save reads only the version (`readVersion`). When it is `previous`'s epoch and
116
+ * generation, the store holds exactly `previous.graph`, so the manifest and the derived rows are diffed against it in
117
+ * memory (a reused row is the same object) and neither `readManifest` nor `derivedRows` is called — O(changes), not
118
+ * O(files). Otherwise (no `previous`, or a stale one) the save diffs against the stored manifest and rows. Either way the
119
+ * commit is the version CAS of `writeManifest`, so a writer that lands in between makes this save reject
120
+ * `fact_store_generation_conflict` (see the recovery contract in the header).
121
+ *
122
+ * `previous` must be EXACTLY a result of `saveFactGraph` or `loadFactGraph` on this port — never hand-built or patched: the
123
+ * fast path trusts that its `graph` is what the store holds at its `{ epoch, generation }`.
116
124
  */
117
125
  export async function saveFactGraph(port: FactStorePort, graph: FactGraph, previous?: StoredFactGraph): Promise<FactStoreSaveResult> {
126
+ if (previous) {
127
+ const version = await port.readVersion();
128
+ if (sameVersion(previous, version)) return commitDelta(port, graph, version, previous.graph.manifest, previous.graph.derived);
129
+ }
118
130
  const stored = await port.readManifest();
131
+ return commitDelta(port, graph, stored, stored.files, await port.derivedRows());
132
+ }
119
133
 
134
+ /**
135
+ * Writes the delta of `graph` against `base` (the manifest and derived rows the store holds at `version`): objects first,
136
+ * then one `writeManifest`. A base row that is the same object as the graph's row is unchanged without serializing it.
137
+ */
138
+ async function commitDelta(
139
+ port: FactStorePort,
140
+ graph: FactGraph,
141
+ version: FactStoreVersion,
142
+ baseFiles: ReadonlyMap<string, FactManifestEntry>,
143
+ baseRows: ReadonlyMap<string, DerivedRow>,
144
+ ): Promise<FactStoreSaveResult> {
120
145
  const puts = new Map<string, FactManifestEntry>();
121
- for (const [path, e] of graph.manifest) if (!sameManifestEntry(e, stored.files.get(path))) puts.set(path, e);
122
- const deletes = [...stored.files.keys()].filter((p) => !graph.manifest.has(p)).sort(compareStr);
146
+ for (const [path, e] of graph.manifest) if (!sameManifestEntry(e, baseFiles.get(path))) puts.set(path, e);
147
+ const deletes = [...baseFiles.keys()].filter((p) => !graph.manifest.has(p)).sort(compareStr);
123
148
 
124
149
  const objects = [...new Set([...puts.values()].map((e) => e.factsHash))].sort(compareStr);
125
150
  if (objects.length > 0) {
@@ -133,25 +158,18 @@ export async function saveFactGraph(port: FactStorePort, graph: FactGraph, previ
133
158
  }
134
159
 
135
160
  const derivedPuts: DerivedRow[] = [];
136
- let derivedDeletes: string[];
137
- if (previous && sameVersion(previous, stored)) {
138
- for (const [key, row] of graph.derived) if (previous.graph.derived.get(key) !== row) derivedPuts.push(row);
139
- derivedDeletes = [...previous.graph.derived.keys()].filter((k) => !graph.derived.has(k));
140
- } else {
141
- const rows = await port.derivedRows();
142
- for (const [key, row] of graph.derived) {
143
- const prior = rows.get(key);
144
- if (!prior || rowJson(prior) !== rowJson(row)) derivedPuts.push(row);
145
- }
146
- derivedDeletes = [...rows.keys()].filter((k) => !graph.derived.has(k));
161
+ for (const [key, row] of graph.derived) {
162
+ const prior = baseRows.get(key);
163
+ if (prior !== row && (!prior || rowJson(prior) !== rowJson(row))) derivedPuts.push(row);
147
164
  }
165
+ const derivedDeletes = [...baseRows.keys()].filter((k) => !graph.derived.has(k));
148
166
  derivedPuts.sort((a, b) => compareStr(derivedRowKey(a.rule, a.focus), derivedRowKey(b.rule, b.focus)));
149
167
  derivedDeletes.sort(compareStr);
150
168
 
151
- const generation = stored.generation + 1;
152
- await port.writeManifest({ epoch: stored.epoch, generation, puts, deletes }, derivedPuts, derivedDeletes);
169
+ const generation = version.generation + 1;
170
+ await port.writeManifest({ epoch: version.epoch, generation, puts, deletes }, derivedPuts, derivedDeletes);
153
171
  return {
154
- epoch: stored.epoch,
172
+ epoch: version.epoch,
155
173
  generation,
156
174
  graph,
157
175
  objects,
@@ -174,11 +192,30 @@ export interface LoadFactGraphOptions {
174
192
  /** How many times a load retries when a write lands under it before rejecting `fact_store_generation_conflict:load`. */
175
193
  export const FACT_STORE_LOAD_ATTEMPTS = 3;
176
194
 
195
+ /**
196
+ * How many hashes one `getObjects` call asks for during a load. A port may serve a call synchronously (the SQLite adapter
197
+ * reads it in one transaction on the caller's thread), so a load asks in bounded batches and yields between them.
198
+ */
199
+ const LOAD_OBJECTS_BATCH = 512;
200
+
201
+ /** Every object of `hashes` the port holds, read in {@link LOAD_OBJECTS_BATCH}-sized calls with a yield between them. */
202
+ async function getObjectsBatched(port: FactStorePort, hashes: readonly string[], budget: CooperativeBudget): Promise<Map<string, string>> {
203
+ const raw = new Map<string, string>();
204
+ for (let i = 0; i < hashes.length; i += LOAD_OBJECTS_BATCH) {
205
+ if (i > 0 && budget.due()) await budget.pause();
206
+ for (const [hash, json] of await port.getObjects(hashes.slice(i, i + LOAD_OBJECTS_BATCH))) raw.set(hash, json);
207
+ }
208
+ return raw;
209
+ }
210
+
177
211
  async function loadOnce(port: FactStorePort, stored: FactStoreManifest, verify: 'full' | 'manifest'): Promise<FactGraph> {
212
+ // A host may load on its UI thread: parsing and hashing every object hands the event loop back (cooperative.ts).
213
+ const budget = cooperativeBudget();
178
214
  const hashes = [...new Set([...stored.files.values()].map((e) => e.factsHash))].sort(compareStr);
179
- const raw = await port.getObjects(hashes);
215
+ const raw = await getObjectsBatched(port, hashes, budget);
180
216
  const objects = new Map<string, FileFacts>();
181
217
  for (const hash of hashes) {
218
+ if (budget.due()) await budget.pause();
182
219
  const json = raw.get(hash);
183
220
  if (json === undefined) throw new Error(`fact_store_object_missing:${hash}`);
184
221
  let facts: FileFacts;
@@ -192,6 +229,7 @@ async function loadOnce(port: FactStorePort, stored: FactStoreManifest, verify:
192
229
  }
193
230
  const manifest = new Map<string, FactManifestEntry>();
194
231
  for (const path of [...stored.files.keys()].sort(compareStr)) {
232
+ if (budget.due()) await budget.pause();
195
233
  const e = stored.files.get(path)!;
196
234
  const facts = objects.get(e.factsHash)!;
197
235
  const entry: FactManifestEntry = { contentHash: facts.contentHash, factsHash: e.factsHash, kinds: factKindHashes(facts) };
@@ -0,0 +1,94 @@
1
+ /**
2
+ * src/knowledge/rules/fixpointRules.test.ts — the stratified fixed-point evaluator (PRD 41 §B5):
3
+ * strata from the declared derived-row edges, order-independent results, bounded iterations,
4
+ * a fixed point that reuses every row on the final pass, and rejection of recursive rules.
5
+ */
6
+
7
+ import type { FileFacts } from '../facts/fileFacts.js';
8
+ import { derivedRowKey } from './evaluateRules.js';
9
+ import { defineRule } from './factRule.js';
10
+ import { evaluateRulesFixpoint, MAX_FIXPOINT_ITERATIONS, type SourcedRule } from './fixpointRules.js';
11
+ import { emptyFacts, FIXTURE_RULES } from './rules.testkit.test-util.js';
12
+
13
+ const files = (): Map<string, FileFacts> => new Map([
14
+ ['a.ts', { ...emptyFacts('ha'), calls: [{ callee: 'db.get', enclosing: 'a', awaited: true, inLoop: true, count: 3 }] }],
15
+ ['b.ts', { ...emptyFacts('hb'), calls: [{ callee: 'fs.read', enclosing: 'b', awaited: false, inLoop: true, count: 5 }] }],
16
+ ]);
17
+
18
+ /** A global rule whose `seen` input is the io-in-loop rule's row for focus '' (its global row). */
19
+ const ioTotal = defineRule<{ seen?: { findings: unknown[] } }>({
20
+ id: 'io-total', version: 1, reads: ['body'], scope: 'global', extraInputs: ['seen'],
21
+ derive: ({ files: fs, extra }) => {
22
+ const own = [...fs.values()].reduce((s, x) => s + x.calls.filter((c) => c.inLoop && c.awaited).length, 0);
23
+ const upstream = (extra.seen?.findings ?? []).length;
24
+ return upstream + own > 0
25
+ ? [{ id: `io-total:${own + upstream}`, kind: 'io-total', pack: 'fixture', nodes: [], severity: 'info', params: { total: own + upstream } }]
26
+ : [];
27
+ },
28
+ });
29
+
30
+ const ioTotalSourced: SourcedRule<{ seen?: { findings: unknown[] } }> = {
31
+ rule: ioTotal,
32
+ rowSources: { seen: { rowKey: derivedRowKey('io-in-loop', '') } },
33
+ };
34
+
35
+ const plain = FIXTURE_RULES.map((rule) => ({ rule }));
36
+
37
+ describe('evaluateRulesFixpoint: stratified semi-naive fixed point', () => {
38
+ it('places row-reading rules above their producers and reaches a fixed point', () => {
39
+ const r = evaluateRulesFixpoint([...plain, ioTotalSourced], { files: files() });
40
+ // Strata: every FIXTURE_RULE (no row sources) at 0; io-total (reads io-in-loop's row) at 1.
41
+ expect(r.strata).toHaveLength(2);
42
+ expect(r.strata[1]).toEqual(['io-total']);
43
+ // a.ts has 1 awaited io-in-loop call; the global row feeds io-total.
44
+ expect(r.evaluation.findings.map((x) => x.id)).toContain('io-total:1');
45
+ // The fixed point is audited: at least one iteration per stratum; the final pass reused rows.
46
+ expect(r.iterations).toHaveLength(2);
47
+ expect(r.iterations.every((n) => n >= 1)).toBe(true);
48
+ });
49
+
50
+ it('is order-independent: registration order never changes the rows or strata', () => {
51
+ const a = evaluateRulesFixpoint([...plain, ioTotalSourced].reverse(), { files: files() });
52
+ const b = evaluateRulesFixpoint([...plain, ioTotalSourced], { files: files() });
53
+ expect([...a.evaluation.rows.keys()].sort()).toEqual([...b.evaluation.rows.keys()].sort());
54
+ expect(a.evaluation.findings.map((x) => x.id).sort()).toEqual(b.evaluation.findings.map((x) => x.id).sort());
55
+ expect(a.strata).toEqual(b.strata);
56
+ expect(a.iterations).toEqual(b.iterations);
57
+ });
58
+
59
+ it('reuses every row on a no-change rerun (early cutoff holds across the fixpoint)', () => {
60
+ const first = evaluateRulesFixpoint([...plain, ioTotalSourced], { files: files() });
61
+ const second = evaluateRulesFixpoint([...plain, ioTotalSourced], { files: files() }, first.evaluation.rows);
62
+ expect(second.evaluation.trace.filter((t) => t.outcome === 'ran')).toEqual([]);
63
+ expect(second.evaluation.findings.map((x) => x.id).sort()).toEqual(first.evaluation.findings.map((x) => x.id).sort());
64
+ expect(second.iterations.every((n) => n === 1)).toBe(true);
65
+ });
66
+
67
+ it('rejects a recursive derived-row cycle as unstratifiable', () => {
68
+ const cycA = defineRule<{ b?: unknown }>({ id: 'cyc-a', version: 1, reads: [], scope: 'global', extraInputs: ['b'], derive: () => [] });
69
+ const cycB = defineRule<{ a?: unknown }>({ id: 'cyc-b', version: 1, reads: [], scope: 'global', extraInputs: ['a'], derive: () => [] });
70
+ const a: SourcedRule<{ b?: unknown }> = { rule: cycA, rowSources: { b: { rowKey: derivedRowKey('cyc-b', '') } } };
71
+ const b: SourcedRule<{ a?: unknown }> = { rule: cycB, rowSources: { a: { rowKey: derivedRowKey('cyc-a', '') } } };
72
+ expect(() => evaluateRulesFixpoint([a, b], { files: new Map() })).toThrow(/fact_rule_unstratifiable/);
73
+ });
74
+
75
+ it('rejects a self-reading rule as unstratifiable and never runs it', () => {
76
+ let calls = 0;
77
+ const noisy = defineRule<{ self?: { findings: unknown[] } }>({
78
+ id: 'noisy', version: 1, reads: [], scope: 'global', extraInputs: ['self'],
79
+ derive: () => { calls += 1; return []; },
80
+ });
81
+ const self: SourcedRule<{ self?: { findings: unknown[] } }> = { rule: noisy, rowSources: { self: { rowKey: derivedRowKey('noisy', '') } } };
82
+ expect(() => evaluateRulesFixpoint([self], { files: new Map() })).toThrow(/fact_rule_unstratifiable/);
83
+ expect(calls).toBe(0);
84
+ expect(MAX_FIXPOINT_ITERATIONS).toBeGreaterThan(0);
85
+ });
86
+
87
+ it('a stratum stabilizes after one pass when its row-source inputs never change', () => {
88
+ // io-total reads io-in-loop's row; io-in-loop is in stratum 0 and its inputs are static,
89
+ // so stratum 1 converges on its second pass (first computes, second reuses) or first reuse.
90
+ const r = evaluateRulesFixpoint([...plain, ioTotalSourced], { files: files() });
91
+ // Stratum 0 (7 rules) iterates until reuse; stratum 1 (io-total) needs at most 2 iterations.
92
+ expect(r.iterations[1]).toBeLessThanOrEqual(2);
93
+ });
94
+ });
@@ -8,7 +8,6 @@ import { htmlParser, markdownParser, ParserRegistry, plainTextParser } from '../
8
8
  import { isBinaryDocumentType, mediaTypeOf } from '../ingest/parserSupport.js';
9
9
  import { CONTENT_HASH_FIELD, type ChunkFingerprint, type IngestManifest, type SourceDocument } from '../ingest/types.js';
10
10
  import type { Extracted, KnowledgePack, KnowledgeParser } from './model.js';
11
- import { matchGlob } from './partitions.js';
12
11
  import { compareStr, walkRelative } from './refs.js';
13
12
 
14
13
  /** Default per-file size cap (bytes). */
@@ -24,7 +23,9 @@ export const DEFAULT_MAX_FILE_BYTES = 2 * 1024 * 1024;
24
23
  // 5 (2026-11-10, PRD 43 P0b): the code pack's file nodes carry the file→file rollup of the symbol-level edge kinds.
25
24
  // 6 (2026-11-10, PRD 43 P0c): the agent-tools code pack resolves tsconfig path aliases, names callback-owner symbols,
26
25
  // emits `new X().m()` call edges and reads JSX renders as calls, so cached code extracts re-run.
27
- export const EXTRACTOR_VERSION = 6;
26
+ // 7 (2026-11-10, PRD 43): the code pack extracts deploy descriptors (Dockerfile, wrangler, compose, k8s, workflows, package.json)
27
+ // as deployable units and adds a per-file `concurrency` badge.
28
+ export const EXTRACTOR_VERSION = 7;
28
29
 
29
30
  /**
30
31
  * THE test of "this extract (or this root's extractor entry) was made by today's extractor": today's
@@ -41,13 +42,6 @@ export function isCurrentExtractor(recorded: { version: number | undefined; key:
41
42
  export function sameExtractorKey(a: string | undefined, b: string | undefined): boolean {
42
43
  return (a || undefined) === (b || undefined);
43
44
  }
44
- /**
45
- * Always ignored: VCS internals, installed dependencies, builderforce config, and lockfiles (`yarn.lock`, `Cargo.lock` …): generated,
46
- * huge, and plain text — extracted they would cost judgement calls for nothing; they were never stored (once skipped as binary).
47
- * A `.builderforce/ignore` rule can still re-include one (`!yarn.lock`).
48
- */
49
- const DEFAULT_IGNORES = ['.git/', 'node_modules/', '.builderforce/', '.gitignore', '*.lock'];
50
-
51
45
  const MEDIA_TYPES: Record<string, string> = {
52
46
  md: 'text/markdown', markdown: 'text/markdown', mdx: 'text/markdown',
53
47
  html: 'text/html', htm: 'text/html', xhtml: 'application/xhtml+xml', xml: 'application/xml',
@@ -78,6 +72,13 @@ const MEDIA_TYPES: Record<string, string> = {
78
72
  /** Binary documents whose text a HOST extractor may supply (§4.5); otherwise stored as an asset (never read). */
79
73
  const DOCUMENT_EXT = new Set(['pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp']);
80
74
 
75
+ /**
76
+ * A markdown/html/text link target with no extension may name a sibling document (`troubleshooting` →
77
+ * `troubleshooting.md`). The set of extensions a target may resolve to — the docs pack's broken-link rule
78
+ * only judges targets that match these, so a target it would never flag is not resolved here either.
79
+ */
80
+ export const LINKABLE_DOC_EXT = ['md', 'markdown', 'mdx', 'html', 'htm', 'txt', 'rst', 'adoc'];
81
+
81
82
  const BINARY_EXT = new Set([
82
83
  'png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'ico', 'icns', 'tif', 'tiff', 'psd', 'avif', 'heic',
83
84
  'mp3', 'mp4', 'mov', 'avi', 'mkv', 'webm', 'wav', 'flac', 'ogg', 'm4a',
@@ -217,43 +218,8 @@ export function composePacks(packs: readonly KnowledgePack[]): ComposedPacks {
217
218
  };
218
219
  }
219
220
 
220
- /**
221
- * A `.gitignore`-style matcher: `#` comments, `!` negation (last match wins), a trailing
222
- * `/` for directories only, a `/` elsewhere anchors to the root, otherwise any depth.
223
- */
224
- export function ignoreMatcher(texts: ReadonlyArray<string | { text: string; base: string }>): (path: string) => boolean {
225
- const rules: Array<{ glob: string; negate: boolean; dirOnly: boolean }> = [];
226
- const lines = [
227
- ...DEFAULT_IGNORES.map((line) => ({ line, base: '' })),
228
- ...texts.flatMap((t) => {
229
- const { text, base } = typeof t === 'string' ? { text: t, base: '' } : t;
230
- return text.split(/\r?\n/).map((line) => ({ line, base }));
231
- }),
232
- ];
233
- for (const { line, base } of lines) {
234
- let p = line.replace(/\s+$/, '');
235
- if (!p || p.startsWith('#')) continue;
236
- const negate = p.startsWith('!');
237
- if (negate) p = p.slice(1);
238
- const dirOnly = p.endsWith('/');
239
- if (dirOnly) p = p.slice(0, -1);
240
- const anchored = p.includes('/');
241
- p = p.replace(/^\//, '');
242
- // A nested `.gitignore` scopes its patterns to its own folder.
243
- const prefix = base ? `${base}/` : '';
244
- if (p) rules.push({ glob: anchored ? `${prefix}${p}` : `${prefix}**/${p}`, negate, dirOnly });
245
- }
246
- return (path) => {
247
- const segments = path.split('/');
248
- const dirs = segments.slice(0, -1).map((_, i) => segments.slice(0, i + 1).join('/'));
249
- let ignored = false;
250
- for (const r of rules) {
251
- const hit = (r.dirOnly ? dirs : [...dirs, path]).some((c) => matchGlob(c, r.glob));
252
- if (hit) ignored = !r.negate;
253
- }
254
- return ignored;
255
- };
256
- }
221
+ /** The `.gitignore`-style matcher lives in its own module (ignoreMatcher.ts); re-exported here, where callers import it. */
222
+ export { ignoreMatcher } from './ignoreMatcher.js';
257
223
 
258
224
  /**
259
225
  * The ignore files present in a listing, each with the folder its patterns are relative to,
@@ -0,0 +1,122 @@
1
+ /**
2
+ * src/knowledge/statManifest.test.ts — the stat prefilter (PRD 41 §B2 steps 1–2): a size+mtimeNs+fileId
3
+ * manifest lets a warm plan reuse a stored hash without reading the file, and git's racy-file rule
4
+ * re-hashes a file whose mtime is within 2 s of the manifest write or of now.
5
+ */
6
+
7
+ import { jest } from '@jest/globals';
8
+ import {
9
+ createStatPrefilter, isRacy, loadStatManifest, prefilterStats, RACY_WINDOW_MS, saveStatManifest, statMatches,
10
+ type StatManifestEntry, type StatRecord,
11
+ } from './statManifest.js';
12
+ import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
13
+
14
+ const stat = (size: number, mtimeNs: bigint, fileId: bigint | null = null): StatRecord => ({ size, mtimeNs, fileId });
15
+ const entry = (size: number, mtimeNs: bigint, hash: string, recordedAtMs: number, fileId: bigint | null = null): StatManifestEntry =>
16
+ ({ size, mtimeNs, fileId, hash, recordedAtMs });
17
+
18
+ const NOW = 1_000_000;
19
+ // An mtime far from both `recordedAtMs` and NOW so the racy rule does not fire unless a test moves it.
20
+ const OLD_MTIME = BigInt((NOW - 60_000) * 1_000_000);
21
+
22
+ describe('statMatches', () => {
23
+ it('requires size, full-precision mtimeNs and fileId', () => {
24
+ expect(statMatches(stat(10, OLD_MTIME, 5n), stat(10, OLD_MTIME, 5n))).toBe(true);
25
+ expect(statMatches(stat(10, OLD_MTIME, 5n), stat(11, OLD_MTIME, 5n))).toBe(false); // size moved
26
+ expect(statMatches(stat(10, OLD_MTIME, 5n), stat(10, OLD_MTIME + 1n, 5n))).toBe(false); // ns mtime moved
27
+ expect(statMatches(stat(10, OLD_MTIME, 5n), stat(10, OLD_MTIME, 6n))).toBe(false); // fileId moved
28
+ expect(statMatches(stat(10, OLD_MTIME, null), stat(10, OLD_MTIME, 6n))).toBe(false); // null matches only null
29
+ expect(statMatches(stat(10, OLD_MTIME, null), stat(10, OLD_MTIME, null))).toBe(true);
30
+ });
31
+ });
32
+
33
+ describe('isRacy (git racy-file rule, §B2 step 2)', () => {
34
+ it('is racy within 2 s of the manifest write time', () => {
35
+ expect(isRacy(stat(1, BigInt((NOW - RACY_WINDOW_MS + 1) * 1_000_000)), NOW, NOW)).toBe(true);
36
+ expect(isRacy(stat(1, BigInt((NOW + RACY_WINDOW_MS - 1) * 1_000_000)), NOW, NOW)).toBe(true);
37
+ expect(isRacy(stat(1, BigInt((NOW - RACY_WINDOW_MS - 1) * 1_000_000)), NOW, NOW)).toBe(false);
38
+ });
39
+ it('is racy within 2 s of now, whatever the manifest says', () => {
40
+ expect(isRacy(stat(1, BigInt(NOW * 1_000_000)), NOW - 60_000, NOW)).toBe(true);
41
+ expect(isRacy(stat(1, BigInt((NOW - 10_000) * 1_000_000)), NOW - 60_000, NOW)).toBe(false);
42
+ });
43
+ });
44
+
45
+ describe('prefilterStats', () => {
46
+ const prior = new Map<string, StatManifestEntry>([
47
+ ['a.ts', entry(10, OLD_MTIME, 'h-a', NOW)],
48
+ ['b.ts', entry(20, OLD_MTIME, 'h-b', NOW)],
49
+ ['c.ts', entry(30, OLD_MTIME, 'h-c', NOW)],
50
+ ]);
51
+
52
+ it('reuses the stored hash on a stat match and hashes everything else, both sorted', () => {
53
+ const decision = prefilterStats(
54
+ [
55
+ { path: 'c.ts', stat: stat(30, OLD_MTIME) },
56
+ { path: 'a.ts', stat: stat(10, OLD_MTIME) },
57
+ { path: 'b.ts', stat: stat(21, OLD_MTIME) }, // size moved → hash
58
+ { path: 'd.ts', stat: stat(40, OLD_MTIME) }, // new → hash
59
+ ],
60
+ prior, NOW,
61
+ );
62
+ expect(decision.reused).toEqual(['a.ts', 'c.ts']);
63
+ expect(decision.hash).toEqual(['b.ts', 'd.ts']);
64
+ });
65
+
66
+ it('re-hashes a racy file whatever its stat says', () => {
67
+ const racyMtime = BigInt(NOW * 1_000_000); // within 2 s of now
68
+ const decision = prefilterStats([{ path: 'a.ts', stat: stat(10, racyMtime) }], prior, NOW);
69
+ expect(decision.reused).toEqual([]);
70
+ expect(decision.hash).toEqual(['a.ts']);
71
+ });
72
+
73
+ it('is deterministic: input order never changes the output', () => {
74
+ const listed = [
75
+ { path: 'a.ts', stat: stat(10, OLD_MTIME) },
76
+ { path: 'b.ts', stat: stat(20, OLD_MTIME) },
77
+ { path: 'c.ts', stat: stat(30, OLD_MTIME) },
78
+ ];
79
+ expect(prefilterStats([...listed].reverse(), prior, NOW)).toEqual(prefilterStats(listed, prior, NOW));
80
+ });
81
+ });
82
+
83
+ describe('createStatPrefilter', () => {
84
+ it('returns the stored hash without reading, and hashes a moved file through hashPath', async () => {
85
+ const prior = new Map<string, StatManifestEntry>([['a.ts', entry(10, OLD_MTIME, 'h-a', NOW)]]);
86
+ const hashPath = jest.fn(async (_: string) => 'h-fresh');
87
+ const prefilter = createStatPrefilter(prior, hashPath, () => NOW);
88
+
89
+ await expect(prefilter({ path: 'a.ts', stat: stat(10, OLD_MTIME) })).resolves.toEqual({ path: 'a.ts', hash: 'h-a' });
90
+ expect(hashPath).not.toHaveBeenCalled();
91
+
92
+ await expect(prefilter({ path: 'a.ts', stat: stat(11, OLD_MTIME) })).resolves.toEqual({ path: 'a.ts', hash: 'h-fresh' });
93
+ expect(hashPath).toHaveBeenCalledTimes(1);
94
+ expect(hashPath).toHaveBeenCalledWith('a.ts');
95
+ });
96
+ });
97
+
98
+ describe('stat manifest persistence', () => {
99
+ it('round-trips BigInt stat tuples through the ingest manifest and reloads them', async () => {
100
+ const manifest = new InMemoryIngestManifest();
101
+ const fileId = 12345678901234567890n; // exceeds a double: must survive as a BigInt
102
+ const mtimeNs = 1700000000123456789n;
103
+ const files = [
104
+ { path: 'src/x.ts', hash: 'h-x', stat: stat(100, mtimeNs, fileId) },
105
+ { path: 'src/y.ts', hash: 'h-y', stat: stat(200, OLD_MTIME, null) },
106
+ ];
107
+ await saveStatManifest(manifest, 'root', files, NOW);
108
+ const loaded = await loadStatManifest(manifest, 'root');
109
+ expect(loaded.size).toBe(2);
110
+ expect(loaded.get('src/x.ts')).toEqual({ size: 100, mtimeNs, fileId, hash: 'h-x', recordedAtMs: NOW });
111
+ expect(loaded.get('src/y.ts')).toEqual({ size: 200, mtimeNs: OLD_MTIME, fileId: null, hash: 'h-y', recordedAtMs: NOW });
112
+ // A warm prefilter over the reloaded manifest reuses the stored hash.
113
+ expect(prefilterStats([{ path: 'src/x.ts', stat: stat(100, mtimeNs, fileId) }], loaded, NOW).reused).toEqual(['src/x.ts']);
114
+ });
115
+
116
+ it('returns empty on a missing manifest (the first run hashes everything) and on a corrupt one', async () => {
117
+ const manifest = new InMemoryIngestManifest();
118
+ expect((await loadStatManifest(manifest, 'root')).size).toBe(0);
119
+ await manifest.set('stats:root', [{ id: 'entries', hash: '{not json' }]);
120
+ expect((await loadStatManifest(manifest, 'root')).size).toBe(0);
121
+ });
122
+ });