@aroman22/codegraph-vba-darwin-arm64 1.5.1 → 1.6.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/bin/codegraph +5 -0
- package/lib/dist/bin/codegraph.d.ts +1 -1
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +307 -81
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/bin/command-supervision.d.ts +38 -1
- package/lib/dist/bin/command-supervision.d.ts.map +1 -1
- package/lib/dist/bin/command-supervision.js +22 -3
- package/lib/dist/bin/command-supervision.js.map +1 -1
- package/lib/dist/db/index.d.ts +84 -5
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +209 -12
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/migrations.d.ts +1 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +80 -3
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts +127 -4
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +317 -7
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +43 -1
- package/lib/dist/db/wal-valve.d.ts +106 -0
- package/lib/dist/db/wal-valve.d.ts.map +1 -0
- package/lib/dist/db/wal-valve.js +208 -0
- package/lib/dist/db/wal-valve.js.map +1 -0
- package/lib/dist/directory.d.ts +9 -5
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +210 -19
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/extraction/cfml-extractor.d.ts +107 -0
- package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/cfml-extractor.js +494 -0
- package/lib/dist/extraction/cfml-extractor.js.map +1 -0
- package/lib/dist/extraction/grammars.d.ts +25 -1
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +177 -23
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +47 -2
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +568 -51
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/languages/arkts.d.ts +3 -0
- package/lib/dist/extraction/languages/arkts.d.ts.map +1 -0
- package/lib/dist/extraction/languages/arkts.js +127 -0
- package/lib/dist/extraction/languages/arkts.js.map +1 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts +98 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +563 -1
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/cfquery.d.ts +12 -0
- package/lib/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cfquery.js +28 -0
- package/lib/dist/extraction/languages/cfquery.js.map +1 -0
- package/lib/dist/extraction/languages/cfscript.d.ts +3 -0
- package/lib/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cfscript.js +73 -0
- package/lib/dist/extraction/languages/cfscript.js.map +1 -0
- package/lib/dist/extraction/languages/cobol.d.ts +33 -0
- package/lib/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/lib/dist/extraction/languages/cobol.js +499 -0
- package/lib/dist/extraction/languages/cobol.js.map +1 -0
- package/lib/dist/extraction/languages/erlang.d.ts +3 -0
- package/lib/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/lib/dist/extraction/languages/erlang.js +350 -0
- package/lib/dist/extraction/languages/erlang.js.map +1 -0
- package/lib/dist/extraction/languages/index.d.ts.map +1 -1
- package/lib/dist/extraction/languages/index.js +18 -0
- package/lib/dist/extraction/languages/index.js.map +1 -1
- package/lib/dist/extraction/languages/nix.d.ts +3 -0
- package/lib/dist/extraction/languages/nix.d.ts.map +1 -0
- package/lib/dist/extraction/languages/nix.js +294 -0
- package/lib/dist/extraction/languages/nix.js.map +1 -0
- package/lib/dist/extraction/languages/solidity.d.ts +3 -0
- package/lib/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/lib/dist/extraction/languages/solidity.js +293 -0
- package/lib/dist/extraction/languages/solidity.js.map +1 -0
- package/lib/dist/extraction/languages/terraform.d.ts +3 -0
- package/lib/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/lib/dist/extraction/languages/terraform.js +641 -0
- package/lib/dist/extraction/languages/terraform.js.map +1 -0
- package/lib/dist/extraction/languages/vbnet.d.ts +11 -0
- package/lib/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/lib/dist/extraction/languages/vbnet.js +141 -0
- package/lib/dist/extraction/languages/vbnet.js.map +1 -0
- package/lib/dist/extraction/mybatis-extractor.d.ts +30 -10
- package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/mybatis-extractor.js +140 -38
- package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
- package/lib/dist/extraction/parse-pool.d.ts +28 -1
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +76 -7
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +11 -4
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.js +1 -0
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +20 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +60 -1
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +905 -20
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vba/call-sweep.d.ts +3 -0
- package/lib/dist/extraction/vba/call-sweep.d.ts.map +1 -0
- package/lib/dist/extraction/vba/call-sweep.js +206 -0
- package/lib/dist/extraction/vba/call-sweep.js.map +1 -0
- package/lib/dist/extraction/vba/calls.d.ts +55 -0
- package/lib/dist/extraction/vba/calls.d.ts.map +1 -0
- package/lib/dist/extraction/vba/calls.js +439 -0
- package/lib/dist/extraction/vba/calls.js.map +1 -0
- package/lib/dist/extraction/vba/constants.d.ts +42 -0
- package/lib/dist/extraction/vba/constants.d.ts.map +1 -0
- package/lib/dist/extraction/vba/constants.js +112 -0
- package/lib/dist/extraction/vba/constants.js.map +1 -0
- package/lib/dist/extraction/vba/context.d.ts +175 -0
- package/lib/dist/extraction/vba/context.d.ts.map +1 -0
- package/lib/dist/extraction/vba/context.js +268 -0
- package/lib/dist/extraction/vba/context.js.map +1 -0
- package/lib/dist/extraction/vba/controls.d.ts +24 -0
- package/lib/dist/extraction/vba/controls.d.ts.map +1 -0
- package/lib/dist/extraction/vba/controls.js +89 -0
- package/lib/dist/extraction/vba/controls.js.map +1 -0
- package/lib/dist/extraction/vba/declarations.d.ts +3 -0
- package/lib/dist/extraction/vba/declarations.d.ts.map +1 -0
- package/lib/dist/extraction/vba/declarations.js +154 -0
- package/lib/dist/extraction/vba/declarations.js.map +1 -0
- package/lib/dist/extraction/vba/dims.d.ts +3 -0
- package/lib/dist/extraction/vba/dims.d.ts.map +1 -0
- package/lib/dist/extraction/vba/dims.js +186 -0
- package/lib/dist/extraction/vba/dims.js.map +1 -0
- package/lib/dist/extraction/vba/docmd.d.ts +16 -0
- package/lib/dist/extraction/vba/docmd.d.ts.map +1 -0
- package/lib/dist/extraction/vba/docmd.js +179 -0
- package/lib/dist/extraction/vba/docmd.js.map +1 -0
- package/lib/dist/extraction/vba/enums-consts.d.ts +15 -0
- package/lib/dist/extraction/vba/enums-consts.d.ts.map +1 -0
- package/lib/dist/extraction/vba/enums-consts.js +178 -0
- package/lib/dist/extraction/vba/enums-consts.js.map +1 -0
- package/lib/dist/extraction/vba/implements.d.ts +3 -0
- package/lib/dist/extraction/vba/implements.d.ts.map +1 -0
- package/lib/dist/extraction/vba/implements.js +52 -0
- package/lib/dist/extraction/vba/implements.js.map +1 -0
- package/lib/dist/extraction/vba/procedures.d.ts +3 -0
- package/lib/dist/extraction/vba/procedures.d.ts.map +1 -0
- package/lib/dist/extraction/vba/procedures.js +239 -0
- package/lib/dist/extraction/vba/procedures.js.map +1 -0
- package/lib/dist/extraction/vba/sql-wrapper.d.ts +17 -0
- package/lib/dist/extraction/vba/sql-wrapper.d.ts.map +1 -0
- package/lib/dist/extraction/vba/sql-wrapper.js +212 -0
- package/lib/dist/extraction/vba/sql-wrapper.js.map +1 -0
- package/lib/dist/extraction/vba/tempvars.d.ts +10 -0
- package/lib/dist/extraction/vba/tempvars.d.ts.map +1 -0
- package/lib/dist/extraction/vba/tempvars.js +138 -0
- package/lib/dist/extraction/vba/tempvars.js.map +1 -0
- package/lib/dist/extraction/vba/text-utils.d.ts +73 -0
- package/lib/dist/extraction/vba/text-utils.d.ts.map +1 -0
- package/lib/dist/extraction/vba/text-utils.js +195 -0
- package/lib/dist/extraction/vba/text-utils.js.map +1 -0
- package/lib/dist/extraction/vba-extractor.d.ts +3 -951
- package/lib/dist/extraction/vba-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vba-extractor.js +46 -2934
- package/lib/dist/extraction/vba-extractor.js.map +1 -1
- package/lib/dist/extraction/vba-preprocess.d.ts +1 -1
- package/lib/dist/extraction/vba-preprocess.d.ts.map +1 -1
- package/lib/dist/extraction/vba-preprocess.js +300 -88
- package/lib/dist/extraction/vba-preprocess.js.map +1 -1
- package/lib/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +76 -17
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/index.d.ts +81 -1
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +467 -10
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/index.d.ts +42 -0
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +97 -2
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +35 -3
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +101 -9
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.js +2 -1
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/lib/dist/mcp/early-ppid.d.ts +26 -0
- package/lib/dist/mcp/early-ppid.d.ts.map +1 -0
- package/lib/dist/mcp/early-ppid.js +29 -0
- package/lib/dist/mcp/early-ppid.js.map +1 -0
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +29 -4
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts +18 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.js +73 -13
- package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +30 -4
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/query-pool.d.ts +14 -0
- package/lib/dist/mcp/query-pool.d.ts.map +1 -1
- package/lib/dist/mcp/query-pool.js +18 -0
- package/lib/dist/mcp/query-pool.js.map +1 -1
- package/lib/dist/mcp/session.d.ts +14 -0
- package/lib/dist/mcp/session.d.ts.map +1 -1
- package/lib/dist/mcp/session.js +28 -1
- package/lib/dist/mcp/session.js.map +1 -1
- package/lib/dist/mcp/startup-handshake.d.ts +44 -0
- package/lib/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/lib/dist/mcp/startup-handshake.js +73 -0
- package/lib/dist/mcp/startup-handshake.js.map +1 -0
- package/lib/dist/mcp/tools.d.ts +22 -0
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +289 -23
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/transport.d.ts.map +1 -1
- package/lib/dist/mcp/transport.js +18 -0
- package/lib/dist/mcp/transport.js.map +1 -1
- package/lib/dist/project-config.d.ts +44 -0
- package/lib/dist/project-config.d.ts.map +1 -1
- package/lib/dist/project-config.js +151 -2
- package/lib/dist/project-config.js.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +2 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.js +170 -146
- package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts +1 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +1109 -97
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/cooperative-yield.d.ts +32 -0
- package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -0
- package/lib/dist/resolution/cooperative-yield.js +42 -0
- package/lib/dist/resolution/cooperative-yield.js.map +1 -0
- package/lib/dist/resolution/frameworks/cics.d.ts +20 -0
- package/lib/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/cics.js +90 -0
- package/lib/dist/resolution/frameworks/cics.js.map +1 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +6 -0
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +14 -6
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/lib/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/terraform.js +277 -0
- package/lib/dist/resolution/frameworks/terraform.js.map +1 -0
- package/lib/dist/resolution/goframe-synthesizer.d.ts +2 -1
- package/lib/dist/resolution/goframe-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/goframe-synthesizer.js +8 -3
- package/lib/dist/resolution/goframe-synthesizer.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +7 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +129 -4
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +85 -2
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +535 -58
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/name-matcher.d.ts +22 -3
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +613 -39
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/strip-comments.d.ts +1 -1
- package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
- package/lib/dist/resolution/strip-comments.js +49 -0
- package/lib/dist/resolution/strip-comments.js.map +1 -1
- package/lib/dist/resolution/types.d.ts +29 -0
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/workspace-packages.d.ts +10 -0
- package/lib/dist/resolution/workspace-packages.d.ts.map +1 -1
- package/lib/dist/resolution/workspace-packages.js +142 -4
- package/lib/dist/resolution/workspace-packages.js.map +1 -1
- package/lib/dist/search/identifier-segments.d.ts +60 -0
- package/lib/dist/search/identifier-segments.d.ts.map +1 -0
- package/lib/dist/search/identifier-segments.js +176 -0
- package/lib/dist/search/identifier-segments.js.map +1 -0
- package/lib/dist/sync/git-hooks.d.ts.map +1 -1
- package/lib/dist/sync/git-hooks.js +2 -0
- package/lib/dist/sync/git-hooks.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +10 -5
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +51 -14
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/sync/worktree.d.ts +9 -0
- package/lib/dist/sync/worktree.d.ts.map +1 -1
- package/lib/dist/sync/worktree.js +45 -0
- package/lib/dist/sync/worktree.js.map +1 -1
- package/lib/dist/types.d.ts +25 -2
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +10 -0
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/upgrade/index.d.ts +32 -0
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +163 -14
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/dist/upgrade/remove-binary.d.ts +87 -0
- package/lib/dist/upgrade/remove-binary.d.ts.map +1 -0
- package/lib/dist/upgrade/remove-binary.js +289 -0
- package/lib/dist/upgrade/remove-binary.js.map +1 -0
- package/lib/dist/upgrade/update-check.d.ts +92 -0
- package/lib/dist/upgrade/update-check.d.ts.map +1 -0
- package/lib/dist/upgrade/update-check.js +258 -0
- package/lib/dist/upgrade/update-check.js.map +1 -0
- package/lib/node_modules/.modules.yaml +1 -1
- package/lib/node_modules/.pnpm-workspace-state-v1.json +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/lib/dist/reasoning/config.d.ts +0 -45
- package/lib/dist/reasoning/config.d.ts.map +0 -1
- package/lib/dist/reasoning/config.js +0 -171
- package/lib/dist/reasoning/config.js.map +0 -1
- package/lib/dist/reasoning/credentials.d.ts +0 -5
- package/lib/dist/reasoning/credentials.d.ts.map +0 -1
- package/lib/dist/reasoning/credentials.js +0 -83
- package/lib/dist/reasoning/credentials.js.map +0 -1
- package/lib/dist/reasoning/login.d.ts +0 -21
- package/lib/dist/reasoning/login.d.ts.map +0 -1
- package/lib/dist/reasoning/login.js +0 -85
- package/lib/dist/reasoning/login.js.map +0 -1
- package/lib/dist/reasoning/reasoner.d.ts +0 -43
- package/lib/dist/reasoning/reasoner.d.ts.map +0 -1
- package/lib/dist/reasoning/reasoner.js +0 -308
- package/lib/dist/reasoning/reasoner.js.map +0 -1
package/lib/dist/db/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.DATABASE_FILENAME = exports.DatabaseConnection = void 0;
|
|
42
42
|
exports.getDatabasePath = getDatabasePath;
|
|
43
|
+
exports.removeDatabaseFiles = removeDatabaseFiles;
|
|
43
44
|
const sqlite_adapter_1 = require("./sqlite-adapter");
|
|
44
45
|
const fs = __importStar(require("fs"));
|
|
45
46
|
const path = __importStar(require("path"));
|
|
@@ -196,6 +197,100 @@ class DatabaseConnection {
|
|
|
196
197
|
const stats = fs.statSync(this.dbPath);
|
|
197
198
|
return stats.size;
|
|
198
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Size of the `-wal` sidecar file in bytes. 0 when it doesn't exist (non-WAL
|
|
202
|
+
* journal mode, in-memory DB, or no write since the last checkpoint+reset).
|
|
203
|
+
*/
|
|
204
|
+
getWalSizeBytes() {
|
|
205
|
+
if (!this.dbPath || this.dbPath === ':memory:')
|
|
206
|
+
return 0;
|
|
207
|
+
try {
|
|
208
|
+
return fs.statSync(`${this.dbPath}-wal`).size;
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Current `wal_autocheckpoint` interval in pages (0 = disabled). */
|
|
215
|
+
getWalAutocheckpoint() {
|
|
216
|
+
const v = this.db.pragma('wal_autocheckpoint', { simple: true });
|
|
217
|
+
const n = Number(v);
|
|
218
|
+
return Number.isFinite(n) ? n : 0;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Set the connection's `wal_autocheckpoint` interval (pages; 0 disables).
|
|
222
|
+
* Bulk indexing defers checkpoints entirely (#1231): the default 1000-page
|
|
223
|
+
* auto-checkpoint re-writes hot B-tree/FTS pages into the main DB file over
|
|
224
|
+
* and over — measured at ~95% of ALL disk I/O during a bulk index, and the
|
|
225
|
+
* difference between 45s and 19+ minutes on HDD-class storage. During
|
|
226
|
+
* deferral a {@link WalCheckpointValve} bounds WAL growth off-thread.
|
|
227
|
+
*/
|
|
228
|
+
setWalAutocheckpoint(pages) {
|
|
229
|
+
this.db.pragma(`wal_autocheckpoint = ${Math.max(0, Math.floor(pages))}`);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* `PRAGMA wal_checkpoint(PASSIVE)` on a worker thread with its own
|
|
233
|
+
* connection. PASSIVE never blocks the writer, and running it off-thread
|
|
234
|
+
* means the main thread — and the #850 watchdog heartbeat — keep turning
|
|
235
|
+
* even when the backfill is minutes of I/O on slow storage (a synchronous
|
|
236
|
+
* checkpoint that exceeds the watchdog's 60s window gets a healthy index
|
|
237
|
+
* SIGKILLed — observed in the #1231 repro).
|
|
238
|
+
*
|
|
239
|
+
* Returns SQLite's checkpoint result row — `log === checkpointed` with
|
|
240
|
+
* `busy === 0` means the ENTIRE WAL was backfilled, so the writer's next
|
|
241
|
+
* commit restarts the WAL from the top and the file stops growing. The
|
|
242
|
+
* WAL valve needs that signal because a WAL file's SIZE never shrinks:
|
|
243
|
+
* after the first wrap, raw file size says nothing about the un-backfilled
|
|
244
|
+
* backlog. Best-effort: returns null on any failure (including worker
|
|
245
|
+
* threads being unavailable — a potentially minutes-long checkpoint must
|
|
246
|
+
* never run inline on the main thread).
|
|
247
|
+
*/
|
|
248
|
+
async checkpointWalPassive() {
|
|
249
|
+
if (!this.dbPath || this.dbPath === ':memory:') {
|
|
250
|
+
try {
|
|
251
|
+
const row = this.db.prepare('PRAGMA wal_checkpoint(PASSIVE)').get();
|
|
252
|
+
return row ? { busy: Number(row.busy), log: Number(row.log), checkpointed: Number(row.checkpointed) } : null;
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
const { Worker } = await Promise.resolve().then(() => __importStar(require('node:worker_threads')));
|
|
260
|
+
const workerSource = `
|
|
261
|
+
const { workerData, parentPort } = require('node:worker_threads');
|
|
262
|
+
let row = null;
|
|
263
|
+
try {
|
|
264
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
265
|
+
const db = new DatabaseSync(workerData.dbPath);
|
|
266
|
+
try { row = db.prepare('PRAGMA wal_checkpoint(PASSIVE)').get(); } catch {}
|
|
267
|
+
try { db.close(); } catch {}
|
|
268
|
+
} catch {}
|
|
269
|
+
parentPort.postMessage({ row });
|
|
270
|
+
`;
|
|
271
|
+
return await new Promise((resolve) => {
|
|
272
|
+
let settled = false;
|
|
273
|
+
const finish = (row) => {
|
|
274
|
+
if (settled)
|
|
275
|
+
return;
|
|
276
|
+
settled = true;
|
|
277
|
+
resolve(row ? { busy: Number(row.busy), log: Number(row.log), checkpointed: Number(row.checkpointed) } : null);
|
|
278
|
+
};
|
|
279
|
+
try {
|
|
280
|
+
const worker = new Worker(workerSource, { eval: true, workerData: { dbPath: this.dbPath } });
|
|
281
|
+
worker.once('message', (m) => { void worker.terminate(); finish(m?.row ?? null); });
|
|
282
|
+
worker.once('error', () => { void worker.terminate(); finish(null); });
|
|
283
|
+
worker.once('exit', () => finish(null));
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
finish(null);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
199
294
|
/**
|
|
200
295
|
* Optimize database (vacuum and analyze)
|
|
201
296
|
*/
|
|
@@ -204,8 +299,8 @@ class DatabaseConnection {
|
|
|
204
299
|
this.db.exec('ANALYZE');
|
|
205
300
|
}
|
|
206
301
|
/**
|
|
207
|
-
* Lightweight
|
|
208
|
-
*
|
|
302
|
+
* Lightweight maintenance to run after bulk writes (indexAll, sync).
|
|
303
|
+
* Two operations:
|
|
209
304
|
*
|
|
210
305
|
* - `PRAGMA optimize` — incremental ANALYZE; SQLite only re-analyzes
|
|
211
306
|
* tables whose row counts changed materially since the last
|
|
@@ -217,21 +312,85 @@ class DatabaseConnection {
|
|
|
217
312
|
* unboundedly between automatic checkpoints (auto-fires at 1000
|
|
218
313
|
* pages by default; large indexAll runs blow past that).
|
|
219
314
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
315
|
+
* Runs on a WORKER THREAD with its own connection: on a multi-GB index
|
|
316
|
+
* these pragmas are minutes of synchronous IO (a 95k-file kernel index
|
|
317
|
+
* left a 593MB WAL whose checkpoint alone blew the #850 watchdog's 60s
|
|
318
|
+
* window and got a COMPLETED index SIGKILLed at the finish line). WAL
|
|
319
|
+
* checkpointing from a second connection is standard SQLite; `PRAGMA
|
|
320
|
+
* optimize` persists its statistics in sqlite_stat tables, so the main
|
|
321
|
+
* connection benefits the same. The main thread just awaits a message,
|
|
322
|
+
* so the event loop — and the watchdog heartbeat — keep turning.
|
|
323
|
+
*
|
|
324
|
+
* Everything is silently swallowed on failure — best-effort
|
|
325
|
+
* optimization, never load-bearing for correctness. If worker threads
|
|
326
|
+
* are unavailable, falls back to a bounded in-line `PRAGMA optimize`
|
|
327
|
+
* and SKIPS the checkpoint (the final close() checkpoints after the
|
|
328
|
+
* CLI has already disarmed its watchdog).
|
|
222
329
|
*/
|
|
223
|
-
runMaintenance() {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
330
|
+
async runMaintenance() {
|
|
331
|
+
// In-memory / test databases: nothing worth a worker round-trip.
|
|
332
|
+
if (!this.dbPath || this.dbPath === ':memory:') {
|
|
333
|
+
try {
|
|
334
|
+
this.db.exec('PRAGMA optimize');
|
|
335
|
+
}
|
|
336
|
+
catch { /* ignore */ }
|
|
337
|
+
try {
|
|
338
|
+
this.db.exec('PRAGMA wal_checkpoint(PASSIVE)');
|
|
339
|
+
}
|
|
340
|
+
catch { /* ignore */ }
|
|
341
|
+
return;
|
|
229
342
|
}
|
|
343
|
+
await this.runPragmasOffThread(['PRAGMA analysis_limit=1000', 'PRAGMA optimize', 'PRAGMA wal_checkpoint(PASSIVE)'],
|
|
344
|
+
// Worker threads unavailable — bounded in-line fallback, no checkpoint.
|
|
345
|
+
['PRAGMA analysis_limit=1000', 'PRAGMA optimize']);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Run pragmas on a worker thread against its own connection to this DB
|
|
349
|
+
* (shared machinery for {@link runMaintenance} and
|
|
350
|
+
* {@link checkpointWalPassive}). Each pragma is individually best-effort;
|
|
351
|
+
* the whole call is best-effort. `inlineFallback` (if any) runs on THIS
|
|
352
|
+
* connection only when worker threads are unavailable — keep it to pragmas
|
|
353
|
+
* that are safe to run synchronously on the main thread.
|
|
354
|
+
*/
|
|
355
|
+
async runPragmasOffThread(pragmas, inlineFallback = []) {
|
|
356
|
+
try {
|
|
357
|
+
const { Worker } = await Promise.resolve().then(() => __importStar(require('node:worker_threads')));
|
|
358
|
+
const workerSource = `
|
|
359
|
+
const { workerData, parentPort } = require('node:worker_threads');
|
|
230
360
|
try {
|
|
231
|
-
|
|
361
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
362
|
+
const db = new DatabaseSync(workerData.dbPath);
|
|
363
|
+
for (const p of workerData.pragmas) { try { db.exec(p); } catch {} }
|
|
364
|
+
try { db.close(); } catch {}
|
|
365
|
+
} catch {}
|
|
366
|
+
parentPort.postMessage('done');
|
|
367
|
+
`;
|
|
368
|
+
await new Promise((resolve) => {
|
|
369
|
+
let settled = false;
|
|
370
|
+
const finish = () => {
|
|
371
|
+
if (!settled) {
|
|
372
|
+
settled = true;
|
|
373
|
+
resolve();
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
try {
|
|
377
|
+
const worker = new Worker(workerSource, { eval: true, workerData: { dbPath: this.dbPath, pragmas } });
|
|
378
|
+
worker.once('message', () => { void worker.terminate(); finish(); });
|
|
379
|
+
worker.once('error', () => { void worker.terminate(); finish(); });
|
|
380
|
+
worker.once('exit', finish);
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
finish();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
232
386
|
}
|
|
233
387
|
catch {
|
|
234
|
-
|
|
388
|
+
for (const p of inlineFallback) {
|
|
389
|
+
try {
|
|
390
|
+
this.db.exec(p);
|
|
391
|
+
}
|
|
392
|
+
catch { /* ignore */ }
|
|
393
|
+
}
|
|
235
394
|
}
|
|
236
395
|
}
|
|
237
396
|
/**
|
|
@@ -287,10 +446,48 @@ function statInode(p) {
|
|
|
287
446
|
* Default database filename
|
|
288
447
|
*/
|
|
289
448
|
exports.DATABASE_FILENAME = 'codegraph.db';
|
|
449
|
+
/**
|
|
450
|
+
* SQLite's sidecar files in WAL mode — the write-ahead log and its shared-memory
|
|
451
|
+
* index. They sit beside the main DB file and are removed alongside it when the
|
|
452
|
+
* database is discarded (see `removeDatabaseFiles`).
|
|
453
|
+
*/
|
|
454
|
+
const WAL_SIDECAR_SUFFIXES = ['-wal', '-shm'];
|
|
290
455
|
/**
|
|
291
456
|
* Get the default database path for a project
|
|
292
457
|
*/
|
|
293
458
|
function getDatabasePath(projectRoot) {
|
|
294
459
|
return path.join((0, directory_1.getCodeGraphDir)(projectRoot), exports.DATABASE_FILENAME);
|
|
295
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Delete a database file and its WAL sidecars (`-wal`/`-shm`).
|
|
463
|
+
*
|
|
464
|
+
* This is how a FULL re-index discards an existing database — rather than
|
|
465
|
+
* opening the old graph and DELETE-ing every row. On a large or pre-fix
|
|
466
|
+
* poisoned index (e.g. an old graph that scanned an ignored gitlink corpus into
|
|
467
|
+
* ~1.6M nodes with a multi-GB WAL, #1065) the per-row `nodes_fts` delete-trigger
|
|
468
|
+
* churn blocks the main thread long enough to trip the #850 liveness watchdog
|
|
469
|
+
* before indexing even starts, so the rebuild could never recover the bad state
|
|
470
|
+
* (#1067). Unlinking is O(1) regardless of DB size and also reclaims the disk
|
|
471
|
+
* the bloated WAL would otherwise keep.
|
|
472
|
+
*
|
|
473
|
+
* POSIX removes the directory entry even while another process (a daemon/MCP
|
|
474
|
+
* server) still holds the file open; that holder heals via `reopenIfReplaced`
|
|
475
|
+
* (#925). On Windows a live holder can make the unlink fail with EBUSY/EPERM —
|
|
476
|
+
* that is thrown for the caller to surface ("stop the other process and retry").
|
|
477
|
+
* The `-wal`/`-shm` sidecars are best-effort: SQLite recreates them on the next
|
|
478
|
+
* open, so a leftover sidecar is harmless.
|
|
479
|
+
*/
|
|
480
|
+
function removeDatabaseFiles(dbPath) {
|
|
481
|
+
// The main DB file first — its removal is the operation that must succeed (or
|
|
482
|
+
// report why it couldn't). force:true treats an already-missing file as done.
|
|
483
|
+
fs.rmSync(dbPath, { force: true });
|
|
484
|
+
for (const suffix of WAL_SIDECAR_SUFFIXES) {
|
|
485
|
+
try {
|
|
486
|
+
fs.rmSync(dbPath + suffix, { force: true });
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
// A sidecar still held/locked is harmless — SQLite rebuilds it on open.
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
296
493
|
//# sourceMappingURL=index.js.map
|
package/lib/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names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;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAEvD;;GAEG;AACH,SAAgB,eAAe,CAAC,WAAmB;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAA,2BAAe,EAAC,WAAW,CAAC,EAAE,yBAAiB,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,mBAAmB,CAAC,MAAc;IAChD,8EAA8E;IAC9E,8EAA8E;IAC9E,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC;YACH,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,wEAAwE;QAC1E,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -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,IAAI,CAAC;AAExC;;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;
|
|
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,IAAI,CAAC;AAExC;;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;AAqJD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAU5D;AAWD;;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 = 9;
|
|
18
18
|
/**
|
|
19
19
|
* All migrations in order
|
|
20
20
|
*
|
|
@@ -70,13 +70,90 @@ const migrations = [
|
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
version: 6,
|
|
73
|
-
description: '
|
|
73
|
+
description: 'Dedup duplicate edge rows and add a UNIQUE identity index so INSERT OR IGNORE actually dedups (#1034)',
|
|
74
74
|
up: (db) => {
|
|
75
|
+
// `insertEdge` has always used `INSERT OR IGNORE`, but the edges table had
|
|
76
|
+
// no UNIQUE constraint, so nothing conflicted and byte-identical rows
|
|
77
|
+
// accumulated whenever two passes emitted the same edge. Collapse each
|
|
78
|
+
// identity group to its lowest id, then add the constraint that makes
|
|
79
|
+
// `OR IGNORE` keep its promise. IFNULL folds nullable line/col so
|
|
80
|
+
// coordinate-less edges dedup too (SQLite treats each NULL as distinct) —
|
|
81
|
+
// and it MUST match the GROUP BY exactly, or the index creation would
|
|
82
|
+
// fail on a pair the DELETE left behind. Idempotent: the index is
|
|
83
|
+
// `IF NOT EXISTS` and the DELETE is a no-op once the table is unique.
|
|
75
84
|
db.exec(`
|
|
76
|
-
|
|
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));
|
|
77
92
|
`);
|
|
78
93
|
},
|
|
79
94
|
},
|
|
95
|
+
{
|
|
96
|
+
version: 7,
|
|
97
|
+
description: 'Add name_segment_vocab — prose-word → symbol-name lookup for the prompt hook’s graph-derived gate',
|
|
98
|
+
up: (db) => {
|
|
99
|
+
// DDL only — instant on any size database (the row-churn hazards of #1067
|
|
100
|
+
// don't apply). The table starts EMPTY on migrated databases; `sync`
|
|
101
|
+
// detects that over a populated graph and backfills batched+yielding
|
|
102
|
+
// (CodeGraph.rebuildNameSegmentVocab), and any full index rebuilds it
|
|
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;
|
|
110
|
+
`);
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
version: 8,
|
|
115
|
+
description: 'Track attempted-but-unresolvable refs as status=failed so sync can retry them when a changed file adds a matching symbol (#1240)',
|
|
116
|
+
up: (db) => {
|
|
117
|
+
// DDL only — instant on any size database. No backfill needed: rows are
|
|
118
|
+
// only ever queried by name_tail once they carry status='failed', and
|
|
119
|
+
// both fields are written together by markReferencesFailed. Legacy rows
|
|
120
|
+
// (all 'pending' after this migration) are orphans from interrupted runs
|
|
121
|
+
// that the #1187 sweep grinds down on the next sync, marking survivors
|
|
122
|
+
// failed with their tails as it goes. The tail index is partial: on a
|
|
123
|
+
// healthy index the pending set is empty and the failed set is the only
|
|
124
|
+
// population worth indexing. Keep the definitions in lockstep with
|
|
125
|
+
// schema.sql. ALTER TABLE has no IF NOT EXISTS, so guard each column for
|
|
126
|
+
// idempotency — a database created from current schema.sql already has
|
|
127
|
+
// both (matters when migrations are re-run from an older recorded
|
|
128
|
+
// version, as the v6 regression test does).
|
|
129
|
+
const cols = db.prepare('PRAGMA table_info(unresolved_refs)').all();
|
|
130
|
+
const hasColumn = (name) => cols.some((c) => c.name === name);
|
|
131
|
+
if (!hasColumn('status')) {
|
|
132
|
+
db.exec("ALTER TABLE unresolved_refs ADD COLUMN status TEXT NOT NULL DEFAULT 'pending'");
|
|
133
|
+
}
|
|
134
|
+
if (!hasColumn('name_tail')) {
|
|
135
|
+
db.exec("ALTER TABLE unresolved_refs ADD COLUMN name_tail TEXT NOT NULL DEFAULT ''");
|
|
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';
|
|
140
|
+
`);
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
version: 9,
|
|
145
|
+
description: 'Add nodes.metadata — persisted extractor annotations for first-class symbol metadata (VBA fork)',
|
|
146
|
+
up: (db) => {
|
|
147
|
+
// Fork migration re-stacked above upstream's v6–v8. ALTER TABLE has no
|
|
148
|
+
// IF NOT EXISTS, so guard the column for idempotency — a database created
|
|
149
|
+
// from the current schema.sql already has it (matters when migrations are
|
|
150
|
+
// re-run from an older recorded version). Keep in lockstep with schema.sql.
|
|
151
|
+
const cols = db.prepare('PRAGMA table_info(nodes)').all();
|
|
152
|
+
if (!cols.some((c) => c.name === 'metadata')) {
|
|
153
|
+
db.exec('ALTER TABLE nodes ADD COLUMN metadata TEXT');
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
},
|
|
80
157
|
];
|
|
81
158
|
/**
|
|
82
159
|
* Get the current schema version from the database
|
|
@@ -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;;;AAwKH,8CAUC;AAcD,sCAiBC;AAKD,wCAGC;AAKD,oDAKC;AAKD,kDAYC;AAhPD;;GAEG;AACU,QAAA,sBAAsB,GAAG,CAAC,CAAC;AAWxC;;;;;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,CAA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B,CACjC,EAAkB;IAElB,MAAM,IAAI,GAAG,EAAE;SACZ,OAAO,CAAC,+EAA+E,CAAC;SACxF,GAAG,EAAgF,CAAC;IAEvF,OAAO,IAAI,CAAC,GAAG,CAAC,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"}
|
package/lib/dist/db/queries.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Prepared statements for CRUD operations on the knowledge graph.
|
|
5
5
|
*/
|
|
6
6
|
import { SqliteDatabase } from './sqlite-adapter';
|
|
7
|
-
import { Node, Edge, FileRecord, UnresolvedReference, NodeKind, EdgeKind, GraphStats, SearchOptions, SearchResult } from '../types';
|
|
7
|
+
import { Node, Edge, FileRecord, UnresolvedReference, NodeKind, EdgeKind, Language, GraphStats, SearchOptions, SearchResult } from '../types';
|
|
8
8
|
/**
|
|
9
9
|
* Query builder for the knowledge graph database
|
|
10
10
|
*/
|
|
@@ -14,6 +14,8 @@ export declare class QueryBuilder {
|
|
|
14
14
|
private nodeCache;
|
|
15
15
|
private readonly maxCacheSize;
|
|
16
16
|
private stmts;
|
|
17
|
+
private segmentedNames;
|
|
18
|
+
private static readonly MAX_SEGMENTED_NAMES;
|
|
17
19
|
constructor(db: SqliteDatabase);
|
|
18
20
|
/** Set the normalized project-name tokens used to down-weight non-discriminative
|
|
19
21
|
* query words in path scoring (#720). Called once when the project opens. */
|
|
@@ -24,6 +26,12 @@ export declare class QueryBuilder {
|
|
|
24
26
|
* Insert a new node
|
|
25
27
|
*/
|
|
26
28
|
insertNode(node: Node): void;
|
|
29
|
+
/** Which node kinds contribute their name to the segment vocabulary — the
|
|
30
|
+
* single gate shared by insertNode, updateNode, and the rebuild page query
|
|
31
|
+
* (getDistinctNodeNames), so the write paths can't drift apart. */
|
|
32
|
+
private isSegmentableKind;
|
|
33
|
+
/** Write `name`'s segments into name_segment_vocab (idempotent). */
|
|
34
|
+
private insertNameSegments;
|
|
27
35
|
/**
|
|
28
36
|
* Insert multiple nodes in a transaction
|
|
29
37
|
*/
|
|
@@ -40,6 +48,44 @@ export declare class QueryBuilder {
|
|
|
40
48
|
* Delete all nodes for a file
|
|
41
49
|
*/
|
|
42
50
|
deleteNodesByFile(filePath: string): void;
|
|
51
|
+
/** Wipe the segment vocabulary. A full index calls this at its start; the
|
|
52
|
+
* node write path repopulates it as files (re-)index, so the end state is
|
|
53
|
+
* exactly the current names with no orphan rows. */
|
|
54
|
+
clearNameSegmentVocab(): void;
|
|
55
|
+
/** True when the vocab has no rows — an index built before the table existed.
|
|
56
|
+
* `sync` uses this to heal such databases (see rebuildNameSegmentVocabFrom). */
|
|
57
|
+
isNameSegmentVocabEmpty(): boolean;
|
|
58
|
+
/** One page of distinct segmentable node names, for batched vocab rebuilds
|
|
59
|
+
* (file basenames and import specifiers are excluded from the vocab — see
|
|
60
|
+
* insertNode). */
|
|
61
|
+
getDistinctNodeNames(limit: number, offset: number): string[];
|
|
62
|
+
/** Insert segments for a batch of names in one transaction (vocab heal path). */
|
|
63
|
+
insertNameSegmentsBatch(names: string[]): void;
|
|
64
|
+
/**
|
|
65
|
+
* Names whose segments cover at least `minWords` distinct PROMPT WORDS —
|
|
66
|
+
* the co-occurrence probe behind the prompt hook's medium tier: the words
|
|
67
|
+
* "state" and "machine" both being segments of `OrderStateMachine` is strong
|
|
68
|
+
* evidence the prompt names that symbol in prose. Ordered by coverage.
|
|
69
|
+
*
|
|
70
|
+
* Takes (segment variant → original word) pairs and folds variants back to
|
|
71
|
+
* their word INSIDE the SQL: a name matching both `service` and `services`
|
|
72
|
+
* counts ONE word, not two. Counting raw variants let plural-variant pairs
|
|
73
|
+
* of a single word tie with genuine two-word matches and — because ORDER
|
|
74
|
+
* BY/LIMIT run here, before any JS-side re-check — crowd a real match past
|
|
75
|
+
* the LIMIT on vocab-heavy repos (#1146).
|
|
76
|
+
*/
|
|
77
|
+
getSegmentCoOccurrence(variants: Array<{
|
|
78
|
+
segment: string;
|
|
79
|
+
word: string;
|
|
80
|
+
}>, minWords: number, limit: number): Array<{
|
|
81
|
+
name: string;
|
|
82
|
+
matches: number;
|
|
83
|
+
}>;
|
|
84
|
+
/** How many distinct names each segment appears in — the rarity signal that
|
|
85
|
+
* separates a discriminative word ("checkout") from a ubiquitous one ("state"). */
|
|
86
|
+
getSegmentNameCounts(segments: string[]): Map<string, number>;
|
|
87
|
+
/** Names containing the given segment (rare-single-word tier). */
|
|
88
|
+
getNamesForSegment(segment: string, limit: number): string[];
|
|
43
89
|
/**
|
|
44
90
|
* Get a node by ID
|
|
45
91
|
*/
|
|
@@ -152,10 +198,32 @@ export declare class QueryBuilder {
|
|
|
152
198
|
* Get all nodes in the database
|
|
153
199
|
*/
|
|
154
200
|
getAllNodes(): Node[];
|
|
201
|
+
/**
|
|
202
|
+
* Stream nodes of one language whose `decorators` JSON array contains
|
|
203
|
+
* `decorator`. The LIKE on the JSON text is a cheap index-free pre-filter
|
|
204
|
+
* (a decorator name can appear as a substring of another), so callers must
|
|
205
|
+
* still exact-check `node.decorators.includes(decorator)`. Exists so the
|
|
206
|
+
* kotlin expect/actual synthesizer never materializes the whole node table
|
|
207
|
+
* the way `getAllNodes().filter(...)` did — that array alone OOM'd Node's
|
|
208
|
+
* default heap on a 2M-node graph (#1212).
|
|
209
|
+
*/
|
|
210
|
+
iterateNodesByLanguageWithDecorator(language: Language, decorator: string): IterableIterator<Node>;
|
|
211
|
+
/**
|
|
212
|
+
* Distinct languages present in the files table. One indexed aggregate —
|
|
213
|
+
* lets the dynamic-edge synthesizers skip passes for languages the project
|
|
214
|
+
* doesn't contain at all (a Kotlin pass has no work on a pure-C repo), so
|
|
215
|
+
* their cost is zero rather than a full-graph scan that finds nothing (#1212).
|
|
216
|
+
*/
|
|
217
|
+
getDistinctFileLanguages(): Set<string>;
|
|
155
218
|
/**
|
|
156
219
|
* Get nodes by exact name match (uses idx_nodes_name index)
|
|
157
220
|
*/
|
|
158
221
|
getNodesByName(name: string): Node[];
|
|
222
|
+
/**
|
|
223
|
+
* Nodes whose name starts with `prefix`, by index range scan (a LIKE would
|
|
224
|
+
* skip idx_nodes_name under SQLite's default case-insensitive LIKE).
|
|
225
|
+
*/
|
|
226
|
+
getNodesByNamePrefix(prefix: string, limit?: number): Node[];
|
|
159
227
|
/**
|
|
160
228
|
* Get nodes by exact qualified name match (uses idx_nodes_qualified_name index)
|
|
161
229
|
*/
|
|
@@ -251,6 +319,17 @@ export declare class QueryBuilder {
|
|
|
251
319
|
* about the target symbol.
|
|
252
320
|
*/
|
|
253
321
|
getVbaCallStubs(): Node[];
|
|
322
|
+
/**
|
|
323
|
+
* Find VBA reference-stub candidate nodes for `resolveVbaReferenceStubs`
|
|
324
|
+
* (issue #78).
|
|
325
|
+
*
|
|
326
|
+
* A VBA reference-stub is a `class` node whose `metadata.synthesizedBy`
|
|
327
|
+
* starts with `vba-` and is targeted by a `references` edge from a VBA
|
|
328
|
+
* module. These synthetic nodes are created by the extractor for
|
|
329
|
+
* cross-file type references (`Dim x As MyEnum`) but may not have been
|
|
330
|
+
* resolved to the real type node during the main resolution pass.
|
|
331
|
+
*/
|
|
332
|
+
getVbaReferenceStubs(): Node[];
|
|
254
333
|
/**
|
|
255
334
|
* Repoint an edge's `target` + `metadata` in place, leaving all other
|
|
256
335
|
* columns (source, kind, line, col, provenance) untouched. Used by
|
|
@@ -315,6 +394,8 @@ export declare class QueryBuilder {
|
|
|
315
394
|
getCrossFileIncomingEdgesWithTarget(filePath: string): Array<Edge & {
|
|
316
395
|
targetName: string;
|
|
317
396
|
targetKind: NodeKind;
|
|
397
|
+
sourceFilePath: string;
|
|
398
|
+
sourceLanguage: Language;
|
|
318
399
|
}>;
|
|
319
400
|
/**
|
|
320
401
|
* Insert or update a file record
|
|
@@ -362,12 +443,18 @@ export declare class QueryBuilder {
|
|
|
362
443
|
*/
|
|
363
444
|
getUnresolvedReferences(): UnresolvedReference[];
|
|
364
445
|
/**
|
|
365
|
-
* Get the count of
|
|
446
|
+
* Get the count of PENDING (never-attempted) references without loading
|
|
447
|
+
* them into memory. Rows marked status='failed' — attempted by a completed
|
|
448
|
+
* pass, no match — are excluded: they are not outstanding work, only retry
|
|
449
|
+
* candidates for the #1240 sweep, so they must not trip the #1187 orphan
|
|
450
|
+
* sweep or the `status` pending-refs warning.
|
|
366
451
|
*/
|
|
367
452
|
getUnresolvedReferencesCount(): number;
|
|
368
453
|
/**
|
|
369
|
-
* Get a batch of unresolved references using LIMIT/OFFSET
|
|
370
|
-
* Used to process references in bounded memory chunks
|
|
454
|
+
* Get a batch of PENDING unresolved references using LIMIT/OFFSET
|
|
455
|
+
* pagination. Used to process references in bounded memory chunks; failed
|
|
456
|
+
* rows are excluded so the batched drain loop terminates once every row
|
|
457
|
+
* has been attempted.
|
|
371
458
|
*/
|
|
372
459
|
getUnresolvedReferencesBatch(offset: number, limit: number): UnresolvedReference[];
|
|
373
460
|
/**
|
|
@@ -378,6 +465,13 @@ export declare class QueryBuilder {
|
|
|
378
465
|
* Get all distinct node names (lightweight — just name strings for pre-filtering)
|
|
379
466
|
*/
|
|
380
467
|
getAllNodeNames(): string[];
|
|
468
|
+
/**
|
|
469
|
+
* Stream the distinct node names one row at a time — the incremental
|
|
470
|
+
* counterpart to {@link getAllNodeNames} for callers that need to yield
|
|
471
|
+
* to the event loop mid-scan (resolver cache warm-up on multi-million-node
|
|
472
|
+
* indexes). Fresh statement per call: the iterator holds an open cursor.
|
|
473
|
+
*/
|
|
474
|
+
iterateNodeNames(): IterableIterator<string>;
|
|
381
475
|
/**
|
|
382
476
|
* Get unresolved references scoped to specific file paths.
|
|
383
477
|
* Uses the idx_unresolved_file_path index for efficient lookup.
|
|
@@ -400,6 +494,35 @@ export declare class QueryBuilder {
|
|
|
400
494
|
referenceName: string;
|
|
401
495
|
referenceKind: string;
|
|
402
496
|
}>): void;
|
|
497
|
+
/**
|
|
498
|
+
* Mark refs a completed resolution pass could not resolve as status='failed'
|
|
499
|
+
* instead of deleting them (#1240). Failed rows are invisible to the pending
|
|
500
|
+
* count/batch readers (so drain loops and the #1187 orphan sweep still
|
|
501
|
+
* terminate) but stay queryable by name_tail so a later sync can retry them
|
|
502
|
+
* when a changed file introduces a symbol that could satisfy them. name_tail
|
|
503
|
+
* is (re)written here so rows inserted before the v8 migration get their
|
|
504
|
+
* tail the first time they're attempted.
|
|
505
|
+
*/
|
|
506
|
+
markReferencesFailed(refs: Array<{
|
|
507
|
+
fromNodeId: string;
|
|
508
|
+
referenceName: string;
|
|
509
|
+
referenceKind: string;
|
|
510
|
+
}>): void;
|
|
511
|
+
/**
|
|
512
|
+
* Failed refs whose name tail matches one of the given symbol names — the
|
|
513
|
+
* candidates a sync should retry after files carrying those names changed
|
|
514
|
+
* (#1240). Names matching more than `perNameCeiling` failed refs are
|
|
515
|
+
* skipped entirely: at that population a name is external/builtin noise
|
|
516
|
+
* (`get`, `map`, …) that one new definition won't resolve — the same
|
|
517
|
+
* rationale as resolution's AMBIGUOUS_NAME_CEILING (#999) — and retrying an
|
|
518
|
+
* arbitrary subset would be both wasted work and incoherent coverage.
|
|
519
|
+
*/
|
|
520
|
+
getRetryableFailedReferences(names: string[], perNameCeiling?: number): UnresolvedReference[];
|
|
521
|
+
/**
|
|
522
|
+
* Distinct node names present in the given files — the symbol names a sync
|
|
523
|
+
* pass uses to look up retryable failed refs after those files changed.
|
|
524
|
+
*/
|
|
525
|
+
getNodeNamesByFiles(filePaths: string[]): string[];
|
|
403
526
|
/**
|
|
404
527
|
* Lightweight (nodes, edges) count snapshot. Used around an index/sync
|
|
405
528
|
* run to compute true additions across extraction + resolution +
|