Repository navigation
Conversation
Define the browser half of the EC route: consent capture from the publisher's TCF and GPP CMPs, the request contract the server route must accept, in-order delivery that never drops or reorders a withdrawal, merging route answers into identity-mode auctions and copying a localStorage SharedID opt-out into its cookie. The server route (#1598) injects the route path that turns this on.
The Prebid integration observes the publisher's TCF and GPP CMPs and posts each decision to the injected same-origin EC route, one call at a time and in order. A newer grant replaces a waiting grant, but a possible withdrawal is never replaced or dropped, so it reaches the server after any grant in flight and before any later grant. In identity mode the route's answer is merged into publisher auctions while the mirror cookie is unchanged, and nothing is merged while a possible withdrawal is pending. Reporting stays off until the server injects the route path. In both modes a localStorage SharedID opt-out is copied into the _pubcid_optout cookie the server honors, using Prebid's own rule. GPP capture moves in from the Sourcepoint consent extraction (#1535) with its tests. The served shim grows by 11 KB, so its size guard rises.
A known TCF withdrawal whose TC string cannot be sent queues nothing, so the grant already in flight lifted suppression when it was answered and its late mirror reached the next auction. Such a withdrawal now fences suppression: only an answer to a call queued after it lifts it. A repeated withdrawal that is already queued does not fence, so its own answer still lifts suppression. Also remove two members only tests used and make the no-route preservation test cover auction mode too.
A known withdrawal with an unsendable TC string but a valid GPP reading was sent without its TCF part, so the server answered from the stale euconsent-v2 cookie and that answer lifted suppression. Fence whenever the withdrawal's TCF reading cannot be sent, stamping its own call before the fence. After a fence, a reading equal to the last call is sent again, so an unchanged later reading can still lift suppression.
A grant sent after a fence that then failed left the older answered state deduplicating the next identical reading, so merging stayed suppressed for the rest of the page view. A fence now forgets the last answered state instead of flagging repeats, and an identical fenced withdrawal that is already pending or answered no longer re-fences and resends. The spec's contract, ordering and merging sections state the fence rules.
Skipping the fence for a withdrawal whose GPP-only body matched an earlier call let that call's answer, built from the stale euconsent-v2 cookie, lift suppression. A known TCF withdrawal with an unsendable TC string now makes no call at all and only fences, so there is no cookie-based answer to trust and no repeat rule to get wrong.
When an unchanged reading followed an unsendable withdrawal while the identical call was still waiting or in flight, the reading was deduplicated without a new stamp, so that call's answer could not lift suppression for the rest of the page view. Re-stamp the pending call: its answer reflects the current reading.
9 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_pubcid_optoutinto the_pubcid_optoutcookie the server honors (SID-2), using Prebid's own rule.Stacked on #1620 (identity-only mode, #1594), targeting
feat/1594-identity-only-tsjs; it must land first.The server route does not exist yet. #1598 (T19) has no implementation on any branch and is itself blocked by #1591, #1592, #1593 and #1600. Reporting stays off until the server injects
window.__tsjs_prebid.ecRoute, which this PR leaves to T19, so no deployment calls a missing route. The spec's request contract is what T19 must accept, including injectingecRoute, which #1598's text does not mention yet.What changes for existing deployments
_pubcid_optoutnow gets a host-only_pubcid_optout=1cookie and a_ts_pubcid_optout_src=lsmarker. The copy is removed when the localStorage opt-out ends; a publisher-written cookie is left alone. Auction mode previously wrote no cookie from tsjs.pubcid.orgIDs are dropped from auctions while either opt-out is present.Changes
crates/trusted-server-js/lib/src/integrations/prebid/tcf_reader.ts__tcfapiwithout installing an accessor; resubscribe on replacement; remove a superseded stub subscription through the CMP that now holds it.crates/trusted-server-js/lib/src/integrations/prebid/gpp_capture.tsGppConsentCapturemoved unchanged from #1535 apart from log prefixes.crates/trusted-server-js/lib/src/integrations/prebid/consent_queue.tscrates/trusted-server-js/lib/src/integrations/prebid/ec_route.tscrates/trusted-server-js/lib/src/integrations/prebid/pubcid_optout.tscrates/trusted-server-js/lib/src/integrations/prebid/identity.tscrates/trusted-server-js/lib/src/integrations/prebid/index.tsecRoutevalidates, and the identity-mode merge source.crates/trusted-server-js/lib/test/integrations/prebid/*.test.tsinstallPrebidNpmin both modes.crates/trusted-server-js/lib/test/prebid-artifact-integration.test.mjsdocs/guide/integrations/prebid.mddocs/superpowers/specs/2026-11-18-ec-route-consent-script-design.mddocs/superpowers/plans/2026-11-18-ec-route-consent-script.mdCloses
Part of #1599; does not close it. Its acceptance criteria that need the route's
Set-Cookie, record, provider and Safari behavior (on Fastly and on Axum behind CloudFront) can only pass once #1598 lands. The browser-side criteria (ordering, withdrawal during an in-flight grant leaving no ID in Prebid, the localStorage opt-out copy) are covered here against a controlled responder.Spec
Spec: EC route consent script, with four agent review rounds and an implementation review in its log.
Test plan
cargo test-fastly && cargo test-fastly-reuse && cargo test-axum && cargo test-cloudflare && cargo test-spin(Fastly under the pinned Viceroy 0.21.0)cargo fmt --all -- --checknpx vitest run— 87 files, 3,413 testscargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1Runtime results, identical on Axum and Fastly:
ecRoute): identity mode makes no route call and still merges the mirror cookie into the auction; auction mode makes no route call and keeps itstrustedServerbidder. An active localStorage opt-out produces_pubcid_optout=1and the marker (host-only,Secure,SameSite=Lax), the next navigation request carries them, removing the localStorage item removes both on reload, and a publisher_pubcid_optout=pubcookie is left alone.ecRouteand a controlled responder standing in for EC route in the shared app, verified on Fastly #1598: a grant sends exactly onePOSTwith{"tcString":…}and the pageOrigin, and the next auction carries the route's ID. With grant A held in flight, withdrawal B and grant C arrive A, B, C with at most one call in flight; B expires the mirror at once, and auctions run while B or C is pending carry no mirror or route IDs even though A's late answer re-set the mirror. After C is answered the route's ID returns. WithecRouteabsent the same CMP sequence sends nothing. While opted out,pubcid.orgentries are dropped from mirror and route IDs.Set-Cookie, Safari's cookie lifetime, real CMPs, GPP CMP readings, failing or timed-out route answers, BFCache, and HTTPS deployments.Checklist
unwrap()in production code — useexpect("should ...")logmacros (notprintln!)🤖 Generated with Claude Code