@gmickel/gno 2.16.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.
- package/README.md +1 -1
- package/assets/skill/SKILL.md +27 -0
- package/assets/skill/cli-reference.md +20 -13
- package/browser-extension/artifacts/{gno-browser-clipper-v2.16.0.zip → gno-browser-clipper-v2.17.0.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.17.0.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/spec/cli.md +42 -2
- package/spec/db/schema.sql +53 -1
- package/spec/mcp.md +9 -3
- package/spec/output-schemas/doctor.schema.json +27 -0
- package/spec/output-schemas/retrieval-trace-payloads.schema.json +14 -0
- package/spec/output-schemas/search-results.schema.json +14 -0
- package/spec/output-schemas/status.schema.json +22 -0
- package/src/cli/commands/doctor.ts +101 -29
- package/src/cli/commands/links.ts +29 -5
- package/src/cli/commands/vec.ts +180 -8
- package/src/cli/program.ts +43 -0
- package/src/config/types.ts +6 -0
- package/src/core/retrieval-trace-session.ts +3 -0
- package/src/core/retrieval-trace.ts +9 -0
- package/src/core/vector-partition-status.ts +13 -0
- package/src/embed/variant-backlog.ts +36 -2
- package/src/mcp/tools/links.ts +7 -1
- package/src/pipeline/explain.ts +17 -2
- package/src/pipeline/hybrid.ts +28 -1
- package/src/pipeline/types.ts +7 -0
- package/src/pipeline/vsearch.ts +19 -2
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/routes/links.ts +7 -1
- package/src/store/migrations/038-vector-mirror-null-cosine.ts +47 -0
- package/src/store/migrations/039-vector-mirror-v2.ts +94 -0
- package/src/store/migrations/index.ts +4 -0
- package/src/store/sqlite/adapter.ts +117 -74
- package/src/store/vector/coarse-router.ts +312 -0
- package/src/store/vector/partition-index.ts +309 -18
- package/src/store/vector/proof-cache.ts +132 -26
- package/src/store/vector/runtime-compat.ts +6 -0
- package/src/store/vector/sqlite-vec.ts +43 -26
- package/src/store/vector/stats.ts +8 -0
- package/src/store/vector/status.ts +18 -1
- package/src/store/vector/types.ts +9 -0
- package/src/store/vector/v2-mirror.ts +669 -0
- package/src/store/vector/variant-search.ts +434 -20
- package/src/store/vector/variants.ts +480 -32
- package/browser-extension/artifacts/gno-browser-clipper-v2.16.0.zip.sha256 +0 -1
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ See the [guide](docs/COMPILED-CONTEXT.md).
|
|
|
139
139
|
|
|
140
140
|
<!-- public-truth:current-version -->
|
|
141
141
|
|
|
142
|
-
> Current source version: **v2.
|
|
142
|
+
> Current source version: **v2.17.0**. See [CHANGELOG.md](./CHANGELOG.md).
|
|
143
143
|
|
|
144
144
|
<!-- /public-truth -->
|
|
145
145
|
|
package/assets/skill/SKILL.md
CHANGED
|
@@ -766,6 +766,33 @@ MCP-equivalent write tool:
|
|
|
766
766
|
|
|
767
767
|
- `gno_clear_collection_embeddings`
|
|
768
768
|
|
|
769
|
+
## Vector Maintenance, Coarse Routing, and Diagnostics
|
|
770
|
+
|
|
771
|
+
For large unfiltered or collection-scoped vector searches, GNO maintains a 1-bit
|
|
772
|
+
coarse `vec0` mirror (`vec_v2_*`) alongside float32 vectors and rescores
|
|
773
|
+
candidates with exact float32 cosine. Coarse routing is enabled by default for
|
|
774
|
+
partitions above the exact cost budget that pass the build-time recall@10
|
|
775
|
+
self-check (>= 95%); filtered searches and small scopes stay exact.
|
|
776
|
+
|
|
777
|
+
- **Inspect route on a query**: pass `--explain` (`gno query ... --explain`,
|
|
778
|
+
`gno vsearch ... --explain`, or `--json --explain`) to see `vectorRoute`
|
|
779
|
+
(`exact-sql`, `exact-vec0`, or `coarse-bit`, plus `N`, `coarseK`, and
|
|
780
|
+
`rescored`).
|
|
781
|
+
- **Inspect mirror and mmap health**: `gno doctor` reports `sqlite-mmap` and
|
|
782
|
+
`coarse-mirror` (mirror freshness, stored self-check recall@10, and routing
|
|
783
|
+
state); `gno status --json` exposes `vectorPartitions[].coarseMirror`.
|
|
784
|
+
- **Repair mirrors without re-embedding**: run `gno vec sync` (or
|
|
785
|
+
`gno vec rebuild` for a full rebuild) when `coarse-mirror` is `missing` or
|
|
786
|
+
`dirty`.
|
|
787
|
+
- **Disable coarse routing for an index**: set `coarseVectorSearch: false` in
|
|
788
|
+
the index config file (`gno doctor` prints its path) to keep every query on
|
|
789
|
+
exact float32 paths.
|
|
790
|
+
- **Reclaim superseded legacy vector tables**: run `gno vec prune` to drop
|
|
791
|
+
superseded `vec_<hash>` tables, legacy `content_vectors` rows (only for models
|
|
792
|
+
with an activated partition), and orphaned `vec_v1_*` / `vec_v2_*` mirrors.
|
|
793
|
+
Add `--vacuum` for in-place SQLite `VACUUM`, or run SQLite `VACUUM INTO` a new
|
|
794
|
+
file on large databases.
|
|
795
|
+
|
|
769
796
|
## Reference Documentation
|
|
770
797
|
|
|
771
798
|
| Topic | File |
|
|
@@ -447,13 +447,13 @@ gno query <query> [options]
|
|
|
447
447
|
|
|
448
448
|
Additional options:
|
|
449
449
|
|
|
450
|
-
| Option | Description
|
|
451
|
-
| ------------- |
|
|
452
|
-
| `--no-expand` | Disable query expansion
|
|
453
|
-
| `--no-rerank` | Disable reranking
|
|
454
|
-
| `--graph` | Explicitly enable default graph candidates
|
|
455
|
-
| `--no-graph` | Disable graph-neighbor candidates
|
|
456
|
-
| `--explain` | Print retrieval details to stderr
|
|
450
|
+
| Option | Description |
|
|
451
|
+
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
452
|
+
| `--no-expand` | Disable query expansion |
|
|
453
|
+
| `--no-rerank` | Disable reranking |
|
|
454
|
+
| `--graph` | Explicitly enable default graph candidates |
|
|
455
|
+
| `--no-graph` | Disable graph-neighbor candidates |
|
|
456
|
+
| `--explain` | Print retrieval details to stderr (timings, score breakdown, and vector route: `exact-sql`, `exact-vec0`, or `coarse-bit` with `N`, `coarseK`, `rescored`) |
|
|
457
457
|
|
|
458
458
|
### gno ask
|
|
459
459
|
|
|
@@ -904,12 +904,16 @@ gno peek [--json]
|
|
|
904
904
|
gno status [--json|--md]
|
|
905
905
|
```
|
|
906
906
|
|
|
907
|
+
Reports index counts, active vector partitions, and each partition's `coarseMirror` state (`clean`, `dirty`, `missing`, `unsupported`) and build-time recall self-check result.
|
|
908
|
+
|
|
907
909
|
### gno doctor
|
|
908
910
|
|
|
909
911
|
```bash
|
|
910
912
|
gno doctor [--json|--md]
|
|
911
913
|
```
|
|
912
914
|
|
|
915
|
+
Checks config, database, `sqlite-vec`, effective SQLite `mmap_size` (`sqlite-mmap`), embedding fingerprints, vector partitions, and `coarse-mirror` freshness/recall (`gno vec sync` repairs dirty or missing mirrors).
|
|
916
|
+
|
|
913
917
|
### gno cleanup
|
|
914
918
|
|
|
915
919
|
```bash
|
|
@@ -918,17 +922,20 @@ gno cleanup
|
|
|
918
922
|
|
|
919
923
|
### gno vec
|
|
920
924
|
|
|
921
|
-
Vector index maintenance. Use when `gno similar` returns empty despite embeddings.
|
|
925
|
+
Vector index maintenance. Use when `gno similar` returns empty despite embeddings, when `gno doctor` flags a dirty/missing `coarse-mirror`, or to reclaim superseded legacy vector tables.
|
|
922
926
|
|
|
923
927
|
```bash
|
|
924
|
-
gno vec sync
|
|
925
|
-
gno vec rebuild
|
|
928
|
+
gno vec sync # Incremental sync of float32 (v1) and bit coarse (v2) mirrors + recall self-check
|
|
929
|
+
gno vec rebuild # Full rebuild of v1 and v2 mirrors from stored vectors (no re-embedding)
|
|
926
930
|
gno vec drop <partition> # Drop an abandoned shadow partition (id prefix from gno status)
|
|
931
|
+
gno vec prune # Drop superseded legacy vec_<hash> tables, content_vectors rows, and orphan mirrors
|
|
932
|
+
gno vec prune --vacuum # Prune and run in-place SQLite VACUUM to shrink the DB file
|
|
927
933
|
```
|
|
928
934
|
|
|
929
|
-
| Option
|
|
930
|
-
|
|
|
931
|
-
| `--
|
|
935
|
+
| Option | Description |
|
|
936
|
+
| ---------- | --------------------------------------------------------- |
|
|
937
|
+
| `--vacuum` | (`prune` only) Run SQLite `VACUUM` in-place after pruning |
|
|
938
|
+
| `--json` | JSON output |
|
|
932
939
|
|
|
933
940
|
## MCP Server
|
|
934
941
|
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
eace4a15079892d886c7f18875c96257652aec6a59c022baf3d886bee8cb4d4a gno-browser-clipper-v2.17.0.zip
|
package/package.json
CHANGED
package/spec/cli.md
CHANGED
|
@@ -243,7 +243,10 @@ the model with `id`, `model`, `dimensions`, `state` (`active`|`shadow`),
|
|
|
243
243
|
`legacy` (pre-runtime-independent key), `retrieval` (this runtime reads it),
|
|
244
244
|
`droppable` (`gno vec drop` accepts it), `owners` (current chunks),
|
|
245
245
|
`provenance` (building runtime, e.g. `CUDA, Bun 1.4.2`),
|
|
246
|
-
`compatibleRuntimes` (runtimes that read it)
|
|
246
|
+
`compatibleRuntimes` (runtimes that read it), `incompatibleRuntimes`, and
|
|
247
|
+
optional `coarseMirror` (`state`: `clean`|`dirty`|`missing`|`unsupported`,
|
|
248
|
+
`checkRecall`, `checkQueries`, `checkCoarseK`, `belowFloor`) describing the
|
|
249
|
+
partition's v2 binary coarse `vec0` mirror and build-time recall self-check.
|
|
247
250
|
Terminal output prints a `Vector partitions:` block
|
|
248
251
|
unless there is exactly one healthy partition. `collections`, `totalDocuments`
|
|
249
252
|
and `totalChunks` cover configured collections only. Opening an index never
|
|
@@ -1303,7 +1306,7 @@ gno update [--git-pull] [--json] [--lock-wait <duration>] [--no-wait]
|
|
|
1303
1306
|
| `--lock-wait <duration>` | duration | How long to wait for the index write lease (default: `120s`). Accepts `120`, `120s`, or `2m`. |
|
|
1304
1307
|
| `--no-wait` | boolean | Do not wait; fail immediately if another writer holds the lease |
|
|
1305
1308
|
|
|
1306
|
-
**Concurrency:** One writer at a time on the shared index database. `update` waits up to `--lock-wait` for the lease (the same `.mcp-write.lock` MCP write tools use); `index`, `embed`, `cleanup`, `vec sync`, `vec rebuild`, `vec drop`, `collection clear-embeddings`, `tags add`, and `tags rm` follow the same contract; `capture` takes the same lock internally, and single-row writes such as `collection policy set` are absorbed by `busy_timeout`. `--no-wait` opts out. Reads (`search`, `query`, `get`) never take the lease. External serialising wrappers are no longer required for CLI-vs-CLI and CLI-vs-MCP overlap. A resident (`gno serve`/`gno daemon`) takes the same lease without waiting around each watcher sync, embed preparation, background-embedding page write (never around inference), and the final vector activation; when the lease is held it defers that work (watcher retry after 5s, embed pass rescheduled) instead of writing, so resident background writes never hold a SQLite write lock outside the lease. The resident's own SQLite busy wait is capped at 500ms so a stop signal is always handled within the stop grace.
|
|
1309
|
+
**Concurrency:** One writer at a time on the shared index database. `update` waits up to `--lock-wait` for the lease (the same `.mcp-write.lock` MCP write tools use); `index`, `embed`, `cleanup`, `vec sync`, `vec rebuild`, `vec drop`, `vec prune`, `collection clear-embeddings`, `tags add`, and `tags rm` follow the same contract; `capture` takes the same lock internally, and single-row writes such as `collection policy set` are absorbed by `busy_timeout`. `--no-wait` opts out. Reads (`search`, `query`, `get`) never take the lease. External serialising wrappers are no longer required for CLI-vs-CLI and CLI-vs-MCP overlap. A resident (`gno serve`/`gno daemon`) takes the same lease without waiting around each watcher sync, embed preparation, background-embedding page write (never around inference), and the final vector activation; when the lease is held it defers that work (watcher retry after 5s, embed pass rescheduled) instead of writing, so resident background writes never hold a SQLite write lock outside the lease. The resident's own SQLite busy wait is capped at 500ms so a stop signal is always handled within the stop grace.
|
|
1307
1310
|
|
|
1308
1311
|
**Behavior:**
|
|
1309
1312
|
|
|
@@ -1828,6 +1831,7 @@ active with `sourceCount: 1`.
|
|
|
1828
1831
|
```
|
|
1829
1832
|
[explain] expansion: enabled (3 lexical, 2 semantic variants)
|
|
1830
1833
|
[explain] bm25: 45 candidates
|
|
1834
|
+
[explain] vector: 20 candidates (route=exact-sql, N=45000)
|
|
1831
1835
|
[explain] vector: 38 candidates
|
|
1832
1836
|
[explain] graph: seeds=5, candidates=4/20, explicit=3, inferred=1, ambiguous=0, similarity=0
|
|
1833
1837
|
[explain] fusion: RRF k=60, 52 unique documents (best rank per list)
|
|
@@ -3167,6 +3171,42 @@ included, is refused. JSON output is
|
|
|
3167
3171
|
|
|
3168
3172
|
---
|
|
3169
3173
|
|
|
3174
|
+
### gno vec prune
|
|
3175
|
+
|
|
3176
|
+
Drop superseded legacy `vec_<hash>` tables and delete legacy `content_vectors`
|
|
3177
|
+
rows for models that already have an activated v1 vector partition, plus any
|
|
3178
|
+
orphaned `vec_v1_<partition>` and `vec_v2_<partition>` tables (and orphaned
|
|
3179
|
+
`vector_partition_rows` / `vector_mirror_v2_state` rows) absent from
|
|
3180
|
+
`vector_partitions`. Models whose v1 partition is still `shadow` or absent keep
|
|
3181
|
+
their legacy tables and rows.
|
|
3182
|
+
|
|
3183
|
+
**Synopsis:**
|
|
3184
|
+
|
|
3185
|
+
```bash
|
|
3186
|
+
gno vec prune [--vacuum] [--json] [--lock-wait <duration>] [--no-wait]
|
|
3187
|
+
```
|
|
3188
|
+
|
|
3189
|
+
**Options:**
|
|
3190
|
+
| Option | Type | Description |
|
|
3191
|
+
|--------|------|-------------|
|
|
3192
|
+
| `--vacuum` | boolean | Run SQLite `VACUUM` in-place after pruning to reclaim disk space |
|
|
3193
|
+
| `--json` | boolean | JSON output (`{"droppedTables": string[], "removedRows": number, "vacuumed": boolean}`) |
|
|
3194
|
+
| `--lock-wait <duration>` | duration | How long to wait for the index write lease |
|
|
3195
|
+
| `--no-wait` | boolean | Fail immediately if another writer holds the lease |
|
|
3196
|
+
|
|
3197
|
+
**Notes:**
|
|
3198
|
+
|
|
3199
|
+
- Requires `sqlite-vec` (fails closed when the extension is unavailable or the database is read-only).
|
|
3200
|
+
- Without `--vacuum`, pruning frees internal SQLite pages without shrinking the file on disk. For large indexes, prefer `VACUUM INTO` a new file to reclaim disk space and defragment pages while keeping the original file as a rollback copy.
|
|
3201
|
+
|
|
3202
|
+
**Exit Codes:**
|
|
3203
|
+
|
|
3204
|
+
- 0: Success (including zero-op on a clean database)
|
|
3205
|
+
- 2: Runtime error (database open failed, read-only database, or `sqlite-vec` unavailable)
|
|
3206
|
+
- 4: Write lease busy with `--no-wait`
|
|
3207
|
+
|
|
3208
|
+
---
|
|
3209
|
+
|
|
3170
3210
|
### gno cleanup
|
|
3171
3211
|
|
|
3172
3212
|
Delete the documents of indexed collections the config does not list, then
|
package/spec/db/schema.sql
CHANGED
|
@@ -308,7 +308,8 @@ CREATE INDEX IF NOT EXISTS idx_vector_owners_variant ON vector_owners(variant_id
|
|
|
308
308
|
-- scan the variants index.
|
|
309
309
|
CREATE TABLE IF NOT EXISTS vector_mirror_state (
|
|
310
310
|
partition_id TEXT PRIMARY KEY,
|
|
311
|
-
dirty INTEGER NOT NULL CHECK (dirty IN (0, 1))
|
|
311
|
+
dirty INTEGER NOT NULL CHECK (dirty IN (0, 1)),
|
|
312
|
+
null_cosine INTEGER CHECK (null_cosine IS NULL OR null_cosine IN (0, 1))
|
|
312
313
|
);
|
|
313
314
|
CREATE TRIGGER IF NOT EXISTS vector_variants_mirror_before_insert
|
|
314
315
|
BEFORE INSERT ON vector_variants BEGIN
|
|
@@ -1005,3 +1006,54 @@ CREATE TRIGGER graph_inventory_graph_reference_documents_delete AFTER DELETE ON
|
|
|
1005
1006
|
CREATE TRIGGER graph_inventory_graph_frontmatter_references_insert AFTER INSERT ON graph_frontmatter_references BEGIN UPDATE graph_projection_state SET dirty = 1, in_progress = 1 WHERE id = 1; END;
|
|
1006
1007
|
CREATE TRIGGER graph_inventory_graph_frontmatter_references_update AFTER UPDATE ON graph_frontmatter_references BEGIN UPDATE graph_projection_state SET dirty = 1, in_progress = 1 WHERE id = 1; END;
|
|
1007
1008
|
CREATE TRIGGER graph_inventory_graph_frontmatter_references_delete AFTER DELETE ON graph_frontmatter_references BEGIN UPDATE graph_projection_state SET dirty = 1, in_progress = 1 WHERE id = 1; END;
|
|
1009
|
+
|
|
1010
|
+
-- ─────────────────────────────────────────────────────────────────────────────
|
|
1011
|
+
-- Vector v2 bit coarse mirror metadata (migration 039, fn-235)
|
|
1012
|
+
-- ─────────────────────────────────────────────────────────────────────────────
|
|
1013
|
+
|
|
1014
|
+
CREATE TABLE IF NOT EXISTS vector_partition_rows (
|
|
1015
|
+
id INTEGER PRIMARY KEY,
|
|
1016
|
+
partition_id TEXT NOT NULL,
|
|
1017
|
+
collection TEXT NOT NULL,
|
|
1018
|
+
variant_id INTEGER NOT NULL,
|
|
1019
|
+
UNIQUE(partition_id, collection, variant_id)
|
|
1020
|
+
);
|
|
1021
|
+
|
|
1022
|
+
CREATE INDEX IF NOT EXISTS idx_vector_partition_rows_part_var
|
|
1023
|
+
ON vector_partition_rows(partition_id, variant_id);
|
|
1024
|
+
|
|
1025
|
+
CREATE TABLE IF NOT EXISTS vector_mirror_v2_state (
|
|
1026
|
+
partition_id TEXT PRIMARY KEY,
|
|
1027
|
+
dirty INTEGER NOT NULL CHECK (dirty IN (0, 1)),
|
|
1028
|
+
check_recall REAL,
|
|
1029
|
+
check_queries INTEGER,
|
|
1030
|
+
check_coarse_k INTEGER
|
|
1031
|
+
);
|
|
1032
|
+
|
|
1033
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_variants_v2_insert
|
|
1034
|
+
AFTER INSERT ON vector_variants
|
|
1035
|
+
BEGIN
|
|
1036
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
1037
|
+
END;
|
|
1038
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_variants_v2_update
|
|
1039
|
+
AFTER UPDATE ON vector_variants
|
|
1040
|
+
BEGIN
|
|
1041
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = OLD.partition_id;
|
|
1042
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
1043
|
+
END;
|
|
1044
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_variants_v2_delete
|
|
1045
|
+
AFTER DELETE ON vector_variants
|
|
1046
|
+
BEGIN
|
|
1047
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = OLD.partition_id;
|
|
1048
|
+
END;
|
|
1049
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_owners_v2_insert
|
|
1050
|
+
AFTER INSERT ON vector_owners
|
|
1051
|
+
BEGIN
|
|
1052
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
1053
|
+
END;
|
|
1054
|
+
CREATE TRIGGER IF NOT EXISTS trg_vector_owners_v2_update
|
|
1055
|
+
AFTER UPDATE ON vector_owners
|
|
1056
|
+
BEGIN
|
|
1057
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = OLD.partition_id;
|
|
1058
|
+
DELETE FROM vector_mirror_v2_state WHERE partition_id = NEW.partition_id;
|
|
1059
|
+
END;
|
package/spec/mcp.md
CHANGED
|
@@ -1478,8 +1478,11 @@ read under the same selection rule as retrieval (`vectorRuntime` reports
|
|
|
1478
1478
|
`vectors`, `unavailable` with a reason, or `unresolved` before its first query
|
|
1479
1479
|
or embed). `droppable` marks what `gno vec drop` accepts. Other partitions carry `state`, `owners` and a
|
|
1480
1480
|
readable `provenance`; `compatibleRuntimes` names the runtimes that read a
|
|
1481
|
-
partition
|
|
1482
|
-
reproduce the stored vectors
|
|
1481
|
+
partition, `incompatibleRuntimes` names runtimes measured unable to
|
|
1482
|
+
reproduce the stored vectors (whose queries use lexical retrieval only), and
|
|
1483
|
+
optional `coarseMirror` reports the partition's v2 bit coarse mirror freshness
|
|
1484
|
+
and build-time recall self-check (`state`, `checkRecall`, `checkQueries`,
|
|
1485
|
+
`checkCoarseK`, `belowFloor`).
|
|
1483
1486
|
|
|
1484
1487
|
`contentTypeBoost` is a redacted ranking-status projection. It exposes only
|
|
1485
1488
|
normalized IDs/factors plus the rules fingerprint; path prefixes are never
|
|
@@ -2229,7 +2232,10 @@ Get documents linking TO a document.
|
|
|
2229
2232
|
|
|
2230
2233
|
### gno_similar
|
|
2231
2234
|
|
|
2232
|
-
Find semantically similar documents using vector embeddings.
|
|
2235
|
+
Find semantically similar documents using vector embeddings. When
|
|
2236
|
+
`crossCollection` is false (the default), the underlying vector search is scoped
|
|
2237
|
+
directly to the source document's collection so documents in other collections
|
|
2238
|
+
cannot crowd out same-collection candidates.
|
|
2233
2239
|
|
|
2234
2240
|
**Input Schema:**
|
|
2235
2241
|
|
|
@@ -330,6 +330,33 @@
|
|
|
330
330
|
"items": {
|
|
331
331
|
"type": "string"
|
|
332
332
|
}
|
|
333
|
+
},
|
|
334
|
+
"coarseMirror": {
|
|
335
|
+
"type": "object",
|
|
336
|
+
"additionalProperties": false,
|
|
337
|
+
"required": [
|
|
338
|
+
"state",
|
|
339
|
+
"checkRecall",
|
|
340
|
+
"checkQueries",
|
|
341
|
+
"checkCoarseK",
|
|
342
|
+
"belowFloor"
|
|
343
|
+
],
|
|
344
|
+
"properties": {
|
|
345
|
+
"state": {
|
|
346
|
+
"type": "string",
|
|
347
|
+
"enum": ["clean", "dirty", "missing", "unsupported"]
|
|
348
|
+
},
|
|
349
|
+
"checkRecall": { "type": ["number", "null"] },
|
|
350
|
+
"checkQueries": {
|
|
351
|
+
"type": ["integer", "null"],
|
|
352
|
+
"minimum": 0
|
|
353
|
+
},
|
|
354
|
+
"checkCoarseK": {
|
|
355
|
+
"type": ["integer", "null"],
|
|
356
|
+
"minimum": 1
|
|
357
|
+
},
|
|
358
|
+
"belowFloor": { "type": "boolean" }
|
|
359
|
+
}
|
|
333
360
|
}
|
|
334
361
|
}
|
|
335
362
|
}
|
|
@@ -92,6 +92,20 @@
|
|
|
92
92
|
"type": "array",
|
|
93
93
|
"maxItems": 100,
|
|
94
94
|
"items": { "type": "string", "minLength": 1, "maxLength": 128 }
|
|
95
|
+
},
|
|
96
|
+
"vectorRoute": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"additionalProperties": false,
|
|
99
|
+
"required": ["route", "mirrorRows"],
|
|
100
|
+
"properties": {
|
|
101
|
+
"route": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"enum": ["exact-sql", "exact-vec0", "coarse-bit"]
|
|
104
|
+
},
|
|
105
|
+
"mirrorRows": { "type": "integer", "minimum": 0 },
|
|
106
|
+
"coarseK": { "type": "integer", "minimum": 1 },
|
|
107
|
+
"rescored": { "type": "integer", "minimum": 0 }
|
|
108
|
+
}
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
111
|
},
|
|
@@ -592,6 +592,20 @@
|
|
|
592
592
|
"results": {
|
|
593
593
|
"type": "array",
|
|
594
594
|
"items": { "$ref": "#/$defs/explainResult" }
|
|
595
|
+
},
|
|
596
|
+
"vectorRoute": {
|
|
597
|
+
"type": "object",
|
|
598
|
+
"additionalProperties": false,
|
|
599
|
+
"required": ["route", "mirrorRows"],
|
|
600
|
+
"properties": {
|
|
601
|
+
"route": {
|
|
602
|
+
"type": "string",
|
|
603
|
+
"enum": ["exact-sql", "exact-vec0", "coarse-bit"]
|
|
604
|
+
},
|
|
605
|
+
"mirrorRows": { "type": "integer", "minimum": 0 },
|
|
606
|
+
"coarseK": { "type": "integer", "minimum": 1 },
|
|
607
|
+
"rescored": { "type": "integer", "minimum": 0 }
|
|
608
|
+
}
|
|
595
609
|
}
|
|
596
610
|
},
|
|
597
611
|
"additionalProperties": false
|
|
@@ -245,6 +245,28 @@
|
|
|
245
245
|
"type": "string"
|
|
246
246
|
},
|
|
247
247
|
"description": "Runtimes measured incompatible; they read another partition or use lexical retrieval only"
|
|
248
|
+
},
|
|
249
|
+
"coarseMirror": {
|
|
250
|
+
"type": "object",
|
|
251
|
+
"additionalProperties": false,
|
|
252
|
+
"required": [
|
|
253
|
+
"state",
|
|
254
|
+
"checkRecall",
|
|
255
|
+
"checkQueries",
|
|
256
|
+
"checkCoarseK",
|
|
257
|
+
"belowFloor"
|
|
258
|
+
],
|
|
259
|
+
"description": "Bit coarse vec0 mirror freshness and build-time recall self-check status",
|
|
260
|
+
"properties": {
|
|
261
|
+
"state": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"enum": ["clean", "dirty", "missing", "unsupported"]
|
|
264
|
+
},
|
|
265
|
+
"checkRecall": { "type": ["number", "null"] },
|
|
266
|
+
"checkQueries": { "type": ["integer", "null"], "minimum": 0 },
|
|
267
|
+
"checkCoarseK": { "type": ["integer", "null"], "minimum": 1 },
|
|
268
|
+
"belowFloor": { "type": "boolean" }
|
|
269
|
+
}
|
|
248
270
|
}
|
|
249
271
|
}
|
|
250
272
|
}
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
getExtensionLoadingMode,
|
|
44
44
|
getLoadAttempts,
|
|
45
45
|
} from "../../store/sqlite/setup";
|
|
46
|
+
import { COARSE_ROUTER_DEFAULTS } from "../../store/vector/coarse-router";
|
|
46
47
|
import { getStoredEmbeddingFingerprint } from "../../store/vector/freshness";
|
|
47
48
|
import { currentOwnerCount } from "../../store/vector/runtime-compat";
|
|
48
49
|
import { storedVectorPartition } from "../../store/vector/status";
|
|
@@ -170,22 +171,30 @@ async function checkDatabase(indexName?: string): Promise<DoctorCheck> {
|
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
/**
|
|
173
|
-
* Report
|
|
174
|
+
* Report live SQLite PRAGMAs (`busy_timeout` and `mmap_size`) read back from
|
|
175
|
+
* the open index connection, not config echoes or requested ceilings.
|
|
174
176
|
*/
|
|
175
|
-
async function
|
|
177
|
+
async function checkSqlitePragmas(
|
|
176
178
|
config: Config,
|
|
177
179
|
indexName?: string
|
|
178
|
-
): Promise<DoctorCheck> {
|
|
180
|
+
): Promise<DoctorCheck[]> {
|
|
179
181
|
const dbPath = getIndexDbPath(indexName);
|
|
180
182
|
|
|
181
183
|
try {
|
|
182
184
|
await stat(dbPath);
|
|
183
185
|
} catch {
|
|
184
|
-
return
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
return [
|
|
187
|
+
{
|
|
188
|
+
name: "busy-timeout",
|
|
189
|
+
status: "warn",
|
|
190
|
+
message: "Database not found. Run: gno init",
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "sqlite-mmap",
|
|
194
|
+
status: "warn",
|
|
195
|
+
message: "Database not found. Run: gno init",
|
|
196
|
+
},
|
|
197
|
+
];
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
const store = new SqliteAdapter();
|
|
@@ -198,30 +207,58 @@ async function checkBusyTimeout(
|
|
|
198
207
|
config.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS
|
|
199
208
|
);
|
|
200
209
|
if (!openResult.ok) {
|
|
201
|
-
return
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
return [
|
|
211
|
+
{
|
|
212
|
+
name: "busy-timeout",
|
|
213
|
+
status: "warn",
|
|
214
|
+
message: `busy_timeout unavailable: ${openResult.error.message}`,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: "sqlite-mmap",
|
|
218
|
+
status: "warn",
|
|
219
|
+
message: `mmap_size unavailable: ${openResult.error.message}`,
|
|
220
|
+
},
|
|
221
|
+
];
|
|
206
222
|
}
|
|
207
223
|
|
|
208
224
|
try {
|
|
209
|
-
const
|
|
210
|
-
|
|
225
|
+
const db = store.getRawDb();
|
|
226
|
+
const timeout = db
|
|
211
227
|
.query<{ timeout: number }, []>("PRAGMA busy_timeout")
|
|
212
228
|
.get()?.timeout;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
const busyCheck: DoctorCheck =
|
|
230
|
+
timeout === undefined
|
|
231
|
+
? {
|
|
232
|
+
name: "busy-timeout",
|
|
233
|
+
status: "warn",
|
|
234
|
+
message: "PRAGMA busy_timeout returned no value",
|
|
235
|
+
}
|
|
236
|
+
: {
|
|
237
|
+
name: "busy-timeout",
|
|
238
|
+
status: "ok",
|
|
239
|
+
message: `busy_timeout ${timeout}ms`,
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const mmapSize = db
|
|
243
|
+
.query<{ mmap_size: number }, []>("PRAGMA mmap_size")
|
|
244
|
+
.get()?.mmap_size;
|
|
245
|
+
const mmapCheck: DoctorCheck =
|
|
246
|
+
mmapSize === undefined
|
|
247
|
+
? {
|
|
248
|
+
name: "sqlite-mmap",
|
|
249
|
+
status: "warn",
|
|
250
|
+
message: "PRAGMA mmap_size returned no value",
|
|
251
|
+
}
|
|
252
|
+
: {
|
|
253
|
+
name: "sqlite-mmap",
|
|
254
|
+
status: "ok",
|
|
255
|
+
message:
|
|
256
|
+
mmapSize > 0
|
|
257
|
+
? `mmap_size ${mmapSize} bytes (${Math.round(mmapSize / (1024 * 1024))} MiB)`
|
|
258
|
+
: "mmap_size 0 bytes (disabled)",
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
return [busyCheck, mmapCheck];
|
|
225
262
|
} finally {
|
|
226
263
|
await store.close();
|
|
227
264
|
}
|
|
@@ -441,6 +478,40 @@ async function checkEmbeddingFingerprints(
|
|
|
441
478
|
const runtime = statusResult.value.vectorRuntime;
|
|
442
479
|
const partitionLines = formatVectorPartitionLines(partitions, runtime);
|
|
443
480
|
const retrieval = partitions.find((p) => p.retrieval);
|
|
481
|
+
const activeTarget =
|
|
482
|
+
retrieval ?? partitions.find((p) => p.state === "active");
|
|
483
|
+
const coarse = activeTarget?.coarseMirror;
|
|
484
|
+
const coarseChecks: DoctorCheck[] = [];
|
|
485
|
+
if (activeTarget && coarse) {
|
|
486
|
+
const enabled =
|
|
487
|
+
config.coarseVectorSearch ?? COARSE_ROUTER_DEFAULTS.enabledByDefault;
|
|
488
|
+
let coarseStatus: DoctorCheckStatus = "ok";
|
|
489
|
+
let coarseMsg: string;
|
|
490
|
+
const coarseDetails: string[] = [];
|
|
491
|
+
if (coarse.state === "unsupported") {
|
|
492
|
+
coarseMsg = `unsupported (dimensions=${activeTarget.dimensions} not divisible by 8; stays exact)`;
|
|
493
|
+
} else if (coarse.state === "missing" || coarse.state === "dirty") {
|
|
494
|
+
coarseStatus = enabled ? "warn" : "info";
|
|
495
|
+
coarseMsg = `${coarse.state} (stays exact; run: gno vec sync)`;
|
|
496
|
+
coarseDetails.push("Run: gno vec sync");
|
|
497
|
+
} else if (coarse.belowFloor && coarse.checkRecall !== null) {
|
|
498
|
+
coarseStatus = enabled ? "warn" : "info";
|
|
499
|
+
coarseMsg = `clean, recall@10=${(coarse.checkRecall * 100).toFixed(1)}% below 95% floor (stays exact)`;
|
|
500
|
+
coarseDetails.push(
|
|
501
|
+
"Two-stage coarse routing stays disabled for this partition because self-check recall is below the 95% floor."
|
|
502
|
+
);
|
|
503
|
+
} else if (coarse.checkRecall !== null) {
|
|
504
|
+
coarseMsg = `clean, recall@10=${(coarse.checkRecall * 100).toFixed(1)}% (${coarse.checkQueries ?? 0}q, coarseK=${coarse.checkCoarseK ?? 200}); routing ${enabled ? "enabled" : "disabled in config"}`;
|
|
505
|
+
} else {
|
|
506
|
+
coarseMsg = `clean, self-check not run (partition within exact budget or unchecked; stays exact); routing ${enabled ? "enabled" : "disabled in config"}`;
|
|
507
|
+
}
|
|
508
|
+
coarseChecks.push({
|
|
509
|
+
name: "coarse-mirror",
|
|
510
|
+
status: coarseStatus,
|
|
511
|
+
message: coarseMsg,
|
|
512
|
+
...(coarseDetails.length > 0 ? { details: coarseDetails } : {}),
|
|
513
|
+
});
|
|
514
|
+
}
|
|
444
515
|
return [
|
|
445
516
|
fingerprintCheck,
|
|
446
517
|
{
|
|
@@ -455,6 +526,7 @@ async function checkEmbeddingFingerprints(
|
|
|
455
526
|
vectorPartitions: partitions,
|
|
456
527
|
vectorRuntime: runtime,
|
|
457
528
|
},
|
|
529
|
+
...coarseChecks,
|
|
458
530
|
];
|
|
459
531
|
} finally {
|
|
460
532
|
await store.close();
|
|
@@ -805,8 +877,8 @@ export async function doctor(
|
|
|
805
877
|
const sqliteChecks = await checkSqliteExtensions();
|
|
806
878
|
checks.push(...sqliteChecks);
|
|
807
879
|
|
|
808
|
-
// Live busy_timeout from the open index (not
|
|
809
|
-
checks.push(await
|
|
880
|
+
// Live busy_timeout and mmap_size from the open index (not config echoes)
|
|
881
|
+
checks.push(...(await checkSqlitePragmas(config, options.indexName)));
|
|
810
882
|
|
|
811
883
|
// Code chunking capability
|
|
812
884
|
checks.push(checkCodeChunking());
|
|
@@ -634,16 +634,40 @@ export async function similar(
|
|
|
634
634
|
const searchResult = await vectorIndex.searchNearest(
|
|
635
635
|
embedding,
|
|
636
636
|
candidateLimit,
|
|
637
|
-
|
|
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
|
-
//
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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 };
|