Skip to content

feat(atlas-core): shard discovery, tier ceilings and parallel fan-out over the core scan shards (#5755 slice 1) - #6661

Merged
dezren39 merged 2 commits into
mainfrom
fw/atlas5755-consumer-wiring
Nov 7, 2026
Merged

dezren39 merged 2 commits into
mainfrom
fw/atlas5755-consumer-wiring

Conversation

@dezren39

@dezren39 dezren39 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

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, crate atlas-core, module shards)

  • Shard discovery — registry-of-record decision: manifest fan-out at startup. A ShardLister only names candidate databases (TursoApiLister = Turso platform API listing filtered to atlas-core-*; DirLister; StaticLister). Each scan shard's atlas_manifest is then read and cross-checked against its name (shard/tier/topic) and must say metric = cosine; count(*) is recorded. New shards join by existing — no code change. Integrity failures abort discovery (fail closed) unless lenient. 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 more ShardLister. (Listing response shape was verified read-only against the live API; no data was read from any shard.)
  • Query path: fanout_scan runs the existing turso_vector_scan_stmt (exact vector_distance_cos, top-k) on every selected shard in parallel threads and merge_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.
  • Tier ceiling, physical, three enforcement points: 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), and scan_one (refuses before sending anything). Mapping: shareable→public, personal/local-only→internal, secret-bearing→secret; default personal can never include secret. Per-tier read-only tokens come from ATLAS_TURSO_TOKEN_{PUBLIC,INTERNAL,SECRET} (names only; Debug never prints tokens). Row-level c.sensitivity IN (...) is kept so results equal the monolith at the same --max-sensitivity.
  • Wiring: ShardedBackend<B> wraps any SearchBackend; 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 no chunks_fts). Hidden, default-off search --shards dir:<path>|turso[:<org>] (ATLAS_SHARDS); skips --via-service. Shipped CLI semantics unchanged — --expand still 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_cos registered, so the identical SQL runs.

  • Oracle: fan-out == one union store scanned with the same statement (25 random queries × random k × 4 ceilings, ids/order/distances).
  • Oracle: recording connector — secret shard never connected at internal ceiling; secret-capable path ranks the planted exact match test #1; shareable sees only public; missing credential fails closed.
  • Discovery (internal-first order, content store/stray DB skipped, new shard joins + snapshot id moves, manifest/name tier mismatch aborts or is rejected when lenient, non-cosine refused), topic scoping, parallelism (all shards in flight together), unsupported filters fail loudly, failing shard fails the query, merge tie-break/dedupe unit tests.
  • CLI e2e: the fixture corpus split into tiered shards reproduces the recorded production-Python envelopes for vector_default, hybrid_default, hybrid_secret_ceiling, hybrid_shareable_ceiling, hybrid_pool2_k2 (only notes gains the fan-out note); default ceiling never opens a (corrupted) secret shard.

cargo test (whole pkgs/atlas-search workspace): all green. cargo fmt clean. (cargo clippy is unusable in this sandbox toolchain — clippy-driver/rustc mismatch on pre-existing deps — not run.)

Not in this slice (follow-ups filed)

--expand hydration from content stores, classification/date filters on shards, serve-mode wiring, live latency/parity re-run, embedded replicas, cache snapshot integration.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

developing-today[bot] added 2 commits November 6, 2026 19:27
…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
@dezren39
dezren39 requested a review from a team as a code owner November 7, 2026 01:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T01:31:26.662332Z 5cdd6ac PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant