Repository navigation
Add portable conditional KV records across providers - #510
ChristianPavilonis wants to merge 40 commits into
Conversation
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.
#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.
|
For the identity integration branch (#495), I pushed |
…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
left a comment
There was a problem hiding this comment.
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
PutItemwith SDK retries disabled (max_attempts(1)), so a resent request cannot turn a committed CAS intoPreconditionFailed. celld checks the instance, ledger and precondition and performs the write inside onetransactionSync. 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 nativeif_generation_match. The repository's Viceroy patch (patches/viceroy/0.22.0-body-readiness.patch, theif let Some(g) = generation && let Some(val) = &existinghunk) still only rejects when a row exists. The Fastlyrecord-contractphase thatcrates/edgezero-test-harness/src/runners/ci.rs:239-260adds 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
existson record bindings now uses the live, instance-checked lookup. Onlyrecords.exists_stronguses the physicalHEAD.
Findings
Blocking
- 🔧 Merge conflict with the current base:
git merge-tree --write-treeagainstfeature/pluggable-geo-providers(dd34d19d) reportsCONFLICT (content): Merge conflict in CHANGELOG.md. The base's new native Geo entry and this PR's### Portable conditional KV recordsentry 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 forb4be3c3d. The workflows only trigger on PRs targetingmain. The last green set was ata296a067, 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 targetingmain, 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 testforedgezero-core,-adapter-axum,-store-aws,-store-celld,-adapter-fastly,-adapter-cloudflareand-adapter-spin: pass (includes the Axum shared record contract).cargo clippy --all-targets --all-features -D warningsfor core, axum, store-aws, store-celld, fastly and cli on the host target: pass. Cloudflare onwasm32-unknown-unknownand Spin onwasm32-wasip2: pass.node --test services/celld-store/test/*.test.mjson 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()) |
There was a problem hiding this comment.
🔧 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:
- Land the emulator fix in the base so the required Fastly suite passes on this head.
- Document it as a Fastly limitation (and have the contract skip that one assertion for Fastly only).
- Don't claim
IfGenerationMatchon 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; |
There was a problem hiding this comment.
🤔 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
Writtenand revives a value thatlookupalready reports as absent. lookupreturnsNonewhileAddreturnsPreconditionFailed, 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; |
There was a problem hiding this comment.
😃 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)") |
There was a problem hiding this comment.
😃 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.
|
📝 Correction to blocking item 3 in my review above: the workflows are not restricted to PRs targeting |
Bring in PR #439's native Geo sanitization fixes and the review fixes below it, from PR #422 down to PR #275, including NativeProviderCapabilities::missing_feature, the bindings-only validate rules, typed KvOpenFailure categories for local KV, error propagation in the celld dependency contract, the Geo contract's tokio 1.53.1 and main's lockfile versions. CHANGELOG.md: both sides added Unreleased sections at the top. The resolution keeps the base's sections first, then this PR's "Portable conditional KV records". crates/edgezero-adapter-axum/src/native_bindings.rs and native_stores.rs: the base checks compiled providers through missing_feature on a named capabilities value. This PR added the DynamoDbRecords and CelldRecords variants and their capability flags. The resolution keeps the base's call and teaches missing_feature both record variants: aws-dynamodb-records and celld-records. The capabilities value gains dynamodb_records and celld_records. crates/edgezero-adapter-axum/src/key_value_store.rs: the imports keep this PR's records module and record types and the base's io, DatabaseError and StorageError. The base's typed open also sets this PR's record_binding: None. open moves after this PR's new_records, so the impl's methods stay in alphabetical order. crates/edgezero-adapter-axum/src/dev_server.rs: the base returns KvOpenFailure from local KV opens and reports error.category(). This PR added record-bound opens through new_records. kv_handle_from_path and kv_handle_from_path_with_records keep this PR's layout split and the base's KvOpenFailure return. A record-bound open maps the KvError from new_records through a new record_open_failure helper: Unavailable stays Unavailable, and any other error becomes Initialize. The production local KV path uses the base's open for ordinary stores and the same mapping for record stores, with the base's "KV" subject and failure category. The development registry keeps this PR's rule that a record-bound ID is never omitted as optional, and uses the base's category in both messages. run_production_selected keeps the base's "configure: application: assembly failed" error and this PR's build_production_stores_with_records. The test modules keep this PR's record_preparation_tests and the base's scoped ordering expect on native_store_tests. crates/edgezero-cli/tests/celld_generated_proof.rs: PR #422 made the official celld TLS proof Linux-only and pointed its ignore reason at scripts/run_native_celld_integration.mjs. This PR added a stock-service records proof next to it, and that script runs both proofs. The records proof and its generate_records and record_bindings helpers now get the same Linux gate and ignore reason. crates/edgezero-cli/src/config.rs (not conflicted): this PR's record-provider validate test set the --target* fields, which PR #414 removed. The test drops them. scripts/check_native_store_dependency_contract.sh: PR #422 made cargo tree failures fail the script. This PR generalized celld_features into provider_features for the record features. The resolution keeps provider_features and adds PR #422's || return and || exit 1 to it and to every caller. scripts/check_geo_dependency_contract.sh: the base pinned the Cloudflare empty-feature tokio at 1.53.1. This PR replaced the exact-version exception with assert_wasm_tokio_features, which accepts any version without runtime features. The resolution keeps this PR's check. scripts/ci_tooling.test.mjs (not conflicted): PR #422's test that the native store contract fails closed runs that script against a cargo stub. The stub only answered PR #422's graph queries, so this PR's record-feature queries made the success run fail ("Selected AWS service SDK is missing"). The stub now answers this PR's DynamoDB and celld record graphs and keeps formatted store-aws queries empty. The injected AWS-only graph failure still fails the script.
|
Round 12 identity realignment:
The Fastly wasm suite failed here on the record contract's stale write after a delete ( Each merge message says what it carries and how any conflict was resolved. |
|
Round 15 identity realignment:
Each merge message says what it carries and how any conflict was resolved. |
A record store missing or unregistered at request time is a deployment fault, so every route must not answer as a client error. An ordinary-only binding keeps its 501.
Generation 0 is a valid token that never names a stored celld record, so it answers PreconditionFailed like the other providers instead of a validation error.
A CAS on a key that never allocated its generation created a permanent allocator row and sent a doomed PutItem. The allocator condition now rejects it, and only an exhausted allocator stays Unavailable.
An absent key with many descendants cost one strong list call per 1,000 descendants on a request path. The walk now stops after eight pages with Unavailable.
run_app_with_config wires no KV and FastlyService binds only the default ID, so a record app assembled and then failed every request. Both now fail before preparation with an error naming the constraint.
…d Viceroy The records guide promised the CAS check on Fastly without saying its only evidence is the locally patched emulator CI runs.
The guide only asked for an explicit cutover decision. redb refuses to open, DynamoDB silently starts an empty keyspace, and celld and Fastly keep old rows under the new rules.
One pair per mode could not tell a race from two sequential writes. Each round now starts both inserts at one wall-clock instant, and the evidence requires every round to have one winner and at least one round whose inserts overlapped.
# Conflicts: # crates/edgezero-adapter-axum/src/run_options.rs # crates/edgezero-store-celld/src/test_support.rs # crates/edgezero-test-harness/src/evidence/cutover/reviewed_owners.json # crates/edgezero-test-harness/src/runners.rs # scripts/run_celld_store_fleet_proof.mjs # scripts/run_celld_store_fleet_proof.test.mjs
Review follow-up: fixes committed to this branchA full review of this PR turned up the problems below; each would otherwise have needed a follow-up ticket, so it is fixed on this branch instead. Every item names its commit. Fixed in an earlier pass:
Fixed in this pass:
Fixes made on the PRs below this one in the stack were merged into this branch with merge commits. The merge of #422's fixes (6ee5166) carried these resolutions: the celld token capture now also skips |
# Conflicts: # crates/edgezero-test-harness/src/main.rs
Summary
Changes
edgezero-coreedgezero-store-awsservices/celld-storeedgezero-store-celldCloses
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"]Test plan
Local verification uses Rust 1.98.1 with locked dependencies.
cargo test --workspace --all-targetsafter 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 warningscargo fmt --all -- --checkcargo check --workspace --all-targets --features "fastly cloudflare spin"examples/app-demonative workspace tests and strict all-target/all-feature Clippy.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