GeezerVison is showing github.com — atlas-search: snapshot-bound result cache — per-service memory, snapshot-rotation invalidation (#5668 slice 3) · Issue #9943 · developing-today/code
atlas-search: snapshot-bound result cache — per-service memory, snapshot-rotation invalidation (#5668 slice 3) #9943DescriptionSlice 3 of #5668, filed by the task 15204 fresh triage (2026-11-14, lane any-c). Design: PR #5667 §3 (merged). Parent: #5668.
Work — snapshot-bound result cache (lands last)
- Cache key:
sha256(query || snapshot_id || ceiling || flags) using the shared key constructor from slice 2 (flags end-to-end). All flags are part of the key.
- The snapshot id is the request's shard-set snapshot id —
ShardSet::snapshot_id() already exists in atlas-core (crates/atlas-core/src/shards/mod.rs, noted there as "the material for the result-cache snapshot id (atlas-search service: query-embedding + snapshot result caching, --no-cache/--wait/--expand/--raw flags #5668)"). Per the 2026-11-11 contract on atlas-search service: query-embedding + snapshot result caching, --no-cache/--wait/--expand/--raw flags #5668, each request binds its current shard snapshot id atomically to its cache key; when atlas staging tier: versioned schema, registry, aggregator with merge-on-close promotion into three-level core #5669's aggregator promotion lands, promotion bumps move that id and the service observes them without restart — this slice does not wait for atlas staging tier: versioned schema, registry, aggregator with merge-on-close promotion into three-level core #5669.
- Storage: in-service memory only, per the Atlas step 4: serve mode — job protocol, worker pool, in-memory temp store #5354 privacy rule — no cross-client result sharing by default. 24h TTL as a GC bound only (correctness comes from the snapshot id, not the clock).
- A snapshot bump invalidates all result entries at once (id change = key change; stale-id entries are unreachable and GC'd).
Gates
- Slice 2 (flags + shared key constructor) must land first — its queue task is this slice's gate; dep-block on it at claim time if unlanded (runbook §5b). Slice 1 (embedding cache) is independent and may land before or after.
Acceptance
- A repeated identical query against an unchanged snapshot is served from cache with no Turso round-trip for the ranking (oracle: backend call count in tests).
- MBT for snapshot-rotation invalidation: model the shard-set rotation, prove no pre-rotation entry is ever served post-rotation (testing doctrine — the test names its oracle).
- Golden-311 parity unchanged with caches cold and warm; eval runs use
--no-cache.
--no-cache bypasses result-cache reads and refreshes writes.
Activitydeveloping-today commented on Nov 14, 2026 dezren39 commented on Nov 14, 2026 agent-note:v1
state: picked_up
task: 16728
lane: any-b
issue: #9943
Claimed task 16728 by lane any-b (direct assignment). Revalidated fresh: issue #9943 is OPEN with no held / user/owned / do-not-merge / do-not-auto-edit labels. Gate verified landed: slice 2 issue #9942 is CLOSED and its PR #10090 is MERGED (merge commit 5ed55ee), so the shared cache-key constructor + flags are on main and no dep-block applies. Proceeding to implement the snapshot-bound result cache in pkgs/atlas-search. dezren39 commented on Nov 14, 2026
Picked up by repo-worker-code-b — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while repo-worker-code-b posts progress markers; after 30 minutes of silence any other worker may pick this up.) dezren39 commented on Nov 14, 2026
Progress from repo-worker-code-b: claimed: gate revalidated - slice 2 (#9942) is CLOSED/merged; scoping the snapshot-bound result cache in the atlas service dezren39 commented on Nov 14, 2026 agent-note:v1 — gate clear, archaeology complete, implementation map recorded (lane code-b, FALLBACK MODE backend down, 2026-11-14)
Claimed and mapped. Gate revalidation: slice 2 (#9942) is CLOSED/merged (lane code-a revalidation, 2026-11-14T16:10Z), so this slice is unblocked. Nothing built: the remaining work is a full design-and-build slice in the search server's concurrency core, and this claim's deliverable is the verified current-state map below so the build starts from facts, not rediscovery.
What already exists (verified in the laptop checkout at a521d86):
- The shared key constructor is live:
SearchParameters::result_cache_key(query, snapshot_id, ceiling, expand, group, with_message) in atlas-proto (sha256 over atlas-result-cache/v1|query=…|snapshot=…|ceiling=…|<canonical flag material>), with flag-sensitivity tests. The canonical material includes no_cache/wait/hydrate/raw and the planner parameters — but NOT k, pool, mode, filters, or model (see the key-shape question below).
- The server (
crates/atlas-search/src/server.rs, JobManager) already has a dedupe/coalescing cache: CacheKey (the verbatim effective request, parameters via the same canonical constructor) → shared Computations; an identical submit queued/running/done-within-TTL coalesces with NO second branch execution — the acceptance's "no Turso round-trip for the ranking" behavior already exists inside the job TTL (RuntimeLimits.job_ttl, default 600s).
--no-cache IS honored at submit: the read is skipped and a fresh computation runs. One inaccuracy to fix in the build: the fresh computation lands in the cache under the no_cache-flavored key (the canonical material carries no_cache=true), so it does NOT refresh the normal key's entry, despite the submit comment claiming it does. Slice 3's "bypasses reads and refreshes writes" needs the write keyed by the no_cache=false form.
- Slice 1's embedding cache (atlas-search: query-embedding cache — sha256 key, memory LRU + shared Turso tier, async writes (#5668 slice 1) #9941 family) is independent, as the issue says.
What is missing (the actual slice):
- Snapshot binding exists nowhere in the server.
ShardSet::snapshot_id() exists in atlas-core, and ShardedBackend is only constructed in the CLI path (main.rs); the server's CoreSearchEngine<B,E> is generic over SearchBackend and neither SearchEngine nor SearchBackend exposes a current snapshot id. Within the job TTL today, a shard rotation can still serve a pre-rotation ranking from the dedupe cache — the correctness hole this slice closes. Seam for the build: a defaulted snapshot_id() on the engine/backend trait (None for non-sharded), bound into the key at submit.
- No 24h result store. The only retention is the dedupe cache at job_ttl. The spec's result cache (24h as GC bound only, correctness from the snapshot id) is a separate store keyed by
result_cache_key; on a hit it must materialize an already-done computation/handle without branch execution (test oracle: backend call count), and rotation makes old entries unreachable (key change), GC'd by the 24h bound.
- Key-shape question the build must settle first:
result_cache_key does not cover k/pool/mode/filters/model, but the stored computation result is a k-shaped, filtered ranking envelope. Either the result store keys on the dedupe CacheKey PLUS snapshot id (and result_cache_key remains the cross-cache flag-material constructor), or the stored value must be the unshaped ranking pool from which per-k envelopes are re-derived. Serving one request's envelope for a different k/filters from the proto key as-is would be a correctness bug; the design (PR docs: Scaler-era Atlas/Turso data architecture revision #5667 §3) should be amended or interpreted explicitly in the build PR.
- MBT for rotation per the acceptance: model the shard-set rotation against the cache and prove no pre-rotation entry is served post-rotation; the dedupe-cache tests around
JobManager::submit with the stub backend are the natural harness (a snapshot-id provider that flips mid-test is the rotation model).
Released free with the gate clear and this map; the build is a single focused session in crates/atlas-search/src/server.rs + the trait seam in atlas-core, with items 1–4 in that order. dezren39 commented on Nov 14, 2026
Released by repo-worker-code-b (outcome: free). Gate clear (slice 2 #9942 merged) but not built: full archaeology + implementation map posted on #9943 - dedupe cache and result_cache_key already exist, --no-cache read-bypass exists (write-refresh keyed wrong), snapshot binding and the 24h result store are the real work, plus a key-shape question (k/filters not in the proto key) the build must settle first. dezren39 commented on Nov 14, 2026 agent-note:v1
state: done
task: 16728
lane: any-b
issue: #9943
pr: #10123
Done — fixed_merged. PR #10123 merged (merge commit 068350d); issue #9943 closed by the merge.
Implemented the snapshot-bound result cache (#5668 slice 3): the service cache key now carries the corpus snapshot plus the shared sha256 result_cache_key from slice 2; ShardedBackend reports its ShardSet snapshot_id (monolith = one stable partition); a submit observing a new snapshot drops all result-cache entries at once; entries live 24h as a GC bound only, in service memory only; repeats on an unchanged snapshot serve past the job TTL with no branch execution; --no-cache bypasses reads and refreshes its variant entry. Mirrored to fleet-search (parity guard OK).
Tests: atlas-core + atlas-search all suites pass (143, incl. call-count oracle, GC bound, no-cache, rotation MBT, golden-311 parity); fleet-search --all-features 53 pass. Codex review was unavailable on the PR (usage limits, no findings produced) — recorded on PR #10123.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|