Repository navigation
Conversation
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Reviewed 4a1c79876 against feat/s2s-eid-collection-providers (e6c0e51af). The range also merges #1715 and #1712; I reviewed the companion-specific changes, and those PRs have their own reviews.
Approving so I'm not blocking, on the understanding that you'll handle the comments before merging. R1 does need fixing before this merges: for any deployment with mirror_enabled partners, the mirror cookie gets expired by the page's first same-origin subresource and never reaches page JS. I reproduced it by switching the test fixture to the production clock rule.
Checks: focused core tests on the touched modules plus the R1 fixture experiment.
| // The mirror cannot be rebuilt here, and it may hold UIDs of a | ||
| // provider whose TCF vendor consent is now denied, whose source is | ||
| // excluded on this GDPR visit or whose cookies now record an opt-out. | ||
| } else if !retained_mirror_matches_policy(ec_context, registry, now) { |
There was a problem hiding this comment.
R1 · P1: a carried mirror cookie is now expired on every non-navigation response. This branch keeps a carried mirror only if retained_mirror_matches_policy can rebuild the exact value from a readable row and a clock. But Fastly only computes now for a permitted, non-redirect navigation (main.rs:699-704, the only production FinalizeRequest caller), so every other response passes now = None. rebuild_mirror(Some(row), None) returns None, the match fails, and this sends Max-Age=0.
In practice: the navigation sets the mirror, the browser sends it on the page's next same-origin request (/static/tsjs=, /auction, integration proxies, fallback subresources), and that response expires it. The mirror never survives into page JS. The same happens on navigations that skip the row read (for example only after-response providers and no browser EID updates). The documented invariants (no Set-Cookie on responses that leave the mirror alone, at most one per UTC day) no longer hold.
The tests miss it because run_split_vendor_mirror_request gives non-navigations now: NOW (finalize.rs:2558). With the production rule (now: if navigation { NOW } else { None }), partial_vendor_denial_keeps_a_mirror_without_the_denied_vendor fails with "should keep a mirror that holds no denied vendor's UIDs".
Suggested fix, keeping the owner-safety goal: when the mirror can't be rebuilt, go back to "leave it alone unless denied", and extend the deny check with a config-only owner check (decode the carried sources and expire if any has no configured owner, or is vendor-denied, excluded or opted out). Optionally read the row on a navigation that carries a mirror and has none loaded. Either way, make the mirror fixtures pass now: None for non-navigations. If strict "verify or expire" is actually intended, the spec and guide need to say the mirror usually lasts only until the next subresource.
| } | ||
|
|
||
| /// Includes the built-in owners synthesized from configured pull-sync partners. | ||
| pub(crate) fn for_ec(ec: &Ec) -> Self { |
There was a problem hiding this comment.
R2 · Nonblocking: the synthesized pull-sync owner ID is a cross-crate string contract. This rebuilds format!("{PULL_SYNC_KIND}:{}", partner.source_domain) and the runs_pull_sync() filter, while the real ID comes from pull_sync_providers in trusted-server-identity-providers (lib.rs:151-167). Owner gating now withholds and then prunes any UID whose owner isn't in ConfiguredProviders, so if either side changes (normalized domain, prefix handling, the base's reserved-prefix work), every pull-sync UID is silently dropped and deleted. Core tests hard-code "pull-sync:ids.example.com". One shared helper for the ID, plus a test in trusted-server-identity-providers asserting every pull_sync_providers(ec) ID is allowed by PartnerRegistry::from_ec(ec), would lock it down.
| } | ||
|
|
||
| /// Applies configured provider ownership to reads and every row write. | ||
| /// |
There was a problem hiding this comment.
R3 · Nonblocking: with_provider_config is public, unused in production, and prunes pull-sync UIDs. Runtime uses with_ec_config; this one is only used by kv.rs tests but the doc example recommends it. It builds ConfiguredProviders::new, which leaves out the synthesized pull-sync owners, so a caller following the example would prune every pull-sync UID on each write. I'd remove it or make it #[cfg(test)]. Also entry_for_write can be clone plus prepare_entry, and admin's raw_body is now always None and can go.
| let mut partner = make_test_partner(source); | ||
| partner.bidstream_enabled = bidstream; | ||
| PartnerRegistry::from_config(&[partner]).expect("should build registry") | ||
| let mut registry = PartnerRegistry::from_config(&[partner]).expect("should build registry"); |
There was a problem hiding this comment.
R4 · Nonblocking: owner policy is injected by hand in 13 test sites. Setting registry.providers = ConfiguredProviders::new(...) directly lets tests build states PartnerRegistry::from_ec_with_kinds never produces, such as owners without the matching vendor gates, or a "kind":"pull-sync" provider that config validation rejects. R1 shows how fixtures that drift from production hide defects. A test_support helper that goes through from_ec_with_kinds would fix this, and providers could go back to private.
| @@ -112,7 +114,9 @@ pub struct FinalizeRequest<'a> { | |||
| /// is expired when the request denies TCF vendor consent to a vendor gating | |||
There was a problem hiding this comment.
R5 · Nonblocking: the docs no longer match the mirror behavior. This doc still promises unchanged responses stay free of Set-Cookie and a returning reader gets at most one mirror Set-Cookie per UTC day, and the "Leaving the mirror cookie untouched" log now only runs when there's no carried cookie or it matches. In the spec, D6 still describes source-level vendor gating, and §8.2 says "the mirror on the dependent collection branch also needs this policy", which is this branch. The "#1488 is gated on #1547" note is in both the guide and the spec. And the change table says configuration.md documents the mirror contract, but it only has the mirror_enabled example comment. Worth sorting out after R1 is settled.
| assert_eq!(eids[0].uids[0].id, "v", "should emit legacy uid"); | ||
| assert_eq!(eids[0].uids[0].atype, Some(3), "should use partner atype"); | ||
| } | ||
| #[test] |
There was a problem hiding this comment.
R6 · Nit: missing blank line before this test. The same thing happens in validate.rs, mirror.rs, kv.rs, write_plan.rs, finalize.rs, identify.rs and admin.rs; rustfmt doesn't enforce it.
Summary
Base and dependency
Targets
feat/s2s-eid-collection-providers, starting at #1489 heade6c0e51aff7e1813b77d4e2b0cb6e7ba0db3dd40, because that branch supplies the mirror and built-in pull-sync integration absent from #1488. Prerequisite core PR: #1715, targeting #1488feat/s2s-eid-vendors. The core fix is incorporated by signed merge, so this PR includes its owner/lifetime behavior and the #1547 / #1712 retry dependency. Review the companion-specific changes against that core integration as well as this PR's full diff. Neithermainnorrc/identityis the base or target.Companion behavior before and after
Previously, mirror construction used source-level consent and liveness without checking each UID's recorded owner. Its fallback could retain a carried mirror after a row read or clock failure, and a rolling mirror cap could outlive a legacy UID's fixed server deadline. The core owner policy alone would also treat the coordinator's synthesized pull-sync owner as unknown.
Now mirror construction uses the shared stored-UID policy and serializes the earlier of the effective server deadline and the existing UTC-day mirror cap. A carried cookie has no owner metadata: fallback retains it only when a readable current row and request clock reproduce the exact allowed cookie value. An unreadable/missing row, unavailable clock, or changed value expires it, including a non-navigation response without a clock. This deliberately can clear an otherwise valid cookie during a read/clock failure; a later successful navigation rebuilds it.
Configured pull-sync partners contribute
pull-sync:<source>owners to both the EID registry and graph sanitation. Their UIDs remain eligible only while that built-in owner is configured for the source; disabling/removing pull sync withholds and later prunes those UIDs. Pull requests send the EC ID rather than a stored provider UID. Unspecified pull result expiry receives the core finite maximum.Inherited core behavior
Previously, an unspecified provider expiry became
Expiry::Never. Any live provider UID at a source suppressed lookup, even if another provider owned it. Egress checked current source configuration, so removing or renaming a provider could leave its stored UID served indefinitely and prevent the new owner from acquiring an identity.Now validation defaults an unspecified UID expiry to the existing 30-day maximum and preserves the existing
At/Afterclamps. The constant is shared fromec/eid_types.rs. An unspecified refresh time still schedules no refresh. Lookup eligibility, generated IDs and cookie deduplication distinguish owners; a former owner's UID, expiry or private refresh state cannot satisfy or block the new owner.Owned UIDs require a configured owner that still claims the source and passes its own vendor-consent gate. Disabled providers remain configured. Matching duplicate disabled-owner policies retain every applicable vendor gate. Ownerless browser/batch records retain their existing source-level rules. Source GDPR exclusions, cookie opt-outs, revocations, retry memory and conditional-write protections remain in force.
Orphaned owners are withheld immediately and physically pruned on the next successful write. Cleanup resynchronizes the legacy
record.uidalias and covers page-load, after-response, create/revive, partner/batch upsert and identify's cluster-cache writes. Pruning accompanies real writes rather than introducing a separate cleanup write.Egress coverage
user.eidsfrom/auctionand page-bidslive_eidsand the shared filtered EID viewx-ts-eidsuidandeidlive_eidsA carried mirror contains no owner metadata. If its row or request clock cannot establish current eligibility, this PR expires it. This can clear an otherwise valid cookie during a read/clock failure or non-navigation response without a clock; a later successful navigation rebuilds it.
Existing rows and rollback
New provider results record additive optional
acquired_atmetadata. Effective expiry is the earlier of the stated deadline and acquisition plusMAX_EXPIRY_SECS. Existing owned UIDs without acquisition metadata useKvEntry.createdas a fixed anchor, includingNeverand overlong absolute expiries. Repeated reads do not extend that deadline; no migration is needed.The conservative fallback can immediately expire a legacy UID acquired recently on a much older row, because its true acquisition time was never stored. New results on old rows use their own acquisition timestamp. Older binaries ignore and may discard
acquired_atwhen rewriting rows, causing upgraded readers to use the conservative fallback again. Ownerless IDs are unaffected.Changes
This PR includes the prerequisite core fix through a signed merge. Most files below are inherited core/retry changes; the mirror finalization and synthesized pull-sync owner handling are the companion-specific behavior.
crates/trusted-server-adapter-fastly/src/app.rscrates/trusted-server-adapter-fastly/src/main.rscrates/trusted-server-core/src/ec/admin.rscrates/trusted-server-core/src/ec/after_response.rscrates/trusted-server-core/src/ec/coordinator/mod.rscrates/trusted-server-core/src/ec/coordinator/results.rscrates/trusted-server-core/src/ec/coordinator/validate.rscrates/trusted-server-core/src/ec/eid_types.rscrates/trusted-server-core/src/ec/eids.rscrates/trusted-server-core/src/ec/finalize.rscrates/trusted-server-core/src/ec/identify.rsuidandeidthrough the shared stored-UID policy.crates/trusted-server-core/src/ec/kv.rswith_ec_configso graph pruning recognizes built-in pull-sync owners.crates/trusted-server-core/src/ec/kv_types.rscrates/trusted-server-core/src/ec/mirror.rscrates/trusted-server-core/src/ec/registry.rspull-sync:<source>owners for partners that run pull sync.crates/trusted-server-core/src/ec/write_plan.rscrates/trusted-server-core/src/test_support.rsdocs/guide/configuration.mddocs/superpowers/specs/2026-10-30-s2s-eid-collection-design.mdCloses
Closes #1548
Spec
Updated existing collection design. The updated guide and design describe both the inherited core behavior and mirror failure/retention policy.
Test plan
Companion merge commit:
441a2b51768c0fb94db9a4498d06feed3b1b5ee1, with core commitead6159013767c782f6bacce7e4e60df1e12635fas its second parent. Its tree exactly matches the reviewed and tested companion integration.Rust 1.98.1, Node 24.20.0 and Viceroy 0.22.0 (the actual worktree pin) were used. Full local CI was intentionally omitted at the author's request; GitHub Actions must run the full gates.
cargo clippy --locked -p trusted-server-core --all-targets --all-features -- -D warnings.cargo clippy --locked -p trusted-server-core --lib --all-features --target wasm32-wasip1 -- -D warnings.cargo clippy --locked -p trusted-server-adapter-fastly --all-targets --all-features --target wasm32-wasip1 -- -D warnings.ignoreexamples.Independent review and runtime evidence
Review corrections through
4a1c7987621a7ece94fb49e82ee78d655b8566edpreserve cookie IDs alongside another source's failed lookup and record its one-hour or five-minute retry interval, including request-build failures. Cookie-only updates preserve the deadline; successful lookups/generated results and fresh opt-outs clear it. Filtering all cookie IDs preserves the actual failure interval. Admin diagnostics now reportprovider_policyfor owner/lifetime exclusions; guidance matches retry-only writes, bounded lifetimes and opaque-body withholding. The final correction passed 662 native EC tests and all-target/all-feature core Clippy under the pinned toolchain. Fail-first regressions distinguish the lost deadline, changed-cookie clearing, filtered-result interval and request-build path. Formatting passes. All 25 current-revision hosted checks pass. Checkout logs confirm the tested merge includes head4a1c7987621a7ece94fb49e82ee78d655b8566edand live base7c11f6bde71a9eac681152d56d51dfc33a0982dc; the API workflow base field retains historicale6c0e51aff7e1813b77d4e2b0cb6e7ba0db3dd40.Local Axum runtime verdict: VERIFIED for the approved integration-overlay scope. The #1488 Axum adapter itself rejects providers. Verification therefore used native-support revision
6b4a5fdc0aca527eed1f8842eb7b87b89cca6cf8with the core and mirror changes applied in a disposable worktree; that later adapter support is not included here.The real Axum application served localhost HTTP with persistent EC records and scripted provider, origin and bidder transport at example hosts. A seeded UID had no expiry and carried the old owner's private refresh state. Positive controls first observed it in actual bidder OpenRTB EIDs,
/auctionresponsex-ts-eids, authenticated identify and mirror output.Disabling the shared owner checks only in the disposable copy makes the pre-write identify assertion fail. Restoring the exact source reproduces both positive scenarios. Every positive-run listener was stopped and verified closed; the disposable runtime worktree was removed after preserving the patch and sanitized evidence.
This proves the local application route/storage/serialization flow with controlled upstreams. It does not claim browser behavior, live provider TLS/API validation, deployed behavior, or that unmodified #1488 supports providers on Axum. The 30-day boundary is established by targeted tests rather than waiting 30 days in the runtime probe. No browser, DataDome bypass, remote proxy task, real credential or operator configuration was used.
Checklist
unwrap()introduced in production code.