Skip to content

Portable KV-backed Geo lookup - #454

Open
ChristianPavilonis wants to merge 31 commits into
feat/kv-record-contractfrom
feature/kv-geoip
Open

ChristianPavilonis wants to merge 31 commits into
feat/kv-record-contractfrom
feature/kv-geoip

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR delivers

This replaces the prototype-only serving story with opt-in, managed Axum KV Geo. The portable reader takes a checked IP and uses the existing KvHandle interface and a pinned immutable generation. It has no CSV, MMDB, native SDK, or backend-specific lookup dependency. Off remains the default; protected CloudFront and supplied-provider behavior are preserved.

The standalone operator tool builds GeoLite City or Country CSV artifacts, publishes with read-back and manifest-last ordering, and verifies the full tree through the serving binding against an independent CSV oracle. It supports ordinary stock celld and DynamoDB KV. The serving identity is read-only; the publisher can retire prior generations by inventory. No new service API, storage provisioning, or EC binding is required.

  • Design and acceptance: docs/superpowers/specs/2026-11-05-kv-geo-design.md
  • Configuration and proof commands: docs/guide/native-geo.md
  • Operator tool: examples/geo-kv-prototype/README.md

Review and landing order

This branch still targets #510 (feat/kv-record-contract). It includes the #439 provider foundation and a local reconciliation of #502. Please confirm that #439 lands first, that #502 and #510 are reconciled into the target before #454 lands, and that #454 need not carry their changes as its own feature diff. The PR base has not been changed.

Closes #438.

For acceptance, verify the full tree through the read-only serving binding before rollout, then validate the pinned manifest and each nonempty root before Axum readiness. These checks replace the MMDB-specific malformed-file and mount checks. A required descendant missing or corrupt at request time is a provider failure, not a geographic miss or fallback.

Evidence

The local workspace run passed 3,051 tests with 9 existing ignores, alongside strict Clippy, feature checks, and the Spin WASM build. The earlier CLI test stall reproduces on both base and candidate only with terminal stdin. The workspace run used noninteractive stdin without adding any skips. The final standalone default and all-feature suites passed after the object-size decision. The Axum native feature lint matrix passed locally after the compiled-out fixture fixes.

The combined backend proof passed on stock celld and DynamoDB Local, including full-tree readback, managed Axum requests, and 4,096 IPv4/IPv6 oracle comparisons per backend and object size. The same 16 KiB artifacts avoided repeat KV reads in the sampled workload on both backends, so 16 KiB is now the default. 64 KiB remains an explicit option for fewer objects and fewer cold path reads. The report records which binaries were measured. Hosted IAM, production performance and durability are not claimed. No licensed source or derived data is checked in.

Trusted Server integration, deployment, and tags are out of scope for this PR.

@ChristianPavilonis
ChristianPavilonis marked this pull request as ready for review November 10, 2026 23:48

@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

This PR adds a standalone KV Geo prototype: a CSV importer, the p1 binary index, digest-validated async lookup through KvHandle, the design spec and the results record. The lookup algorithm holds up under a randomized differential check: 872,448 lookups compared against naive range containment, covering both families, object budgets of 512–4096 bytes and cache budgets of 0, 2 KiB and 1 MiB, with zero mismatches. The blocking issues are about keeping the crate buildable and the evidence accurate. Nothing in CI builds it, its pins break on the next root bump, several tests can't fail, and the results doc's provenance doesn't match this head.

Findings

Blocking

  • 🔧 No CI coverage, and exact pins coupled to the root: a simulated root serde_json bump makes this crate unresolvable while CI stays green (examples/geo-kv-prototype/Cargo.toml:8)
  • 🔧 Object cache effectively untested: a cache that stores nothing passes all 10 tests (examples/geo-kv-prototype/src/index.rs:635)
  • 🔧 Overlap-rejection test can't fail: no build succeeds at 140 bytes, and deleting the overlap check still passes (examples/geo-kv-prototype/src/index.rs:763)
  • 🔧 Results doc provenance and coverage claims don't match this head (docs/superpowers/plans/2026-11-05-kv-geo-prototype-results.md:9)

Non-blocking

  • 🤔 Cache hit skips the family check, so warm and cold resolvers can disagree (src/index.rs:531)
  • 🤔 IPv4-mapped input misses (src/index.rs:501)
  • 🤔 Generation ID isn't derived from content (src/index.rs:274)
  • ♻️ Validation runs after publication (src/index.rs:291, src/main.rs:55)
  • ♻️ Second SHA-256 stack (Cargo.toml:20)
  • 🤔 load and ArtifactStore have no tests (src/import.rs:149)
  • ⛏ I/O errors lose the path (src/import.rs:132)
  • ⛏ oracle_mismatches is a constant (src/main.rs:128)
  • 🌱 An interrupted write blocks every rerun (src/store.rs:98)
  • 🌱 Before p1 is frozen:
    • The manifest serializes u128 bounds as JSON numbers and each digest as a 32-element array. IPv6 bounds above 2^53 lose precision in JavaScript and jq, and each digest takes about 115 characters as an array versus 64 as hex. Hex strings fix both.
    • Tests match anyhow errors by substring, which doesn't give the bounded failure categories spec §9 asks for. A typed error enum would.
    • Cache::get calls order.retain on every hit, which costs O(entries). A production cache needs O(1) LRU bookkeeping.
    • Resolver::lookup(&mut self) can't be shared across concurrent requests as written.

📌 Out of Scope

  • Dependabot's cargo entry covers only /. Standalone lockfiles such as this crate's get updated only when someone notices a root bump broke them. A tracking issue across the standalone crates would cover this.

CI Status

  • PR checks: 18/18 pass at c52bdaf3
  • Local workspace gates (fmt, clippy, test, feature check, spin wasm32): PASS
  • Local prototype checks: fmt PASS, tests PASS (10/10), clippy -D warnings PASS, release build PASS, cargo check for wasm32-unknown-unknown and wasm32-wasip1 PASS
  • None of the workspace gates or PR checks compile this crate.

How the findings were checked

  • Mutation testing: cargo mutants on index.rs, import.rs and store.rs produced 243 mutants: 146 caught, 71 missed, 20 unviable, 6 timeouts.
  • Probe tests in a scratch copy covered the cache/family divergence, IPv4-mapped input, the minimum budget and the randomized differential check.
  • CLI run: end-to-end build/verify/lookup on synthetic Country-shaped CSV.

Comment thread examples/geo-kv-prototype/Cargo.toml Resolved
Comment thread examples/geo-kv-prototype/src/index.rs Resolved
Comment thread examples/geo-kv-prototype/src/index.rs Resolved
Comment thread examples/geo-kv-prototype/src/index.rs Resolved
Comment thread examples/geo-kv-prototype/Cargo.toml Resolved
Comment thread examples/geo-kv-prototype/src/import.rs Resolved
Comment thread examples/geo-kv-prototype/src/import.rs Resolved
Comment thread examples/geo-kv-prototype/src/main.rs Resolved
Comment thread examples/geo-kv-prototype/src/store.rs Resolved

@dhruv8sh dhruv8sh 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

Standalone, opt-in geo-KV prototype (own [workspace], no production impact) plus design/results docs. Lookup algorithm looks correct and is well validated; only non-blocking notes.

😃 Praise

  • Lookups are verified against a plain containment search over the original, unmerged source networks (import.rs:224-236). XK is kept with a core_country_supported flag rather than widening or dropping it, and the lookup path uses only KvHandle with block_on tests.

Findings

Non-blocking

  • 🤔 Generation check after write (src/main.rs:55) — inline
  • 🤔 O(n) cache hit bookkeeping (src/index.rs:427) — inline
  • ⛏ Silent edition fallback (src/import.rs:150) — inline
  • ⛏ Manifest size unbounded on read (src/index.rs:466) — inline
  • 🌱 Prototype not exercised by CI: its own [workspace] means root CI never builds or tests it, so it can rot as edgezero-core changes. Consider a cargo test --locked --manifest-path examples/geo-kv-prototype/Cargo.toml step or a follow-up issue.
  • 📝 Results doc predates the toolchain bump: it records Rust 1.95.0 and base 72ceed7e; the repo is now on 1.98.1 and the measurements weren't rerun. Keep that caveat visible.

CI Status

  • fmt: PASS
  • clippy (prototype, -D warnings): PASS
  • tests (prototype): PASS (10 passed, 0 failed)

Comment thread examples/geo-kv-prototype/src/main.rs Resolved
Comment thread examples/geo-kv-prototype/src/index.rs Resolved
Comment thread examples/geo-kv-prototype/src/import.rs Resolved
Comment thread examples/geo-kv-prototype/src/index.rs Resolved
Comment thread examples/geo-kv-prototype/src/index.rs Resolved
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.
@ChristianPavilonis ChristianPavilonis linked an issue Nov 19, 2026 that may be closed by this pull request
5 tasks
@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.
The workspace now pins url =2.5.9 for main's Fastly SDK 0.13.3 upgrade
(#529), and this example resolves edgezero-core from the workspace, so
its lockfile no longer satisfied the manifests after the merge. A
targeted `cargo update -p url --precise 2.5.9` moves url to 2.5.9 and
form_urlencoded to 1.2.3, matching the v0.0.12 lockfiles.
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 e68a0783, bbcb3d0f and 0190f778.

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.
kv_geo_listener_checks_reader_provenance_and_pinned_objects reused its
pre-spawn address after the host was ready; it now uses server.addr(),
which follows a respawn.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 96b9f79d and 00091a61. 96b9f79d merges #510's new head, which brings #275's atomic conditional KV insert in the Viceroy readiness repair and the production hosting tests' held port reservations and spawn-token respawn from #406 up; it had no conflicts. 00091a61 makes kv_geo_listener_checks_reader_provenance_and_pinned_objects send its rejected request to server.addr(), which follows a respawn, instead of its pre-spawn address.

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
the AWS emulator proofs' readiness markers from PRs #414 and #510, now
published by rename.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 7580806a, a merge of #510's new head that brings #275's 0e2a58ae, which fixes an intermittent failure of the batch cutoff test by advancing its clock when the request arms its deadline timer, and the AWS emulator proofs' readiness markers from #414 and #510, now published by rename. It had no conflicts.

@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

Re-review at 7580806a (base a296a067). The PR is now opt-in managed Axum KV Geo serving, plus Fastly/Cloudflare platform geo and the operator tool. I found no code defects in the core lookup, publication or Axum wiring. All four blocking items from my earlier review are fixed. One blocking docs issue remains: docs/guide/native-geo.md is now wrong in ways this PR caused.

😃 Praise

  • A missing or corrupt index object is always a provider failure, never a geographic miss. Cached objects are re-checked against the parent's family, envelope and level on every hit.
  • kv_geo_listener_checks_reader_provenance_and_pinned_objects drives every outcome through a real listener with distinguishable values: checked forwarded reader, IPv4-mapped input, XK as unsupported geography, a gap, IPv6 country-only, a removed leaf (provider failure) and a missing root (no readiness, port never bound).

Earlier blocking findings

  • CI never built the tool: fixed. test.yml:219-229 runs standalone fmt, clippy -D warnings and --locked tests on every PR.
  • Object cache untested: fixed. With Cache::get always missing, repeated_lookup_uses_cache_without_backend_reads and the eviction test fail. Without the recency update, the eviction test fails.
  • Overlap test couldn't fail: fixed. With range.start > end changed to >= at geo/kv.rs:273, or the check removed, rejects_overlaps_with_a_compatible_object_budget fails.
  • Results doc provenance: fixed. The serving results name 7c0cd31e. Since then the tool changed only in its default object size, README and a lockfile url bump.

Findings

Blocking

  • 🔧 docs/guide/native-geo.md contradicts the new behaviour (unchanged lines, so not inline):
    • L273-287: the describe() classifier matches GeoUnavailableReason exhaustively but has no arms for MissingReaderIp, NoMatch or UnsupportedGeography. That enum isn't #[non_exhaustive], so the documented snippet no longer compiles. The same snippet in the Axum geo.rs module docs was updated in this PR.
    • L313: says Fastly and Cloudflare expose NoSelection. They now always pass GeoOutcome::platform(...), as configuration.md:566 in this PR says.
    • L289-291: says located results carry GeoSource::CloudFront and DeclaredProtectedAlb. The Fastly, Cloudflare and Kv sources and their trust bases now exist.
    • Fix: add the three arms (or a wildcard), update the adapter sentence, and generalize the source/trust sentence.

Non-blocking

  • 🤔 forwarded-required without a trusted proxy starts and never locates (crates/edgezero-adapter-axum/src/geo.rs:394, inline)
  • 🤔 Breaking geo API changes have no CHANGELOG entry: GeoSource/GeoTrustBasis became #[non_exhaustive] with new variants. GeoUnavailableReason gained three variants but stays exhaustive, which is inconsistent and will break downstream matches again. GeoProviderId::new now rejects fastly, cloudflare and kv. Fastly/Cloudflare ctx.geo() moves from NoSelection to Selected. This is within the 0.x policy, but worth recording. Consider #[non_exhaustive] on GeoUnavailableReason.
  • 🤔 Depth failure leaves a receipt that blocks reruns (examples/geo-kv-prototype/src/main.rs:106, inline)
  • ⛏ README path limit says 32 (README.md:152, inline)
  • ⛏ README example folder name says 64k (README.md:19, inline)
  • ⛏ Configuration table omits kv (docs/guide/configuration.md:579, inline)
  • ⛏ Core geo::kv CI line can select zero tests (.github/workflows/test.yml:226, inline)
  • ⛏ geo_mixed_provider_fields has no message (crates/edgezero-core/src/manifest.rs:1530, inline)
  • 🌱 Test gaps: nothing unit-tests KV selection from the manifest (configured_kv, the documented primary path); only the all-settings path runs, in the listener test. Changing the importer overlap check (import.rs:130-135) from < to <= survives every test, because no case shares an endpoint, e.g. 1.0.0.0/24 plus 1.0.0.255/32. expectFailure in run_geo_kv_integration.mjs:408-412 asserts only exit code 1, so the conflict-publish and incomplete-tree steps would pass for unrelated failures.

📌 Out of Scope

  • Landing order (#439, #502, #510 before this PR) and the #438 decision on full-tree verification instead of the MMDB checks are maintainer decisions the PR already asks for.

CI Status

  • PR checks at 7580806a: 29 pass, 2 fail. cache-restore-smoke and cache-new-revision-smoke fail on TARGET_CACHE_HIT=false (seed cache not found). This PR doesn't touch that workflow. The same jobs pass on #510, and main's #435 addresses this seed-verification race. They need a rerun or a main sync before merge.
  • fmt: PASS (local).
  • tests: PASS locally, 3,053 passed, 0 failed, 9 ignored (cargo test --workspace --all-targets, Rust 1.99.1). The Axum kv_geo listener test passes on 1.98.1. The standalone tool passes 10 unit + 2 CLI tests (default and all-features) and the Node helper passes 8/8.
  • clippy: PASS on hosted 1.98.1 and in a focused local 1.98.1 run over the core/Axum geo-kv code. Local workspace clippy on 1.99.1 fails only on newer lints in unchanged files.
  • Not run: the full celld/DynamoDB integration and the local Fastly/Cloudflare wasm suites (they ran in CI).

Comment thread crates/edgezero-adapter-axum/src/geo.rs Resolved
Comment thread examples/geo-kv-prototype/src/main.rs Resolved
Comment thread examples/geo-kv-prototype/README.md Resolved
Comment thread examples/geo-kv-prototype/README.md Resolved
Comment thread docs/guide/configuration.md Resolved
Comment thread .github/workflows/test.yml Resolved
Comment thread crates/edgezero-core/src/manifest.rs Resolved

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

This PR adds a portable, KV-backed Geo index. It includes a content-addressed codec and tree builder in core (geo/kv.rs), a pin-validated resolver with a bounded LRU cache, Axum integration, adapter contract updates, an example importer/publisher and integration scripts. I focused on the core codec and resolver, and they look solid:

  • Objects are checked against their digest, the header, the record count and record ordering.
  • Envelopes are re-checked when an object comes from the cache.
  • Lookup depth is bounded by the root level, which must be below max_path_objects.
  • Cache arithmetic is guarded.
  • No lock is held across an await.

I didn't find any blocking issues. One non-blocking concern: the generation ID is derived only from the source metadata, not from the range contents. A rebuild with the same source but different ranges would therefore overwrite a manifest that existing deployments have pinned (details inline).

The large diff in examples/geo-kv-prototype/Cargo.lock is generated and I didn't review it. I couldn't run CI here (read-only review).

Comment thread crates/edgezero-core/src/geo/kv.rs Resolved

@dhruv8sh dhruv8sh 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

This PR adds a portable, digest-pinned KV Geo index in edgezero-core, behind the geo-kv and geo-kv-build features. It adds an Axum KV Geo provider with reader-IP provenance, time and concurrency budgets, and selection from the manifest and EDGEZERO__ADAPTER__GEO__* settings. Fastly and Cloudflare now take geography from their own platform metadata. The work is careful and well-tested, and I found no blocking problems. The comments below are about API compatibility, documentation gaps and per-request cost.

😃 Praise

  • Integrity is checked end to end. The pin covers the manifest digest. Each object is addressed by its content hash and checked against it, plus its header, record order and the range its parent gives it. On a cache hit, the range and level are checked again, because the hash identifies the bytes but not the range the parent states. Missing or corrupt objects become errors rather than silent misses.
  • The Off / NoMatch / UnsupportedGeography / MissingReaderIp statuses are precise, and a bad setting never quietly falls back to off. Callers get bounded, actionable outcomes.
  • The tests are thorough: multi-level round trip, deterministic rebuilds, LRU eviction at both cache limits, full-range and empty-family edge cases, and records that are malformed but still match their digest. They all use block_on.

Findings

Non-blocking

  • 🤔 Eager KV lookup on every admitted request (crates/edgezero-adapter-axum/src/service.rs:496): see the inline comment.
  • 🤔 Public enum additions are semver-breaking (crates/edgezero-core/src/geo.rs:323): see the inline comment.
  • 📝 The configuration reference table leaves out the KV provider (docs/guide/configuration.md:579): see the inline comment.
  • ⛏ The LRU touch is O(n) (crates/edgezero-core/src/geo/kv.rs:503): see the inline comment.

📌 Out of Scope

  • Fastly and Cloudflare now always return a Selected platform outcome where they used to return NoSelection. This is a behaviour change for existing apps on those adapters and should get a CHANGELOG or migration note.

Comment thread crates/edgezero-core/src/geo.rs Resolved
Comment thread docs/guide/configuration.md Resolved
Comment thread crates/edgezero-core/src/geo/kv.rs Resolved
@ChristianPavilonis

Copy link
Copy Markdown
Collaborator Author

Review follow-up: 915e935f.

  • Fixed the native Geo guide's Rust classifier and corrected its adapter, source, and trust descriptions. I compiled the classifier against the updated core API.
  • Added coverage for baked KV manifest selection with a settings override, inclusive CSV endpoint overlap, and the distinct remote conflict and incomplete-index verification paths. The managed listener regression also covers rejection before binding when forwarded Geo has no trusted peers.
  • Focused Rust tests, strict Clippy, the docs build, and synthetic proofs on stock celld and DynamoDB Local passed. I did not rerun the licensed-data benchmark or test hosted IAM.

The description now says Closes #438 and records the accepted replacement for the MMDB checks: full-tree verification through the serving binding before rollout, then pin and nonempty-root checks before readiness. The base stays on #510. The #502 platform Geo migration and stack reconciliation remain separate.

@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 915e935f. The only change since my last review at 7580806a is 915e935f, which addresses every item from that review. I re-checked each fix in the code and found no new code defects. One blocker remains: the branch no longer merges cleanly into its base. feat/kv-record-contract has moved to a839312d, and its new "Portable conditional KV records" changelog section conflicts with this PR's "KV-backed Geo" section in CHANGELOG.md.

😃 Praise

  • forwarded-required without trusted peers now fails startup on both the production and dev paths, before store preparation. The new listener assertion also checks that the port never binds. With the check removed, the server would bind and that assertion would fail.
  • Core build refuses to overwrite an occupied manifest key with different bytes, and the regression proves the original pin still resolves. The docs say plainly that this is a single-writer check, not a lock.
  • The too-deep CLI build now validates the whole tree before it writes any metadata, and it installs receipt.json last via temp file and rename. The new CLI test retries in the same directory.

Prior findings status

Review at e043f93e (all four blocking items were already fixed at 7580806a and are unchanged since):

  • ✅ CI never built the standalone tool: test.yml:219-231.
  • ✅ Object cache untested.
  • ✅ Overlap test couldn't fail.
  • ✅ Results doc provenance.

Review at 7580806a:

  • ✅ 🔧 native-geo.md contradicted the new behaviour. The describe() snippet now has the three new arms plus a wildcard (L288-291). The adapter sentence says Fastly and Cloudflare report Selected and only Spin, the unmanaged converter and legacy dispatch expose NoSelection (L326-329). The source/trust sentence covers CloudFront, Fastly/Cloudflare and KV (L300-303).
  • ✅ 🤔 forwarded-required without a trusted proxy: geo/kv.rs:118-126, called from geo::resolve (geo.rs:293) with the runner's and dev server's policy.
  • ✅ 🤔 Breaking geo API changes had no CHANGELOG entry: CHANGELOG.md:5-17 adds one, and GeoUnavailableReason is now #[non_exhaustive] (edgezero-core/src/geo.rs:321). The fixture and both doc snippets have wildcard arms.
  • ✅ 🤔 A depth failure left a receipt that blocked reruns: main.rs:78-114, too_deep_build_does_not_commit_a_receipt_and_can_retry.
  • ✅ ⛏ README path limit and artifacts-16k label.
  • ✅ ⛏ Configuration table now lists kv and the five KV fields with their overrides.
  • ✅ ⛏ Core geo::kv CI line now runs through run_test_nonzero.sh with a sentinel.
  • ✅ ⛏ geo_mixed_provider_fields has a message, and a loader test checks it.
  • ✅ 🌱 Test gaps: manifest-driven KV selection is now unit-tested. The inclusive-endpoint importer case exists (1.0.0.0/24 plus 1.0.0.255/32), and by inspection it fails under <=. expectFailure now asserts the classified failure line.

Findings

Blocking

  • 🔧 Merge conflict with the current base (CHANGELOG.md:5, inline). GitHub still shows base a296a067, but feat/kv-record-contract is at a839312d. git merge-tree reports a content conflict in CHANGELOG.md only. Both sides add a section at the top of ## Unreleased. No other file is changed on both sides. Fix: merge the current base and keep both sections.

Non-blocking

  • ⛏ Startup error doesn't name the cause (crates/edgezero-adapter-axum/src/geo/kv.rs:123, inline).
  • 📝 dhruv8sh's O(n) LRU touch and eager per-request lookup threads were answered: the cache is capped at 256 entries in managed Axum, and eager lookup is now documented with sizing guidance. I agree neither blocks.

CI Status

  • Hosted CI: no checks have run on 915e935f. The last head with hosted runs is 7580806a, where Run Tests, Run Format, Deploy actions and CodeQL all show success. Only 915e935f changed since then.
  • Local at 915e935f on Rust 1.98.1:
    • fmt: PASS.
    • clippy: PASS (--workspace --all-targets --all-features -D warnings), plus the Axum --no-default-features axum,test-utils and geo-kv-only combinations.
    • cargo check --workspace --all-targets --features "fastly cloudflare spin": PASS.
    • wasm checks: PASS for Spin wasm32-wasip2, Fastly wasm32-wasip1, Cloudflare and core geo-kv wasm32-unknown-unknown.
    • Targeted tests: PASS for core (all features), the CI Geo sentinel steps (core geo::kv, Axum manifest selection, managed kv_geo listener) and the Axum doctests with geo-cloudfront and geo-kv. The standalone tool passes fmt, clippy and tests (default and all features), and the Node helper test passes.
    • Workspace tests: PASS (cargo test --workspace --all-targets, non-interactive stdin, exit 0).
  • Not verified: the merged result with the new base (blocked by the conflict above; no other overlapping files), the celld/DynamoDB backend integration, and the Fastly/Cloudflare runtime wasm suites.

Comment thread CHANGELOG.md

## Unreleased

### KV-backed Geo

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.

🔧 Conflicts with the current base

feat/kv-record-contract is now at a839312d. It adds a ### Portable conditional KV records section at this same spot under ## Unreleased, and git merge-tree reports a content conflict here. This is the only file changed on both sides.

Fix: merge the current base and keep both sections, records first then KV-backed Geo, or whatever order you prefer.

Comment on lines +118 to +126
pub(super) fn validate_proxy_policy(
&self,
policy: &TrustedProxyPolicy,
) -> Result<(), NativeGeoConfigError> {
if self.reader_ip == KvGeoReaderIp::ForwardedRequired && !policy.has_trusted_peers() {
return Err(NativeGeoConfigError::InvalidSelection);
}
Ok(())
}

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.

😃 Good fix. The check runs inside geo::resolve, so production, dev and the public geo_capability() all see the same rejection before any store is prepared. Explicit with_geo(Off) still overrides it, and the unit test covers that case.

policy: &TrustedProxyPolicy,
) -> Result<(), NativeGeoConfigError> {
if self.reader_ip == KvGeoReaderIp::ForwardedRequired && !policy.has_trusted_peers() {
return Err(NativeGeoConfigError::InvalidSelection);

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.

⛏ The startup error doesn't name the cause

This reuses InvalidSelection, so the operator sees only native_geo: invalid provider selection, the same message as a malformed pin or an unknown reader_ip. The guide does explain it, but nothing in the log points at EDGEZERO__ADAPTER__TRUSTED_PROXY_CIDRS.

Optional: add a variant such as ForwardedReaderWithoutTrustedProxy, or log the category at the call site. Note that NativeGeoConfigError isn't #[non_exhaustive], so a new variant is another breaking change. You may prefer to add the variant now, while the enum is already changing in this PR.

Comment on lines +373 to +380
if let Some(existing) = kv.get_bytes(&receipt.manifest_key).await? {
ensure!(
existing.as_ref() == bytes.as_slice(),
"immutable Geo manifest conflict"
);
} else {
kv.put_bytes(&receipt.manifest_key, bytes.into()).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.

😃 Refusing different bytes at an occupied manifest key keeps every existing generation@hash pin readable. The regression test fails if this check is removed, because the second build would succeed and the original pin would hit a digest mismatch.

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.

Axum: follow up with an explicit local GeoIP provider

4 participants