@quolu/lattice 0.63.0 → 0.63.2

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.
Files changed (60) hide show
  1. package/LICENSE +147 -147
  2. package/README.ja.md +378 -378
  3. package/README.md +303 -303
  4. package/bin/lattice-mcp.mjs +0 -0
  5. package/bin/lattice-scripted-adapter.mjs +0 -0
  6. package/bin/lattice-scripted-worker.mjs +0 -0
  7. package/bin/lattice-work-order-adapter.mjs +0 -0
  8. package/bin/lattice.mjs +3 -1
  9. package/docs/bridge-setup.md +248 -248
  10. package/docs/schemas/lattice.executor_packet.v1.schema.json +57 -57
  11. package/docs/schemas/lattice.executor_receipt.v1.schema.json +66 -66
  12. package/docs/schemas/lattice.phase_todo_revision.v3.schema.json +360 -360
  13. package/docs/schemas/lattice.plan_create_input.v1.schema.json +56 -56
  14. package/docs/schemas/lattice.plan_create_input.v2.schema.json +72 -72
  15. package/docs/schemas/lattice.plan_create_input.v3.schema.json +81 -81
  16. package/docs/schemas/lattice.plan_create_input.v4.schema.json +357 -85
  17. package/docs/schemas/lattice.plan_scope_review.v1.schema.json +55 -55
  18. package/docs/schemas/lattice.run_request.v1.schema.json +238 -238
  19. package/docs/schemas/lattice.runtime_adapter_capabilities.v2.schema.json +55 -55
  20. package/docs/schemas/lattice.runtime_adapter_registration_input.v1.schema.json +78 -78
  21. package/docs/schemas/lattice.runtime_adapter_registration_input.v2.schema.json +86 -86
  22. package/docs/schemas/lattice.todo_extraction.v2.schema.json +298 -298
  23. package/docs/schemas/lattice.todo_extraction.v3.schema.json +150 -150
  24. package/docs/schemas/lattice.todo_extraction.v4.schema.json +161 -161
  25. package/docs/schemas/lattice.todo_revision.v2.schema.json +260 -260
  26. package/docs/schemas/lattice.todo_revision_set.v3.schema.json +363 -363
  27. package/docs/schemas/lattice.todo_structure_binding.v1.schema.json +47 -47
  28. package/docs/schemas/lattice.todo_structure_realization.v1.schema.json +55 -55
  29. package/docs/schemas/lattice.todo_structure_set.v1.schema.json +264 -264
  30. package/package.json +109 -109
  31. package/sensor/LICENSE +21 -21
  32. package/sensor/NOTICE +19 -19
  33. package/sensor/dist/bin/lattice-sensor.js +9 -9
  34. package/sensor/dist/db/index.js +24 -24
  35. package/sensor/dist/db/migrations.js +41 -41
  36. package/sensor/dist/db/queries.js +164 -164
  37. package/sensor/dist/db/schema.sql +205 -205
  38. package/sensor/dist/directory.js +5 -5
  39. package/sensor/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  40. package/sensor/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  41. package/sensor/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  42. package/sensor/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  43. package/sensor/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  44. package/sensor/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  45. package/sensor/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  46. package/sensor/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  47. package/sensor/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  48. package/sensor/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  49. package/sensor/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  50. package/sensor/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  51. package/sensor/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  52. package/sensor/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  53. package/sensor/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  54. package/sensor/dist/mcp/liveness-watchdog.js +53 -53
  55. package/sensor/dist/mcp/server-instructions.js +95 -95
  56. package/sensor/package.json +56 -56
  57. package/src/project-cli.mjs +164 -24
  58. package/src/todo-authoring-input.mjs +35 -5
  59. package/src/todo-cli.mjs +2 -2
  60. package/src/todo-store.mjs +52 -21
package/package.json CHANGED
@@ -1,109 +1,109 @@
1
- {
2
- "name": "@quolu/lattice",
3
- "version": "0.63.0",
4
- "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
- "author": {
6
- "name": "Quo / クオ at kitepon.dev",
7
- "url": "https://kitepon.dev/"
8
- },
9
- "type": "module",
10
- "license": "PolyForm-Noncommercial-1.0.0",
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/kitepon/Lattice.git"
14
- },
15
- "engines": {
16
- "node": ">=22.13 <25 || >=26"
17
- },
18
- "bin": {
19
- "lattice": "bin/lattice.mjs",
20
- "lattice-mcp": "bin/lattice-mcp.mjs",
21
- "lattice-scripted-adapter": "bin/lattice-scripted-adapter.mjs",
22
- "lattice-work-order-adapter": "bin/lattice-work-order-adapter.mjs"
23
- },
24
- "files": [
25
- "bin",
26
- "bin/lattice-scripted-adapter.mjs",
27
- "src",
28
- "docs/schemas/lattice.plan_create_input.v1.schema.json",
29
- "docs/schemas/lattice.plan_create_input.v2.schema.json",
30
- "docs/schemas/lattice.plan_create_input.v3.schema.json",
31
- "docs/schemas/lattice.plan_create_input.v4.schema.json",
32
- "docs/schemas/lattice.plan_scope_review.v1.schema.json",
33
- "docs/schemas/lattice.todo_revision.v2.schema.json",
34
- "docs/schemas/lattice.todo_revision_set.v3.schema.json",
35
- "docs/schemas/lattice.phase_todo_revision.v3.schema.json",
36
- "docs/schemas/lattice.todo_extraction.v2.schema.json",
37
- "docs/schemas/lattice.todo_extraction.v3.schema.json",
38
- "docs/schemas/lattice.todo_extraction.v4.schema.json",
39
- "docs/schemas/lattice.todo_structure_set.v1.schema.json",
40
- "docs/schemas/lattice.todo_structure_realization.v1.schema.json",
41
- "docs/schemas/lattice.todo_structure_binding.v1.schema.json",
42
- "docs/schemas/lattice.run_request.v1.schema.json",
43
- "docs/schemas/lattice.executor_packet.v1.schema.json",
44
- "docs/schemas/lattice.executor_receipt.v1.schema.json",
45
- "docs/schemas/lattice.runtime_adapter_registration_input.v1.schema.json",
46
- "docs/schemas/lattice.runtime_adapter_registration_input.v2.schema.json",
47
- "docs/schemas/lattice.runtime_adapter_capabilities.v2.schema.json",
48
- "docs/bridge-setup.md",
49
- "sensor/dist",
50
- "!sensor/dist/bin/lattice-sensor.*",
51
- "sensor/dist/bin/lattice-sensor.js",
52
- "sensor/package.json",
53
- "sensor/LICENSE",
54
- "sensor/NOTICE"
55
- ],
56
- "publishConfig": {
57
- "access": "public"
58
- },
59
- "dependencies": {
60
- "@clack/prompts": "^1.3.0",
61
- "commander": "^14.0.2",
62
- "fast-string-width": "^3.0.2",
63
- "fast-wrap-ansi": "^0.2.0",
64
- "ignore": "^7.0.5",
65
- "jsonc-parser": "^3.3.1",
66
- "picomatch": "^4.0.3",
67
- "remark-gfm": "^4.0.1",
68
- "remark-parse": "^11.0.0",
69
- "sisteransi": "^1.0.5",
70
- "tree-sitter-wasms": "^0.1.11",
71
- "unified": "^11.0.5",
72
- "web-tree-sitter": "^0.25.3"
73
- },
74
- "scripts": {
75
- "prepack": "npm --prefix sensor run build",
76
- "verify:release-commit": "node scripts/verify-release-commit.mjs",
77
- "prepublishOnly": "npm run verify:release-commit",
78
- "test": "node scripts/run-product-tests.mjs",
79
- "test:profile": "node scripts/run-product-tests.mjs",
80
- "test:sensor": "npm --prefix sensor test",
81
- "check": "node scripts/check-syntax.mjs",
82
- "ci": "npm run test && npm run test:sensor && npm run check && npm run check:cli-surface && npm run check:open-questions && npm run check:reachability && npm run verify:todo-store",
83
- "verify:todo-store": "node bin/lattice.mjs todo verify --json",
84
- "check:cli-surface": "node scripts/verify-cli-surface.mjs",
85
- "check:open-questions": "node scripts/verify-open-questions.mjs",
86
- "check:reachability": "node scripts/verify-product-reachability.mjs",
87
- "upstream:check": "node scripts/upstream-check.mjs",
88
- "upstream:sync": "node scripts/upstream-sync.mjs"
89
- },
90
- "homepage": "https://github.com/kitepon/Lattice#readme",
91
- "bugs": {
92
- "url": "https://github.com/kitepon/Lattice/issues"
93
- },
94
- "keywords": [
95
- "ai",
96
- "agent",
97
- "multi-agent",
98
- "claude",
99
- "codex",
100
- "orchestration",
101
- "parallel",
102
- "refactoring",
103
- "code-analysis",
104
- "dependency-graph",
105
- "scheduling",
106
- "cli",
107
- "mcp"
108
- ]
109
- }
1
+ {
2
+ "name": "@quolu/lattice",
3
+ "version": "0.63.2",
4
+ "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
+ "author": {
6
+ "name": "Quo / クオ at kitepon.dev",
7
+ "url": "https://kitepon.dev/"
8
+ },
9
+ "type": "module",
10
+ "license": "PolyForm-Noncommercial-1.0.0",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/kitepon/Lattice.git"
14
+ },
15
+ "engines": {
16
+ "node": ">=22.13 <25 || >=26"
17
+ },
18
+ "bin": {
19
+ "lattice": "bin/lattice.mjs",
20
+ "lattice-mcp": "bin/lattice-mcp.mjs",
21
+ "lattice-scripted-adapter": "bin/lattice-scripted-adapter.mjs",
22
+ "lattice-work-order-adapter": "bin/lattice-work-order-adapter.mjs"
23
+ },
24
+ "files": [
25
+ "bin",
26
+ "bin/lattice-scripted-adapter.mjs",
27
+ "src",
28
+ "docs/schemas/lattice.plan_create_input.v1.schema.json",
29
+ "docs/schemas/lattice.plan_create_input.v2.schema.json",
30
+ "docs/schemas/lattice.plan_create_input.v3.schema.json",
31
+ "docs/schemas/lattice.plan_create_input.v4.schema.json",
32
+ "docs/schemas/lattice.plan_scope_review.v1.schema.json",
33
+ "docs/schemas/lattice.todo_revision.v2.schema.json",
34
+ "docs/schemas/lattice.todo_revision_set.v3.schema.json",
35
+ "docs/schemas/lattice.phase_todo_revision.v3.schema.json",
36
+ "docs/schemas/lattice.todo_extraction.v2.schema.json",
37
+ "docs/schemas/lattice.todo_extraction.v3.schema.json",
38
+ "docs/schemas/lattice.todo_extraction.v4.schema.json",
39
+ "docs/schemas/lattice.todo_structure_set.v1.schema.json",
40
+ "docs/schemas/lattice.todo_structure_realization.v1.schema.json",
41
+ "docs/schemas/lattice.todo_structure_binding.v1.schema.json",
42
+ "docs/schemas/lattice.run_request.v1.schema.json",
43
+ "docs/schemas/lattice.executor_packet.v1.schema.json",
44
+ "docs/schemas/lattice.executor_receipt.v1.schema.json",
45
+ "docs/schemas/lattice.runtime_adapter_registration_input.v1.schema.json",
46
+ "docs/schemas/lattice.runtime_adapter_registration_input.v2.schema.json",
47
+ "docs/schemas/lattice.runtime_adapter_capabilities.v2.schema.json",
48
+ "docs/bridge-setup.md",
49
+ "sensor/dist",
50
+ "!sensor/dist/bin/lattice-sensor.*",
51
+ "sensor/dist/bin/lattice-sensor.js",
52
+ "sensor/package.json",
53
+ "sensor/LICENSE",
54
+ "sensor/NOTICE"
55
+ ],
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "dependencies": {
60
+ "@clack/prompts": "^1.3.0",
61
+ "commander": "^14.0.2",
62
+ "fast-string-width": "^3.0.2",
63
+ "fast-wrap-ansi": "^0.2.0",
64
+ "ignore": "^7.0.5",
65
+ "jsonc-parser": "^3.3.1",
66
+ "picomatch": "^4.0.3",
67
+ "remark-gfm": "^4.0.1",
68
+ "remark-parse": "^11.0.0",
69
+ "sisteransi": "^1.0.5",
70
+ "tree-sitter-wasms": "^0.1.11",
71
+ "unified": "^11.0.5",
72
+ "web-tree-sitter": "^0.25.3"
73
+ },
74
+ "scripts": {
75
+ "prepack": "npm --prefix sensor run build",
76
+ "verify:release-commit": "node scripts/verify-release-commit.mjs",
77
+ "prepublishOnly": "npm run verify:release-commit",
78
+ "test": "node scripts/run-product-tests.mjs",
79
+ "test:profile": "node scripts/run-product-tests.mjs",
80
+ "test:sensor": "npm --prefix sensor test",
81
+ "check": "node scripts/check-syntax.mjs",
82
+ "ci": "npm run test && npm run test:sensor && npm run check && npm run check:cli-surface && npm run check:open-questions && npm run check:reachability && npm run verify:todo-store",
83
+ "verify:todo-store": "node bin/lattice.mjs todo verify --json",
84
+ "check:cli-surface": "node scripts/verify-cli-surface.mjs",
85
+ "check:open-questions": "node scripts/verify-open-questions.mjs",
86
+ "check:reachability": "node scripts/verify-product-reachability.mjs",
87
+ "upstream:check": "node scripts/upstream-check.mjs",
88
+ "upstream:sync": "node scripts/upstream-sync.mjs"
89
+ },
90
+ "homepage": "https://github.com/kitepon/Lattice#readme",
91
+ "bugs": {
92
+ "url": "https://github.com/kitepon/Lattice/issues"
93
+ },
94
+ "keywords": [
95
+ "ai",
96
+ "agent",
97
+ "multi-agent",
98
+ "claude",
99
+ "codex",
100
+ "orchestration",
101
+ "parallel",
102
+ "refactoring",
103
+ "code-analysis",
104
+ "dependency-graph",
105
+ "scheduling",
106
+ "cli",
107
+ "mcp"
108
+ ]
109
+ }
package/sensor/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Colby Mchenry
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Colby Mchenry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/sensor/NOTICE CHANGED
@@ -1,19 +1,19 @@
1
- # NOTICE — sensor/ の出自
2
-
3
- このディレクトリは CodeGraph (https://github.com/colbymchenry/codegraph) を
4
- Lattice の構造 sensor として吸収したものである(Lattice ADR 0047 / 0048)。
5
-
6
- - upstream: @colbymchenry/codegraph(MIT License — 同梱の LICENSE を保持)
7
- - 吸収時点: upstream commit 04ab45c91fff97263d2d305ecb2908bce80bd159 (2026-07-17)
8
- - 取り込み方法: `git archive`(pristine tree。改変は吸収後の履歴が持つ)
9
- - 取り込み時の唯一の改変: upstream `CLAUDE.md` → `docs/UPSTREAM-CLAUDE.md` へ移動
10
- (Lattice 内での AI セッションへ upstream 正典が自動注入されるのを防ぐ。内容は不変)
11
- ## upstream 追従方針(ADR 0155・オーナー裁定 2026-08-03)
12
-
13
- - 既定は**全量 3-way merge**。貰えるものは全部取り込む。旧方針(選択的 cherry-pick・
14
- 必要駆動の監視)は54コミット溜めた実績をもって廃止した(経緯は ADR 0155)。
15
- - 正本は `sensor/UPSTREAM.json`(同期点 synced_at・path 写像・skip・衝突方針・削除承認)。
16
- - 追従は `npm run upstream:sync`(衝突後は解決 → commit → `--mark-synced`)、
17
- 検知は週次の `.github/workflows/upstream-check.yml` と `npm run upstream:check`。
18
- - 取り込み履歴は UPSTREAM.json の synced_at と git 履歴が持つ(本 NOTICE には重複記録しない)。
19
- 現在の同期点: 49c11fc(2026-08-03、54コミット消化・kernel 20言語化)。
1
+ # NOTICE — sensor/ の出自
2
+
3
+ このディレクトリは CodeGraph (https://github.com/colbymchenry/codegraph) を
4
+ Lattice の構造 sensor として吸収したものである(Lattice ADR 0047 / 0048)。
5
+
6
+ - upstream: @colbymchenry/codegraph(MIT License — 同梱の LICENSE を保持)
7
+ - 吸収時点: upstream commit 04ab45c91fff97263d2d305ecb2908bce80bd159 (2026-07-17)
8
+ - 取り込み方法: `git archive`(pristine tree。改変は吸収後の履歴が持つ)
9
+ - 取り込み時の唯一の改変: upstream `CLAUDE.md` → `docs/UPSTREAM-CLAUDE.md` へ移動
10
+ (Lattice 内での AI セッションへ upstream 正典が自動注入されるのを防ぐ。内容は不変)
11
+ ## upstream 追従方針(ADR 0155・オーナー裁定 2026-08-03)
12
+
13
+ - 既定は**全量 3-way merge**。貰えるものは全部取り込む。旧方針(選択的 cherry-pick・
14
+ 必要駆動の監視)は54コミット溜めた実績をもって廃止した(経緯は ADR 0155)。
15
+ - 正本は `sensor/UPSTREAM.json`(同期点 synced_at・path 写像・skip・衝突方針・削除承認)。
16
+ - 追従は `npm run upstream:sync`(衝突後は解決 → commit → `--mark-synced`)、
17
+ 検知は週次の `.github/workflows/upstream-check.yml` と `npm run upstream:check`。
18
+ - 取り込み履歴は UPSTREAM.json の synced_at と git 履歴が持つ(本 NOTICE には重複記録しない)。
19
+ 現在の同期点: 49c11fc(2026-08-03、54コミット消化・kernel 20言語化)。
@@ -1742,15 +1742,15 @@ function main() {
1742
1742
  console.error(chalk.bold('\nLatticeSensor MCP Server\n'));
1743
1743
  console.error(chalk.blue((0, glyphs_1.getGlyphs)().info) + ' Use --mcp flag to start the MCP server');
1744
1744
  console.error('\nTo use with Claude Code, add to your MCP configuration:');
1745
- console.error(chalk.dim(`
1746
- {
1747
- "mcpServers": {
1748
- "lattice-sensor": {
1749
- "command": "lattice-sensor",
1750
- "args": ["serve", "--mcp"]
1751
- }
1752
- }
1753
- }
1745
+ console.error(chalk.dim(`
1746
+ {
1747
+ "mcpServers": {
1748
+ "lattice-sensor": {
1749
+ "command": "lattice-sensor",
1750
+ "args": ["serve", "--mcp"]
1751
+ }
1752
+ }
1753
+ }
1754
1754
  `));
1755
1755
  console.error('Available tools:');
1756
1756
  console.error(chalk.cyan(' lattice_sensor_explore') + ' - Primary: source of the relevant symbols for any question');
@@ -584,21 +584,21 @@ class DatabaseConnection {
584
584
  }
585
585
  try {
586
586
  const { Worker } = await Promise.resolve().then(() => __importStar(require('node:worker_threads')));
587
- const workerSource = `
588
- const { workerData, parentPort } = require('node:worker_threads');
589
- let row = null;
590
- let err = null;
591
- try {
592
- const { DatabaseSync } = require('node:sqlite');
593
- const db = new DatabaseSync(workerData.dbPath);
594
- const mode = workerData.mode === 'TRUNCATE' ? 'TRUNCATE' : 'PASSIVE';
595
- try {
596
- if (mode === 'TRUNCATE') db.exec('PRAGMA busy_timeout = 2000');
597
- row = db.prepare('PRAGMA wal_checkpoint(' + mode + ')').get();
598
- } catch (e) { err = String(e && e.message || e); }
599
- try { db.close(); } catch {}
600
- } catch (e) { err = err || String(e && e.message || e); }
601
- parentPort.postMessage({ row, err });
587
+ const workerSource = `
588
+ const { workerData, parentPort } = require('node:worker_threads');
589
+ let row = null;
590
+ let err = null;
591
+ try {
592
+ const { DatabaseSync } = require('node:sqlite');
593
+ const db = new DatabaseSync(workerData.dbPath);
594
+ const mode = workerData.mode === 'TRUNCATE' ? 'TRUNCATE' : 'PASSIVE';
595
+ try {
596
+ if (mode === 'TRUNCATE') db.exec('PRAGMA busy_timeout = 2000');
597
+ row = db.prepare('PRAGMA wal_checkpoint(' + mode + ')').get();
598
+ } catch (e) { err = String(e && e.message || e); }
599
+ try { db.close(); } catch {}
600
+ } catch (e) { err = err || String(e && e.message || e); }
601
+ parentPort.postMessage({ row, err });
602
602
  `;
603
603
  return await new Promise((resolve) => {
604
604
  let settled = false;
@@ -693,15 +693,15 @@ class DatabaseConnection {
693
693
  async runPragmasOffThread(pragmas, inlineFallback = []) {
694
694
  try {
695
695
  const { Worker } = await Promise.resolve().then(() => __importStar(require('node:worker_threads')));
696
- const workerSource = `
697
- const { workerData, parentPort } = require('node:worker_threads');
698
- try {
699
- const { DatabaseSync } = require('node:sqlite');
700
- const db = new DatabaseSync(workerData.dbPath);
701
- for (const p of workerData.pragmas) { try { db.exec(p); } catch {} }
702
- try { db.close(); } catch {}
703
- } catch {}
704
- parentPort.postMessage('done');
696
+ const workerSource = `
697
+ const { workerData, parentPort } = require('node:worker_threads');
698
+ try {
699
+ const { DatabaseSync } = require('node:sqlite');
700
+ const db = new DatabaseSync(workerData.dbPath);
701
+ for (const p of workerData.pragmas) { try { db.exec(p); } catch {} }
702
+ try { db.close(); } catch {}
703
+ } catch {}
704
+ parentPort.postMessage('done');
705
705
  `;
706
706
  await new Promise((resolve) => {
707
707
  let settled = false;
@@ -26,17 +26,17 @@ const migrations = [
26
26
  version: 2,
27
27
  description: 'Add project metadata, provenance tracking, and unresolved ref context',
28
28
  up: (db) => {
29
- db.exec(`
30
- CREATE TABLE IF NOT EXISTS project_metadata (
31
- key TEXT PRIMARY KEY,
32
- value TEXT NOT NULL,
33
- updated_at INTEGER NOT NULL
34
- );
35
- ALTER TABLE unresolved_refs ADD COLUMN file_path TEXT NOT NULL DEFAULT '';
36
- ALTER TABLE unresolved_refs ADD COLUMN language TEXT NOT NULL DEFAULT 'unknown';
37
- ALTER TABLE edges ADD COLUMN provenance TEXT DEFAULT NULL;
38
- CREATE INDEX IF NOT EXISTS idx_unresolved_file_path ON unresolved_refs(file_path);
39
- CREATE INDEX IF NOT EXISTS idx_edges_provenance ON edges(provenance);
29
+ db.exec(`
30
+ CREATE TABLE IF NOT EXISTS project_metadata (
31
+ key TEXT PRIMARY KEY,
32
+ value TEXT NOT NULL,
33
+ updated_at INTEGER NOT NULL
34
+ );
35
+ ALTER TABLE unresolved_refs ADD COLUMN file_path TEXT NOT NULL DEFAULT '';
36
+ ALTER TABLE unresolved_refs ADD COLUMN language TEXT NOT NULL DEFAULT 'unknown';
37
+ ALTER TABLE edges ADD COLUMN provenance TEXT DEFAULT NULL;
38
+ CREATE INDEX IF NOT EXISTS idx_unresolved_file_path ON unresolved_refs(file_path);
39
+ CREATE INDEX IF NOT EXISTS idx_edges_provenance ON edges(provenance);
40
40
  `);
41
41
  },
42
42
  },
@@ -44,8 +44,8 @@ const migrations = [
44
44
  version: 3,
45
45
  description: 'Add lower(name) expression index for memory-efficient case-insensitive lookups',
46
46
  up: (db) => {
47
- db.exec(`
48
- CREATE INDEX IF NOT EXISTS idx_nodes_lower_name ON nodes(lower(name));
47
+ db.exec(`
48
+ CREATE INDEX IF NOT EXISTS idx_nodes_lower_name ON nodes(lower(name));
49
49
  `);
50
50
  },
51
51
  },
@@ -53,9 +53,9 @@ const migrations = [
53
53
  version: 4,
54
54
  description: 'Drop redundant idx_edges_source / idx_edges_target (covered by source_kind / target_kind composites)',
55
55
  up: (db) => {
56
- db.exec(`
57
- DROP INDEX IF EXISTS idx_edges_source;
58
- DROP INDEX IF EXISTS idx_edges_target;
56
+ db.exec(`
57
+ DROP INDEX IF EXISTS idx_edges_source;
58
+ DROP INDEX IF EXISTS idx_edges_target;
59
59
  `);
60
60
  },
61
61
  },
@@ -63,8 +63,8 @@ const migrations = [
63
63
  version: 5,
64
64
  description: 'Add nodes.return_type — normalized return/result type for receiver-type inference (C++ singletons/factories, #645)',
65
65
  up: (db) => {
66
- db.exec(`
67
- ALTER TABLE nodes ADD COLUMN return_type TEXT;
66
+ db.exec(`
67
+ ALTER TABLE nodes ADD COLUMN return_type TEXT;
68
68
  `);
69
69
  },
70
70
  },
@@ -81,14 +81,14 @@ const migrations = [
81
81
  // and it MUST match the GROUP BY exactly, or the index creation would
82
82
  // fail on a pair the DELETE left behind. Idempotent: the index is
83
83
  // `IF NOT EXISTS` and the DELETE is a no-op once the table is unique.
84
- db.exec(`
85
- DELETE FROM edges
86
- WHERE id NOT IN (
87
- SELECT MIN(id) FROM edges
88
- GROUP BY source, target, kind, IFNULL(line, -1), IFNULL(col, -1)
89
- );
90
- CREATE UNIQUE INDEX IF NOT EXISTS idx_edges_identity
91
- ON edges(source, target, kind, IFNULL(line, -1), IFNULL(col, -1));
84
+ db.exec(`
85
+ DELETE FROM edges
86
+ WHERE id NOT IN (
87
+ SELECT MIN(id) FROM edges
88
+ GROUP BY source, target, kind, IFNULL(line, -1), IFNULL(col, -1)
89
+ );
90
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_edges_identity
91
+ ON edges(source, target, kind, IFNULL(line, -1), IFNULL(col, -1));
92
92
  `);
93
93
  },
94
94
  },
@@ -101,12 +101,12 @@ const migrations = [
101
101
  // detects that over a populated graph and backfills batched+yielding
102
102
  // (LatticeSensor.rebuildNameSegmentVocab), and any full index rebuilds it
103
103
  // from scratch. Keep the definition in lockstep with schema.sql.
104
- db.exec(`
105
- CREATE TABLE IF NOT EXISTS name_segment_vocab (
106
- segment TEXT NOT NULL,
107
- name TEXT NOT NULL,
108
- PRIMARY KEY (segment, name)
109
- ) WITHOUT ROWID;
104
+ db.exec(`
105
+ CREATE TABLE IF NOT EXISTS name_segment_vocab (
106
+ segment TEXT NOT NULL,
107
+ name TEXT NOT NULL,
108
+ PRIMARY KEY (segment, name)
109
+ ) WITHOUT ROWID;
110
110
  `);
111
111
  },
112
112
  },
@@ -134,9 +134,9 @@ const migrations = [
134
134
  if (!hasColumn('name_tail')) {
135
135
  db.exec("ALTER TABLE unresolved_refs ADD COLUMN name_tail TEXT NOT NULL DEFAULT ''");
136
136
  }
137
- db.exec(`
138
- CREATE INDEX IF NOT EXISTS idx_unresolved_status ON unresolved_refs(status);
139
- CREATE INDEX IF NOT EXISTS idx_unresolved_failed_tail ON unresolved_refs(name_tail) WHERE status = 'failed';
137
+ db.exec(`
138
+ CREATE INDEX IF NOT EXISTS idx_unresolved_status ON unresolved_refs(status);
139
+ CREATE INDEX IF NOT EXISTS idx_unresolved_failed_tail ON unresolved_refs(name_tail) WHERE status = 'failed';
140
140
  `);
141
141
  },
142
142
  },
@@ -193,13 +193,13 @@ const migrations = [
193
193
  // Backfill from the JSON metadata every resolved edge already carries —
194
194
  // only new/re-resolved edges will populate the columns directly going
195
195
  // forward, so existing rows would otherwise read NULL forever.
196
- db.exec(`
197
- UPDATE edges SET confidence = json_extract(metadata, '$.confidence')
198
- WHERE metadata IS NOT NULL AND confidence IS NULL
196
+ db.exec(`
197
+ UPDATE edges SET confidence = json_extract(metadata, '$.confidence')
198
+ WHERE metadata IS NOT NULL AND confidence IS NULL
199
199
  `);
200
- db.exec(`
201
- UPDATE edges SET resolved_by = json_extract(metadata, '$.resolvedBy')
202
- WHERE metadata IS NOT NULL AND resolved_by IS NULL
200
+ db.exec(`
201
+ UPDATE edges SET resolved_by = json_extract(metadata, '$.resolvedBy')
202
+ WHERE metadata IS NOT NULL AND resolved_by IS NULL
203
203
  `);
204
204
  },
205
205
  },