Skip to content

Read SharedID from Prebid's configured cookie and send it once as pubcid.org - #1628

Open
dhruv8sh wants to merge 8 commits into
feat/openrtb-user-eidsfrom
feat/sharedid-cleanup
Open

dhruv8sh wants to merge 8 commits into
feat/openrtb-user-eidsfrom
feat/sharedid-cleanup

Conversation

@dhruv8sh

Copy link
Copy Markdown
Collaborator

Summary

  • The server reads SharedID from the cookie Prebid's storage.name names, from the managed sharedId / pubCommonId entry, instead of the hard-wired sharedId cookie (SID-1). Prebid's cookie&html5 storage type counts as cookie storage. With html5 only, no cookie is read.
  • A _pubcid_optout cookie stops SharedID from being read into the record, ingested from ts-eids, sent in auction and server-side ad-stack EIDs, or shown as sendable by /_ts/admin/eids (SID-2, cookie part).
  • SharedID is filed and sent once as {source: "pubcid.org", atype: 1} (SID-3). The legacy cookie path now files under the pubcid.org partner. A record still holding sharedid.org is re-filed on its next real write, and the outbound merge dedupes sharedid.org and pubcid.org as one source.
  • Reading, storing and sending SharedID need EID consent (TCF Purposes 1 and 4) on the legacy path too, including the vendor gate for a client-sent sharedid.org EID (SID-6).
  • The template-cache deny list uses the configured SharedID cookie name, not sharedId (WB-5).

Stacks on #1489 (feat/s2s-eid-collection-providers); review only the two commits above it.

Choices made for this PR

  • The legacy path is retargeted, not removed: it keeps reading the cookie when no sharedid identity provider owns pubcid.org.
  • Settings::sharedid_storage() parses the Prebid config on each call. Fastly resolves it once per sandbox in AppState; the other adapters call it only for /_ts/admin/eids.
  • Re-filing sharedid.org rides along with a write the row already needs, so it adds no KV write.

Changes

File Change
crates/trusted-server-core/src/ec/sharedid.rs New: SharedIdStorage from Prebid's config, SharedIdRequest (cookie value and opt-out), canonical source, re-filing and opt-out filtering helpers
crates/trusted-server-core/src/settings.rs sharedid_storage(); validates the template-cache key cookies against the configured name
crates/trusted-server-core/src/cookies/template_cache_policy.rs, constants.rs Deny the configured SharedID cookie instead of sharedId
crates/trusted-server-core/src/ec/finalize.rs, ec/prebid_eids.rs, ec/write_plan.rs, ec/eids.rs Read the configured cookie, skip it on opt-out, file under pubcid.org atype 1, re-file sharedid.org
crates/trusted-server-core/src/auction/endpoints.rs, publisher.rs One canonical SharedID EID; none for an opted-out reader; vendor gate for legacy client EIDs
crates/trusted-server-core/src/ec/admin.rs Read the configured cookie; report sharedid_opted_out
crates/trusted-server-core/src/integrations/prebid.rs, crates/trusted-server-js/lib/src/integrations/prebid/index.ts Accept and forward cookie&html5
crates/trusted-server-identity-providers/src/lib.rs The sharedid provider reads Prebid's configured cookie name
crates/trusted-server-adapter-* Carry the SharedID cookie name and request state
docs/guide/* Configured cookie name, opt-out and canonical EID

Closes

Closes #1584

Acceptance criteria:

Spec

Spec: server-side identity on every adapter (SID-1, SID-2, SID-3, SID-6, WB-5); plan task T3.

Test plan

  • cargo test-fastly && cargo test-fastly-reuse && cargo test-axum && cargo test-cloudflare && cargo test-spin
  • cargo clippy-fastly && cargo clippy-axum && cargo clippy-cloudflare && cargo clippy-cloudflare-wasm && cargo clippy-spin-native && cargo clippy-spin-wasm && cargo clippy-cli && cargo clippy-codegen
  • cargo fmt --all -- --check
  • JS tests: cd crates/trusted-server-js/lib && npx vitest run
  • JS format: cd crates/trusted-server-js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other: CLI tests, integration --test parity, scripts/lint-wasm-clock.sh, ts dev lint domains --changed-vs feat/s2s-eid-collection-providers

Checklist

  • Feature PRs: spec linked above, ending in a review log of two or more agent review rounds
  • Changes follow AGENTS.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed

Prebid treats cookie&html5 as cookie storage plus local storage. SharedID write-back counts it as cookie storage, so the config must accept it and forward it to Prebid unchanged.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
…cid.org

The server read a cookie hard-named sharedId and filed it under sharedid.org. It now reads the cookie named by the storage.name of the sharedId managed User ID entry, keeps reading sharedId when no entry has storage, and reads none when Prebid keeps SharedID in local storage only. The admin EIDs echo on every adapter and the template-cache key deny list use the same name.

SharedID is filed under the pubcid.org partner, or under sharedid.org when only that one is configured. A record still holding it under sharedid.org is moved to pubcid.org on its next write, and the stored value wins. Bidders receive it once, as source pubcid.org with atype 1, whether it came from the record, the cookies or the auction body, and a sharedid.org browser EID follows the pubcid.org vendor gate.

A _pubcid_optout cookie keeps SharedID out of the record, the ingestion preview and bid requests. Storing and sending it already needed TCF Purposes 1 and 4; tests now cover SharedID for both.

Closes #1584

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
@dhruv8sh dhruv8sh self-assigned this Nov 18, 2026
@dhruv8sh
dhruv8sh added this pull request to stack #1621 November 18, 2026 16:10
@dhruv8sh
dhruv8sh removed this pull request from stack #1621 November 18, 2026 16:50
@dhruv8sh
dhruv8sh added this pull request to stack #1630 November 18, 2026 16:50
@dhruv8sh
dhruv8sh marked this pull request as draft November 18, 2026 17:01
Moves #1628 on top of #1612. Keep both build_ec_request_state's SharedID storage and the provider cookie opt-out read in the Fastly adapter, pass the EC context to the client EID gate so cookie opt-outs apply to both SharedID sources, and union the Prebid guide's EID forwarding steps.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
OpenRTB requests now carry EIDs in user.eids, so the SharedID auction tests read them there and check that user.ext.eids stays unset.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
Keep this PR's SharedID cookie wording in the configuration and edge cookies guides, with the lower PRs' EC-hash rate-limit and full-row pull sync notes.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
dhruv8sh added a commit that referenced this pull request Nov 20, 2026
Moves #1623 on top of #1628. Keep the identity app structure: the SharedID storage is resolved once in IdentityApp, which passes its cookie name to the mounted admin EIDs lookup for every adapter, and the Fastly adapter reads it from there instead of an AppState field. The adapters' own admin routes stay removed, and the Fastly adapter still records provider cookie opt-outs on the EC context before routing.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
dhruv8sh added a commit that referenced this pull request Nov 20, 2026
Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
dhruv8sh added a commit that referenced this pull request Nov 20, 2026
Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
@dhruv8sh
dhruv8sh removed this pull request from stack #1630 November 20, 2026 01:52
@dhruv8sh
dhruv8sh changed the base branch from feat/s2s-eid-collection-providers to feat/openrtb-user-eids November 20, 2026 01:53
@dhruv8sh
dhruv8sh added this pull request to stack #1643 November 20, 2026 01:53
@dhruv8sh
dhruv8sh removed this pull request from stack #1643 November 20, 2026 01:53
@dhruv8sh
dhruv8sh added this pull request to stack #1644 November 20, 2026 01:54
@dhruv8sh
dhruv8sh marked this pull request as ready for review November 20, 2026 11:18
aram356 added a commit that referenced this pull request Nov 24, 2026
Brings #1613, which now carries dhruv8sh's spine on #1489 (#1639, #1640,
#1612, #1628 and the core identity app from #1623), the native prepared
startup (#1531) and the protected native Geo (#1532), into the
certificate-check statement for every outbound HTTPS request.

Fastly post-delivery tests: the PR's EC ID parameter on the returning-reader
helpers stays, and the helpers open the local identity store through the core
identity app as the base does. The returning-reader state loads its snapshot
for the given EC ID from that app. The PR's certificate-check pull helper
builds the identity app from its settings to seed, read and remove its row,
because require_identity_graph now takes the identity app instead of the
settings.

Core config, settings, docs and the example config merge without conflict.
Cargo.lock is the base's.
aram356 added a commit that referenced this pull request Nov 24, 2026
Brings the identity integration chain, now carrying dhruv8sh's spine
(#1639, #1640, #1612, #1628 and the core identity app from #1623), the
native prepared startup (#1531), the protected native Geo (#1532), the
identity conformance suite (#1613) and the certificate-check statement
(#1616), into the uniform health and startup-failure contract, and applies
the contract to the native production runner the same way the PR applies it
to the cutover's runner.

Axum startup: Hooks::routes keeps returning the empty pre-initialization
router and declaring the stores, and the prepared-store initializer still
builds the real router. initialize_native now splits its store reads,
settings validation and router build into prepare_native. When that fails,
it logs the base's single safe diagnostic ("Trusted Server initialization
failed: ...", the top context only) and installs the PR's failure router, so
the process listens with /health at 200 and /ready and every supported route
at the fixed 503, instead of returning an error. Invalid config extraction
limits still fail the initializer. Hosting, Geo profile, provider
preparation (including a missing local config file), ingress and bind
failures still stop the process before it listens. startup_error_router is
reachable from the initializer and takes the failure as a Debug value it
never reads.

Axum router: the base's snapshot state, received-head preparer, middleware
and core identity app mount stay. The PR's probe hook wraps the trace hook
in place of the base's explicit /health route.

Spin router: the base's identity app mount stays, and the explicit /health
route and its helper go as the PR has them, because the probe hook answers
liveness.

Tests: the Axum binary settings-failure test keeps the base's prepared local
config and the PR's probe assertions, and also requires the initialization
failure log and no startup failure exit. The startup tests for a missing
secret, a short passphrase and a tampered envelope, and the native
acceptance cases for an empty config map, each missing secret, an invalid
origin and a short passphrase, move from an exit before listening to the
failure router: liveness 200, /ready and the page 503 with the fixed body,
the same diagnostic and no secret in the log. A missing config file and the
Geo profile cases keep expecting the exit. The absent-stores unit test keeps
its error on prepare_native and checks the failure router through
initialize_native. Readiness waits in the startup and native acceptance
fixtures and the integration fixture poll /ready, because liveness stays up
after a caught failure; the integration fixture keeps the base's workspace
ownership and early exit check. The restart test checks /ready, not
/health, to show the initialized state is retained. Startup tests that read
configured response headers or managed Geo headers from /health read them
from the unknown-hash TSJS route, because probes bypass the response
middleware, and the managed Geo test checks that the liveness probe carries
no Geo header.

Scripts: smoke-axum.sh keeps the base's prepared config directory, isolated
environment, legacy poison values and bounded teardown, runs the PR's probe
cases, including the malformed envelope, invalid settings and hostile
cases, and expects the base's initializer diagnostics with a 503 on the
listener the base gives the positive case. The provider acceptance script
waits for /ready and observes the config snapshot and secret semantics
through the authenticated /_ts/admin/eids echo, because the /health probe
now bypasses authentication and configured response headers; its selected
provider failure cases still exit before listening.

Docs: the Axum README, the axum-dev guide, the native prepared startup guide
and main.rs describe the failure router for store read, settings and state
failures and the exit for hosting and provider preparation failures.

Cargo.lock is the base's.
aram356 added a commit that referenced this pull request Nov 24, 2026
The merge has no textual conflicts. Two of this PR's uses of core APIs
change on the base, and the fix lives here rather than in a
compatibility alias:

- `ts ec eids` now names the SharedID cookie with
  `ec::sharedid::LEGACY_SHAREDID_COOKIE`. #1628 replaced
  `constants::COOKIE_SHAREDID` with it; the value is still `sharedId`.
- The CLI test that decodes a cookie through the real admin handler now
  dispatches through `IdentityApp::mount`, the entry #1623 gives adapters.
  The handler itself is private to the EC module there.
- The test crate allows `Body::into_bytes`, which #1506's `clippy.toml`
  bans outside tests, as #1506's own test crates do.
aram356 added a commit that referenced this pull request Nov 24, 2026
Brings in, through #1636 (cf1102c):
- dhruv8sh's spine on #1489: #1639 (738ba34), #1640 (46530d8),
  #1612 (36e35f8), #1628 (384a481) and #1623 (6fd236e).
- #1531 (47411de) and #1532 (4d17086, which renames the native Geo
  profile variable to TRUSTED_SERVER__NATIVE_GEO_PROFILE_FILE).
- #1613 (2415b7d), then #1616 (c142e87), #1617 (b91770e) and
  #1615 (255c390), restacked on #1613.
- #1635 (06b4044), restacked on #1615, and #1636 (cf1102c).

Each conflict was resolved in the PR that sits higher. This merge is clean.
This brings in 1f054c6 from #1488, which forwards ortb2.user.ext.eids
from the Prebid config into the auction EIDs, and a99dd66, a62601b,
d1eb75f and 394892b from #1489, which cap mirrored UID expiry at 30
days from the UTC day start and pass the request time into finalize.

EC finalize: the file keeps #1489's FinalizeRequest, request-time and
mirror changes, and applies this PR's SharedID change in that form, as
#1662 does. FinalizeRequest carries `sharedid: &SharedIdRequest` in place
of the raw SharedID cookie, and finalize collects the readable value and
drops SharedID updates for an opted-out reader as before. Test call sites
pass SharedIdRequest::default() or with_value_for_test() where they passed
no cookie or a cookie value. This PR's three SharedID storage tests and
their helper take a FinalizeRequest at the fixed test request time and
seed the row at that time.

Fastly adapter: finalize gets the request's SharedIdRequest inside the
FinalizeRequest, with #1489's request time read only for an eligible
navigation. The post-delivery test does the same with a default request.

Auction, EC and publisher tests: each finalize call builds a
FinalizeRequest with the SharedIdRequest the test already used.

It also brings b2d4bfd from #1488, which records the known UID hashes
on lookup results with a setter, so the provider IDs the write planner
logs are not derived from them.

The base now also carries #1506's repin of EdgeZero to rc/identity at
d063a8e7 and its merge of main's Fastly SDK 0.13.3 upgrade (#1671): fastly
0.13.3, url 2.5.9 and Viceroy 0.22.0.

It also brings a610152 and 9104fd3 from #1488, which add hashed-email
intake for the LiveRamp and ID5 identity providers.

Fastly adapter imports: #1488 adds a `ConsentContext` import next to the
constants line, and this PR drops `COOKIE_SHAREDID` from that line because
finalize no longer reads the raw SharedID cookie. The merge keeps the new
import and this PR's constants line.
aram356 added a commit that referenced this pull request Nov 25, 2026
This brings in 1f054c6 from #1488, which forwards ortb2.user.ext.eids
from the Prebid config into the auction EIDs, and a99dd66, a62601b,
d1eb75f and 394892b from #1489, which cap mirrored UID expiry at 30
days from the UTC day start and pass the request time into finalize. They
arrive through the chain's merges into #1639, #1640, #1612, #1628, #1623,
#1531, #1532, #1533, #1534, #1536, #1535, #1537, #1539, #1538, #1540,
#1566, #1624, #1641, #1642 and #1646, with #1646's move of the request
time into IdentityApp::finalize. It also brings d5276ee, which publishes
the native AWS runtime files without GNU mv -T, and Christian's merge
5597d3e of #1538 into #1540, through #1566's merge.

The base now also carries the Axum serving line (#1613, #1616, #1617, #1615,
#1635, #1637 and #1627), which #1533 merged, and #1627's b958107, which
decodes the Spin discovery document with Response::json, and #1627's merge
of #1625 (006b45e), which pins Wrangler for the Cloudflare smoke and CI.

This PR already carries #1646's head 461aa0d, so the merge adds only
#1646's new merge 166944769 of #1642 and the chain below it, including the
identity conformance check that now strips the mirrored UID's exp.

It also brings b2d4bfd from #1488, which records the known UID hashes
on lookup results with a setter, so the provider IDs the write planner
logs are not derived from them.

Restacking on the Axum serving line conflicts in the Axum startup tests,
where #1617 waits for /ready, since liveness stays up after a caught
initialization failure, and this PR rewrites the wait to retry a port
collision and to require the child's own ready lifecycle event.

Axum startup tests: wait_ready keeps this PR's collision retry and
lifecycle check, then probes #1617's /ready and returns the /health
response once the child is ready.

The fixture drains each child's output through this PR's log readers, so
#1617's assert_serves_failure_router reaps the stopped child and reads
those captured logs instead of collecting the pipes, which the readers
already own.

The base now also carries #1506's repin of EdgeZero to rc/identity at
d063a8e7 and its merge of main's Fastly SDK 0.13.3 upgrade (#1671): fastly
0.13.3, url 2.5.9 and Viceroy 0.22.0.

This PR now stacks on #1661 instead of #1646, so rc/identity can take both
as plain merges. #1661 sits on #1656 and #1626, which sit on #1646, so the
merge also brings #1626 (provider opt-outs and legacy EID expiry on Fastly
and Axum), #1656 (the configurable Edge Cookie browser gate) and #1661
(refusing EC creation when a trusted JA4 contradicts the User-Agent).

Fastly identity conformance fixture: #1661 records each scenario's runtime
TLS JA4 through a RuntimeTlsJa4 middleware in place of derived device
signals, takes the User-Agent from the scenario and drops the browser flag.
This PR adds geo consent requests with their own trusted client IP settings
and no browser device signals. The merge assembles the conformance app with
#1661's middleware and keeps this PR's geo_configured flag and
producer_settings. It sends the scenario's User-Agent unless the API request
supplies one, and inserts the scenario's JA4 only for requests without a geo
consent exchange, because this PR derived device signals only for those.

The base now also carries #1627's 4d0c1a2, which renames the generic
runtime KV store to trusted_server_runtime_kv, #1488's a610152 and
9104fd3, which add hashed-email intake for the LiveRamp and ID5
identity providers, #1646's aa31559, which gates identity writes for
rejected clients, and #1626's d07f789, which withholds a mirrored UID
while another source owner is opted out.

Fastly conformance JA4: the rebuilt #1661 merge supplies a trusted Python
JA4 behind the Chrome User-Agent for #1646's known non-browser API
requests, and this PR inserts the scenario's JA4 only without a geo
consent exchange, with its producer_settings. The merge keeps both: a
known non-browser request gets the Python JA4, any other request the
scenario's JA4 unless it is a geo consent exchange.

This PR's head moves to e8015ca, its clean merge of #1646's aa31559,
which the base already carries, so it adds no change beyond the base.

Axum lib.rs: the base now carries #1636, through #1626's merge of it, whose
after_response_drain_tests module sits where this PR adds its
geo_conformance module. The crate keeps both test modules.
aram356 added a commit that referenced this pull request Nov 25, 2026
This brings in 1f054c6 from #1488, which forwards ortb2.user.ext.eids
from the Prebid config into the auction EIDs, and a99dd66, a62601b,
d1eb75f and 394892b from #1489, which cap mirrored UID expiry at 30
days from the UTC day start and pass the request time into finalize. They
arrive through the chain's merges into #1639, #1640, #1612, #1628, #1623,
#1531, #1532, #1533, #1534, #1536, #1535, #1537, #1539, #1538, #1540,
#1566, #1624, #1641, #1642 and #1646, with #1646's move of the request
time into IdentityApp::finalize. It also brings d5276ee, which publishes
the native AWS runtime files without GNU mv -T, and Christian's merge
5597d3e of #1538 into #1540, through #1566's merge.

The base now also carries the Axum serving line (#1613, #1616, #1617, #1615,
#1635, #1637 and #1627), which #1533 merged, and #1627's b958107, which
decodes the Spin discovery document with Response::json, and #1627's merge
of #1625 (006b45e), which pins Wrangler for the Cloudflare smoke and CI.

The merge also brings the 12 #1646 commits this PR lacked, from 48a43ae
to 461aa0d: dhruv8sh's page-phase lookup and /auction EID work
(48a43ae, 82fe088, 1d0a74f, 838586e and his chain merges a061c01,
ecf16e8, e1d23a0, edcf4c5 and 9a020e1), the merge 9cad928 of
#1641 into #1642, and prk-Jr's "Merge providers-awaited into shared
identity" (4ffbaf8) and "Restore Fastly auction browser gating"
(461aa0d).

Edge cookies guide: a conflict is the request lifecycle paragraph.
The merge takes #1646's sentences on positive identity cookies, core
expiries and /auction body EIDs, and keeps this PR's closing sentences on
the default ec.sliding_refresh = false flow and sliding renewal.

Fastly adapter tests: 82fe088 from #1646 removed the navigation-lookups
thread-local and the page-lookups argument of apply_edgezero_ec_finalize,
since the handler now collects page lookups onto the EC context. This PR's
sliding_ec_renews_held_publisher_identity_before_terminal_privacy test
drops its two take_navigation_lookups calls and passes no page lookups to
finalize. Its configuration has no record store or providers, so no
lookups were collected before either, and its assertions are unchanged.

It also brings b2d4bfd from #1488, which records the known UID hashes
on lookup results with a setter, so the provider IDs the write planner
logs are not derived from them.

The base now also carries #1506's repin of EdgeZero to rc/identity at
d063a8e7 and its merge of main's Fastly SDK 0.13.3 upgrade (#1671): fastly
0.13.3, url 2.5.9 and Viceroy 0.22.0.

This PR now stacks on #1661 instead of #1646, so rc/identity can take both
as plain merges. #1661 sits on #1656 and #1626, which sit on #1646, so the
merge also brings #1626 (provider opt-outs and legacy EID expiry on Fastly
and Axum), #1656 (the configurable Edge Cookie browser gate) and #1661
(refusing EC creation when a trusted JA4 contradicts the User-Agent).

Cloudflare route tests: both PRs add a test at the end of the file. The
merge keeps both, this PR's
sliding_ec_configuration_preserves_unsupported_platform_responses and
#1661's ec_route_creates_no_record_whatever_the_bot_management_ja4.

Fastly sliding EC test: #1617, which now sits below this PR, answers GET
/health through the router's probe hook as an operational response, which
carries no EC state. This PR's
sliding_ec_renews_held_publisher_identity_before_terminal_privacy routes
/health through the router and expected EC state on every path but the
unsupported EC route, so it now also accepts the liveness probe without EC
state. Its check that /health issues no renewal cookie is unchanged.

The base now also carries #1627's 4d0c1a2, which renames the generic
runtime KV store to trusted_server_runtime_kv, #1488's a610152 and
9104fd3, which add hashed-email intake for the LiveRamp and ID5
identity providers, #1646's aa31559, which gates identity writes for
rejected clients, and #1626's d07f789, which withholds a mirrored UID
while another source owner is opted out.

Settings: this PR's MaxAgeDays and #1488's HashedEmailSource are both
added before Ec in settings.rs; the merge keeps both.

This PR's head moves to fbe5670, its merge of #1646's aa31559, which
models admitted clients in the core sliding tests, finalizes them with
the store gate and adds refused_client_gets_no_renewal_or_record_io, and
adds the proposal's review log. Taken as the change from the old head
668d501, the new head would replay #1646 commits the base already
carries in rebuilt form. The merge takes only fbe5670's own resolution,
the change from a plain merge of 668d501 and aa31559 to fbe5670:
the sliding tests and the proposal apply cleanly, and its Fastly sliding
test port is the one this merge already made.
aram356 added a commit that referenced this pull request Nov 25, 2026
…1622 into rc/identity

#1622 (244ca26) now carries the whole chain, each PR merging the one below
it:

- #1506 (c197404) repins EdgeZero to rc/identity at d063a8e7, which
  carries EdgeZero main's Fastly SDK 0.13.3 upgrade through every EdgeZero PR
  here, and merges Trusted Server main's upgrade (#1671): fastly 0.13.3, url
  2.5.9 and Viceroy 0.22.0.
- #1614, #1525, #1526, #1487 and #1488 take it in turn. #1488 also adds
  b2d4bfd, which records known UID hashes with a setter.
- #1489, the identity spine (#1639, #1640, #1612, #1628 and #1623), #1531 and
  #1532.
- The Axum serving line: #1613, #1616, #1617, #1615, #1635, #1637 and #1627,
  chained, with #1627's b958107 decoding the Spin discovery document with
  Response::json and #1627's merge of #1625, which brings #1625's Wrangler pin
  into the chain.
- The held line on #1627: #1533, #1534, #1536, #1535, #1537, #1539, #1538,
  #1540, #1566, #1624, #1641, #1642 and #1646. #1646 keeps its own shared
  after-response runner in ec::app::lookups.
- #1636 (72096cd) on #1646 (b5a5f62), draining Axum
  after-response identity tasks on SIGTERM through #1646's shared runner.
- The EC route line on #1636: #1626 (067531e), which merges #1636, the
  draft #1656, #1661, #1662 and #1622, and through #1622's merge of it,
  #1620's round-6 head.

Each conflict was resolved in the PR that sits higher. This merge is clean.

Since the last update the chain also takes #1488's hashed-email intake
(a610152 and 9104fd3) and its POST, body and header options for the
status call (f063a76), #1627's split of the generic runtime KV store into
trusted_server_runtime_kv (4d0c1a2), #1646's gate on identity writes for
rejected clients (aa31559) its native container test of the failure router
(4f4c036) and that test's header check on an ordinary route (71a573a),
#1626's withholding of a mirrored UID while another source owner is opted
out (d07f789), and #1617's description of the Axum startup failure router
(6d174a8) and of the startup failures that still exit before listening
(4c07cad). #1636 no longer sits in the Axum serving line; it arrives
through #1626, which merges it on top of #1646. Its new head adopts #1646's
after-response runner in place of the one rc/identity took with cf1102c.

Cloudflare guide: #1627's merge of #1625 now keeps both #1625's tool version
clause and #1627's TRUSTED_SERVER_RUNTIME_KV binding in the smoke paragraph,
and fixes #1625's smoke script test for #1617's Python floor and Worker
build, and #1537's merge fixes its ts stub for #1537's storage template
step, so this merge needs no resolution.
@aram356

aram356 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed 0347d5652, a merge of #1612's new head 983baa76d. It brings #1489's FinalizeRequest, request time and 30-day mirrored UID expiry cap, #1488's hashed-email intake, and #1506's repin of EdgeZero to rc/identity at d063a8e7 with main's Fastly SDK upgrade (#1671). Resolutions:

  • EC finalize (ec/finalize.rs): the file keeps Mirror provider EIDs to a cookie and run pull sync as an identity provider #1489's FinalizeRequest, request-time and mirror changes, and applies this PR's SharedID change in that form. FinalizeRequest carries sharedid: &SharedIdRequest in place of the raw SharedID cookie, and finalize collects the readable value and drops SharedID updates for an opted-out reader as before. This PR's three SharedID storage tests and their helper take a FinalizeRequest at the fixed test request time and seed the row at that time.
  • Fastly adapter: finalize gets the request's SharedIdRequest inside the FinalizeRequest, with Mirror provider EIDs to a cookie and run pull sync as an identity provider #1489's request time read only for an eligible navigation, and the post-delivery test does the same with a default request. The imports keep Add identity providers for ID5, LiveIntent, LiveRamp, ConnectID and UID2 #1488's new ConsentContext import and this PR's constants line without COOKIE_SHAREDID.
  • Auction, EC and publisher tests: each finalize call builds a FinalizeRequest with the SharedIdRequest the test already used, SharedIdRequest::default() or with_value_for_test() where it passed no cookie or a cookie value.

ChristianPavilonis added a commit that referenced this pull request Nov 25, 2026
…cookie and send it once as pubcid.org

Source: feat/sharedid-cleanup at 0347d56.
Takes #1612's new head d880070, which carries #1506's repin of EdgeZero to
rc/identity at 459bd27d (42e0c46): PR 275 at 0e2a58ae, the stack's test
fixes and EdgeZero 536's bounded record update, RecordHandle::update.

The merge is clean.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed 9fa139833, a merge of #1612's new head d88007043, which brings #1506's repin of EdgeZero to rc/identity at 459bd27d (42e0c46c7): EdgeZero #275 at 0e2a58ae, the EdgeZero stack's test fixes and EdgeZero #536's bounded record update, RecordHandle::update. The merge 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.

Summary

Reads SharedID from the cookie named by Prebid's storage.name for the sharedId/pubCommonId entry, with cookie&html5 counted as cookie storage. Honours _pubcid_optout on the record, auction, server-side ad-stack and /_ts/admin/eids paths. Files and sends SharedID once as pubcid.org with atype 1, re-files legacy sharedid.org rows when the row is next written anyway, and keys the template-cache deny list on the configured cookie. Reviewed against the merge base with feat/openrtb-user-eids (d88007043).

I'm approving: I found no blocking defects. The opt-out, canonical-EID and vendor-gate changes are tested, and CI is green on the head. There are two non-blocking items below. One is a gap in the vendor gate that the PR's own rule implies should be closed.

Non-blocking

🤔 thinking

  • Stored legacy sharedid.org rows skip the pubcid.org vendor gate. See inline at crates/trusted-server-core/src/ec/eids.rs:124.

📝 note

  • The opt-out on the server-side ad-stack path has no test. See inline at crates/trusted-server-core/src/publisher.rs:5712.

Cross-cutting / body-level findings

  • 📝 PR metadata. The body says this stacks on #1489 and asks reviewers to look only at the two commits above it. The base is now feat/openrtb-user-eids (#1612), and the delta also contains the #1612 merge commits plus the test follow-up 47a94d949. The body also says Closes #1584 while the SID-2 and SID-6 criteria are unchecked and deferred to #1593, #1599 and #1507. Merging would close the issue with those criteria still open. Part of #1584 would keep it tracking them.

CI Status

All 25 checks reported by gh pr checks pass on 9fa13983. These include cargo fmt, cargo test, axum, cloudflare, spin, cross-adapter parity, ts CLI (macOS and Ubuntu), vitest, format-typescript, format-docs, the integration and browser suites, worker deadlines and the domain lint.

Verification

  • Ran cargo test --target aarch64-apple-darwin -p trusted-server-core --lib with the filters sharedid, refile, admin::tests::eids, template_cache_policy and write_plan. 39 and 56 tests passed.
  • cargo test -p trusted-server-identity-providers with the filters sharedid and prebid: 13 passed.
  • Negative control: I removed canonicalize_sharedid_eid from merge_auction_eids and the canonical_source vendor check from drop_vendor_denied_client_eids. Three tests then failed: merge_auction_eids_keeps_one_sharedid_across_sources, auction_sends_one_canonical_sharedid_eid and legacy_sharedid_client_eid_follows_the_pubcid_vendor_gate. I restored the code afterwards.
  • Probe for the inline eids.rs finding. With pubcid.org provider-owned under vendor 9999 and a sharedid.org partner registered, a row holding sharedid.org and consent without vendor 9999 makes live_eids emit a pubcid.org EID. This was a temporary test, now removed.
  • npx vitest run test/integrations/prebid: 327 passed.
  • I did not run a manual fastly compute serve check or the Fastly WASM release build.

Comment on lines +124 to +132
partner.into_iter().flat_map(move |partner| {
// A stored SharedID is sent as `pubcid.org` with atype 1,
// whichever SharedID source holds it.
let atype = if is_sharedid_source(source) {
SHAREDID_ATYPE
} else {
partner.openrtb_atype
};
source_views(canonical_source(source), record, atype, 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.

🤔 thinking: stored legacy sharedid.org rows skip the pubcid.org vendor gate.

live_eids checks the partner registered for the stored key, then emits the EID as pubcid.org. Take this setup:

  • pubcid.org is gated by a TCF vendor, either provider-owned (mark_provider_owned) or held by keep_vendor_gate for a disabled provider, or it is GDPR-excluded.
  • A sharedid.org partner is still registered.
  • A row still holds sharedid.org.

For that row, only the sharedid.org partner's gate runs, and the bidder gets a pubcid.org EID while that source's vendor is denied. I checked this with a temporary test: provider-owned pubcid.org with vendor 9999, consent granting only vendor 1, and a row holding sharedid.org. live_eids yielded ["pubcid.org"]. drop_vendor_denied_client_eids now applies the pubcid.org gate to a client sharedid.org EID for exactly this reason, so the stored path breaks the same rule.

The window lasts until the row is re-filed, and re-filing only happens alongside some other real write. A stable returning row can keep sharedid.org indefinitely. The data flow existed before this PR too, when the ID went out labelled sharedid.org. That, plus the narrow config it needs, is why I'm not blocking on it.

Proposed fix: for a SharedID source, also require the pubcid.org partner, when one is registered, to pass owner_vendor_consent_denied and excluded_for, the same way the client path checks canonical_source. Add a live_eids test that covers this case.

Comment on lines +5712 to +5716
let sharedid_opted_out = targeting
.cookie_jar
.is_some_and(|jar| jar.get(SHAREDID_OPTOUT_COOKIE).is_some());
let merged_eids =
strip_opted_out_sharedid_eids(merge_auction_eids(client_eids, kv_eids), sharedid_opted_out);

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.

📝 note: the _pubcid_optout strip on the server-side ad-stack path (apply_auction_eids_and_device, used by both the initial-page and page-bids dispatch) has no test. The helper is unit-tested and /auction has auction_sends_no_sharedid_eid_for_an_opted_out_reader, but nothing would fail if this call site dropped the strip. A publisher-path test with an _pubcid_optout cookie and a stored or ts-eids pubcid.org EID would protect the SID-2 send claim here.

Takes #1612's new head 65c1170, which carries #1506's repin of EdgeZero to
rc/identity at 1619078a (8edc50e), a revert that removes EdgeZero 522
(portable Fastly record providers) and 524 (outbound mTLS client
identities).

The merge is clean.
@aram356

aram356 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed edd910294.

Takes #1612's new head 65c1170, which carries #1506's repin of EdgeZero to rc/identity at 1619078a (8edc50e), a revert that removes IABTechLab/edgezero#522 (portable Fastly record providers) and IABTechLab/edgezero#524 (outbound mTLS client identities).

The merge is clean.

@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 edd910294 against the live feat/openrtb-user-eids base at 65c1170b6. The configured-cookie and canonical-EID cases pass CI. I’m requesting changes because re-filing can make an existing provider’s SharedID opt-out clear miss the stored ID. The inline comments distinguish that regression from the narrower consent, compatibility, and documentation follow-ups.

} else {
partner.openrtb_atype
};
source_views(canonical_source(source), record, atype, 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 · P2: Apply the destination policy to stored SharedID

The earlier vendor-gate finding still applies at this head. This branch checks the partner for the stored sharedid.org key, then emits pubcid.org without checking that partner’s vendor consent or regional exclusion. The client branch checks both names, so dropping the client EID can leave the same ID in the auction via KV. The base already sent the legacy UID under its old label. The inconsistency introduced here is emitting it as pubcid.org under different gates depending on whether it came from KV or the client. Keep the stored source through the checks and apply the destination policy before normalizing.

.and_then(|name| extract_cookie_value(req, name))
.map(|value| decode_cookie_value(&value).into_owned())
.filter(|value| !value.trim().is_empty());
let opted_out = extract_cookie_value(req, SHAREDID_OPTOUT_COOKIE).is_some();

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 · P2: Check all Cookie fields for SharedID opt-out

This helper and /auction use extract_cookie_value; publisher and page-bids use a cookie jar populated from the first Cookie field. A marker in a later field can be missed in ingestion, bidder output, and the admin preview. EdgeZero preserves repeated Cookie fields, and the Fastly provider path already joins them. Use a shared presence check across all fields, before decoding the ID. Separately, the legacy and provider readers disagree on an empty marker. Define that case once when sharing the check.

entry.prune_opt_outs(input.now);
entry.ids.retain(|_, record| !record.uid.is_empty());
// Re-filing a legacy `SharedID` rides along with a real change too.
refile_legacy_sharedid(&mut entry, input.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.

R3 · P1: Don’t move a legacy ID before its provider can clear it

An enabled provider can claim sharedid.org while pubcid.org is also registered. On opt-out its lookup clears the exact legacy key, but the planner has already moved the record. A no-op write leaves the original UID in KV; an unrelated real change can save the opted-out UID under pubcid.org. This affects both page and after-response writes. Apply the clears before moving keys and defer migration of a provider-owned legacy key until lookups and revocations can address both aliases. Keep the default pubcid.org provider's ability to clear legacy data too; add a planner test for a legacy provider clear alongside an unrelated write.

Comment on lines +164 to +165
source.eq_ignore_ascii_case(SHAREDID_SOURCE)
|| source.eq_ignore_ascii_case(LEGACY_SHAREDID_SOURCE)

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 · P3: Match the registry’s SharedID domain equality

normalize_partner_source_domain strips a trailing dot for partner lookup. The SharedID recognizer does not, so a client EID resolving to the same partner can miss outbound opt-out filtering, normalization, and deduplication. Match the registry’s trailing-dot and case rules here.

Suggested change
source.eq_ignore_ascii_case(SHAREDID_SOURCE)
|| source.eq_ignore_ascii_case(LEGACY_SHAREDID_SOURCE)
let source = source.trim_end_matches('.');
source.eq_ignore_ascii_case(SHAREDID_SOURCE)
|| source.eq_ignore_ascii_case(LEGACY_SHAREDID_SOURCE)

Comment on lines +64 to +69
.filter(|entry| {
SHAREDID_MODULE_NAMES
.iter()
.any(|name| entry.name.eq_ignore_ascii_case(name))
})
.find_map(|entry| entry.storage.as_ref());

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 · P3: Resolve the same managed entry that Prebid uses

TSJS resolves sharedId and pubCommonId to the same submodule and keeps the first entry, including when it has no storage. An operator using a prebuilt external bundle can configure both aliases without going through the CLI check. Skipping the first entry here makes Trusted Server read and deny-list a cookie from an entry the browser drops. Select the entry first, then inspect its storage.

Suggested change
.filter(|entry| {
SHAREDID_MODULE_NAMES
.iter()
.any(|name| entry.name.eq_ignore_ascii_case(name))
})
.find_map(|entry| entry.storage.as_ref());
.find(|entry| {
SHAREDID_MODULE_NAMES
.iter()
.any(|name| entry.name.eq_ignore_ascii_case(name))
})
.and_then(|entry| entry.storage.as_ref());

.and_then(|()| {
crate::cookies::template_cache_policy::validate_sharedid_key_cookie(
co.template_cache_key_cookies(),
sharedid_storage.cookie_name(),

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.

R7 · Include the effective provider cookie in the cache-key deny list

A SharedID provider can explicitly set cookie_names = ["sharedId"] independently of Prebid’s configured name. This PR removes the fixed sharedId ban while validating only the Prebid-derived name, so that still-active identity cookie becomes eligible as a template key. Validate the names the enabled readers use without removing the provider override.

Current TSJS writers preserve the full OpenRTB-style `{source, uids:[...]}` shape in `ts-eids`. The server remains backward-compatible with earlier flattened `{source, id, atype}` cookies during rollout, but new cookies use the structured `uids[]` form.

The `sharedId` cookie follows a similar path but is written directly by Prebid's SharedID module rather than by TSJS. The server reads it separately and maps it via the `sharedid.org` source domain.
The SharedID cookie follows a similar path but is written directly by Prebid's SharedID module rather than by TSJS. The server reads the cookie named by the `storage.name` of the `sharedId` entry in [`integrations.prebid.managed_user_ids`](./configuration.md), and reads the legacy `sharedId` cookie when no such entry has storage settings. With `storage.type = "html5"` there is no cookie to read. The ID is stored under the `pubcid.org` partner, the source Prebid sends it under, or under a `sharedid.org` partner when only that one is configured. A record that still holds it under `sharedid.org` is moved to `pubcid.org` on its next write, keeping any SharedID already stored under `pubcid.org`. Bidders receive it once, as source `pubcid.org` with `atype` 1, whichever of the record, the cookies or the `/auction` body carried it. A `_pubcid_optout` cookie keeps the SharedID out of the record and out of bid requests.

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.

R8 · P3: Clarify when legacy rows are re-filed

Only ec/write_plan.rs calls the re-filing helper. Authenticated batch sync can update the row without migrating it. If re-filing is intentionally navigation-only, say “on its next navigation write,” rather than “on its next write.” If the intent is any real write, the batch path needs the same migration.

assert_eq!(
eids,
json!([{ "source": "pubcid.org", "uids": [{ "id": SHAREDID_UUID, "atype": 1 }] }]),
"should send the SharedID from record, cookie and body as one pubcid.org EID with atype 1"

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.

R9 · This assertion only exercises the record and body

A valid body prevents resolve_client_auction_eids from falling back to ts-eids, and the route doesn’t read the direct SharedID cookie. Keep the record/body assertion and add a separate cookie fallback case with no valid body EIDs.

Suggested change
"should send the SharedID from record, cookie and body as one pubcid.org EID with atype 1"
"should merge the SharedID from the record and body as one pubcid.org EID with atype 1"

Html5,
/// Store the module's value in both a browser cookie and local storage.
#[serde(rename = "cookie&html5")]
CookieAndHtml5,

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.

R10 · List cookie&html5 in the configuration reference

docs/guide/configuration.md:2488 and docs/guide/integrations/prebid.md:109 still enumerate only cookie and html5. Please list all three accepted values and say that the combined option writes to both stores.


/// Source Prebid sends `SharedID` under, and the one the server stores and
/// sends it under.
pub const SHAREDID_SOURCE: &str = "pubcid.org";

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.

R11 · Keep one source constant and narrow the helper API

settings.rs already defines SHAREDID_DEFAULT_SOURCE. Keep that API, reuse its value here, and narrow the visibility of the constants and helpers used only by core. Keep the request and storage API needed by the adapters and provider crate public.

Suggested change
pub const SHAREDID_SOURCE: &str = "pubcid.org";
pub(crate) const SHAREDID_SOURCE: &str = crate::settings::SHAREDID_DEFAULT_SOURCE;

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.

SharedID cleanup: legacy path, cross-source dedupe, re-filing, SID-6 gate, template-cache deny list

4 participants