@seanhogg/builderforce-memory 2026.10.30 → 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 +14 -63
- 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 +16 -58
- 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
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/knowledge/review.gaps.test.ts
|
|
3
|
+
* PRD 38 audit follow-ups: abort DURING judgement re-judges next time; stale relations and
|
|
4
|
+
* facts on deleted sources show stale; the contradiction finding; nested `.gitignore`;
|
|
5
|
+
* pdf/office only with a host extractor; files binary on read are not re-read; *Continue*
|
|
6
|
+
* reuses the confirmed plan; wiki links by name, reference-style links, out-of-root links
|
|
7
|
+
* and the pre-heading section.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
|
|
11
|
+
import { markdownParser } from '../ingest/parsers.js';
|
|
12
|
+
import type { SourceDocument } from '../ingest/types.js';
|
|
13
|
+
import { buildGraph } from './build.js';
|
|
14
|
+
import type { ExtractContext, KnowledgePack, KnowledgeParser, NodeRef, ReviewArgs, StoredFact } 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 { asPathSource, resolveRelativePath } from './sources.js';
|
|
19
|
+
import { extractedOf, fakeJudge, fileNode, memSource, memStore, ref, ROOT, type SpySource } from './testkit.test-util.js';
|
|
20
|
+
|
|
21
|
+
const BUDGET = { modelCalls: 200, ms: 60_000 };
|
|
22
|
+
const args = (source: SpySource, store = memStore(), manifest = new InMemoryIngestManifest(), extra: Partial<ReviewArgs> = {}): ReviewArgs =>
|
|
23
|
+
({ source, store, manifest, packs: [DOCS_PACK], budget: BUDGET, ...extra });
|
|
24
|
+
|
|
25
|
+
describe('reviewDirectory — audit follow-ups', () => {
|
|
26
|
+
it('an abort during judgement leaves that file to be judged again', async () => {
|
|
27
|
+
const source = memSource({ 'a.md': '# A\nalpha\n## B\nbeta\n' });
|
|
28
|
+
const store = memStore();
|
|
29
|
+
const manifest = new InMemoryIngestManifest();
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
let calls = 0;
|
|
32
|
+
const judge = fakeJudge();
|
|
33
|
+
const inner = judge.judge.bind(judge);
|
|
34
|
+
judge.judge = async (req) => {
|
|
35
|
+
calls += 1;
|
|
36
|
+
const out = await inner(req);
|
|
37
|
+
if (calls === 1) controller.abort();
|
|
38
|
+
return out;
|
|
39
|
+
};
|
|
40
|
+
const first = await reviewDirectory(args(source, store, manifest, { judgement: judge, signal: controller.signal }));
|
|
41
|
+
expect(first.aborted).toBe(true);
|
|
42
|
+
expect((await store.facts({ rootId: ROOT })).filter((f) => f.key.startsWith('claim:'))).toHaveLength(0);
|
|
43
|
+
|
|
44
|
+
const again = fakeJudge();
|
|
45
|
+
await reviewDirectory(args(source, store, manifest, { judgement: again }));
|
|
46
|
+
expect(again.requests.filter((r) => r.kind === 'extract')).toHaveLength(2);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('records a file found binary on read, so it is not re-read', async () => {
|
|
50
|
+
const source = memSource({ 'a.txt': 'bin\u0000ary' });
|
|
51
|
+
const manifest = new InMemoryIngestManifest();
|
|
52
|
+
await reviewDirectory(args(source, memStore(), manifest));
|
|
53
|
+
source.reads.length = 0;
|
|
54
|
+
await reviewDirectory(args(source, memStore(), manifest));
|
|
55
|
+
expect(source.reads).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('Continue reuses the confirmed plan without re-walking', async () => {
|
|
59
|
+
const source = memSource({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n' });
|
|
60
|
+
const manifest = new InMemoryIngestManifest();
|
|
61
|
+
const detail = await planDetail(source, manifest, [DOCS_PACK]);
|
|
62
|
+
let walks = 0;
|
|
63
|
+
const list = source.list.bind(source);
|
|
64
|
+
source.list = () => { walks += 1; return list(); };
|
|
65
|
+
const store = memStore();
|
|
66
|
+
const report = await reviewDirectory(args(source, store, manifest, { plan: detail }));
|
|
67
|
+
expect(walks).toBe(0);
|
|
68
|
+
expect(report.extracted).toBe(2);
|
|
69
|
+
|
|
70
|
+
// Run again with the same plan: what the first run finished is not reviewed (or read) again.
|
|
71
|
+
source.reads.length = 0;
|
|
72
|
+
const again = await reviewDirectory(args(source, store, manifest, { plan: detail }));
|
|
73
|
+
expect(again.extracted).toBe(0);
|
|
74
|
+
expect(source.reads).toEqual([]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('counts compare pairs skipped for budget as unjudged', async () => {
|
|
78
|
+
const source = memSource({ 'a.md': '# A\nalpha\n', 'b.md': '# B\nbeta\n' });
|
|
79
|
+
const report = await reviewDirectory(args(source, memStore(), new InMemoryIngestManifest(), {
|
|
80
|
+
judgement: fakeJudge(),
|
|
81
|
+
budget: { modelCalls: 2, ms: 60_000 },
|
|
82
|
+
similar: async (ids) => (ids.length >= 2 ? [{ a: ids[0]!, b: ids[1]!, similarity: 0.95 }] : []),
|
|
83
|
+
}));
|
|
84
|
+
expect(report.judged).toBe(2);
|
|
85
|
+
expect(report.unjudged).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('planReview — ignores and documents', () => {
|
|
90
|
+
it('scopes a nested .gitignore to its folder', async () => {
|
|
91
|
+
const source = memSource({ 'docs/.gitignore': 'draft.md\n', 'docs/draft.md': '# D\n', 'draft.md': '# Root\n' });
|
|
92
|
+
const plan = await planReview(source, new InMemoryIngestManifest(), [DOCS_PACK]);
|
|
93
|
+
expect(plan.skipped).toContainEqual({ path: 'docs/draft.md', reason: 'ignored' });
|
|
94
|
+
expect(plan.changed).toContain('draft.md');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('skips pdf/office as binary unless a host parser claims the media type', async () => {
|
|
98
|
+
const source = memSource({ 'a.pdf': 'text', 'b.md': '# B\n' });
|
|
99
|
+
expect((await planReview(source, new InMemoryIngestManifest(), [DOCS_PACK])).skipped)
|
|
100
|
+
.toContainEqual({ path: 'a.pdf', reason: 'binary' });
|
|
101
|
+
const pdf: KnowledgeParser = {
|
|
102
|
+
id: 'pdf-text',
|
|
103
|
+
accepts: (s) => s.content.kind === 'text' && s.content.mediaType === 'application/pdf',
|
|
104
|
+
parse: (s) => [{ text: s.content.kind === 'text' ? s.content.text : '' }],
|
|
105
|
+
};
|
|
106
|
+
const withPdf: KnowledgePack = { ...DOCS_PACK, parsers: [pdf, ...DOCS_PACK.parsers] };
|
|
107
|
+
const plan = await planReview(source, new InMemoryIngestManifest(), [withPdf]);
|
|
108
|
+
expect(plan.changed).toContain('a.pdf');
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
describe('buildGraph — stale knowledge', () => {
|
|
113
|
+
const claim: StoredFact = {
|
|
114
|
+
key: 'claim:x', content: 'The lease ends', source: 'review', importance: 0.5, origin: 'model',
|
|
115
|
+
fileAnchors: [{ path: 'gone.md', contentHash: 'h:old' }],
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
it('marks a model fact anchored to a deleted source stale', () => {
|
|
119
|
+
const g = buildGraph({ rootId: ROOT, packs: [DOCS_PACK], extracted: [extractedOf(fileNode('a.md'))], facts: [claim], relations: [] });
|
|
120
|
+
expect(g.nodes.find((n) => n.ref === 'fact:claim:x')?.stale).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('carries a stale relation as a stale edge', () => {
|
|
124
|
+
const g = buildGraph({
|
|
125
|
+
rootId: ROOT, packs: [DOCS_PACK], extracted: [extractedOf(fileNode('a.md')), extractedOf(fileNode('b.md'))], facts: [],
|
|
126
|
+
relations: [{ from: ref('a.md'), to: ref('b.md'), kind: 'agrees', weight: 1, origin: 'model', staleAt: '2026-10-28' }],
|
|
127
|
+
});
|
|
128
|
+
expect(g.edges.find((e) => e.kind === 'agrees')?.stale).toBe(true);
|
|
129
|
+
expect(g.stats.stale).toBe(0); // stale NODES only; the edge carries its own flag
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('reports a contradiction naming both sections', () => {
|
|
133
|
+
const fact = (key: string, path: string): StoredFact => ({
|
|
134
|
+
key, content: key, source: 'review', importance: 0.5, origin: 'model', fileAnchors: [{ path, contentHash: `h:${path}` }],
|
|
135
|
+
});
|
|
136
|
+
const g = buildGraph({
|
|
137
|
+
rootId: ROOT, packs: [DOCS_PACK],
|
|
138
|
+
extracted: [extractedOf(fileNode('a.md')), extractedOf(fileNode('b.md'))],
|
|
139
|
+
facts: [fact('claim:a', 'a.md'), fact('claim:b', 'b.md')],
|
|
140
|
+
relations: [{ from: 'fact:claim:a', to: 'fact:claim:b', kind: 'contradicts', weight: 1, origin: 'model', confidence: 0.8 }],
|
|
141
|
+
});
|
|
142
|
+
const f = g.findings.find((x) => x.kind === 'contradiction');
|
|
143
|
+
expect(f?.params).toMatchObject({ fileA: 'a.md', fileB: 'b.md', confidence: 80 });
|
|
144
|
+
expect(f?.requestKey).toBe('knowledgeGraph.fix.contradiction');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('docs extract — links and sections', () => {
|
|
149
|
+
const ctx: ExtractContext = { rootId: ROOT, knownKeys: new Map(), resolvePath: resolveRelativePath };
|
|
150
|
+
const extract = (path: string, text: string) => {
|
|
151
|
+
const src: SourceDocument = asPathSource({ id: path, tenantId: 't', content: { kind: 'text', text } }, path, `h:${path}`);
|
|
152
|
+
return markdownParser.extract!(src, markdownParser.parse(src), ctx);
|
|
153
|
+
};
|
|
154
|
+
const links = (ex: ReturnType<typeof extract>) => ex.edges.filter((e) => e.kind === 'links').map((e) => e.to as NodeRef);
|
|
155
|
+
|
|
156
|
+
it('extracts reference-style links and keeps out-of-root targets as broken', () => {
|
|
157
|
+
const ex = extract('one.md', '# One\nSee [the guide][g] and [up](../outside.md).\n\n[g]: docs/guide.md\n');
|
|
158
|
+
expect(links(ex).sort()).toEqual([ref('../outside.md'), ref('docs/guide.md')].sort());
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('makes text before the first heading a section, but not front matter alone', () => {
|
|
162
|
+
const pre = extract('p.md', 'Intro before any heading.\n# H\nbody\n');
|
|
163
|
+
expect(pre.nodes.some((n) => n.ref === `${ref('p.md')}#~preamble`)).toBe(true);
|
|
164
|
+
const fm = extract('f.md', '---\ntitle: T\n---\n# H\nbody\n');
|
|
165
|
+
expect(fm.nodes.some((n) => n.ref.endsWith('#body'))).toBe(false);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
|
|
10
10
|
import { hashText } from '../ingest/hash.js';
|
|
11
|
-
import {
|
|
12
|
-
import type { Extracted, JudgementRequest, KnowledgeStore, ReviewArgs, StoredFact, StoredRelation } from './model.js';
|
|
11
|
+
import type { JudgementRequest, KnowledgeStore, ReviewArgs, StoredFact, StoredRelation } from './model.js';
|
|
13
12
|
import { DOCS_PACK } from './packs/docs.js';
|
|
14
13
|
import { planReview } from './plan.js';
|
|
15
14
|
import { assertStoredBatch, reviewDirectory } from './review.js';
|
|
16
|
-
import { fakeJudge, memSource, memStore, ROOT, type SpySource } from './testkit.test-util.js';
|
|
15
|
+
import { fakeJudge, graphOf, memSource, memStore, ROOT, type SpySource } from './testkit.test-util.js';
|
|
17
16
|
|
|
18
17
|
const BUDGET = { modelCalls: 200, ms: 60_000 };
|
|
19
18
|
|
|
@@ -21,18 +20,6 @@ function args(source: SpySource, store: KnowledgeStore, manifest: InMemoryIngest
|
|
|
21
20
|
return { source, store, manifest, packs: [DOCS_PACK], budget: BUDGET, ...extra };
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
async function graphOf(source: SpySource, store: KnowledgeStore) {
|
|
25
|
-
const extracted: Extracted[] = [];
|
|
26
|
-
for await (const f of source.list()) {
|
|
27
|
-
const hit = (await store.getExtracted!(f.hash))?.find((e) => e.sourceRef === `src:${ROOT}::${f.path}`);
|
|
28
|
-
if (hit) extracted.push(hit);
|
|
29
|
-
}
|
|
30
|
-
return buildGraph({
|
|
31
|
-
rootId: ROOT, extracted, packs: [DOCS_PACK],
|
|
32
|
-
facts: await store.facts({ rootId: ROOT }), relations: await store.relations({ rootId: ROOT }),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
23
|
const anchoredTo = (facts: StoredFact[], path: string) => facts.filter((f) => f.fileAnchors.some((a) => a.path === path));
|
|
37
24
|
|
|
38
25
|
describe('planReview', () => {
|
package/src/knowledge/review.ts
CHANGED
|
@@ -5,33 +5,33 @@
|
|
|
5
5
|
* plan (walk + manifest diff) → per changed file: read · parse (the ONE ParserRegistry,
|
|
6
6
|
* composed from the packs) · extract (cached by content hash) · judge (changed sections
|
|
7
7
|
* of judged kinds, within budget) · write · markStale → analyzers → compare near-duplicate
|
|
8
|
-
* claims → manifest + scope digest.
|
|
8
|
+
* claims → manifest + scope digest. Claims whose compare pairs were skipped wait in the
|
|
9
|
+
* compare manifest for *Continue*.
|
|
9
10
|
*
|
|
10
11
|
* Store judgement, compute perception: only `model` facts and relations are written —
|
|
11
12
|
* `extracted` output goes to the extracted cache, never to memory ({@link assertStoredBatch}).
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* and
|
|
13
|
+
* A file whose read throws is skipped, never retired: its knowledge and manifest hash stay
|
|
14
|
+
* as they were (`readErrors`); only a file the fresh plan no longer lists is removed.
|
|
15
|
+
* Abort is honoured between files and inside judgement; a file is written whole or not at
|
|
16
|
+
* all. A file whose sections were cut by the budget stays "changed" in the manifest, so
|
|
17
|
+
* *Continue* (the confirmed plan passed back as `args.plan`, no re-walk) judges only the
|
|
18
|
+
* sections not judged yet.
|
|
15
19
|
*/
|
|
16
20
|
|
|
17
21
|
import { hashText } from '../ingest/hash.js';
|
|
22
|
+
import type { SourceDocument } from '../ingest/types.js';
|
|
18
23
|
import { sha256Hex } from '../retrieval/knowledge-index/sha256.js';
|
|
19
|
-
import type {
|
|
20
|
-
ExtractContext, Extracted, KnowledgeParser, KnowledgeStore, NodeRef, ReviewArgs, ReviewReport, ScopeRecord,
|
|
21
|
-
StoredFact, StoredRelation,
|
|
22
|
-
} from './model.js';
|
|
23
|
-
import type { SourceDocument, ParsedSection } from '../ingest/types.js';
|
|
24
|
+
import type { NodeRef, ReviewArgs, ReviewReport, ScopeRecord, StoredFact, StoredRelation } from './model.js';
|
|
24
25
|
import { SECTION_INDEX_BADGE } from '../ingest/docsExtract.js';
|
|
25
|
-
import { planDetail } from './plan.js';
|
|
26
|
+
import { planDetail, refreshPlan } from './plan.js';
|
|
26
27
|
import {
|
|
27
|
-
|
|
28
|
-
saveManifestMap,
|
|
28
|
+
composePacks, filesManifestKey, isBinaryText, judgedManifestKey, manifestMap, saveExtractorVersion, saveManifestMap,
|
|
29
29
|
} from './sources.js';
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
} from './
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
30
|
+
import { extractFileDetailed, knownKeysOfEntities } from './extractFile.js';
|
|
31
|
+
import { DEFAULT_REVIEW_MODEL_CALLS, JudgedBatch, judgeSections, type CompareOutcome, type JudgeBudget } from './judge.js';
|
|
32
|
+
import { compareNew, pendingClaims, saveAwaiting } from './reviewCompare.js';
|
|
33
|
+
import { factsWithoutAnchor, StoredIndex } from './reviewStored.js';
|
|
34
|
+
import { canonicalJson, compareStr, srcRef } from './refs.js';
|
|
35
35
|
|
|
36
36
|
/** Throws if a batch carries `extracted` items — perception is never memory. */
|
|
37
37
|
export function assertStoredBatch(batch: { facts: readonly StoredFact[]; relations: readonly StoredRelation[] }): void {
|
|
@@ -39,66 +39,6 @@ export function assertStoredBatch(batch: { facts: readonly StoredFact[]; relatio
|
|
|
39
39
|
if (bad) throw new Error('knowledge: extracted output is never written to a KnowledgeStore');
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async function extractedFor(
|
|
43
|
-
store: KnowledgeStore, parser: KnowledgeParser, pack: string, src: SourceDocument, sections: ParsedSection[],
|
|
44
|
-
ctx: ExtractContext, hash: string,
|
|
45
|
-
): Promise<Extracted> {
|
|
46
|
-
const ref = srcRef(ctx.rootId, src.id);
|
|
47
|
-
const cached = await store.getExtracted?.(hash);
|
|
48
|
-
const hit = cached?.find((e) => e.sourceRef === ref);
|
|
49
|
-
if (hit) return hit;
|
|
50
|
-
const ex: Extracted = parser.extract
|
|
51
|
-
? { ...parser.extract(src, sections, ctx), sourceHash: hash }
|
|
52
|
-
: {
|
|
53
|
-
sourceRef: ref, sourceHash: hash, edges: [], keys: [{ ref, key: src.id }],
|
|
54
|
-
nodes: [{ ref, kind: 'file', label: basenameOf(src.id), pack, importance: 0, origin: 'extracted', sourceHash: hash }],
|
|
55
|
-
};
|
|
56
|
-
await store.putExtracted?.(hash, [...(cached ?? []).filter((e) => e.sourceRef !== ref), ex]);
|
|
57
|
-
return ex;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Stored knowledge, indexed for re-anchoring unchanged sections without a model call. */
|
|
61
|
-
class StoredIndex {
|
|
62
|
-
readonly facts: Map<string, StoredFact>;
|
|
63
|
-
private readonly from = new Map<string, StoredRelation[]>();
|
|
64
|
-
private readonly to = new Map<string, StoredRelation[]>();
|
|
65
|
-
|
|
66
|
-
constructor(facts: StoredFact[], relations: StoredRelation[]) {
|
|
67
|
-
this.facts = new Map(facts.map((f) => [f.key, f] as const));
|
|
68
|
-
for (const r of relations) {
|
|
69
|
-
if (r.origin !== 'model') continue;
|
|
70
|
-
(this.from.get(r.from) ?? this.from.set(r.from, []).get(r.from)!).push(r);
|
|
71
|
-
(this.to.get(r.to) ?? this.to.set(r.to, []).get(r.to)!).push(r);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** An unchanged section keeps its claims and mentions; they are re-anchored to the file's new hash. */
|
|
76
|
-
refresh(section: NodeRef, path: string, hash: string, batch: JudgedBatch, entities: Map<string, StoredFact>): void {
|
|
77
|
-
const reanchor = (f: StoredFact): StoredFact => ({
|
|
78
|
-
...f, fileAnchors: f.fileAnchors.map((a) => (a.path === path ? { ...a, contentHash: hash } : a)),
|
|
79
|
-
});
|
|
80
|
-
const relation = (r: StoredRelation) => batch.relation({ ...r, sourceHash: hash, staleAt: null });
|
|
81
|
-
for (const r of this.to.get(section) ?? []) {
|
|
82
|
-
if (r.kind !== 'about') continue;
|
|
83
|
-
relation(r);
|
|
84
|
-
const key = factKeyOf(r.from);
|
|
85
|
-
const fact = key && (batch.facts.get(key) ?? this.facts.get(key));
|
|
86
|
-
if (fact && fact.origin === 'model') batch.fact(reanchor(fact));
|
|
87
|
-
for (const m of this.from.get(r.from) ?? []) if (m.kind === 'mentions') relation(m);
|
|
88
|
-
}
|
|
89
|
-
for (const r of this.from.get(section) ?? []) {
|
|
90
|
-
if (r.kind !== 'mentions') continue;
|
|
91
|
-
relation(r);
|
|
92
|
-
const ent = entities.get(r.to);
|
|
93
|
-
if (ent && ent.origin === 'model') {
|
|
94
|
-
const next = reanchor(ent);
|
|
95
|
-
entities.set(r.to, next);
|
|
96
|
-
batch.fact(next);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
42
|
export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
103
43
|
const now = () => Date.now();
|
|
104
44
|
const started = now();
|
|
@@ -108,10 +48,12 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
108
48
|
const progress = (p: Parameters<NonNullable<ReviewArgs['onProgress']>>[0]) => args.onProgress?.(p);
|
|
109
49
|
const report: ReviewReport = {
|
|
110
50
|
rootId, digest: '', extracted: 0, judged: 0, unjudged: 0, invalidJudgements: 0,
|
|
111
|
-
factsWritten: 0, relationsWritten: 0, staleMarked: 0, aborted: false, durationMs: 0,
|
|
51
|
+
factsWritten: 0, relationsWritten: 0, staleMarked: 0, readErrors: 0, aborted: false, durationMs: 0,
|
|
112
52
|
};
|
|
113
53
|
|
|
114
|
-
const detail =
|
|
54
|
+
const detail = args.plan
|
|
55
|
+
? await refreshPlan(args.plan, manifest)
|
|
56
|
+
: await planDetail(source, manifest, packs, args.force ? { force: true } : {});
|
|
115
57
|
progress({ phase: 'plan', done: detail.files.length, total: detail.files.length });
|
|
116
58
|
const composed = composePacks(packs);
|
|
117
59
|
const packIds = packs.map((p) => p.id).sort(compareStr);
|
|
@@ -119,11 +61,7 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
119
61
|
const [storedFacts, storedRelations] = await Promise.all([store.facts(scope), store.relations(scope)]);
|
|
120
62
|
const stored = new StoredIndex(storedFacts, storedRelations);
|
|
121
63
|
const entities = new Map(storedFacts.filter((f) => f.key.startsWith('ent:')).map((f) => [f.key, f] as const));
|
|
122
|
-
const
|
|
123
|
-
rootId,
|
|
124
|
-
knownKeys: knownKeysOf(resolveEntities([...entities.keys()].map((k) => ({ ref: k as NodeRef, key: entityName(k) })))),
|
|
125
|
-
resolvePath: resolveRelativePath,
|
|
126
|
-
};
|
|
64
|
+
const knownKeys = knownKeysOfEntities(entities.keys());
|
|
127
65
|
const budget: JudgeBudget = {
|
|
128
66
|
modelCalls: args.budget?.modelCalls ?? DEFAULT_REVIEW_MODEL_CALLS,
|
|
129
67
|
deadline: started + (Number.isFinite(args.budget?.ms) ? args.budget.ms : Number.POSITIVE_INFINITY),
|
|
@@ -133,7 +71,8 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
133
71
|
const judgedPrior = await manifestMap(manifest, judgedManifestKey(rootId));
|
|
134
72
|
const judgedNow = new Map(judgedPrior);
|
|
135
73
|
const filesNow = new Map(detail.prior);
|
|
136
|
-
|
|
74
|
+
// Claims awaiting comparison: those a previous run could not compare, then this run's.
|
|
75
|
+
const newClaims = await pendingClaims(manifest, rootId, stored.facts);
|
|
137
76
|
|
|
138
77
|
const write = async (withScope: ScopeRecord = scopeRecord) => {
|
|
139
78
|
const out = batch.take();
|
|
@@ -144,20 +83,51 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
144
83
|
report.relationsWritten += out.relations.length;
|
|
145
84
|
};
|
|
146
85
|
|
|
86
|
+
// A source that is gone: its knowledge goes stale at no hash, its judged sections are forgotten, and
|
|
87
|
+
// facts other sources still back drop its anchor. `rewritten` is the run's one record of such facts,
|
|
88
|
+
// so a later retire() never restores an anchor an earlier one dropped.
|
|
89
|
+
const rewritten = new Map<string, StoredFact>();
|
|
90
|
+
const retire = async (paths: readonly string[]) => {
|
|
91
|
+
const live = new Map([...stored.facts, ...entities, ...rewritten]);
|
|
92
|
+
for (const path of paths) {
|
|
93
|
+
await store.markStale(scope, srcRef(rootId, path), '');
|
|
94
|
+
report.staleMarked += 1;
|
|
95
|
+
filesNow.delete(path);
|
|
96
|
+
const sectionPrefix = `${srcRef(rootId, path)}#`;
|
|
97
|
+
for (const section of [...judgedNow.keys()]) if (section.startsWith(sectionPrefix)) judgedNow.delete(section);
|
|
98
|
+
for (const fact of factsWithoutAnchor(live.values(), path)) {
|
|
99
|
+
batch.fact(fact);
|
|
100
|
+
live.set(fact.key, fact);
|
|
101
|
+
rewritten.set(fact.key, fact);
|
|
102
|
+
if (entities.has(fact.key)) entities.set(fact.key, fact);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
await write();
|
|
106
|
+
};
|
|
107
|
+
|
|
147
108
|
const changed = detail.files.filter((f) => f.changed);
|
|
148
109
|
for (const [i, f] of changed.entries()) {
|
|
149
110
|
if (signal?.aborted) { report.aborted = true; break; }
|
|
150
111
|
progress({ phase: 'extract', done: i, total: changed.length, path: f.path });
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
112
|
+
// A read that throws (permissions, a lock, a race with a delete) says nothing about the file:
|
|
113
|
+
// skipped with its knowledge and manifest hash intact, tried again next review.
|
|
114
|
+
let doc: SourceDocument;
|
|
115
|
+
try { doc = await source.read(f.path); } catch { report.readErrors += 1; continue; }
|
|
116
|
+
// Recorded, so a file found binary on read is not re-read by every later review.
|
|
117
|
+
if (doc.content.kind === 'text' && isBinaryText(doc.content.text)) {
|
|
118
|
+
filesNow.set(f.path, f.hash);
|
|
119
|
+
await store.markStale(scope, srcRef(rootId, f.path), f.hash);
|
|
120
|
+
report.staleMarked += 1;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const extraction = await extractFileDetailed({
|
|
124
|
+
rootId, path: f.path, hash: f.hash, doc, packs, store, composed, knownKeys,
|
|
125
|
+
});
|
|
126
|
+
if (!extraction) continue;
|
|
127
|
+
const { extracted: ex, sections, pack } = extraction;
|
|
158
128
|
report.extracted += 1;
|
|
159
129
|
|
|
160
|
-
const spec =
|
|
130
|
+
const spec = pack.judgement;
|
|
161
131
|
let complete = true;
|
|
162
132
|
if (spec && args.judgement && (spec.claims || spec.entities)) {
|
|
163
133
|
const kinds = new Set(spec.nodeKinds);
|
|
@@ -170,12 +140,15 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
170
140
|
else toJudge.push({ ref: node.ref, text });
|
|
171
141
|
}
|
|
172
142
|
const unjudgedBefore = batch.unjudged;
|
|
143
|
+
// Staged per file: a section counts as judged only once its facts are written,
|
|
144
|
+
// so an abort mid-file leaves it to be judged again (written whole or not at all).
|
|
145
|
+
const judgedHere = new Map<NodeRef, string>();
|
|
173
146
|
progress({ phase: 'judge', done: i, total: changed.length, path: f.path });
|
|
174
147
|
try {
|
|
175
148
|
const claims = await judgeSections({
|
|
176
|
-
port: args.judgement, pack:
|
|
149
|
+
port: args.judgement, pack: pack.id, path: f.path, fileHash: f.hash, sections: toJudge,
|
|
177
150
|
budget, batch, entities, ...(signal ? { signal } : {}),
|
|
178
|
-
onJudged: (ref) =>
|
|
151
|
+
onJudged: (ref) => judgedHere.set(ref, hashText(toJudge.find((s) => s.ref === ref)!.text)),
|
|
179
152
|
});
|
|
180
153
|
for (const c of claims) newClaims.set(c.ref, { text: c.text, hash: f.hash });
|
|
181
154
|
} catch (err) {
|
|
@@ -184,6 +157,7 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
184
157
|
report.aborted = true;
|
|
185
158
|
break;
|
|
186
159
|
}
|
|
160
|
+
for (const [ref, h] of judgedHere) judgedNow.set(ref, h);
|
|
187
161
|
complete = batch.unjudged === unjudgedBefore;
|
|
188
162
|
}
|
|
189
163
|
progress({ phase: 'write', done: i, total: changed.length, path: f.path });
|
|
@@ -194,11 +168,7 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
194
168
|
}
|
|
195
169
|
|
|
196
170
|
if (!report.aborted) {
|
|
197
|
-
|
|
198
|
-
await store.markStale(scope, srcRef(rootId, path), '');
|
|
199
|
-
report.staleMarked += 1;
|
|
200
|
-
filesNow.delete(path);
|
|
201
|
-
}
|
|
171
|
+
await retire(detail.plan.removed);
|
|
202
172
|
for (const pack of packs) {
|
|
203
173
|
if (!pack.analyzers) continue;
|
|
204
174
|
for (const ex of await pack.analyzers.analyse(rootId, signal)) {
|
|
@@ -207,27 +177,29 @@ export async function reviewDirectory(args: ReviewArgs): Promise<ReviewReport> {
|
|
|
207
177
|
}
|
|
208
178
|
}
|
|
209
179
|
progress({ phase: 'resolve', done: 0, total: newClaims.size });
|
|
210
|
-
const wantsCompare = packs.some((p) => p.judgement?.contradictions);
|
|
211
|
-
if (wantsCompare && args.judgement && args.similar && newClaims.size > 0 && budgetLeft(budget)) {
|
|
212
|
-
const pairs = await args.similar([...newClaims.keys()].sort(compareStr));
|
|
213
|
-
const claims = new Map(newClaims);
|
|
214
|
-
for (const p of pairs) {
|
|
215
|
-
for (const id of [p.a, p.b]) {
|
|
216
|
-
const fact = !claims.has(id) ? stored.facts.get(factKeyOf(id as NodeRef) ?? '') : undefined;
|
|
217
|
-
if (fact?.key.startsWith('claim:')) claims.set(id, { text: fact.content, hash: fact.fileAnchors[0]?.contentHash ?? '' });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
progress({ phase: 'judge', done: 0, total: pairs.length });
|
|
221
|
-
await compareClaims({ port: args.judgement, pairs, claims, budget, batch, ...(signal ? { signal } : {}) });
|
|
222
|
-
}
|
|
223
180
|
}
|
|
224
181
|
|
|
182
|
+
// The compare phase needs a pack asking for it AND both ports; without them nothing waits for it.
|
|
183
|
+
const canCompare = packs.some((p) => p.judgement?.contradictions) && !!args.judgement && !!args.similar;
|
|
184
|
+
let outcome: CompareOutcome | undefined;
|
|
185
|
+
if (!report.aborted && canCompare) {
|
|
186
|
+
outcome = await compareNew({
|
|
187
|
+
args, pending: newClaims, known: stored.facts, budget, batch,
|
|
188
|
+
onPairs: (total) => progress({ phase: 'judge', done: 0, total }),
|
|
189
|
+
});
|
|
190
|
+
// Aborted only if the abort landed before the last pair was compared.
|
|
191
|
+
if (outcome?.aborted) report.aborted = true;
|
|
192
|
+
}
|
|
193
|
+
await saveAwaiting(manifest, rootId, newClaims, outcome, canCompare);
|
|
194
|
+
|
|
225
195
|
report.judged = batch.judged;
|
|
226
196
|
report.unjudged = batch.unjudged;
|
|
227
197
|
report.invalidJudgements = batch.invalid;
|
|
228
198
|
report.digest = sha256Hex(canonicalJson({ rootId, packs: packIds, files: [...filesNow].sort((a, b) => compareStr(a[0], b[0])) }));
|
|
229
199
|
await saveManifestMap(manifest, filesManifestKey(rootId), filesNow);
|
|
230
200
|
await saveManifestMap(manifest, judgedManifestKey(rootId), judgedNow);
|
|
201
|
+
// Recorded only once every changed file was handled: an abort or a skipped read leaves the next review to redo them.
|
|
202
|
+
if (!report.aborted && report.readErrors === 0) await saveExtractorVersion(manifest, rootId);
|
|
231
203
|
await write(report.aborted ? scopeRecord : { ...scopeRecord, lastDigest: report.digest, lastReviewedAt: new Date(now()).toISOString() });
|
|
232
204
|
report.durationMs = now() - started;
|
|
233
205
|
progress({ phase: 'done', done: changed.length, total: changed.length });
|