Route KV access through RuntimeServices (PR 5)#616
Merged
Conversation
aram356
approved these changes
Apr 6, 2026
Collaborator
aram356
left a comment
There was a problem hiding this comment.
Summary
Well-structured PR that cleanly routes remaining KV usage through RuntimeServices for EdgeZero portability. The key design decisions are sound.
Non-blocking
⛏ nitpick
- Stale
#[allow(dead_code)]onopen_kv_store(platform.rs):open_kv_storenow has a live call site inmain.rs(runtime_services_for_consent_route), so#[allow(dead_code)]is no longer needed and would mask future regressions. match ... Err(e) => Err(e)pattern (main.rs:156): Could use?to propagate, though the current form is arguably more readable with the async Ok branch.
♻️ refactor
- Duplicate
make_test_context()helper (storage/kv_store.rs): Defined identically in bothmod testsandmod new_api_tests. Could be extracted to a shared#[cfg(test)]helper within the file.
🤔 thinking
open_kv_storecalled per-request: Not a regression (old code did the same), but the store could be opened once at startup sincesettings.consent.consent_storeis static for the process lifetime. The lazy injection pattern is nice for fault isolation though — just worth considering.
🌱 seedling
consent_storeconfig checked in two places: Bothhandle_auction(auction/endpoints.rs) andhandle_publisher_request(publisher.rs) re-checksettings.consent.consent_store, but the adapter already performs this check inruntime_services_for_consent_route. Future PR could simplify by signaling "consent KV available" at theRuntimeServiceslevel.
📝 note
- Fingerprint moved from KV metadata to body: Old code stored fingerprint in Fastly KV metadata (platform-specific). New code embeds
fpin JSON body with#[serde(default)]for backward compat — entries withoutfptrigger self-healing re-write. Clean migration path.
👍 praise
- Lazy consent store injection: Starting with
UnavailableKvStoreand lazily replacing only for consent-dependent routes — misconfigured store only breaks/auctionand publisher while health, discovery, and admin remain functional. - Thorough route test coverage:
configured_missing_consent_store_only_breaks_consent_routesvalidates four distinct route categories and directly proves the fault isolation claim.
CI Status
All checks pass.
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.
Summary
RuntimeServices::kv_storepath so PR5 matches the EdgeZero portability design instead of a Fastly-specific side channel.storage/kv_store.rs, add adapter regression coverage, and align the migration spec with the current repo scope.Changes
crates/trusted-server-adapter-fastly/src/main.rskv_storeslot and lazily swap in the configured consent store only on consent-dependent routes.crates/trusted-server-adapter-fastly/src/route_tests.rscrates/trusted-server-core/src/auction/README.mdRuntimeServices-backed handler signatures.crates/trusted-server-core/src/auction/endpoints.rscrates/trusted-server-core/src/consent/mod.rsconsent::kvand update consent pipeline docs.crates/trusted-server-core/src/platform/mod.rswith_kv_storereplacement semantics onRuntimeServices.crates/trusted-server-core/src/platform/types.rsRuntimeServices::kv_store()andRuntimeServices::with_kv_store(...)for portable KV injection.crates/trusted-server-core/src/publisher.rscrates/trusted-server-core/src/consent/kv.rs->crates/trusted-server-core/src/storage/kv_store.rsstorage, preserving the publicconsent::kvAPI via re-export.crates/trusted-server-core/src/storage/mod.rskv_storemodule.docs/superpowers/specs/2026-03-19-edgezero-migration-design.mdCloses
Closes #486
Test plan
cargo test --workspacecargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcd crates/js/lib && npx vitest runcd crates/js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute servecargo doc --no-deps --all-features(passes with existing rustdoc warnings unrelated to this PR)JS tests are currently failing in the workspace with a pre-existing Vitest worker startup error rooted in
ERR_REQUIRE_ESMbetweenhtml-encoding-snifferand@exodus/bytes/encoding-lite.js. This PR does not touch JS code.Checklist
unwrap()in production code — useexpect("should ...")logmacros (notprintln!)