@seanhogg/builderforce-memory 2026.10.48 → 2026.10.51
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 +36 -0
- package/dist/knowledge/backfillNoExtract.d.ts.map +1 -0
- package/dist/knowledge/backfillNoExtract.js +97 -0
- package/dist/knowledge/backfillNoExtract.js.map +1 -0
- package/dist/knowledge/extractFile.d.ts +5 -0
- package/dist/knowledge/extractFile.d.ts.map +1 -1
- package/dist/knowledge/extractFile.js +9 -0
- package/dist/knowledge/extractFile.js.map +1 -1
- package/dist/knowledge/findingBuilder.d.ts +18 -0
- package/dist/knowledge/findingBuilder.d.ts.map +1 -0
- package/dist/knowledge/findingBuilder.js +29 -0
- package/dist/knowledge/findingBuilder.js.map +1 -0
- package/dist/knowledge/findings.d.ts +2 -11
- package/dist/knowledge/findings.d.ts.map +1 -1
- package/dist/knowledge/findings.js +4 -22
- package/dist/knowledge/findings.js.map +1 -1
- package/dist/knowledge/godModule.d.ts +21 -0
- package/dist/knowledge/godModule.d.ts.map +1 -0
- package/dist/knowledge/godModule.js +42 -0
- package/dist/knowledge/godModule.js.map +1 -0
- package/dist/knowledge/index.d.ts +3 -1
- package/dist/knowledge/index.d.ts.map +1 -1
- package/dist/knowledge/index.js +2 -1
- package/dist/knowledge/index.js.map +1 -1
- package/dist/knowledge/model.d.ts +9 -0
- package/dist/knowledge/model.d.ts.map +1 -1
- package/dist/knowledge/modelLimiter.d.ts +2 -1
- package/dist/knowledge/modelLimiter.d.ts.map +1 -1
- package/dist/knowledge/modelLimiter.js +43 -3
- package/dist/knowledge/modelLimiter.js.map +1 -1
- package/dist/knowledge/review.d.ts.map +1 -1
- package/dist/knowledge/review.js +27 -8
- package/dist/knowledge/review.js.map +1 -1
- package/dist/knowledge/reviewPrefetch.d.ts.map +1 -1
- package/dist/knowledge/reviewPrefetch.js +7 -2
- package/dist/knowledge/reviewPrefetch.js.map +1 -1
- package/dist/knowledge/stores/localSnapshotStore.d.ts +8 -8
- package/dist/knowledge/stores/localSnapshotStore.d.ts.map +1 -1
- package/dist/knowledge/stores/localSnapshotStore.js +25 -43
- package/dist/knowledge/stores/localSnapshotStore.js.map +1 -1
- package/dist/knowledge/stores/snapshotFormat.d.ts +32 -0
- package/dist/knowledge/stores/snapshotFormat.d.ts.map +1 -0
- package/dist/knowledge/stores/snapshotFormat.js +49 -0
- package/dist/knowledge/stores/snapshotFormat.js.map +1 -0
- package/package.json +3 -3
- package/src/contract/exports.snapshot.json +4 -0
- package/src/contract/regression.review.test.ts +93 -1
- package/src/contract/regression.store.test.ts +13 -0
- package/src/contract/types.contract.test.ts +10 -6
- package/src/knowledge/backfillNoExtract.ts +84 -0
- package/src/knowledge/extractFile.ts +9 -0
- package/src/knowledge/findingBuilder.ts +37 -0
- package/src/knowledge/findings.ts +4 -27
- package/src/knowledge/godModule.test.ts +64 -0
- package/src/knowledge/godModule.ts +46 -0
- package/src/knowledge/index.ts +3 -1
- package/src/knowledge/model.ts +9 -0
- package/src/knowledge/modelLimiter.test.ts +35 -0
- package/src/knowledge/modelLimiter.ts +36 -3
- package/src/knowledge/pack/pack.roundtrip.test.ts +1 -1
- package/src/knowledge/review.readAhead.test.ts +97 -0
- package/src/knowledge/review.ts +27 -7
- package/src/knowledge/reviewPrefetch.ts +5 -2
- package/src/knowledge/stores/localSnapshotStore.ts +23 -60
- package/src/knowledge/stores/snapshotFormat.ts +69 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/knowledge/godModule.test.ts — the `god-module` finding: measures beside limits, omitted when
|
|
3
|
+
* the badge is absent, stable id, deterministic order.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { computeFindings, findingId } from './findings.js';
|
|
7
|
+
import { GOD_MODULE_LIMITS, godModuleFindings } from './godModule.js';
|
|
8
|
+
import type { KNode, KnowledgeGraph } from './model.js';
|
|
9
|
+
|
|
10
|
+
function fileNode(ref: string, badges: Record<string, number | string>, kind = 'file'): KNode {
|
|
11
|
+
return { ref, kind, label: ref, pack: 'code', importance: 0, origin: 'extracted' as KNode['origin'], badges };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function graph(nodes: KNode[]): KnowledgeGraph {
|
|
15
|
+
return {
|
|
16
|
+
scope: { rootId: 'r', packs: ['code'], digest: 'd' }, nodes, edges: [], findings: [],
|
|
17
|
+
stats: { sources: nodes.length, nodes: nodes.length, edges: 0, stale: 0, truncated: false },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('GOD_MODULE_LIMITS', () => {
|
|
22
|
+
it('is frozen at the documented limits', () => {
|
|
23
|
+
expect(GOD_MODULE_LIMITS).toEqual({ lines: 1000, exports: 40, complexity: 60 });
|
|
24
|
+
expect(Object.isFrozen(GOD_MODULE_LIMITS)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('godModuleFindings', () => {
|
|
29
|
+
it('regression: a file with the god-module badge yields a heuristic-sized warn finding with measures and limits', () => {
|
|
30
|
+
const g = graph([fileNode('src:r::big.ts', { patterns: 'adapter,god-module', lines: 1500, exports: 12, maxComplexity: 70 })]);
|
|
31
|
+
const found = godModuleFindings(g);
|
|
32
|
+
expect(found).toHaveLength(1);
|
|
33
|
+
expect(found[0]).toMatchObject({
|
|
34
|
+
kind: 'god-module', pack: 'code', severity: 'warn', nodes: ['src:r::big.ts'], requestKey: 'knowledgeGraph.fix.godModule',
|
|
35
|
+
params: { lines: 1500, exports: 12, complexity: 70, linesLimit: 1000, exportsLimit: 40, complexityLimit: 60 },
|
|
36
|
+
});
|
|
37
|
+
expect(found[0]!.id).toBe(findingId('god-module', ['src:r::big.ts']));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('omits a measure whose badge is absent, never the limits', () => {
|
|
41
|
+
const [f] = godModuleFindings(graph([fileNode('src:r::old.ts', { patterns: 'god-module', exports: 55 })]));
|
|
42
|
+
expect(f!.params).toEqual({ exports: 55, linesLimit: 1000, exportsLimit: 40, complexityLimit: 60 });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('ignores files without the badge, a lookalike pattern id and non-file nodes', () => {
|
|
46
|
+
const g = graph([
|
|
47
|
+
fileNode('src:r::a.ts', { patterns: 'adapter' }),
|
|
48
|
+
fileNode('src:r::b.ts', { patterns: 'not-god-module-ish' }),
|
|
49
|
+
fileNode('src:r::c.ts', { patterns: 'god-module' }, 'symbol'),
|
|
50
|
+
]);
|
|
51
|
+
expect(godModuleFindings(g)).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('is part of computeFindings, in a deterministic order', () => {
|
|
55
|
+
const g = graph([
|
|
56
|
+
fileNode('src:r::z.ts', { patterns: 'god-module' }),
|
|
57
|
+
fileNode('src:r::a.ts', { patterns: 'god-module' }),
|
|
58
|
+
]);
|
|
59
|
+
const a = computeFindings(g, [], new Map(), []).filter((f) => f.kind === 'god-module');
|
|
60
|
+
const b = computeFindings({ ...g, nodes: [...g.nodes].reverse() }, [], new Map(), []).filter((f) => f.kind === 'god-module');
|
|
61
|
+
expect(a).toHaveLength(2);
|
|
62
|
+
expect(a.map((f) => f.id)).toEqual(b.map((f) => f.id));
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knowledge/godModule.ts — the `god-module` finding: one per file node whose `patterns` badge
|
|
3
|
+
* names `god-module`, carrying the measures that tripped it next to the limits they are held to.
|
|
4
|
+
*
|
|
5
|
+
* Memory owns the limits ({@link GOD_MODULE_LIMITS}); the code pack's detector imports them, so the
|
|
6
|
+
* badge and the finding can never disagree. The measures are read from the file's badges
|
|
7
|
+
* (`lines`, `exports`, `maxComplexity`); a measure is omitted when its badge is absent (a graph
|
|
8
|
+
* reviewed before that badge existed). Heuristic by nature: it is a size/shape guess, never a model.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Finding, KnowledgeGraph } from './model.js';
|
|
12
|
+
import { finding } from './findingBuilder.js';
|
|
13
|
+
import { compareStr } from './refs.js';
|
|
14
|
+
|
|
15
|
+
/** What a file may grow to before it is a god module: more lines, exports or worst-function complexity than this. */
|
|
16
|
+
export const GOD_MODULE_LIMITS = Object.freeze({ lines: 1_000, exports: 40, complexity: 60 } as const);
|
|
17
|
+
export type GodModuleLimits = typeof GOD_MODULE_LIMITS;
|
|
18
|
+
|
|
19
|
+
/** The finding kind (also the pattern id in the `patterns` badge). */
|
|
20
|
+
export const GOD_MODULE_KIND = 'god-module';
|
|
21
|
+
|
|
22
|
+
const PATTERNS_BADGE = 'patterns';
|
|
23
|
+
const MEASURE_BADGES = { lines: 'lines', exports: 'exports', complexity: 'maxComplexity' } as const;
|
|
24
|
+
|
|
25
|
+
const numberOf = (v: unknown): number | undefined => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
|
|
26
|
+
|
|
27
|
+
export function godModuleFindings(g: KnowledgeGraph): Finding[] {
|
|
28
|
+
const out: Finding[] = [];
|
|
29
|
+
for (const n of [...g.nodes].sort((a, b) => compareStr(a.ref, b.ref))) {
|
|
30
|
+
if (n.kind !== 'file') continue;
|
|
31
|
+
const patterns = n.badges?.[PATTERNS_BADGE];
|
|
32
|
+
if (typeof patterns !== 'string' || !patterns.split(',').includes(GOD_MODULE_KIND)) continue;
|
|
33
|
+
const params: Record<string, number> = {};
|
|
34
|
+
for (const [key, badge] of Object.entries(MEASURE_BADGES)) {
|
|
35
|
+
const value = numberOf(n.badges?.[badge]);
|
|
36
|
+
if (value !== undefined) params[key] = value;
|
|
37
|
+
}
|
|
38
|
+
out.push(finding(GOD_MODULE_KIND, n.pack, [n.ref], 'warn', {
|
|
39
|
+
...params,
|
|
40
|
+
linesLimit: GOD_MODULE_LIMITS.lines,
|
|
41
|
+
exportsLimit: GOD_MODULE_LIMITS.exports,
|
|
42
|
+
complexityLimit: GOD_MODULE_LIMITS.complexity,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
package/src/knowledge/index.ts
CHANGED
|
@@ -34,6 +34,8 @@ export type { LanedTrace, TraceOptions } from './trace.js';
|
|
|
34
34
|
export {
|
|
35
35
|
computeFindings, genericFindings, finding, findingId, partitionSeverity, requestKeyFor, components, CLONE_GROUP_BADGE, MAX_FINDING_NODES,
|
|
36
36
|
} from './findings.js';
|
|
37
|
+
export { GOD_MODULE_LIMITS, GOD_MODULE_KIND, godModuleFindings } from './godModule.js';
|
|
38
|
+
export type { GodModuleLimits } from './godModule.js';
|
|
37
39
|
export {
|
|
38
40
|
resolveEntities, knownKeysOf, possibleSameFindings, normalizeKey, entityName, entityKey,
|
|
39
41
|
} from './resolve.js';
|
|
@@ -49,7 +51,7 @@ export { extractFile, extractFileDetailed, knownKeysOfEntities } from './extract
|
|
|
49
51
|
export type { ExtractFileArgs, FileExtraction } from './extractFile.js';
|
|
50
52
|
export { extractJob, jobOf } from './extractJob.js';
|
|
51
53
|
export type { ExtractJob, ExtractJobResult, ExtractPool } from './extractJob.js';
|
|
52
|
-
export { putExtract } from './extractFile.js';
|
|
54
|
+
export { putExtract, putNoExtract } from './extractFile.js';
|
|
53
55
|
export { createModelLimiter, isRateLimit } from './modelLimiter.js';
|
|
54
56
|
export type { ModelLimiter } from './modelLimiter.js';
|
|
55
57
|
export { reasonOf } from './reviewRunModel.js';
|
package/src/knowledge/model.ts
CHANGED
|
@@ -224,6 +224,15 @@ export interface KnowledgeStore {
|
|
|
224
224
|
* Only a hint: `getExtracted` stays correct without it, and a failure propagates like any store failure.
|
|
225
225
|
*/
|
|
226
226
|
preloadExtracted?(hashes: readonly string[]): Promise<void>;
|
|
227
|
+
/**
|
|
228
|
+
* The re-check channel between a replica and the review, through the one store both already share: a replica that
|
|
229
|
+
* is asked for the body of a hash it holds none of calls `markRecheck(hashes)`; the next review reads ONLY the
|
|
230
|
+
* manifest files with those hashes (binary → an explicit `[]`, text → extracted), then `clearRecheck`s them. A store
|
|
231
|
+
* that cannot persist the set keeps it in memory. Optional like the cache methods; a store without them has no channel.
|
|
232
|
+
*/
|
|
233
|
+
markRecheck?(hashes: readonly string[]): Promise<void>;
|
|
234
|
+
recheckHashes?(): Promise<string[]>;
|
|
235
|
+
clearRecheck?(hashes: readonly string[]): Promise<void>;
|
|
227
236
|
/**
|
|
228
237
|
* Runs `work` as one unit of many mutations. Inside it the store may hold persistence back
|
|
229
238
|
* (a whole-snapshot store would otherwise rewrite everything per mutation); `flush` makes
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* nothing starts once the signal has aborted.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { jest } from '@jest/globals';
|
|
7
8
|
import { createModelLimiter, isRateLimit } from './modelLimiter.js';
|
|
8
9
|
|
|
9
10
|
const rateLimited = () => Object.assign(new Error('429 rate limited'), { status: 429 });
|
|
@@ -66,3 +67,37 @@ describe('isRateLimit', () => {
|
|
|
66
67
|
expect(isRateLimit(null)).toBe(false);
|
|
67
68
|
});
|
|
68
69
|
});
|
|
70
|
+
|
|
71
|
+
describe('createModelLimiter: abort of queued calls', () => {
|
|
72
|
+
it('regression: a queued call rejects at the abort while slot holders still run, and holders finish normally', async () => {
|
|
73
|
+
const limiter = createModelLimiter(2);
|
|
74
|
+
const ctl = new AbortController();
|
|
75
|
+
const release: Array<() => void> = [];
|
|
76
|
+
const holders = [0, 1].map((i) => limiter.run(() => new Promise<string>((r) => { release.push(() => r(`held${i}`)); }), ctl.signal));
|
|
77
|
+
const queued = limiter.run(ok, ctl.signal);
|
|
78
|
+
const rejected = expect(queued).rejects.toThrow('stop');
|
|
79
|
+
ctl.abort(new Error('stop'));
|
|
80
|
+
await rejected;
|
|
81
|
+
release.forEach((r) => r());
|
|
82
|
+
await expect(Promise.all(holders)).resolves.toEqual(['held0', 'held1']);
|
|
83
|
+
// Slots were released exactly once: a new call still runs.
|
|
84
|
+
await expect(limiter.run(ok)).resolves.toBe('ok');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('regression: 500 queued calls on one signal add exactly one abort listener', async () => {
|
|
88
|
+
const limiter = createModelLimiter(1);
|
|
89
|
+
const ctl = new AbortController();
|
|
90
|
+
const add = jest.spyOn(ctl.signal, 'addEventListener');
|
|
91
|
+
const remove = jest.spyOn(ctl.signal, 'removeEventListener');
|
|
92
|
+
let free!: () => void;
|
|
93
|
+
const holder = limiter.run(() => new Promise<string>((r) => { free = () => r('done'); }), ctl.signal);
|
|
94
|
+
const queued = Array.from({ length: 500 }, () => limiter.run(ok, ctl.signal));
|
|
95
|
+
const settled = queued.map((q) => q.then(() => 'ran', () => 'rejected'));
|
|
96
|
+
// The slot holder's listener is dropped when it starts; the 500 waiters share ONE live listener.
|
|
97
|
+
expect(add.mock.calls.length - remove.mock.calls.length).toBe(1);
|
|
98
|
+
ctl.abort(new Error('stop'));
|
|
99
|
+
expect((await Promise.all(settled)).every((s) => s === 'rejected')).toBe(true);
|
|
100
|
+
free();
|
|
101
|
+
await expect(holder).resolves.toBe('done');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* AIMD: a rate-limit answer halves the width (minimum 1); every `growEvery` successful calls grow it
|
|
6
6
|
* by 1, back up to the cap. Waiting calls start in order; one whose signal has aborted is rejected
|
|
7
|
-
* instead of started, so nothing starts after an abort.
|
|
7
|
+
* instead of started, so nothing starts after an abort. A queued call is rejected AT the abort, through ONE
|
|
8
|
+
* listener per distinct signal (not per waiter); a call already holding a slot is never rejected by it.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
export interface ModelLimiter {
|
|
@@ -30,10 +31,20 @@ export function createModelLimiter(max: number, opts: { growEvery?: number } = {
|
|
|
30
31
|
let active = 0;
|
|
31
32
|
let successes = 0;
|
|
32
33
|
const waiting: Waiter[] = [];
|
|
34
|
+
// ONE abort listener per distinct signal, however many calls are queued on it.
|
|
35
|
+
const queuedBySignal = new Map<AbortSignal, { waiters: Set<Waiter>; onAbort: () => void }>();
|
|
36
|
+
|
|
37
|
+
const unqueue = (w: Waiter): void => {
|
|
38
|
+
const s = w.signal && queuedBySignal.get(w.signal);
|
|
39
|
+
if (!s || !w.signal) return;
|
|
40
|
+
s.waiters.delete(w);
|
|
41
|
+
if (s.waiters.size === 0) { w.signal.removeEventListener('abort', s.onAbort); queuedBySignal.delete(w.signal); }
|
|
42
|
+
};
|
|
33
43
|
|
|
34
44
|
const pump = () => {
|
|
35
45
|
while (active < width && waiting.length > 0) {
|
|
36
46
|
const w = waiting.shift()!;
|
|
47
|
+
unqueue(w);
|
|
37
48
|
if (w.signal?.aborted) { w.reject(w.signal.reason ?? new Error('aborted')); continue; }
|
|
38
49
|
active += 1;
|
|
39
50
|
w.start();
|
|
@@ -45,7 +56,9 @@ export function createModelLimiter(max: number, opts: { growEvery?: number } = {
|
|
|
45
56
|
max: cap,
|
|
46
57
|
run<T>(fn: () => Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
47
58
|
return new Promise<T>((resolve, reject) => {
|
|
48
|
-
|
|
59
|
+
// A queued call whose signal aborts is rejected AT ONCE (not when its turn comes), so a stopped run drains its queue immediately.
|
|
60
|
+
if (signal?.aborted) { reject(signal.reason ?? new Error('aborted')); return; }
|
|
61
|
+
const w: Waiter = {
|
|
49
62
|
signal, reject,
|
|
50
63
|
start: () => {
|
|
51
64
|
(async () => fn())().then(
|
|
@@ -60,7 +73,27 @@ export function createModelLimiter(max: number, opts: { growEvery?: number } = {
|
|
|
60
73
|
},
|
|
61
74
|
).finally(() => { active -= 1; pump(); });
|
|
62
75
|
},
|
|
63
|
-
}
|
|
76
|
+
};
|
|
77
|
+
if (signal) {
|
|
78
|
+
let entry = queuedBySignal.get(signal);
|
|
79
|
+
if (!entry) {
|
|
80
|
+
const waiters = new Set<Waiter>();
|
|
81
|
+
const onAbort = (): void => {
|
|
82
|
+
queuedBySignal.delete(signal);
|
|
83
|
+
for (const q of waiters) {
|
|
84
|
+
const at = waiting.indexOf(q);
|
|
85
|
+
if (at >= 0) waiting.splice(at, 1);
|
|
86
|
+
q.reject(signal.reason ?? new Error('aborted'));
|
|
87
|
+
}
|
|
88
|
+
waiters.clear();
|
|
89
|
+
};
|
|
90
|
+
entry = { waiters, onAbort };
|
|
91
|
+
queuedBySignal.set(signal, entry);
|
|
92
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
93
|
+
}
|
|
94
|
+
entry.waiters.add(w);
|
|
95
|
+
}
|
|
96
|
+
waiting.push(w);
|
|
64
97
|
pump();
|
|
65
98
|
});
|
|
66
99
|
},
|
|
@@ -41,7 +41,7 @@ describe('BFKP round trip', () => {
|
|
|
41
41
|
|
|
42
42
|
it('round-trips awkward numbers exactly', async () => {
|
|
43
43
|
const g = genPack(1, { files: 1 });
|
|
44
|
-
g.facts = [0, 1, 0.5, 1e-9, 0.1234567, 2 ** 40, 1e15 + 0.5, 123456789.
|
|
44
|
+
g.facts = [0, 1, 0.5, 1e-9, 0.1234567, 2 ** 40, 1e15 + 0.5, 123456789.12345679].map((importance, i) => ({
|
|
45
45
|
key: `k${i}`, content: 'c', source: 's', importance, origin: 'model' as const, fileAnchors: [],
|
|
46
46
|
}));
|
|
47
47
|
const back = await decodePack(await encodePack(g));
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/knowledge/review.readAhead.test.ts
|
|
3
|
+
* A pool that reads files itself runs a wide read-ahead window, so one slow head file does not stall the
|
|
4
|
+
* other workers; and Stop settles the review at once however many jobs are queued behind the slot limiter.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { jest } from '@jest/globals';
|
|
8
|
+
import { InMemoryIngestManifest } from '../ingest/IngestionPipeline.js';
|
|
9
|
+
import { extractJob, type ExtractJob, type ExtractPool } from './extractJob.js';
|
|
10
|
+
import { DOCS_PACK } from './packs/docs.js';
|
|
11
|
+
import { reviewDirectory } from './review.js';
|
|
12
|
+
import { LocalSnapshotStore } from './stores/localSnapshotStore.js';
|
|
13
|
+
import { args, fakeJudge, memPersistence, memSource } from './testkit.test-util.js';
|
|
14
|
+
|
|
15
|
+
const FILE_COUNT = 400;
|
|
16
|
+
const files = (): Record<string, string> =>
|
|
17
|
+
Object.fromEntries(Array.from({ length: FILE_COUNT }, (_, i) => [`d${String(i).padStart(4, '0')}.md`, `# T${i}\nbody ${i}\n`]));
|
|
18
|
+
|
|
19
|
+
/** A pool that reads the file itself (a `readByPool` job), then extracts it. */
|
|
20
|
+
function readingPool(source: ReturnType<typeof memSource>, hold: (job: ExtractJob, started: number) => Promise<void>): { pool: ExtractPool; started: () => number } {
|
|
21
|
+
let started = 0;
|
|
22
|
+
return {
|
|
23
|
+
started: () => started,
|
|
24
|
+
pool: async (job, signal) => {
|
|
25
|
+
started += 1;
|
|
26
|
+
// Like the host pool: a stopped review rejects the job with an AbortError.
|
|
27
|
+
const aborted = new Promise<never>((_, reject) => {
|
|
28
|
+
const stop = (): void => reject(Object.assign(new Error('aborted'), { name: 'AbortError' }));
|
|
29
|
+
if (signal?.aborted) stop(); else signal?.addEventListener('abort', stop, { once: true });
|
|
30
|
+
});
|
|
31
|
+
aborted.catch(() => undefined);
|
|
32
|
+
await Promise.race([hold(job, started), aborted]);
|
|
33
|
+
const doc = await source.read(job.readByPool!.path);
|
|
34
|
+
const { readByPool: _drop, ...rest } = job;
|
|
35
|
+
return extractJob({ ...rest, doc } as ExtractJob, [DOCS_PACK]);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('read-ahead with a pool that reads', () => {
|
|
41
|
+
afterEach(() => jest.useRealTimers());
|
|
42
|
+
|
|
43
|
+
it('regression: one slow head file does not stop the other files being extracted beyond 64 ahead', async () => {
|
|
44
|
+
const source = memSource(files());
|
|
45
|
+
const head = 'd0000.md';
|
|
46
|
+
let startedWhenHeadSettled = 0;
|
|
47
|
+
let release!: () => void;
|
|
48
|
+
const gate = new Promise<void>((r) => { release = r; });
|
|
49
|
+
const { pool, started } = readingPool(source, async (job, n) => {
|
|
50
|
+
if (job.path === head) {
|
|
51
|
+
// The head settles only once well over 64 other files have started.
|
|
52
|
+
await Promise.race([gate, new Promise<void>((r) => setTimeout(r, 500))]);
|
|
53
|
+
startedWhenHeadSettled = started();
|
|
54
|
+
} else if (n > 100) release();
|
|
55
|
+
});
|
|
56
|
+
const report = await reviewDirectory(args(source, new LocalSnapshotStore(memPersistence()), new InMemoryIngestManifest(), {
|
|
57
|
+
judgement: fakeJudge(), mechanical: true, extractPool: pool, deferRead: true, concurrency: 8,
|
|
58
|
+
}));
|
|
59
|
+
expect(report.aborted).toBe(false);
|
|
60
|
+
expect(startedWhenHeadSettled - 1).toBeGreaterThan(64);
|
|
61
|
+
}, 15_000);
|
|
62
|
+
|
|
63
|
+
it('a judging (non-mechanical) review keeps the narrow window: at most 64 files ahead of a slow head', async () => {
|
|
64
|
+
const source = memSource(files());
|
|
65
|
+
const head = 'd0000.md';
|
|
66
|
+
let startedWhenHeadSettled = 0;
|
|
67
|
+
const { pool, started } = readingPool(source, async (job) => {
|
|
68
|
+
if (job.path === head) {
|
|
69
|
+
// Hold the head long enough for the window to fill, then record how far ahead the others got.
|
|
70
|
+
await new Promise<void>((r) => setTimeout(r, 300));
|
|
71
|
+
startedWhenHeadSettled = started();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const report = await reviewDirectory(args(source, new LocalSnapshotStore(memPersistence()), new InMemoryIngestManifest(), {
|
|
75
|
+
judgement: fakeJudge(), extractPool: pool, deferRead: true, concurrency: 8,
|
|
76
|
+
}));
|
|
77
|
+
expect(report.aborted).toBe(false);
|
|
78
|
+
expect(startedWhenHeadSettled - 1).toBeLessThanOrEqual(64);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('regression: Stop settles the review at once with hundreds of jobs queued behind the slots', async () => {
|
|
82
|
+
jest.useFakeTimers();
|
|
83
|
+
const source = memSource(files());
|
|
84
|
+
const ctl = new AbortController();
|
|
85
|
+
// Every pool job hangs until its signal aborts (an AbortError, as the host pool does); queued limiter waiters must not hold up the settle.
|
|
86
|
+
const { pool, started } = readingPool(source, () => new Promise<void>(() => undefined));
|
|
87
|
+
const run = reviewDirectory(args(source, new LocalSnapshotStore(memPersistence()), new InMemoryIngestManifest(), {
|
|
88
|
+
judgement: fakeJudge(), mechanical: true, extractPool: pool, deferRead: true, concurrency: 8, signal: ctl.signal,
|
|
89
|
+
}));
|
|
90
|
+
await jest.advanceTimersByTimeAsync(50);
|
|
91
|
+
expect(started()).toBe(8);
|
|
92
|
+
ctl.abort();
|
|
93
|
+
// No timer is advanced past the 10 s extract deadline: the stop alone settles every in-flight and queued job.
|
|
94
|
+
const report = await run;
|
|
95
|
+
expect(report.aborted).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
});
|
package/src/knowledge/review.ts
CHANGED
|
@@ -31,7 +31,8 @@ import type { ReviewArgs, ReviewReport, ScopeRecord, StoredFact, StoredRelation
|
|
|
31
31
|
import { owedAfterRun, owedCalls, saveExtractorState } from './owedFiles.js';
|
|
32
32
|
import { planDetail, refreshPlan } from './plan.js';
|
|
33
33
|
import { composePacks, filesManifestKey, judgedManifestKey, manifestMap, saveManifestMap } from './sources.js';
|
|
34
|
-
import { knownKeysOfEntities, putExtract } from './extractFile.js';
|
|
34
|
+
import { knownKeysOfEntities, putExtract, putNoExtract } from './extractFile.js';
|
|
35
|
+
import { backfillCandidates, backfillNoExtract } from './backfillNoExtract.js';
|
|
35
36
|
import { prefetchOrdered } from './orderedPool.js';
|
|
36
37
|
import {
|
|
37
38
|
DEFAULT_REVIEW_CONCURRENCY, DEFAULT_REVIEW_JUDGE_CONCURRENCY, DEFAULT_REVIEW_MODEL_CALLS, JUDGE_CONCURRENCY, JudgedBatch,
|
|
@@ -46,6 +47,22 @@ import { compareNew, pendingClaims, saveAwaiting } from './reviewCompare.js';
|
|
|
46
47
|
import { factsWithoutAnchor, StoredIndex } from './reviewStored.js';
|
|
47
48
|
import { canonicalJson, compareStr, srcRef } from './refs.js';
|
|
48
49
|
|
|
50
|
+
/** Read-ahead window for a MECHANICAL review with a pool that reads files itself: wide enough to buffer finished results behind one slow head file. Real extraction width is bounded separately (the extract-slot limiter in reviewPrefetch). */
|
|
51
|
+
const POOL_READ_AHEAD_DEFAULT = 256;
|
|
52
|
+
const POOL_READ_AHEAD_MAX = 512;
|
|
53
|
+
|
|
54
|
+
/** Files read and extracted ahead of the ordered writer. */
|
|
55
|
+
function readAheadOf(args: ReviewArgs, concurrency: number): number {
|
|
56
|
+
if (!args.extractPool) return concurrency;
|
|
57
|
+
// Wide only for a mechanical pool-reads run: each settled prefetch then holds just the small extracted output.
|
|
58
|
+
// A judging review keeps each settled file's parsed sections in memory, so it keeps the narrow window.
|
|
59
|
+
if (args.deferRead && args.mechanical) {
|
|
60
|
+
const want = Math.floor(args.readAhead ?? Math.max(POOL_READ_AHEAD_DEFAULT, concurrency * 32)) || concurrency;
|
|
61
|
+
return Math.min(POOL_READ_AHEAD_MAX, Math.max(concurrency, want));
|
|
62
|
+
}
|
|
63
|
+
return Math.min(64, Math.max(concurrency, Math.floor(args.readAhead ?? Math.max(32, concurrency * 4)) || concurrency));
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
/** One changed file between dispatch and the ordered writer: what its prefetch found and its judging in flight. */
|
|
50
67
|
interface Slot {
|
|
51
68
|
f: { path: string; hash: string };
|
|
@@ -102,6 +119,13 @@ async function reviewRun(args: ReviewArgs, flush: () => Promise<void>): Promise<
|
|
|
102
119
|
const judgedPrior = await manifestMap(manifest, judgedManifestKey(rootId));
|
|
103
120
|
const judgedNow = new Map(judgedPrior);
|
|
104
121
|
const filesNow = new Map(detail.prior);
|
|
122
|
+
// A root reviewed before binary files were recorded: settle files with no body: binary-by-extension ones (no read), and the ones a replica asked to re-check.
|
|
123
|
+
const asked = (await store.recheckHashes?.()) ?? [];
|
|
124
|
+
// ONE bulk fetch of the extract cache for the whole run instead of a round trip per file: the files this run extracts and the ones the backfill looks up.
|
|
125
|
+
const preChanged = detail.files.filter((f) => f.changed && (!args.only || args.only.includes(f.path)));
|
|
126
|
+
const preload = [...new Set([...preChanged.map((f) => f.hash), ...backfillCandidates(detail, asked)])];
|
|
127
|
+
if (preload.length > 0) await store.preloadExtracted?.(preload);
|
|
128
|
+
await backfillNoExtract({ store, source, detail, asked, only: args.only, signal });
|
|
105
129
|
// Claims awaiting comparison: those a previous run could not compare, then this run's.
|
|
106
130
|
const newClaims = await pendingClaims(manifest, rootId, stored.facts);
|
|
107
131
|
|
|
@@ -145,17 +169,12 @@ async function reviewRun(args: ReviewArgs, flush: () => Promise<void>): Promise<
|
|
|
145
169
|
// at the model calls it still costs where this run could measure that (see owedFiles.ts).
|
|
146
170
|
const finished = new Set<string>();
|
|
147
171
|
const measured = new Map<string, number>();
|
|
148
|
-
// One bulk fetch of the extract cache for the whole run instead of a round trip per file.
|
|
149
|
-
const hashes = [...new Set(work.map((f) => f.hash))];
|
|
150
|
-
if (hashes.length > 0) await store.preloadExtracted?.(hashes);
|
|
151
172
|
// Read + binary check + extract run ahead with bounded concurrency (extraction only reads `knownKeys`,
|
|
152
173
|
// fixed above, and the content-hash extract cache); with `args.extractPool` the width is the pool's.
|
|
153
174
|
// Judging runs `judgeWidth` files at once; ONE writer (`applyFile`) consumes them strictly in plan order.
|
|
154
175
|
const concurrency = Math.min(32, Math.max(1, Math.floor(args.concurrency ?? DEFAULT_REVIEW_CONCURRENCY) || 1));
|
|
155
176
|
// Read-ahead is wider than the pool (PRD 41 A10 rule 8) so workers never wait for the ordered writer.
|
|
156
|
-
const readAhead = args
|
|
157
|
-
? Math.min(64, Math.max(concurrency, Math.floor(args.readAhead ?? Math.max(32, concurrency * 4)) || concurrency))
|
|
158
|
-
: concurrency;
|
|
177
|
+
const readAhead = readAheadOf(args, concurrency);
|
|
159
178
|
const judgeWidth = Math.min(concurrency, Math.min(16, Math.max(1, Math.floor(args.judgeConcurrency ?? DEFAULT_REVIEW_JUDGE_CONCURRENCY) || 1)));
|
|
160
179
|
// The run's own stop: the caller's abort relays into it, and a thrown error (a local store failure) aborts it,
|
|
161
180
|
// so queued and in-flight judge calls and pool jobs stop and nothing outlives the run.
|
|
@@ -195,6 +214,7 @@ async function reviewRun(args: ReviewArgs, flush: () => Promise<void>): Promise<
|
|
|
195
214
|
if (job.kind === 'binary') {
|
|
196
215
|
filesNow.set(f.path, f.hash);
|
|
197
216
|
finished.add(f.path);
|
|
217
|
+
await putNoExtract(store, f.hash); // the explicit "nothing extracted", so a replica can tell it from "not extracted yet"
|
|
198
218
|
await store.markStale(scope, srcRef(rootId, f.path), f.hash);
|
|
199
219
|
report.staleMarked += 1;
|
|
200
220
|
return true;
|
|
@@ -78,6 +78,8 @@ export function createPrefetch(c: PrefetchContext): (f: { path: string; hash: st
|
|
|
78
78
|
const byPool = !!c.args.extractPool && !!c.args.deferRead;
|
|
79
79
|
|
|
80
80
|
const run = async (f: { path: string; hash: string }, parts: NonNullable<ReviewStep['parts']>, held: { lane: number }): Promise<Outcome> => {
|
|
81
|
+
// A stopped run starts nothing: a job that has not begun settles at once. Once the read has begun the job finishes (its slot wait below is signal-free for a file already read).
|
|
82
|
+
if (c.signal.aborted) return { kind: 'failed', reason: reasonOf(c.signal.reason) };
|
|
81
83
|
let doc: SourceDocument | undefined;
|
|
82
84
|
const t0 = Date.now();
|
|
83
85
|
if (!byPool) {
|
|
@@ -96,7 +98,7 @@ export function createPrefetch(c: PrefetchContext): (f: { path: string; hash: st
|
|
|
96
98
|
onTiming: (t) => { parts.lookupMs = t.lookupMs; parts.poolMs = t.poolMs; },
|
|
97
99
|
...(c.args.extractPool ? { pool: c.args.extractPool, signal, wantsSections, ...(byPool ? { readByPool: true } : {}) } : {}),
|
|
98
100
|
})); } finally { lanes.free(held.lane); }
|
|
99
|
-
});
|
|
101
|
+
}, byPool ? c.signal : undefined);
|
|
100
102
|
if (!extraction) return { kind: 'none' };
|
|
101
103
|
// Binary and no-pack files are decided above and never hash-checked (as in the host worker). For a file that WILL be
|
|
102
104
|
// stored, the bytes read must be the bytes planned: hashed once, from the text already in hand. The review writes the
|
|
@@ -116,7 +118,8 @@ export function createPrefetch(c: PrefetchContext): (f: { path: string; hash: st
|
|
|
116
118
|
const held = { lane: 0 };
|
|
117
119
|
const out = await run(f, parts, held);
|
|
118
120
|
const job = { ...out, ms: Date.now() - t0, lane: held.lane, parts } as Prefetch;
|
|
119
|
-
|
|
121
|
+
// A job that ended only because the run was stopped is not a failed file: one Stop must not emit hundreds of failed steps. A job that finished normally still reports.
|
|
122
|
+
if (!(c.signal.aborted && job.kind === 'failed')) c.args.onStep?.(extractStepOf(f.path, job));
|
|
120
123
|
return job;
|
|
121
124
|
};
|
|
122
125
|
}
|
|
@@ -22,6 +22,9 @@ import type {
|
|
|
22
22
|
Extracted, KnowledgeStore, NodeRef, Scope, ScopeRecord, StoredFact, StoredRelation,
|
|
23
23
|
} from '../model.js';
|
|
24
24
|
import { canonicalJson, compareStr, pathOfRef } from '../refs.js';
|
|
25
|
+
import { emptySnapshot, parse, parseLog, type KnowledgeSnapshot, type ParsedLog } from './snapshotFormat.js';
|
|
26
|
+
|
|
27
|
+
export type { KnowledgeSnapshot } from './snapshotFormat.js';
|
|
25
28
|
|
|
26
29
|
export interface SnapshotPersistence {
|
|
27
30
|
read(): Promise<string | undefined>;
|
|
@@ -42,15 +45,6 @@ export interface ExtractedLogPersistence {
|
|
|
42
45
|
replace?(text: string): Promise<void>;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
export interface KnowledgeSnapshot {
|
|
46
|
-
version: 1;
|
|
47
|
-
scopes: ScopeRecord[];
|
|
48
|
-
facts: Record<string, StoredFact[]>;
|
|
49
|
-
relations: Record<string, StoredRelation[]>;
|
|
50
|
-
/** Present only when the store has no `extractedLog` (or in a snapshot written before the log existed). */
|
|
51
|
-
extracted?: Record<string, Extracted[]>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
48
|
export interface LocalSnapshotStoreOptions {
|
|
55
49
|
/** When given, the extract cache lives in this log and the snapshot omits `extracted`. */
|
|
56
50
|
extractedLog?: ExtractedLogPersistence;
|
|
@@ -64,57 +58,6 @@ export interface LocalSnapshotStoreOptions {
|
|
|
64
58
|
|
|
65
59
|
const relKey = (r: Pick<StoredRelation, 'from' | 'to' | 'kind'>) => `${r.from}\u0000${r.to}\u0000${r.kind}`;
|
|
66
60
|
|
|
67
|
-
function asRecord<T>(v: unknown): Record<string, T[]> {
|
|
68
|
-
return v && typeof v === 'object' && !Array.isArray(v) ? v as Record<string, T[]> : {};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const emptySnapshot = (): KnowledgeSnapshot => ({ version: 1, scopes: [], facts: {}, relations: {} });
|
|
72
|
-
|
|
73
|
-
/** Reads a snapshot's text. THROWS when it does not parse, so the caller can keep the bytes aside before starting empty. */
|
|
74
|
-
function parse(text: string | undefined): KnowledgeSnapshot {
|
|
75
|
-
if (!text) return emptySnapshot();
|
|
76
|
-
const s = JSON.parse(text) as Partial<KnowledgeSnapshot>;
|
|
77
|
-
return {
|
|
78
|
-
version: 1,
|
|
79
|
-
scopes: Array.isArray(s.scopes) ? s.scopes : [],
|
|
80
|
-
facts: asRecord(s.facts),
|
|
81
|
-
relations: asRecord(s.relations),
|
|
82
|
-
...(s.extracted && typeof s.extracted === 'object' ? { extracted: s.extracted } : {}),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface ParsedLog {
|
|
87
|
-
entries: Map<string, Extracted[]>;
|
|
88
|
-
/** The live (last) line of each hash, newline-terminated, in log order. */
|
|
89
|
-
liveLines: Map<string, string>;
|
|
90
|
-
liveBytes: number;
|
|
91
|
-
/** Superseded lines, torn lines and blank lines. */
|
|
92
|
-
deadBytes: number;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The log's entries, last line per hash winning. A line that does not parse (torn by a crash or a failed
|
|
97
|
-
* append) is skipped on its own: it never costs the other lines.
|
|
98
|
-
*/
|
|
99
|
-
function parseLog(text: string | undefined): ParsedLog {
|
|
100
|
-
const out: ParsedLog = { entries: new Map(), liveLines: new Map(), liveBytes: 0, deadBytes: 0 };
|
|
101
|
-
if (!text) return out;
|
|
102
|
-
for (const line of text.split('\n')) {
|
|
103
|
-
if (!line.trim()) continue;
|
|
104
|
-
try {
|
|
105
|
-
const row = JSON.parse(line) as { h?: unknown; e?: unknown };
|
|
106
|
-
if (typeof row.h === 'string' && Array.isArray(row.e)) {
|
|
107
|
-
out.entries.set(row.h, row.e as Extracted[]);
|
|
108
|
-
out.liveLines.delete(row.h); // re-set below so the map stays in log order of last occurrence
|
|
109
|
-
out.liveLines.set(row.h, `${line}\n`);
|
|
110
|
-
}
|
|
111
|
-
} catch { /* torn line */ }
|
|
112
|
-
}
|
|
113
|
-
for (const l of out.liveLines.values()) out.liveBytes += l.length;
|
|
114
|
-
out.deadBytes = Math.max(0, text.length - out.liveBytes);
|
|
115
|
-
return out;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
61
|
type Index = Map<string, Set<string>>;
|
|
119
62
|
|
|
120
63
|
export class LocalSnapshotStore implements KnowledgeStore {
|
|
@@ -127,6 +70,8 @@ export class LocalSnapshotStore implements KnowledgeStore {
|
|
|
127
70
|
/** Per root: source path → keys of the relations touching it (`from` or `to`). */
|
|
128
71
|
private readonly relByPath = new Map<string, Index>();
|
|
129
72
|
private readonly extracted = new Map<string, Extracted[]>();
|
|
73
|
+
/** Hashes the next review re-checks (persisted with the snapshot). */
|
|
74
|
+
private readonly recheck = new Set<string>();
|
|
130
75
|
/** Extract entries not yet appended to the log. */
|
|
131
76
|
private pending = new Map<string, Extracted[]>();
|
|
132
77
|
/** The log's last line is torn (no newline), so the next append starts on a fresh line. */
|
|
@@ -173,6 +118,7 @@ export class LocalSnapshotStore implements KnowledgeStore {
|
|
|
173
118
|
}
|
|
174
119
|
const logText = this.log ? await this.log.read() : undefined;
|
|
175
120
|
this.scopeList = snap.scopes;
|
|
121
|
+
for (const h of snap.recheck ?? []) this.recheck.add(h);
|
|
176
122
|
for (const [rootId, rows] of Object.entries(snap.facts)) {
|
|
177
123
|
const m = this.factsOf(rootId);
|
|
178
124
|
if (Array.isArray(rows)) for (const f of rows) m.set(f.key, f);
|
|
@@ -387,6 +333,22 @@ export class LocalSnapshotStore implements KnowledgeStore {
|
|
|
387
333
|
return this.extracted.get(hash);
|
|
388
334
|
}
|
|
389
335
|
|
|
336
|
+
/** Asks the next review to re-check the files with these content hashes (persisted until {@link clearRecheck}). */
|
|
337
|
+
markRecheck(hashes: readonly string[]): Promise<void> {
|
|
338
|
+
// The snapshot is dirty only when the set really changed (a repeated mark costs no write).
|
|
339
|
+
return this.mutate(() => { for (const h of hashes) if (!this.recheck.has(h)) { this.recheck.add(h); this.dirty = true; } }, false);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async recheckHashes(): Promise<string[]> {
|
|
343
|
+
await this.load();
|
|
344
|
+
return [...this.recheck].sort(compareStr);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** Forgets hashes a review has handled. */
|
|
348
|
+
clearRecheck(hashes: readonly string[]): Promise<void> {
|
|
349
|
+
return this.mutate(() => { for (const h of hashes) if (this.recheck.delete(h)) this.dirty = true; }, false);
|
|
350
|
+
}
|
|
351
|
+
|
|
390
352
|
/** Every cached entry by content hash (the log's, else the snapshot's `extracted`), for a host that packs the cache. */
|
|
391
353
|
async extractedEntries(): Promise<Record<string, Extracted[]>> {
|
|
392
354
|
await this.load();
|
|
@@ -414,6 +376,7 @@ export class LocalSnapshotStore implements KnowledgeStore {
|
|
|
414
376
|
facts: rows(this.factMaps, (a, b) => compareStr(a.key, b.key)),
|
|
415
377
|
relations: rows(this.relMaps, (a, b) => compareStr(relKey(a), relKey(b))),
|
|
416
378
|
...(this.log ? {} : { extracted: Object.fromEntries(this.extracted) }),
|
|
379
|
+
...(this.recheck.size > 0 ? { recheck: [...this.recheck].sort(compareStr) } : {}),
|
|
417
380
|
});
|
|
418
381
|
}
|
|
419
382
|
}
|