@gmickel/gno 2.15.0 → 2.17.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 (218) hide show
  1. package/README.md +1 -1
  2. package/assets/skill/SKILL.md +27 -0
  3. package/assets/skill/cli-reference.md +24 -15
  4. package/assets/spa-production.json.gz +0 -0
  5. package/browser-extension/artifacts/{gno-browser-clipper-v2.15.0.zip → gno-browser-clipper-v2.17.0.zip} +0 -0
  6. package/browser-extension/artifacts/gno-browser-clipper-v2.17.0.zip.sha256 +1 -0
  7. package/browser-extension/dist/manifest.json +1 -1
  8. package/package.json +1 -1
  9. package/spec/cli.md +43 -3
  10. package/spec/db/schema.sql +53 -1
  11. package/spec/mcp.md +9 -3
  12. package/spec/output-schemas/doctor.schema.json +27 -0
  13. package/spec/output-schemas/retrieval-trace-payloads.schema.json +14 -0
  14. package/spec/output-schemas/search-results.schema.json +14 -0
  15. package/spec/output-schemas/status.schema.json +22 -0
  16. package/src/cli/commands/agents/commands.ts +1 -1
  17. package/src/cli/commands/ask.ts +1 -1
  18. package/src/cli/commands/context-build.ts +1 -1
  19. package/src/cli/commands/doctor.ts +101 -29
  20. package/src/cli/commands/embed.ts +2 -2
  21. package/src/cli/commands/links.ts +30 -6
  22. package/src/cli/commands/mcp/install.ts +2 -2
  23. package/src/cli/commands/mcp/status.ts +1 -1
  24. package/src/cli/commands/mcp/uninstall.ts +1 -1
  25. package/src/cli/commands/query.ts +1 -1
  26. package/src/cli/commands/shared.ts +4 -4
  27. package/src/cli/commands/skill/install.ts +1 -1
  28. package/src/cli/commands/skill/paths-cmd.ts +1 -1
  29. package/src/cli/commands/skill/uninstall.ts +1 -1
  30. package/src/cli/commands/status.ts +75 -58
  31. package/src/cli/commands/vec.ts +180 -8
  32. package/src/cli/config-cache.ts +86 -0
  33. package/src/cli/globals.ts +64 -0
  34. package/src/cli/program.ts +63 -36
  35. package/src/cli/run.ts +121 -67
  36. package/src/cli/runtime-health.ts +132 -122
  37. package/src/cli/session-binding.ts +11 -2
  38. package/src/config/saver.ts +8 -0
  39. package/src/config/types.ts +6 -0
  40. package/src/converters/adapters/browser-export/formats.ts +25 -15
  41. package/src/converters/adapters/email/adapter.ts +37 -53
  42. package/src/converters/adapters/email/html.ts +37 -20
  43. package/src/converters/adapters/email/mime.ts +71 -39
  44. package/src/converters/adapters/ical/adapter.ts +20 -12
  45. package/src/converters/adapters/jsonl/adapter.ts +8 -6
  46. package/src/converters/adapters/shared/html-text.ts +55 -37
  47. package/src/converters/adapters/shared/ooxml-protection.ts +5 -13
  48. package/src/converters/adapters/shared/utf8-lines.ts +69 -31
  49. package/src/converters/adapters/transcript/adapter.ts +12 -7
  50. package/src/converters/adapters/xlsx/adapter.ts +10 -7
  51. package/src/converters/adapters/xlsx/sheet-markdown.ts +93 -50
  52. package/src/converters/canonicalize.ts +17 -3
  53. package/src/converters/native/markdown.ts +24 -17
  54. package/src/converters/native/plaintext.ts +5 -6
  55. package/src/converters/registry.ts +130 -8
  56. package/src/core/activation-status.ts +4 -8
  57. package/src/core/change-diff.ts +38 -11
  58. package/src/core/context-compiler.ts +17 -18
  59. package/src/core/context-evidence.ts +116 -25
  60. package/src/core/context-verifier.ts +70 -31
  61. package/src/core/file-lock.ts +10 -2
  62. package/src/core/graph-analysis.ts +3 -3
  63. package/src/core/link-inventory-markdown.ts +2 -2
  64. package/src/core/links.ts +20 -87
  65. package/src/core/memory-fence.ts +16 -9
  66. package/src/core/memory-recall.ts +168 -34
  67. package/src/core/path-rules.ts +143 -0
  68. package/src/core/retrieval-trace-session.ts +3 -0
  69. package/src/core/retrieval-trace.ts +9 -0
  70. package/src/core/section-parse.ts +16 -6
  71. package/src/core/typed-metadata.ts +68 -0
  72. package/src/core/vector-partition-status.ts +13 -0
  73. package/src/core/wiki-link-syntax.ts +88 -0
  74. package/src/embed/backlog.ts +142 -60
  75. package/src/embed/retry.ts +39 -33
  76. package/src/embed/variant-backlog.ts +582 -116
  77. package/src/embed/variant-retry.ts +157 -48
  78. package/src/index.ts +3 -3
  79. package/src/ingestion/budget-error-codes.ts +13 -0
  80. package/src/ingestion/chunker.ts +60 -49
  81. package/src/ingestion/compiled-context.ts +4 -5
  82. package/src/ingestion/convert-file.ts +1 -1
  83. package/src/ingestion/document-metadata.ts +16 -9
  84. package/src/ingestion/excluded-ranges.ts +97 -0
  85. package/src/ingestion/file-processor.ts +122 -37
  86. package/src/ingestion/frontmatter.ts +35 -7
  87. package/src/ingestion/graph-reconciliation.ts +187 -51
  88. package/src/ingestion/language.ts +66 -61
  89. package/src/ingestion/position.ts +5 -5
  90. package/src/ingestion/prepare-file.ts +50 -29
  91. package/src/ingestion/record-adapter-canonical.ts +37 -26
  92. package/src/ingestion/record-adapter.ts +46 -26
  93. package/src/ingestion/record-container.ts +121 -53
  94. package/src/ingestion/record-path.ts +5 -2
  95. package/src/ingestion/source-availability/darwin-io.ts +10 -7
  96. package/src/ingestion/source-availability/darwin-path.ts +21 -3
  97. package/src/ingestion/source-availability/readers.ts +51 -0
  98. package/src/ingestion/strip.ts +39 -105
  99. package/src/ingestion/sync.ts +692 -386
  100. package/src/ingestion/typed-metadata.ts +10 -4
  101. package/src/ingestion/walker.ts +485 -158
  102. package/src/llm/cache.ts +128 -84
  103. package/src/llm/http-inference.ts +112 -35
  104. package/src/llm/http-policy.ts +101 -0
  105. package/src/llm/httpEmbedding.ts +8 -1
  106. package/src/llm/httpGeneration.ts +5 -1
  107. package/src/llm/httpRerank.ts +5 -1
  108. package/src/llm/inference-scope.ts +15 -2
  109. package/src/llm/lazy-ports.ts +33 -3
  110. package/src/llm/lockfile.ts +34 -7
  111. package/src/llm/model-cleanup.ts +24 -0
  112. package/src/llm/native-worker/client.ts +23 -12
  113. package/src/llm/native-worker/dispatcher.ts +19 -9
  114. package/src/llm/native-worker/embedding-identity.ts +42 -16
  115. package/src/llm/native-worker/entry.ts +2 -1
  116. package/src/llm/native-worker/owner.ts +1 -0
  117. package/src/llm/native-worker/ports.ts +86 -23
  118. package/src/llm/native-worker/protocol.ts +386 -55
  119. package/src/llm/nodeLlamaCpp/adapter.ts +46 -29
  120. package/src/llm/nodeLlamaCpp/embedding.ts +93 -40
  121. package/src/llm/nodeLlamaCpp/generation.ts +194 -30
  122. package/src/llm/nodeLlamaCpp/lifecycle.ts +2 -0
  123. package/src/llm/nodeLlamaCpp/rerank-capacity.ts +101 -23
  124. package/src/llm/nodeLlamaCpp/rerank.ts +253 -44
  125. package/src/llm/types.ts +14 -0
  126. package/src/mcp/context.ts +342 -23
  127. package/src/mcp/http-transport.ts +21 -3
  128. package/src/mcp/tool-profile-types.ts +62 -0
  129. package/src/mcp/tool-profile.ts +32 -56
  130. package/src/mcp/tools/context.ts +5 -1
  131. package/src/mcp/tools/index.ts +269 -191
  132. package/src/mcp/tools/links.ts +14 -6
  133. package/src/mcp/tools/query.ts +60 -37
  134. package/src/mcp/tools/vsearch.ts +25 -14
  135. package/src/pipeline/answer.ts +133 -40
  136. package/src/pipeline/claim-verification.ts +293 -189
  137. package/src/pipeline/claim-verifier.ts +6 -7
  138. package/src/pipeline/egress-lineage.ts +37 -26
  139. package/src/pipeline/exclude.ts +34 -11
  140. package/src/pipeline/expansion.ts +233 -19
  141. package/src/pipeline/explain.ts +17 -2
  142. package/src/pipeline/filters.ts +169 -33
  143. package/src/pipeline/graph-retrieval.ts +117 -61
  144. package/src/pipeline/hybrid.ts +626 -330
  145. package/src/pipeline/hydration.ts +86 -24
  146. package/src/pipeline/intent.ts +15 -7
  147. package/src/pipeline/owner-fusion.ts +61 -19
  148. package/src/pipeline/query-language.ts +15 -2
  149. package/src/pipeline/rerank.ts +15 -22
  150. package/src/pipeline/search.ts +193 -72
  151. package/src/pipeline/snippet.ts +15 -2
  152. package/src/pipeline/temporal.ts +51 -10
  153. package/src/pipeline/types.ts +7 -0
  154. package/src/pipeline/vsearch.ts +269 -154
  155. package/src/publish/attachment-raster.ts +2 -16
  156. package/src/publish/encrypted-export.ts +15 -5
  157. package/src/serve/browse-tree.ts +50 -42
  158. package/src/serve/connectors.ts +2 -1
  159. package/src/serve/context.ts +13 -4
  160. package/src/serve/doc-events.ts +3 -0
  161. package/src/serve/public/app.tsx +49 -21
  162. package/src/serve/public/components/BrowseTreeSidebar.tsx +163 -23
  163. package/src/serve/public/components/CaptureModal.tsx +14 -10
  164. package/src/serve/public/components/ai-elements/code-block.tsx +87 -50
  165. package/src/serve/public/components/editor/MarkdownPreview.tsx +99 -67
  166. package/src/serve/public/globals.built.css +1 -1
  167. package/src/serve/public/globals.css +19 -0
  168. package/src/serve/public/hooks/useCaptureModal.tsx +23 -10
  169. package/src/serve/public/lib/metadata-filter.ts +234 -9
  170. package/src/serve/public/pages/Browse.tsx +61 -27
  171. package/src/serve/public/pages/DocView.tsx +44 -25
  172. package/src/serve/public/pages/GraphView.tsx +8 -3
  173. package/src/serve/resident-runtime.ts +199 -48
  174. package/src/serve/routes/api.ts +98 -67
  175. package/src/serve/routes/links.ts +25 -5
  176. package/src/serve/server.ts +1370 -1180
  177. package/src/serve/spa-bundle-source.ts +52 -27
  178. package/src/serve/status.ts +101 -52
  179. package/src/serve/watch-reconciliation-fallback.ts +11 -7
  180. package/src/serve/watch-reconciliation-shared.ts +42 -4
  181. package/src/serve/watch-reconciliation.ts +21 -8
  182. package/src/serve/watch-service-events.ts +7 -1
  183. package/src/serve/watch-service-hosts.ts +3 -1
  184. package/src/serve/watch-service.ts +46 -21
  185. package/src/serve/watch-snapshot-scan.ts +6 -15
  186. package/src/sessions/archive.ts +20 -8
  187. package/src/sessions/sanitize.ts +38 -18
  188. package/src/sessions/service.ts +180 -102
  189. package/src/store/migrations/037-performance-indexes.ts +56 -0
  190. package/src/store/migrations/038-vector-mirror-null-cosine.ts +47 -0
  191. package/src/store/migrations/039-vector-mirror-v2.ts +94 -0
  192. package/src/store/migrations/index.ts +6 -0
  193. package/src/store/sqlite/adapter.ts +1260 -651
  194. package/src/store/sqlite/chunking-policy.ts +15 -1
  195. package/src/store/sqlite/eligibility.ts +110 -70
  196. package/src/store/sqlite/graph-neighbors.ts +71 -46
  197. package/src/store/sqlite/graph-reference-state.ts +27 -3
  198. package/src/store/sqlite/graph-similarity.ts +59 -12
  199. package/src/store/sqlite/metadata-predicate.ts +123 -28
  200. package/src/store/sqlite/retrieval-trace-management-store.ts +126 -33
  201. package/src/store/sqlite/retrieval-trace-retention.ts +88 -76
  202. package/src/store/sqlite/retrieval-trace-rows.ts +7 -3
  203. package/src/store/types.ts +32 -0
  204. package/src/store/vector/coarse-router.ts +312 -0
  205. package/src/store/vector/eligibility.ts +39 -0
  206. package/src/store/vector/lazy.ts +17 -0
  207. package/src/store/vector/partition-index.ts +333 -59
  208. package/src/store/vector/proof-cache.ts +209 -0
  209. package/src/store/vector/runtime-compat.ts +6 -0
  210. package/src/store/vector/sqlite-vec.ts +270 -162
  211. package/src/store/vector/stats.ts +37 -73
  212. package/src/store/vector/status.ts +169 -53
  213. package/src/store/vector/stored-vectors.ts +131 -45
  214. package/src/store/vector/types.ts +19 -0
  215. package/src/store/vector/v2-mirror.ts +669 -0
  216. package/src/store/vector/variant-search.ts +1187 -111
  217. package/src/store/vector/variants.ts +964 -160
  218. package/browser-extension/artifacts/gno-browser-clipper-v2.15.0.zip.sha256 +0 -1
@@ -64,7 +64,7 @@ import {
64
64
  type VectorIndexPort,
65
65
  type VectorStatsPort,
66
66
  } from "../../store/vector";
67
- import { getGlobals } from "../program";
67
+ import { getGlobals } from "../globals";
68
68
  import {
69
69
  createProgressRenderer,
70
70
  createThrottledProgressRenderer,
@@ -652,7 +652,7 @@ async function confirmSeparatePartition(message: string): Promise<boolean> {
652
652
  * Execute gno embed command.
653
653
  */
654
654
  export async function embed(options: EmbedOptions = {}): Promise<EmbedResult> {
655
- const batchSize = options.batchSize ?? 32;
655
+ const batchSize = options.batchSize ?? 64;
656
656
  const force = options.force ?? false;
657
657
  const dryRun = options.dryRun ?? false;
658
658
  const limits: EmbedRunLimits | undefined =
@@ -5,7 +5,7 @@
5
5
  * @module src/cli/commands/links
6
6
  */
7
7
 
8
- import type { DocEdgeRow, DocLinkRow, StorePort } from "../../store/types";
8
+ import type { DocEdgeRow, DocLinkRow } from "../../store/types";
9
9
 
10
10
  import { resolveDocRef } from "../../core/ref-parser";
11
11
  import { initStore } from "./shared";
@@ -634,16 +634,40 @@ export async function similar(
634
634
  const searchResult = await vectorIndex.searchNearest(
635
635
  embedding,
636
636
  candidateLimit,
637
- storedVectorSearchOptions(source)
637
+ {
638
+ ...storedVectorSearchOptions(source),
639
+ coarseVectorSearch: config.coarseVectorSearch,
640
+ ...(!crossCollection
641
+ ? { eligibility: { collection: doc.collection } }
642
+ : {}),
643
+ }
638
644
  );
639
645
  if (!searchResult.ok) {
640
646
  return { success: false, error: searchResult.error.message };
641
647
  }
642
648
 
643
- // Candidate documents from a single listDocuments call
644
- const docsResult = crossCollection
645
- ? await store.listDocuments()
646
- : await store.listDocuments(doc.collection);
649
+ // Hydrate only the documents owning returned hits (targeted json_each SQL)
650
+ // rather than loading the entire documents table.
651
+ const hitDocumentIds = [
652
+ ...new Set(searchResult.value.flatMap((r) => r.documentIds ?? [])),
653
+ ];
654
+ const hitMirrorHashes = [
655
+ ...new Set(
656
+ searchResult.value
657
+ .filter((r) => !r.documentIds)
658
+ .map((r) => r.mirrorHash)
659
+ ),
660
+ ];
661
+ const docsResult =
662
+ typeof store.listDocumentsForSimilarity === "function"
663
+ ? await store.listDocumentsForSimilarity({
664
+ documentIds: hitDocumentIds,
665
+ mirrorHashes: hitMirrorHashes,
666
+ collection: crossCollection ? undefined : doc.collection,
667
+ })
668
+ : crossCollection
669
+ ? await store.listDocuments()
670
+ : await store.listDocuments(doc.collection);
647
671
 
648
672
  if (!docsResult.ok) {
649
673
  return { success: false, error: docsResult.error.message };
@@ -9,9 +9,9 @@ import { getConfigPaths, toAbsolutePath } from "../../../config/paths.js";
9
9
  import {
10
10
  type McpToolProfile,
11
11
  parseMcpToolProfile,
12
- } from "../../../mcp/tool-profile.js";
12
+ } from "../../../mcp/tool-profile-types.js";
13
13
  import { CliError } from "../../errors.js";
14
- import { getGlobals } from "../../program.js";
14
+ import { getGlobals } from "../../globals.js";
15
15
  import { resolveMcpConfigLocation } from "./config-discovery.js";
16
16
  import {
17
17
  getJsoncServerEntry,
@@ -11,7 +11,7 @@ import type { StandardMcpEntry } from "./config.js";
11
11
 
12
12
  import { normalizeConnectorWorkspaceEnvironment } from "../../../core/connector-environment";
13
13
  import { CliError } from "../../errors.js";
14
- import { getGlobals } from "../../program.js";
14
+ import { getGlobals } from "../../globals.js";
15
15
  import {
16
16
  configPathEntryExists,
17
17
  resolveMcpConfigLocation,
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { CliError } from "../../errors.js";
8
- import { getGlobals } from "../../program.js";
8
+ import { getGlobals } from "../../globals.js";
9
9
  import { resolveMcpConfigLocation } from "./config-discovery.js";
10
10
  import {
11
11
  removeJsoncServerEntry,
@@ -39,7 +39,7 @@ import {
39
39
  type VectorIndexPort,
40
40
  } from "../../store/vector";
41
41
  import { VECTOR_RUNTIME_INCOMPATIBLE } from "../../store/vector/variant-search";
42
- import { getGlobals } from "../program";
42
+ import { getGlobals } from "../globals";
43
43
  import {
44
44
  createProgressRenderer,
45
45
  createThrottledProgressRenderer,
@@ -17,15 +17,15 @@ import {
17
17
  import {
18
18
  getConfigPaths,
19
19
  isInitialized,
20
- loadConfig,
21
20
  writeConfigWarningsToStderr,
22
21
  } from "../../config";
23
22
  import { tracePhase } from "../../core/phase-trace";
24
- import { BUDGET_ERROR_CODES } from "../../ingestion/file-processor";
23
+ import { BUDGET_ERROR_CODES } from "../../ingestion/budget-error-codes";
25
24
  import {
26
25
  SqliteAdapter,
27
26
  staleCollectionsMessage,
28
27
  } from "../../store/sqlite/adapter";
28
+ import { loadConfigCached } from "../config-cache";
29
29
  import { assertCliSessionBinding } from "../session-binding";
30
30
 
31
31
  /**
@@ -78,8 +78,8 @@ export async function initStore(
78
78
  return { ok: false, error: "GNO not initialized. Run: gno init" };
79
79
  }
80
80
 
81
- // Load config
82
- const configResult = await loadConfig(options.configPath);
81
+ // Load config (reused within the same CLI invocation when unchanged)
82
+ const configResult = await loadConfigCached(options.configPath);
83
83
  if (!configResult.ok) {
84
84
  return { ok: false, error: configResult.error.message };
85
85
  }
@@ -10,7 +10,7 @@ import { dirname, join } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
11
 
12
12
  import { CliError } from "../../errors.js";
13
- import { getGlobals } from "../../program.js";
13
+ import { getGlobals } from "../../globals.js";
14
14
  import {
15
15
  resolveSkillPaths,
16
16
  SKILL_TARGETS,
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { join } from "node:path";
9
9
 
10
- import { getGlobals } from "../../program.js";
10
+ import { getGlobals } from "../../globals.js";
11
11
  import { resolveAllPaths, type SkillScope, type SkillTarget } from "./paths.js";
12
12
 
13
13
  // ─────────────────────────────────────────────────────────────────────────────
@@ -9,7 +9,7 @@ import { rm } from "node:fs/promises";
9
9
  import { join } from "node:path";
10
10
 
11
11
  import { CliError } from "../../errors.js";
12
- import { getGlobals } from "../../program.js";
12
+ import { getGlobals } from "../../globals.js";
13
13
  import {
14
14
  resolveSkillPaths,
15
15
  SKILL_TARGETS,
@@ -16,7 +16,6 @@ import {
16
16
  buildContentTypeBoostStatus,
17
17
  getConfigPaths,
18
18
  isInitialized,
19
- loadConfig,
20
19
  } from "../../config";
21
20
  import {
22
21
  describeConnectorSummary,
@@ -32,7 +31,7 @@ import {
32
31
  formatMemoryStatusLines,
33
32
  } from "../../core/memory-diagnostics";
34
33
  import { formatVectorPartitionLines } from "../../core/vector-partition-status";
35
- import { BUDGET_ERROR_CODES } from "../../ingestion/file-processor";
34
+ import { BUDGET_ERROR_CODES } from "../../ingestion/budget-error-codes";
36
35
  import {
37
36
  checkCollectionRoots,
38
37
  type CollectionRootError,
@@ -42,6 +41,7 @@ import { getActivePreset, resolveModelUri } from "../../llm/registry";
42
41
  import { getConnectorVerificationTargets } from "../../serve/connectors";
43
42
  import { createStandaloneResidentStatus } from "../../serve/resident-status";
44
43
  import { SqliteAdapter } from "../../store/sqlite/adapter";
44
+ import { loadConfigCached } from "../config-cache";
45
45
  import {
46
46
  formatBackgroundIssue,
47
47
  residentIssues,
@@ -115,37 +115,19 @@ const STALE_COLLECTIONS_HINT =
115
115
  const BUDGET_STOP_SCAN_LIMIT = 100;
116
116
  /** Most budget stops listed in status output. */
117
117
  const MAX_BUDGET_STOPS = 10;
118
+ const BUDGET_ERROR_CODE_LIST = Array.from(BUDGET_ERROR_CODES);
118
119
 
119
120
  /**
120
121
  * Files whose latest indexing attempt stopped at the conversion budget, from
121
122
  * the recent error log, kept only while the document still carries that code.
122
123
  */
123
124
  async function collectBudgetStops(store: SqliteAdapter): Promise<BudgetStop[]> {
124
- const recent = await store.getRecentErrors(BUDGET_STOP_SCAN_LIMIT);
125
- if (!recent.ok) return [];
126
- const stops: BudgetStop[] = [];
127
- const seen = new Set<string>();
128
- for (const row of recent.value) {
129
- const key = `${row.collection}\u0000${row.relPath}`;
130
- if (seen.has(key)) continue;
131
- seen.add(key);
132
- if (!BUDGET_ERROR_CODES.has(row.code)) continue;
133
- const document = await store.getDocument(row.collection, row.relPath);
134
- if (
135
- document.ok &&
136
- document.value?.active &&
137
- document.value.lastErrorCode === row.code
138
- ) {
139
- stops.push({
140
- collection: row.collection,
141
- relPath: row.relPath,
142
- code: row.code,
143
- message: row.message,
144
- });
145
- if (stops.length >= MAX_BUDGET_STOPS) break;
146
- }
147
- }
148
- return stops;
125
+ const stops = await store.getRecentBudgetStops(
126
+ BUDGET_ERROR_CODE_LIST,
127
+ BUDGET_STOP_SCAN_LIMIT,
128
+ MAX_BUDGET_STOPS
129
+ );
130
+ return stops.ok ? stops.value : [];
149
131
  }
150
132
 
151
133
  /** A background issue reported by (or about) a running detached resident. */
@@ -423,13 +405,22 @@ export async function status(
423
405
  }
424
406
 
425
407
  // Load config
426
- const configResult = await loadConfig(options.configPath);
408
+ const configResult = await loadConfigCached(options.configPath);
427
409
  if (!configResult.ok) {
428
410
  return { success: false, error: configResult.error.message };
429
411
  }
430
412
  const config = configResult.value;
431
- // Read-time root check, overlapping the index reads below; it never rejects.
432
- const rootErrors = checkCollectionRoots(config.collections);
413
+ const collectionNames = config.collections.map(({ name }) => name);
414
+ const preset = getActivePreset(config);
415
+ // Launch filesystem/process probes in parallel with index open + SQLite reads.
416
+ const rootErrorsPromise = checkCollectionRoots(config.collections);
417
+ const embedModelCachedPromise = new ModelCache(getModelsCachePath()).isCached(
418
+ preset.embed
419
+ );
420
+ const connectorTargetsPromise = getConnectorVerificationTargets();
421
+ const backgroundIssuesPromise = collectResidentIssues();
422
+ const registrationRuntimeIssuesPromise = checkRegistrationRuntimes();
423
+ const residentRuntimeIssuesPromise = checkResidentRuntimes();
433
424
 
434
425
  // Open database
435
426
  const store = new SqliteAdapter();
@@ -445,52 +436,78 @@ export async function status(
445
436
  config.busyTimeoutMs
446
437
  );
447
438
  if (!openResult.ok) {
439
+ await Promise.allSettled([
440
+ rootErrorsPromise,
441
+ embedModelCachedPromise,
442
+ connectorTargetsPromise,
443
+ backgroundIssuesPromise,
444
+ registrationRuntimeIssuesPromise,
445
+ residentRuntimeIssuesPromise,
446
+ ]);
448
447
  return { success: false, error: openResult.error.message };
449
448
  }
450
449
 
451
450
  try {
452
- const statusResult = await store.getStatus({
453
- embedModel: resolveModelUri(config, "embed"),
454
- chunking: config.chunking ?? {},
455
- configuredCollections: config.collections.map(({ name }) => name),
456
- });
451
+ const [
452
+ statusResult,
453
+ embedModelCached,
454
+ connectorTargets,
455
+ memory,
456
+ budgetStops,
457
+ staleCollections,
458
+ ] = await Promise.all([
459
+ store.getStatus({
460
+ embedModel: resolveModelUri(config, "embed"),
461
+ chunking: config.chunking ?? {},
462
+ configuredCollections: collectionNames,
463
+ }),
464
+ embedModelCachedPromise,
465
+ connectorTargetsPromise,
466
+ buildMemoryStatus(store, config.collections),
467
+ collectBudgetStops(store),
468
+ collectStaleCollections(store, collectionNames),
469
+ ]);
457
470
  if (!statusResult.ok) {
471
+ await Promise.allSettled([
472
+ rootErrorsPromise,
473
+ backgroundIssuesPromise,
474
+ registrationRuntimeIssuesPromise,
475
+ residentRuntimeIssuesPromise,
476
+ ]);
458
477
  return { success: false, error: statusResult.error.message };
459
478
  }
460
479
 
461
- const preset = getActivePreset(config);
462
- const embedModelCached = await new ModelCache(
463
- getModelsCachePath()
464
- ).isCached(preset.embed);
465
- const activation = await buildActivationStatus(
466
- store,
467
- config.collections.map(({ name }) => name),
468
- {
480
+ const [
481
+ activation,
482
+ backgroundIssues,
483
+ registrationIssues,
484
+ residentIssuesList,
485
+ rootErrors,
486
+ ] = await Promise.all([
487
+ buildActivationStatus(store, collectionNames, {
469
488
  semantic: {
470
489
  modelsCached: embedModelCached,
471
490
  embeddingBacklog: statusResult.value.embeddingBacklog,
472
491
  },
473
- connectorTargets: await getConnectorVerificationTargets(),
474
- }
475
- );
492
+ connectorTargets,
493
+ }),
494
+ backgroundIssuesPromise,
495
+ registrationRuntimeIssuesPromise,
496
+ residentRuntimeIssuesPromise,
497
+ rootErrorsPromise,
498
+ ]);
476
499
 
477
500
  return {
478
501
  success: true,
479
502
  status: statusResult.value,
480
503
  activation,
481
504
  contentTypeBoost: buildContentTypeBoostStatus(config.contentTypes ?? []),
482
- memory: await buildMemoryStatus(store, config.collections),
483
- backgroundIssues: await collectResidentIssues(),
484
- runtimeIssues: [
485
- ...(await checkRegistrationRuntimes()),
486
- ...(await checkResidentRuntimes()),
487
- ],
488
- budgetStops: await collectBudgetStops(store),
489
- staleCollections: await collectStaleCollections(
490
- store,
491
- config.collections.map(({ name }) => name)
492
- ),
493
- rootErrors: await rootErrors,
505
+ memory,
506
+ backgroundIssues,
507
+ runtimeIssues: [...registrationIssues, ...residentIssuesList],
508
+ budgetStops,
509
+ staleCollections,
510
+ rootErrors,
494
511
  };
495
512
  } finally {
496
513
  await store.close();
@@ -14,8 +14,9 @@ import {
14
14
  createVectorStatsPort,
15
15
  } from "../../store/vector";
16
16
  import {
17
- rebuildPartitionIndex,
18
- syncPartitionIndex,
17
+ pruneLegacyVectors,
18
+ rebuildPartitionIndexWithDetails,
19
+ syncPartitionIndexWithDetails,
19
20
  } from "../../store/vector/partition-index";
20
21
  import {
21
22
  dropVectorPartition,
@@ -35,11 +36,25 @@ export interface VecOptions {
35
36
  }
36
37
 
37
38
  export type VecSyncResult =
38
- | { success: true; added: number; removed: number; model: string }
39
+ | {
40
+ success: true;
41
+ added: number;
42
+ removed: number;
43
+ v2Added?: number;
44
+ v2Removed?: number;
45
+ checkRecall?: number | null;
46
+ model: string;
47
+ }
39
48
  | { success: false; error: string };
40
49
 
41
50
  export type VecRebuildResult =
42
- | { success: true; count: number; model: string }
51
+ | {
52
+ success: true;
53
+ count: number;
54
+ v2Count?: number;
55
+ checkRecall?: number | null;
56
+ model: string;
57
+ }
43
58
  | { success: false; error: string };
44
59
 
45
60
  // ─────────────────────────────────────────────────────────────────────────────
@@ -130,7 +145,7 @@ export async function vecSync(
130
145
  }
131
146
  return {
132
147
  success: true,
133
- ...syncPartitionIndex(db, partition),
148
+ ...syncPartitionIndexWithDetails(db, partition),
134
149
  model: modelUri,
135
150
  };
136
151
  }
@@ -223,9 +238,14 @@ export async function vecRebuild(
223
238
  error: "sqlite-vec not available. Cannot rebuild index.",
224
239
  };
225
240
  }
241
+ const rebuilt = rebuildPartitionIndexWithDetails(db, partition);
226
242
  return {
227
243
  success: true,
228
- count: rebuildPartitionIndex(db, partition),
244
+ count: rebuilt.count,
245
+ ...(rebuilt.v2Count !== undefined ? { v2Count: rebuilt.v2Count } : {}),
246
+ ...(rebuilt.checkRecall !== undefined
247
+ ? { checkRecall: rebuilt.checkRecall }
248
+ : {}),
229
249
  model: modelUri,
230
250
  };
231
251
  }
@@ -294,6 +314,13 @@ export function formatVecSync(
294
314
  {
295
315
  added: result.added,
296
316
  removed: result.removed,
317
+ ...(result.v2Added !== undefined ? { v2Added: result.v2Added } : {}),
318
+ ...(result.v2Removed !== undefined
319
+ ? { v2Removed: result.v2Removed }
320
+ : {}),
321
+ ...(result.checkRecall !== undefined
322
+ ? { checkRecall: result.checkRecall }
323
+ : {}),
297
324
  model: result.model,
298
325
  },
299
326
  null,
@@ -301,7 +328,8 @@ export function formatVecSync(
301
328
  );
302
329
  }
303
330
 
304
- if (result.added === 0 && result.removed === 0) {
331
+ const v2Changed = (result.v2Added ?? 0) > 0 || (result.v2Removed ?? 0) > 0;
332
+ if (result.added === 0 && result.removed === 0 && !v2Changed) {
305
333
  return "Vec index already in sync.";
306
334
  }
307
335
 
@@ -312,6 +340,15 @@ export function formatVecSync(
312
340
  if (result.removed > 0) {
313
341
  parts.push(`-${result.removed} removed`);
314
342
  }
343
+ if (v2Changed) {
344
+ const v2Parts: string[] = [];
345
+ if ((result.v2Added ?? 0) > 0) v2Parts.push(`+${result.v2Added}`);
346
+ if ((result.v2Removed ?? 0) > 0) v2Parts.push(`-${result.v2Removed}`);
347
+ parts.push(`coarse mirror ${v2Parts.join("/")}`);
348
+ }
349
+ if (result.checkRecall !== undefined && result.checkRecall !== null) {
350
+ parts.push(`recall@10=${(result.checkRecall * 100).toFixed(1)}%`);
351
+ }
315
352
  return `Vec index synced: ${parts.join(", ")}`;
316
353
  }
317
354
 
@@ -329,6 +366,10 @@ export function formatVecRebuild(
329
366
  return JSON.stringify(
330
367
  {
331
368
  count: result.count,
369
+ ...(result.v2Count !== undefined ? { v2Count: result.v2Count } : {}),
370
+ ...(result.checkRecall !== undefined
371
+ ? { checkRecall: result.checkRecall }
372
+ : {}),
332
373
  model: result.model,
333
374
  },
334
375
  null,
@@ -336,7 +377,15 @@ export function formatVecRebuild(
336
377
  );
337
378
  }
338
379
 
339
- return `Vec index rebuilt: ${result.count.toLocaleString()} vectors`;
380
+ const extras: string[] = [];
381
+ if (result.v2Count !== undefined) {
382
+ extras.push(`coarse mirror ${result.v2Count.toLocaleString()} rows`);
383
+ }
384
+ if (result.checkRecall !== undefined && result.checkRecall !== null) {
385
+ extras.push(`recall@10=${(result.checkRecall * 100).toFixed(1)}%`);
386
+ }
387
+ const suffix = extras.length > 0 ? ` (${extras.join(", ")})` : "";
388
+ return `Vec index rebuilt: ${result.count.toLocaleString()} vectors${suffix}`;
340
389
  }
341
390
 
342
391
  export type VecDropResult =
@@ -388,3 +437,126 @@ export function formatVecDrop(
388
437
  ? JSON.stringify({ dropped: partition }, null, 2)
389
438
  : `Dropped ${partition.state} partition ${partition.id.slice(0, 12)} (${partition.provenance}, ${partition.owners} chunks)`;
390
439
  }
440
+
441
+ export interface VecPruneOptions extends VecOptions {
442
+ /** Run SQLite VACUUM after pruning to reclaim disk space in-place. */
443
+ vacuum?: boolean;
444
+ }
445
+
446
+ export type VecPruneResult =
447
+ | {
448
+ success: true;
449
+ droppedTables: string[];
450
+ removedRows: number;
451
+ vacuumed: boolean;
452
+ }
453
+ | { success: false; error: string };
454
+
455
+ /**
456
+ * Drop superseded legacy `vec_<hash>` tables and delete legacy `content_vectors`
457
+ * rows for models that already have an activated v1 partition, plus any
458
+ * orphaned `vec_v1_*` tables absent from `vector_partitions`.
459
+ */
460
+ export async function vecPrune(
461
+ options: VecPruneOptions = {}
462
+ ): Promise<VecPruneResult> {
463
+ if (!(await isInitialized(options.configPath))) {
464
+ return { success: false, error: "GNO not initialized. Run: gno init" };
465
+ }
466
+ const configResult = await loadConfig(options.configPath);
467
+ if (!configResult.ok) {
468
+ return { success: false, error: configResult.error.message };
469
+ }
470
+ const config = configResult.value;
471
+
472
+ const store = new SqliteAdapter();
473
+ const dbPath = getIndexDbPath(options.indexName);
474
+ const paths = getConfigPaths();
475
+ store.setConfigPath(paths.configFile);
476
+
477
+ const openResult = await store.open(
478
+ dbPath,
479
+ config.ftsTokenizer,
480
+ config.busyTimeoutMs
481
+ );
482
+ if (!openResult.ok) {
483
+ return { success: false, error: openResult.error.message };
484
+ }
485
+
486
+ try {
487
+ const db = store.getRawDb();
488
+ const pruned = await pruneLegacyVectors(db);
489
+ if (!pruned.ok) {
490
+ return { success: false, error: pruned.error };
491
+ }
492
+ if (options.vacuum) {
493
+ try {
494
+ db.exec("VACUUM");
495
+ } catch (vacuumCause) {
496
+ const vacuumMsg =
497
+ vacuumCause instanceof Error
498
+ ? vacuumCause.message
499
+ : String(vacuumCause);
500
+ return {
501
+ success: false,
502
+ error: `Pruned ${pruned.droppedTables.length} legacy table(s) and ${pruned.removedRows.toLocaleString()} legacy row(s), but VACUUM failed: ${vacuumMsg}. The prune already committed; reclaim disk space with VACUUM INTO or retry gno vec prune --vacuum.`,
503
+ };
504
+ }
505
+ }
506
+ return {
507
+ success: true,
508
+ droppedTables: pruned.droppedTables,
509
+ removedRows: pruned.removedRows,
510
+ vacuumed: Boolean(options.vacuum),
511
+ };
512
+ } catch (cause) {
513
+ return {
514
+ success: false,
515
+ error:
516
+ cause instanceof Error
517
+ ? cause.message
518
+ : "Failed to prune legacy vector tables",
519
+ };
520
+ } finally {
521
+ await store.close();
522
+ }
523
+ }
524
+
525
+ export function formatVecPrune(
526
+ result: VecPruneResult,
527
+ options: { json?: boolean }
528
+ ): string {
529
+ if (!result.success) {
530
+ return options.json
531
+ ? JSON.stringify({ error: { code: "RUNTIME", message: result.error } })
532
+ : `Error: ${result.error}`;
533
+ }
534
+ if (options.json) {
535
+ return JSON.stringify(
536
+ {
537
+ droppedTables: result.droppedTables,
538
+ removedRows: result.removedRows,
539
+ vacuumed: result.vacuumed,
540
+ },
541
+ null,
542
+ 2
543
+ );
544
+ }
545
+ if (result.droppedTables.length === 0 && result.removedRows === 0) {
546
+ return result.vacuumed
547
+ ? "No legacy vector tables or rows to prune. Database vacuumed."
548
+ : "No legacy vector tables or rows to prune.";
549
+ }
550
+ const lines = [
551
+ `Pruned ${result.droppedTables.length} legacy table(s) and ${result.removedRows.toLocaleString()} legacy row(s)${result.vacuumed ? "; database vacuumed." : "."}`,
552
+ ];
553
+ if (result.droppedTables.length > 0) {
554
+ lines.push(`Dropped tables: ${result.droppedTables.join(", ")}`);
555
+ }
556
+ if (!result.vacuumed) {
557
+ lines.push(
558
+ "Disk space is reclaimed only after vacuuming (for large indexes, run SQLite VACUUM INTO a new file and swap it in, or rerun with --vacuum)."
559
+ );
560
+ }
561
+ return lines.join("\n");
562
+ }