Repository navigation
Conversation
…TL rules (#13101) Follow-on 2 of 6 under #9134 (design merged via PR #13098), §1 + §8 item 2: the pure freshness evaluator for the D1 tenant hot cache. - Class A: the content hash is the version — fresh on hash match at any age, watermark state irrelevant; a mismatch is never served. - Class B: fresh iff the entry's source_watermark still equals the tenant's current watermark AND age <= TTL_B (60 s) — whichever fails first; a watermark advance is stale even inside the TTL. - Class C: fresh iff age <= TTL_C (15 min) AND no invalidation event for the tenant post-dates the entry. - Fail-safe degradation: watermark source unreachable -> Class B TTL-only with TTL_B halved (divisor config, floored, clamped so it can never extend), Class C not served, Class A unaffected. Clock skew (future filled_at) is never fresh for the TTL classes. - The tenant watermark read is a thin seam (WatermarkSource) that maps every source failure to 'unavailable'; the evaluator itself is pure — no I/O, no clock reads. - Bounds are named config (TTL_B, TTL_C, degraded divisor) with the design's defaults; invalid overrides fall back to the defaults and can never widen a bound. Oracle (per the issue): property tests over generated (watermark, age, class, event) sequences assert exact agreement with an independent transcription of the §1 table; the stale-serves counter is asserted zero (200 sequences, >1000 evaluations, plus 22 unit tests for the named rules). README Shape gains the module. Verification (sandbox): the worker package's node_modules are not installed in the sandbox, so the committed vitest file was run byte-for-byte under bun test with a vitest->bun:test shim: 23/23 pass, 1398 expect() calls; the package's runtime-independent suites (key, body, space) also pass 15/15 under the same shim; mcp/worker suites need the Cloudflare pool and are untouched. Strict tsc (5.9.3, package-equivalent flags) passes on both new files. CI runs the real vitest pool suite.
|
Warning Review limit reachedYou'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 4 minutes. View limit details
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. |
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-on 2 of 6 under #9134 (Atlas D1 tenant hot cache design, merged via PR #13098), implementing §1 + §8 item 2 in
pkgs/atlas-search/worker. Based on main — no code dependence on follow-on 1 (#13100, the D1 store).What landed
src/freshness.ts— the pure freshness evaluator. No I/O, no clock reads: the caller suppliesnowand the watermark read result.source_watermarkstill equals the tenant's current watermark and age ≤ TTL_B (default 60 s) — whichever fails first, so a watermark advance is stale even inside the TTL.filled_at(clock skew) is never fresh for the TTL classes.WatermarkSourceseam +readTenantWatermark, mapping every source failure (throw, null) tounavailable— unknown can only narrow the bound, never widen it.evaluateWithWatermarkReadcomposes read + pure evaluation for the read path.ttlBSeconds,ttlCSeconds,degradedDivisor) with the design's defaults; invalid overrides fall back to the defaults.test/freshness.test.ts— 23 tests. The named oracle: property tests over generated (watermark, age, class, event) sequences (seeded, reproducible; 200 sequences × up to 12 events across 3 configs) asserting exact agreement with an independent transcription of the §1 table — the stale-serves counter is asserted zero, and so is the over-refusal counter. Plus unit tests for each named rule, config resolution, and the watermark read.README.md— Shape section gains the module, noting it is not wired into a read path yet (store is impl(atlas): D1 hot-cache schema, binding, and store module for the atlas-search Worker #13100, integration is follow-on 4).Test evidence
The worker package's
node_modulesare not installed in the sandbox (and installing was out of bounds for this lane), so the committed vitest file was run byte-for-byte underbun testwith avitest→bun:testshim, in a scratch dir outside the repo:key,body,space): 15 pass / 0 fail under the same shim.mcp/workersuites importcloudflare:testand need the Cloudflare vitest pool — not runnable in the sandbox; their files are untouched (this PR only adds files plus one README bullet).--strict --skipLibCheck, package-equivalent flags): both new files pass.atlas-search-worker-tests) runs the real vitest pool suite and is the first run of the new tests under vitest proper.Closes #13101
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.