Skip to content

refactor(hotpath): swap cache route back onto WorkersCachekitIO (LAB-1492) - #12

Merged
27Bslash6 merged 5 commits into
mainfrom
lab-1492-workerscachekitio-swap-back
Aug 7, 2026
Merged

refactor(hotpath): swap cache route back onto WorkersCachekitIO (LAB-1492)#12
27Bslash6 merged 5 commits into
mainfrom
lab-1492-workerscachekitio-swap-back

Conversation

@27Bslash6

@27Bslash6 27Bslash6 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Closes LAB-1492. Consumer half of LAB-1079: cachekit-rs 0.7.0 (crates.io) fixes the wasm32 SystemTime::now() panic in session_headers(), so the interim direct worker::Fetch GET is deleted and GET /v1/cache/:operation/:window routes through WorkersCachekitIO.

Changes

  • hotpath/Cargo.toml: cachekit-rs 0.5.0 → 0.7.0 (both native and wasm32 target deps; the staged workers/cachekitio feature block is now the live path). cachekit-core 0.3 → 0.4 to match cachekit-rs 0.7.0's pin (one copy in the wasm binary). urlencoding direct dep removed — it existed only for the workaround fetch.
  • hotpath/src/lib.rs: workaround block deleted (including the stale "≤ 0.8.0" comment — real affected range was 0.2.0–0.6.0). Cache route builds WorkersCachekitIO with .api_url(env) + .allow_custom_host(true) (dev instance is outside the SDK SSRF allowlist; HTTPS + private-IP checks still apply). Backend errors echo the BackendError kind only — the SDK message can embed backend response body content, preserving the old code's "never echo the body" property. The SDK emits X-CacheKit-L1-Status: disabled itself (metrics_headers with no provider), so nothing the workaround sent by hand is lost.
  • Docs: hotpath/README.md, hotpath/wrangler.toml, docs/architecture.md (version table, credentials section, build-chain pins — also fixed the stale encryption,macros features line). worker stays pinned at 0.4 in 0.7.0, so build-chain pins are unchanged.

Verification

  • Native: cargo test --locked 13 passed; cargo clippy --all-targets --locked -- -D warnings clean.
  • wasm32: cargo clippy --target wasm32-unknown-unknown --locked clean; worker-build --release succeeds.
  • Live (deployed version f4ca84da-5016-46a7-9025-7addc07979ee, sdk reports cachekit-rs 0.7.0): GET https://skyline-hotpath.raywalker.workers.dev/v1/cache/posts_per_minute/5m → HTTP 200 with fresh backend data, no CF error 1101.

Supply-chain audit (Kody Rule 81)

cargo audit (RustSec advisory-db, 1190 advisories, 2026-08-07) against the committed hotpath/Cargo.lock (200 locked deps, including cachekit-rs 0.7.0 and cachekit-core 0.4.0): 0 vulnerabilities, 0 warnings. Both bumped crates are first-party (cachekit-io org), published via the repo's release-please train; the lockfile is committed and fully pinned.

…1492)

cachekit-rs 0.7.0 fixes the wasm32 SystemTime::now() panic (LAB-1079),
so the direct worker::Fetch workaround is deleted and the cache route
calls WorkersCachekitIO::get. The SDK sends X-CacheKit-L1-Status:
disabled itself (metrics_headers with no provider), so no header
behaviour is lost. cachekit-core aligns to 0.4 to keep a single copy
in the wasm binary; urlencoding drops as a direct dep (workaround-only).
Backend errors echo the BackendError kind only — the SDK message can
embed backend response bodies, which are not ours to relay.
@kodus-27b

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2906ba6c-d2a6-44a3-bb25-1eb8ef3a83e1

📥 Commits

Reviewing files that changed from the base of the PR and between 3f6c922 and a5c8af0.

📒 Files selected for processing (1)
  • docs/architecture.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/architecture.md

📝 Walkthrough

Summary by CodeRabbit

  • Improvements
    • Updated the Rust SDK integration to version 0.7.0 for improved compatibility and reliability.
    • Cache requests now use the standard Workers integration with configurable API endpoints.
    • Custom cache hosts can be enabled with validation for safer configuration.
  • Bug Fixes
    • Resolved the WebAssembly time-handling issue that required a temporary request workaround.
    • Improved error handling for configuration and cache request failures.
  • Documentation
    • Updated setup, build, and configuration guidance to reflect the latest integration approach.

Walkthrough

The hotpath upgrades cachekit-rs to 0.7.0 and cachekit-core to 0.4. It replaces direct worker::Fetch calls with WorkersCachekitIO, enables custom hosts, updates HTTP error handling, and refreshes related documentation.

Changes

WorkersCachekitIO integration

Layer / File(s) Summary
SDK and wasm dependency upgrade
hotpath/Cargo.toml, docs/architecture.md, hotpath/src/lib.rs, hotpath/README.md
The hotpath upgrades cachekit-rs and cachekit-core, removes urlencoding, and retains the workers and cachekitio features. Documentation records Rust support from 0.5.0 onwards, the wasm32 SystemTime fix, and the 0.7.0 build and publication version.
WorkersCachekitIO request path
hotpath/src/lib.rs, hotpath/wrangler.toml, hotpath/README.md, docs/architecture.md
cache_handler uses WorkersCachekitIO with the configured API URL and .allow_custom_host(true). Configuration failures return HTTP 500. SDK failures return HTTP 502 with only the error class. Documentation removes the raw-fetch workaround.

Sequence Diagram(s)

sequenceDiagram
  participant cache_handler
  participant WorkersCachekitIO
  participant Cachekit backend
  cache_handler->>WorkersCachekitIO: Build with API key and API URL
  WorkersCachekitIO->>Cachekit backend: Send cache request
  Cachekit backend-->>WorkersCachekitIO: Return cache response or SDK error
  WorkersCachekitIO-->>cache_handler: Return cache result or error class
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses conventional commit syntax and clearly describes the main change, although it exceeds the preferred 50-character length.
Description check ✅ Passed The description directly explains the SDK upgrade, workaround removal, route change, configuration, and verification steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture.md`:
- Line 12: Update the current-version references for the edge hot path in the
architecture documentation: change item 3’s build guidance from cachekit-rs
0.5.0 to 0.7.0, and mark the live verification at lines 63-65 as historical or
update it to verify 0.7.0.

In `@hotpath/README.md`:
- Line 16: Update the cache-read documentation in the table to include all
failure statuses from the handler: 500 when WorkersCachekitIO::build() fails,
502 when backend.get() fails, and 503 when CACHEKIT_API_KEY is missing. Replace
the claim that 503 is the only failure status while preserving the existing
successful-flow description.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d5c75cc5-aaa3-4d27-8bd4-bd1fe68e34e3

📥 Commits

Reviewing files that changed from the base of the PR and between 28e586d and 9a6aa27.

⛔ Files ignored due to path filters (1)
  • hotpath/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • docs/architecture.md
  • hotpath/Cargo.toml
  • hotpath/README.md
  • hotpath/src/lib.rs
  • hotpath/wrangler.toml

Comment thread docs/architecture.md
Comment thread hotpath/README.md Outdated
Comment thread hotpath/Cargo.toml
Comment thread hotpath/src/lib.rs Outdated
…ons (panel findings)

Expert-panel MAJ items: a 502 previously carried zero server-side
diagnostic (kind only, message dropped entirely) — full BackendError
now goes to Worker logs via console_error! while the client response
keeps the kind-only discipline. docs/architecture.md open item 3
claimed hotpath builds against 0.5.0 and that crates.io carries 0.8.0
(a version that never existed; real latest is 0.7.0).
@kodus-27b

This comment has been minimized.

kodus-27b[bot]
kodus-27b Bot previously approved these changes Aug 7, 2026

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
hotpath/src/lib.rs (1)

163-170: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Return a sanitised builder error.

CachekitError exposes configuration reasons but has no public error kind. Log {e} with console_error!, then return a fixed generic 500 message. The error does not include the configured endpoint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hotpath/src/lib.rs` around lines 163 - 170, Update the WorkersCachekitIO
builder error branch in the backend initialization flow to log the detailed
error with console_error!, then return a fixed generic 500 response message
instead of exposing {e} through json_error. Keep the successful backend path
unchanged and ensure the returned message does not include the configured
endpoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@hotpath/src/lib.rs`:
- Around line 163-170: Update the WorkersCachekitIO builder error branch in the
backend initialization flow to log the detailed error with console_error!, then
return a fixed generic 500 response message instead of exposing {e} through
json_error. Keep the successful backend path unchanged and ensure the returned
message does not include the configured endpoint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 73d107f9-4676-4729-982e-1093a400aad7

📥 Commits

Reviewing files that changed from the base of the PR and between 9a6aa27 and 1447463.

📒 Files selected for processing (2)
  • docs/architecture.md
  • hotpath/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/architecture.md

Log the full builder error to Worker logs; the 500 response is now a
fixed string. Today's CachekitError::Config messages are static
literals, but the SDK's wording (which could name the endpoint) is
not part of our client contract — same log-full/return-sanitized
pattern as the 502 arm.
@kodus-27b

This comment has been minimized.

kodus-27b[bot]
kodus-27b Bot previously approved these changes Aug 7, 2026
@kodus-27b

kodus-27b Bot commented Aug 7, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

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.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

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

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 Aug 7, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@27Bslash6

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@27Bslash6

Copy link
Copy Markdown
Contributor Author

Resolved merge conflict in docs/architecture.md (union of both sides: the PR's updated LAB-1079 paragraph + main's dcb6da0 feature-line provenance); auto-rebased onto main; CI will re-run.

@27Bslash6

Copy link
Copy Markdown
Contributor Author

@27Bslash6 — ready for your signoff / merge.

Automated review is clean on head a5c8af0: hotpath-qa native + wasm32 both green, CodeRabbit APPROVED after two remediation rounds, mergeStateStatus: CLEAN. The expert panel ran on the feature diff last session (findings applied, one rebutted); post-panel commits were the CodeRabbit sanitisation fix plus docs.

Crypto/protocol gate re-verified independently, since the diff bumps the crates implementing interop key derivation and the wire checksum:

  1. Key derivation unchanged 0.5.0→0.7.0 — the byte-locked 3-way key vectors still pass in the native lane.
  2. cachekit-core 0.3.0→0.4.0 src/checksum.rs is byte-identical in the published crates (diffed) — so the wire checksum is stable.
  3. 0.4.0's StorageEnvelope.compressed_data → msgpack bin change is inert here: hotpath only uses checksum/verify_checksum, never the envelope.
  4. WorkersCachekitIO::get() is byte-parity with the deleted worker::Fetch block — same URL encoding and trailing-slash trim, same 200/404/else mapping, X-CacheKit-L1-Status: disabled emitted via metrics_headers(None), raw bytes returned with no envelope decode.

Non-blocking: the three checksum tests in hotpath/src/compute.rs compare cachekit_core::checksum() to itself, so they would not have caught a change to the primitive. One byte-locked literal (as derives_byte_locked_keys already does for keys) would make the next bump self-policing.

Not merging — that is yours.

@27Bslash6
27Bslash6 merged commit 5379e98 into main Aug 7, 2026
4 checks passed
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