@codeledger/engine 0.7.0
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/ccs/index.d.ts +11 -0
- package/dist/ccs/index.d.ts.map +1 -0
- package/dist/ccs/index.js +10 -0
- package/dist/ccs/index.js.map +1 -0
- package/dist/ccs/score.d.ts +61 -0
- package/dist/ccs/score.d.ts.map +1 -0
- package/dist/ccs/score.js +250 -0
- package/dist/ccs/score.js.map +1 -0
- package/dist/ecl/index.d.ts +9 -0
- package/dist/ecl/index.d.ts.map +1 -0
- package/dist/ecl/index.js +9 -0
- package/dist/ecl/index.js.map +1 -0
- package/dist/ecl/ledger.d.ts +84 -0
- package/dist/ecl/ledger.d.ts.map +1 -0
- package/dist/ecl/ledger.js +235 -0
- package/dist/ecl/ledger.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/iole/expansion-ladder.d.ts +51 -0
- package/dist/iole/expansion-ladder.d.ts.map +1 -0
- package/dist/iole/expansion-ladder.js +153 -0
- package/dist/iole/expansion-ladder.js.map +1 -0
- package/dist/iole/failure-vector.d.ts +21 -0
- package/dist/iole/failure-vector.d.ts.map +1 -0
- package/dist/iole/failure-vector.js +156 -0
- package/dist/iole/failure-vector.js.map +1 -0
- package/dist/iole/index.d.ts +19 -0
- package/dist/iole/index.d.ts.map +1 -0
- package/dist/iole/index.js +17 -0
- package/dist/iole/index.js.map +1 -0
- package/dist/iole/intent-decomposition.d.ts +33 -0
- package/dist/iole/intent-decomposition.d.ts.map +1 -0
- package/dist/iole/intent-decomposition.js +252 -0
- package/dist/iole/intent-decomposition.js.map +1 -0
- package/dist/iole/intent-signature.d.ts +37 -0
- package/dist/iole/intent-signature.d.ts.map +1 -0
- package/dist/iole/intent-signature.js +112 -0
- package/dist/iole/intent-signature.js.map +1 -0
- package/dist/iole/outcome-score.d.ts +25 -0
- package/dist/iole/outcome-score.d.ts.map +1 -0
- package/dist/iole/outcome-score.js +128 -0
- package/dist/iole/outcome-score.js.map +1 -0
- package/dist/isc/index.d.ts +8 -0
- package/dist/isc/index.d.ts.map +1 -0
- package/dist/isc/index.js +8 -0
- package/dist/isc/index.js.map +1 -0
- package/dist/isc/score.d.ts +27 -0
- package/dist/isc/score.d.ts.map +1 -0
- package/dist/isc/score.js +347 -0
- package/dist/isc/score.js.map +1 -0
- package/dist/license/index.d.ts +14 -0
- package/dist/license/index.d.ts.map +1 -0
- package/dist/license/index.js +11 -0
- package/dist/license/index.js.map +1 -0
- package/dist/license/parse.d.ts +42 -0
- package/dist/license/parse.d.ts.map +1 -0
- package/dist/license/parse.js +106 -0
- package/dist/license/parse.js.map +1 -0
- package/dist/license/publicKey.d.ts +37 -0
- package/dist/license/publicKey.d.ts.map +1 -0
- package/dist/license/publicKey.js +48 -0
- package/dist/license/publicKey.js.map +1 -0
- package/dist/license/verify.d.ts +33 -0
- package/dist/license/verify.d.ts.map +1 -0
- package/dist/license/verify.js +82 -0
- package/dist/license/verify.js.map +1 -0
- package/dist/orchestrator/index.d.ts +10 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +10 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +44 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.js +182 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/policy-sim/index.d.ts +8 -0
- package/dist/policy-sim/index.d.ts.map +1 -0
- package/dist/policy-sim/index.js +8 -0
- package/dist/policy-sim/index.js.map +1 -0
- package/dist/policy-sim/simulate.d.ts +18 -0
- package/dist/policy-sim/simulate.d.ts.map +1 -0
- package/dist/policy-sim/simulate.js +61 -0
- package/dist/policy-sim/simulate.js.map +1 -0
- package/dist/provenance/graph.d.ts +42 -0
- package/dist/provenance/graph.d.ts.map +1 -0
- package/dist/provenance/graph.js +139 -0
- package/dist/provenance/graph.js.map +1 -0
- package/dist/provenance/index.d.ts +8 -0
- package/dist/provenance/index.d.ts.map +1 -0
- package/dist/provenance/index.js +8 -0
- package/dist/provenance/index.js.map +1 -0
- package/dist/sce/index.d.ts +15 -0
- package/dist/sce/index.d.ts.map +1 -0
- package/dist/sce/index.js +14 -0
- package/dist/sce/index.js.map +1 -0
- package/dist/sce/slice-builder.d.ts +35 -0
- package/dist/sce/slice-builder.d.ts.map +1 -0
- package/dist/sce/slice-builder.js +198 -0
- package/dist/sce/slice-builder.js.map +1 -0
- package/dist/sce/symbol-graph.d.ts +21 -0
- package/dist/sce/symbol-graph.d.ts.map +1 -0
- package/dist/sce/symbol-graph.js +187 -0
- package/dist/sce/symbol-graph.js.map +1 -0
- package/dist/team-ledger/index.d.ts +8 -0
- package/dist/team-ledger/index.d.ts.map +1 -0
- package/dist/team-ledger/index.js +8 -0
- package/dist/team-ledger/index.js.map +1 -0
- package/dist/team-ledger/ledger.d.ts +48 -0
- package/dist/team-ledger/ledger.d.ts.map +1 -0
- package/dist/team-ledger/ledger.js +208 -0
- package/dist/team-ledger/ledger.js.map +1 -0
- package/dist/team-metrics/index.d.ts +8 -0
- package/dist/team-metrics/index.d.ts.map +1 -0
- package/dist/team-metrics/index.js +8 -0
- package/dist/team-metrics/index.js.map +1 -0
- package/dist/team-metrics/metrics.d.ts +42 -0
- package/dist/team-metrics/metrics.d.ts.map +1 -0
- package/dist/team-metrics/metrics.js +156 -0
- package/dist/team-metrics/metrics.js.map +1 -0
- package/dist/team-policy/index.d.ts +8 -0
- package/dist/team-policy/index.d.ts.map +1 -0
- package/dist/team-policy/index.js +8 -0
- package/dist/team-policy/index.js.map +1 -0
- package/dist/team-policy/policy.d.ts +35 -0
- package/dist/team-policy/policy.d.ts.map +1 -0
- package/dist/team-policy/policy.js +100 -0
- package/dist/team-policy/policy.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Provenance Graph — Implementation
|
|
3
|
+
*
|
|
4
|
+
* Storage: .codeledger/provenance/
|
|
5
|
+
* - nodes.jsonl (append-only node records)
|
|
6
|
+
* - edges.jsonl (append-only edge records)
|
|
7
|
+
*
|
|
8
|
+
* Node types: task, intent, bundle, file, edit, commit, outcome
|
|
9
|
+
* Edge types: GENERATED_CONTEXT, INCLUDED_FILE, MODIFIED_FILE,
|
|
10
|
+
* PRODUCED_OUTCOME, DERIVED_INTENT, COMMITTED_CHANGE
|
|
11
|
+
*
|
|
12
|
+
* Provides traceTask() for causal chain extraction:
|
|
13
|
+
* "Auth bug fix → bundle (8 files) → edits (3 files) → commit → tests passed"
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync, appendFileSync, existsSync, mkdirSync } from 'fs';
|
|
16
|
+
import { join, dirname } from 'path';
|
|
17
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
18
|
+
export const PROVENANCE_DIR = 'provenance';
|
|
19
|
+
const NODES_FILE = 'nodes.jsonl';
|
|
20
|
+
const EDGES_FILE = 'edges.jsonl';
|
|
21
|
+
// ─── Paths ────────────────────────────────────────────────────────────────────
|
|
22
|
+
export function provenancePath(repoRoot) {
|
|
23
|
+
return join(repoRoot, '.codeledger', PROVENANCE_DIR);
|
|
24
|
+
}
|
|
25
|
+
function nodesPath(repoRoot) {
|
|
26
|
+
return join(provenancePath(repoRoot), NODES_FILE);
|
|
27
|
+
}
|
|
28
|
+
function edgesPath(repoRoot) {
|
|
29
|
+
return join(provenancePath(repoRoot), EDGES_FILE);
|
|
30
|
+
}
|
|
31
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
32
|
+
/**
|
|
33
|
+
* Add a node to the provenance graph.
|
|
34
|
+
* Creates the directory structure if it doesn't exist.
|
|
35
|
+
*/
|
|
36
|
+
export function addNode(repoRoot, node) {
|
|
37
|
+
const path = nodesPath(repoRoot);
|
|
38
|
+
ensureDir(dirname(path));
|
|
39
|
+
appendFileSync(path, JSON.stringify(node) + '\n', 'utf-8');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Add an edge to the provenance graph.
|
|
43
|
+
*/
|
|
44
|
+
export function addEdge(repoRoot, edge) {
|
|
45
|
+
const path = edgesPath(repoRoot);
|
|
46
|
+
ensureDir(dirname(path));
|
|
47
|
+
appendFileSync(path, JSON.stringify(edge) + '\n', 'utf-8');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Load the full provenance graph from disk.
|
|
51
|
+
*/
|
|
52
|
+
export function loadGraph(repoRoot) {
|
|
53
|
+
return {
|
|
54
|
+
nodes: loadJsonl(nodesPath(repoRoot)),
|
|
55
|
+
edges: loadJsonl(edgesPath(repoRoot)),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Trace the causal chain for a given task.
|
|
60
|
+
*
|
|
61
|
+
* Walks the graph from the task node through bundles, files, edits,
|
|
62
|
+
* commits, and outcomes — producing an ordered causal chain.
|
|
63
|
+
*/
|
|
64
|
+
export function traceTask(repoRoot, taskId) {
|
|
65
|
+
const graph = loadGraph(repoRoot);
|
|
66
|
+
// Find the task node
|
|
67
|
+
const taskNode = graph.nodes.find((n) => n.id === taskId && n.kind === 'task');
|
|
68
|
+
if (!taskNode)
|
|
69
|
+
return null;
|
|
70
|
+
// BFS from the task node following edges forward
|
|
71
|
+
const chain = [taskNode];
|
|
72
|
+
const chainEdges = [];
|
|
73
|
+
const visited = new Set([taskId]);
|
|
74
|
+
const queue = [taskId];
|
|
75
|
+
const nodeMap = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
76
|
+
const outEdges = new Map();
|
|
77
|
+
for (const edge of graph.edges) {
|
|
78
|
+
const existing = outEdges.get(edge.source) ?? [];
|
|
79
|
+
existing.push(edge);
|
|
80
|
+
outEdges.set(edge.source, existing);
|
|
81
|
+
}
|
|
82
|
+
while (queue.length > 0) {
|
|
83
|
+
const current = queue.shift();
|
|
84
|
+
const edges = outEdges.get(current) ?? [];
|
|
85
|
+
for (const edge of edges) {
|
|
86
|
+
if (visited.has(edge.target))
|
|
87
|
+
continue;
|
|
88
|
+
visited.add(edge.target);
|
|
89
|
+
const targetNode = nodeMap.get(edge.target);
|
|
90
|
+
if (targetNode) {
|
|
91
|
+
chain.push(targetNode);
|
|
92
|
+
chainEdges.push(edge);
|
|
93
|
+
queue.push(edge.target);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Sort chain by timestamp
|
|
98
|
+
chain.sort((a, b) => a.timestamp - b.timestamp);
|
|
99
|
+
// Determine outcome
|
|
100
|
+
const outcomeNode = chain.find((n) => n.kind === 'outcome');
|
|
101
|
+
const outcome = outcomeNode
|
|
102
|
+
? outcomeNode.metadata['result'] ?? 'pending'
|
|
103
|
+
: 'pending';
|
|
104
|
+
return {
|
|
105
|
+
taskId,
|
|
106
|
+
taskLabel: taskNode.label,
|
|
107
|
+
chain,
|
|
108
|
+
chainEdges,
|
|
109
|
+
outcome,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Export the graph as a JSON object (for --format graph in audit-export).
|
|
114
|
+
*/
|
|
115
|
+
export function exportGraph(repoRoot) {
|
|
116
|
+
return loadGraph(repoRoot);
|
|
117
|
+
}
|
|
118
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
119
|
+
function loadJsonl(path) {
|
|
120
|
+
if (!existsSync(path))
|
|
121
|
+
return [];
|
|
122
|
+
const lines = readFileSync(path, 'utf-8').split('\n').filter((l) => l.trim());
|
|
123
|
+
const items = [];
|
|
124
|
+
for (const line of lines) {
|
|
125
|
+
try {
|
|
126
|
+
items.push(JSON.parse(line));
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Skip malformed lines
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return items;
|
|
133
|
+
}
|
|
134
|
+
function ensureDir(dir) {
|
|
135
|
+
if (!existsSync(dir)) {
|
|
136
|
+
mkdirSync(dir, { recursive: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/provenance/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAQrC,iFAAiF;AAEjF,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAC3C,MAAM,UAAU,GAAG,aAAa,CAAC;AACjC,MAAM,UAAU,GAAG,aAAa,CAAC;AAEjC,iFAAiF;AAEjF,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,IAAI,CAAC,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,SAAS,CAAC,QAAgB;IACjC,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,SAAS,CAAC,QAAgB;IACjC,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC;AAED,iFAAiF;AAEjF;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,QAAgB,EAAE,IAAoB;IAC5D,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACjC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACzB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,QAAgB,E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full causal traceability: Task → Context → Files → Edits → Outcome.
|
|
5
|
+
* Append-only graph stored as JSONL (nodes.jsonl + edges.jsonl).
|
|
6
|
+
*/
|
|
7
|
+
export { provenancePath, addNode, addEdge, loadGraph, traceTask, exportGraph, PROVENANCE_DIR, } from './graph.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provenance/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Provenance Graph (Enterprise)
|
|
3
|
+
*
|
|
4
|
+
* Full causal traceability: Task → Context → Files → Edits → Outcome.
|
|
5
|
+
* Append-only graph stored as JSONL (nodes.jsonl + edges.jsonl).
|
|
6
|
+
*/
|
|
7
|
+
export { provenancePath, addNode, addEdge, loadGraph, traceTask, exportGraph, PROVENANCE_DIR, } from './graph.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/provenance/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCE — Structural Context Engine
|
|
3
|
+
*
|
|
4
|
+
* Provides symbol-level code analysis for the DCOL (Deterministic Context
|
|
5
|
+
* Orchestration Layer). The SCE produces Minimal Sufficient Code Slices
|
|
6
|
+
* instead of whole-file inclusion, reducing token usage by 30–60%.
|
|
7
|
+
*
|
|
8
|
+
* Subsystems:
|
|
9
|
+
* - symbol-graph: Extract typed symbols and their import relationships
|
|
10
|
+
* - slice-builder: Build the minimal slice from symbol graph + task keywords
|
|
11
|
+
*/
|
|
12
|
+
export { buildSymbolGraph, extractSymbols } from './symbol-graph.js';
|
|
13
|
+
export { buildMinimalSlice } from './slice-builder.js';
|
|
14
|
+
export type { SliceOptions } from './slice-builder.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sce/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCE — Structural Context Engine
|
|
3
|
+
*
|
|
4
|
+
* Provides symbol-level code analysis for the DCOL (Deterministic Context
|
|
5
|
+
* Orchestration Layer). The SCE produces Minimal Sufficient Code Slices
|
|
6
|
+
* instead of whole-file inclusion, reducing token usage by 30–60%.
|
|
7
|
+
*
|
|
8
|
+
* Subsystems:
|
|
9
|
+
* - symbol-graph: Extract typed symbols and their import relationships
|
|
10
|
+
* - slice-builder: Build the minimal slice from symbol graph + task keywords
|
|
11
|
+
*/
|
|
12
|
+
export { buildSymbolGraph, extractSymbols } from './symbol-graph.js';
|
|
13
|
+
export { buildMinimalSlice } from './slice-builder.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sce/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCE — Slice Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs the Minimal Sufficient Code Slice (MSCS) for a given task.
|
|
5
|
+
*
|
|
6
|
+
* The MSCS is the smallest set of symbols + their dependency chain that
|
|
7
|
+
* satisfies the task's keyword requirements. It excludes unrelated code,
|
|
8
|
+
* keeping context bounded and token-efficient.
|
|
9
|
+
*
|
|
10
|
+
* Deterministic: same input → same output.
|
|
11
|
+
*/
|
|
12
|
+
import type { SymbolGraph, MinimalSufficientCodeSlice, FailureHotspot } from '@codeledger/types';
|
|
13
|
+
/**
|
|
14
|
+
* Build the Minimal Sufficient Code Slice for a task.
|
|
15
|
+
*
|
|
16
|
+
* Steps:
|
|
17
|
+
* 1. Find seed symbols matching task keywords
|
|
18
|
+
* 2. Expand to their transitive dependency chain
|
|
19
|
+
* 3. Deduplicate and rank by relevance
|
|
20
|
+
* 4. Return sliced content (symbol signatures, not full files)
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildMinimalSlice(graph: SymbolGraph, taskKeywords: string[], options?: SliceOptions): MinimalSufficientCodeSlice;
|
|
23
|
+
export interface SliceOptions {
|
|
24
|
+
/** Maximum dependency depth to traverse. Default: 3 */
|
|
25
|
+
maxDepth?: number;
|
|
26
|
+
/** Maximum symbols to include in the slice. Default: 50 */
|
|
27
|
+
maxSymbols?: number;
|
|
28
|
+
/**
|
|
29
|
+
* ECL-Lite failure hotspots — files that frequently appear in failure vectors.
|
|
30
|
+
* When provided, symbols in these files are boosted in seed discovery and
|
|
31
|
+
* relevance scoring, surfacing execution-path-aware context automatically.
|
|
32
|
+
*/
|
|
33
|
+
failureHotspots?: FailureHotspot[];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=slice-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slice-builder.d.ts","sourceRoot":"","sources":["../../src/sce/slice-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EACV,WAAW,EAEX,0BAA0B,EAE1B,cAAc,EACf,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,GAAE,YAAiB,GACzB,0BAA0B,CA6B5B;AAoND,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCE — Slice Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs the Minimal Sufficient Code Slice (MSCS) for a given task.
|
|
5
|
+
*
|
|
6
|
+
* The MSCS is the smallest set of symbols + their dependency chain that
|
|
7
|
+
* satisfies the task's keyword requirements. It excludes unrelated code,
|
|
8
|
+
* keeping context bounded and token-efficient.
|
|
9
|
+
*
|
|
10
|
+
* Deterministic: same input → same output.
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync } from 'fs';
|
|
13
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* Build the Minimal Sufficient Code Slice for a task.
|
|
16
|
+
*
|
|
17
|
+
* Steps:
|
|
18
|
+
* 1. Find seed symbols matching task keywords
|
|
19
|
+
* 2. Expand to their transitive dependency chain
|
|
20
|
+
* 3. Deduplicate and rank by relevance
|
|
21
|
+
* 4. Return sliced content (symbol signatures, not full files)
|
|
22
|
+
*/
|
|
23
|
+
export function buildMinimalSlice(graph, taskKeywords, options = {}) {
|
|
24
|
+
const maxDepth = options.maxDepth ?? 3;
|
|
25
|
+
const maxSymbols = options.maxSymbols ?? 50;
|
|
26
|
+
const keywordsLower = taskKeywords.map((k) => k.toLowerCase());
|
|
27
|
+
// Build hotspot index for O(1) lookups during scoring
|
|
28
|
+
const hotspotIndex = buildHotspotIndex(options.failureHotspots ?? []);
|
|
29
|
+
// Step 1: Find seed symbols matching task keywords, boosted by hotspot signals
|
|
30
|
+
const seeds = findSeedSymbols(graph, keywordsLower, hotspotIndex);
|
|
31
|
+
// Step 2: Expand via dependency chain (BFS, bounded by maxDepth)
|
|
32
|
+
const sliceNodes = expandDependencyChain(graph, seeds, maxDepth, maxSymbols);
|
|
33
|
+
// Step 3: Build CodeSlice entries with content excerpts + hotspot boosts
|
|
34
|
+
const slices = buildSliceEntries(sliceNodes, graph, keywordsLower, hotspotIndex);
|
|
35
|
+
// Step 4: Compute metrics
|
|
36
|
+
const uniqueFiles = new Set(sliceNodes.map((n) => n.file));
|
|
37
|
+
return {
|
|
38
|
+
task_keywords: taskKeywords,
|
|
39
|
+
seed_symbols: seeds.map((n) => n.id),
|
|
40
|
+
slices,
|
|
41
|
+
file_count: uniqueFiles.size,
|
|
42
|
+
symbol_count: sliceNodes.length,
|
|
43
|
+
dependency_depth_reached: computeMaxDepth(seeds, sliceNodes, graph),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// ─── Execution Path Signals ───────────────────────────────────────────────────
|
|
47
|
+
const MS_PER_DAY = 86_400_000;
|
|
48
|
+
/**
|
|
49
|
+
* Build a file → decayed hotspot score index from ECL-Lite failure hotspots.
|
|
50
|
+
*
|
|
51
|
+
* Score = implicationRate × recencyDecay
|
|
52
|
+
* recencyDecay = 1 / (1 + daysSinceLastFailure)
|
|
53
|
+
*
|
|
54
|
+
* This prevents self-reinforcing feedback loops: old hotspots decay toward 0
|
|
55
|
+
* as the file stops appearing in failures, while recent hotspots retain full weight.
|
|
56
|
+
*/
|
|
57
|
+
function buildHotspotIndex(hotspots) {
|
|
58
|
+
const index = new Map();
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
for (const hs of hotspots) {
|
|
61
|
+
const daysSince = hs.lastFailureTimestamp > 0
|
|
62
|
+
? (now - hs.lastFailureTimestamp) / MS_PER_DAY
|
|
63
|
+
: 0; // treat missing timestamp as "just now"
|
|
64
|
+
const recencyDecay = 1 / (1 + daysSince);
|
|
65
|
+
const decayedScore = hs.implicationRate * recencyDecay;
|
|
66
|
+
index.set(hs.file, decayedScore);
|
|
67
|
+
}
|
|
68
|
+
return index;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Compute the capped hotspot boost for a file.
|
|
72
|
+
*
|
|
73
|
+
* Boost is proportional to the decayed hotspot score (linear: 0→0, 1→0.5).
|
|
74
|
+
* Cap: hotspot contribution may not exceed 25% of the total relevance score.
|
|
75
|
+
* This prevents hotspots from crowding out keyword-matched seeds.
|
|
76
|
+
*/
|
|
77
|
+
function hotspotBoost(file, hotspotIndex, keywordScore) {
|
|
78
|
+
const decayedScore = hotspotIndex.get(file);
|
|
79
|
+
if (decayedScore === undefined || decayedScore === 0)
|
|
80
|
+
return 0;
|
|
81
|
+
// Raw boost: linear scale of decayed score
|
|
82
|
+
const rawBoost = decayedScore * 0.5;
|
|
83
|
+
// Cap: boost/(keywordScore + boost) ≤ 0.25
|
|
84
|
+
// ⟹ boost ≤ keywordScore / 3 (when keywordScore > 0)
|
|
85
|
+
const cap = keywordScore > 0 ? keywordScore / 3 : 0;
|
|
86
|
+
return Math.min(rawBoost, cap);
|
|
87
|
+
}
|
|
88
|
+
// ─── Seed Discovery ───────────────────────────────────────────────────────────
|
|
89
|
+
function findSeedSymbols(graph, keywords, hotspotIndex) {
|
|
90
|
+
const scored = [];
|
|
91
|
+
for (const node of Object.values(graph.nodes)) {
|
|
92
|
+
const nameLower = node.name.toLowerCase();
|
|
93
|
+
const fileLower = node.file.toLowerCase();
|
|
94
|
+
const keywordMatches = keywords.filter((kw) => nameLower.includes(kw) || fileLower.includes(kw)).length;
|
|
95
|
+
if (keywordMatches === 0)
|
|
96
|
+
continue;
|
|
97
|
+
// Base score: keyword match rate
|
|
98
|
+
const baseScore = keywordMatches / Math.max(keywords.length, 1);
|
|
99
|
+
// Execution path boost: decay-weighted, capped at 25% of total
|
|
100
|
+
const boost = hotspotBoost(node.file, hotspotIndex, baseScore);
|
|
101
|
+
scored.push({ node, score: baseScore + boost });
|
|
102
|
+
}
|
|
103
|
+
// Sort by score descending (hotspot + keyword match wins)
|
|
104
|
+
scored.sort((a, b) => b.score - a.score);
|
|
105
|
+
return scored.map((s) => s.node);
|
|
106
|
+
}
|
|
107
|
+
// ─── Dependency Chain Expansion ───────────────────────────────────────────────
|
|
108
|
+
function expandDependencyChain(graph, seeds, maxDepth, maxSymbols) {
|
|
109
|
+
const visited = new Set();
|
|
110
|
+
const result = [];
|
|
111
|
+
// BFS queue: [node, depth]
|
|
112
|
+
const queue = seeds.map((s) => [s, 0]);
|
|
113
|
+
while (queue.length > 0 && result.length < maxSymbols) {
|
|
114
|
+
const entry = queue.shift();
|
|
115
|
+
if (!entry)
|
|
116
|
+
break;
|
|
117
|
+
const [node, depth] = entry;
|
|
118
|
+
if (visited.has(node.id))
|
|
119
|
+
continue;
|
|
120
|
+
visited.add(node.id);
|
|
121
|
+
result.push(node);
|
|
122
|
+
if (depth >= maxDepth)
|
|
123
|
+
continue;
|
|
124
|
+
// Expand dependencies (what this symbol imports)
|
|
125
|
+
for (const depId of node.dependencies) {
|
|
126
|
+
const dep = graph.nodes[depId];
|
|
127
|
+
if (dep && !visited.has(dep.id)) {
|
|
128
|
+
queue.push([dep, depth + 1]);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
// ─── Slice Entries ────────────────────────────────────────────────────────────
|
|
135
|
+
function buildSliceEntries(nodes, _graph, keywords, hotspotIndex) {
|
|
136
|
+
// Group nodes by file
|
|
137
|
+
const byFile = new Map();
|
|
138
|
+
for (const node of nodes) {
|
|
139
|
+
const existing = byFile.get(node.file) ?? [];
|
|
140
|
+
existing.push(node);
|
|
141
|
+
byFile.set(node.file, existing);
|
|
142
|
+
}
|
|
143
|
+
const slices = [];
|
|
144
|
+
for (const [file, fileNodes] of byFile) {
|
|
145
|
+
// Read file content (best-effort)
|
|
146
|
+
let content = '';
|
|
147
|
+
try {
|
|
148
|
+
content = readFileSync(file, 'utf8');
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
content = '';
|
|
152
|
+
}
|
|
153
|
+
const lines = content.split('\n');
|
|
154
|
+
for (const node of fileNodes) {
|
|
155
|
+
// Extract symbol signature (the definition line + following lines until closing brace/paren)
|
|
156
|
+
const excerpt = extractSymbolExcerpt(lines, node.line, 20);
|
|
157
|
+
const relevanceScore = computeSymbolRelevance(node, keywords, hotspotIndex);
|
|
158
|
+
slices.push({
|
|
159
|
+
symbol_id: node.id,
|
|
160
|
+
symbol_name: node.name,
|
|
161
|
+
symbol_kind: node.kind,
|
|
162
|
+
file: node.file,
|
|
163
|
+
line: node.line,
|
|
164
|
+
excerpt,
|
|
165
|
+
relevance_score: relevanceScore,
|
|
166
|
+
dependency_ids: node.dependencies,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Sort by relevance (seeds first)
|
|
171
|
+
slices.sort((a, b) => b.relevance_score - a.relevance_score);
|
|
172
|
+
return slices;
|
|
173
|
+
}
|
|
174
|
+
function extractSymbolExcerpt(lines, startLine, maxLines) {
|
|
175
|
+
const start = Math.max(0, startLine - 1);
|
|
176
|
+
const end = Math.min(lines.length, start + maxLines);
|
|
177
|
+
return lines.slice(start, end).join('\n');
|
|
178
|
+
}
|
|
179
|
+
function computeSymbolRelevance(node, keywords, hotspotIndex) {
|
|
180
|
+
const nameLower = node.name.toLowerCase();
|
|
181
|
+
const matches = keywords.filter((kw) => nameLower.includes(kw)).length;
|
|
182
|
+
const keywordScore = matches / Math.max(keywords.length, 1);
|
|
183
|
+
// Decay-weighted, 25%-capped hotspot boost
|
|
184
|
+
return Math.min(keywordScore + hotspotBoost(node.file, hotspotIndex, keywordScore), 1.0);
|
|
185
|
+
}
|
|
186
|
+
function computeMaxDepth(seeds, allNodes, _graph) {
|
|
187
|
+
if (seeds.length === 0 || allNodes.length === 0)
|
|
188
|
+
return 0;
|
|
189
|
+
const seedIds = new Set(seeds.map((s) => s.id));
|
|
190
|
+
let maxDepth = 0;
|
|
191
|
+
for (const node of allNodes) {
|
|
192
|
+
if (!seedIds.has(node.id)) {
|
|
193
|
+
maxDepth = Math.max(maxDepth, 1); // at least 1 hop from seed
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return maxDepth;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=slice-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slice-builder.js","sourceRoot":"","sources":["../../src/sce/slice-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AASlC,iFAAiF;AAEjF;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAkB,EAClB,YAAsB,EACtB,UAAwB,EAAE;IAE1B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IAE5C,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAE/D,sDAAsD;IACtD,MAAM,YAAY,GAAG,iBAAiB,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;IAEtE,+EAA+E;IAC/E,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IAElE,iEAAiE;IACjE,MAAM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AI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACvE,MAAM,YAAY,GAAG,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5D,2CAA2C;IAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,eAAe,CACtB,KAAmB,EACnB,QAAsB,EACtB,MAAmB;IAEnB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC1B,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,2BAA2B;QAC/D,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCE — Symbol Graph
|
|
3
|
+
*
|
|
4
|
+
* Extracts a symbol-level dependency graph from TypeScript source files
|
|
5
|
+
* using regex-based AST approximation (no external parser dependencies).
|
|
6
|
+
*
|
|
7
|
+
* Deterministic: same input → same output. No randomness, no embeddings.
|
|
8
|
+
*/
|
|
9
|
+
import type { SymbolGraph, SymbolNode } from '@codeledger/types';
|
|
10
|
+
/**
|
|
11
|
+
* Extract a SymbolGraph from a set of source file paths.
|
|
12
|
+
*
|
|
13
|
+
* Each node represents a named exported symbol. Edges track which symbols
|
|
14
|
+
* import (and thus depend on) symbols from other files.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildSymbolGraph(filePaths: string[]): SymbolGraph;
|
|
17
|
+
/**
|
|
18
|
+
* Extract all exported symbols from a TypeScript source file.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractSymbols(filePath: string, src: string): SymbolNode[];
|
|
21
|
+
//# sourceMappingURL=symbol-graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbol-graph.d.ts","sourceRoot":"","sources":["../../src/sce/symbol-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAc,MAAM,mBAAmB,CAAC;AA8B7E;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,WAAW,CA4DjE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE,CA+B1E"}
|