@seanhogg/builderforce-memory 2026.10.31 → 2026.10.32
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.
- package/dist/agent/SSMAgent.d.ts.map +1 -1
- package/dist/agent/SSMAgent.js.map +1 -1
- package/dist/bridges/AnthropicBridge.d.ts.map +1 -1
- package/dist/bridges/AnthropicBridge.js.map +1 -1
- package/dist/bridges/CachingBridge.d.ts.map +1 -1
- package/dist/bridges/CachingBridge.js.map +1 -1
- package/dist/bridges/FetchBridge.d.ts.map +1 -1
- package/dist/bridges/OpenAIBridge.d.ts.map +1 -1
- package/dist/bridges/OpenAIBridge.js.map +1 -1
- package/dist/bridges/ResponseCache.d.ts.map +1 -1
- package/dist/bridges/ResponseCache.js.map +1 -1
- package/dist/bridges/SemanticCachingBridge.d.ts.map +1 -1
- package/dist/bridges/SemanticCachingBridge.js.map +1 -1
- package/dist/bridges/VertexAIBridge.d.ts.map +1 -1
- package/dist/bridges/VertexAIBridge.js.map +1 -1
- package/dist/cache/FetchSemanticCacheBackend.d.ts.map +1 -1
- package/dist/cache/SemanticCache.d.ts.map +1 -1
- package/dist/cognition/EvermindCognition.d.ts.map +1 -1
- package/dist/cognition/EvermindCognition.js.map +1 -1
- package/dist/diagnostics/stack-diagnostic.js.map +1 -1
- package/dist/distillation/DistillationEngine.d.ts.map +1 -1
- package/dist/distillation/DistillationEngine.js.map +1 -1
- package/dist/errors/SSMError.d.ts +2 -2
- package/dist/errors/SSMError.d.ts.map +1 -1
- package/dist/errors/SSMError.js.map +1 -1
- package/dist/eval/EvalHarness.d.ts.map +1 -1
- package/dist/eval/EvalHarness.js.map +1 -1
- package/dist/evermind/runtime.js.map +1 -1
- package/dist/evermind/textCoherence.js.map +1 -1
- package/dist/evermind/toolCall.js.map +1 -1
- package/dist/handoff/pack.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/ingest/IngestionPipeline.d.ts.map +1 -1
- package/dist/ingest/docsExtract.d.ts +9 -3
- package/dist/ingest/docsExtract.d.ts.map +1 -1
- package/dist/ingest/docsExtract.js +73 -20
- package/dist/ingest/docsExtract.js.map +1 -1
- package/dist/ingest/index.d.ts +1 -1
- package/dist/ingest/index.d.ts.map +1 -1
- package/dist/ingest/index.js +1 -1
- package/dist/ingest/index.js.map +1 -1
- package/dist/ingest/parserSupport.d.ts +16 -0
- package/dist/ingest/parserSupport.d.ts.map +1 -0
- package/dist/ingest/parserSupport.js +18 -0
- package/dist/ingest/parserSupport.js.map +1 -0
- package/dist/ingest/parsers.d.ts +3 -3
- package/dist/ingest/parsers.d.ts.map +1 -1
- package/dist/ingest/parsers.js +3 -92
- package/dist/ingest/parsers.js.map +1 -1
- package/dist/ingest/textParsers.d.ts +9 -0
- package/dist/ingest/textParsers.d.ts.map +1 -0
- package/dist/ingest/textParsers.js +99 -0
- package/dist/ingest/textParsers.js.map +1 -0
- package/dist/knowledge/build.d.ts +2 -0
- package/dist/knowledge/build.d.ts.map +1 -1
- package/dist/knowledge/build.js +46 -12
- package/dist/knowledge/build.js.map +1 -1
- package/dist/knowledge/cards.js.map +1 -1
- package/dist/knowledge/extractFile.d.ts +51 -0
- package/dist/knowledge/extractFile.d.ts.map +1 -0
- package/dist/knowledge/extractFile.js +59 -0
- package/dist/knowledge/extractFile.js.map +1 -0
- package/dist/knowledge/findings.d.ts +6 -0
- package/dist/knowledge/findings.d.ts.map +1 -1
- package/dist/knowledge/findings.js +9 -7
- package/dist/knowledge/findings.js.map +1 -1
- package/dist/knowledge/importance.js.map +1 -1
- package/dist/knowledge/index.d.ts +9 -7
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +8 -7
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/judge.d.ts +21 -2
- package/dist/knowledge/judge.d.ts.map +1 -1
- package/dist/knowledge/judge.js +63 -16
- package/dist/knowledge/judge.js.map +1 -1
- package/dist/knowledge/model.d.ts +13 -62
- package/dist/knowledge/model.d.ts.map +1 -1
- package/dist/knowledge/packs/docs.d.ts +5 -2
- package/dist/knowledge/packs/docs.d.ts.map +1 -1
- package/dist/knowledge/packs/docs.js +33 -5
- package/dist/knowledge/packs/docs.js.map +1 -1
- package/dist/knowledge/plan.d.ts +18 -3
- package/dist/knowledge/plan.d.ts.map +1 -1
- package/dist/knowledge/plan.js +35 -13
- package/dist/knowledge/plan.js.map +1 -1
- package/dist/knowledge/refs.d.ts +22 -1
- package/dist/knowledge/refs.d.ts.map +1 -1
- package/dist/knowledge/refs.js +52 -0
- package/dist/knowledge/refs.js.map +1 -1
- package/dist/knowledge/review.d.ts +8 -4
- package/dist/knowledge/review.d.ts.map +1 -1
- package/dist/knowledge/review.js +92 -106
- package/dist/knowledge/review.js.map +1 -1
- package/dist/knowledge/reviewCompare.d.ts +38 -0
- package/dist/knowledge/reviewCompare.d.ts.map +1 -0
- package/dist/knowledge/reviewCompare.js +59 -0
- package/dist/knowledge/reviewCompare.js.map +1 -0
- package/dist/knowledge/reviewModel.d.ts +80 -0
- package/dist/knowledge/reviewModel.d.ts.map +1 -0
- package/dist/knowledge/reviewModel.js +6 -0
- package/dist/knowledge/reviewModel.js.map +1 -0
- package/dist/knowledge/reviewStored.d.ts +23 -0
- package/dist/knowledge/reviewStored.d.ts.map +1 -0
- package/dist/knowledge/reviewStored.js +62 -0
- package/dist/knowledge/reviewStored.js.map +1 -0
- package/dist/knowledge/sources.d.ts +36 -4
- package/dist/knowledge/sources.d.ts.map +1 -1
- package/dist/knowledge/sources.js +99 -26
- package/dist/knowledge/sources.js.map +1 -1
- package/dist/knowledge/stores/localSnapshotStore.d.ts.map +1 -1
- package/dist/knowledge/stores/localSnapshotStore.js.map +1 -1
- package/dist/knowledge/trace.js.map +1 -1
- package/dist/knowledge/truncate.d.ts +4 -4
- package/dist/knowledge/truncate.d.ts.map +1 -1
- package/dist/knowledge/truncate.js +9 -13
- package/dist/knowledge/truncate.js.map +1 -1
- package/dist/limbic/LimbicSession.d.ts.map +1 -1
- package/dist/limbic/LimbicSession.js.map +1 -1
- package/dist/memory/MemoryStore.d.ts.map +1 -1
- package/dist/memory/MemoryStore.js.map +1 -1
- package/dist/memory/SemanticRecall.d.ts.map +1 -1
- package/dist/memory/SemanticRecall.js.map +1 -1
- package/dist/memory/ttlSweeper.d.ts.map +1 -1
- package/dist/orchestration/AgentGraph.d.ts.map +1 -1
- package/dist/orchestration/AgentGraph.js.map +1 -1
- package/dist/orchestration/checkpoint.d.ts.map +1 -1
- package/dist/orchestration/checkpoint.js.map +1 -1
- package/dist/publish/huggingface.js.map +1 -1
- package/dist/rag/EnterpriseRetriever.d.ts.map +1 -1
- package/dist/rag/EnterpriseRetriever.js.map +1 -1
- package/dist/retrieval/HybridRetriever.js.map +1 -1
- package/dist/retrieval/bm25.js.map +1 -1
- package/dist/retrieval/chunk.js.map +1 -1
- package/dist/retrieval/fusion.js.map +1 -1
- package/dist/retrieval/hnsw.d.ts.map +1 -1
- package/dist/retrieval/hnsw.js.map +1 -1
- package/dist/retrieval/knowledge-index/bytes.d.ts.map +1 -1
- package/dist/retrieval/knowledge-index/bytes.js.map +1 -1
- package/dist/retrieval/knowledge-index/cascade.js.map +1 -1
- package/dist/retrieval/knowledge-index/embeddings.d.ts.map +1 -1
- package/dist/retrieval/knowledge-index/embeddings.js.map +1 -1
- package/dist/retrieval/knowledge-index/expand.js.map +1 -1
- package/dist/retrieval/knowledge-index/index.js.map +1 -1
- package/dist/retrieval/knowledge-index/lexical.d.ts.map +1 -1
- package/dist/retrieval/knowledge-index/sha256.d.ts.map +1 -1
- package/dist/retrieval/order.js.map +1 -1
- package/dist/router/InferenceRouter.d.ts.map +1 -1
- package/dist/router/InferenceRouter.js.map +1 -1
- package/dist/runtime/SSMRuntime.d.ts.map +1 -1
- package/dist/runtime/SSMRuntime.js.map +1 -1
- package/dist/session/errors.d.ts +2 -2
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/errors.js.map +1 -1
- package/dist/session/session.d.ts.map +1 -1
- package/dist/session/session.js.map +1 -1
- package/dist/session/streaming.js.map +1 -1
- package/dist/storage/ScopedFactRepository.d.ts.map +1 -1
- package/dist/storage/ScopedFactRepository.js.map +1 -1
- package/dist/storage/fileLock.d.ts.map +1 -1
- package/dist/storage/fileLock.js.map +1 -1
- package/dist/storage/fileTransaction.d.ts.map +1 -1
- package/dist/storage/fileTransaction.js.map +1 -1
- package/dist/storage/idbAdapter.d.ts +1 -1
- package/dist/storage/idbAdapter.d.ts.map +1 -1
- package/dist/storage/idbAdapter.js.map +1 -1
- package/dist/storage/nodeFileAdapter.d.ts +1 -1
- package/dist/storage/nodeFileAdapter.d.ts.map +1 -1
- package/dist/storage/nodeFileAdapter.js.map +1 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/telemetry/InstrumentedBridge.d.ts.map +1 -1
- package/dist/telemetry/InstrumentedBridge.js.map +1 -1
- package/dist/telemetry/MetricsRegistry.d.ts.map +1 -1
- package/dist/telemetry/MetricsRegistry.js.map +1 -1
- package/dist/telemetry/Tracer.d.ts.map +1 -1
- package/dist/telemetry/Tracer.js.map +1 -1
- package/dist/telemetry/exporters.d.ts.map +1 -1
- package/dist/telemetry/exporters.js.map +1 -1
- package/dist/telemetry/pricing.js.map +1 -1
- package/dist/vectorstore/MemoryVectorStore.d.ts.map +1 -1
- package/dist/vectorstore/MemoryVectorStore.js.map +1 -1
- package/dist/vectorstore/RestVectorStore.d.ts.map +1 -1
- package/dist/vectorstore/dialects.js.map +1 -1
- package/dist/vectorstore/filter.js.map +1 -1
- package/dist/wire/chatClient.d.ts +5 -0
- package/dist/wire/chatClient.d.ts.map +1 -1
- package/dist/wire/chatClient.js +6 -0
- package/dist/wire/chatClient.js.map +1 -1
- package/dist/wire/usage.d.ts.map +1 -1
- package/dist/workflow/registry.d.ts.map +1 -1
- package/dist/workflow/run.js.map +1 -1
- package/dist/workflow/templates.js.map +1 -1
- package/dist/working/codemapAreas.js.map +1 -1
- package/dist/working/consolidate.js.map +1 -1
- package/dist/working/workingMemory.d.ts.map +1 -1
- package/dist/working/workingMemory.js.map +1 -1
- package/package.json +8 -9
- package/src/ingest/docsExtract.ts +68 -18
- package/src/ingest/index.ts +1 -0
- package/src/ingest/parserSupport.ts +24 -0
- package/src/ingest/parsers.ts +4 -102
- package/src/ingest/textParsers.ts +107 -0
- package/src/knowledge/build.ts +43 -11
- package/src/knowledge/extractFile.ts +86 -0
- package/src/knowledge/findings.ts +12 -5
- package/src/knowledge/index.ts +13 -8
- package/src/knowledge/judge.ts +64 -19
- package/src/knowledge/model.ts +15 -57
- package/src/knowledge/packs/docs.ts +34 -5
- package/src/knowledge/plan.ts +46 -14
- package/src/knowledge/refs.ts +49 -1
- package/src/knowledge/review.details.test.ts +93 -0
- package/src/knowledge/review.fixes.test.ts +235 -0
- package/src/knowledge/review.gaps.test.ts +167 -0
- package/src/knowledge/review.test.ts +2 -15
- package/src/knowledge/review.ts +85 -113
- package/src/knowledge/review.upgrade.test.ts +192 -0
- package/src/knowledge/reviewCompare.ts +68 -0
- package/src/knowledge/reviewModel.ts +75 -0
- package/src/knowledge/reviewStored.ts +62 -0
- package/src/knowledge/sources.ts +106 -20
- package/src/knowledge/testkit.test-util.ts +16 -1
- package/src/knowledge/truncate.ts +8 -11
- package/src/wire/chatClient.ts +13 -0
package/src/knowledge/plan.ts
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
* knowledge/plan.ts — `planReview`: the confirm chip's numbers (PRD 38 §4.3).
|
|
3
3
|
*
|
|
4
4
|
* A walk plus a manifest diff by hash, nothing more: a file whose hash is unchanged is
|
|
5
|
-
* never read. The only reads are the ignore files (`.
|
|
6
|
-
* when the listing has them. Binary files
|
|
7
|
-
*
|
|
5
|
+
* never read. The only reads are the ignore files (`.builderforce/ignore` and every
|
|
6
|
+
* `.gitignore`, a nested one scoped to its folder) when the listing has them. Binary files
|
|
7
|
+
* (by extension — pdf/office only when a host parser claims their media type), oversized
|
|
8
|
+
* files and files no pack accepts are skipped with a reason.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import type { IngestManifest } from '../ingest/types.js';
|
|
11
12
|
import type { DirectorySource, KnowledgePack, ReviewPlan } from './model.js';
|
|
12
13
|
import {
|
|
13
|
-
composePacks, DEFAULT_MAX_FILE_BYTES,
|
|
14
|
-
manifestMap, stubSource,
|
|
14
|
+
composePacks, DEFAULT_MAX_FILE_BYTES, EXTRACTOR_VERSION, filesManifestKey, ignoreMatcher, ignoreSourcesOf, isBinaryPath,
|
|
15
|
+
isDocumentPath, manifestMap, resolveDocument, storedExtractorVersion, stubSource,
|
|
15
16
|
} from './sources.js';
|
|
16
17
|
import { compareStr, sortBy } from './refs.js';
|
|
17
18
|
|
|
@@ -23,6 +24,14 @@ const SECTIONS_PER_COMPARE = 10;
|
|
|
23
24
|
export interface PlanOptions {
|
|
24
25
|
/** Per-file size cap in bytes. Default 2 MB. */
|
|
25
26
|
maxFileBytes?: number;
|
|
27
|
+
/**
|
|
28
|
+
* *Re-review all*: every file is `changed`, whatever its hash — but `removed` still comes
|
|
29
|
+
* from the real prior manifest, and the estimate still counts only files whose content
|
|
30
|
+
* changed (sections whose text was judged before are re-anchored, not judged again).
|
|
31
|
+
* A forced run cut short is forced again, not continued: *Continue* re-derives what is
|
|
32
|
+
* left from content hashes.
|
|
33
|
+
*/
|
|
34
|
+
force?: boolean;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
export interface PlannedFile {
|
|
@@ -61,15 +70,17 @@ export async function planDetail(
|
|
|
61
70
|
for await (const entry of source.list()) listed.push({ ...entry, path: entry.path.replace(/\\/g, '/').replace(/^\.?\//, '') });
|
|
62
71
|
const entries = sortBy(listed, (e) => e.path);
|
|
63
72
|
|
|
64
|
-
const ignoreTexts: string
|
|
65
|
-
for (const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (doc.content.kind === 'text') ignoreTexts.push(doc.content.text);
|
|
73
|
+
const ignoreTexts: Array<{ text: string; base: string }> = [];
|
|
74
|
+
for (const { path, base } of ignoreSourcesOf(entries.map((e) => e.path))) {
|
|
75
|
+
const doc = await source.read(path);
|
|
76
|
+
if (doc.content.kind === 'text') ignoreTexts.push({ text: doc.content.text, base });
|
|
69
77
|
}
|
|
70
78
|
const ignored = ignoreMatcher(ignoreTexts);
|
|
71
79
|
const composed = composePacks(packs);
|
|
72
80
|
const prior = await manifestMap(manifest, filesManifestKey(source.rootId));
|
|
81
|
+
// Another extractor version than the one that reviewed these files: all are re-extracted
|
|
82
|
+
// once, but `prior` stays the real manifest (removals) and the estimate counts content changes only.
|
|
83
|
+
const everything = opts.force === true || (await storedExtractorVersion(manifest, source.rootId)) !== EXTRACTOR_VERSION;
|
|
73
84
|
const packById = new Map(packs.map((p) => [p.id, p] as const));
|
|
74
85
|
|
|
75
86
|
const files: PlannedFile[] = [];
|
|
@@ -79,15 +90,17 @@ export async function planDetail(
|
|
|
79
90
|
let compareSections = 0;
|
|
80
91
|
for (const e of entries) {
|
|
81
92
|
if (ignored(e.path)) { skipped.push({ path: e.path, reason: 'ignored' }); continue; }
|
|
82
|
-
|
|
93
|
+
const document = isDocumentPath(e.path) ? resolveDocument(composed, e.path) : undefined;
|
|
94
|
+
if (isBinaryPath(e.path) && !document) { skipped.push({ path: e.path, reason: 'binary' }); continue; }
|
|
83
95
|
if (e.size > maxBytes) { skipped.push({ path: e.path, reason: 'too-large' }); continue; }
|
|
84
|
-
const hit = composed.resolve(stubSource(e.path));
|
|
96
|
+
const hit = document ?? composed.resolve(stubSource(e.path));
|
|
85
97
|
if (!hit) { skipped.push({ path: e.path, reason: 'no-pack' }); continue; }
|
|
86
|
-
const
|
|
98
|
+
const contentChanged = prior.get(e.path) !== e.hash;
|
|
99
|
+
const changed = everything || contentChanged;
|
|
87
100
|
files.push({ path: e.path, hash: e.hash, size: e.size, pack: hit.pack.id, changed });
|
|
88
101
|
byPack[hit.pack.id] = (byPack[hit.pack.id] ?? 0) + 1;
|
|
89
102
|
const spec = packById.get(hit.pack.id)?.judgement;
|
|
90
|
-
if (
|
|
103
|
+
if (contentChanged && spec && (spec.claims || spec.entities)) {
|
|
91
104
|
const sections = Math.max(1, Math.ceil(e.size / AVG_SECTION_BYTES));
|
|
92
105
|
estimatedSections += sections;
|
|
93
106
|
if (spec.contradictions) compareSections += sections;
|
|
@@ -113,3 +126,22 @@ export async function planDetail(
|
|
|
113
126
|
prior,
|
|
114
127
|
};
|
|
115
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* *Continue*: the confirmed plan without a re-walk. Only `changed` is re-read — against the
|
|
132
|
+
* manifest as the last run left it — so files finished since are not reviewed again. (While
|
|
133
|
+
* the stored extractor version is not today's, every file still counts as changed.)
|
|
134
|
+
*/
|
|
135
|
+
export async function refreshPlan(detail: PlanDetail, manifest: IngestManifest): Promise<PlanDetail> {
|
|
136
|
+
const prior = await manifestMap(manifest, filesManifestKey(detail.plan.rootId));
|
|
137
|
+
// The version entry is written only by a run that finished, so an upgrade cut short stays "everything".
|
|
138
|
+
const everything = (await storedExtractorVersion(manifest, detail.plan.rootId)) !== EXTRACTOR_VERSION;
|
|
139
|
+
const files = detail.files.map((f) => ({ ...f, changed: everything || prior.get(f.path) !== f.hash }));
|
|
140
|
+
const changed = files.filter((f) => f.changed).map((f) => f.path);
|
|
141
|
+
const removed = detail.plan.removed.filter((p) => prior.has(p));
|
|
142
|
+
return {
|
|
143
|
+
plan: { ...detail.plan, unchanged: files.length - changed.length, changed, removed },
|
|
144
|
+
files,
|
|
145
|
+
prior,
|
|
146
|
+
};
|
|
147
|
+
}
|
package/src/knowledge/refs.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* fact:${key} any other fact (claims: fact:claim:${hash})
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import type { NodeRef } from './model.js';
|
|
14
|
+
import type { KEdge, NodeRef } from './model.js';
|
|
15
15
|
|
|
16
16
|
/** Code-unit ordering — never `localeCompare`, whose result depends on the host's ICU. */
|
|
17
17
|
export function compareStr(a: string, b: string): number {
|
|
@@ -106,3 +106,51 @@ export function sortBy<T>(items: readonly T[], ...keys: Array<(t: T) => string>)
|
|
|
106
106
|
return 0;
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A relative target walked from the linking file's folder (a leading `/` is the root):
|
|
112
|
+
* `segments` is where it lands under the root, `ups` how many levels it climbed ABOVE the
|
|
113
|
+
* root. Pure path arithmetic — the one place that decides "inside", "root itself" and "escapes".
|
|
114
|
+
*/
|
|
115
|
+
export function walkRelative(fromPath: string, target: string): { ups: number; segments: string[] } {
|
|
116
|
+
const t = target.replace(/\\/g, '/');
|
|
117
|
+
const segments = t.startsWith('/') ? [] : fromPath.split('/').slice(0, -1);
|
|
118
|
+
let ups = 0;
|
|
119
|
+
for (const seg of t.split('/')) {
|
|
120
|
+
if (seg === '' || seg === '.') continue;
|
|
121
|
+
if (seg === '..') {
|
|
122
|
+
if (segments.length) segments.pop();
|
|
123
|
+
else ups += 1;
|
|
124
|
+
} else segments.push(seg);
|
|
125
|
+
}
|
|
126
|
+
return { ups, segments };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* `[[Name]]` → the one listed file named `Name` (or `Name.md`), case-insensitively, anywhere
|
|
131
|
+
* in the root. Ambiguous names resolve to none, so the link keeps its beside-the-file fallback.
|
|
132
|
+
*/
|
|
133
|
+
export function nameResolver(paths: readonly string[]): (name: string) => string | undefined {
|
|
134
|
+
const byName = new Map<string, string | null>();
|
|
135
|
+
for (const p of [...paths].sort(compareStr)) {
|
|
136
|
+
const base = basenameOf(p).toLowerCase();
|
|
137
|
+
for (const key of new Set([base, base.replace(/\.md$/, '')])) {
|
|
138
|
+
byName.set(key, byName.has(key) && byName.get(key) !== p ? null : p);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return (name) => byName.get(name.trim().toLowerCase()) ?? undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The `about` target of each node, from edges in graph order. By default the first; with
|
|
146
|
+
* `preferSection` a section wins over the file it belongs to (the most specific source).
|
|
147
|
+
*/
|
|
148
|
+
export function aboutTargets(edges: readonly KEdge[], opts: { preferSection?: boolean } = {}): Map<NodeRef, NodeRef> {
|
|
149
|
+
const out = new Map<NodeRef, NodeRef>();
|
|
150
|
+
for (const e of edges) {
|
|
151
|
+
if (e.kind !== 'about') continue;
|
|
152
|
+
const prior = out.get(e.from);
|
|
153
|
+
if (!prior || (opts.preferSection && prior === fileRefOf(prior) && e.to !== fileRefOf(e.to))) out.set(e.from, e.to);
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/knowledge/review.details.test.ts
|
|
3
|
+
* A file found binary on read goes stale, a throwing judgement port leaves the file to be
|
|
4
|
+
* retried, a contradiction names its sections, and `extractFile` is the one single-file extraction.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
|
|
8
|
+
import { hashText } from '../ingest/hash.js';
|
|
9
|
+
import { buildGraph } from './build.js';
|
|
10
|
+
import { extractFile } from './extractFile.js';
|
|
11
|
+
import type { NodeRef, ReviewArgs, StoredFact } from './model.js';
|
|
12
|
+
import { DOCS_PACK } from './packs/docs.js';
|
|
13
|
+
import { planReview } from './plan.js';
|
|
14
|
+
import { reviewDirectory } from './review.js';
|
|
15
|
+
import { EXTRACTOR_VERSION } from './sources.js';
|
|
16
|
+
import { extractedOf, fakeJudge, fileNode, memSource, memStore, ref, ROOT, type SpySource } from './testkit.test-util.js';
|
|
17
|
+
|
|
18
|
+
const args = (source: SpySource, store = memStore(), manifest = new InMemoryIngestManifest(), extra: Partial<ReviewArgs> = {}): ReviewArgs =>
|
|
19
|
+
({ source, store, manifest, packs: [DOCS_PACK], budget: { modelCalls: 200, ms: 60_000 }, ...extra });
|
|
20
|
+
|
|
21
|
+
describe('judgement and findings details', () => {
|
|
22
|
+
it('a file found binary on read has its old relations marked stale', async () => {
|
|
23
|
+
const source = memSource({ 'a.md': '# A\nalpha\n' });
|
|
24
|
+
const store = memStore();
|
|
25
|
+
const manifest = new InMemoryIngestManifest();
|
|
26
|
+
await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge() }));
|
|
27
|
+
source.files['a.md'] = 'bin\u0000ary';
|
|
28
|
+
await reviewDirectory(args(source, store, manifest));
|
|
29
|
+
const about = (await store.relations({ rootId: ROOT })).filter((r) => r.kind === 'about');
|
|
30
|
+
expect(about.length).toBeGreaterThan(0);
|
|
31
|
+
expect(about.every((r) => r.staleAt)).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('a judgement call that throws is unjudged, and the file is retried', async () => {
|
|
35
|
+
const source = memSource({ 'a.md': '# A\nalpha\n' });
|
|
36
|
+
const store = memStore();
|
|
37
|
+
const manifest = new InMemoryIngestManifest();
|
|
38
|
+
const broken = { async judge(): Promise<never> { throw new Error('port down'); } };
|
|
39
|
+
const report = await reviewDirectory(args(source, store, manifest, { judgement: broken }));
|
|
40
|
+
expect(report).toMatchObject({ judged: 0, unjudged: 1 });
|
|
41
|
+
expect((await planReview(source, manifest, [DOCS_PACK])).changed).toEqual(['a.md']);
|
|
42
|
+
|
|
43
|
+
const judge = fakeJudge();
|
|
44
|
+
const again = await reviewDirectory(args(source, store, manifest, { judgement: judge }));
|
|
45
|
+
expect(judge.requests.filter((r) => r.kind === 'extract')).toHaveLength(1);
|
|
46
|
+
expect(again.judged).toBe(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('a contradiction names the sections its claims are about', () => {
|
|
50
|
+
const section = (path: string, slug: string, label: string) => ({
|
|
51
|
+
...fileNode(path), ref: `${ref(path)}#${slug}` as NodeRef, kind: 'section', label,
|
|
52
|
+
});
|
|
53
|
+
const claim = (key: string, path: string): StoredFact => ({
|
|
54
|
+
key, content: key, source: 'review', importance: 0.5, origin: 'model', fileAnchors: [{ path, contentHash: `h:${path}` }],
|
|
55
|
+
});
|
|
56
|
+
const g = buildGraph({
|
|
57
|
+
rootId: ROOT, packs: [DOCS_PACK],
|
|
58
|
+
extracted: [
|
|
59
|
+
{ ...extractedOf(fileNode('a.md')), nodes: [fileNode('a.md'), section('a.md', 'rent', 'Rent')] },
|
|
60
|
+
{ ...extractedOf(fileNode('b.md')), nodes: [fileNode('b.md'), section('b.md', 'term', 'Term')] },
|
|
61
|
+
],
|
|
62
|
+
facts: [claim('claim:a', 'a.md'), claim('claim:b', 'b.md')],
|
|
63
|
+
relations: [
|
|
64
|
+
{ from: 'fact:claim:a', to: `${ref('a.md')}#rent` as NodeRef, kind: 'about', weight: 1, origin: 'model' },
|
|
65
|
+
{ from: 'fact:claim:b', to: `${ref('b.md')}#term` as NodeRef, kind: 'about', weight: 1, origin: 'model' },
|
|
66
|
+
{ from: 'fact:claim:a', to: 'fact:claim:b', kind: 'contradicts', weight: 1, origin: 'model', confidence: 0.8 },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
const f = g.findings.find((x) => x.kind === 'contradiction');
|
|
70
|
+
expect(f?.params).toMatchObject({ fileA: 'a.md', sectionA: 'Rent', fileB: 'b.md', sectionB: 'Term' });
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('extractFile', () => {
|
|
75
|
+
it('extracts one file with the cache, the version and the stored entity keys', async () => {
|
|
76
|
+
const store = memStore();
|
|
77
|
+
const lease = { key: 'ent:docs:lease', content: 'Lease', source: 's', importance: 0.5, origin: 'model' as const, fileAnchors: [] };
|
|
78
|
+
await store.write({ scope: { rootId: ROOT, title: 't', packs: [] }, facts: [lease], relations: [] });
|
|
79
|
+
const text = '# A\nThe Lease ends.\n';
|
|
80
|
+
const hash = hashText(text);
|
|
81
|
+
const input = {
|
|
82
|
+
rootId: ROOT, path: 'a.md', hash, packs: [DOCS_PACK], store,
|
|
83
|
+
doc: { id: 'a.md', tenantId: 't', content: { kind: 'text' as const, text } },
|
|
84
|
+
};
|
|
85
|
+
const ex = await extractFile(input);
|
|
86
|
+
expect(ex).toMatchObject({ sourceRef: ref('a.md'), sourceHash: hash, extractorVersion: EXTRACTOR_VERSION });
|
|
87
|
+
expect(ex!.edges.some((e) => e.kind === 'mentions' && e.to === 'ent:docs:lease')).toBe(true);
|
|
88
|
+
expect(await store.getExtracted(hash)).toEqual([ex]);
|
|
89
|
+
expect(await extractFile(input)).toEqual(ex);
|
|
90
|
+
const pdf = { ...input, path: 'a.pdf', doc: { ...input.doc, content: { kind: 'text' as const, text, mediaType: 'application/pdf' } } };
|
|
91
|
+
expect(await extractFile(pdf)).toBeUndefined();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/knowledge/review.fixes.test.ts
|
|
3
|
+
* Review follow-ups: binary documents are claimed only by a host extractor (any pack order);
|
|
4
|
+
* `[[Name]]` is resolved at build time, never in the cached extract; a fact outlives one of
|
|
5
|
+
* its deleted sources; ignore precedence; out-of-root and root links; compare pairs survive
|
|
6
|
+
* a skipped run; extractor versions; a stale plan.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
|
|
10
|
+
import { hashText } from '../ingest/hash.js';
|
|
11
|
+
import { htmlParser, isBinaryDocumentType, markdownParser, plainTextParser } from '../ingest/parsers.js';
|
|
12
|
+
import type { SourceDocument } from '../ingest/types.js';
|
|
13
|
+
import { buildGraph } from './build.js';
|
|
14
|
+
import type { ExtractContext, Extracted, KnowledgePack, KnowledgeParser, ReviewArgs } from './model.js';
|
|
15
|
+
import { DOCS_PACK } from './packs/docs.js';
|
|
16
|
+
import { planDetail, planReview } from './plan.js';
|
|
17
|
+
import { reviewDirectory } from './review.js';
|
|
18
|
+
import {
|
|
19
|
+
asPathSource, compareManifestKey, composePacks, EXTRACTOR_VERSION, filesManifestKey, manifestMap, resolveRelativePath,
|
|
20
|
+
} from './sources.js';
|
|
21
|
+
import {
|
|
22
|
+
extractedOf, fakeJudge, fileNode, graphOf, memSource, memStore, ref, ROOT, type SpySource,
|
|
23
|
+
} from './testkit.test-util.js';
|
|
24
|
+
|
|
25
|
+
const BUDGET = { modelCalls: 200, ms: 60_000 };
|
|
26
|
+
const args = (source: SpySource, store = memStore(), manifest = new InMemoryIngestManifest(), extra: Partial<ReviewArgs> = {}): ReviewArgs =>
|
|
27
|
+
({ source, store, manifest, packs: [DOCS_PACK], budget: BUDGET, ...extra });
|
|
28
|
+
|
|
29
|
+
const ctx: ExtractContext = { rootId: ROOT, knownKeys: new Map(), resolvePath: resolveRelativePath };
|
|
30
|
+
const doc = (path: string, text: string): SourceDocument =>
|
|
31
|
+
asPathSource({ id: path, tenantId: 't', content: { kind: 'text', text } }, path, `h:${path}`);
|
|
32
|
+
const extractMd = (path: string, text: string): Extracted => {
|
|
33
|
+
const src = doc(path, text);
|
|
34
|
+
return markdownParser.extract!(src, markdownParser.parse(src), ctx);
|
|
35
|
+
};
|
|
36
|
+
const links = (ex: Extracted) => ex.edges.filter((e) => e.kind === 'links');
|
|
37
|
+
|
|
38
|
+
const pdfParser: KnowledgeParser = {
|
|
39
|
+
id: 'pdf-text',
|
|
40
|
+
accepts: (s) => s.content.kind === 'text' && s.content.mediaType === 'application/pdf',
|
|
41
|
+
parse: (s) => [{ text: s.content.kind === 'text' ? s.content.text : '' }],
|
|
42
|
+
};
|
|
43
|
+
const pdfPack: KnowledgePack = { id: 'pdf', parsers: [pdfParser] };
|
|
44
|
+
|
|
45
|
+
describe('binary documents', () => {
|
|
46
|
+
it('knowledge composition refuses an office or pdf media type to the builtin text parsers; ingest is unchanged', () => {
|
|
47
|
+
const docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
48
|
+
for (const type of [docx, 'application/pdf', 'application/msword', 'application/vnd.ms-excel']) {
|
|
49
|
+
expect(isBinaryDocumentType(type)).toBe(true);
|
|
50
|
+
const source: SourceDocument = { id: 'x', tenantId: 't', content: { kind: 'text', text: 't', mediaType: type } };
|
|
51
|
+
expect(composePacks([DOCS_PACK]).resolve(source)).toBeUndefined();
|
|
52
|
+
expect(composePacks([DOCS_PACK, pdfPack]).resolve(source)?.pack.id).toBe(type === 'application/pdf' ? 'pdf' : undefined);
|
|
53
|
+
// The ingest pipeline's builtins accept exactly what they always did.
|
|
54
|
+
expect(plainTextParser.accepts(source)).toBe(true);
|
|
55
|
+
}
|
|
56
|
+
const xml: SourceDocument = { id: 'x', tenantId: 't', content: { kind: 'text', text: 't', mediaType: docx } };
|
|
57
|
+
expect(htmlParser.accepts(xml)).toBe(true);
|
|
58
|
+
expect(isBinaryDocumentType('application/vnd.api+json')).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('a docx with no host parser is skipped as binary', async () => {
|
|
62
|
+
const plan = await planReview(memSource({ 'a.docx': 'x', 'b.md': '# B\n' }), new InMemoryIngestManifest(), [DOCS_PACK]);
|
|
63
|
+
expect(plan.skipped).toContainEqual({ path: 'a.docx', reason: 'binary' });
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('a host pdf pack placed AFTER the docs pack still claims the pdf', async () => {
|
|
67
|
+
const source = memSource({ 'a.pdf': 'text' });
|
|
68
|
+
const plan = await planReview(source, new InMemoryIngestManifest(), [DOCS_PACK, pdfPack]);
|
|
69
|
+
expect(plan.byPack).toEqual({ pdf: 1 });
|
|
70
|
+
const report = await reviewDirectory(args(source, memStore(), new InMemoryIngestManifest(), { packs: [DOCS_PACK, pdfPack] }));
|
|
71
|
+
expect(report.extracted).toBe(1);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('[[Name]] links resolve at build time', () => {
|
|
76
|
+
const one = extractMd('a/one.md', '# One\nSee [[Two]].\n');
|
|
77
|
+
const build = (...paths: string[]) => buildGraph({
|
|
78
|
+
rootId: ROOT, packs: [DOCS_PACK], extracted: [one, ...paths.map((p) => extractedOf(fileNode(p)))], facts: [], relations: [],
|
|
79
|
+
});
|
|
80
|
+
const targets = (g: ReturnType<typeof build>) => g.edges.filter((e) => e.kind === 'links').map((e) => e.to);
|
|
81
|
+
|
|
82
|
+
it('the cached extract carries the fallback and the name, not the resolution', () => {
|
|
83
|
+
expect(links(one)).toEqual([expect.objectContaining({ to: ref('a/Two.md'), byName: 'Two' })]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('points at the unique file of that name, even when it appeared after the extract', () => {
|
|
87
|
+
const g = build('b/Two.md');
|
|
88
|
+
expect(targets(g)).toEqual([ref('b/Two.md')]);
|
|
89
|
+
expect(g.edges.every((e) => !('byName' in e))).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('keeps the fallback when the name is ambiguous or absent', () => {
|
|
93
|
+
expect(targets(build('b/Two.md', 'c/Two.md'))).toEqual([ref('a/Two.md')]);
|
|
94
|
+
expect(targets(build())).toEqual([ref('a/Two.md')]);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('a fact outlives one of its deleted sources', () => {
|
|
99
|
+
it('drops the removed anchor from a fact other sources back; a fact anchored only there stays stale', async () => {
|
|
100
|
+
const source = memSource({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n' });
|
|
101
|
+
const store = memStore();
|
|
102
|
+
const manifest = new InMemoryIngestManifest();
|
|
103
|
+
await reviewDirectory(args(source, store, manifest, { judgement: fakeJudge() }));
|
|
104
|
+
const lease = (await store.facts({ rootId: ROOT })).find((f) => f.key === 'ent:docs:lease')!;
|
|
105
|
+
expect(lease.fileAnchors.map((a) => a.path)).toEqual(['a.md', 'b.md']);
|
|
106
|
+
|
|
107
|
+
delete source.files['b.md'];
|
|
108
|
+
await reviewDirectory(args(source, store, manifest));
|
|
109
|
+
const facts = await store.facts({ rootId: ROOT });
|
|
110
|
+
expect(facts.find((f) => f.key === 'ent:docs:lease')!.fileAnchors.map((a) => a.path)).toEqual(['a.md']);
|
|
111
|
+
const g = await graphOf(source, store);
|
|
112
|
+
expect(g.nodes.find((n) => n.ref === 'ent:docs:lease')?.stale).toBeUndefined();
|
|
113
|
+
const onlyB = facts.find((f) => f.key.startsWith('claim:') && f.fileAnchors.every((a) => a.path === 'b.md'))!;
|
|
114
|
+
expect(g.nodes.find((n) => n.ref === `fact:${onlyB.key}`)?.stale).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('ignore precedence', () => {
|
|
119
|
+
it('.builderforce/ignore overrides .gitignore', async () => {
|
|
120
|
+
const source = memSource({
|
|
121
|
+
'.gitignore': 'docs/generated/\n', '.builderforce/ignore': '!docs/generated/\n', 'docs/generated/x.md': '# X\n',
|
|
122
|
+
});
|
|
123
|
+
const plan = await planReview(source, new InMemoryIngestManifest(), [DOCS_PACK]);
|
|
124
|
+
expect(plan.changed).toEqual(['docs/generated/x.md']);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('links out of and to the root', () => {
|
|
129
|
+
it('a link to the root itself is no link', () => {
|
|
130
|
+
expect(links(extractMd('a/b.md', '# T\n[x](/) [y](./) [z](.) [w](..) [v](../) [d](docs/)\n'))).toEqual([]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('an escape stays a broken link under a normalized path that never collapses different files', () => {
|
|
134
|
+
const refs = [
|
|
135
|
+
links(extractMd('a/x.md', '# T\n[u](../../y.md)\n')),
|
|
136
|
+
links(extractMd('a/b/x.md', '# T\n[u](../../../y.md)\n')),
|
|
137
|
+
links(extractMd('x.md', '# T\n[u](../../y.md)\n')),
|
|
138
|
+
].map((l) => l.map((e) => e.to));
|
|
139
|
+
expect(refs).toEqual([[ref('../y.md')], [ref('../y.md')], [ref('../../y.md')]]);
|
|
140
|
+
|
|
141
|
+
const g = buildGraph({ rootId: ROOT, packs: [DOCS_PACK], extracted: [extractMd('a/x.md', '# T\n[u](../../y.md)\n')], facts: [], relations: [] });
|
|
142
|
+
const missing = g.nodes.find((n) => n.ref === ref('../y.md'));
|
|
143
|
+
expect(missing).toMatchObject({ kind: 'missing' });
|
|
144
|
+
expect(missing?.partition).toBeUndefined();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('a reference definition may end in whitespace', () => {
|
|
148
|
+
for (const eol of [' \n', '\t\r\n']) {
|
|
149
|
+
const ex = extractMd('one.md', `# One\nSee [the guide][g].\n\n[g]: docs/guide.md${eol}`);
|
|
150
|
+
expect(links(ex).map((e) => e.to)).toEqual([ref('docs/guide.md')]);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('compare pairs skipped can continue', () => {
|
|
156
|
+
const similar = async (ids: string[]) => (ids.length >= 2 ? [{ a: ids[0]!, b: ids[1]!, similarity: 0.95 }] : []);
|
|
157
|
+
|
|
158
|
+
it('a pair skipped for budget is compared by the next run, once', async () => {
|
|
159
|
+
const source = memSource({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n' });
|
|
160
|
+
const store = memStore();
|
|
161
|
+
const manifest = new InMemoryIngestManifest();
|
|
162
|
+
const first = await reviewDirectory(args(source, store, manifest, {
|
|
163
|
+
judgement: fakeJudge(), similar, budget: { modelCalls: 2, ms: 60_000 },
|
|
164
|
+
}));
|
|
165
|
+
expect(first.unjudged).toBe(1);
|
|
166
|
+
expect((await manifestMap(manifest, compareManifestKey(ROOT))).size).toBe(2);
|
|
167
|
+
|
|
168
|
+
const judge = fakeJudge();
|
|
169
|
+
const second = await reviewDirectory(args(source, store, manifest, { judgement: judge, similar }));
|
|
170
|
+
expect(judge.requests.map((r) => r.kind)).toEqual(['compare']);
|
|
171
|
+
expect(second.unjudged).toBe(0);
|
|
172
|
+
expect(await store.relations({ rootId: ROOT })).toContainEqual(expect.objectContaining({ kind: 'contradicts' }));
|
|
173
|
+
expect((await manifestMap(manifest, compareManifestKey(ROOT))).size).toBe(0);
|
|
174
|
+
|
|
175
|
+
const third = fakeJudge();
|
|
176
|
+
await reviewDirectory(args(source, store, manifest, { judgement: third, similar }));
|
|
177
|
+
expect(third.requests).toHaveLength(0);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('aborted is set only when the abort landed before compare finished', async () => {
|
|
181
|
+
const run = async (files: Record<string, string>, pairs: number) => {
|
|
182
|
+
const controller = new AbortController();
|
|
183
|
+
const judge = fakeJudge();
|
|
184
|
+
const inner = judge.judge.bind(judge);
|
|
185
|
+
judge.judge = async (req) => {
|
|
186
|
+
const out = await inner(req);
|
|
187
|
+
if (req.kind === 'compare') controller.abort();
|
|
188
|
+
return out;
|
|
189
|
+
};
|
|
190
|
+
const manifest = new InMemoryIngestManifest();
|
|
191
|
+
const report = await reviewDirectory(args(memSource(files), memStore(), manifest, {
|
|
192
|
+
judgement: judge, signal: controller.signal,
|
|
193
|
+
similar: async (ids) => ids.slice(1).slice(0, pairs).map((b, i) => ({ a: ids[i]!, b, similarity: 0.9 })),
|
|
194
|
+
}));
|
|
195
|
+
return { report, awaiting: (await manifestMap(manifest, compareManifestKey(ROOT))).size };
|
|
196
|
+
};
|
|
197
|
+
const last = await run({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n' }, 1);
|
|
198
|
+
expect(last.report.aborted).toBe(false);
|
|
199
|
+
expect(last.awaiting).toBe(0);
|
|
200
|
+
const mid = await run({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n', 'c.md': '# C\ngamma\n' }, 2);
|
|
201
|
+
expect(mid.report.aborted).toBe(true);
|
|
202
|
+
expect(mid.awaiting).toBeGreaterThan(0);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('extractor version and stale plans', () => {
|
|
207
|
+
it('a cached Extracted of an older version is re-extracted', async () => {
|
|
208
|
+
const text = '# A\nalpha\n';
|
|
209
|
+
const store = memStore();
|
|
210
|
+
const hash = hashText(text);
|
|
211
|
+
await store.putExtracted(hash, [{ sourceRef: ref('a.md'), sourceHash: hash, extractorVersion: EXTRACTOR_VERSION - 1, nodes: [], edges: [], keys: [] }]);
|
|
212
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), store));
|
|
213
|
+
const cached = (await store.getExtracted(hash))!;
|
|
214
|
+
expect(cached).toHaveLength(1);
|
|
215
|
+
expect(cached[0]).toMatchObject({ extractorVersion: EXTRACTOR_VERSION });
|
|
216
|
+
expect(cached[0]!.nodes.length).toBeGreaterThan(0);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('Continue with a plan that lists a file that can no longer be read skips it, without retiring it', async () => {
|
|
220
|
+
const source = memSource({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n' });
|
|
221
|
+
const manifest = new InMemoryIngestManifest();
|
|
222
|
+
const detail = await planDetail(source, manifest, [DOCS_PACK]);
|
|
223
|
+
delete source.files['b.md'];
|
|
224
|
+
const read = source.read.bind(source);
|
|
225
|
+
source.read = async (p) => {
|
|
226
|
+
if (!(p in source.files)) throw new Error('ENOENT');
|
|
227
|
+
return read(p);
|
|
228
|
+
};
|
|
229
|
+
const report = await reviewDirectory(args(source, memStore(), manifest, { plan: detail }));
|
|
230
|
+
expect(report.aborted).toBe(false);
|
|
231
|
+
expect(report.extracted).toBe(1);
|
|
232
|
+
expect(report.readErrors).toBe(1);
|
|
233
|
+
expect([...(await manifestMap(manifest, filesManifestKey(ROOT))).keys()]).toEqual(['a.md']);
|
|
234
|
+
});
|
|
235
|
+
});
|