Skip to content

impl(atlas): D1 hot-cache schema, binding, and store module (#13100) - #13141

Merged
dezren39 merged 1 commit into
mainfrom
lane-ol-13100
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-ol-13100

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Implements #13100 — follow-on 1 of 6 under the #9134 Atlas D1 tenant hot cache design (§5 storage, §8 item 1).

What lands

  • migrations/0001_hot_cache.sql — the design §5 hot_cache schema verbatim (shared database, tenant in the key, eviction index on (tenant_id, last_hit_at)).
  • HOT_CACHE D1 binding in wrangler.toml and mirrored in cloudflare.config.ts, plus the HOT_CACHE_ENABLED flag (default "false") in both. The committed database_id is the repo's local-placeholder convention (same as pkgs/id/worker-poc/d1-journal-poc): the real atlas-hot-cache database is created at deploy time and its id replaces the placeholder in both files; the README records this.
  • src/hot_cache.ts — the store module: get / put / touch / evict primitives over the table, plus hotCacheEnabled / hotCacheStore gating (flag off or binding absent → no store, callers keep the pre-cache path).
  • src/index.ts — Env gains the optional binding/flag fields only; no read path changes.

Acceptance check

  • Schema migration lands: yes, as migrations/0001_hot_cache.sql with migrations_dir wired in wrangler.toml.
  • Store round-trips all three classes (A/B/C) against a local D1: test/hot_cache.test.ts applies the real migration file to the miniflare D1 and round-trips byte-for-byte per class, plus tenant isolation, put-replace bookkeeping reset, touch/hit counting, evict semantics, and flag gating — 10/10.
  • Flag off = zero behavior change: full package suite 41/41 (31 pre-existing + 10 new), tsc --noEmit clean; nothing outside the new module references the store.

Closes #13100.


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

Follow-on 1 of 6 under #9134 (design §5, §8 item 1): the hot_cache
schema as migration 0001, the HOT_CACHE D1 binding in wrangler.toml
and cloudflare.config.ts (placeholder id; the real database is
created at deploy time), and src/hot_cache.ts with get/put/touch/
evict primitives over the shared table. The tier sits behind
HOT_CACHE_ENABLED, default off, so existing read paths are
untouched. Env gains the optional binding/flag fields only.

Tests: test/hot_cache.test.ts applies the real migration to a
local (miniflare) D1 and round-trips entries for all three classes
(A/B/C); full package suite 41/41, typecheck clean.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-23T09:06:34.498508Z cfe0eab 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.

@dezren39
dezren39 merged commit 9db2efc into main Nov 23, 2026
1 check passed
@coderabbitai

coderabbitai Bot commented Nov 23, 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

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.

impl(atlas): D1 hot-cache schema, binding, and store module for the atlas-search Worker

1 participant