Skip to content

Add portable conditional KV records across providers - #510

Open
ChristianPavilonis wants to merge 23 commits into
feature/pluggable-geo-providersfrom
feat/kv-record-contract
Open

ChristianPavilonis wants to merge 23 commits into
feature/pluggable-geo-providersfrom
feat/kv-record-contract

Conversation

@ChristianPavilonis

Copy link
Copy Markdown
Collaborator

Summary

  • Add portable conditional KV records with opaque generations, atomic Add/Overwrite/CAS, UTF-8 metadata, authoritative existence and complete partition-scoped listing. Ordinary and record operations use the same stored values.
  • Implement the capability for Fastly KV, Axum's persistent local store, DynamoDB and the EdgeZero-owned store service on official stock celld. Unsupported stores continue to refuse record operations.
  • Declare immutable layouts before preparation, then acquire the prepared capability. Forward native features through configuration and scaffolding without reopening providers or automatically replaying uncertain mutations.

Changes

Crate / File Change
edgezero-core Record types, capability/layout requirements, registry validation and shared contract tests.
Fastly and Axum adapters Conditional Fastly operations and durable local record transactions, generations, expiry and cursors.
edgezero-store-aws DynamoDB conditions, per-key retained allocation history, scoped partition queries/cursors and native item-size accounting.
services/celld-store Additive record API on the existing stock service rows and namespace object. Check the expected instance before effects and transactionally retain successful and rejected mutation outcomes for internal resend handling.
edgezero-store-celld Stock-service record client and read-only capability preparation. No celld fork, custom listener or extra deployment/bootstrap step.
Native bindings, CLI and templates Default-off record wiring, declaration/feature forwarding, alias validation and bootstrap-token capture for record bindings.
Tests, scripts and docs Provider contracts, actual generated consumers, stock celld fleet/restart/reply-loss proofs, feature-aware portable dependency checks and record guidance.

Closes

Closes #472
Closes #473

Stack placement

Base this PR on #439. #454 belongs above this PR; #464 belongs above #454 but remains outside official stack membership. Preserve existing PR identities and ordinary forward-merge ancestry.

flowchart TD
    A["#439: native Geo"] --> B["This PR: conditional records"]
    B --> C["#454: KV-backed Geo"]
    C --> D["#464: error finalization, outside stack membership"]
Loading

Test plan

Local verification uses Rust 1.98.1 with locked dependencies.

  • cargo test --workspace --all-targets after merging current Add pluggable native Geo providers and protected CloudFront ingress #439. Follow-up lint-only changes also pass the affected adapter and example tests.
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • cargo check --workspace --all-targets --features "fastly cloudflare spin"
  • examples/app-demo native workspace tests and strict all-target/all-feature Clippy.
  • Cloudflare and Spin all-target WASM Clippy for production and test-utils feature combinations, including affected lifecycle/ingress fixtures.
  • Isolated integration harness: 679 passed, four existing ignored; strict harness Clippy passes.
  • Prior provider/runtime proofs retained for unchanged provider/service code: persistent local records, DynamoDB Local, actual Fastly WASM KV cases, generated stock-celld TLS consumers, service restart/no-expiry persistence, independent writers, replay/rejection retention, committed-reply loss and two-node official celld takeover.
  • Complete hosted checks for this PR's exact head and intended base. A draft is intentional while checks and the deferred acceptance item below remain outstanding.

Known validation gap

The Viceroy emulator's record race can report more than one successful CAS writer. The one-winner assertion remains unchanged and the failed result remains disclosed. The emulator checks and replacement use separate locking intervals. Its repair is explicitly deferred; no retries for a favorable schedule, serialization, weakened assertions or runtime patch are included here. Successful individual runs do not establish atomicity. This does not establish a production Fastly defect or qualify the full Fastly concurrency acceptance criterion in #472.

Operational limits

Stock celld retains one serialized namespace object and allocator. Same-instance snapshot rollback/restore is not protected. Local/emulator proofs do not qualify production IAM, capacity, hosted fleets, backups or deployment. Native connector credentials remain outside published application configuration. No release, deployment, infrastructure apply or image publication is part of this PR.

Checklist

  • Follow repository conventions; changes are separated from inherited upstream repairs.
  • No Tokio dependency added to Core or portable adapters; portable checks inspect enabled features rather than version exceptions.
  • Route parameters use brace syntax and application HTTP types use EdgeZero's re-exports.
  • Store wiring uses the registries and prepared capabilities, not a second provider instance.
  • New behavior has contract, provider and runtime coverage with the limitations above stated separately.
  • No real credentials or secrets committed.

Preserve record and current stock-service/Geo ancestry. Add the service record API, prepared Rust client, generated TLS proofs and two-node resend/deadline/takeover checks.

Local checkpoint only. Native SDK, stock celld and strict lint checks pass; final SDK acceptance remains blocked by an observed Viceroy concurrent-CAS defect. Keep exact-one-winner assertions unchanged.
@aram356 aram356 linked an issue Nov 18, 2026 that may be closed by this pull request
1 task
@aram356
aram356 marked this pull request as ready for review November 18, 2026 17:27
@aram356 aram356 linked an issue Nov 18, 2026 that may be closed by this pull request
1 task
aram356 added a commit that referenced this pull request Nov 19, 2026
#517 (10ed380) tops ChristianPavilonis's line on #439:
- #510, the KvStore record contract with DynamoDB and celld providers on
  Axum (#472, #473);
- #454, portable KV-backed geo;
- #514, country and region through ctx.geo() on Cloudflare and Spin (#480,
  #486);
- #517, the portable ClientInfo contract with its Fastly, Axum, Cloudflare and
  Spin mappings (#475, #90, #91, #92, #485).

#517 also merged #469 and #502 itself, so its tree contains everything this
branch had. The only conflicts were JA4 lines that #517 refactors on top of
#469; this merge takes #517's version, and its tree is identical to #517's.
@prk-Jr prk-Jr mentioned this pull request Nov 20, 2026
14 of 15 tasks
Bring in main's Fastly SDK 0.13.3 upgrade (#529) with Viceroy 0.22.0
and the Fastly CLI 17.2.0 upgrade (#531), with PR #275's exact pins at
0.13.3 and url 2.5.9, its Viceroy readiness repair on 0.22.0 and its
typed Image Optimizer unavailability check for SDK 0.13.3.
Bring in PR #275's installation of the wasm32-unknown-unknown target
before the Viceroy 0.22.0 readiness repair builds, which the fastly
wasm tests and Portable record contracts (Fastly) jobs need.
@aram356

aram356 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 894c8bd0 and cba2a91f, two merges of #439's new heads. 894c8bd0 takes EdgeZero main's Fastly SDK 0.13.3 upgrade (#529), with Viceroy 0.22.0 and the Fastly CLI 17.2.0 upgrade (#531), with #275's exact pins at 0.13.3 and url 2.5.9, its Viceroy readiness repair on 0.22.0, its typed Image Optimizer unavailability check and its drain of declared uploads after an early response on Axum. cba2a91f takes #275's d8cd85c8, which installs the wasm32-unknown-unknown target before the Viceroy 0.22.0 readiness repair builds, as the fastly wasm tests and Portable record contracts (Fastly) jobs need. Both merges had no conflicts.

Bring in PR #275's atomic conditional KV insert in the Viceroy readiness
repair, and the production hosting tests' held port reservations and
spawn-token respawn from PR #406 up, with each later PR's tests reading
the live host's address.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 97317c28, a merge of #439's new head that brings #275's 41cdf035, which makes conditional KV inserts atomic in the Viceroy readiness repair, as the Fastly record contract's native race needs, and the production hosting tests' held port reservations and spawn-token respawn from #406 up, with each later PR's tests reading the live host's address. It had no conflicts.

Bring in PR #275's batch cutoff test fix, which advances the test clock
when the request arms its own deadline instead of after dispatch, and
PR #414's AWS emulator proof marker, now published by rename.
The generated records initializer wrote PROOF_ENTERED with
std::fs::write, so App::ready could read the marker after it was created
and before "records-ready" was written. It now writes a staged file and
renames it into place, as the ordinary proof's initializer does.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 152fcce8 and a296a067. 152fcce8 merges #439's new head, which brings #275's 0e2a58ae, the fix for an intermittent failure of the batch cutoff test, and #414's AWS emulator proof readiness marker, now published by rename; it had no conflicts. a296a067 does the same for this PR's records proof: its generated initializer wrote PROOF_ENTERED with std::fs::write, so App::ready could read the marker after it was created and before "records-ready" was written. It now writes a staged file and renames it into place.

@prk-Jr prk-Jr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for one blocking question on the Fastly CAS contract; one smaller non-blocking item is inline.

The record design is careful overall. Generation allocation is transactional and survives deletion on redb, DynamoDB and celld; cursors are bound to scope, format, layout and partition; and Overwrite/Add/CAS outcomes are kept separate from MutationUncertain. Hosted checks are green at a296a067.

Blocking: a CAS against a deleted (absent) key is not established on Fastly.

RecordWriteMode::IfGenerationMatch promises "write only while this key still has the supplied generation". So a writer holding a generation from before a delete must get PreconditionFailed, not recreate the key. redb, DynamoDB (#generation = :expected against a missing item) and celld (existing === undefined is rejected) all reject this by construction. The Fastly provider instead passes the generation straight to the native if_generation_match and relies on the platform.

The only Fastly runtime this repository tests against does not reject it. In Viceroy's ObjectStores::insert (0.21.0 upstream, and unchanged by patches/viceroy/0.22.0-body-readiness.patch), the precondition only fails when existing is Some with a different generation (if let Some(g) = generation && let Some(val) = &existing && val.generation != g). With no current value, the insert proceeds. Scenario: client A looks up k (generation G), client B deletes k, then A's CAS(G) returns Written and the deleted record comes back.

Nothing in the PR shows what production Fastly does here, and no test covers it. assert_record_contract checks a stale CAS only after the key has been recreated (assert_deletion → Add → assert_stale), never while it is absent, and the Fastly record_cases fixture has no such case either. I added assert_stale(records, key, before_delete) straight after the delete in assert_deletion and ran the Axum shared-contract test, and it passes. So the extra assertion is compatible with the other providers and would discriminate this case.

Suggested resolution:

  1. Add the CAS-on-absent assertion to the shared contract (and the Fastly record fixture) so every provider runs it.
  2. Establish the production Fastly behaviour from Fastly's documentation or a hosted run. If production rejects it, this becomes the Viceroy disclosure alongside the existing race gap. If not, Fastly needs a documented limitation, or the CAS capability should not be claimed for Fastly yet.

Checks I ran (Rust 1.98.1, at a296a067): edgezero-core record_api and record_configuration tests pass. The Axum public_handle_shared_record_contract passes both unmodified and with the extra absent-key assertion. I did not run DynamoDB Local, stock celld or Fastly WASM locally; for those I relied on the hosted results.

RecordWriteMode::Add => request.mode(InsertMode::Add),
RecordWriteMode::Overwrite => request.mode(InsertMode::Overwrite),
RecordWriteMode::IfGenerationMatch(generation) => {
request.if_generation_match(generation.as_u64())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking. On a missing key this native precondition is not rejected by Viceroy: ObjectStores::insert only fails when an existing value has a different generation, so a stale CAS after a delete recreates the record. The redb, DynamoDB and celld providers all return PreconditionFailed here. Please establish the production Fastly behaviour and cover the case in the shared contract (see the review summary).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b4be3c3 adds the missing-key case to the shared contract the Fastly WASM fixture already runs. With the updated fixture, stock Viceroy 0.22.0 returned Written instead of PreconditionFailed. The inherited atomic-insert repair fixes the race, but still only compares generations when a row exists. The plan now distinguishes those two findings.

Fastly’s Compute docs say a conditional write only succeeds when the current generation matches. The existing production deployment was reported to be working; I did not run or inspect a separate hosted missing-key trace. No adapter workaround or contract exception is included. I’m leaving this open until the missing-key emulator fix comes through #275 and #439 and the required Fastly suite passes.

@aram356 aram356 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Summary

Found while reviewing the rc/identity integration branch (#495) and traced to this PR. Each finding was re-checked at this head (b4be3c3d); line numbers refer to it.

Requesting changes for three blocking findings and one question.

Findings

Blocking

  • 🔧 Fastly record-store misconfiguration answers every request with 400. See fastly/src/lib.rs.
  • 🔧 The kv-records.md sample does not compile. See kv-records.md:63.
  • 🔧 CHANGELOG: ## Unreleased has no entry for the portable record contract (require_record_store, RecordLayout, conditional writes, record listing) or the DynamoDB and celld record providers.
  • ❓ Should one key outside the layout fail every Fastly record list page? See fastly/src/key_value_store.rs:174.

Non-blocking

  • 🤔 Record cursors carry the binding scope, including the DynamoDB table ARN, in plaintext. See record_store.rs.
  • 🤔 DynamoDB partition listing walks allocator rows first. See dynamodb_records.rs:558.
  • 🤔 Fastly record reads report every error as a retryable 503. See fastly/src/key_value_store.rs:330.

CI Status

  • GitHub reports no checks at b4be3c3d.

.any(|id| !metadata.is_some_and(|meta| meta.ids.contains(&id.as_str())))
{
return Err(
KvError::Validation("record declaration uses an undeclared ID".to_owned()).into(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 A deployment misconfiguration reaches every visitor as 400

A record declaration that names an undeclared store ID is an operator error, but KvError::Validation maps to 400, so every request answers as if the client sent something wrong. Axum refuses to start for the same mistake. Return EdgeError::internal here and keep 4xx for request-derived failures. #275 (outbound contract checks), #514 and #517 (Spin settings, 422) have the same class of problem.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8cc8133. build_target_app now returns EdgeError::internal, so an undeclared record store ID answers 500. record_layouts_must_name_declared_ids_without_opening_a_provider asserts the status and message. Cloudflare (lib.rs:88-91) and Spin (lib.rs:123-126) still map the same mistake to KvError::Validation (400); I will follow up on those here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up in a839312: Cloudflare and Spin now report an undeclared record store ID as EdgeError::internal (500) too. The record_requirement_refuses_unsupported_platform_before_store_preparation tests in both crates assert the 500 and the message.

Comment thread docs/guide/kv-records.md Outdated
In your existing `Hooks::configure` implementation:

```rust
app.require_record_store("sessions", RecordLayout::new(FirstSegmentLayout)?)?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 This sample does not compile

Compiled as a scratch test, it fails with E0277: the trait bound RecordLayout: RecordKeyLayout is not satisfied: require_record_store takes KeyLayout: RecordKeyLayout + 'static (core/src/app.rs:563-570). Pass FirstSegmentLayout directly, or change the signature to take a RecordLayout.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 702ad42. The sample passes FirstSegmentLayout directly and drops the unused RecordLayout import. All three Rust blocks in this guide now compile in a scratch test.

let page = self.with_store(|store| {
strong_list_page(store, prefix, native_cursor.as_deref(), limit)
})?;
for key in &page.keys {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Should one key outside the layout fail every list page that contains it?

Every listed key goes through binding.layout.resolve(key)? (:169-176). docs/guide/kv.md:163 seeds key = "__init__" into the sessions store for Viceroy, which is the same ID the records guide binds, so ordinary listing fails on that store locally. Skip keys the layout does not cover, or document that a record-bound store must hold only layout keys.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1a14228 with docs, per the decision on this question. kv.md now declares the Viceroy sessions store empty (sessions = []) instead of seeding __init__. kv-records.md states that a record-bound store must hold only layout keys, and that a page containing another key fails listing.

.cursor
.map(|native| {
serde_json::to_string(&RecordCursor {
scope: self.binding.scope.clone(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Record cursors serialize the binding scope in plaintext

For DynamoDB records, scope is the JSON of the endpoint, table ARN (with the account ID), table ID, region, table and namespace (store-aws/src/dynamodb_records.rs:107-115), and this cursor is what apps hand to HTTP clients for pagination. Debug already hides scope, and celld binds its cursors with a hash. Bind with a SHA-256 of the scope instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 15dcf26. The new RecordBinding::scope_digest() (SHA-256, hex) replaces the raw scope in every record cursor: core partition cursors, DynamoDB partition and Scan cursors, Axum redb cursors and Fastly ordinary cursors. Tests assert that no endpoint, ARN, account ID, table ID, DB path or store name appears in a cursor, and that a cursor from another scope is rejected before any I/O. Previously issued cursors become invalid; the feature is unreleased.

values.insert(":pk".to_owned(), AttributeValue::S(self.partition_key(query_partition)?));
let output = self.inner.client.query().table_name(&self.inner.table).consistent_read(true)
.scan_index_forward(true).limit(native_limit)
.key_condition_expression("#pk = :pk")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Partition listing walks allocator rows before reaching any record

Limit applies before filter_expression, and allocator rows sort before value rows and are never deleted. A traversal therefore returns empty pages first and reads every key ever written. :prefix is built and then dropped because "Query cannot filter a key attribute", but a key condition can use the sort key: #pk = :pk AND begins_with(#sk, :prefix). No format change is needed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c1fc9e2. The partition Query key condition is now #pk = :pk AND begins_with(#sk, :prefix), so allocator rows (g#…) never consume Limit. The mock applies the sort-key condition before Limit, and the traversal test goes from 2 empty pages to 0. decode_cursor also rejects a partition cursor whose sk falls outside r#<prefix>. That check goes slightly beyond the finding, so drop it if you prefer. The env-gated DynamoDB Local test was not run.

body: Bytes::from(response.take_body_bytes()),
})),
Err(KVStoreError::ItemNotFound) => Ok(None),
Err(_) => Err(KvError::Unavailable),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Every lookup error except ItemNotFound becomes Unavailable (503, retryable)

The write path distinguishes InvalidKey, ItemBadRequest and similar errors (:404-416), but record lookup here and strong list (:444, :447) collapse them all. A rejected key or a tampered list cursor then becomes a retry loop. Reuse the write path's mapping.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2b6eb62. A shared rejection_error now classifies InvalidKey, ItemBadRequest and the other rejections the same way for mutations, record lookup and both strong-list paths. Unknown read failures stay Unavailable, and reads never yield MutationUncertain. Covered by read_rejections_match_mutations_and_unknown_read_failures_stay_retryable.

A record declaration naming an undeclared store ID is a deployment mistake, not a client error, so it must not answer every request with 400.
require_record_store takes a RecordKeyLayout and validates it itself; wrapping it in RecordLayout::new does not compile.
Every listed key on a record binding goes through the layout, so the Viceroy __init__ seed in the sessions example broke listing once sessions was record-bound.
Record lookup and strong list mapped every error to a retryable 503, so a rejected key or cursor became a retry loop. Reads now share the mutation path's rejection classification and fall back to Unavailable only for unknown outcomes.
Limit applies before the filter, so allocator rows, which sort first and are never deleted, produced empty pages ahead of every partition's values. Move the r#<partition> prefix into the key condition and reject partition cursors outside that range.
Cursors are handed to HTTP clients, and the DynamoDB scope holds the endpoint and table ARN with its account ID, while redb's holds the database path. Core, DynamoDB, redb and Fastly cursors now carry only RecordBinding::scope_digest, a SHA-256 of the scope.
Covers require_record_store, RecordLayout/RecordKeyLayout, conditional writes, partition listing and cursors, and the DynamoDB and celld record providers.
@aram356

aram356 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

CHANGELOG finding from the review: fixed in 81be117. ## Unreleased now has a "Portable conditional KV records" entry covering require_record_store, RecordKeyLayout/RecordLayout, conditional writes and MutationUncertain, partition listing with opaque cursors, provider support (Fastly, redb, DynamoDB, celld; rejected on Cloudflare and Spin) and the record feature flags.

…rors

A record declaration naming an undeclared store ID is a deployment mistake, not a client error, so it must not answer every request with 400. Matches the Fastly adapter.

@prk-Jr prk-Jr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

Summary

Follow-up review at a839312d. The new commits deal with most of the review feedback since a296a067: Fastly/Cloudflare/Spin misconfiguration now returns 500, the guide sample compiles, record cursors carry a scope digest, DynamoDB partition queries use a begins_with key condition, Fastly read errors use the mutation classification, and the shared contract now runs a stale CAS while the key is absent. The record design is still careful. I'm requesting changes because my earlier blocking finding about Fastly CAS on an absent key is still open, the branch now conflicts with its base, and no hosted CI has run on this head.

😃 Praise

  • Every provider now runs the absent-key CAS assertion (record_store.rs:77), and redb, DynamoDB and celld reject it by construction. The DynamoDB partition-query fix also tightens cursor validation, so a forged allocator-row position is rejected (dynamodb_records.rs:434-446).
  • The production code reviewed here matches the stated atomicity model. redb checks and allocates in one write transaction. DynamoDB uses a per-key allocator that is never reset, plus a conditional PutItem with SDK retries disabled (max_attempts(1)), so a resent request cannot turn a committed CAS into PreconditionFailed. celld checks the instance, ledger and precondition and performs the write inside one transactionSync. Each mutation also gets a new ID from the client.

Prior findings status

  • 🔧 Still open: a stale CAS on a deleted key is not established on Fastly (crates/edgezero-adapter-fastly/src/key_value_store.rs:372). b4be3c3 added the shared-contract assertion I asked for. However, the Fastly provider still passes the generation straight to native if_generation_match. The repository's Viceroy patch (patches/viceroy/0.22.0-body-readiness.patch, the if let Some(g) = generation && let Some(val) = &existing hunk) still only rejects when a row exists. The Fastly record-contract phase that crates/edgezero-test-harness/src/runners/ci.rs:239-260 adds to the Fastly CI suite would therefore fail on the pinned emulator. The author's reply and the plan (docs/superpowers/plans/2026-11-13-kv-record-contract.md:15-21) confirm this. Production Fastly behaviour is also still unverified: the linked JS SDK page doesn't cover a missing key, and no hosted trace was run. Please land the emulator fix through the base, or take Fastly out of the CAS claim or document it as a Fastly limitation, so the required suite can pass.
  • ✅ Resolved: celld ordinary exists on record bindings now uses the live, instance-checked lookup. Only records.exists_strong uses the physical HEAD.

Findings

Blocking

  • 🔧 Merge conflict with the current base: git merge-tree --write-tree against feature/pluggable-geo-providers (dd34d19d) reports CONFLICT (content): Merge conflict in CHANGELOG.md. The base's new native Geo entry and this PR's ### Portable conditional KV records entry both insert directly under ## Unreleased. Please forward-merge the base and keep both entries.
  • 🔧 No hosted CI on this head: GitHub reports zero check runs and zero statuses for a839312d, and none for b4be3c3d. The workflows only trigger on PRs targeting main. The last green set was at a296a067, which predates the absent-key assertion that is expected to fail the Fastly suite. Please run the full suite for this exact head (for example by temporarily targeting main, or with a manual dispatch) and link it.

Non-blocking

  • 🤔 celld Add/CAS judge expired rows by physical presence (inline at services/celld-store/src/index.js:860). This is a cross-provider difference that the portable guide doesn't spell out.

Checks run locally (Rust 1.98.1, --locked, at a839312d)

  • cargo fmt --all -- --check: pass.
  • cargo test for edgezero-core, -adapter-axum, -store-aws, -store-celld, -adapter-fastly, -adapter-cloudflare and -adapter-spin: pass (includes the Axum shared record contract).
  • cargo clippy --all-targets --all-features -D warnings for core, axum, store-aws, store-celld, fastly and cli on the host target: pass. Cloudflare on wasm32-unknown-unknown and Spin on wasm32-wasip2: pass.
  • node --test services/celld-store/test/*.test.mjs on the pinned Node 24.20.0: 28/28 pass. Two empty-body cases fail on Node 24.12, which looks like a local runtime difference, not this PR.
  • Not run: Fastly WASM under the pinned Viceroy 0.22.0, DynamoDB Local, stock celld interop and the full workspace. Test scripts, specs and plans were only skimmed.

CI Status

  • No hosted checks reported for a839312d (blocking, see above).

RecordWriteMode::Add => request.mode(InsertMode::Add),
RecordWriteMode::Overwrite => request.mode(InsertMode::Overwrite),
RecordWriteMode::IfGenerationMatch(generation) => {
request.if_generation_match(generation.as_u64())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Still open: a stale CAS can recreate a deleted key on the tested Fastly runtime

The shared contract now asserts the right behaviour (thanks). This call still passes the generation through unchanged, and the pinned Viceroy (with patches/viceroy/0.22.0-body-readiness.patch applied) only fails the precondition when existing is Some. So the Fastly record-contract phase wired into runners/ci.rs fails at assert_stale straight after the delete. Production Fastly is still unverified.

To unblock, any one of these is enough:

  1. Land the emulator fix in the base so the required Fastly suite passes on this head.
  2. Document it as a Fastly limitation (and have the contract skip that one assertion for Fastly only).
  3. Don't claim IfGenerationMatch on Fastly yet.

Leaving a required suite that is known to fail is not mergeable.

let result;
if (meta.op === "put") {
const { allocator } = readMeta(this.sql);
const existing = meta.op === "record-put" ? this.row(meta.key) : undefined;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Add/CAS see expired-but-unswept rows, while lookup hides them

this.row() doesn't apply live(row, now). Until the alarm sweep runs (sweepIntervalMs = 60s, in batches of 256), two things happen:

  • A CAS that holds a pre-expiry generation returns Written and revives a value that lookup already reports as absent.
  • lookup returns None while Add returns PreconditionFailed, so a "lookup miss, then Add" flow keeps losing for up to a minute.

redb evaluates Add/CAS against live rows (key_value_store_records.rs:216), so the two record providers behave differently. The celld README and the stock-celld spec describe this as intended, but the portable guide (docs/guide/kv-records.md:145-149) only says celld "can hide expired rows". Consider either applying live() to existing here (sweep never resets the allocator, so generations stay unique), or stating this behaviour in the portable TTL section.

records.delete(key).await.unwrap();
assert_eq!(kv.get_bytes(key).await.unwrap(), None);
assert!(!records.exists_strong(key).await.unwrap());
assert_stale(records, key, before_delete).await;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😃 Running the stale CAS while the key is absent, and then confirming it stayed absent, is exactly the check that separates a provider that recreates the key from one that doesn't. Putting it in the shared contract means every provider gets it for free.

.scan_index_forward(true).limit(native_limit)
// Value SKs share `r#<partition>`; allocator `g#` rows sort first
// and stay outside the key range, so `Limit` counts only values.
.key_condition_expression("#pk = :pk AND begins_with(#sk, :prefix)")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😃 Bounding the Query with begins_with(#sk, :prefix) keeps Limit counting only value rows. Pairing it with the value_position check in decode_cursor also closes off allocator-row cursors. Nice fix.

@prk-Jr

prk-Jr commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

📝 Correction to blocking item 3 in my review above: the workflows are not restricted to PRs targeting main — test.yml triggers on every pull_request. The missing runs on a839312d (and b4be3c3d) are more likely because GitHub can't build the PR merge ref while this PR conflicts with its base (mergeable: UNKNOWN, CHANGELOG conflict in item 2). Also there is no workflow_dispatch trigger, so the practical path is: forward-merge the base, resolve the conflict, and confirm the full suite runs green on the new head. The finding itself (no hosted CI on the reviewed head) stands.

This branch has not been deployed

No deployments
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.

DynamoDB and celld providers on Axum meet the record contract KvStore record contract with listing strong within a partition

3 participants