Skip to content

Bound provider UID lifetimes and gate stored owners - #1715

Open
prk-Jr wants to merge 6 commits into
feat/s2s-eid-vendorsfrom
fix/1548-provider-uid-max-lifetime
Open

prk-Jr wants to merge 6 commits into
feat/s2s-eid-vendorsfrom
fix/1548-provider-uid-max-lifetime

Conversation

@prk-Jr

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

Copy link
Copy Markdown
Collaborator

Summary

  • Give provider UIDs a finite lifetime and immediately withhold UIDs whose recorded owner no longer claims their source.
  • Let a renamed provider acquire fresh identities without reusing the old owner's UID or private refresh state.
  • Preserve consent and retry protections, with stable legacy deadlines and pruning during real writes.

Base and scope

Targets feat/s2s-eid-vendors, starting at #1488 head b990702eaaaaaa8e0000723c78b5994bd91f28d5. That branch already introduces MAX_EXPIRY_SECS and clamps absolute and relative provider expiries. The approved dependency merge dad2dce732b9b64d0640453f40d48daf299fb4de incorporates #1712 / #1547 retry memory before this change. Neither main nor rc/identity is the base or target.

The mirror does not exist on this base. Separately reviewed companion changes on fix/1548-provider-uid-mirror-compat, targeting #1489's feat/s2s-eid-collection-providers, cover mirror construction, retained-cookie fallback, and synthesized pull-sync owners. Merge that companion as part of integrating the identity stack to complete mirror coverage; this core change does not import #1489 or later Axum support.

Behavior before and after

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, legacy pull-sync enrichment 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, in the #1489 companion 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. The 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, the companion 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

The diff includes prerequisite #1547 / #1712 retry memory through the signed dependency merge; the table identifies that inherited behavior alongside #1548.

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 Configure both graph factories with the current provider owner list.
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 Apply the shared per-UID owner/source/consent and effective-expiry policy.
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 Normalize reads, sanitize every configured writer and return snapshots matching stored rows.
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/registry.rs Index configured owners and require owner/source membership and applicable vendor gates.
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, especially validation, disabled providers, the no-expiry acceptance scenario and mirror policy.

Test plan

Core implementation commit: ead6159013767c782f6bacce7e4e60df1e12635f. Its committed tree exactly matches the reviewed and tested working tree.

Rust 1.98.1 and Node 24.20.0 were used. Fastly tests used Viceroy 0.22.0, matching the actual worktree .tool-versions pin.

  • Fail-first regressions demonstrated unspecified lifetime, rename/removal, mixed-owner consent, identify/admin exports and next-write pruning failures before implementation.
  • Core: cargo test --locked -p trusted-server-core --lib ec:: — 662 passed.
  • Core native 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: cargo test --locked -p trusted-server-adapter-fastly --target wasm32-wasip1 ec — 62 passed; one existing deadline-network fixture ignored because it needs its separate origin harness.
  • Fastly lint: cargo clippy --locked -p trusted-server-adapter-fastly --all-targets --all-features --target wasm32-wasip1 -- -D warnings.
  • Existing absolute/relative expiry clamp tests remain passing; tests cover stable legacy bounds, new acquisition on old rows, owner-specific scheduling/generation/cookie comparison, mixed and duplicate-owner policies, and every configured graph writer.
  • Owner-blind cookie-comparison control rejects the strengthened rename test; restoring the owner comparison passes it.
  • Separate Mirror provider EIDs to a cookie and run pull sync as an identity provider #1489 integration overlay: 657 core EC tests, matching core/Fastly lint, 62 Fastly EC tests with the same existing ignore, and dedicated mirror/pull-sync fail-first regressions.
  • Rust formatting, whitespace and formatting of the changed Markdown files.
  • Targeted core documentation builds completed; inherited unresolved/private intra-doc link warnings remain (32 core, 31 companion). Constructor examples are illustrative ignore examples.
  • Full CI matrix: intentionally left to PR CI under the author's requested targeted local scope.

Independent review and runtime evidence

Review corrections through c012ddf0dcce3464e2d7311fd3fb6ae00e2c70bf 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 667 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 c012ddf0dcce3464e2d7311fd3fb6ae00e2c70bf and live base bfdd19b077d67d697e85408f8974aae5442d7a0e; the API workflow base field retains historical b990702eaaaaaa8e0000723c78b5994bd91f28d5.

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 technical design updated and independently reviewed with the implementation.
  • Changes follow repository error, logging and fictional-data conventions.
  • Production code introduces no unwrap().
  • New behavior has regression coverage and meaningful failing controls.
  • No secrets 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 13:25

@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 c012ddf0d against feat/s2s-eid-vendors (b990702ea). The range includes the #1712 retry-memory commit via merge dad2dce73; comments here are about this PR's own changes.

Approving so I'm not blocking, on the understanding that you'll handle the comments before merging. R1 needs a decision before this lands: it's a broader consent change than #1548 asks for, and I'd like the stack owners to agree to it explicitly or have the combined gate restored. R2 is a small retry-memory bug.

Checks: focused core tests on the touched modules.

///
/// Owned UIDs use their recorded owner's consent. Ownerless legacy UIDs
/// retain the source's existing aggregate vendor gates.
pub(crate) fn uid_allowed(&self, source: &str, uid: &KvUid, consent: &ConsentContext) -> bool {

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 · Decision needed: owned UIDs no longer need the source's combined vendor consent. Before, every stored UID for a source was withheld unless all vendors claiming that source had consent, including disabled providers' vendors via keep_vendor_gate. Now an owned UID checks only its owner. Example: source S moves from disabled provider old (vendor B) to new (vendor A). A visitor who consents to A but not B now gets new's UIDs for S. Before, they were withheld.

Browser-sent EIDs for the same source still use the combined gate (auction/endpoints.rs:661-671), so one source now has two consent rules. from_ec_with_kinds_keeps_a_disabled_providers_gate_on_a_reassigned_source still says the source is "withheld while the disabled provider's vendor lacks consent", which no longer governs owned UIDs. The guide also lost the sentence saying the gate covered "every ID for those sources, whether a provider stored it or the browser sent it".

#1548 only asks that egress check the owner is still configured. The smallest change that keeps the old contract is providers.allows(...) && !partner.owner_vendor_consent_denied(consent). If relaxing it is a deliberate product call for the stack, that's fine, but please get the stack owners to sign off, document the stored-vs-browser difference in the guide, and update that registry test.

ProviderLookup {
provider: registered.id.clone(),
status,
retry: status.retry_action(),

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 · P3: a response whose IDs are all for GDPR-excluded sources still clears retry memory. retry is fixed here from the initial status, so a vendor that returned IDs gets RetryAction::Clear. After the merge, exclude_sources drops the GDPR-excluded sources and recount_found downgrades the status to NoMatch, but retry stays Clear, and plan_write removes the deadline. For a GDPR visitor where the vendor only returns an ID for an excluded source, the due source is retried on every navigation, which contradicts the new spec §8.3 ("an empty validated result classified as NoMatch" records an hour). In exclude_sources, when filtering turns a Found/Clear into NoMatch, set retry = RetryAction::NoMatch (leave cookie-derived Preserve and Failure alone), and add a test with only an excluded source in the response. I traced this path in the code but didn't run it.

/// .with_provider_config(&settings.ec.identity_providers);
/// ```
#[must_use]
pub fn with_provider_config(mut self, providers: &[IdentityProviderConfig]) -> 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.

R3 · Nonblocking: owner configuration exists in two copies. The policy is built once into PartnerRegistry.providers (used by plan_write, egress and admin) and again into KvIdentityGraph.providers, which is only set through the with_provider_config builder. A graph built without it skips pruning silently, and the two can disagree; the Fastly fixture had to rewrite settings.ec.identity_providers to line them up (app.rs:3765-3768). Fastly also rebuilds the graph copy per maybe_identity_graph call. Since egress is already enforced by the registry and #1548 says "pruned or not served", I'd either keep pruning only in plan_write and admin and drop the graph-level copy, or pass the registry's ConfiguredProviders into the graph as a required argument.

if !record.is_provider_written() {
return true;
}
let mut entry = KvEntry::tombstone(created);

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 and lifetime sanitizing is duplicated. normalize_provider_expiries(); prune_unconfigured_owners(...) appears here, in kv.rs prepare_entry and entry_for_write, and in write_plan.rs:70-71. KvPartnerId::retain_uids is a fourth copy of the retain/drop-empty/resync shape in prune_expired, retain_readable and drop_last_uid. This function also wraps one record in a fake KvEntry::tombstone just to reach entry-level pruning, and the ownerless gate in eids.rs:133-137 repeats uid_allowed's ownerless branch. A record-level retain_servable, one KvEntry helper running both steps, and a single ownerless gate would cover all of it.

"should mark {source}"
);
}
registry.providers = super::super::registry::ConfiguredProviders::new(&[

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: owner-policy fixtures are copied ten times. This registry.providers = ConfiguredProviders::new(&[serde_json::from_value(json!({...}))]) shape repeats across write_plan, identify (×4), eids, coordinator, after_response and admin (×2), mostly as single lines over 100 columns that rustfmt can't wrap. providers is pub(crate) largely so tests can overwrite it. One test helper (for example test_support::owner_registry(...)) with a multi-line json! would cut this and let providers go private.

matches!(only_status(&results), LookupStatus::Found { .. }),
"should make a fresh lookup for the new owner"
);
assert!(

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 · Nits: this should be assert_eq!(transport.sent.borrow().len(), 1, ...). Also: seven new tests have no blank line before them (validate.rs:513, eids.rs:457, identify.rs:1199, kv.rs:4823, write_plan.rs:1729, admin.rs:1794, coordinator/mod.rs:5020), 18 added lines exceed 100 columns (the R5 fixtures), several new tests skip the Arrange/Act/Assert layout AGENTS.md asks for, and the "#1488 is gated on #1547" note in docs/guide/configuration.md:1021 and spec §8.3 is process state that goes stale once the stack merges.

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