seer-mcp 0.1.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.
Files changed (371) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/LICENSE +176 -0
  3. package/README.md +272 -0
  4. package/README_dev.md +199 -0
  5. package/dist/bundle/ci.d.ts +47 -0
  6. package/dist/bundle/ci.d.ts.map +1 -0
  7. package/dist/bundle/ci.js +113 -0
  8. package/dist/bundle/ci.js.map +1 -0
  9. package/dist/bundle/contract.d.ts +111 -0
  10. package/dist/bundle/contract.d.ts.map +1 -0
  11. package/dist/bundle/contract.js +352 -0
  12. package/dist/bundle/contract.js.map +1 -0
  13. package/dist/bundle/export.d.ts +36 -0
  14. package/dist/bundle/export.d.ts.map +1 -0
  15. package/dist/bundle/export.js +152 -0
  16. package/dist/bundle/export.js.map +1 -0
  17. package/dist/bundle/external.d.ts +66 -0
  18. package/dist/bundle/external.d.ts.map +1 -0
  19. package/dist/bundle/external.js +238 -0
  20. package/dist/bundle/external.js.map +1 -0
  21. package/dist/bundle/format.d.ts +94 -0
  22. package/dist/bundle/format.d.ts.map +1 -0
  23. package/dist/bundle/format.js +42 -0
  24. package/dist/bundle/format.js.map +1 -0
  25. package/dist/bundle/import.d.ts +49 -0
  26. package/dist/bundle/import.d.ts.map +1 -0
  27. package/dist/bundle/import.js +116 -0
  28. package/dist/bundle/import.js.map +1 -0
  29. package/dist/cli/index.d.ts +3 -0
  30. package/dist/cli/index.d.ts.map +1 -0
  31. package/dist/cli/index.js +1402 -0
  32. package/dist/cli/index.js.map +1 -0
  33. package/dist/cli/init.d.ts +48 -0
  34. package/dist/cli/init.d.ts.map +1 -0
  35. package/dist/cli/init.js +284 -0
  36. package/dist/cli/init.js.map +1 -0
  37. package/dist/db/schema.d.ts +3 -0
  38. package/dist/db/schema.d.ts.map +1 -0
  39. package/dist/db/schema.js +616 -0
  40. package/dist/db/schema.js.map +1 -0
  41. package/dist/db/store.d.ts +1011 -0
  42. package/dist/db/store.d.ts.map +1 -0
  43. package/dist/db/store.js +3888 -0
  44. package/dist/db/store.js.map +1 -0
  45. package/dist/graph/pagerank.d.ts +9 -0
  46. package/dist/graph/pagerank.d.ts.map +1 -0
  47. package/dist/graph/pagerank.js +47 -0
  48. package/dist/graph/pagerank.js.map +1 -0
  49. package/dist/indexer/architecture.d.ts +72 -0
  50. package/dist/indexer/architecture.d.ts.map +1 -0
  51. package/dist/indexer/architecture.js +112 -0
  52. package/dist/indexer/architecture.js.map +1 -0
  53. package/dist/indexer/behavior.d.ts +75 -0
  54. package/dist/indexer/behavior.d.ts.map +1 -0
  55. package/dist/indexer/behavior.js +395 -0
  56. package/dist/indexer/behavior.js.map +1 -0
  57. package/dist/indexer/boundaries.d.ts +60 -0
  58. package/dist/indexer/boundaries.d.ts.map +1 -0
  59. package/dist/indexer/boundaries.js +366 -0
  60. package/dist/indexer/boundaries.js.map +1 -0
  61. package/dist/indexer/churn.d.ts +15 -0
  62. package/dist/indexer/churn.d.ts.map +1 -0
  63. package/dist/indexer/churn.js +49 -0
  64. package/dist/indexer/churn.js.map +1 -0
  65. package/dist/indexer/classify.d.ts +9 -0
  66. package/dist/indexer/classify.d.ts.map +1 -0
  67. package/dist/indexer/classify.js +90 -0
  68. package/dist/indexer/classify.js.map +1 -0
  69. package/dist/indexer/context.d.ts +176 -0
  70. package/dist/indexer/context.d.ts.map +1 -0
  71. package/dist/indexer/context.js +193 -0
  72. package/dist/indexer/context.js.map +1 -0
  73. package/dist/indexer/continuity.d.ts +67 -0
  74. package/dist/indexer/continuity.d.ts.map +1 -0
  75. package/dist/indexer/continuity.js +288 -0
  76. package/dist/indexer/continuity.js.map +1 -0
  77. package/dist/indexer/detectchanges.d.ts +32 -0
  78. package/dist/indexer/detectchanges.d.ts.map +1 -0
  79. package/dist/indexer/detectchanges.js +74 -0
  80. package/dist/indexer/detectchanges.js.map +1 -0
  81. package/dist/indexer/discovery.d.ts +37 -0
  82. package/dist/indexer/discovery.d.ts.map +1 -0
  83. package/dist/indexer/discovery.js +136 -0
  84. package/dist/indexer/discovery.js.map +1 -0
  85. package/dist/indexer/externaldeps.d.ts +18 -0
  86. package/dist/indexer/externaldeps.d.ts.map +1 -0
  87. package/dist/indexer/externaldeps.js +288 -0
  88. package/dist/indexer/externaldeps.js.map +1 -0
  89. package/dist/indexer/freshness.d.ts +48 -0
  90. package/dist/indexer/freshness.d.ts.map +1 -0
  91. package/dist/indexer/freshness.js +128 -0
  92. package/dist/indexer/freshness.js.map +1 -0
  93. package/dist/indexer/git.d.ts +144 -0
  94. package/dist/indexer/git.d.ts.map +1 -0
  95. package/dist/indexer/git.js +444 -0
  96. package/dist/indexer/git.js.map +1 -0
  97. package/dist/indexer/index.d.ts +145 -0
  98. package/dist/indexer/index.d.ts.map +1 -0
  99. package/dist/indexer/index.js +930 -0
  100. package/dist/indexer/index.js.map +1 -0
  101. package/dist/indexer/modules.d.ts +62 -0
  102. package/dist/indexer/modules.d.ts.map +1 -0
  103. package/dist/indexer/modules.js +293 -0
  104. package/dist/indexer/modules.js.map +1 -0
  105. package/dist/indexer/preflight.d.ts +154 -0
  106. package/dist/indexer/preflight.d.ts.map +1 -0
  107. package/dist/indexer/preflight.js +399 -0
  108. package/dist/indexer/preflight.js.map +1 -0
  109. package/dist/indexer/protoScanner.d.ts +34 -0
  110. package/dist/indexer/protoScanner.d.ts.map +1 -0
  111. package/dist/indexer/protoScanner.js +133 -0
  112. package/dist/indexer/protoScanner.js.map +1 -0
  113. package/dist/indexer/risk.d.ts +115 -0
  114. package/dist/indexer/risk.d.ts.map +1 -0
  115. package/dist/indexer/risk.js +194 -0
  116. package/dist/indexer/risk.js.map +1 -0
  117. package/dist/indexer/serviceHostScanner.d.ts +25 -0
  118. package/dist/indexer/serviceHostScanner.d.ts.map +1 -0
  119. package/dist/indexer/serviceHostScanner.js +95 -0
  120. package/dist/indexer/serviceHostScanner.js.map +1 -0
  121. package/dist/indexer/serviceLinks.d.ts +105 -0
  122. package/dist/indexer/serviceLinks.d.ts.map +1 -0
  123. package/dist/indexer/serviceLinks.js +509 -0
  124. package/dist/indexer/serviceLinks.js.map +1 -0
  125. package/dist/indexer/shapehash.d.ts +98 -0
  126. package/dist/indexer/shapehash.d.ts.map +1 -0
  127. package/dist/indexer/shapehash.js +354 -0
  128. package/dist/indexer/shapehash.js.map +1 -0
  129. package/dist/indexer/skeleton.d.ts +15 -0
  130. package/dist/indexer/skeleton.d.ts.map +1 -0
  131. package/dist/indexer/skeleton.js +136 -0
  132. package/dist/indexer/skeleton.js.map +1 -0
  133. package/dist/indexer/symbolhistory.d.ts +41 -0
  134. package/dist/indexer/symbolhistory.d.ts.map +1 -0
  135. package/dist/indexer/symbolhistory.js +124 -0
  136. package/dist/indexer/symbolhistory.js.map +1 -0
  137. package/dist/indexer/watcher.d.ts +68 -0
  138. package/dist/indexer/watcher.d.ts.map +1 -0
  139. package/dist/indexer/watcher.js +179 -0
  140. package/dist/indexer/watcher.js.map +1 -0
  141. package/dist/mcp/server.d.ts +80 -0
  142. package/dist/mcp/server.d.ts.map +1 -0
  143. package/dist/mcp/server.js +1610 -0
  144. package/dist/mcp/server.js.map +1 -0
  145. package/dist/parser/index.d.ts +8 -0
  146. package/dist/parser/index.d.ts.map +1 -0
  147. package/dist/parser/index.js +33 -0
  148. package/dist/parser/index.js.map +1 -0
  149. package/dist/parser/languages/cpp.d.ts +3 -0
  150. package/dist/parser/languages/cpp.d.ts.map +1 -0
  151. package/dist/parser/languages/cpp.js +350 -0
  152. package/dist/parser/languages/cpp.js.map +1 -0
  153. package/dist/parser/languages/csharp.d.ts +3 -0
  154. package/dist/parser/languages/csharp.d.ts.map +1 -0
  155. package/dist/parser/languages/csharp.js +239 -0
  156. package/dist/parser/languages/csharp.js.map +1 -0
  157. package/dist/parser/languages/go.d.ts +3 -0
  158. package/dist/parser/languages/go.d.ts.map +1 -0
  159. package/dist/parser/languages/go.js +259 -0
  160. package/dist/parser/languages/go.js.map +1 -0
  161. package/dist/parser/languages/java.d.ts +3 -0
  162. package/dist/parser/languages/java.d.ts.map +1 -0
  163. package/dist/parser/languages/java.js +391 -0
  164. package/dist/parser/languages/java.js.map +1 -0
  165. package/dist/parser/languages/python.d.ts +3 -0
  166. package/dist/parser/languages/python.d.ts.map +1 -0
  167. package/dist/parser/languages/python.js +396 -0
  168. package/dist/parser/languages/python.js.map +1 -0
  169. package/dist/parser/languages/rust.d.ts +3 -0
  170. package/dist/parser/languages/rust.d.ts.map +1 -0
  171. package/dist/parser/languages/rust.js +159 -0
  172. package/dist/parser/languages/rust.js.map +1 -0
  173. package/dist/parser/languages/typescript.d.ts +3 -0
  174. package/dist/parser/languages/typescript.d.ts.map +1 -0
  175. package/dist/parser/languages/typescript.js +1442 -0
  176. package/dist/parser/languages/typescript.js.map +1 -0
  177. package/dist/parser/parserContext.d.ts +77 -0
  178. package/dist/parser/parserContext.d.ts.map +1 -0
  179. package/dist/parser/parserContext.js +354 -0
  180. package/dist/parser/parserContext.js.map +1 -0
  181. package/dist/parser/walker.d.ts +81 -0
  182. package/dist/parser/walker.d.ts.map +1 -0
  183. package/dist/parser/walker.js +217 -0
  184. package/dist/parser/walker.js.map +1 -0
  185. package/dist/parser/worker.d.ts +66 -0
  186. package/dist/parser/worker.d.ts.map +1 -0
  187. package/dist/parser/worker.js +129 -0
  188. package/dist/parser/worker.js.map +1 -0
  189. package/dist/parser/workerpool.d.ts +107 -0
  190. package/dist/parser/workerpool.d.ts.map +1 -0
  191. package/dist/parser/workerpool.js +383 -0
  192. package/dist/parser/workerpool.js.map +1 -0
  193. package/dist/scip/format.d.ts +87 -0
  194. package/dist/scip/format.d.ts.map +1 -0
  195. package/dist/scip/format.js +31 -0
  196. package/dist/scip/format.js.map +1 -0
  197. package/dist/scip/import.d.ts +37 -0
  198. package/dist/scip/import.d.ts.map +1 -0
  199. package/dist/scip/import.js +180 -0
  200. package/dist/scip/import.js.map +1 -0
  201. package/dist/types.d.ts +392 -0
  202. package/dist/types.d.ts.map +1 -0
  203. package/dist/types.js +4 -0
  204. package/dist/types.js.map +1 -0
  205. package/docs/architecture.md +105 -0
  206. package/docs/benchmarks/methodology.md +134 -0
  207. package/docs/benchmarks/raw-results.md +71 -0
  208. package/docs/benchmarks.md +74 -0
  209. package/docs/cli.md +148 -0
  210. package/docs/examples/behavior-tests.md +70 -0
  211. package/docs/examples/change-history.md +85 -0
  212. package/docs/examples/pre-edit-context.md +81 -0
  213. package/docs/examples/service-links.md +88 -0
  214. package/docs/examples.md +80 -0
  215. package/docs/faq.md +70 -0
  216. package/docs/internals.md +104 -0
  217. package/docs/languages.md +70 -0
  218. package/docs/limits.md +52 -0
  219. package/docs/mcp.md +199 -0
  220. package/docs/quickstart.md +119 -0
  221. package/docs/testing.md +123 -0
  222. package/docs/tools.md +115 -0
  223. package/package.json +52 -0
  224. package/research-codebase.md +578 -0
  225. package/seer-cli-docs.md +326 -0
  226. package/seer-master-guide.md +246 -0
  227. package/src/bundle/ci.ts +141 -0
  228. package/src/bundle/contract.ts +387 -0
  229. package/src/bundle/export.ts +175 -0
  230. package/src/bundle/external.ts +285 -0
  231. package/src/bundle/format.ts +92 -0
  232. package/src/bundle/import.ts +157 -0
  233. package/src/cli/index.ts +1249 -0
  234. package/src/cli/init.ts +389 -0
  235. package/src/db/schema.ts +614 -0
  236. package/src/db/store.ts +4306 -0
  237. package/src/graph/pagerank.ts +53 -0
  238. package/src/indexer/architecture.ts +148 -0
  239. package/src/indexer/behavior.ts +466 -0
  240. package/src/indexer/boundaries.ts +374 -0
  241. package/src/indexer/churn.ts +58 -0
  242. package/src/indexer/classify.ts +96 -0
  243. package/src/indexer/context.ts +340 -0
  244. package/src/indexer/continuity.ts +322 -0
  245. package/src/indexer/detectchanges.ts +94 -0
  246. package/src/indexer/discovery.ts +176 -0
  247. package/src/indexer/externaldeps.ts +243 -0
  248. package/src/indexer/freshness.ts +166 -0
  249. package/src/indexer/git.ts +453 -0
  250. package/src/indexer/index.ts +1092 -0
  251. package/src/indexer/modules.ts +358 -0
  252. package/src/indexer/preflight.ts +548 -0
  253. package/src/indexer/protoScanner.ts +147 -0
  254. package/src/indexer/risk.ts +304 -0
  255. package/src/indexer/serviceHostScanner.ts +92 -0
  256. package/src/indexer/serviceLinks.ts +543 -0
  257. package/src/indexer/shapehash.ts +370 -0
  258. package/src/indexer/skeleton.ts +169 -0
  259. package/src/indexer/symbolhistory.ts +172 -0
  260. package/src/indexer/watcher.ts +206 -0
  261. package/src/mcp/server.ts +1659 -0
  262. package/src/parser/index.ts +37 -0
  263. package/src/parser/languages/cpp.ts +361 -0
  264. package/src/parser/languages/csharp.ts +235 -0
  265. package/src/parser/languages/go.ts +259 -0
  266. package/src/parser/languages/java.ts +382 -0
  267. package/src/parser/languages/python.ts +370 -0
  268. package/src/parser/languages/rust.ts +164 -0
  269. package/src/parser/languages/typescript.ts +1435 -0
  270. package/src/parser/parserContext.ts +392 -0
  271. package/src/parser/walker.ts +306 -0
  272. package/src/parser/worker.ts +181 -0
  273. package/src/parser/workerpool.ts +448 -0
  274. package/src/scip/format.ts +83 -0
  275. package/src/scip/import.ts +216 -0
  276. package/src/types.ts +457 -0
  277. package/tests/benchmark-service-links.ts +244 -0
  278. package/tests/bug-regressions.ts +626 -0
  279. package/tests/filters.ts +264 -0
  280. package/tests/fixtures/Counter.tsx +38 -0
  281. package/tests/fixtures/caller.ts +7 -0
  282. package/tests/fixtures/collisions.ts +23 -0
  283. package/tests/fixtures/local_helper.ts +5 -0
  284. package/tests/fixtures/overloads.java +17 -0
  285. package/tests/fixtures/remote_helper.ts +4 -0
  286. package/tests/fixtures/sample.c +15 -0
  287. package/tests/fixtures/sample.cpp +47 -0
  288. package/tests/fixtures/sample.cs +62 -0
  289. package/tests/fixtures/sample.go +68 -0
  290. package/tests/fixtures/sample.h +30 -0
  291. package/tests/fixtures/sample.java +85 -0
  292. package/tests/fixtures/sample.py +46 -0
  293. package/tests/fixtures/sample.rs +78 -0
  294. package/tests/fixtures/sample.ts +76 -0
  295. package/tests/fixtures-service/HttpClients.cs +30 -0
  296. package/tests/fixtures-service/HttpClients.java +24 -0
  297. package/tests/fixtures-service/billing.ts +15 -0
  298. package/tests/fixtures-service/docker-compose.yml +15 -0
  299. package/tests/fixtures-service/gateway.ts +10 -0
  300. package/tests/fixtures-service/get_user.ts +11 -0
  301. package/tests/fixtures-service/graphql_client.ts +63 -0
  302. package/tests/fixtures-service/graphql_server.ts +30 -0
  303. package/tests/fixtures-service/grpc_client.go +30 -0
  304. package/tests/fixtures-service/http_clients.go +23 -0
  305. package/tests/fixtures-service/http_clients.py +38 -0
  306. package/tests/fixtures-service/http_clients.ts +49 -0
  307. package/tests/fixtures-service/k8s/payment-service.yaml +22 -0
  308. package/tests/fixtures-service/k8s_calls.ts +20 -0
  309. package/tests/fixtures-service/messaging.ts +87 -0
  310. package/tests/fixtures-service/trpc_client.ts +39 -0
  311. package/tests/fixtures-service/trpc_server.ts +39 -0
  312. package/tests/fixtures-service/user_service.proto +33 -0
  313. package/tests/fixtures-trackcd/Cargo.toml +11 -0
  314. package/tests/fixtures-trackcd/SpringController.java +36 -0
  315. package/tests/fixtures-trackcd/auth_service.ts +19 -0
  316. package/tests/fixtures-trackcd/complex_module.py +50 -0
  317. package/tests/fixtures-trackcd/express_app.js +30 -0
  318. package/tests/fixtures-trackcd/fastapi_app.py +49 -0
  319. package/tests/fixtures-trackcd/fastify_object_routes.js +32 -0
  320. package/tests/fixtures-trackcd/go.mod +8 -0
  321. package/tests/fixtures-trackcd/package.json +15 -0
  322. package/tests/fixtures-trackcd/requirements.txt +4 -0
  323. package/tests/fixtures-trackcd/tests/auth_service.test.ts +13 -0
  324. package/tests/fixtures-tracke/auth/AuthService.ts +23 -0
  325. package/tests/fixtures-tracke/auth/crypto.ts +7 -0
  326. package/tests/fixtures-tracke/billing/Billing.ts +20 -0
  327. package/tests/fixtures-tracke/billing/Invoice.ts +10 -0
  328. package/tests/fixtures-tracke/billing/server.ts +17 -0
  329. package/tests/fixtures-tracke/package.json +7 -0
  330. package/tests/fixtures-tracke/tests/auth.test.ts +23 -0
  331. package/tests/fixtures-tracke/tests/billing.test.ts +14 -0
  332. package/tests/fixtures-trackf/package.json +5 -0
  333. package/tests/fixtures-trackf/src/auth.ts +26 -0
  334. package/tests/fixtures-trackf/src/handlers.ts +35 -0
  335. package/tests/fixtures-tracki/billing/routes.ts +12 -0
  336. package/tests/fixtures-tracki/gateway/client.ts +13 -0
  337. package/tests/git-features.ts +267 -0
  338. package/tests/init.ts +141 -0
  339. package/tests/mcp-jit.ts +130 -0
  340. package/tests/mcp-smoke.ts +191 -0
  341. package/tests/mcp-trackcd.ts +169 -0
  342. package/tests/mcp-tracke.ts +229 -0
  343. package/tests/mcp-trackf.ts +330 -0
  344. package/tests/mcp-trackg.ts +219 -0
  345. package/tests/mcp-tracki.ts +174 -0
  346. package/tests/mcp-watcher.ts +126 -0
  347. package/tests/optspec.ts +194 -0
  348. package/tests/parallel-index.ts +333 -0
  349. package/tests/parallel-read.ts +125 -0
  350. package/tests/parallel-recovery.ts +241 -0
  351. package/tests/perf-callers.ts +145 -0
  352. package/tests/query-parity.ts +184 -0
  353. package/tests/query-perf.ts +55 -0
  354. package/tests/scale-parallel-parity.ts +225 -0
  355. package/tests/scale-test.ts +523 -0
  356. package/tests/smoke.ts +396 -0
  357. package/tests/trackcd.ts +325 -0
  358. package/tests/tracke-collisions.ts +255 -0
  359. package/tests/tracke.ts +314 -0
  360. package/tests/trackf-bugs.ts +406 -0
  361. package/tests/trackf.ts +390 -0
  362. package/tests/trackg.ts +1372 -0
  363. package/tests/tracki-boundaries.ts +202 -0
  364. package/tests/tracki-continuity.ts +253 -0
  365. package/tests/tracki-contract-diff.ts +249 -0
  366. package/tests/tracki-external-bundles.ts +341 -0
  367. package/tests/tracki-preflight.ts +251 -0
  368. package/tests/verify-roles.ts +51 -0
  369. package/tests/worker-parity.ts +286 -0
  370. package/tests/worker-pool.ts +262 -0
  371. package/tsconfig.json +20 -0
@@ -0,0 +1,616 @@
1
+ "use strict";
2
+ // SQL DDL for the Seer graph database
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SCHEMA_SQL = exports.CURRENT_SCHEMA_VERSION = void 0;
5
+ // Current schema version. Bumped whenever the table layout or column meanings
6
+ // change in a way that older code can't read transparently. Stored on the
7
+ // `_schema_meta` table; the Store checks it on open and runs migrations to
8
+ // catch up. ALTER TABLE ADD COLUMN additions don't bump this version — they
9
+ // are detected via PRAGMA table_info() and applied unconditionally for back
10
+ // compat with DBs older than schema-version tracking itself.
11
+ //
12
+ // v4 brings Track-C enrichment + Track-D symbol history:
13
+ // - routes, external_dependencies, config_keys
14
+ // - symbol complexity metrics columns
15
+ // - file_churn (file-level git stats)
16
+ // - symbol_history + git_index_state (per-symbol commit chains)
17
+ // - FTS5 virtual table over symbols for BM25 search
18
+ //
19
+ // v5 adds explicit symbol_role on `symbols`:
20
+ // - 'definition' (default) | 'declaration' | 'type_ref'
21
+ // - Required so agent-facing search/ranking can hide forward declarations
22
+ // and (future) bare type-reference rows by default while keeping them
23
+ // queryable when callers opt in via includeDeclarations / includeTypeRefs.
24
+ // - C/C++ class-body method declarations (field_declaration with a
25
+ // function_declarator inside, no body) are now recorded as 'declaration'
26
+ // while the out-of-line `void Class::method() { ... }` stays
27
+ // 'definition'. Pre-existing behavior of every other extractor is
28
+ // preserved: when an extractor doesn't set symbolRole, the Store writes
29
+ // 'definition'.
30
+ //
31
+ // v6 adds Track-E "agent orientation" tables:
32
+ // - modules: one row per Louvain-clustered module (label, size, primary
33
+ // language, cohesion, centrality)
34
+ // - module_members: file_id → module_id mapping (PRIMARY KEY on file_id —
35
+ // a file belongs to exactly one module)
36
+ // - module_edges: cached cross-module call+import weights so
37
+ // seer_module_dependencies stays sub-millisecond
38
+ // The clustering is deterministic (seeded label-tie-break by id, modularity-
39
+ // gain ties resolved by lower-id-wins), so two indexes of the same DB
40
+ // produce the same module ids.
41
+ //
42
+ // v7 adds Track-F "portability and precision":
43
+ // - symbols.provenance / edges.provenance — 'tree-sitter' (default) | 'scip' |
44
+ // 'scip-merge'. SCIP-imported precision data is additive and source-
45
+ // labelled so agents can see which signals came from a precise indexer vs
46
+ // tree-sitter's syntactic best-effort.
47
+ // - symbols.shape_hash — 64-bit SimHash (stored as INTEGER) over the
48
+ // symbol's structural token stream. NULL for non-function symbols and for
49
+ // symbols where the extractor didn't compute it. Used by
50
+ // seer_duplicates to find near-duplicate functions within Hamming distance N.
51
+ // - scip_imports — one row per SCIP file ingested (path, sha, indexed_at,
52
+ // symbol_count, ref_count). Lets us re-run idempotently and lets the
53
+ // bundle exporter record which SCIP layers contributed precision.
54
+ //
55
+ // v8 adds Track-G "service links" — deterministic cross-service linking:
56
+ // - service_calls: one row per HTTP client call extracted from source
57
+ // (fetch/axios/requests/http.Get/HttpClient/etc.). The caller symbol is
58
+ // AST-attributed; the endpoint value is captured as raw_target + an
59
+ // optional normalized_path / host_hint / env_key parsed by serviceLinks.
60
+ // - service_links: deterministic rendezvous between service_calls and the
61
+ // route handlers that satisfy them. Built by the post-index resolver.
62
+ // A parallel evidence layer; not mutating the normal edges table.
63
+ // Routes table is the rendezvous; service calls are the clients.
64
+ //
65
+ // v9 adds Track-H "protocol expansion" — generalize beyond HTTP to tRPC /
66
+ // GraphQL / gRPC / Kafka / SQS / SNS / RabbitMQ / NATS / Redis pub-sub /
67
+ // WebSocket / SSE. Rather than overfit one column per protocol, we add a
68
+ // small shared set of fields and let each protocol fill the ones that apply:
69
+ // service_calls + routes both gain:
70
+ // - operation — graphql opName, tRPC procedure path, gRPC method
71
+ // - topic — kafka / pub-sub topic
72
+ // - queue — sqs / rabbitmq queue
73
+ // - exchange — rabbitmq exchange
74
+ // - service — gRPC service name, k8s service hostname
75
+ // - broker — broker host/cluster identifier (kafka:9092, etc.)
76
+ // - metadata_json — protocol-specific catch-all
77
+ // routes additionally gains:
78
+ // - protocol — 'http' (default) / 'trpc' / 'graphql' / 'grpc' /
79
+ // 'kafka' / 'sqs' / 'sns' / 'rabbitmq' / 'nats' /
80
+ // 'redis_pubsub' / 'websocket' / 'sse'
81
+ // All columns are added via ALTER TABLE ADD COLUMN so v8 DBs migrate
82
+ // in-place; pre-v9 rows get NULL for the new fields. HTTP behavior is
83
+ // unchanged: when protocol/operation/topic/etc. are NULL the resolver
84
+ // keeps using the existing literal-path / pattern-path matching.
85
+ //
86
+ // v10 adds post-Track-H features:
87
+ // - external_bundles: read-only layer of routes / service-endpoints imported
88
+ // from a peer repo's exported .seerbundle. Additive — local files/symbols
89
+ // are untouched. Rows have provenance='external-bundle' and a foreign-key
90
+ // bundle id so re-importing the same bundle replaces only that layer.
91
+ // - routes / service_calls / service_links gain `external_bundle_id` so the
92
+ // resolver can pick up cross-repo evidence (auth → billing) without
93
+ // checking out billing source. Local rows leave it NULL.
94
+ // - boundaries / boundary_members / boundary_edges: monorepo package/service
95
+ // boundary detection (package.json workspaces, pnpm-workspace.yaml,
96
+ // turbo.json, nx.json, go.work, Cargo workspace, nested manifests, and
97
+ // services/* / packages/* fallback). Risk and context get a boundary
98
+ // crossing signal — strictly advisory.
99
+ // - symbol_history_continuity: rename/move continuity evidence. When exact
100
+ // symbol_key history stops, optional heuristics (shape_hash exact / close
101
+ // Hamming + signature similarity / shared file rename history) attach the
102
+ // historical previous_symbol_key with a confidence and a match_reasons
103
+ // blob. Never pretends rename continuity is certain.
104
+ exports.CURRENT_SCHEMA_VERSION = 10;
105
+ exports.SCHEMA_SQL = `
106
+ PRAGMA journal_mode = WAL;
107
+ PRAGMA foreign_keys = ON;
108
+
109
+ CREATE TABLE IF NOT EXISTS _schema_meta (
110
+ key TEXT PRIMARY KEY,
111
+ value TEXT NOT NULL
112
+ );
113
+
114
+ CREATE TABLE IF NOT EXISTS files (
115
+ id INTEGER PRIMARY KEY,
116
+ path TEXT NOT NULL UNIQUE,
117
+ rel_path TEXT NOT NULL,
118
+ language TEXT NOT NULL,
119
+ hash TEXT NOT NULL,
120
+ lines INTEGER NOT NULL DEFAULT 0,
121
+ indexed_at INTEGER NOT NULL,
122
+ -- Project-owned / vendored / generated / test / docs classification. Used
123
+ -- so ranking and search default to project-owned code while keeping vendor
124
+ -- and generated code inspectable when explicitly included.
125
+ -- 'project' — first-party application/library code (default)
126
+ -- 'vendor' — vendored third-party deps left untouched (./vendor, /vendored, etc.)
127
+ -- 'generated' — machine-emitted boilerplate (*.generated.h, *.pb.cc, etc.)
128
+ -- 'test' — files inside test directories
129
+ role TEXT NOT NULL DEFAULT 'project',
130
+ -- Convenience boolean projections of role, indexed independently so
131
+ -- predicates like "exclude vendored unless explicitly included" are cheap.
132
+ is_vendor INTEGER NOT NULL DEFAULT 0,
133
+ is_generated INTEGER NOT NULL DEFAULT 0
134
+ );
135
+
136
+ CREATE INDEX IF NOT EXISTS idx_files_role ON files(role);
137
+ CREATE INDEX IF NOT EXISTS idx_files_is_vendor ON files(is_vendor);
138
+ CREATE INDEX IF NOT EXISTS idx_files_is_generated ON files(is_generated);
139
+
140
+ CREATE TABLE IF NOT EXISTS symbols (
141
+ id INTEGER PRIMARY KEY,
142
+ name TEXT NOT NULL,
143
+ qualified_name TEXT,
144
+ kind TEXT NOT NULL,
145
+ file_id INTEGER NOT NULL REFERENCES files(id) ON DELETE CASCADE,
146
+ line_start INTEGER NOT NULL DEFAULT 0,
147
+ line_end INTEGER NOT NULL DEFAULT 0,
148
+ col_start INTEGER NOT NULL DEFAULT 0,
149
+ col_end INTEGER NOT NULL DEFAULT 0,
150
+ signature TEXT,
151
+ pagerank REAL NOT NULL DEFAULT 0.15,
152
+ -- 1 when this symbol participates in PageRank, top-N ranking, and the
153
+ -- agent-facing default symbol list. Functions/methods/constructors/classes
154
+ -- are rankable; structs/enums/types/interfaces/variables are not.
155
+ is_rankable INTEGER NOT NULL DEFAULT 1,
156
+ -- v4 Complexity columns. Populated by the language extractor for
157
+ -- function/method/constructor symbols; NULL for types/classes.
158
+ --
159
+ -- loc: lines of code (line_end - line_start + 1; non-blank)
160
+ -- cyclomatic: McCabe complexity (1 + branch count)
161
+ -- cognitive: cognitive complexity (penalizes nesting)
162
+ -- max_nesting: deepest nested control-flow depth inside the body
163
+ loc INTEGER,
164
+ cyclomatic INTEGER,
165
+ cognitive INTEGER,
166
+ max_nesting INTEGER,
167
+ -- v4 Symbol identity key for git history matching across line moves. Built
168
+ -- as kind:qualified_name(arity?) so a function rename keeps history as long
169
+ -- as the qualified name stays the same. NOT unique - duplicate keys are
170
+ -- possible across files; symbol_history is keyed by (symbol_id, symbol_key).
171
+ symbol_key TEXT,
172
+ -- v5 symbol_role distinguishes canonical definitions from forward / class-
173
+ -- body declarations and (future) bare type-reference sites. Default keeps
174
+ -- legacy behavior: every existing extractor that doesn't set a role gets
175
+ -- 'definition'. Used by default search/ranking filters to exclude
176
+ -- declarations unless includeDeclarations=true and to never emit type_ref
177
+ -- rows in agent-facing defaults unless includeTypeRefs=true.
178
+ symbol_role TEXT NOT NULL DEFAULT 'definition',
179
+ -- v7 provenance — which indexer produced this row:
180
+ -- 'tree-sitter' (default) — our syntactic extractor; never deleted by SCIP merges
181
+ -- 'scip' — imported from a precise SCIP index
182
+ -- 'scip-merge' — tree-sitter row that SCIP confirmed/refined (rare)
183
+ -- SCIP rows are additive; agents can filter precision by provenance.
184
+ provenance TEXT NOT NULL DEFAULT 'tree-sitter',
185
+ -- v7 shape_hash — 64-bit structural SimHash of the symbol's body token
186
+ -- stream, stored as INTEGER for cheap Hamming-distance comparison. NULL
187
+ -- when not computed (non-function kinds, declarations, types).
188
+ shape_hash INTEGER,
189
+ -- v7.1 scip_import_id — when provenance='scip', the scip_imports.id row
190
+ -- that contributed this symbol. Lets us wipe/refresh a single SCIP layer
191
+ -- without touching siblings.
192
+ scip_import_id INTEGER
193
+ );
194
+
195
+ CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
196
+ CREATE INDEX IF NOT EXISTS idx_symbols_qualified_name ON symbols(qualified_name);
197
+ CREATE INDEX IF NOT EXISTS idx_symbols_file_id ON symbols(file_id);
198
+ CREATE INDEX IF NOT EXISTS idx_symbols_file_name ON symbols(file_id, name);
199
+ CREATE INDEX IF NOT EXISTS idx_symbols_pagerank ON symbols(pagerank DESC);
200
+ -- v5 idx_symbols_symbol_role is created in runMigrations after the column
201
+ -- exists; putting it here would fail on pre-v5 DBs whose symbols table
202
+ -- does not yet have the column (CREATE TABLE IF NOT EXISTS above is a
203
+ -- no-op against an existing pre-v5 table).
204
+ -- v3+ indexes (idx_symbols_is_rankable, idx_symbols_symbol_key) live in
205
+ -- runMigrations because they target columns that don't exist on pre-v3/v4
206
+ -- DBs; trying to create them here on an upgrade would fail before the
207
+ -- ALTER TABLE ADD COLUMN runs.
208
+
209
+ -- from_id calls/references to_name; to_id is resolved after full index
210
+ CREATE TABLE IF NOT EXISTS edges (
211
+ id INTEGER PRIMARY KEY,
212
+ from_id INTEGER NOT NULL REFERENCES symbols(id) ON DELETE CASCADE,
213
+ to_name TEXT NOT NULL,
214
+ to_id INTEGER REFERENCES symbols(id) ON DELETE SET NULL,
215
+ kind TEXT NOT NULL DEFAULT 'call',
216
+ line INTEGER NOT NULL DEFAULT 0,
217
+ -- v7 provenance — see symbols.provenance.
218
+ provenance TEXT NOT NULL DEFAULT 'tree-sitter',
219
+ -- v7.1 — see symbols.scip_import_id.
220
+ scip_import_id INTEGER
221
+ );
222
+
223
+ CREATE INDEX IF NOT EXISTS idx_edges_from ON edges(from_id);
224
+ CREATE INDEX IF NOT EXISTS idx_edges_to_name ON edges(to_name);
225
+ CREATE INDEX IF NOT EXISTS idx_edges_to_id ON edges(to_id);
226
+ CREATE INDEX IF NOT EXISTS idx_edges_kind ON edges(kind);
227
+ CREATE INDEX IF NOT EXISTS idx_edges_from_to_kind ON edges(from_id, to_id, kind);
228
+
229
+ -- File-level imports. resolved_file_id is populated by a post-index pass
230
+ -- when the imported module can be mapped to a file we've also indexed.
231
+ CREATE TABLE IF NOT EXISTS file_imports (
232
+ id INTEGER PRIMARY KEY,
233
+ from_file_id INTEGER NOT NULL REFERENCES files(id) ON DELETE CASCADE,
234
+ import_name TEXT NOT NULL,
235
+ resolved_file_id INTEGER REFERENCES files(id) ON DELETE SET NULL
236
+ );
237
+
238
+ CREATE INDEX IF NOT EXISTS idx_file_imports_from ON file_imports(from_file_id);
239
+ CREATE INDEX IF NOT EXISTS idx_file_imports_resolved ON file_imports(resolved_file_id);
240
+
241
+ -- v4 routes table. One row per HTTP route detected in source. Handlers are
242
+ -- linked by symbol_id when resolvable (extractor sees the handler name in the
243
+ -- same file), otherwise handler_name is filled in and the post-pass leaves
244
+ -- handler_id NULL.
245
+ CREATE TABLE IF NOT EXISTS routes (
246
+ id INTEGER PRIMARY KEY,
247
+ file_id INTEGER NOT NULL REFERENCES files(id) ON DELETE CASCADE,
248
+ method TEXT NOT NULL,
249
+ path TEXT NOT NULL,
250
+ framework TEXT NOT NULL,
251
+ handler_name TEXT,
252
+ handler_id INTEGER REFERENCES symbols(id) ON DELETE SET NULL,
253
+ line INTEGER NOT NULL DEFAULT 0,
254
+ -- v9 Track-H protocol expansion. protocol defaults to 'http' so all
255
+ -- pre-v9 routes keep their semantics; tRPC procedures / GraphQL resolvers /
256
+ -- gRPC service methods / Kafka consumers etc. set protocol explicitly.
257
+ -- The generalized columns mirror service_calls so client to handler matching
258
+ -- can be done by the same field on both sides.
259
+ protocol TEXT NOT NULL DEFAULT 'http',
260
+ operation TEXT,
261
+ topic TEXT,
262
+ queue TEXT,
263
+ exchange TEXT,
264
+ service TEXT,
265
+ broker TEXT,
266
+ metadata_json TEXT
267
+ );
268
+
269
+ CREATE INDEX IF NOT EXISTS idx_routes_method ON routes(method);
270
+ CREATE INDEX IF NOT EXISTS idx_routes_path ON routes(path);
271
+ CREATE INDEX IF NOT EXISTS idx_routes_file_id ON routes(file_id);
272
+ CREATE INDEX IF NOT EXISTS idx_routes_framework ON routes(framework);
273
+ CREATE INDEX IF NOT EXISTS idx_routes_handler_id ON routes(handler_id);
274
+ CREATE INDEX IF NOT EXISTS idx_routes_protocol ON routes(protocol);
275
+ CREATE INDEX IF NOT EXISTS idx_routes_operation ON routes(operation) WHERE operation IS NOT NULL;
276
+ CREATE INDEX IF NOT EXISTS idx_routes_topic ON routes(topic) WHERE topic IS NOT NULL;
277
+ CREATE INDEX IF NOT EXISTS idx_routes_queue ON routes(queue) WHERE queue IS NOT NULL;
278
+ CREATE INDEX IF NOT EXISTS idx_routes_service ON routes(service) WHERE service IS NOT NULL;
279
+
280
+ -- v4 external dependencies extracted from package manifests/lockfiles.
281
+ -- Each row represents one dependency entry; (manifest_file, name) is unique.
282
+ -- ecosystem ∈ {npm, cargo, pypi, maven, gradle, go}
283
+ CREATE TABLE IF NOT EXISTS external_dependencies (
284
+ id INTEGER PRIMARY KEY,
285
+ ecosystem TEXT NOT NULL,
286
+ name TEXT NOT NULL,
287
+ version_range TEXT,
288
+ manifest_path TEXT NOT NULL,
289
+ is_dev INTEGER NOT NULL DEFAULT 0,
290
+ UNIQUE(ecosystem, name, manifest_path)
291
+ );
292
+
293
+ CREATE INDEX IF NOT EXISTS idx_extdeps_name ON external_dependencies(name);
294
+ CREATE INDEX IF NOT EXISTS idx_extdeps_ecosystem ON external_dependencies(ecosystem);
295
+
296
+ -- v4 config keys read by source. Each row is a static read of an env var or
297
+ -- config key. symbol_id is the enclosing function/method when the read happens
298
+ -- inside one; NULL for module-level reads.
299
+ CREATE TABLE IF NOT EXISTS config_keys (
300
+ id INTEGER PRIMARY KEY,
301
+ key TEXT NOT NULL,
302
+ source TEXT NOT NULL, -- 'env' | 'config' | other future kinds
303
+ file_id INTEGER NOT NULL REFERENCES files(id) ON DELETE CASCADE,
304
+ symbol_id INTEGER REFERENCES symbols(id) ON DELETE SET NULL,
305
+ line INTEGER NOT NULL DEFAULT 0
306
+ );
307
+
308
+ CREATE INDEX IF NOT EXISTS idx_config_keys_key ON config_keys(key);
309
+ CREATE INDEX IF NOT EXISTS idx_config_keys_file_id ON config_keys(file_id);
310
+ CREATE INDEX IF NOT EXISTS idx_config_keys_symbol_id ON config_keys(symbol_id);
311
+
312
+ -- v4 file_churn - populated by an optional "seer churn" pass that shells
313
+ -- out to git log. One row per indexed file; absent when the file lives
314
+ -- outside a git repo or churn was not run.
315
+ CREATE TABLE IF NOT EXISTS file_churn (
316
+ file_id INTEGER PRIMARY KEY REFERENCES files(id) ON DELETE CASCADE,
317
+ commit_count INTEGER NOT NULL DEFAULT 0,
318
+ last_commit_sha TEXT,
319
+ last_commit_at INTEGER,
320
+ top_author TEXT,
321
+ second_author TEXT,
322
+ collected_at INTEGER NOT NULL DEFAULT 0
323
+ );
324
+
325
+ CREATE INDEX IF NOT EXISTS idx_file_churn_commit_count ON file_churn(commit_count DESC);
326
+ CREATE INDEX IF NOT EXISTS idx_file_churn_last_commit ON file_churn(last_commit_at DESC);
327
+
328
+ -- v4 symbol_history — per-symbol commit chain. Built by an opt-in pass that
329
+ -- walks git log and matches changed line ranges to symbol line spans.
330
+ -- match_strategy describes how we matched the commit to the symbol; the
331
+ -- coarser strategies are honest about being heuristic.
332
+ -- 'overlap' = changed hunk overlapped the current symbol's line range
333
+ -- 'key-match' = symbol_key matched the symbol in the historical file version
334
+ CREATE TABLE IF NOT EXISTS symbol_history (
335
+ id INTEGER PRIMARY KEY,
336
+ symbol_id INTEGER NOT NULL REFERENCES symbols(id) ON DELETE CASCADE,
337
+ symbol_key TEXT NOT NULL,
338
+ commit_sha TEXT NOT NULL,
339
+ author_name TEXT,
340
+ author_email TEXT,
341
+ committed_at INTEGER NOT NULL,
342
+ message TEXT,
343
+ lines_added INTEGER NOT NULL DEFAULT 0,
344
+ lines_removed INTEGER NOT NULL DEFAULT 0,
345
+ pr_number INTEGER,
346
+ pr_url TEXT,
347
+ match_strategy TEXT NOT NULL,
348
+ confidence REAL NOT NULL DEFAULT 1.0,
349
+ UNIQUE(symbol_id, commit_sha)
350
+ );
351
+
352
+ CREATE INDEX IF NOT EXISTS idx_symbol_history_symbol ON symbol_history(symbol_id, committed_at DESC);
353
+ CREATE INDEX IF NOT EXISTS idx_symbol_history_key ON symbol_history(symbol_key, committed_at DESC);
354
+ CREATE INDEX IF NOT EXISTS idx_symbol_history_commit_sha ON symbol_history(commit_sha);
355
+
356
+ -- v4 git_index_state — tracks how far history extraction has progressed.
357
+ -- last_head_sha is a generic "the index has seen this HEAD" marker stamped
358
+ -- by churn AND symbol-history. last_history_head_sha is set ONLY by the
359
+ -- symbol-history pass and is what its skip-if-unchanged guard checks against.
360
+ -- Keeping them separate prevents the previous bug where running churn would
361
+ -- stamp last_head_sha = HEAD and a subsequent symbol-history build would
362
+ -- short-circuit despite never having indexed any history.
363
+ CREATE TABLE IF NOT EXISTS git_index_state (
364
+ id INTEGER PRIMARY KEY CHECK (id = 1),
365
+ repo_root TEXT NOT NULL,
366
+ last_head_sha TEXT,
367
+ last_processed_at INTEGER NOT NULL DEFAULT 0,
368
+ remote_url TEXT,
369
+ algorithm_version INTEGER NOT NULL DEFAULT 1,
370
+ last_history_head_sha TEXT,
371
+ last_history_at INTEGER
372
+ );
373
+
374
+ -- v4 FTS5 virtual table over symbol names/qualified names + signatures.
375
+ -- Tokenizer is "unicode61 remove_diacritics 2" which splits on punctuation,
376
+ -- so identifiers like AuthService_login or auth_service.login break cleanly
377
+ -- on _ and .; camelCase is split by the symbols_fts_split() helper in the
378
+ -- Store at insertion time (we store both the original and the split form).
379
+ CREATE VIRTUAL TABLE IF NOT EXISTS symbols_fts USING fts5(
380
+ name,
381
+ qualified_name,
382
+ signature,
383
+ split, -- camelCase + snake_case split form
384
+ content='', -- contentless table — Store keeps it in sync manually
385
+ tokenize="unicode61 remove_diacritics 2"
386
+ );
387
+
388
+ CREATE VIRTUAL TABLE IF NOT EXISTS files_fts USING fts5(
389
+ rel_path,
390
+ content='',
391
+ tokenize="unicode61 remove_diacritics 2"
392
+ );
393
+
394
+ -- v6 modules: one row per Louvain-clustered group of files. The cluster is
395
+ -- deterministic given the input graph, so two builds against the same DB
396
+ -- produce the same membership.
397
+ -- label — derived from the dominant top-level directory of the
398
+ -- files in the module, with a numeric suffix when two
399
+ -- modules share the same dominant dir.
400
+ -- size_files — number of files in the module
401
+ -- size_symbols — number of rankable symbols in the module
402
+ -- primary_language — most common files.language across members
403
+ -- cohesion — fraction of intra-module edges over total weighted
404
+ -- edges touching the module's members (0..1).
405
+ -- centrality — sum of PageRank of the rankable symbols in this
406
+ -- module — lets agents sort modules by graph importance.
407
+ -- algorithm — 'louvain' today; allows alternate clusterings later.
408
+ CREATE TABLE IF NOT EXISTS modules (
409
+ id INTEGER PRIMARY KEY,
410
+ label TEXT NOT NULL,
411
+ size_files INTEGER NOT NULL DEFAULT 0,
412
+ size_symbols INTEGER NOT NULL DEFAULT 0,
413
+ primary_language TEXT,
414
+ cohesion REAL NOT NULL DEFAULT 0,
415
+ centrality REAL NOT NULL DEFAULT 0,
416
+ computed_at INTEGER NOT NULL DEFAULT 0,
417
+ algorithm TEXT NOT NULL DEFAULT 'louvain'
418
+ );
419
+
420
+ CREATE INDEX IF NOT EXISTS idx_modules_label ON modules(label);
421
+ CREATE INDEX IF NOT EXISTS idx_modules_centrality ON modules(centrality DESC);
422
+ CREATE INDEX IF NOT EXISTS idx_modules_size ON modules(size_files DESC);
423
+
424
+ -- v6 module_members: file → module mapping. A file belongs to exactly one
425
+ -- module (PRIMARY KEY on file_id). Rebuilt every time we run clustering.
426
+ CREATE TABLE IF NOT EXISTS module_members (
427
+ file_id INTEGER PRIMARY KEY REFERENCES files(id) ON DELETE CASCADE,
428
+ module_id INTEGER NOT NULL REFERENCES modules(id) ON DELETE CASCADE
429
+ );
430
+
431
+ CREATE INDEX IF NOT EXISTS idx_module_members_module ON module_members(module_id);
432
+
433
+ -- v6 module_edges: cached cross-module dependency weights. Aggregated from
434
+ -- the resolved call/import/test graph by the clustering pass. UNIQUE on
435
+ -- (from, to, kind) so we can store calls / imports / tests separately and
436
+ -- agents can ask "which modules call into auth?" vs "which modules import
437
+ -- from auth?" independently.
438
+ CREATE TABLE IF NOT EXISTS module_edges (
439
+ id INTEGER PRIMARY KEY,
440
+ from_module_id INTEGER NOT NULL REFERENCES modules(id) ON DELETE CASCADE,
441
+ to_module_id INTEGER NOT NULL REFERENCES modules(id) ON DELETE CASCADE,
442
+ kind TEXT NOT NULL DEFAULT 'call',
443
+ weight INTEGER NOT NULL DEFAULT 1,
444
+ UNIQUE(from_module_id, to_module_id, kind)
445
+ );
446
+
447
+ CREATE INDEX IF NOT EXISTS idx_module_edges_from ON module_edges(from_module_id);
448
+ CREATE INDEX IF NOT EXISTS idx_module_edges_to ON module_edges(to_module_id);
449
+
450
+ -- v7 scip_imports: tracks every SCIP index that's been merged into the DB so
451
+ -- re-runs are idempotent and bundle manifests can list precision provenance.
452
+ -- One row per SCIP file path; the (path, sha) tuple is the dedup key.
453
+ CREATE TABLE IF NOT EXISTS scip_imports (
454
+ id INTEGER PRIMARY KEY,
455
+ path TEXT NOT NULL,
456
+ sha256 TEXT NOT NULL,
457
+ tool TEXT, -- e.g. "scip-typescript@0.3.5"
458
+ project_root TEXT,
459
+ imported_at INTEGER NOT NULL,
460
+ symbol_count INTEGER NOT NULL DEFAULT 0,
461
+ ref_count INTEGER NOT NULL DEFAULT 0,
462
+ UNIQUE(path, sha256)
463
+ );
464
+ CREATE INDEX IF NOT EXISTS idx_scip_imports_path ON scip_imports(path);
465
+
466
+ -- v7 indexes for provenance and shape_hash (CREATE IF NOT EXISTS so they're
467
+ -- harmless against pre-v7 DBs where the columns don't yet exist — those are
468
+ -- created in runMigrations before the indexes are attempted).
469
+
470
+ -- v8 service_calls — one row per HTTP client call site detected during parse.
471
+ -- symbol_id is the enclosing function/method when the call is inside one
472
+ -- (most cases); module-level calls leave it NULL. raw_target is the original
473
+ -- literal/expression text (e.g. "/api/users", "\${BASE_URL}/charge"); the
474
+ -- post-index resolver fills normalized_path / host_hint / env_key where it can
475
+ -- recover them deterministically.
476
+ CREATE TABLE IF NOT EXISTS service_calls (
477
+ id INTEGER PRIMARY KEY,
478
+ file_id INTEGER NOT NULL REFERENCES files(id) ON DELETE CASCADE,
479
+ symbol_id INTEGER REFERENCES symbols(id) ON DELETE SET NULL,
480
+ protocol TEXT NOT NULL, -- 'http' / 'trpc' / 'graphql' / 'grpc' / 'kafka' / 'sqs' / ...
481
+ method TEXT, -- 'GET' / 'POST' / 'ANY' / null (HTTP) or operation kind ('query'/'mutation')
482
+ raw_target TEXT NOT NULL, -- original literal/expression text
483
+ normalized_path TEXT, -- '/api/users' where confidently extractable
484
+ host_hint TEXT, -- service name / hostname when present
485
+ env_key TEXT, -- env var used in the URL (PAYMENT_URL, etc.)
486
+ framework TEXT NOT NULL, -- 'fetch' / 'axios' / 'requests' / 'http.Get' / 'trpc' / 'apollo' / ...
487
+ line INTEGER NOT NULL DEFAULT 0,
488
+ confidence REAL NOT NULL DEFAULT 0.5,
489
+ -- v9 Track-H protocol expansion. NULL for HTTP rows; populated by the
490
+ -- protocol-specific extractor when the field is meaningful.
491
+ operation TEXT, -- tRPC procedure path / GraphQL op name / gRPC method
492
+ topic TEXT, -- kafka / pub-sub topic
493
+ queue TEXT, -- sqs / rabbitmq queue
494
+ exchange TEXT, -- rabbitmq exchange
495
+ service TEXT, -- gRPC service name / k8s service hostname
496
+ broker TEXT, -- broker host / cluster identifier
497
+ metadata_json TEXT -- protocol-specific catch-all (JSON object)
498
+ );
499
+
500
+ CREATE INDEX IF NOT EXISTS idx_service_calls_symbol_id ON service_calls(symbol_id);
501
+ CREATE INDEX IF NOT EXISTS idx_service_calls_path ON service_calls(normalized_path);
502
+ CREATE INDEX IF NOT EXISTS idx_service_calls_protocol ON service_calls(protocol);
503
+ CREATE INDEX IF NOT EXISTS idx_service_calls_file_id ON service_calls(file_id);
504
+ CREATE INDEX IF NOT EXISTS idx_service_calls_operation ON service_calls(operation) WHERE operation IS NOT NULL;
505
+ CREATE INDEX IF NOT EXISTS idx_service_calls_topic ON service_calls(topic) WHERE topic IS NOT NULL;
506
+ CREATE INDEX IF NOT EXISTS idx_service_calls_queue ON service_calls(queue) WHERE queue IS NOT NULL;
507
+ CREATE INDEX IF NOT EXISTS idx_service_calls_service ON service_calls(service) WHERE service IS NOT NULL;
508
+
509
+ -- v8 service_links — deterministic rendezvous between a service_call and the
510
+ -- route handler that satisfies it. caller_symbol_id and handler_symbol_id are
511
+ -- snapshotted from service_calls.symbol_id / routes.handler_id at link time
512
+ -- so a caller can query "service links for symbol X" cheaply without joining
513
+ -- back through the service_calls / routes / symbols chain.
514
+ --
515
+ -- match_kind:
516
+ -- 'literal_path' — call.normalized_path == route.path exactly (method-match preferred)
517
+ -- 'env_base' — call references an env var resolved to the same host; path also matched
518
+ -- 'service_host' — call's host_hint matched a known service host; path matched
519
+ -- 'route_pattern' — call path matched a parameterised route (e.g. /users/:id)
520
+ CREATE TABLE IF NOT EXISTS service_links (
521
+ id INTEGER PRIMARY KEY,
522
+ call_id INTEGER NOT NULL REFERENCES service_calls(id) ON DELETE CASCADE,
523
+ route_id INTEGER REFERENCES routes(id) ON DELETE CASCADE,
524
+ caller_symbol_id INTEGER REFERENCES symbols(id) ON DELETE SET NULL,
525
+ handler_symbol_id INTEGER REFERENCES symbols(id) ON DELETE SET NULL,
526
+ protocol TEXT NOT NULL,
527
+ match_kind TEXT NOT NULL,
528
+ confidence REAL NOT NULL,
529
+ evidence_json TEXT NOT NULL DEFAULT '{}'
530
+ );
531
+
532
+ CREATE INDEX IF NOT EXISTS idx_service_links_call_id ON service_links(call_id);
533
+ CREATE INDEX IF NOT EXISTS idx_service_links_handler ON service_links(handler_symbol_id);
534
+ CREATE INDEX IF NOT EXISTS idx_service_links_caller ON service_links(caller_symbol_id);
535
+ CREATE INDEX IF NOT EXISTS idx_service_links_protocol ON service_links(protocol);
536
+ CREATE INDEX IF NOT EXISTS idx_service_links_match_kind ON service_links(match_kind);
537
+
538
+ -- v10 external_bundles — one row per .seerbundle imported as an additive
539
+ -- external layer. Each row carries the source bundle's manifest identity so
540
+ -- callers can see exactly which external service contributed which rows.
541
+ -- Re-importing the same bundle replaces (per-bundle id) without disturbing
542
+ -- siblings or local rows.
543
+ CREATE TABLE IF NOT EXISTS external_bundles (
544
+ id INTEGER PRIMARY KEY,
545
+ source_kind TEXT NOT NULL DEFAULT 'external-bundle',
546
+ bundle_path TEXT NOT NULL,
547
+ external_project TEXT,
548
+ external_version TEXT,
549
+ external_hash TEXT,
550
+ schema_version INTEGER NOT NULL DEFAULT 0,
551
+ imported_at INTEGER NOT NULL,
552
+ routes_imported INTEGER NOT NULL DEFAULT 0,
553
+ service_calls_imported INTEGER NOT NULL DEFAULT 0,
554
+ service_links_imported INTEGER NOT NULL DEFAULT 0,
555
+ UNIQUE(bundle_path)
556
+ );
557
+ CREATE INDEX IF NOT EXISTS idx_external_bundles_project ON external_bundles(external_project);
558
+
559
+ -- v10 boundaries — package/service boundaries detected at index time. A file
560
+ -- belongs to at most one boundary. The clustering is deterministic from the
561
+ -- detected manifest layout (workspaces, services/* fallback, nested
562
+ -- package.json / go.mod / Cargo.toml / pyproject.toml).
563
+ CREATE TABLE IF NOT EXISTS boundaries (
564
+ id INTEGER PRIMARY KEY,
565
+ label TEXT NOT NULL,
566
+ kind TEXT NOT NULL DEFAULT 'package',
567
+ root_rel_path TEXT NOT NULL,
568
+ manifest_path TEXT,
569
+ ecosystem TEXT,
570
+ size_files INTEGER NOT NULL DEFAULT 0,
571
+ computed_at INTEGER NOT NULL DEFAULT 0,
572
+ UNIQUE(root_rel_path)
573
+ );
574
+ CREATE INDEX IF NOT EXISTS idx_boundaries_label ON boundaries(label);
575
+ CREATE INDEX IF NOT EXISTS idx_boundaries_kind ON boundaries(kind);
576
+
577
+ CREATE TABLE IF NOT EXISTS boundary_members (
578
+ file_id INTEGER PRIMARY KEY REFERENCES files(id) ON DELETE CASCADE,
579
+ boundary_id INTEGER NOT NULL REFERENCES boundaries(id) ON DELETE CASCADE
580
+ );
581
+ CREATE INDEX IF NOT EXISTS idx_boundary_members_boundary ON boundary_members(boundary_id);
582
+
583
+ -- Cross-boundary dependency edges. kind ∈ ('call', 'import', 'service').
584
+ -- weight is the aggregated count.
585
+ CREATE TABLE IF NOT EXISTS boundary_edges (
586
+ id INTEGER PRIMARY KEY,
587
+ from_boundary_id INTEGER NOT NULL REFERENCES boundaries(id) ON DELETE CASCADE,
588
+ to_boundary_id INTEGER NOT NULL REFERENCES boundaries(id) ON DELETE CASCADE,
589
+ kind TEXT NOT NULL DEFAULT 'call',
590
+ weight INTEGER NOT NULL DEFAULT 1,
591
+ UNIQUE(from_boundary_id, to_boundary_id, kind)
592
+ );
593
+ CREATE INDEX IF NOT EXISTS idx_boundary_edges_from ON boundary_edges(from_boundary_id);
594
+ CREATE INDEX IF NOT EXISTS idx_boundary_edges_to ON boundary_edges(to_boundary_id);
595
+
596
+ -- v10 symbol_history_continuity — when an exact-symbol_key history walk
597
+ -- terminates at a rename/move boundary, the continuity layer records the
598
+ -- previous identity it most likely had. Confidence + reasons stay honest:
599
+ -- shape_hash exact match is high confidence, signature similarity is lower.
600
+ CREATE TABLE IF NOT EXISTS symbol_history_continuity (
601
+ id INTEGER PRIMARY KEY,
602
+ symbol_id INTEGER NOT NULL REFERENCES symbols(id) ON DELETE CASCADE,
603
+ symbol_key TEXT NOT NULL,
604
+ previous_symbol_key TEXT,
605
+ previous_name TEXT,
606
+ previous_file TEXT,
607
+ bridging_sha TEXT,
608
+ confidence REAL NOT NULL DEFAULT 0.0,
609
+ match_reasons TEXT NOT NULL DEFAULT '[]',
610
+ recorded_at INTEGER NOT NULL,
611
+ UNIQUE(symbol_id, previous_symbol_key)
612
+ );
613
+ CREATE INDEX IF NOT EXISTS idx_symbol_history_continuity_symbol ON symbol_history_continuity(symbol_id);
614
+ CREATE INDEX IF NOT EXISTS idx_symbol_history_continuity_prev ON symbol_history_continuity(previous_symbol_key);
615
+ `;
616
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAEtC,8EAA8E;AAC9E,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,6DAA6D;AAC7D,EAAE;AACF,yDAAyD;AACzD,iDAAiD;AACjD,wCAAwC;AACxC,wCAAwC;AACxC,kEAAkE;AAClE,sDAAsD;AACtD,EAAE;AACF,6CAA6C;AAC7C,0DAA0D;AAC1D,4EAA4E;AAC5E,0EAA0E;AAC1E,+EAA+E;AAC/E,qEAAqE;AACrE,6EAA6E;AAC7E,iEAAiE;AACjE,sEAAsE;AACtE,4EAA4E;AAC5E,oBAAoB;AACpB,EAAE;AACF,8CAA8C;AAC9C,0EAA0E;AAC1E,sCAAsC;AACtC,4EAA4E;AAC5E,4CAA4C;AAC5C,+DAA+D;AAC/D,qDAAqD;AACrD,+EAA+E;AAC/E,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,+CAA+C;AAC/C,iFAAiF;AACjF,yEAAyE;AACzE,8EAA8E;AAC9E,2CAA2C;AAC3C,uEAAuE;AACvE,8EAA8E;AAC9E,6DAA6D;AAC7D,kFAAkF;AAClF,4EAA4E;AAC5E,yEAAyE;AACzE,sEAAsE;AACtE,EAAE;AACF,yEAAyE;AACzE,wEAAwE;AACxE,4EAA4E;AAC5E,wEAAwE;AACxE,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,sEAAsE;AACtE,mEAAmE;AACnE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,6EAA6E;AAC7E,sCAAsC;AACtC,2EAA2E;AAC3E,gDAAgD;AAChD,+CAA+C;AAC/C,4CAA4C;AAC5C,kEAAkE;AAClE,4EAA4E;AAC5E,sDAAsD;AACtD,+BAA+B;AAC/B,2EAA2E;AAC3E,0EAA0E;AAC1E,+DAA+D;AAC/D,uEAAuE;AACvE,wEAAwE;AACxE,wEAAwE;AACxE,mEAAmE;AACnE,EAAE;AACF,kCAAkC;AAClC,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,8EAA8E;AAC9E,wEAAwE;AACxE,6DAA6D;AAC7D,+EAA+E;AAC/E,wEAAwE;AACxE,2EAA2E;AAC3E,yEAAyE;AACzE,2CAA2C;AAC3C,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,yDAAyD;AAC5C,QAAA,sBAAsB,GAAG,EAAE,CAAC;AAE5B,QAAA,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8fzB,CAAC"}