@cleocode/nexus 2026.10.12 → 2026.10.13-rc.ci.682
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/src/pipeline/call-processor.d.ts +9 -5
- package/dist/src/pipeline/call-processor.d.ts.map +1 -1
- package/dist/src/pipeline/call-processor.js +76 -78
- package/dist/src/pipeline/call-processor.js.map +1 -1
- package/dist/src/pipeline/index.d.ts +8 -3
- package/dist/src/pipeline/index.d.ts.map +1 -1
- package/dist/src/pipeline/index.js +50 -39
- package/dist/src/pipeline/index.js.map +1 -1
- package/dist/src/pipeline/knowledge-graph.d.ts +14 -2
- package/dist/src/pipeline/knowledge-graph.d.ts.map +1 -1
- package/dist/src/pipeline/knowledge-graph.js +79 -45
- package/dist/src/pipeline/knowledge-graph.js.map +1 -1
- package/dist/src/pipeline/parse-cache.d.ts +72 -1
- package/dist/src/pipeline/parse-cache.d.ts.map +1 -1
- package/dist/src/pipeline/parse-cache.js +138 -28
- package/dist/src/pipeline/parse-cache.js.map +1 -1
- package/dist/src/pipeline/parse-loop.d.ts +19 -13
- package/dist/src/pipeline/parse-loop.d.ts.map +1 -1
- package/dist/src/pipeline/parse-loop.js +50 -55
- package/dist/src/pipeline/parse-loop.js.map +1 -1
- package/dist/src/pipeline/processors/access-processor.d.ts +7 -2
- package/dist/src/pipeline/processors/access-processor.d.ts.map +1 -1
- package/dist/src/pipeline/processors/access-processor.js +41 -14
- package/dist/src/pipeline/processors/access-processor.js.map +1 -1
- package/dist/src/pipeline/reference-spool.d.ts +43 -0
- package/dist/src/pipeline/reference-spool.d.ts.map +1 -0
- package/dist/src/pipeline/reference-spool.js +69 -0
- package/dist/src/pipeline/reference-spool.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @task T532
|
|
19
19
|
* @module pipeline/knowledge-graph
|
|
20
20
|
*/
|
|
21
|
-
import type { GraphNode, GraphPublicationRows, GraphRelation } from '@cleocode/contracts';
|
|
21
|
+
import type { GraphNode, GraphPublicationRows, GraphRelation, NexusNodeInsertRow, NexusRelationInsertRow } from '@cleocode/contracts';
|
|
22
22
|
import type { Column } from 'drizzle-orm';
|
|
23
23
|
/**
|
|
24
24
|
* Minimal Drizzle-like insert interface required by `KnowledgeGraph.flush()`.
|
|
@@ -85,9 +85,21 @@ export interface KnowledgeGraph {
|
|
|
85
85
|
* @param tables - Table references ({ nexusNodes, nexusRelations })
|
|
86
86
|
*/
|
|
87
87
|
/** Serialize and validate the staged generation before opening a write transaction. */
|
|
88
|
-
preparePublication():
|
|
88
|
+
preparePublication(): EagerPublicationRows;
|
|
89
|
+
/**
|
|
90
|
+
* Validate the staged generation now and serialize its rows lazily, as the
|
|
91
|
+
* publisher consumes them: the graph is never held twice (T13656). Seals the
|
|
92
|
+
* graph: a later {@link KnowledgeGraph.addRelation} throws, since its dedup
|
|
93
|
+
* keys are released and the rows already handed out would not include it.
|
|
94
|
+
*/
|
|
95
|
+
streamPublication(): GraphPublicationRows;
|
|
89
96
|
flush(projectId: string, db: NexusDbInsert, tables: NexusTables): Promise<void>;
|
|
90
97
|
}
|
|
98
|
+
/** Publication rows built up front, for callers that inspect them. */
|
|
99
|
+
export type EagerPublicationRows = GraphPublicationRows & {
|
|
100
|
+
nodes: NexusNodeInsertRow[];
|
|
101
|
+
relations: NexusRelationInsertRow[];
|
|
102
|
+
};
|
|
91
103
|
/**
|
|
92
104
|
* Create a new empty KnowledgeGraph.
|
|
93
105
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-graph.d.ts","sourceRoot":"","sources":["../../../src/pipeline/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EACpB,aAAa,
|
|
1
|
+
{"version":3,"file":"know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AE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjF;AAED,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GAAG;IACxD,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAsJrD"}
|
|
@@ -40,19 +40,27 @@ export function createKnowledgeGraph() {
|
|
|
40
40
|
const relations = [];
|
|
41
41
|
/** Dedup set for relations: `${source}::${target}::${type}` */
|
|
42
42
|
const relationKeys = new Set();
|
|
43
|
+
/** Set by {@link streamPublication}; the graph accepts no relation afterwards. */
|
|
44
|
+
let sealed = false;
|
|
43
45
|
function addNode(node) {
|
|
44
46
|
if (!nodes.has(node.id)) {
|
|
45
47
|
nodes.set(node.id, node);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
function canonicalEndpoint(id) {
|
|
49
|
-
|
|
51
|
+
// The node's own id string, so relations share it rather than hold copies (T13656).
|
|
52
|
+
const node = nodes.get(id);
|
|
53
|
+
if (node)
|
|
54
|
+
return node.id;
|
|
55
|
+
if (!id.endsWith('::__file__'))
|
|
50
56
|
return id;
|
|
51
57
|
const filePath = id.slice(0, -'::__file__'.length);
|
|
52
58
|
const file = nodes.get(filePath);
|
|
53
59
|
return file?.kind === 'file' && file.filePath === filePath ? filePath : id;
|
|
54
60
|
}
|
|
55
61
|
function addRelation(rel) {
|
|
62
|
+
if (sealed)
|
|
63
|
+
throw new Error('Knowledge graph is sealed for publication; no relation can be added');
|
|
56
64
|
rel = { ...rel, source: canonicalEndpoint(rel.source), target: canonicalEndpoint(rel.target) };
|
|
57
65
|
const key = `${rel.source}::${rel.target}::${rel.type}`;
|
|
58
66
|
if (!relationKeys.has(key)) {
|
|
@@ -60,49 +68,46 @@ export function createKnowledgeGraph() {
|
|
|
60
68
|
relations.push(rel);
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
indexedAt: now,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
71
|
+
function nodeRow(node, now) {
|
|
72
|
+
// ADR-090 · T11648 — no `projectId`.
|
|
73
|
+
return {
|
|
74
|
+
id: node.id,
|
|
75
|
+
kind: node.kind,
|
|
76
|
+
label: node.name || node.id,
|
|
77
|
+
name: node.name || null,
|
|
78
|
+
filePath: node.filePath || null,
|
|
79
|
+
startLine: node.startLine ?? null,
|
|
80
|
+
endLine: node.endLine ?? null,
|
|
81
|
+
language: node.language || null,
|
|
82
|
+
isExported: node.exported ?? false,
|
|
83
|
+
parentId: node.parent ?? null,
|
|
84
|
+
parametersJson: node.parameters ? JSON.stringify(node.parameters) : null,
|
|
85
|
+
returnType: node.returnType ?? null,
|
|
86
|
+
docSummary: node.docSummary ?? null,
|
|
87
|
+
communityId: node.communityId ?? null,
|
|
88
|
+
metaJson: node.meta || node.isExternal !== undefined
|
|
89
|
+
? JSON.stringify({
|
|
90
|
+
...node.meta,
|
|
91
|
+
...(node.isExternal !== undefined ? { isExternal: node.isExternal } : {}),
|
|
92
|
+
})
|
|
93
|
+
: null,
|
|
94
|
+
indexedAt: now,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function relationRow(rel, now) {
|
|
98
|
+
return {
|
|
99
|
+
id: randomUUID(),
|
|
100
|
+
sourceId: rel.source,
|
|
101
|
+
targetId: rel.target,
|
|
102
|
+
type: rel.type,
|
|
103
|
+
confidence: rel.confidence,
|
|
104
|
+
reason: rel.reason ?? null,
|
|
105
|
+
step: null,
|
|
106
|
+
indexedAt: now,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Validate the staged generation; returns the shared row timestamp. */
|
|
110
|
+
function validate() {
|
|
106
111
|
for (const relation of relations) {
|
|
107
112
|
if (!nodes.has(relation.source) || !nodes.has(relation.target)) {
|
|
108
113
|
throw new Error(`Invalid graph relationship: ${relation.source} -> ${relation.target}`);
|
|
@@ -113,7 +118,35 @@ export function createKnowledgeGraph() {
|
|
|
113
118
|
throw new Error(`Invalid graph confidence: ${relation.source} -> ${relation.target}`);
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
|
-
return
|
|
121
|
+
return new Date().toISOString();
|
|
122
|
+
}
|
|
123
|
+
function preparePublication() {
|
|
124
|
+
const now = validate();
|
|
125
|
+
return {
|
|
126
|
+
nodes: [...nodes.values()].map((node) => nodeRow(node, now)),
|
|
127
|
+
relations: relations.map((rel) => relationRow(rel, now)),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function streamPublication() {
|
|
131
|
+
const now = validate();
|
|
132
|
+
// The dedup keys (one string per relation) would otherwise be held beside
|
|
133
|
+
// the rows; releasing them is why the graph is sealed (T13656).
|
|
134
|
+
sealed = true;
|
|
135
|
+
relationKeys.clear();
|
|
136
|
+
return {
|
|
137
|
+
nodes: {
|
|
138
|
+
*[Symbol.iterator]() {
|
|
139
|
+
for (const node of nodes.values())
|
|
140
|
+
yield nodeRow(node, now);
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
relations: {
|
|
144
|
+
*[Symbol.iterator]() {
|
|
145
|
+
for (const rel of relations)
|
|
146
|
+
yield relationRow(rel, now);
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
117
150
|
}
|
|
118
151
|
async function flush(_projectId, db, tables) {
|
|
119
152
|
const { nodes: nodeRows, relations: relationRows } = preparePublication();
|
|
@@ -139,6 +172,7 @@ export function createKnowledgeGraph() {
|
|
|
139
172
|
addRelation,
|
|
140
173
|
flush,
|
|
141
174
|
preparePublication,
|
|
175
|
+
streamPublication,
|
|
142
176
|
};
|
|
143
177
|
}
|
|
144
178
|
//# sourceMappingURL=knowledge-graph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-graph.js","sourceRoot":"","sources":["../../../src/pipeline/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsDzC,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAE9E,yEAAyE;AACzE,kFAAkF;AAClF,+DAA+D;AAE/D,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E,+EAA+E;AAC/E,MAAM,UAAU,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"knowledge-graph.js","sourceRoot":"","sources":["../../../src/pipeline/knowledge-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAsDzC,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAE9E,yEAAyE;AACzE,kFAAkF;AAClF,+DAA+D;AAE/D,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E,+EAA+E;AAC/E,MAAM,UAAU,GAAG,GAAG,CAAC;AA6CvB;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC3C,MAAM,SAA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,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;YAChD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC;YACzE,CAAC;QACH,CAAC;QAED,yBAAyB;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC;YACzD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC;YACpD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC;YAC7E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK;QACL,SAAS;QACT,OAAO;QACP,WAAW;QACX,KAAK;QACL,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -47,6 +47,20 @@ export interface FileExtraction {
|
|
|
47
47
|
* (the caller must then refuse to reuse any entry).
|
|
48
48
|
*/
|
|
49
49
|
export declare function computeExtractorFingerprint(): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Replace every string reachable from `value` with one canonical instance.
|
|
52
|
+
*
|
|
53
|
+
* A result that crosses a process boundary arrives as JSON, and `JSON.parse`
|
|
54
|
+
* materialises each occurrence of a string separately: the 64-character
|
|
55
|
+
* generation hash, file path, source id and lexical reason repeated on every
|
|
56
|
+
* call and access record. Measured over 5 098 files of a real repository, the
|
|
57
|
+
* received extractions retained 806 MiB against 498 MiB for the same objects
|
|
58
|
+
* built in-process; sharing the strings brought them to 397 MiB (T13325).
|
|
59
|
+
*
|
|
60
|
+
* @param value - Freshly received JSON data, mutated in place.
|
|
61
|
+
* @param pool - Canonical strings for the current parse.
|
|
62
|
+
*/
|
|
63
|
+
export declare function internStrings(value: object, pool: Map<string, string>): void;
|
|
50
64
|
/**
|
|
51
65
|
* Encode a freshly parsed extraction for storage.
|
|
52
66
|
*
|
|
@@ -60,13 +74,70 @@ export declare function computeExtractorFingerprint(): string | null;
|
|
|
60
74
|
* @returns A cache entry ready for atomic publication.
|
|
61
75
|
*/
|
|
62
76
|
export declare function encodeParseCacheEntry(file: FileExtraction, contentHash: string, fingerprint: string, generation: string): GraphParseCacheEntry;
|
|
77
|
+
/** Extraction fields a resolution phase reads one file at a time (T13656). */
|
|
78
|
+
export type ExtractionSites = 'calls' | 'accesses';
|
|
79
|
+
/** Everything but the sites: what the parse-loop merge consumes. */
|
|
80
|
+
export type ExtractionHead = Omit<Required<CommonExtractionResult>, ExtractionSites>;
|
|
81
|
+
/**
|
|
82
|
+
* Compress one file's extraction into its parse-cache payload form.
|
|
83
|
+
*
|
|
84
|
+
* The payload frames three gzip sections — head, calls, accesses — behind a
|
|
85
|
+
* table of their byte lengths, so each phase decodes only the section it
|
|
86
|
+
* reads. The parse loop holds every file in this form between parsing and
|
|
87
|
+
* resolution (T13656): compressed bytes outside the V8 heap.
|
|
88
|
+
*
|
|
89
|
+
* @param extraction - The complete per-file extraction.
|
|
90
|
+
* @returns The framed payload.
|
|
91
|
+
*/
|
|
92
|
+
export declare function encodeExtraction(extraction: Required<CommonExtractionResult>): Uint8Array;
|
|
93
|
+
/**
|
|
94
|
+
* Decode the head of a payload written by {@link encodeExtraction}.
|
|
95
|
+
*
|
|
96
|
+
* @param payload - Framed extraction.
|
|
97
|
+
* @param strings - Canonical strings for this decode (see {@link internStrings}).
|
|
98
|
+
* @param from - Generation embedded in the payload, rewritten to `to` when they differ.
|
|
99
|
+
* @param to - Publication generation of the run decoding it.
|
|
100
|
+
* @returns Declarations, imports, heritage, re-exports and parse limitations.
|
|
101
|
+
* @throws When the payload is not a decodable extraction.
|
|
102
|
+
*/
|
|
103
|
+
export declare function decodeExtractionHead(payload: Uint8Array, strings?: Map<string, string>, from?: string, to?: string): ExtractionHead;
|
|
104
|
+
/**
|
|
105
|
+
* Decode one site section of a payload written by {@link encodeExtraction}.
|
|
106
|
+
*
|
|
107
|
+
* Not interned: resolution reads each record once and keeps nothing of it but
|
|
108
|
+
* strings the graph already holds (relation endpoints resolve to node ids).
|
|
109
|
+
*
|
|
110
|
+
* @param payload - Framed extraction.
|
|
111
|
+
* @param sites - Which section to decode.
|
|
112
|
+
* @param from - Generation embedded in the payload, rewritten to `to` when they differ.
|
|
113
|
+
* @param to - Publication generation of the run decoding it.
|
|
114
|
+
* @returns The section's records.
|
|
115
|
+
* @throws When the section is not a decodable record array.
|
|
116
|
+
*/
|
|
117
|
+
export declare function decodeExtractionSites<K extends ExtractionSites>(payload: Uint8Array, sites: K, from?: string, to?: string): Required<CommonExtractionResult>[K];
|
|
118
|
+
/**
|
|
119
|
+
* Decode a whole payload written by {@link encodeExtraction}.
|
|
120
|
+
*
|
|
121
|
+
* @param payload - Framed extraction.
|
|
122
|
+
* @param strings - Canonical strings for the head (see {@link internStrings}).
|
|
123
|
+
* @param from - Generation embedded in the payload, rewritten to `to` when they differ.
|
|
124
|
+
* @param to - Publication generation of the run decoding it.
|
|
125
|
+
* @returns The extraction with every per-file array present.
|
|
126
|
+
* @throws When the payload is not a decodable extraction.
|
|
127
|
+
*/
|
|
128
|
+
export declare function decodeExtraction(payload: Uint8Array, strings?: Map<string, string>, from?: string, to?: string): Required<CommonExtractionResult>;
|
|
63
129
|
/**
|
|
64
130
|
* Decode a stored extraction and rebind it to the current publication generation.
|
|
65
131
|
*
|
|
132
|
+
* Strings are interned into `strings`: a bare `JSON.parse` materialises each
|
|
133
|
+
* repeated path, scope id and generation separately, twice the heap of the
|
|
134
|
+
* same objects built in-process (T13325).
|
|
135
|
+
*
|
|
66
136
|
* @param entry - Stored cache entry.
|
|
67
137
|
* @param generation - The publication generation of the run reusing it.
|
|
138
|
+
* @param strings - Canonical strings for this decode.
|
|
68
139
|
* @returns The extraction exactly as re-parsing the same bytes under `generation` would produce.
|
|
69
140
|
* @throws When the payload is not a decodable extraction; callers treat that file as changed.
|
|
70
141
|
*/
|
|
71
|
-
export declare function decodeParseCacheEntry(entry: GraphParseCacheEntry, generation: string): FileExtraction;
|
|
142
|
+
export declare function decodeParseCacheEntry(entry: GraphParseCacheEntry, generation: string, strings?: Map<string, string>): FileExtraction;
|
|
72
143
|
//# sourceMappingURL=parse-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cache.d.ts","sourceRoot":"","sources":["../../../src/pipeline/parse-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAQH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC;CAC9C;AAsCD;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,GAAG,IAAI,CAmC3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,cAAc,EACpB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,oBAAoB,CAQtB;AAED
|
|
1
|
+
{"version":3,"file":"parse-cache.d.ts","sourceRoot":"","sources":["../../../src/pipeline/parse-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAQH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;A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EACb,EAAE,CAAC,EAAE,MAAM,GACV,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAIrC;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,EACxC,IAAI,CAAC,EAAE,MAAM,EACb,EAAE,CAAC,EAAE,MAAM,GACV,QAAQ,CAAC,sBAAsB,CAAC,CAMlC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,oBAAoB,EAC3B,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,GACvC,cAAc,CAMhB"}
|
|
@@ -31,7 +31,7 @@ import { gunzipSync, gzipSync } from 'node:zlib';
|
|
|
31
31
|
* Serialization format version. Bump when the payload encoding (not the
|
|
32
32
|
* extractor) changes; extractor changes are caught by the fingerprint.
|
|
33
33
|
*/
|
|
34
|
-
const PAYLOAD_FORMAT = 'nexus-parse-cache/
|
|
34
|
+
const PAYLOAD_FORMAT = 'nexus-parse-cache/v2';
|
|
35
35
|
/** Grammar packages whose native behaviour determines extraction output. */
|
|
36
36
|
const GRAMMAR_PACKAGES = [
|
|
37
37
|
'tree-sitter',
|
|
@@ -106,6 +106,38 @@ export function computeExtractorFingerprint() {
|
|
|
106
106
|
}
|
|
107
107
|
return cachedFingerprint;
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Replace every string reachable from `value` with one canonical instance.
|
|
111
|
+
*
|
|
112
|
+
* A result that crosses a process boundary arrives as JSON, and `JSON.parse`
|
|
113
|
+
* materialises each occurrence of a string separately: the 64-character
|
|
114
|
+
* generation hash, file path, source id and lexical reason repeated on every
|
|
115
|
+
* call and access record. Measured over 5 098 files of a real repository, the
|
|
116
|
+
* received extractions retained 806 MiB against 498 MiB for the same objects
|
|
117
|
+
* built in-process; sharing the strings brought them to 397 MiB (T13325).
|
|
118
|
+
*
|
|
119
|
+
* @param value - Freshly received JSON data, mutated in place.
|
|
120
|
+
* @param pool - Canonical strings for the current parse.
|
|
121
|
+
*/
|
|
122
|
+
export function internStrings(value, pool) {
|
|
123
|
+
const canonical = (text) => {
|
|
124
|
+
const known = pool.get(text);
|
|
125
|
+
if (known !== undefined)
|
|
126
|
+
return known;
|
|
127
|
+
pool.set(text, text);
|
|
128
|
+
return text;
|
|
129
|
+
};
|
|
130
|
+
const pending = [value];
|
|
131
|
+
for (let node = pending.pop(); node !== undefined; node = pending.pop()) {
|
|
132
|
+
for (const key of Object.keys(node)) {
|
|
133
|
+
const child = Reflect.get(node, key);
|
|
134
|
+
if (typeof child === 'string')
|
|
135
|
+
Reflect.set(node, key, canonical(child));
|
|
136
|
+
else if (typeof child === 'object' && child !== null)
|
|
137
|
+
pending.push(child);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
109
141
|
/**
|
|
110
142
|
* Encode a freshly parsed extraction for storage.
|
|
111
143
|
*
|
|
@@ -124,47 +156,125 @@ export function encodeParseCacheEntry(file, contentHash, fingerprint, generation
|
|
|
124
156
|
contentHash,
|
|
125
157
|
fingerprint,
|
|
126
158
|
generation,
|
|
127
|
-
payload:
|
|
159
|
+
payload: encodeExtraction(file.extraction),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/** Payload sections, in order: head, calls, accesses. */
|
|
163
|
+
const SECTION_COUNT = 3;
|
|
164
|
+
/**
|
|
165
|
+
* Compress one file's extraction into its parse-cache payload form.
|
|
166
|
+
*
|
|
167
|
+
* The payload frames three gzip sections — head, calls, accesses — behind a
|
|
168
|
+
* table of their byte lengths, so each phase decodes only the section it
|
|
169
|
+
* reads. The parse loop holds every file in this form between parsing and
|
|
170
|
+
* resolution (T13656): compressed bytes outside the V8 heap.
|
|
171
|
+
*
|
|
172
|
+
* @param extraction - The complete per-file extraction.
|
|
173
|
+
* @returns The framed payload.
|
|
174
|
+
*/
|
|
175
|
+
export function encodeExtraction(extraction) {
|
|
176
|
+
const { calls, accesses, ...head } = extraction;
|
|
177
|
+
const sections = [head, calls, accesses].map((section) => gzipSync(JSON.stringify(section), { level: 1 }));
|
|
178
|
+
const table = Buffer.alloc(4 * SECTION_COUNT);
|
|
179
|
+
sections.forEach((section, index) => {
|
|
180
|
+
table.writeUInt32LE(section.length, 4 * index);
|
|
181
|
+
});
|
|
182
|
+
return Buffer.concat([table, ...sections]);
|
|
183
|
+
}
|
|
184
|
+
/** Inflate one section of a framed payload, rebinding its generation. */
|
|
185
|
+
function sectionText(payload, index, from, to) {
|
|
186
|
+
const bytes = Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
187
|
+
if (bytes.length < 4 * SECTION_COUNT)
|
|
188
|
+
throw new Error('Parse cache payload is truncated');
|
|
189
|
+
let offset = 4 * SECTION_COUNT;
|
|
190
|
+
for (let section = 0; section < index; section++)
|
|
191
|
+
offset += bytes.readUInt32LE(4 * section);
|
|
192
|
+
const end = offset + bytes.readUInt32LE(4 * index);
|
|
193
|
+
if (end > bytes.length)
|
|
194
|
+
throw new Error('Parse cache payload is truncated');
|
|
195
|
+
const text = gunzipSync(bytes.subarray(offset, end)).toString('utf8');
|
|
196
|
+
return from && to && from !== to ? text.split(from).join(to) : text;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Decode the head of a payload written by {@link encodeExtraction}.
|
|
200
|
+
*
|
|
201
|
+
* @param payload - Framed extraction.
|
|
202
|
+
* @param strings - Canonical strings for this decode (see {@link internStrings}).
|
|
203
|
+
* @param from - Generation embedded in the payload, rewritten to `to` when they differ.
|
|
204
|
+
* @param to - Publication generation of the run decoding it.
|
|
205
|
+
* @returns Declarations, imports, heritage, re-exports and parse limitations.
|
|
206
|
+
* @throws When the payload is not a decodable extraction.
|
|
207
|
+
*/
|
|
208
|
+
export function decodeExtractionHead(payload, strings = new Map(), from, to) {
|
|
209
|
+
const parsed = JSON.parse(sectionText(payload, 0, from, to));
|
|
210
|
+
for (const key of ['definitions', 'imports', 'heritage', 'reExports']) {
|
|
211
|
+
if (!Array.isArray(parsed[key]))
|
|
212
|
+
throw new Error(`Parse cache entry lacks ${key}`);
|
|
213
|
+
}
|
|
214
|
+
internStrings(parsed, strings);
|
|
215
|
+
return {
|
|
216
|
+
definitions: parsed.definitions ?? [],
|
|
217
|
+
imports: parsed.imports ?? [],
|
|
218
|
+
heritage: parsed.heritage ?? [],
|
|
219
|
+
reExports: parsed.reExports ?? [],
|
|
220
|
+
parseLimitations: parsed.parseLimitations ?? [],
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Decode one site section of a payload written by {@link encodeExtraction}.
|
|
225
|
+
*
|
|
226
|
+
* Not interned: resolution reads each record once and keeps nothing of it but
|
|
227
|
+
* strings the graph already holds (relation endpoints resolve to node ids).
|
|
228
|
+
*
|
|
229
|
+
* @param payload - Framed extraction.
|
|
230
|
+
* @param sites - Which section to decode.
|
|
231
|
+
* @param from - Generation embedded in the payload, rewritten to `to` when they differ.
|
|
232
|
+
* @param to - Publication generation of the run decoding it.
|
|
233
|
+
* @returns The section's records.
|
|
234
|
+
* @throws When the section is not a decodable record array.
|
|
235
|
+
*/
|
|
236
|
+
export function decodeExtractionSites(payload, sites, from, to) {
|
|
237
|
+
const parsed = JSON.parse(sectionText(payload, sites === 'calls' ? 1 : 2, from, to));
|
|
238
|
+
if (!Array.isArray(parsed))
|
|
239
|
+
throw new Error(`Parse cache entry lacks ${sites}`);
|
|
240
|
+
return parsed;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Decode a whole payload written by {@link encodeExtraction}.
|
|
244
|
+
*
|
|
245
|
+
* @param payload - Framed extraction.
|
|
246
|
+
* @param strings - Canonical strings for the head (see {@link internStrings}).
|
|
247
|
+
* @param from - Generation embedded in the payload, rewritten to `to` when they differ.
|
|
248
|
+
* @param to - Publication generation of the run decoding it.
|
|
249
|
+
* @returns The extraction with every per-file array present.
|
|
250
|
+
* @throws When the payload is not a decodable extraction.
|
|
251
|
+
*/
|
|
252
|
+
export function decodeExtraction(payload, strings = new Map(), from, to) {
|
|
253
|
+
return {
|
|
254
|
+
...decodeExtractionHead(payload, strings, from, to),
|
|
255
|
+
calls: decodeExtractionSites(payload, 'calls', from, to),
|
|
256
|
+
accesses: decodeExtractionSites(payload, 'accesses', from, to),
|
|
128
257
|
};
|
|
129
258
|
}
|
|
130
259
|
/**
|
|
131
260
|
* Decode a stored extraction and rebind it to the current publication generation.
|
|
132
261
|
*
|
|
262
|
+
* Strings are interned into `strings`: a bare `JSON.parse` materialises each
|
|
263
|
+
* repeated path, scope id and generation separately, twice the heap of the
|
|
264
|
+
* same objects built in-process (T13325).
|
|
265
|
+
*
|
|
133
266
|
* @param entry - Stored cache entry.
|
|
134
267
|
* @param generation - The publication generation of the run reusing it.
|
|
268
|
+
* @param strings - Canonical strings for this decode.
|
|
135
269
|
* @returns The extraction exactly as re-parsing the same bytes under `generation` would produce.
|
|
136
270
|
* @throws When the payload is not a decodable extraction; callers treat that file as changed.
|
|
137
271
|
*/
|
|
138
|
-
export function decodeParseCacheEntry(entry, generation) {
|
|
272
|
+
export function decodeParseCacheEntry(entry, generation, strings = new Map()) {
|
|
139
273
|
if (!entry.generation)
|
|
140
274
|
throw new Error('Parse cache entry lacks its generation');
|
|
141
|
-
let text = gunzipSync(entry.payload).toString('utf8');
|
|
142
|
-
if (entry.generation !== generation)
|
|
143
|
-
text = text.split(entry.generation).join(generation);
|
|
144
|
-
const parsed = JSON.parse(text);
|
|
145
|
-
for (const key of [
|
|
146
|
-
'definitions',
|
|
147
|
-
'imports',
|
|
148
|
-
'heritage',
|
|
149
|
-
'calls',
|
|
150
|
-
'reExports',
|
|
151
|
-
'accesses',
|
|
152
|
-
]) {
|
|
153
|
-
if (!Array.isArray(parsed[key]))
|
|
154
|
-
throw new Error(`Parse cache entry lacks ${key}`);
|
|
155
|
-
}
|
|
156
275
|
return {
|
|
157
276
|
path: entry.path,
|
|
158
|
-
extraction:
|
|
159
|
-
definitions: parsed.definitions,
|
|
160
|
-
imports: parsed.imports,
|
|
161
|
-
heritage: parsed.heritage,
|
|
162
|
-
calls: parsed.calls,
|
|
163
|
-
reExports: parsed.reExports ?? [],
|
|
164
|
-
accesses: parsed.accesses ?? [],
|
|
165
|
-
// Absent on entries written before T13379.
|
|
166
|
-
parseLimitations: parsed.parseLimitations ?? [],
|
|
167
|
-
},
|
|
277
|
+
extraction: decodeExtraction(entry.payload, strings, entry.generation, generation),
|
|
168
278
|
};
|
|
169
279
|
}
|
|
170
280
|
//# sourceMappingURL=parse-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cache.js","sourceRoot":"","sources":["../../../src/pipeline/parse-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAiBjD;;;GAGG;AACH,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG;IACvB,aAAa;IACb,wBAAwB;IACxB,wBAAwB;IACxB,oBAAoB;IACpB,gBAAgB;IAChB,kBAAkB;CACV,CAAC;AAEX,IAAI,iBAA4C,CAAC;AAEjD,sEAAsE;AACtE,SAAS,kBAAkB,CAAC,SAAiB,EAAE,GAAa;IAC1D,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,I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EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC;KACnF,CAAC;AACJ,CAAC"}
|
|
@@ -32,13 +32,12 @@
|
|
|
32
32
|
* @module pipeline/parse-loop
|
|
33
33
|
*/
|
|
34
34
|
import { type HeapInfo } from 'node:v8';
|
|
35
|
-
import type { GraphIndexFileReport, GraphNode, ParserExecutionLimits, ParserExecutionPort } from '@cleocode/contracts';
|
|
35
|
+
import type { GraphIndexFileReport, GraphNode, GraphParseCacheEntry, ParserExecutionLimits, ParserExecutionPort } from '@cleocode/contracts';
|
|
36
36
|
import type { GraphFileCapabilityCoverage } from '@cleocode/contracts/graph';
|
|
37
37
|
import { type ExtractedCall, type ExtractedHeritage, type ExtractedReExport } from './extractors/typescript-extractor.js';
|
|
38
38
|
import type { ScannedFile } from './filesystem-walker.js';
|
|
39
39
|
import type { BarrelExportMap, ExtractedImport, ImportResolutionContext, NamedImportMap, TsconfigPaths } from './import-processor.js';
|
|
40
40
|
import type { KnowledgeGraph } from './knowledge-graph.js';
|
|
41
|
-
import type { FileExtraction } from './parse-cache.js';
|
|
42
41
|
import { type ExtractedAccess } from './processors/access-processor.js';
|
|
43
42
|
import type { SymbolTable } from './symbol-table.js';
|
|
44
43
|
/**
|
|
@@ -106,16 +105,17 @@ export interface ParseLoopOptions {
|
|
|
106
105
|
*/
|
|
107
106
|
onProgress?: (current: number, total: number, filePath: string) => void;
|
|
108
107
|
/**
|
|
109
|
-
*
|
|
110
|
-
* file with an entry here is not re-parsed; its
|
|
111
|
-
* where re-parsing it would have been, so
|
|
108
|
+
* Parse-cache entries whose bytes and extractor build match, keyed by path
|
|
109
|
+
* (T12315). A parseable file with an entry here is not re-parsed; its
|
|
110
|
+
* extraction is decoded where re-parsing it would have been merged, so
|
|
111
|
+
* resolution sees the same input. An undecodable entry is re-parsed.
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
reusedEntries?: ReadonlyMap<string, GraphParseCacheEntry>;
|
|
114
114
|
/**
|
|
115
|
-
* Called once per freshly and successfully parsed file
|
|
116
|
-
*
|
|
115
|
+
* Called once per freshly and successfully parsed file with its compressed
|
|
116
|
+
* extraction ({@link encodeExtraction}) — the parse-cache payload.
|
|
117
117
|
*/
|
|
118
|
-
onFileExtracted?: (
|
|
118
|
+
onFileExtracted?: (path: string, payload: Uint8Array) => void;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* Result returned by the parse loop.
|
|
@@ -127,10 +127,14 @@ export interface ParseLoopOptions {
|
|
|
127
127
|
export interface ParseLoopResult {
|
|
128
128
|
/** All heritage records accumulated during the parse loop (for Phase 3c). */
|
|
129
129
|
allHeritage: ExtractedHeritage[];
|
|
130
|
-
/**
|
|
131
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Every call expression record, in scan order (for Phase 3e). Re-iterable;
|
|
132
|
+
* each iteration decodes one file at a time, so the records of the whole
|
|
133
|
+
* repository are never held at once (T13656).
|
|
134
|
+
*/
|
|
135
|
+
allCalls: Iterable<ExtractedCall>;
|
|
132
136
|
/** All member-access records accumulated during the parse loop (for Phase 3f). */
|
|
133
|
-
allAccesses: ExtractedAccess
|
|
137
|
+
allAccesses: Iterable<ExtractedAccess>;
|
|
134
138
|
/**
|
|
135
139
|
* Barrel export map built from re-export statements (T617).
|
|
136
140
|
* Used by the call resolution phase to trace imports through barrel index files.
|
|
@@ -138,8 +142,10 @@ export interface ParseLoopResult {
|
|
|
138
142
|
barrelMap: BarrelExportMap;
|
|
139
143
|
/** Parseable files handed to the parser this run. */
|
|
140
144
|
parsedFileCount: number;
|
|
141
|
-
/** Parseable files whose extraction came from {@link ParseLoopOptions.
|
|
145
|
+
/** Parseable files whose extraction came from {@link ParseLoopOptions.reusedEntries}. */
|
|
142
146
|
reusedFileCount: number;
|
|
147
|
+
/** Paths of those files. */
|
|
148
|
+
reusedPaths: Set<string>;
|
|
143
149
|
}
|
|
144
150
|
/** Limitation recorded on a file too large to read (T13380). */
|
|
145
151
|
export declare const OVERSIZED_FILE_LIMITATION = "Exceeds the 512 KB scan limit and was not read; none of its capabilities were assessed.";
|