Skip to content

atlas(worker): key hosted search cache by disclosure context - #12627

Open
dezren39 wants to merge 2 commits into
mainfrom
queue/21057-atlas-worker-context
Open

dezren39 wants to merge 2 commits into
mainfrom
queue/21057-atlas-worker-context

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

POST /search
  pins context = hosted-per-user
  cache key = query + context + existing config
  forwards context to atlas-search service
  • Bump the Worker cache-key schema and include disclosure context in its canonical hash material.
  • Thread the hosted-per-user context through the Durable Object and search service request.
  • Document the boundary and cover explicit forwarding plus cross-context key separation.

Closes #12622

Evidence

  • Before: no disclosure context in the Worker cache key or forwarded search request.
  • After: npm test — 4 files, 24 tests passed; npm run typecheck passed; git diff --check passed.

Merge Danger

Door: Two-way.

Blast Radius: Worker-only. Cache key schema changes invalidate reuse of existing Durable Object entries; subsequent searches repopulate them.


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

Summary by CodeRabbit

  • New Features
    • Search requests now include an explicit disclosure context, and cached results are separated by that context. Identical searches made under different contexts will not share the same cache entry.
  • Documentation
    • Search documentation now describes the hosted-per-user context and clarifies how the personal tier ceiling is specified in requests.

@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 16:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 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-22T18:38:38.837162Z 60b6bd9 New commits
ℹ️ 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 22, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: edf25d1d-085c-4bd5-bfc1-3b111549bec2
Commits

Reviewing files that changed from the base of the PR and between 8868c24 and 60b6bd9.

Files selected for processing: 1

  • pkgs/atlas-search/worker/test/key.test.ts

No actionable comments were generated in the recent review.

Walkthrough

The Worker now sets hosted-per-user as the disclosure context for search requests and includes context in cache keys. The Durable Object forwards the context to the search service. Tests and README documentation reflect these changes.

Changes: Hosted search disclosure context

Layer / File(s) Summary
Context-aware cache identity
pkgs/atlas-search/worker/src/space.ts, pkgs/atlas-search/worker/src/key.ts, pkgs/atlas-search/worker/test/key.test.ts
The Worker defines the hosted context and adds context to version-2 cache key material. Tests verify that different contexts produce different keys.
Context propagation through search
pkgs/atlas-search/worker/src/index.ts, pkgs/atlas-search/worker/src/cache_do.ts, pkgs/atlas-search/worker/src/service.ts, pkgs/atlas-search/worker/test/worker.test.ts, pkgs/atlas-search/worker/README.md
Search, cache inspection, and purge keys use the hosted context. The Durable Object forwards context to the search service. Tests and documentation describe the forwarded request and cache identity.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Worker
  participant QueryCache
  participant SearchService
  Worker->>QueryCache: Send query, k, and hosted-per-user context
  QueryCache->>SearchService: Pass query, k, and disclosure context
  SearchService->>SearchService: Include context in /v1/search request
Loading

Possibly related issues

  • 6805 — The change adds disclosure context to cache identity, which overlaps with the issue’s cache-key and invalidation scope.
  • 10166 — The change updates cache-key identity in key.ts and the Durable Object path, but does not address the issue’s other requirements.
  • 9092 — The change updates cache identity for the hosted search Worker, one part of the issue’s broader scope.

Suggested reviewers: claude

Merge Risk: Minimal · previous review 8868c

Hosted search requests now state their disclosure context explicitly, and cached results are keyed by it, so different contexts cannot share cached payloads. Existing cache entries are invalidated once and refill on later searches. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "atlas(worker): key hosted search cache by disclosure context" matches the main change. The PR adds a DisclosureContext to the query cache key (key schema version 2), threads it through the …
Linked Issues check Passed Directly linked issue #12622 has two coding requirements. (1) The Worker states context on forwarded search requests: src/index.ts sets context: DISCLOSURE_CONTEXT on the Durable Object request body…
Out of Scope Changes check Passed All changed files relate to the objective: README.md documents the context and cache-key boundary; src/space.ts adds DISCLOSURE_CONTEXT and the DisclosureContext type; src/key.ts adds context to the k…
Full details: Title check

Explanation

The title "atlas(worker): key hosted search cache by disclosure context" matches the main change. The PR adds a DisclosureContext to the query cache key (key schema version 2), threads it through the worker, Durable Object, and searchService, and pins it to "hosted-per-user". The title is specific, concise, and has no file lists or vague terms.

Full details: Linked Issues check

Explanation

Directly linked issue #12622 has two coding requirements. (1) The Worker states context on forwarded search requests: src/index.ts sets context: DISCLOSURE_CONTEXT on the Durable Object request body. The PR summary states that src/service.ts adds context to the /v1/search body; that file was not read directly. (2) The result-cache key includes the context alongside the ceiling: src/key.ts (confirmed by diff) adds context to keyMaterial after q, keeps ceiling: CEILING, and bumps KEY_SCHEMA from 1 to 2. src/index.ts computes every cache key with context: DISCLOSURE_CONTEXT. The separation test in test/key.test.ts asserts that identical query and k yield different keys for "hosted-per-user" and "public-surface". The existing worker tests are updated to the new key material and reported green (4 files, 24 tests). The issue's 'pinned' context means no caller can currently state a different context, so separation is proven at the key level, which matches the acceptance criterion's conditional wording. Parent context (#9092, #12404) is not required beyond this scope.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the objective: README.md documents the context and cache-key boundary; src/space.ts adds DISCLOSURE_CONTEXT and the DisclosureContext type; src/key.ts adds context to the key material (confirmed by diff); src/index.ts passes the context to key generation and the Durable Object; src/cache_do.ts and src/service.ts thread the context through to the search service (per PR summary; not read directly); test/key.test.ts and test/worker.test.ts cover key separation and forwarding. The KEY_SCHEMA bump is a necessary consequence of the key material change and is disclosed in the PR as a Worker-only cache invalidation. No unrelated changes were identified.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fcf72c4-4bc4-4506-9e94-dd232a24ce0b
Commits

Reviewing files that changed from the base of the PR and between f026268 and 8868c24.

Files selected for processing: 8

  • pkgs/atlas-search/worker/README.md
  • pkgs/atlas-search/worker/src/cache_do.ts
  • pkgs/atlas-search/worker/src/index.ts
  • pkgs/atlas-search/worker/src/key.ts
  • pkgs/atlas-search/worker/src/service.ts
  • pkgs/atlas-search/worker/src/space.ts
  • pkgs/atlas-search/worker/test/key.test.ts
  • pkgs/atlas-search/worker/test/worker.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@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: 8868c2410e

ℹ️ 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".

Add a seeded generated test asserting that, for 64 generated (query, k)
pairs, all four disclosure contexts produce distinct cache keys, so a
cached entry can never be served across a disclosure boundary. The
generator varies words, case, whitespace (including tabs/newlines and
padding) and depth over the valid 1..50 range; the key digest itself is
the oracle. Deterministic mulberry32 seed, no new dependency; the fixed
two-context example is kept as smoke coverage.

Verified locally by executing the test file under Node (vitest unavailable
in this seat: npm install fails); CI runs the real vitest suite.
@dezren39

Copy link
Copy Markdown
Member Author

Codex review round answered (2026-11-22 ~12:40 CST): the one open thread — property-based coverage for disclosure-context key isolation — is fixed in 60b6bd9 and the thread is resolved. The new seeded generated test covers 64 (query, depth) pairs across all four disclosure contexts with the key digest as the oracle; the fixed two-context example stays as smoke coverage. Verified by executing the test file under Node in this seat (npm/vitest install fails here, so CI is the first real vitest run). Remaining merge blockers: none from review threads (0 unresolved); checks pending on the new head.

This branch has not been deployed

No deployments
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.

atlas(worker): state the disclosure context on hosted search requests and key the result cache by it

1 participant