@seanhogg/builderforce-memory 2026.10.53 → 2026.10.55
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/knowledge/backfillNoExtract.d.ts +2 -2
- package/dist/knowledge/backfillNoExtract.js +2 -2
- package/dist/knowledge/extractFile.d.ts.map +1 -1
- package/dist/knowledge/extractFile.js +11 -4
- package/dist/knowledge/extractFile.js.map +1 -1
- package/dist/knowledge/extractJob.d.ts +11 -0
- package/dist/knowledge/extractJob.d.ts.map +1 -1
- package/dist/knowledge/extractJob.js +10 -0
- package/dist/knowledge/extractJob.js.map +1 -1
- package/dist/knowledge/index.d.ts +1 -1
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/owedFiles.d.ts +9 -1
- package/dist/knowledge/owedFiles.d.ts.map +1 -1
- package/dist/knowledge/owedFiles.js +11 -2
- package/dist/knowledge/owedFiles.js.map +1 -1
- package/dist/knowledge/review.d.ts.map +1 -1
- package/dist/knowledge/review.js +11 -15
- package/dist/knowledge/review.js.map +1 -1
- package/dist/knowledge/reviewFailure.d.ts +39 -0
- package/dist/knowledge/reviewFailure.d.ts.map +1 -0
- package/dist/knowledge/reviewFailure.js +40 -0
- package/dist/knowledge/reviewFailure.js.map +1 -0
- package/dist/knowledge/reviewPrefetch.d.ts +2 -2
- package/dist/knowledge/reviewPrefetch.d.ts.map +1 -1
- package/dist/knowledge/reviewPrefetch.js +6 -6
- package/dist/knowledge/reviewPrefetch.js.map +1 -1
- package/package.json +3 -3
- package/src/contract/exports.snapshot.json +1 -0
- package/src/contract/regression.recheck.test.ts +290 -0
- package/src/contract/regression.review.test.ts +1 -143
- package/src/contract/types.contract.test.ts +6 -1
- package/src/knowledge/backfillNoExtract.ts +2 -2
- package/src/knowledge/extractFile.ts +6 -4
- package/src/knowledge/extractJob.ts +11 -0
- package/src/knowledge/index.ts +1 -1
- package/src/knowledge/owedFiles.ts +13 -2
- package/src/knowledge/review.ordered.test.ts +7 -3
- package/src/knowledge/review.ts +10 -10
- package/src/knowledge/reviewFailure.ts +54 -0
- package/src/knowledge/reviewPrefetch.ts +6 -6
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import type { SourceDocument } from '../ingest/types.js';
|
|
12
12
|
import type { KnowledgePack, KnowledgeStore, NodeRef, ReviewArgs } from './model.js';
|
|
13
13
|
import { type FileExtraction } from './extractFile.js';
|
|
14
|
+
import { CHANGED_SINCE_PLAN } from './extractJob.js';
|
|
14
15
|
import { type ReviewStep } from './reviewRunModel.js';
|
|
15
16
|
import { type ComposedPacks } from './sources.js';
|
|
16
17
|
/** What the prefetch stage learned about one file. `failed` and `read-error` carry why. */
|
|
@@ -50,8 +51,7 @@ export interface PrefetchContext {
|
|
|
50
51
|
}
|
|
51
52
|
/** The extract step event of a settled job. */
|
|
52
53
|
export declare function extractStepOf(path: string, job: Prefetch): ReviewStep;
|
|
53
|
-
|
|
54
|
-
export declare const CHANGED_SINCE_PLAN = "changed since plan";
|
|
54
|
+
export { CHANGED_SINCE_PLAN };
|
|
55
55
|
/** Per-job ceilings of the extract path (PRD 41 A10 rule 2). */
|
|
56
56
|
export declare const DEFAULT_READ_TIMEOUT_MS = 5000;
|
|
57
57
|
export declare const DEFAULT_EXTRACT_TIMEOUT_MS = 10000;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewPrefetch.d.ts","sourceRoot":"","sources":["../../src/knowledge/reviewPrefetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"reviewPr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AAc,CAAC;IACtB,QAAQ,EAAE,aAAa,CAAC;IACxB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAKD,+CAA+C;AAC/C,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,UAAU,CASrE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CA2D3G"}
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* holds one lane (0..width-1) and emits its `extract` step the moment it settles.
|
|
10
10
|
*/
|
|
11
11
|
import { extractFileDetailed } from './extractFile.js';
|
|
12
|
-
import { BinaryContent } from './extractJob.js';
|
|
12
|
+
import { BinaryContent, CHANGED_SINCE_PLAN, ExtractFailed } from './extractJob.js';
|
|
13
13
|
import { judgesPack } from './reviewJudge.js';
|
|
14
|
-
import { createDeadlines
|
|
14
|
+
import { createDeadlines } from './jobDeadline.js';
|
|
15
15
|
import { createModelLimiter } from './modelLimiter.js';
|
|
16
16
|
import { Lanes, reasonOf } from './reviewRunModel.js';
|
|
17
17
|
import { isBinaryText } from './sources.js';
|
|
@@ -26,8 +26,7 @@ export function extractStepOf(path, job) {
|
|
|
26
26
|
case 'extracted': return { ...base, outcome: job.extraction.cached ? 'cached' : 'ok' };
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
export const CHANGED_SINCE_PLAN = 'changed since plan';
|
|
29
|
+
export { CHANGED_SINCE_PLAN };
|
|
31
30
|
/** Per-job ceilings of the extract path (PRD 41 A10 rule 2). */
|
|
32
31
|
export const DEFAULT_READ_TIMEOUT_MS = 5_000;
|
|
33
32
|
export const DEFAULT_EXTRACT_TIMEOUT_MS = 10_000;
|
|
@@ -87,8 +86,9 @@ export function createPrefetch(c) {
|
|
|
87
86
|
catch (error) {
|
|
88
87
|
if (error instanceof BinaryContent)
|
|
89
88
|
return { kind: 'binary' };
|
|
90
|
-
//
|
|
91
|
-
|
|
89
|
+
// Transient UNLESS proven final: only the parser or extractor throwing on these bytes (ExtractFailed) is. A read, a timeout, a crashed or
|
|
90
|
+
// disposed worker, a failing store, a stop: all say nothing final about the file.
|
|
91
|
+
return { kind: 'failed', reason: reasonOf(error), ...((error instanceof ExtractFailed || error?.name === 'ExtractFailed') && !c.signal.aborted ? {} : { transient: true }) };
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
return async (f) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewPrefetch.js","sourceRoot":"","sources":["../../src/knowledge/reviewPrefetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,mBAAmB,EAAuB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"reviewPrefetch.js","sourceRoot":"","sources":["../../src/knowledge/reviewPrefetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,mBAAmB,EAAuB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB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AM,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9F,OAAO,GAAG,CAAC;IACf,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanhogg/builderforce-memory",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.55",
|
|
4
4
|
"description": "BuilderForce Agent Memory — runtime layer. SSM execution, Transformer orchestration, online distillation, enterprise RAG (ingestion pipelines, vector-store adapters, tenant/ACL-scoped hybrid retrieval), multi-agent graph orchestration, LLM telemetry and cost accounting, persistent agent memory, and token-saving agent-run memory (code maps, a prompt-cache-safe working memory, chunked transcript windowing) for BuilderForce.ai agents.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
},
|
|
118
118
|
"homepage": "https://github.com/SeanHogg/builderforce-memory/tree/main/packages/memory#readme",
|
|
119
119
|
"peerDependencies": {
|
|
120
|
-
"@seanhogg/builderforce-memory-engine": "^2026.10.
|
|
120
|
+
"@seanhogg/builderforce-memory-engine": "^2026.10.55"
|
|
121
121
|
},
|
|
122
122
|
"devDependencies": {
|
|
123
123
|
"@jest/globals": "^29.7.0",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"ts-jest": "^29.2.0",
|
|
132
132
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
133
133
|
"typescript-7": "npm:typescript@^7.0.2",
|
|
134
|
-
"@seanhogg/builderforce-memory-engine": "2026.10.
|
|
134
|
+
"@seanhogg/builderforce-memory-engine": "2026.10.55"
|
|
135
135
|
},
|
|
136
136
|
"jest": {
|
|
137
137
|
"preset": "ts-jest/presets/default-esm",
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/contract/regression.recheck.test.ts — the re-check channel between a replica and the review, each bug pinned by one test named
|
|
3
|
+
* `regression: <what broke>`: a replica that holds a file back asks the next review about its hash; the review answers only when the work is done.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { hashText } from '../ingest/hash.js';
|
|
7
|
+
import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
|
|
8
|
+
import { ExtractFailed, extractJob, type ExtractJob, type ExtractPool } from '../knowledge/extractJob.js';
|
|
9
|
+
import { CHANGED_SINCE_PLAN } from '../knowledge/reviewPrefetch.js';
|
|
10
|
+
import { DOCS_PACK } from '../knowledge/packs/docs.js';
|
|
11
|
+
import type { KnowledgePack } from '../knowledge/model.js';
|
|
12
|
+
import { reviewDirectory } from '../knowledge/review.js';
|
|
13
|
+
import { extractorManifestKey, filesManifestKey, manifestMap, saveManifestMap } from '../knowledge/sources.js';
|
|
14
|
+
import { args, memSource, memStore, ROOT, stateOf, type SpySource } from '../knowledge/testkit.test-util.js';
|
|
15
|
+
|
|
16
|
+
describe('regression: a root reviewed before binary files were recorded is settled by its next review, without reading a file', () => {
|
|
17
|
+
const text = '# A\nalpha\n';
|
|
18
|
+
|
|
19
|
+
it('regression: a binary-by-extension file the manifest names, with no stored body, gets a stored [] and no file is read', async () => {
|
|
20
|
+
const source = memSource({ 'a.md': text, 'img.png': 'x' });
|
|
21
|
+
const manifest = new InMemoryIngestManifest();
|
|
22
|
+
await saveManifestMap(manifest, filesManifestKey(ROOT), new Map([['img.png', 'imghash']]));
|
|
23
|
+
const store = memStore();
|
|
24
|
+
await reviewDirectory(args(source, store, manifest));
|
|
25
|
+
expect(await store.getExtracted('imghash')).toEqual([]);
|
|
26
|
+
expect(source.reads).not.toContain('img.png');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('regression: the review reads ONLY the files a replica asked to re-check: a NUL-binary gets [], a text file is extracted, the set is cleared', async () => {
|
|
30
|
+
const binary = 'bin\u0000ary';
|
|
31
|
+
const files = { 'blob.txt': binary, 'a.md': text, 'b.md': '# B\nbeta\n' };
|
|
32
|
+
const manifest = new InMemoryIngestManifest();
|
|
33
|
+
await reviewDirectory(args(memSource(files), memStore(), manifest));
|
|
34
|
+
const legacy = memStore(); // a root reviewed before: the manifest names the files, this store holds no bodies
|
|
35
|
+
await legacy.markRecheck([hashText(binary), hashText(text)]);
|
|
36
|
+
|
|
37
|
+
const source = memSource(files);
|
|
38
|
+
await reviewDirectory(args(source, legacy, manifest));
|
|
39
|
+
expect(new Set(source.reads)).toEqual(new Set(['blob.txt', 'a.md'])); // b.md was never named
|
|
40
|
+
expect(await legacy.getExtracted(hashText(binary))).toEqual([]);
|
|
41
|
+
expect((await legacy.getExtracted(hashText(text)))!.length).toBeGreaterThan(0);
|
|
42
|
+
expect(await legacy.getExtracted(hashText(files['b.md']))).toBeUndefined();
|
|
43
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
44
|
+
|
|
45
|
+
source.reads.length = 0;
|
|
46
|
+
await reviewDirectory(args(source, legacy, manifest)); // the set is empty now: nothing is read
|
|
47
|
+
expect(source.reads).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('regression: a re-checked hash only a SKIPPED manifest entry carries (here: ignored) is settled with [] and cleared, never left to loop', async () => {
|
|
51
|
+
const manifest = new InMemoryIngestManifest();
|
|
52
|
+
await saveManifestMap(manifest, filesManifestKey(ROOT), new Map([['skip.md', 'skiphash']]));
|
|
53
|
+
const legacy = memStore();
|
|
54
|
+
await legacy.markRecheck(['skiphash', 'gonehash']);
|
|
55
|
+
await reviewDirectory(args(memSource({ '.gitignore': 'skip.md\n', 'skip.md': '# S\nskipped\n', 'a.md': text }), legacy, manifest));
|
|
56
|
+
expect(await legacy.getExtracted('skiphash')).toEqual([]); // no review will ever extract an ignored file
|
|
57
|
+
expect(await legacy.getExtracted('gonehash')).toBeUndefined(); // carried by nothing: nothing to store
|
|
58
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('regression: a file whose read fails gets a terminal [] under the hash the manifest holds, so it is never held back forever (and a later read replaces it)', async () => {
|
|
62
|
+
const manifest = new InMemoryIngestManifest();
|
|
63
|
+
await saveManifestMap(manifest, filesManifestKey(ROOT), new Map([['locked.md', 'oldhash']]));
|
|
64
|
+
const store = memStore();
|
|
65
|
+
const inner = memSource({ 'locked.md': '# L\nlocked\n' });
|
|
66
|
+
const locked = { ...inner, read: async () => { throw new Error('EBUSY'); } };
|
|
67
|
+
const report = await reviewDirectory(args(locked as never, store, manifest));
|
|
68
|
+
expect(report.readErrors).toBe(1);
|
|
69
|
+
expect(await store.getExtracted('oldhash')).toEqual([]);
|
|
70
|
+
// The file becomes readable at a new hash: the real body is stored under it, and the terminal answer for the old hash stays harmless.
|
|
71
|
+
await reviewDirectory(args(inner, store, manifest));
|
|
72
|
+
expect((await store.getExtracted(hashText('# L\nlocked\n')))!.length).toBeGreaterThan(0);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/** A source whose `a.md` read is observed: `onRead(n)` runs on its n-th read and may throw. */
|
|
77
|
+
const watched = (onRead: (n: number) => void): SpySource => {
|
|
78
|
+
const inner = memSource({ 'a.md': text });
|
|
79
|
+
let n = 0;
|
|
80
|
+
return { ...inner, read: async (p: string) => { if (p === 'a.md') onRead(++n); return inner.read(p); } } as SpySource;
|
|
81
|
+
};
|
|
82
|
+
const legacyStore = async (manifest: InMemoryIngestManifest) => {
|
|
83
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), memStore(), manifest));
|
|
84
|
+
const legacy = memStore(); // the manifest names a.md; this store holds no body for it
|
|
85
|
+
await legacy.markRecheck([hashText(text)]);
|
|
86
|
+
return legacy;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
it('regression: a review stopped mid-way (after the backfill queued the file) keeps the re-check request and records no terminal [], and a complete one clears it', async () => {
|
|
90
|
+
const manifest = new InMemoryIngestManifest();
|
|
91
|
+
const legacy = await legacyStore(manifest);
|
|
92
|
+
const stop = new AbortController();
|
|
93
|
+
// Read 1 is the backfill's, read 2 is the review's: the run is stopped there and the read rejects.
|
|
94
|
+
const source = watched((n) => { if (n === 2) { stop.abort(); throw new Error('aborted'); } });
|
|
95
|
+
await reviewDirectory(args(source, legacy, manifest, { signal: stop.signal })).catch(() => undefined);
|
|
96
|
+
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
97
|
+
expect(await legacy.getExtracted(hashText(text))).toBeUndefined();
|
|
98
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest));
|
|
99
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
100
|
+
expect((await legacy.getExtracted(hashText(text)))!.length).toBeGreaterThan(0);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('regression: a read error at the manifest\'s own bytes keeps the request and makes the file owed; the next review stores the body', async () => {
|
|
104
|
+
const manifest = new InMemoryIngestManifest();
|
|
105
|
+
const legacy = await legacyStore(manifest);
|
|
106
|
+
const report = await reviewDirectory(args(watched(() => { throw new Error('EBUSY'); }), legacy, manifest));
|
|
107
|
+
expect(report.readErrors).toBe(1);
|
|
108
|
+
expect(await legacy.getExtracted(hashText(text))).toBeUndefined(); // not a terminal answer: the bytes may be readable next time
|
|
109
|
+
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
110
|
+
expect((await stateOf(manifest)).owed).toContain('a.md');
|
|
111
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest)); // a normal review: it is owed, so it is retried
|
|
112
|
+
expect((await legacy.getExtracted(hashText(text)))!.length).toBeGreaterThan(0);
|
|
113
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
114
|
+
expect((await stateOf(manifest)).owed).toEqual([]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('regression: a PROVEN-final extraction failure (the parser threw) at the same bytes gets a terminal [] and settles the request', async () => {
|
|
118
|
+
const manifest = new InMemoryIngestManifest();
|
|
119
|
+
const legacy = await legacyStore(manifest);
|
|
120
|
+
const exploding: ExtractPool = async () => { throw new ExtractFailed('parser exploded'); }; // proven final: the parser itself threw
|
|
121
|
+
const report = await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: exploding, deferRead: true }));
|
|
122
|
+
expect(report.extractErrors).toBe(1);
|
|
123
|
+
expect(await legacy.getExtracted(hashText(text))).toEqual([]);
|
|
124
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('regression: the body is stored BEFORE the request is cleared (a store that observes the put still sees the request)', async () => {
|
|
128
|
+
const manifest = new InMemoryIngestManifest();
|
|
129
|
+
const legacy = await legacyStore(manifest);
|
|
130
|
+
let sawRequest: boolean | undefined;
|
|
131
|
+
const put = legacy.putExtracted.bind(legacy);
|
|
132
|
+
legacy.putExtracted = async (h, e) => { sawRequest ??= await legacy.hasRecheck(h); await put(h, e); };
|
|
133
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest));
|
|
134
|
+
expect(sawRequest).toBe(true);
|
|
135
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/** The request is kept, the file is owed, and nothing terminal is stored: the failure said nothing final about the file. */
|
|
140
|
+
const expectTransient = async (legacy: ReturnType<typeof memStore>, manifest: InMemoryIngestManifest): Promise<void> => {
|
|
141
|
+
expect(await legacy.getExtracted(hashText(text))).toBeUndefined();
|
|
142
|
+
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
143
|
+
expect((await stateOf(manifest)).owed).toContain('a.md');
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
it('regression: a deferRead pool whose read fails (EBUSY) at the manifest\'s bytes is transient, not a terminal []', async () => {
|
|
147
|
+
const manifest = new InMemoryIngestManifest();
|
|
148
|
+
const legacy = await legacyStore(manifest);
|
|
149
|
+
const busy: ExtractPool = async () => { throw new Error('EBUSY: resource busy or locked'); };
|
|
150
|
+
const report = await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: busy, deferRead: true }));
|
|
151
|
+
expect(report.extractErrors).toBe(1);
|
|
152
|
+
await expectTransient(legacy, manifest);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('regression: a pool that times out (plain Error "timeout") is transient', async () => {
|
|
156
|
+
const manifest = new InMemoryIngestManifest();
|
|
157
|
+
const legacy = await legacyStore(manifest);
|
|
158
|
+
const stuck: ExtractPool = async () => { throw new Error('timeout'); };
|
|
159
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: stuck, deferRead: true }));
|
|
160
|
+
await expectTransient(legacy, manifest);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('guard: an in-thread read that does not match the planned hash (changed since plan) at the same hash is transient', async () => {
|
|
164
|
+
const manifest = new InMemoryIngestManifest();
|
|
165
|
+
const legacy = await legacyStore(manifest);
|
|
166
|
+
const drifting = { ...memSource({ 'a.md': text }), hashOf: () => 'some-other-hash' } as SpySource;
|
|
167
|
+
const report = await reviewDirectory(args(drifting, legacy, manifest));
|
|
168
|
+
expect(report.failures).toEqual([{ path: 'a.md', phase: 'extract', reason: 'changed since plan' }]);
|
|
169
|
+
await expectTransient(legacy, manifest);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('guard: an extraction past its ceiling (a slow pool under a tiny extractMs) is transient', async () => {
|
|
173
|
+
const manifest = new InMemoryIngestManifest();
|
|
174
|
+
const legacy = await legacyStore(manifest);
|
|
175
|
+
const slow: ExtractPool = () => new Promise(() => undefined);
|
|
176
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: slow, deferRead: true, timeouts: { extractMs: 5 } }));
|
|
177
|
+
await expectTransient(legacy, manifest);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('regression: the third transient failure in a row at the same hash is recorded as final, and STICKY: the file is not re-read while its bytes stand', async () => {
|
|
181
|
+
const manifest = new InMemoryIngestManifest();
|
|
182
|
+
const legacy = await legacyStore(manifest);
|
|
183
|
+
let calls = 0;
|
|
184
|
+
const busy: ExtractPool = async () => { calls += 1; throw new Error('EBUSY'); };
|
|
185
|
+
const run = () => reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: busy, deferRead: true }));
|
|
186
|
+
await run();
|
|
187
|
+
await run();
|
|
188
|
+
await expectTransient(legacy, manifest); // two in a row: still asked for
|
|
189
|
+
await run();
|
|
190
|
+
expect(await legacy.getExtracted(hashText(text))).toEqual([]); // the third: final
|
|
191
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
192
|
+
const settledAt = calls;
|
|
193
|
+
const report = await run();
|
|
194
|
+
expect(calls).toBe(settledAt); // sticky: not re-read ...
|
|
195
|
+
expect(report.failures).toEqual([]); // ... and not reported failed again
|
|
196
|
+
expect((await stateOf(manifest)).owed).toEqual([]);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('regression: a pool that rejects with "changed since plan" is transient (it was terminal before)', async () => {
|
|
200
|
+
const manifest = new InMemoryIngestManifest();
|
|
201
|
+
const legacy = await legacyStore(manifest);
|
|
202
|
+
const drifting: ExtractPool = async () => { throw new Error(CHANGED_SINCE_PLAN); };
|
|
203
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: drifting, deferRead: true }));
|
|
204
|
+
await expectTransient(legacy, manifest);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('regression: the failure count resets on a success: fail, fail, succeed, then fail, fail is still transient and `fail:a.md` is gone after the success', async () => {
|
|
208
|
+
const manifest = new InMemoryIngestManifest();
|
|
209
|
+
const source = memSource({ 'a.md': text });
|
|
210
|
+
await reviewDirectory(args(source, memStore(), manifest));
|
|
211
|
+
const busy: ExtractPool = async () => { throw new Error('EBUSY'); };
|
|
212
|
+
const reading: ExtractPool = async (job) => extractJob({ ...job, doc: await source.read(job.path) } as ExtractJob, [DOCS_PACK]);
|
|
213
|
+
const failIds = async () => ((await manifest.get(extractorManifestKey(ROOT))) ?? []).map((f) => f.id).filter((id) => id.startsWith('fail:'));
|
|
214
|
+
const withPool = (store: ReturnType<typeof memStore>, pool: ExtractPool, extra = {}) =>
|
|
215
|
+
reviewDirectory(args(source, store, manifest, { extractPool: pool, deferRead: true, ...extra }));
|
|
216
|
+
await withPool(memStore(), busy, { force: true });
|
|
217
|
+
await withPool(memStore(), busy, { force: true });
|
|
218
|
+
expect(await failIds()).toEqual(['fail:a.md']);
|
|
219
|
+
await withPool(memStore(), reading, { force: true }); // a success
|
|
220
|
+
expect(await failIds()).toEqual([]);
|
|
221
|
+
const last = memStore();
|
|
222
|
+
await withPool(last, busy, { force: true });
|
|
223
|
+
await withPool(last, busy, { force: true });
|
|
224
|
+
expect(await last.getExtracted(hashText(text))).toBeUndefined(); // two since the success: not final (it would be the fourth without the reset)
|
|
225
|
+
expect((await stateOf(manifest)).owed).toContain('a.md');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('regression: two paths share a hash; the unchanged one stays readable content, so a final failure of the other stores no [] under it and the request stays asked', async () => {
|
|
229
|
+
const manifest = new InMemoryIngestManifest();
|
|
230
|
+
await reviewDirectory(args(memSource({ 'x.md': text, 'y.md': text }), memStore(), manifest)); // both at hash H
|
|
231
|
+
const legacy = memStore();
|
|
232
|
+
await legacy.markRecheck([hashText(text)]);
|
|
233
|
+
const inner = memSource({ 'x.md': text, 'y.md': '# Y\nchanged\n' });
|
|
234
|
+
const source = { ...inner, read: async (p: string) => { if (p === 'y.md') throw new Error('EBUSY'); return inner.read(p); } } as SpySource;
|
|
235
|
+
await reviewDirectory(args(source, legacy, manifest, { only: ['y.md'] })); // y.md moved off H and cannot be read
|
|
236
|
+
expect(await legacy.getExtracted(hashText(text))).toBeUndefined();
|
|
237
|
+
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('regression: a Stop that lands during the LAST file still applies it, but retires nothing, runs no analyzers and stamps no digest', async () => {
|
|
241
|
+
const manifest = new InMemoryIngestManifest();
|
|
242
|
+
const store = memStore();
|
|
243
|
+
await reviewDirectory(args(memSource({ 'a.md': text, 'gone.md': '# G\nbye\n' }), store, manifest));
|
|
244
|
+
const stamped = (await store.scopes()).find((s) => s.rootId === ROOT)!.lastDigest;
|
|
245
|
+
const stop = new AbortController();
|
|
246
|
+
const report = await reviewDirectory(args(memSource({ 'a.md': '# A\nedited\n' }), store, manifest, {
|
|
247
|
+
signal: stop.signal, onProgress: (p) => { if (p.phase === 'write') stop.abort(); },
|
|
248
|
+
}));
|
|
249
|
+
expect(report.aborted).toBe(true);
|
|
250
|
+
expect([...(await manifestMap(manifest, filesManifestKey(ROOT))).keys()]).toContain('gone.md'); // not retired
|
|
251
|
+
expect((await store.scopes()).find((s) => s.rootId === ROOT)!.lastDigest).toBe(stamped);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('guard: a forced review whose read fails keeps the request (the backfill does not clear a changed file\'s hash)', async () => {
|
|
255
|
+
const manifest = new InMemoryIngestManifest();
|
|
256
|
+
const legacy = await legacyStore(manifest);
|
|
257
|
+
const failing = { ...memSource({ 'a.md': text }), read: async () => { throw new Error('EBUSY'); } } as SpySource;
|
|
258
|
+
await reviewDirectory(args(failing, legacy, manifest, { force: true }));
|
|
259
|
+
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('guard: a file the packs accept at plan time but not once read (job "none") is recorded as nothing-to-extract and its request is answered', async () => {
|
|
263
|
+
const picky: KnowledgePack = { ...DOCS_PACK, parsers: [{ ...DOCS_PACK.parsers[0]!, accepts: (s) => s.content.kind === 'text' && s.content.text === '' }] };
|
|
264
|
+
const manifest = new InMemoryIngestManifest();
|
|
265
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), memStore(), manifest, { packs: [picky] }));
|
|
266
|
+
const legacy = memStore();
|
|
267
|
+
await legacy.markRecheck([hashText(text)]);
|
|
268
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { packs: [picky], force: true }));
|
|
269
|
+
expect(await legacy.getExtracted(hashText(text))).toEqual([]);
|
|
270
|
+
expect(await legacy.recheckHashes()).toEqual([]);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('regression: an unchanged text file with no stored body is NOT given [] (it is "not extracted yet")', async () => {
|
|
274
|
+
const manifest = new InMemoryIngestManifest();
|
|
275
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), memStore(), manifest));
|
|
276
|
+
const legacy = memStore();
|
|
277
|
+
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest));
|
|
278
|
+
expect(await legacy.getExtracted(hashText(text))).toBeUndefined();
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('regression: a healthy root performs no extra reads on an incremental review', async () => {
|
|
282
|
+
const source = memSource({ 'a.md': text, 'blob.txt': 'bin\u0000ary' });
|
|
283
|
+
const manifest = new InMemoryIngestManifest();
|
|
284
|
+
const store = memStore();
|
|
285
|
+
await reviewDirectory(args(source, store, manifest));
|
|
286
|
+
source.reads.length = 0;
|
|
287
|
+
await reviewDirectory(args(source, store, manifest));
|
|
288
|
+
expect(source.reads).toEqual([]);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
@@ -15,7 +15,7 @@ import { planReview } from '../knowledge/plan.js';
|
|
|
15
15
|
import { srcRef } from '../knowledge/refs.js';
|
|
16
16
|
import { reviewDirectory } from '../knowledge/review.js';
|
|
17
17
|
import { applyRunEvent, failuresOf, failureTotal, REVIEW_RUN_FAILURE_CHUNK, startRun } from '../knowledge/reviewRun.js';
|
|
18
|
-
import { extractorManifestKey, filesManifestKey, judgedManifestKey, manifestMap
|
|
18
|
+
import { extractorManifestKey, filesManifestKey, judgedManifestKey, manifestMap } from '../knowledge/sources.js';
|
|
19
19
|
import {
|
|
20
20
|
ALL, args, fakeJudge, FILES, memSource, memStore, quietPack, ROOT, stateOf, type SpySource,
|
|
21
21
|
} from '../knowledge/testkit.test-util.js';
|
|
@@ -262,145 +262,3 @@ describe('regression: a file with nothing to extract is told apart from one not
|
|
|
262
262
|
expect(await store.getExtracted(hashText(text))).toEqual(before);
|
|
263
263
|
});
|
|
264
264
|
});
|
|
265
|
-
|
|
266
|
-
describe('regression: a root reviewed before binary files were recorded is settled by its next review, without reading a file', () => {
|
|
267
|
-
const text = '# A\nalpha\n';
|
|
268
|
-
|
|
269
|
-
it('regression: a binary-by-extension file the manifest names, with no stored body, gets a stored [] and no file is read', async () => {
|
|
270
|
-
const source = memSource({ 'a.md': text, 'img.png': 'x' });
|
|
271
|
-
const manifest = new InMemoryIngestManifest();
|
|
272
|
-
await saveManifestMap(manifest, filesManifestKey(ROOT), new Map([['img.png', 'imghash']]));
|
|
273
|
-
const store = memStore();
|
|
274
|
-
await reviewDirectory(args(source, store, manifest));
|
|
275
|
-
expect(await store.getExtracted('imghash')).toEqual([]);
|
|
276
|
-
expect(source.reads).not.toContain('img.png');
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it('regression: the review reads ONLY the files a replica asked to re-check: a NUL-binary gets [], a text file is extracted, the set is cleared', async () => {
|
|
280
|
-
const binary = 'bin\u0000ary';
|
|
281
|
-
const files = { 'blob.txt': binary, 'a.md': text, 'b.md': '# B\nbeta\n' };
|
|
282
|
-
const manifest = new InMemoryIngestManifest();
|
|
283
|
-
await reviewDirectory(args(memSource(files), memStore(), manifest));
|
|
284
|
-
const legacy = memStore(); // a root reviewed before: the manifest names the files, this store holds no bodies
|
|
285
|
-
await legacy.markRecheck([hashText(binary), hashText(text)]);
|
|
286
|
-
|
|
287
|
-
const source = memSource(files);
|
|
288
|
-
await reviewDirectory(args(source, legacy, manifest));
|
|
289
|
-
expect(new Set(source.reads)).toEqual(new Set(['blob.txt', 'a.md'])); // b.md was never named
|
|
290
|
-
expect(await legacy.getExtracted(hashText(binary))).toEqual([]);
|
|
291
|
-
expect((await legacy.getExtracted(hashText(text)))!.length).toBeGreaterThan(0);
|
|
292
|
-
expect(await legacy.getExtracted(hashText(files['b.md']))).toBeUndefined();
|
|
293
|
-
expect(await legacy.recheckHashes()).toEqual([]);
|
|
294
|
-
|
|
295
|
-
source.reads.length = 0;
|
|
296
|
-
await reviewDirectory(args(source, legacy, manifest)); // the set is empty now: nothing is read
|
|
297
|
-
expect(source.reads).toEqual([]);
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it('regression: a re-checked hash only a SKIPPED manifest entry carries (here: ignored) is settled with [] and cleared, never left to loop', async () => {
|
|
301
|
-
const manifest = new InMemoryIngestManifest();
|
|
302
|
-
await saveManifestMap(manifest, filesManifestKey(ROOT), new Map([['skip.md', 'skiphash']]));
|
|
303
|
-
const legacy = memStore();
|
|
304
|
-
await legacy.markRecheck(['skiphash', 'gonehash']);
|
|
305
|
-
await reviewDirectory(args(memSource({ '.gitignore': 'skip.md\n', 'skip.md': '# S\nskipped\n', 'a.md': text }), legacy, manifest));
|
|
306
|
-
expect(await legacy.getExtracted('skiphash')).toEqual([]); // no review will ever extract an ignored file
|
|
307
|
-
expect(await legacy.getExtracted('gonehash')).toBeUndefined(); // carried by nothing: nothing to store
|
|
308
|
-
expect(await legacy.recheckHashes()).toEqual([]);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('regression: a file whose read fails gets a terminal [] under the hash the manifest holds, so it is never held back forever (and a later read replaces it)', async () => {
|
|
312
|
-
const manifest = new InMemoryIngestManifest();
|
|
313
|
-
await saveManifestMap(manifest, filesManifestKey(ROOT), new Map([['locked.md', 'oldhash']]));
|
|
314
|
-
const store = memStore();
|
|
315
|
-
const inner = memSource({ 'locked.md': '# L\nlocked\n' });
|
|
316
|
-
const locked = { ...inner, read: async () => { throw new Error('EBUSY'); } };
|
|
317
|
-
const report = await reviewDirectory(args(locked as never, store, manifest));
|
|
318
|
-
expect(report.readErrors).toBe(1);
|
|
319
|
-
expect(await store.getExtracted('oldhash')).toEqual([]);
|
|
320
|
-
// The file becomes readable at a new hash: the real body is stored under it, and the terminal answer for the old hash stays harmless.
|
|
321
|
-
await reviewDirectory(args(inner, store, manifest));
|
|
322
|
-
expect((await store.getExtracted(hashText('# L\nlocked\n')))!.length).toBeGreaterThan(0);
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
/** A source whose `a.md` read is observed: `onRead(n)` runs on its n-th read and may throw. */
|
|
327
|
-
const watched = (onRead: (n: number) => void): SpySource => {
|
|
328
|
-
const inner = memSource({ 'a.md': text });
|
|
329
|
-
let n = 0;
|
|
330
|
-
return { ...inner, read: async (p: string) => { if (p === 'a.md') onRead(++n); return inner.read(p); } } as SpySource;
|
|
331
|
-
};
|
|
332
|
-
const legacyStore = async (manifest: InMemoryIngestManifest) => {
|
|
333
|
-
await reviewDirectory(args(memSource({ 'a.md': text }), memStore(), manifest));
|
|
334
|
-
const legacy = memStore(); // the manifest names a.md; this store holds no body for it
|
|
335
|
-
await legacy.markRecheck([hashText(text)]);
|
|
336
|
-
return legacy;
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
it('regression: a review stopped mid-way (after the backfill queued the file) keeps the re-check request and records no terminal [], and a complete one clears it', async () => {
|
|
340
|
-
const manifest = new InMemoryIngestManifest();
|
|
341
|
-
const legacy = await legacyStore(manifest);
|
|
342
|
-
const stop = new AbortController();
|
|
343
|
-
// Read 1 is the backfill's, read 2 is the review's: the run is stopped there and the read rejects.
|
|
344
|
-
const source = watched((n) => { if (n === 2) { stop.abort(); throw new Error('aborted'); } });
|
|
345
|
-
await reviewDirectory(args(source, legacy, manifest, { signal: stop.signal })).catch(() => undefined);
|
|
346
|
-
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
347
|
-
expect(await legacy.getExtracted(hashText(text))).toBeUndefined();
|
|
348
|
-
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest));
|
|
349
|
-
expect(await legacy.recheckHashes()).toEqual([]);
|
|
350
|
-
expect((await legacy.getExtracted(hashText(text)))!.length).toBeGreaterThan(0);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it('regression: a read error at the manifest\'s own bytes keeps the request and makes the file owed; the next review stores the body', async () => {
|
|
354
|
-
const manifest = new InMemoryIngestManifest();
|
|
355
|
-
const legacy = await legacyStore(manifest);
|
|
356
|
-
const report = await reviewDirectory(args(watched(() => { throw new Error('EBUSY'); }), legacy, manifest));
|
|
357
|
-
expect(report.readErrors).toBe(1);
|
|
358
|
-
expect(await legacy.getExtracted(hashText(text))).toBeUndefined(); // not a terminal answer: the bytes may be readable next time
|
|
359
|
-
expect(await legacy.recheckHashes()).toEqual([hashText(text)]);
|
|
360
|
-
expect((await stateOf(manifest)).owed).toContain('a.md');
|
|
361
|
-
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest)); // a normal review: it is owed, so it is retried
|
|
362
|
-
expect((await legacy.getExtracted(hashText(text)))!.length).toBeGreaterThan(0);
|
|
363
|
-
expect(await legacy.recheckHashes()).toEqual([]);
|
|
364
|
-
expect((await stateOf(manifest)).owed).toEqual([]);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('regression: a deterministic extraction failure at the same bytes gets a terminal [] and settles the request', async () => {
|
|
368
|
-
const manifest = new InMemoryIngestManifest();
|
|
369
|
-
const legacy = await legacyStore(manifest);
|
|
370
|
-
const exploding: ExtractPool = async () => { throw new Error('parse exploded'); };
|
|
371
|
-
const report = await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest, { extractPool: exploding, deferRead: true }));
|
|
372
|
-
expect(report.extractErrors).toBe(1);
|
|
373
|
-
expect(await legacy.getExtracted(hashText(text))).toEqual([]);
|
|
374
|
-
expect(await legacy.recheckHashes()).toEqual([]);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it('regression: the body is stored BEFORE the request is cleared (a store that observes the put still sees the request)', async () => {
|
|
378
|
-
const manifest = new InMemoryIngestManifest();
|
|
379
|
-
const legacy = await legacyStore(manifest);
|
|
380
|
-
let sawRequest: boolean | undefined;
|
|
381
|
-
const put = legacy.putExtracted.bind(legacy);
|
|
382
|
-
legacy.putExtracted = async (h, e) => { sawRequest ??= await legacy.hasRecheck(h); await put(h, e); };
|
|
383
|
-
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest));
|
|
384
|
-
expect(sawRequest).toBe(true);
|
|
385
|
-
expect(await legacy.recheckHashes()).toEqual([]);
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
it('regression: an unchanged text file with no stored body is NOT given [] (it is "not extracted yet")', async () => {
|
|
390
|
-
const manifest = new InMemoryIngestManifest();
|
|
391
|
-
await reviewDirectory(args(memSource({ 'a.md': text }), memStore(), manifest));
|
|
392
|
-
const legacy = memStore();
|
|
393
|
-
await reviewDirectory(args(memSource({ 'a.md': text }), legacy, manifest));
|
|
394
|
-
expect(await legacy.getExtracted(hashText(text))).toBeUndefined();
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('regression: a healthy root performs no extra reads on an incremental review', async () => {
|
|
398
|
-
const source = memSource({ 'a.md': text, 'blob.txt': 'bin\u0000ary' });
|
|
399
|
-
const manifest = new InMemoryIngestManifest();
|
|
400
|
-
const store = memStore();
|
|
401
|
-
await reviewDirectory(args(source, store, manifest));
|
|
402
|
-
source.reads.length = 0;
|
|
403
|
-
await reviewDirectory(args(source, store, manifest));
|
|
404
|
-
expect(source.reads).toEqual([]);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
OutlineFile, ReviewFailure, ReviewFailureChunks, ReviewPhase, ReviewReport, ReviewRun, ReviewRunPhase, ReviewStep, ScopeRecord,
|
|
18
18
|
StoredFact, StoredRelation, ExtractedLogPersistence, KnowledgeSnapshot, LocalSnapshotStoreOptions, SnapshotPersistence,
|
|
19
19
|
} from '../knowledge/index.js';
|
|
20
|
-
import { failuresOf, failureTotal, LocalSnapshotStore, localSnapshotStore } from '../knowledge/index.js';
|
|
20
|
+
import { ExtractFailed, failuresOf, failureTotal, LocalSnapshotStore, localSnapshotStore, type ExtractorState } from '../knowledge/index.js';
|
|
21
21
|
|
|
22
22
|
type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends (<T>() => T extends B ? 1 : 2) ? true : false;
|
|
23
23
|
type Expect<T extends true> = T;
|
|
@@ -89,6 +89,11 @@ export const jobWithNeither: ExtractJob = { ...base };
|
|
|
89
89
|
export type ExtractJob_readByPool_shape = Expect<Equal<NonNullable<Extract<ExtractJob, { readByPool: unknown }>['readByPool']>, { path: string; hash: string }>>;
|
|
90
90
|
export const resultShape = { binary: true, extracted: [anExtract], sections: someSections } satisfies ExtractJobResult;
|
|
91
91
|
export type ExtractJobResult_fields = Expect<Equal<ExtractJobResult, { binary?: true; extracted: Extracted[]; sections?: ParsedSection[] }>>;
|
|
92
|
+
// ExtractFailed: the marker of a PROVEN-final extraction failure (the parser or extractor threw); every other failure is transient.
|
|
93
|
+
export type ExtractFailed_is_an_Error = Expect<Equal<InstanceType<typeof ExtractFailed> extends Error ? true : false, true>>;
|
|
94
|
+
export type ExtractFailed_constructor = Expect<Equal<ConstructorParameters<typeof ExtractFailed>, [message: string, options?: { cause?: unknown }]>>;
|
|
95
|
+
// ExtractorState.failures: consecutive transient failures by path at one hash; optional so a hand-built state stays valid.
|
|
96
|
+
export type ExtractorState_failures = Expect<Equal<ExtractorState['failures'], ReadonlyMap<string, { hash: string; count: number }> | undefined>>;
|
|
92
97
|
|
|
93
98
|
/* ── KnowledgeStore: the port hosts implement ──────────────────────────────────────────────────────────────── */
|
|
94
99
|
export type KnowledgeStore_methods = Expect<Equal<
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* - binary by CONTENT (a NUL): unknowable without reading. A replica that holds a file back, or is told by the server that a
|
|
12
12
|
* body is missing, calls `store.markRecheck(hashes)`; the review reads ONLY the unchanged planned files with those hashes.
|
|
13
13
|
* Binary → `[]`. Anything else (text, a document) → queued for extraction this run (`changed`). A hash only a SKIPPED
|
|
14
|
-
* prior entry carries is never extracted by any review: `[]`. Hashes settled HERE are cleared here
|
|
15
|
-
* once its body
|
|
14
|
+
* prior entry carries is never extracted by any review: `[]`. Hashes settled HERE are cleared here. A queued one (or one whose read
|
|
15
|
+
* threw here) is cleared by the review only once its body is stored or a FINAL failure is recorded; a transient failure or a stop keeps the request.
|
|
16
16
|
*
|
|
17
17
|
* A healthy root has no body missing and an empty recheck set: it reads nothing and costs only in-memory lookups.
|
|
18
18
|
*/
|