Repository navigation
feat(atlas-core): shard discovery, tier ceilings and parallel fan-out over the core scan shards (#5755 slice 1) - #6661
Conversation
…l fan-out over the core scan shards (#5755 slice 1) Adds atlas_core::shards: manifest-fan-out discovery (name convention + atlas_manifest cross-check; Turso platform API / dir / static listers), physical tier ceilings (no connect or credential above the caller's tier), parallel exact-cosine fan-out with distance merge (internal first on ties), snapshot_id material for #5668, and a ShardedBackend that takes the vector branch from shards while FTS/details stay on the monolith. Hidden, default-off --shards / ATLAS_SHARDS flag on 'search'. Refs #5755
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5cdd6aca8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| &args.vector.vec_table, | ||
| ) | ||
| .map_err(map_err)?; | ||
| backend = Box::new(ShardedBackend::new(backend, set)); |
There was a problem hiding this comment.
Verify or map chunk identities before wrapping a local backend
When --shards is combined with a local corpus whose chunk IDs differ from the monolith's, this wrapper mixes two ID namespaces. pick_backend permits explicit local selection and automatic fallback to local, but ShardedBackend forwards raw shard IDs into fusion and delegates detail lookup unchanged. The existing local vector implementation maps IDs through content_hash specifically because store ID spaces differ (local.rs:449–476). Here, shard hits can disappear or hydrate unrelated local rows with colliding IDs; those unrelated rows have not passed the shard's sensitivity filter. Require a compatible ID namespace or map shard identities into the wrapped corpus before fusion and hydration.
Useful? React with 👍 / 👎.
| &args.vector.vec_table, | ||
| ) | ||
| .map_err(map_err)?; | ||
| backend = Box::new(ShardedBackend::new(backend, set)); |
There was a problem hiding this comment.
Reject or implement truncation for shard vector searches
With --backend local --shards dir:<path> --trunc N, where N is smaller than the stored vector width, the query vector is truncated but the shard document vectors are not. Previously, LocalBackend also truncated document vectors (local.rs:509–510); replacing its vector branch bypasses that behavior. LocalShardTransport::cosine_distance returns NULL for unequal dimensions, and scan_one silently drops those distances, so vector searches return no hits and hybrid searches silently become FTS-only. Either implement document-vector truncation on the shard path or reject the unsupported combination explicitly.
Useful? React with 👍 / 👎.
Refs #5755 (slice 1 of the consumer wiring — not the whole issue). Coordinates with #5668 (cache/flags; this PR only exposes snapshot-id material) and #5604 (serve-role home).
What this adds (
pkgs/atlas-search, crateatlas-core, moduleshards)ShardListeronly names candidate databases (TursoApiLister= Turso platform API listing filtered toatlas-core-*;DirLister;StaticLister). Each scan shard'satlas_manifestis then read and cross-checked against its name (shard/tier/topic) and must saymetric = cosine;count(*)is recorded. New shards join by existing — no code change. Integrity failures abort discovery (fail closed) unlesslenient. Why not the atlas staging tier: versioned schema, registry, aggregator with merge-on-close promotion into three-level core #5669 registry: the pilot registry DB was deleted in the 2026-11-06 spike cleanup, and the atlas staging tier: versioned schema, registry, aggregator with merge-on-close promotion into three-level core #5669 registry tracks staging units, not scan shards; when it grows a shard table it is just one moreShardLister. (Listing response shape was verified read-only against the live API; no data was read from any shard.)fanout_scanruns the existingturso_vector_scan_stmt(exactvector_distance_cos, top-k) on every selected shard in parallel threads andmerge_top_ks by distance (ties: internal tier first, then shard name, chunk id; duplicate ids kept once). A failing shard fails the query (no silent partial answers). Optional manifest-topic scoping touches only that topic's shards.discover(never connects to / needs a credential for a tier above the caller's),ShardSet::select(per-caller; a secret-bearing caller against a set not opened for secret is refused, not downgraded), andscan_one(refuses before sending anything). Mapping: shareable→public, personal/local-only→internal, secret-bearing→secret; defaultpersonalcan never include secret. Per-tier read-only tokens come fromATLAS_TURSO_TOKEN_{PUBLIC,INTERNAL,SECRET}(names only;Debugnever prints tokens). Row-levelc.sensitivity IN (...)is kept so results equal the monolith at the same--max-sensitivity.ShardedBackend<B>wraps anySearchBackend; the vector branch comes from shards, FTS/details/neighbors/messages stay on the wrapped (monolith) backend — this is also the FTS answer for now (TursoDB shards have nochunks_fts). Hidden, default-offsearch --shards dir:<path>|turso[:<org>](ATLAS_SHARDS); skips--via-service. Shipped CLI semantics unchanged —--expandstill means neighbors.ShardSet::snapshot_material()/snapshot_id()— sha256 over sorted (shard, tier, count): changes on re-shard and on promotion batches; hook for atlas-search service: query-embedding + snapshot result caching, --no-cache/--wait/--expand/--raw flags #5668's result-cache key.Tests (no Turso, no secrets)
Local SQLite shard files with
vector32/vector_distance_cosregistered, so the identical SQL runs.vector_default,hybrid_default,hybrid_secret_ceiling,hybrid_shareable_ceiling,hybrid_pool2_k2(onlynotesgains the fan-out note); default ceiling never opens a (corrupted) secret shard.cargo test(wholepkgs/atlas-searchworkspace): all green.cargo fmtclean. (cargo clippyis unusable in this sandbox toolchain — clippy-driver/rustc mismatch on pre-existing deps — not run.)Not in this slice (follow-ups filed)
--expandhydration from content stores, classification/date filters on shards, serve-mode wiring, live latency/parity re-run, embedded replicas, cache snapshot integration.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.