Skip to content

Gate mirrored provider UIDs by configured owners - #1716

Open
prk-Jr wants to merge 6 commits into
feat/s2s-eid-collection-providersfrom
fix/1548-provider-uid-mirror-compat
Open

prk-Jr wants to merge 6 commits into
feat/s2s-eid-collection-providersfrom
fix/1548-provider-uid-mirror-compat

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Base and dependency

Targets feat/s2s-eid-collection-providers, starting at #1489 head e6c0e51aff7e1813b77d4e2b0cb6e7ba0db3dd40, because that branch supplies the mirror and built-in pull-sync integration absent from #1488. Prerequisite core PR: #1715, targeting #1488 feat/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. Neither main nor rc/identity is 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/After clamps. The constant is shared from ec/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.uid alias 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

Exit Enforcement
Bidder user.eids from /auction and page-bids live_eids and the shared filtered EID view
Publisher HTML auctions Same auction EID resolver and filtered view
Auction response x-ts-eids Encodes the already filtered resolved EIDs
Identify uid and eid Uses the same per-UID policy before selecting/serializing a result
Admin auction preview Uses live_eids
Admin raw row export Filters provider UID fields and their legacy alias; opaque unparseable row bytes are omitted
Provider refresh input Existing current-owner isolation remains; graph reads apply stable expiry bounds. Same-owner expired refresh input remains supported while held
Mirror cookie Shared per-UID gate and bounded expiry serialization; fallback retains only an exact value reproduced from a readable row and clock
Pull sync Requests send the EC ID, not a stored provider UID. This companion recognizes its synthesized configured owner and bounds its unspecified result

A 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_at metadata. Effective expiry is the earlier of the stated deadline and acquisition plus MAX_EXPIRY_SECS. Existing owned UIDs without acquisition metadata use KvEntry.created as a fixed anchor, including Never and 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_at when 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.

File Change
crates/trusted-server-adapter-fastly/src/app.rs Align injected provider fixtures with runtime graph owner configuration.
crates/trusted-server-adapter-fastly/src/main.rs Use the full EC configuration in both graph factories, including synthesized pull-sync owners (companion); inherit core owner wiring.
crates/trusted-server-core/src/ec/admin.rs Filter UID-bearing diagnostic exports and the legacy alias; omit opaque row bytes that cannot be checked.
crates/trusted-server-core/src/ec/after_response.rs Inherit persistence of retry-only outcomes from #1547; update owner-aware fixtures.
crates/trusted-server-core/src/ec/coordinator/mod.rs Distinguish owners in held/due decisions, generated identities and cookie comparisons; inherit #1547 retry scheduling.
crates/trusted-server-core/src/ec/coordinator/results.rs Inherit #1547 status-specific retry intervals.
crates/trusted-server-core/src/ec/coordinator/validate.rs Default unspecified UID expiry to the existing maximum; record acquisition time and preserve unspecified refresh semantics.
crates/trusted-server-core/src/ec/eid_types.rs Share the existing maximum expiry constant.
crates/trusted-server-core/src/ec/eids.rs Inherit the shared stored-UID policy; add regression coverage for configured and removed pull-sync owners.
crates/trusted-server-core/src/ec/finalize.rs Retain a carried mirror only when a readable row and clock reproduce its exact allowed value; expire unverifiable fallback cookies.
crates/trusted-server-core/src/ec/identify.rs Filter both uid and eid through the shared stored-UID policy.
crates/trusted-server-core/src/ec/kv.rs Inherit read/write sanitation; add with_ec_config so graph pruning recognizes built-in pull-sync owners.
crates/trusted-server-core/src/ec/kv_types.rs Add optional acquisition metadata, stable legacy lifetime bounds and orphan/alias pruning; inherit #1547 retry state.
crates/trusted-server-core/src/ec/mirror.rs Apply the shared per-UID gate and effective server deadline when serializing mirror UIDs.
crates/trusted-server-core/src/ec/registry.rs Inherit configured-owner gates; include synthesized pull-sync:<source> owners for partners that run pull sync.
crates/trusted-server-core/src/ec/write_plan.rs Prune unknown owners during real writes; inherit #1547 retry persistence, clearing and size-cap protections.
crates/trusted-server-core/src/test_support.rs Inherit the narrowly scoped test-helper lint allowance from #1547.
docs/guide/configuration.md Document finite lifetimes, owner changes, retry memory and the companion mirror contract.
docs/superpowers/specs/2026-10-30-s2s-eid-collection-design.md Reconcile validation, legacy rows, egress, disabled owners and mirror compatibility with the fix.

Closes

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 commit ead6159013767c782f6bacce7e4e60df1e12635f as 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.

  • Companion integration: 657 core EC tests, including mirror/pull-sync regressions; the cookie rename test was strengthened and rerun afterward.
  • Native core lint: cargo clippy --locked -p trusted-server-core --all-targets --all-features -- -D warnings.
  • Core WASM lint: cargo clippy --locked -p trusted-server-core --lib --all-features --target wasm32-wasip1 -- -D warnings.
  • Fastly EC tests: 62 passed; one existing deadline-network fixture ignored because it requires its separate origin harness.
  • Fastly WASM lint: cargo clippy --locked -p trusted-server-adapter-fastly --all-targets --all-features --target wasm32-wasip1 -- -D warnings.
  • Fail-first mirror/pull-sync regressions and owner-blind cookie comparison control.
  • Rust formatting, whitespace checks and Prettier for changed Markdown.
  • Targeted documentation build completed with 31 inherited unresolved/private intra-doc link warnings. Constructor examples are illustrative ignore examples.
  • Full CI matrix in GitHub Actions before merge. Current-revision hosted checks complete.

Independent review and runtime evidence

Review corrections through 4a1c7987621a7ece94fb49e82ee78d655b8566ed preserve 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 report provider_policy for 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 head 4a1c7987621a7ece94fb49e82ee78d655b8566ed and live base 7c11f6bde71a9eac681152d56d51dfc33a0982dc; the API workflow base field retains historical e6c0e51aff7e1813b77d4e2b0cb6e7ba0db3dd40.

Local Axum runtime verdict: VERIFIED for the approved integration-overlay scope. The #1488 Axum adapter itself rejects providers. Verification therefore used native-support revision 6b4a5fdc0aca527eed1f8842eb7b87b89cca6cf8 with 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, /auction response x-ts-eids, authenticated identify and mirror output.

Config change Before any writing navigation Subsequent observations
Rename Identify and auction response header omit the old UID while the raw row still holds it Exactly one new-provider lookup, with no old UID/refresh state in its input; new owner persisted; old UID absent from bidder/header/identify/mirror output and storage; new UID delivered
Remove Identify and auction response header omit the old UID while the raw row still holds it Zero provider calls; stale mirror explicitly expired; old record pruned on a real write; unrelated ownerless browser UID preserved

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

  • Existing design updated and independently reviewed with the implementation.
  • Changes follow AGENTS.md conventions.
  • No unwrap() introduced in production code.
  • Uses repository logging conventions.
  • New behavior has regression coverage and failing controls.
  • No secrets, credentials or operator configuration changes.
  • Full CI gates pass in GitHub Actions before merge. Current-revision hosted checks complete.

@prk-Jr prk-Jr self-assigned this Nov 30, 2026
@prk-Jr prk-Jr linked an issue Nov 30, 2026 that may be closed by this pull request
4 tasks
@prk-Jr
prk-Jr marked this pull request as ready for review December 1, 2026 12:52

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

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) {

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.

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 {

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.

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.
///

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.

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");

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.

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

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.

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]

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.

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.

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.

Framework maximum lifetime for provider UIDs, including UIDs without an expiry

2 participants