@quolu/lattice 0.31.0 → 0.33.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/README.ja.md +11 -1
- package/README.md +11 -2
- package/bin/lattice-scripted-worker.mjs +59 -0
- package/bin/lattice.mjs +12 -1
- package/package.json +1 -1
- package/sensor/dist/bin/lattice-sensor.js +72 -4
- package/sensor/dist/db/migrations.d.ts +1 -1
- package/sensor/dist/db/migrations.d.ts.map +1 -1
- package/sensor/dist/db/migrations.js +32 -2
- package/sensor/dist/db/migrations.js.map +1 -1
- package/sensor/dist/db/queries.d.ts +10 -0
- package/sensor/dist/db/queries.d.ts.map +1 -1
- package/sensor/dist/db/queries.js +53 -7
- package/sensor/dist/db/queries.js.map +1 -1
- package/sensor/dist/db/schema.sql +6 -1
- package/sensor/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/sensor/dist/extraction/tree-sitter.js +89 -16
- package/sensor/dist/extraction/tree-sitter.js.map +1 -1
- package/sensor/dist/index.d.ts +8 -1
- package/sensor/dist/index.d.ts.map +1 -1
- package/sensor/dist/index.js +9 -0
- package/sensor/dist/index.js.map +1 -1
- package/sensor/dist/resolution/import-resolver.d.ts +11 -0
- package/sensor/dist/resolution/import-resolver.d.ts.map +1 -1
- package/sensor/dist/resolution/import-resolver.js +13 -5
- package/sensor/dist/resolution/import-resolver.js.map +1 -1
- package/sensor/dist/resolution/index.d.ts.map +1 -1
- package/sensor/dist/resolution/index.js +11 -0
- package/sensor/dist/resolution/index.js.map +1 -1
- package/sensor/dist/resolution/types.d.ts +4 -0
- package/sensor/dist/resolution/types.d.ts.map +1 -1
- package/sensor/dist/types.d.ts +16 -0
- package/sensor/dist/types.d.ts.map +1 -1
- package/src/artifact-contracts.mjs +3 -0
- package/src/cli-help.mjs +6 -0
- package/src/rc3-scripted-campaign.mjs +3 -1
- package/src/runtime-cli.mjs +454 -97
- package/src/runtime-contracts.mjs +1 -1
- package/src/runtime-control-store.mjs +24 -1
- package/src/runtime-controller-protocol.mjs +21 -3
- package/src/runtime-decision-verifier.mjs +1 -1
- package/src/runtime-diff-observer.mjs +2 -2
- package/src/runtime-front-end.mjs +47 -13
- package/src/runtime-hold-recompile.mjs +31 -2
- package/src/runtime-io-sentinel.mjs +16 -9
- package/src/runtime-managed-supervisor.mjs +9 -1
- package/src/runtime-multi-epoch-store.mjs +2 -2
- package/src/runtime-projection.mjs +27 -0
- package/src/runtime-scripted-adapter-controller.mjs +139 -25
- package/src/runtime-seam-resolve.mjs +156 -13
- package/src/runtime-seam-treatment.mjs +2 -1
- package/src/seam-apply.mjs +101 -4
- package/src/seam-cost.mjs +322 -0
- package/src/seam-gate.mjs +146 -0
- package/src/seam-rewrite.mjs +102 -16
- package/src/seam-verification.mjs +26 -3
- package/src/sensor-adapter.mjs +6 -1
- package/src/todo-cli.mjs +55 -0
package/README.ja.md
CHANGED
|
@@ -47,12 +47,22 @@ planを再コンパイルします。共有面が共有でなくなるので、
|
|
|
47
47
|
|
|
48
48
|
| 条件 | 意味 |
|
|
49
49
|
|---|---|
|
|
50
|
-
| `behavior_equivalent` | 原pathの公開export
|
|
50
|
+
| `behavior_equivalent` | 原pathの公開export面が保たれ、移した先が残余面のsymbolへ束縛なしで言及していない(切断参照の網) |
|
|
51
51
|
| `focused_tests_passed` | 影響testが変換後のsourceで実際に通る |
|
|
52
52
|
| `sensor_fresh` | 構造索引を取り直し、新しい面を収載している |
|
|
53
53
|
| `overlap_reduced` | 対象の競合が消え、**かつ**plan全体の競合対が増えていない |
|
|
54
54
|
| `parallelism_improved` | 実行段階数が減っている |
|
|
55
55
|
|
|
56
|
+
### 実行段階の二段構え
|
|
57
|
+
|
|
58
|
+
計画時に完全な分断は原理的に得られません(動的dispatch・実行時に決まるpath・外部状態)。
|
|
59
|
+
そのため実行中は宣言でなく**実際に変更された資源**を観測し、宣言scope外への書き込みや
|
|
60
|
+
進行中の他工程のscopeとの重なりを実行時競合として挙げます。処置は「一方をholdして他方を
|
|
61
|
+
確定→再開」か「双方停止→seam変換→双方再開」の二択で、どちらも実storeに対する
|
|
62
|
+
integration testで一気通貫に検証済みです。切断の重さは`lattice run seam profile`
|
|
63
|
+
(計画時は`todo seam-profile`)が数えられる事実だけで投影し、機械変換の可否は「確実の門」が
|
|
64
|
+
typed理由つきで分類します——宣言を直せば通るのか、操作AIへ渡すべきなのかまで返します。
|
|
65
|
+
|
|
56
66
|
## 開発工場での位置づけ
|
|
57
67
|
|
|
58
68
|
Latticeは[dotagents開発工場](https://github.com/kitepon-rgb/dotagents)が管理する
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ A transform is adopted only when **all five** hold. One missing condition reject
|
|
|
62
62
|
|
|
63
63
|
| Condition | Meaning |
|
|
64
64
|
|---|---|
|
|
65
|
-
| `behavior_equivalent` | The original path's public export surface is preserved |
|
|
65
|
+
| `behavior_equivalent` | The original path's public export surface is preserved, and no moved code references a symbol that stayed behind without a binding (severed-reference net) |
|
|
66
66
|
| `focused_tests_passed` | The affected tests actually pass against the transformed source |
|
|
67
67
|
| `sensor_fresh` | The structure index was rebuilt and covers the new surfaces |
|
|
68
68
|
| `overlap_reduced` | The target conflict is gone **and** plan-wide conflict pairs did not increase |
|
|
@@ -77,7 +77,16 @@ carries a second stage at runtime.
|
|
|
77
77
|
While work executes, Lattice observes **what was actually changed**, not what was declared. When
|
|
78
78
|
it sees a task writing outside its declared scope, or into another running task's scope, it
|
|
79
79
|
raises a runtime conflict — and can either hold one side while the other commits, or transform
|
|
80
|
-
the seam and resume both.
|
|
80
|
+
the seam and resume both. Both treatments are exercised end-to-end against a live store in the
|
|
81
|
+
integration suite.
|
|
82
|
+
|
|
83
|
+
Two projection surfaces support that decision without scoring anyone. `lattice run seam profile`
|
|
84
|
+
(and `todo seam-profile` at plan time) reports the countable anatomy of a cut — cross references,
|
|
85
|
+
shared module state with read/write distinction, shared imports, cycles — with declared blind
|
|
86
|
+
spots, and never persists into any digested artifact. And every machine-transform rejection is
|
|
87
|
+
classified by a **certainty gate**: the machine only transforms what it can do with certainty,
|
|
88
|
+
and each refusal says whether fixing the declaration suffices or the seam should be handed to
|
|
89
|
+
the operating AI.
|
|
81
90
|
|
|
82
91
|
## Install
|
|
83
92
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* scripted executorのworker process(ADR 0143 Decision 9)。
|
|
4
|
+
*
|
|
5
|
+
* **別processであること自体が要件である。** holdは静止の証明を要求し、直接OS観測は
|
|
6
|
+
* executorのprocessが実際に停止していることまで確かめる。controller自身のprocessで
|
|
7
|
+
* 作業していると、止めれば応答できず、止めなければ証明できない。
|
|
8
|
+
*
|
|
9
|
+
* 書いたあとも生きたまま待つ。作業を終えて消えてしまうと、barrierが掛かった時に
|
|
10
|
+
* 止めるべきprocessが存在せず、静止を証明する相手が居なくなる。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { readFile } from 'node:fs/promises';
|
|
14
|
+
|
|
15
|
+
import { executePacket } from '../src/runtime-scripted-adapter-controller.mjs';
|
|
16
|
+
|
|
17
|
+
const MAX_JOB_BYTES = 8_388_608;
|
|
18
|
+
|
|
19
|
+
function fail(reason) {
|
|
20
|
+
process.stderr.write(`${JSON.stringify({
|
|
21
|
+
schema: 'lattice.scripted_worker_error.v1', reason,
|
|
22
|
+
})}\n`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const jobPath = process.argv[2];
|
|
27
|
+
if (typeof jobPath !== 'string' || jobPath.length === 0) fail('job pathが渡されていない');
|
|
28
|
+
|
|
29
|
+
let job;
|
|
30
|
+
try {
|
|
31
|
+
const bytes = await readFile(jobPath);
|
|
32
|
+
if (bytes.length > MAX_JOB_BYTES) fail('jobが上限byteを超える');
|
|
33
|
+
job = JSON.parse(bytes.toString('utf8'));
|
|
34
|
+
} catch (error) {
|
|
35
|
+
fail(`jobを読めない: ${String(error?.message ?? error)}`);
|
|
36
|
+
}
|
|
37
|
+
if (job?.schema !== 'lattice.scripted_worker_job.v1') fail('job schemaが不正');
|
|
38
|
+
|
|
39
|
+
let result;
|
|
40
|
+
try {
|
|
41
|
+
result = await executePacket({
|
|
42
|
+
packet: job.packet,
|
|
43
|
+
repoRoot: job.worktree_path,
|
|
44
|
+
extraWrites: job.extra_writes ?? [],
|
|
45
|
+
});
|
|
46
|
+
} catch (error) {
|
|
47
|
+
fail(`実行に失敗した: ${String(error?.detail?.reason ?? error?.message ?? error)}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 完了はstdoutの1行で報せる。controllerはこれを受けてreceiptを組む。
|
|
51
|
+
process.stdout.write(`${JSON.stringify({
|
|
52
|
+
schema: 'lattice.scripted_worker_result.v1',
|
|
53
|
+
observed_diff: result.observedDiff,
|
|
54
|
+
checkpoint_digest: result.checkpointDigest,
|
|
55
|
+
})}\n`);
|
|
56
|
+
|
|
57
|
+
// 生きたまま待つ。ここがrunの「作業中」であり、barrierはこのprocessを止めて静止を証明する。
|
|
58
|
+
const holdMs = Number.isSafeInteger(job.hold_ms) && job.hold_ms > 0 ? job.hold_ms : 0;
|
|
59
|
+
if (holdMs > 0) await new Promise((resolve) => { setTimeout(resolve, holdMs); });
|
package/bin/lattice.mjs
CHANGED
|
@@ -90,7 +90,18 @@ if (help !== null) {
|
|
|
90
90
|
// typed契約(cli_error.v2+exit 1/2)の外へ漏れた例外=内部故障。opt-in時のみ観測を残す。
|
|
91
91
|
const { observeRuntimeError } = await import('../src/runtime-errors.mjs');
|
|
92
92
|
observeRuntimeError('LATTICE.CLI_INTERNAL_FAILED', { version: packageJson.version });
|
|
93
|
-
|
|
93
|
+
// **理由を捨てない。** 型名だけでは、何が起きたかを追う手段が無い——実際、seam解決の
|
|
94
|
+
// `witness_set_invalid`はAPIを直接叩くまで見えなかった。typed契約の外へ漏れたこと自体は
|
|
95
|
+
// 内部故障だが、漏れた中身は残す。
|
|
96
|
+
process.stderr.write(`${JSON.stringify({
|
|
97
|
+
schema: 'lattice.cli_error.v2', code: 'INTERNAL_FAILURE',
|
|
98
|
+
message: error?.constructor?.name ?? 'Error',
|
|
99
|
+
detail: {
|
|
100
|
+
reason: typeof error?.message === 'string' && error.message.length > 0
|
|
101
|
+
? error.message.slice(0, 2_048) : null,
|
|
102
|
+
error_detail: error?.detail ?? null,
|
|
103
|
+
},
|
|
104
|
+
})}\n`);
|
|
94
105
|
process.exitCode = 1;
|
|
95
106
|
}
|
|
96
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
|
@@ -1354,6 +1354,74 @@ function main() {
|
|
|
1354
1354
|
process.exit(1);
|
|
1355
1355
|
}
|
|
1356
1356
|
});
|
|
1357
|
+
/**
|
|
1358
|
+
* lattice sensor file-nodes <file> — one file's indexed symbols, machine-readable.
|
|
1359
|
+
*
|
|
1360
|
+
* Lattice's seam verification needs "which top-level symbols does this file own"
|
|
1361
|
+
* at extraction fidelity (module constants/variables included, regardless of the
|
|
1362
|
+
* value-ref name filter). Reading the DB directly from Lattice would couple it to
|
|
1363
|
+
* the schema, so the contract stays at this CLI boundary like every other read.
|
|
1364
|
+
*
|
|
1365
|
+
* `imports` lists the file's import statements (line extents), and
|
|
1366
|
+
* `import_bindings` the locally bound names with their binding form —
|
|
1367
|
+
* resolved bindings come from the import edges' metadata, unresolvable ones
|
|
1368
|
+
* (builtins etc.) from unresolved_refs. Rewrite tooling joins them by line,
|
|
1369
|
+
* so it never re-parses import text with its own grammar.
|
|
1370
|
+
*/
|
|
1371
|
+
program
|
|
1372
|
+
.command('file-nodes <file>')
|
|
1373
|
+
.description('List indexed symbols of one file (JSON only)')
|
|
1374
|
+
.option('-p, --path <path>', 'Project path')
|
|
1375
|
+
.action(async (file, options) => {
|
|
1376
|
+
const projectPath = resolveProjectPath(options.path);
|
|
1377
|
+
try {
|
|
1378
|
+
if (!(0, directory_1.isInitialized)(projectPath)) {
|
|
1379
|
+
error(`LatticeSensor not initialized in ${projectPath}`);
|
|
1380
|
+
process.exit(1);
|
|
1381
|
+
}
|
|
1382
|
+
const { default: LatticeSensor } = await loadLatticeSensor();
|
|
1383
|
+
const cg = await LatticeSensor.open(projectPath);
|
|
1384
|
+
const all = cg.getNodesInFile(file);
|
|
1385
|
+
const nodes = all
|
|
1386
|
+
.filter(n => n.kind !== 'file' && n.kind !== 'import')
|
|
1387
|
+
.map(n => ({
|
|
1388
|
+
name: n.name, kind: n.kind, startLine: n.startLine, endLine: n.endLine,
|
|
1389
|
+
extentStartLine: n.extentStartLine ?? n.startLine,
|
|
1390
|
+
isExported: n.isExported === true,
|
|
1391
|
+
}));
|
|
1392
|
+
const imports = all
|
|
1393
|
+
.filter(n => n.kind === 'import')
|
|
1394
|
+
.map(n => ({ name: n.name, startLine: n.startLine, endLine: n.endLine }));
|
|
1395
|
+
const importBindings = [];
|
|
1396
|
+
const fileNode = all.find(n => n.kind === 'file');
|
|
1397
|
+
for (const edge of fileNode ? cg.getOutgoingEdges(fileNode.id) : []) {
|
|
1398
|
+
if (edge.kind !== 'imports')
|
|
1399
|
+
continue;
|
|
1400
|
+
const meta = edge.metadata;
|
|
1401
|
+
if (typeof meta?.binding !== 'string' || typeof meta?.refName !== 'string')
|
|
1402
|
+
continue;
|
|
1403
|
+
importBindings.push({
|
|
1404
|
+
local: meta.refName, form: meta.binding,
|
|
1405
|
+
imported: typeof meta.importedName === 'string' ? meta.importedName : null,
|
|
1406
|
+
line: typeof edge.line === 'number' ? edge.line : null,
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
for (const ref of cg.getImportBindingRefsForFile(file)) {
|
|
1410
|
+
if (ref.referenceKind !== 'imports' || typeof ref.bindingForm !== 'string')
|
|
1411
|
+
continue;
|
|
1412
|
+
importBindings.push({
|
|
1413
|
+
local: ref.referenceName, form: ref.bindingForm,
|
|
1414
|
+
imported: ref.importedName ?? null, line: ref.line,
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
console.log(JSON.stringify({ filePath: file, nodes, imports, import_bindings: importBindings }));
|
|
1418
|
+
cg.destroy();
|
|
1419
|
+
}
|
|
1420
|
+
catch (err) {
|
|
1421
|
+
error(`file-nodes failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1422
|
+
process.exit(1);
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1357
1425
|
/**
|
|
1358
1426
|
* lattice sensor files [path]
|
|
1359
1427
|
*/
|
|
@@ -1732,7 +1800,7 @@ function main() {
|
|
|
1732
1800
|
for (const c of cg.getCallers(match.node.id)) {
|
|
1733
1801
|
if (!seen.has(c.node.id)) {
|
|
1734
1802
|
seen.add(c.node.id);
|
|
1735
|
-
allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
|
|
1803
|
+
allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeKind: c.edge.kind, valueRef: c.edge.metadata?.valueRef === true, valueWrite: c.edge.metadata?.write === true });
|
|
1736
1804
|
}
|
|
1737
1805
|
}
|
|
1738
1806
|
}
|
|
@@ -1741,7 +1809,7 @@ function main() {
|
|
|
1741
1809
|
for (const c of cg.getCallers(matches[0].node.id)) {
|
|
1742
1810
|
if (!seen.has(c.node.id)) {
|
|
1743
1811
|
seen.add(c.node.id);
|
|
1744
|
-
allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
|
|
1812
|
+
allCallers.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeKind: c.edge.kind, valueRef: c.edge.metadata?.valueRef === true, valueWrite: c.edge.metadata?.write === true });
|
|
1745
1813
|
}
|
|
1746
1814
|
}
|
|
1747
1815
|
}
|
|
@@ -1803,7 +1871,7 @@ function main() {
|
|
|
1803
1871
|
for (const c of cg.getCallees(match.node.id)) {
|
|
1804
1872
|
if (!seen.has(c.node.id)) {
|
|
1805
1873
|
seen.add(c.node.id);
|
|
1806
|
-
allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
|
|
1874
|
+
allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeKind: c.edge.kind, valueRef: c.edge.metadata?.valueRef === true, valueWrite: c.edge.metadata?.write === true });
|
|
1807
1875
|
}
|
|
1808
1876
|
}
|
|
1809
1877
|
}
|
|
@@ -1811,7 +1879,7 @@ function main() {
|
|
|
1811
1879
|
for (const c of cg.getCallees(matches[0].node.id)) {
|
|
1812
1880
|
if (!seen.has(c.node.id)) {
|
|
1813
1881
|
seen.add(c.node.id);
|
|
1814
|
-
allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine });
|
|
1882
|
+
allCallees.push({ name: c.node.name, kind: c.node.kind, filePath: c.node.filePath, startLine: c.node.startLine, edgeKind: c.edge.kind, valueRef: c.edge.metadata?.valueRef === true, valueWrite: c.edge.metadata?.write === true });
|
|
1815
1883
|
}
|
|
1816
1884
|
}
|
|
1817
1885
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;GAEG;AACH,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,IAAI,CAAC;CAClC;AA8LD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAU5D;AAiBD;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAiB3E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAG1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,cAAc,GAAG,SAAS,EAAE,CAKpE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,cAAc,GACjB,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAU3E"}
|
|
@@ -14,7 +14,7 @@ exports.getMigrationHistory = getMigrationHistory;
|
|
|
14
14
|
/**
|
|
15
15
|
* Current schema version
|
|
16
16
|
*/
|
|
17
|
-
exports.CURRENT_SCHEMA_VERSION =
|
|
17
|
+
exports.CURRENT_SCHEMA_VERSION = 11;
|
|
18
18
|
/**
|
|
19
19
|
* All migrations in order
|
|
20
20
|
*
|
|
@@ -140,6 +140,30 @@ const migrations = [
|
|
|
140
140
|
`);
|
|
141
141
|
},
|
|
142
142
|
},
|
|
143
|
+
{
|
|
144
|
+
version: 11,
|
|
145
|
+
description: 'nodes.extent_start_line — first line including preceding decorators/attributes, so extent-based extraction does not orphan Python @decorators / Rust #[attributes] (startLine stays the declaration: it participates in node identity)',
|
|
146
|
+
up: (db) => {
|
|
147
|
+
const cols = db.prepare('PRAGMA table_info(nodes)').all();
|
|
148
|
+
if (!cols.some((c) => c.name === 'extent_start_line')) {
|
|
149
|
+
db.exec('ALTER TABLE nodes ADD COLUMN extent_start_line INTEGER');
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
version: 10,
|
|
155
|
+
description: 'Carry import binding shape (default/named/namespace + source-side name) on unresolved refs so resolved import edges can expose it — rewrite tooling reproduces the binding without re-parsing import text',
|
|
156
|
+
up: (db) => {
|
|
157
|
+
const cols = db.prepare('PRAGMA table_info(unresolved_refs)').all();
|
|
158
|
+
const hasColumn = (name) => cols.some((c) => c.name === name);
|
|
159
|
+
if (!hasColumn('binding_form')) {
|
|
160
|
+
db.exec('ALTER TABLE unresolved_refs ADD COLUMN binding_form TEXT');
|
|
161
|
+
}
|
|
162
|
+
if (!hasColumn('imported_name')) {
|
|
163
|
+
db.exec('ALTER TABLE unresolved_refs ADD COLUMN imported_name TEXT');
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
},
|
|
143
167
|
{
|
|
144
168
|
version: 9,
|
|
145
169
|
description: 'Persist resolution confidence and resolvedBy as their own edges columns (ADR 0048) — previously they only lived in edges.metadata JSON, invisible to index-level filtering/corroboration',
|
|
@@ -189,7 +213,13 @@ function getCurrentVersion(db) {
|
|
|
189
213
|
* Record a migration as applied
|
|
190
214
|
*/
|
|
191
215
|
function recordMigration(db, version, description) {
|
|
192
|
-
|
|
216
|
+
// OR REPLACE: re-running from an older recorded version (a migration history
|
|
217
|
+
// restored from backup, or a partially-reverted history) re-applies every
|
|
218
|
+
// migration above the gap. Migrations themselves are idempotent by contract;
|
|
219
|
+
// the RECORD write must be too, or the first version above the gap that is
|
|
220
|
+
// still recorded blows up on the UNIQUE constraint — first reachable once a
|
|
221
|
+
// v(N+1) exists above a reverted v(N), so it stayed latent until v10.
|
|
222
|
+
db.prepare('INSERT OR REPLACE INTO schema_versions (version, applied_at, description) VALUES (?, ?, ?)').run(version, Date.now(), description);
|
|
193
223
|
}
|
|
194
224
|
/**
|
|
195
225
|
* Run all pending migrations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAiNH,8CAUC;AAoBD,sCAiBC;AAKD,wCAGC;AAKD,oDAKC;AAKD,kDAYC;AA/RD;;GAEG;AACU,QAAA,sBAAsB,GAAG,EAAE,CAAC;AAWzC;;;;;GAKG;AACH,MAAM,UAAU,GAAgB;IAC9B;QACE,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,uEAAuE;QACpF,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;YACT,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;OAWP,CAAC,CAAC;QACL,CAAC;KACF;IACD;QACE,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,gFAAgF;QAC7F,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;YACT,EAAE,CAAC,IAAI,CAAC;;OAEP,CAAC,CAAC;QACL,CAAC;KACF;IACD;QACE,OAAO,EAAE,CAAC;QACV,WAAW,EACT,sGAAsG;QACxG,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;YACT,EAAE,CAAC,IAAI,CAAC;;;OAGP,CAAC,CAAC;QACL,CAAC;KACF;IACD;QACE,OAAO,EAAE,CAAC;QACV,WAAW,EACT,oHAAoH;QACtH,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;YACT,EAAE,CAAC,IAAI,CAAC;;OAEP,CAAC,CAAC;QACL,CAAC;KACF;IACD;QACE,OAAO,EAAE,CAAC;QACV,WAAW,EACT,uGAAuG;QACzG,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE;YACT,2EAA2E;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AAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACxB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,WAAW,EAAE,GAAG,CAAC,WAAW;KAC7B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -461,6 +461,16 @@ export declare class QueryBuilder {
|
|
|
461
461
|
* Uses the idx_unresolved_file_path index for efficient lookup.
|
|
462
462
|
*/
|
|
463
463
|
getUnresolvedReferencesByFiles(filePaths: string[]): UnresolvedReference[];
|
|
464
|
+
/**
|
|
465
|
+
* Import-binding refs of one file, regardless of resolution status.
|
|
466
|
+
*
|
|
467
|
+
* Binding shape (default/named/namespace + alias source name) is an
|
|
468
|
+
* extraction fact. Resolution parks refs whose target never materializes
|
|
469
|
+
* (builtins, external packages) as `failed`, and the pending-only readers
|
|
470
|
+
* hide them — but the binding stays true. Rewrite tooling must see every
|
|
471
|
+
* bound local name, so this reader ignores `status` on purpose.
|
|
472
|
+
*/
|
|
473
|
+
getImportBindingRefsByFile(filePath: string): UnresolvedReference[];
|
|
464
474
|
/**
|
|
465
475
|
* Delete all unresolved references (after resolution)
|
|
466
476
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/db/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,EACb,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/db/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,IAAI,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M,EAAE;IAkBlD;;;;;;OAMG;IACH,mBAAmB,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAMvD;;OAEG;IACH,QAAQ,IAAI,UAAU;IAiDtB;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKvC;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAM7C;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IASxC;;OAEG;IACH,KAAK,IAAI,IAAI;CASd"}
|
|
@@ -107,6 +107,7 @@ function rowToNode(row) {
|
|
|
107
107
|
decorators: row.decorators ? (0, utils_1.safeJsonParse)(row.decorators, undefined) : undefined,
|
|
108
108
|
typeParameters: row.type_parameters ? (0, utils_1.safeJsonParse)(row.type_parameters, undefined) : undefined,
|
|
109
109
|
returnType: row.return_type ?? undefined,
|
|
110
|
+
extentStartLine: row.extent_start_line ?? undefined,
|
|
110
111
|
updatedAt: row.updated_at,
|
|
111
112
|
};
|
|
112
113
|
}
|
|
@@ -252,13 +253,13 @@ class QueryBuilder {
|
|
|
252
253
|
start_line, end_line, start_column, end_column,
|
|
253
254
|
docstring, signature, visibility,
|
|
254
255
|
is_exported, is_async, is_static, is_abstract,
|
|
255
|
-
decorators, type_parameters, return_type, updated_at
|
|
256
|
+
decorators, type_parameters, return_type, extent_start_line, updated_at
|
|
256
257
|
) VALUES (
|
|
257
258
|
@id, @kind, @name, @qualifiedName, @filePath, @language,
|
|
258
259
|
@startLine, @endLine, @startColumn, @endColumn,
|
|
259
260
|
@docstring, @signature, @visibility,
|
|
260
261
|
@isExported, @isAsync, @isStatic, @isAbstract,
|
|
261
|
-
@decorators, @typeParameters, @returnType, @updatedAt
|
|
262
|
+
@decorators, @typeParameters, @returnType, @extentStartLine, @updatedAt
|
|
262
263
|
)
|
|
263
264
|
`);
|
|
264
265
|
}
|
|
@@ -299,6 +300,7 @@ class QueryBuilder {
|
|
|
299
300
|
decorators: node.decorators ? JSON.stringify(node.decorators) : null,
|
|
300
301
|
typeParameters: node.typeParameters ? JSON.stringify(node.typeParameters) : null,
|
|
301
302
|
returnType: node.returnType ?? null,
|
|
303
|
+
extentStartLine: node.extentStartLine ?? null,
|
|
302
304
|
updatedAt: node.updatedAt ?? Date.now(),
|
|
303
305
|
});
|
|
304
306
|
// Segment vocabulary rides the same write path (and transaction) so it can
|
|
@@ -370,6 +372,7 @@ class QueryBuilder {
|
|
|
370
372
|
node.decorators ? JSON.stringify(node.decorators) : null,
|
|
371
373
|
node.typeParameters ? JSON.stringify(node.typeParameters) : null,
|
|
372
374
|
node.returnType ?? null,
|
|
375
|
+
node.extentStartLine ?? null,
|
|
373
376
|
node.updatedAt ?? Date.now(),
|
|
374
377
|
]);
|
|
375
378
|
if (this.isSegmentableKind(node.kind))
|
|
@@ -380,8 +383,8 @@ class QueryBuilder {
|
|
|
380
383
|
start_line, end_line, start_column, end_column,
|
|
381
384
|
docstring, signature, visibility,
|
|
382
385
|
is_exported, is_async, is_static, is_abstract,
|
|
383
|
-
decorators, type_parameters, return_type, updated_at
|
|
384
|
-
) VALUES `, '(
|
|
386
|
+
decorators, type_parameters, return_type, extent_start_line, updated_at
|
|
387
|
+
) VALUES `, '(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', rows);
|
|
385
388
|
this.runBatched('insertNameSegments', 'INSERT OR IGNORE INTO name_segment_vocab (segment, name) VALUES ', '(?,?)', segmentRows);
|
|
386
389
|
})();
|
|
387
390
|
}
|
|
@@ -460,6 +463,7 @@ class QueryBuilder {
|
|
|
460
463
|
decorators = @decorators,
|
|
461
464
|
type_parameters = @typeParameters,
|
|
462
465
|
return_type = @returnType,
|
|
466
|
+
extent_start_line = @extentStartLine,
|
|
463
467
|
updated_at = @updatedAt
|
|
464
468
|
WHERE id = @id
|
|
465
469
|
`);
|
|
@@ -492,6 +496,7 @@ class QueryBuilder {
|
|
|
492
496
|
decorators: node.decorators ? JSON.stringify(node.decorators) : null,
|
|
493
497
|
typeParameters: node.typeParameters ? JSON.stringify(node.typeParameters) : null,
|
|
494
498
|
returnType: node.returnType ?? null,
|
|
499
|
+
extentStartLine: node.extentStartLine ?? null,
|
|
495
500
|
updatedAt: node.updatedAt ?? Date.now(),
|
|
496
501
|
});
|
|
497
502
|
// updateNode is a second real write path to `nodes` — framework
|
|
@@ -1708,8 +1713,8 @@ class QueryBuilder {
|
|
|
1708
1713
|
insertUnresolvedRef(ref) {
|
|
1709
1714
|
if (!this.stmts.insertUnresolved) {
|
|
1710
1715
|
this.stmts.insertUnresolved = this.db.prepare(`
|
|
1711
|
-
INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, col, candidates, file_path, language)
|
|
1712
|
-
VALUES (@fromNodeId, @referenceName, @referenceKind, @line, @col, @candidates, @filePath, @language)
|
|
1716
|
+
INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, col, candidates, file_path, language, binding_form, imported_name)
|
|
1717
|
+
VALUES (@fromNodeId, @referenceName, @referenceKind, @line, @col, @candidates, @filePath, @language, @bindingForm, @importedName)
|
|
1713
1718
|
`);
|
|
1714
1719
|
}
|
|
1715
1720
|
this.stmts.insertUnresolved.run({
|
|
@@ -1721,6 +1726,8 @@ class QueryBuilder {
|
|
|
1721
1726
|
candidates: ref.candidates ? JSON.stringify(ref.candidates) : null,
|
|
1722
1727
|
filePath: ref.filePath ?? '',
|
|
1723
1728
|
language: ref.language ?? 'unknown',
|
|
1729
|
+
bindingForm: ref.bindingForm ?? null,
|
|
1730
|
+
importedName: ref.importedName ?? null,
|
|
1724
1731
|
});
|
|
1725
1732
|
}
|
|
1726
1733
|
/**
|
|
@@ -1741,9 +1748,11 @@ class QueryBuilder {
|
|
|
1741
1748
|
ref.candidates ? JSON.stringify(ref.candidates) : null,
|
|
1742
1749
|
ref.filePath ?? '',
|
|
1743
1750
|
ref.language ?? 'unknown',
|
|
1751
|
+
ref.bindingForm ?? null,
|
|
1752
|
+
ref.importedName ?? null,
|
|
1744
1753
|
]);
|
|
1745
1754
|
}
|
|
1746
|
-
this.runBatched('insertUnresolvedRefs', 'INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, col, candidates, file_path, language) VALUES ', '(
|
|
1755
|
+
this.runBatched('insertUnresolvedRefs', 'INSERT INTO unresolved_refs (from_node_id, reference_name, reference_kind, line, col, candidates, file_path, language, binding_form, imported_name) VALUES ', '(?,?,?,?,?,?,?,?,?,?)', rows);
|
|
1747
1756
|
});
|
|
1748
1757
|
insert();
|
|
1749
1758
|
}
|
|
@@ -1774,6 +1783,8 @@ class QueryBuilder {
|
|
|
1774
1783
|
filePath: row.file_path,
|
|
1775
1784
|
language: row.language,
|
|
1776
1785
|
rowId: row.id,
|
|
1786
|
+
bindingForm: (row.binding_form ?? undefined),
|
|
1787
|
+
importedName: row.imported_name ?? undefined,
|
|
1777
1788
|
}));
|
|
1778
1789
|
}
|
|
1779
1790
|
/**
|
|
@@ -1791,6 +1802,8 @@ class QueryBuilder {
|
|
|
1791
1802
|
filePath: row.file_path,
|
|
1792
1803
|
language: row.language,
|
|
1793
1804
|
rowId: row.id,
|
|
1805
|
+
bindingForm: (row.binding_form ?? undefined),
|
|
1806
|
+
importedName: row.imported_name ?? undefined,
|
|
1794
1807
|
}));
|
|
1795
1808
|
}
|
|
1796
1809
|
/**
|
|
@@ -1833,6 +1846,8 @@ class QueryBuilder {
|
|
|
1833
1846
|
filePath: row.file_path,
|
|
1834
1847
|
language: row.language,
|
|
1835
1848
|
rowId: row.id,
|
|
1849
|
+
bindingForm: (row.binding_form ?? undefined),
|
|
1850
|
+
importedName: row.imported_name ?? undefined,
|
|
1836
1851
|
}));
|
|
1837
1852
|
}
|
|
1838
1853
|
/**
|
|
@@ -1897,6 +1912,35 @@ class QueryBuilder {
|
|
|
1897
1912
|
filePath: row.file_path,
|
|
1898
1913
|
language: row.language,
|
|
1899
1914
|
rowId: row.id,
|
|
1915
|
+
bindingForm: (row.binding_form ?? undefined),
|
|
1916
|
+
importedName: row.imported_name ?? undefined,
|
|
1917
|
+
}));
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Import-binding refs of one file, regardless of resolution status.
|
|
1921
|
+
*
|
|
1922
|
+
* Binding shape (default/named/namespace + alias source name) is an
|
|
1923
|
+
* extraction fact. Resolution parks refs whose target never materializes
|
|
1924
|
+
* (builtins, external packages) as `failed`, and the pending-only readers
|
|
1925
|
+
* hide them — but the binding stays true. Rewrite tooling must see every
|
|
1926
|
+
* bound local name, so this reader ignores `status` on purpose.
|
|
1927
|
+
*/
|
|
1928
|
+
getImportBindingRefsByFile(filePath) {
|
|
1929
|
+
const rows = this.db
|
|
1930
|
+
.prepare("SELECT * FROM unresolved_refs WHERE file_path = ? AND reference_kind = 'imports' AND binding_form IS NOT NULL")
|
|
1931
|
+
.all(filePath);
|
|
1932
|
+
return rows.map((row) => ({
|
|
1933
|
+
fromNodeId: row.from_node_id,
|
|
1934
|
+
referenceName: row.reference_name,
|
|
1935
|
+
referenceKind: row.reference_kind,
|
|
1936
|
+
line: row.line,
|
|
1937
|
+
column: row.col,
|
|
1938
|
+
candidates: row.candidates ? (0, utils_1.safeJsonParse)(row.candidates, undefined) : undefined,
|
|
1939
|
+
filePath: row.file_path,
|
|
1940
|
+
language: row.language,
|
|
1941
|
+
rowId: row.id,
|
|
1942
|
+
bindingForm: (row.binding_form ?? undefined),
|
|
1943
|
+
importedName: row.imported_name ?? undefined,
|
|
1900
1944
|
}));
|
|
1901
1945
|
}
|
|
1902
1946
|
/**
|
|
@@ -2056,6 +2100,8 @@ class QueryBuilder {
|
|
|
2056
2100
|
filePath: row.file_path,
|
|
2057
2101
|
language: row.language,
|
|
2058
2102
|
rowId: row.id,
|
|
2103
|
+
bindingForm: (row.binding_form ?? undefined),
|
|
2104
|
+
importedName: row.imported_name ?? undefined,
|
|
2059
2105
|
}));
|
|
2060
2106
|
}
|
|
2061
2107
|
/**
|