Repository navigation
Conversation
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Reviewed c1c948d47 against main (db36dc0ec).
Approving so I'm not blocking, on the understanding that you'll handle the comments before merging. Behavior matches #1705, and the Fastly, Axum and Cloudflare country-only tests all pass.
Question: the fallback applies even when consent.us_states.privacy_states = []. A resolved US reader is then non-regulated while an unresolved one is strict, and on Cloudflare, which never sets a region, all US traffic gets gated despite no configured states. Is that intended, or should the fallback require at least one configured state? No test covers the empty list.
Worth noting in the PR description: the log label changes from non-regulated to US for this traffic, and on Cloudflare this affects all US requests, including existing ECs no longer being forwarded without a signal.
Checks: core consent and OpenRTB consent-matrix tests (122 passed), country_only_us tests for Axum, Cloudflare and Fastly (Viceroy 0.22.0), cargo fmt --check.
|
|
||
| // A resolved US country still requires US consent when its state is | ||
| // missing or unreadable; losing state detail must not remove the gate. | ||
| return Jurisdiction::UsState("US".to_owned()); |
There was a problem hiding this comment.
R1 · Nonblocking: name the "unresolved US state" sentinel once. Reusing UsState is the right call, since it makes every existing match apply the strict rules. But the literal "US" is now relied on here, in the Display guard, and in 13 test sites across core, OpenRTB and three adapters. A future consumer that reads the payload as a state code (say, per-state GPP section selection) has to know the convention, and nothing enforces it. A Jurisdiction::UNRESOLVED_US_STATE constant or a Jurisdiction::us_unresolved() constructor used everywhere would keep the shape and drop the scattered literal.
| - **Unknown**: Fail-closed when jurisdiction cannot be determined. | ||
|
|
||
| A request whose country is `US` but whose region is missing or unreadable uses | ||
| `UsState("US")`: the same strict US consent rules, without inferring a state. |
There was a problem hiding this comment.
R2 · Nit: describe the label operators see, not the Rust value. These guides use policy labels elsewhere ("US State", "Non-regulated"). Operators will see jurisdiction=US in logs, not UsState("US"). Something like "the US (state unresolved) policy, logged as jurisdiction=US" would fit. Same in docs/guide/gdpr-compliance.md:123.
| Resolution of conflicting signals is configurable (restrictive, | ||
| newest, or permissive). | ||
| - A request with country `US` and a missing or unreadable region uses the | ||
| strict US rules (`UsState("US")`). Without a consent signal, no new EC is |
There was a problem hiding this comment.
Same wording note as in edge-cookies.md (R2).
dhruv8sh
left a comment
There was a problem hiding this comment.
Summary
This PR changes detect_jurisdiction so that a US request with a missing or unreadable region gets UsState("US"). That means the strict US consent gate (no signal → no new EC; GPC and US opt-outs block) applies instead of the old NonRegulated result, which allowed EC with no consent. A readable state not listed in privacy_states still gets NonRegulated, and states the publisher configured still match first. The change is correct and fails closed. Tests cover the core detection, the consent pipeline, OpenRTB regs (no fake GDPR flag and no invented GPP SID) and all three adapters' EC paths. I found nothing blocking. The one thing reviewers should know is how much traffic the new fallback catches: on Cloudflare, that is every US request.
Non-blocking
🤔 thinking
- The fallback covers all Cloudflare US traffic, not an edge case — see inline at
crates/trusted-server-core/src/consent/jurisdiction.rs:93
📝 note
- Country-only US requests can now trigger explicit EC withdrawal — see inline at
crates/trusted-server-core/src/consent/mod.rs:756
👍 praise
- Separate checks for readable vs. unreadable regions, with state matches first — see inline at
crates/trusted-server-core/src/consent/jurisdiction.rs:84
|
|
||
| // A resolved US country still requires US consent when its state is | ||
| // missing or unreadable; losing state detail must not remove the gate. | ||
| return Jurisdiction::UsState("US".to_owned()); |
There was a problem hiding this comment.
🤔 thinking — The docs and comments describe this as a fallback for a missing or unreadable region. On Cloudflare, though, CloudflareGeo::lookup (crates/trusted-server-adapter-cloudflare/src/platform.rs:715) always sets region: None. So every Cloudflare request with cf-ipcountry: US now lands here and gets UsState("US"), whatever the publisher put in consent.us_states.privacy_states. Before this PR, all Cloudflare US traffic was NonRegulated, so EC was always minted. After it, EC is only minted when a US consent signal is present. That is the safe direction, but in practice it is a nationwide policy change for Cloudflare deployments, and the PR description and docs don't present it that way.
Two possible follow-ups:
- Read Cloudflare's
cf-region-codeheader inbuild_geosoprivacy_statesworks on Cloudflare too (📌 follow-up issue). - At least note in
docs/guide/edge-cookies.mdthat Cloudflare doesn't supply a region today, so all US traffic there uses the strict US rules.
The Cloudflare adapter test in this PR already exercises this path, so the behaviour is intended. This comment is only about making it visible to operators.
| "should gate country-only US EC for cookie {cookie:?} and GPC {gpc}" | ||
| ); | ||
| assert_eq!( | ||
| has_explicit_ec_withdrawal(&ctx), |
There was a problem hiding this comment.
📝 note — The test confirms this already, but it's worth noting in the PR description: because has_explicit_ec_withdrawal now returns true for GPC, us_privacy=1YYN or a GPP sale opt-out on country-only US requests, these users' existing ECs will now be withdrawn and tombstoned. Before, NonRegulated never withdrew anything. That is the correct reading of GPC as an opt-out. Operators may still see more withdrawals after deploy, especially on Cloudflare (see the comment on jurisdiction.rs:93).
| // Readable subdivision components contain one to three ASCII | ||
| // alphanumerics. Do not require a catalogue match: valid unlisted | ||
| // states must retain their existing policy. | ||
| if (1..=3).contains(®ion.len()) |
There was a problem hiding this comment.
👍 praise — Good split. Configured state matches come first, so a publisher who lists custom codes keeps them. A readable 1–3 character alphanumeric code keeps its existing NonRegulated behaviour, so nothing changes for real unlisted states. Only empty, sentinel (?, NO REGION) or malformed (US-CA, non-ASCII) values move to the strict fallback. The publisher_state_matches_precede_unreadable_fallback and us_unreadable_region_uses_strict_us_rules tests cover each of those cases.
PR #1718 moves from main onto PR #1717's branch, which sits on PR #1714 and PR #1662's branch, the top of the identity chain trunk. PR #1717's new head brings the identity integration chain as of round 12 wave A, #1714's US GPP opt-out fix, and #1717's explicit refusals with the `us_states.all_states` option. #1718 moves onto #1717 because both change US jurisdiction detection. crates/trusted-server-core/src/consent/jurisdiction.rs: #1718 maps a US request with a missing or unreadable region to UsState("US") and keeps readable unlisted regions NonRegulated. #1717 maps every US request to UsState(region or "US") when all_states is on, and the chain reworded the module and enum docs. The resolution keeps #1718's detection order, listed state then readable region then the UsState("US") fallback, and applies all_states to the readable-region step, so all_states turns a readable unlisted region into UsState(region) and a missing region is strict with or without it, as #1717's spec requires once #1705 lands. The doc wording keeps the chain's, and the detect_jurisdiction docs describe both rules. #1718 intentionally changes four expectations here: us_no_region_is_non_regulated becomes #1718's us_no_region_uses_strict_us_rules; the chain's publisher_state_list_is_authoritative now expects UsState("US") for the unreadable "US-CA", "" and " CA"; the chain's geography_never_synthesizes_tcf_consent no longer allows a signal-free EC for country-only US; and #1717's all_states_switch_controls_unlisted_us_no_signal_creation expects a missing region to need a signal with the flag off too. crates/trusted-server-core/src/consent/mod.rs: #1718 and #1717 both added tests after the request builder, and the chain added proxy disclosure tests and a NonZeroU16 import. The resolution keeps the chain's and #1717's tests first, then #1718's country_only_us_consent_requires_a_signal with the chain's GeoInfo::country_region. #1717's explicit refusals change only the NonRegulated and Unknown arms, so the US arms #1718 relies on are unchanged. crates/trusted-server-adapter-axum/src/app.rs: #1718 added a country-only US test that built main's services and called main's build_ec_context. The chain added startup contract tests at the same place and reads requests through the shared identity app. The resolution keeps the chain's tests and ports #1718's test to the chain: services with an outbound client and clock, the state's IdentityApp::read_request, and the async generate_if_needed. crates/trusted-server-adapter-cloudflare/src/app.rs: same overlap as Axum. The resolution keeps the chain's startup contract tests and ports #1718's test to the chain's fallible build_runtime_services, giving the request the outbound client it needs, then runs the real cf-ipcountry projection and build_ec_context. docs/guide/edge-cookies.md: #1718 added the country-only US paragraph and the chain rewrote the store paragraph for the shared record service. The resolution keeps #1718's paragraph, notes that all_states moves readable unlisted states to US rules, then keeps the chain's store paragraph. crates/trusted-server-adapter-fastly/src/app.rs (merged clean, failed to compile): #1718's country-only US test used main's Fastly services and build_ec_request_state signature. The resolution builds the chain's services and passes the state's IdentityApp to build_ec_request_state. crates/trusted-server-adapter-cloudflare/src/platform.rs (merged clean, failed): the chain's build_geo_country_projection_preserves_core_consent_policy expected a country-only US header to stay NonRegulated with a signal-free EC. #1718 intentionally changes that, so it now expects UsState("US"), auction admission, and no signal-free EC. docs/guide/configuration.md (merged clean, stale): #1717 said a US request without a region falls back to NonRegulated when all_states is off. With #1718 it uses the strict US rules, and the sentence now says so.
One octopus merge of the round 12 tips into rc/identity c3e3366. It is a single octopus because the RC already holds every sibling's old head, so each tip's new head merges in alongside the others rather than as a chain of merges. The tree is the automatic merge of the RC and all tips, with no resolution: every tip pair, their union and the merge into the RC are clean. Tips, in parent order after the RC: - PR #1503 at 4225024 - PR #1653 at 4bd4903 - PR #1654 at 95cf3e8 - PR #1655 at 05c509d - PR #1622 at afe5217 - PR #1660 at c1a05d7 - PR #1666 at 108b122 - PR #1659 at 5fb8190 - PR #1709 at 6d152f6 - PR #1710 at dcceeee - PR #1713 at cae7801 - PR #1557 at 302e972 PR #1659 sits above PR #1718, so it carries PR #1714, PR #1717 and PR #1718.
|
Round 12 identity realignment:
The base moved from Each merge message says what it carries and how any conflict was resolved. |
PR #1717's new head brings #1535's owner fix that keeps mirrored GPP consent through transient CMP not-ready states (#1678), #1535's move of the consent-update test host to publisher.example.com for the URL-host lint and #1540's allow-domain marks on the deployment guide's reference links. The merge is clean.
PR #1717's new head brings #1506's repin of EdgeZero to rc/identity ef5cbf30, which renames Fastly backends to ez_b31v2_* and moves the yanked pin-project-lite, chacha20 and spin, #1625's shared Wrangler installer for CI, #1639's pull reserve boundary check and wording, #1613's conformance doc alignment, #1616's certificate policy and pull-sync fixture corrections, #1617's preserved startup diagnostics and hardened runtime checks, #1635's complete startup evidence in native fixtures, #1637's shared readable non-Unicode Geo fixture, #1627's Spin store reads and retained runtime coverage, #1535's Sourcepoint consent mirror deduplication and consent update coverage, #1636's stronger after-response body and drain checks, #1626's enforcement of stored and carried provider opt-outs, #1656's strict browser gate wording, #1661's grouped QUIC JA4 fixture and #1662's consent-string comment on the EC route fixture. The merge is clean. Cargo.lock changes only the EdgeZero package sources (now ef5cbf30) and the yanked pin-project-lite, chacha20 and spin; the codegen crate's nested Cargo.lock is unchanged.
|
Round 15 identity realignment:
Each merge message says what it carries and how any conflict was resolved. |
|
Cascade of #1533's Axum startup-test port fix ( |
…tegration chain
|
Merged #1627's runtime KV removal ( At the maintainer's request, that commit removes the generic runtime KV store Only that commit was merged, not the base branch's new head. Conflicts were resolved in Checks on this head: no reference to the removed store remains and |
|
Round 17 identity realignment:
Each merge message says what it carries and how any conflict was resolved. |
…ntegration chain
|
Merged #1614's Trusted Server owns the This merge takes #1717's new head ( Checks on this head: no conflict markers; |
Summary
USin logs.Base/target:
main(db36dc0e), where the shared detector lives.rc/identityis runtime/integration qualification only: its newer identity lifecycle is outside this fix. #1708's general refusal/all-states changes, adapter production changes and EdgeZero changes are excluded.Changes
crates/trusted-server-core/src/consent/jurisdiction.rscrates/trusted-server-core/src/consent/mod.rscrates/trusted-server-core/src/auction/openrtb/tests.rscrates/trusted-server-adapter-axum/src/app.rscrates/trusted-server-adapter-cloudflare/src/app.rscrates/trusted-server-adapter-fastly/src/app.rsdocs/guide/edge-cookies.mddocs/guide/gdpr-compliance.mdCloses
Closes #1705
Spec
Not a feature: focused bug fix. No new configuration or provider behavior.
Adapter behavior
NonRegulated, allowing signal-free EC generation.cf-ipcountry: USsupplies no region and selectsNonRegulated.Unknown; injected country-only US selectsNonRegulated.Unknown. With supplied US geo, actual adapter context construction selects strict US policy. Main's publisher lifecycle still cannot mint/finalize an EC cookie, including with a valid grant.NullGeosupplies neither country nor region, retainingUnknown.Consumers checked
allows_ec_creation: matches the US variant, ignores payload; no signal denies, valid US GPP grant permits, explicit opt-outs deny.has_explicit_ec_withdrawal: matches the variant; absence denies creation without asserting withdrawal.build_regs: standard/Prebid omit empty regs; US signals remain non-GDPR unless an actual EU signal applies. APS uses the applicability bit. The pseudo-state is never serialized.US, preserving labels such asUS-CA.privacy_statesmembership test; none downstream. GPP decoding aggregates US sections independently of geographic state.rc/identity, proxy EC disclosure delegates to the existing EC permission gate, so the fallback also tightens disclosure there.Test plan
Hosted PR CI is green for
c1c948d476(merge1ac9304againstdb36dc0e): all 30 reported checks passed, including adapter tests, target-matched lint, docs/JS and integration/runtime suites. Local checks and scratch-RC runtime evidence below are separate. Live mainab5c24f73merges cleanly; those runs did not execute that newer pairing.Fail-first evidence: missing/unreadable US-region and logging assertions fail on the base; all three adapter regressions fail at
NonRegulatedversusUsState("US")before the correction.Passing focused checks with Rust 1.98.1, Node 24.20.0 and Viceroy 0.22.0:
__gpp=DBABLA~BVQqAAAAAgA.QAgrant control. These are adapter-context/generation tests, not end-to-end cookie-finalization claims.--all-targets --all-features), Cloudflare native clippy (--all-targets), core + Fastly WASI clippy (--all-targets --all-features), and Cloudflare Worker WASM library clippy (--features cloudflare): passed with-D warnings.Representative test commands:
The full CI suite was intentionally not run locally; the hosted results above cover the reviewed revision.
rc/identity trial integration
A literal
git merge --no-commit --no-ffof signed commitc1c948d476ac1cc76bceb1f997e32cc50b5078e1intorc/identityatc3e33666, in a disposable scratch worktree, found conflicts in:crates/trusted-server-adapter-axum/src/app.rscrates/trusted-server-adapter-cloudflare/src/app.rscrates/trusted-server-core/src/consent/jurisdiction.rscrates/trusted-server-core/src/consent/mod.rsdocs/guide/edge-cookies.mdAxum/Cloudflare test-module insertions overlap RC startup tests; jurisdiction comments and its old no-region expectation overlap; consent-test imports overlap; the EC guide overlaps RC storage wording. Fastly tests, the OpenRTB matrix and GDPR guide applied textually cleanly. Integration also needs RC's newer
GeoInfofixture shape and adjustments to existing RC country-only/unreadable-region policy assertions and conformance expectations. Preserve the RC identity/storage flow and #1708's independent scope.The literal merge confirmed the earlier uncommitted-patch preview: the same five conflicted files, with no new conflicts. The trial merge was aborted and the clean scratch worktree removed after preserving conflict evidence. No RC merge commit or RC push was made.
Independent review and runtime evidence
Independent local review found zero blocking code findings and zero optional findings. After runtime qualification confirmed that the reviewed source was unchanged, its readiness label is READY TO REQUEST REVIEW for the scoped main policy fix. That label does not certify main Axum's missing identity lifecycle or a combined RC deployment.
Main Axum HTTP routing with injected US/no-region geo returned the article and no EC cookie for both no signal and a valid GPP grant. The positive cookie control failed because main does not run publisher EC generation/finalization. This preexisting limitation remains unchanged and is not hidden by the supplementary result.
Supplementary runtime verdict: VERIFIED on scratch RC integration. Only the exact reviewed production detector/display code was overlaid into
rc/identityatc3e33666; RC tests/docs were not backported for the runtime build. The actual Axum executable ran through its managed startup, local prepared config/secrets, persistent record binding, and existing protected loopback CloudFront geo provider, with synthetic assertions and a controlled HTTP origin. No manual generation/finalization was added.Both matrices passed all seven expectations. The required country-only requests exposed
x-geo-country: US, no region header, and the controlled publisher article with HTTP 200. The positive cookie was__gpp=DBABLA~BVQqAAAAAgA.QA. Every minted EC was confirmed through the authenticated admin lookup: HTTP 200,consent.ok=true,tombstone=false.The invalid-region CloudFront control is rejected by the pinned SDK before reaching the detector, withholding all geography. It proves unchanged fail-closed behavior, not the core unreadable-region fallback. Core fail-first tests cover the latter. No EdgeZero change is included.
The RC runtime qualifies local application routing, managed provider handoff, persistence and finalization with synthetic inputs. It does not qualify real CloudFront/ALB protection, a deployed environment, other adapter runtimes, or main's EC cookie lifecycle. Both owned servers stopped. No browser, DataDome access, staging/production proxy or deployment was used.
Checklist
Feature spec review: not applicable to this bug fix.
unwrap()introduced.logmacros; no production logger installed.