Skip to content

test(cachekit): pin the write-behind receipt-delay excess behind a suspended wrapper (LAB-12540) - #311

Merged
27Bslash6 merged 4 commits into
mainfrom
lab-12540-write-behind-receipt-delay
Nov 3, 2026
Merged

27Bslash6 merged 4 commits into
mainfrom
lab-12540-write-behind-receipt-delay

Conversation

@27Bslash6

@27Bslash6 27Bslash6 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What

This PR adds tests that pin how a writeBehind L1 copy behaves while a custom backend wrapper is still suspended after the inner set resolved. It also aligns the README and the SetResult doc with the protocol's new wording, the receipt-delay excess under API-103 (cachekit-io/protocol#231).

The new tests are in src/backends/cachekitio-freshness.test.ts, under behind a wrapper still suspended after the PUT 2xx:

  • Fresh-For: 1, wrapper suspended past 1 s after receipt. A get() is still served from L1. Once the wrapper resolves, the copy is capped at receipt + 1 s.
  • Fresh-For: 0, ttl: 2, wrapper still suspended. The copy is served at fill + 1.999 s and expires at fill + 2 s. That expiry is the excess's ceiling. The existing write-behind Fresh-For: 0 test covers the drop once the wrapper resolves.

There is no runtime change. CacheImpl already caps the copy when set resolves, which is what the protocol requires.

Why

A write-behind copy is in L1 before the PUT is sent. CacheImpl learns SetResult.receivedAt only when the backend's set resolves, so a wrapper that keeps working after the inner set delays the cap. The earlier tests advanced the clock inside the wrapper, so they never read while it was suspended. These tests do.

Checks

  • pnpm run lint, pnpm run type-check:tests and Prettier on the changed files all pass.
  • The full vitest run passes after pnpm build.

…nd a suspended wrapper

A write-behind copy is in L1 before its PUT is sent and is capped only when
the backend's set resolves, so a wrapper still suspended after the 2xx keeps
it serving past receipt plus Fresh-For, never past its TTL from the L1 fill.
The protocol now names this the receipt-delay excess; the README and the
SetResult doc say so.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

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 28 minutes.

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
Commits

Reviewing files that changed from the base of the PR and between 595fd56 and d838a99.

Files selected for processing: 3
  • packages/cachekit/README.md
  • packages/cachekit/src/backends/cachekitio-freshness.test.ts
  • packages/cachekit/src/backends/types.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@kodus-27b

kodus-27b Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

kodus-27b[bot]
kodus-27b Bot previously approved these changes Nov 2, 2026
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…cite API-103

Review follow-up: the ceiling test now shows a hit just before fill plus ttl
and a miss at it, with Fresh-For 0, so it fails if L1 was never filled. The
protocol states the receipt-delay excess under API-103, not a new id.
@kodus-27b

kodus-27b Bot commented Nov 2, 2026

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

kodus-27b[bot]
kodus-27b Bot previously approved these changes Nov 2, 2026
Review follow-up: the Fresh-For 0 test pins the TTL-from-fill ceiling, since
the header never reaches CacheImpl while the wrapper is suspended; drop an
assertion that restated the clock advance; cite API-103 once in SetResult.
@kodus-27b

kodus-27b Bot commented Nov 2, 2026

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

kodus-27b[bot]
kodus-27b Bot previously approved these changes Nov 2, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Instruction counts: PASS

Head d838a99 against base 595fd564e4a912d8dfaa8b0fc6dd12a65362dc31, Node v24.22.1, valgrind-3.22.0. Instructions per op on the main thread (bench:ir --compare); median of the repeats, A/A = (max − min) / median. A workload fails above +2.00% and warns above +1.00% (its own threshold: napi-encrypted at +4.00%, plaintext-set-1mb at +10.00%, warning at half); an A/A over 0.40% reads INCONCLUSIVE.

All 36 workloads: 36 ok
workload base Ir/op head Ir/op delta A/A base / head verdict
l1-get-hit 1,203 1,203 0.00% 0.00% / 0.00% ok
l1-set-at-capacity-1k 6,371 6,371 0.00% 0.00% / 0.00% ok
l1-set-at-capacity-10k 4,157 4,158 +0.02% 0.00% / 0.00% ok
l1-set-at-capacity-100k 12,742 12,742 0.00% 0.00% / 0.00% ok
plaintext-set-1kb 220,787 220,773 -0.01% 0.00% / 0.00% ok
plaintext-set-10kb 1,850,669 1,850,666 -0.00% 0.00% / 0.00% ok
plaintext-set-100kb 18,091,070 18,091,024 -0.00% 0.00% / 0.00% ok
plaintext-set-64b 42,365 42,365 0.00% 0.00% / 0.00% ok
plaintext-set-1mb 176,402,026 176,376,033 -0.01% 0.00% / 0.00% ok
plaintext-set-containers 1,401,920 1,401,845 -0.01% 0.00% / 0.00% ok
keygen 12,424 12,424 0.00% 0.00% / 0.00% ok
keygen-1kb 276,376 276,372 -0.00% 0.00% / 0.00% ok
keygen-wasm 15,932 15,932 0.00% 0.00% / 0.00% ok
keygen-wasm-1kb 315,786 315,786 0.00% 0.00% / 0.00% ok
serializer-roundtrip 406,542 406,542 0.00% 0.00% / 0.00% ok
napi-envelope 46,149 46,149 0.00% 0.00% / 0.00% ok
napi-envelope-40b 15,551 15,551 0.00% 0.00% / 0.00% ok
napi-envelope-64kb 500,771 500,771 0.00% 0.00% / 0.00% ok
wasm-envelope 59,179 59,179 0.00% 0.00% / 0.00% ok
wasm-envelope-40b 13,939 13,939 0.00% 0.00% / 0.00% ok
wasm-envelope-64kb 907,956 907,939 -0.00% 0.00% / 0.00% ok
napi-encrypted 41,578 41,578 0.00% 0.00% / 0.00% ok
napi-encrypted-64kb 850,983 850,983 0.00% 0.00% / 0.00% ok
wasm-encrypted 320,958 320,958 0.00% 0.00% / 0.00% ok
wasm-encrypted-64kb 32,108,392 32,108,393 +0.00% 0.00% / 0.00% ok
secure-set-get 519,189 519,145 -0.01% 0.00% / 0.00% ok
get-l1-hit 2,112 2,112 0.00% 0.00% / 0.00% ok
wrap-l1-hit 17,157 17,157 0.00% 0.00% / 0.00% ok
wrap-l1-hit-metrics 17,115 17,115 0.00% 0.00% / 0.00% ok
get-l2-hit-metrics 263,452 263,426 -0.01% 0.01% / 0.01% ok
secure-wrap-l1-hit-100b 60,114 60,113 -0.00% 0.00% / 0.00% ok
secure-wrap-l1-hit-10kb 1,523,065 1,523,056 -0.00% 0.00% / 0.00% ok
secure-wrap-l1-hit-1mb 239,417,093 239,414,355 -0.00% 0.00% / 0.00% ok
wrap-l1-hit-cachekitio 17,194 17,194 0.00% 0.00% / 0.00% ok
wrap-l1-hit-int-cachekitio 2,362 2,362 0.00% 0.01% / 0.00% ok
wrap-l1-hit-int 2,351 2,351 0.00% 0.00% / 0.00% ok

Run log

@27Bslash6

Copy link
Copy Markdown
Contributor Author

@kody start-review

@kodus-27b

kodus-27b Bot commented Nov 3, 2026

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

@27Bslash6
27Bslash6 merged commit c69b4a0 into main Nov 3, 2026
24 checks passed
@27Bslash6
27Bslash6 deleted the lab-12540-write-behind-receipt-delay branch November 3, 2026 03:17
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