Repository navigation
Conversation
The Prebid shim adds a trustedServer bid to every ad unit whatever [auction].enabled says, so it would keep sending POST /auction and log a bidder failure on every 404. The design now has the server flag the auction state in the injected Prebid config and the shim drop its bid when the auction is off. It also records that Fastly can still sync cookie EIDs on a turned-off /auction and adds TESTING.md and the Prebid guide to the docs to update.
Plans the shared turned-off 404 helper, the five handler gates, the adapter and parity route tests, the injected auctionEnabled flag that stops the Prebid shim calling /auction, and the docs and changelog updates for #1669.
The spec now matches the plan: the two trace tests move to the consent-denied branch, which keeps their policy_skipped assertions, and the Prebid test it names is the kill-switch test. The changelog entry covers the Prebid shim. The plan adds the auction deadline fixtures to the final gate run, gives Fastly its own turned-off settings, names the parity request helpers, and records which browser fixtures run with the switches off.
Narrow the no-body-read guarantee to the handler, since EdgeZero ingress buffers bodies before routing. Keep Fastly request filters ahead of the switch and document it. Mark the turned-off 404 terminal-private so late Fastly filter headers cannot make it cacheable, with a send-boundary test. Treat adUnitCodes: [] as every global ad unit, as Prebid does, and run the refresh regression through the shim. Restore every AGENTS.md gate in the final run, add the deadline fixture Clippy runs, and add the auction orchestration and DataDome guides to the docs work.
Removing trustedServer bids misses a publisher alias of the adapter, because Prebid copies the adapter spec for an alias and snapshot-backed refresh keeps the alias as browser demand. The plan now has buildRequests return no requests while the injected flag is off, with alias and refresh tests. It also keeps the handler qualifier in the TESTING.md wording, limits the DataDome note about cached pages to Prebid callers, and describes which browser specs rely on endpoints that stay on.
aram356
left a comment
There was a problem hiding this comment.
REVIEWER: REQUEST_CHANGES
GitHub blocked this review event: the REQUEST_CHANGES submission returned HTTP 422 "Review Can not request changes on your own pull request", because the acting login is the PR author. This COMMENT review carries the same verdict and findings. It is not an approval.
- Reviewed head:
468873720, against basedb36dc0ec(main). Phase: implementation. - Account mode: one account. The acting login is the PR author's.
- Planning gate: the spec and plan were not approved in a separate planning PR, because the user asked for spec, plan and implementation in this one PR. I reviewed the implementation against the spec at this head.
- Scope: the diff changes runtime Rust, TypeScript, tests, docs and the example config. It is not documentation-only, so I ran the full prescribed suite.
Findings
There are four should-fix findings and six nits, each in its own thread.
Should-fix:
- On Fastly, a turned-off
POST /auctionstill authorizes EID persistence (auction/endpoints.rs:139). - The non-streaming proxy path still writes URLs for endpoints that are turned off (
creative.rs:1177). - The adapter and parity tests lost their default-config coverage (
adapter-axum/tests/routes.rs:41). docs/guide/first-party-proxy.mdstill describes the endpoints as always on (anchored atapi-reference.md:74).
Nits:
- the walkthrough is missing the auction-on precondition;
- the click debug line names a key that may be unset;
- the Fastly test message overclaims, and no route test checks
Content-Type; - the DataDome note isn't scoped to Fastly;
- the example TOML comment sits in the wrong place;
- the shim-size comment is stale.
Validation
Every check ran at 468873720, in my detached worktree .worktrees/review-1675-4688737, with this setup:
- macOS arm64,
rustc 1.98.1, Node 24.20.0,viceroy 0.22.0,spin 4.1.0. - The disk had 13 GiB free, so the cargo target dir is shared with the author's worktree. The fresh checkout rebuilt every workspace crate; the logs show
Compiling trusted-server-core v0.1.0 (.../review-1675-4688737/crates/trusted-server-core).
Each command exited 0.
| Command | Result |
|---|---|
cargo fmt --all -- --check; cargo fmt --manifest-path crates/trusted-server-integration-tests/Cargo.toml -- --check |
no output |
cargo clippy-fastly, clippy-axum, clippy-cloudflare, clippy-cloudflare-wasm, clippy-spin-native, clippy-spin-wasm, clippy-cli, clippy-codegen; cargo clippy --manifest-path crates/trusted-server-integration-tests/Cargo.toml --all-targets -- -D warnings |
no clippy warnings. The only warning: lines are the proc-macro-error2 v2.0.1 future-incompat note and the tsjs build info. |
cargo test-fastly |
7 test result: ok. lines: 3705 passed, 0 failed, 31 ignored |
cargo test-fastly-reuse |
test result: ok. 246 passed; 0 failed; 5 ignored |
cargo test-axum / test-cloudflare / test-spin |
61 / 58 / 97 passed, 0 failed |
cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity |
test result: ok. 30 passed; 0 failed |
npx vitest run (in crates/trusted-server-js/lib) |
Test Files 80 passed (80), Tests 3312 passed | 1 skipped (3313) |
npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false |
Tests 13 passed (13); shim characters: 52602 |
npm run lint and npm run format (JS); npm run format, npm run lint and npm run build (docs) |
All matched files use Prettier code style!; build complete |
docs/node_modules/.bin/prettier --config docs/.prettierrc --check "*.md" ".claude/**/*.md" ".github/**/*.md" "crates/**/*.md" "scripts/**/*.md" "tinybird/**/*.md" |
All matched files use Prettier code style! |
cargo test -p trusted-server-core --test template_build_digest; its cargo clippy ... -- -D warnings |
10 passed, 0 failed; no warnings |
scripts/lint-wasm-clock.sh |
exit 0 |
shellcheck scripts/docs-proposal/*.sh; node --test scripts/docs-proposal/hunks.test.mjs; scripts/docs-proposal/test.sh |
pass 20, fail 0; All documentation proposal script tests passed. |
cargo run --manifest-path crates/trusted-server-cli/Cargo.toml --target aarch64-apple-darwin --bin ts -- dev lint domains --changed-vs origin/main |
no findings |
node --test scripts/check-ci-node-pin.test.mjs; node scripts/check-ci-node-pin.mjs |
pass 30, fail 0; ok: 34 jobs in 10 workflows pin Node before compiling Rust |
node crates/trusted-server-adapter-fastly/tests/deadline-origin.mjs "$(command -v viceroy)" |
test result: ok. 5 passed; 0 failed |
Cloudflare and Spin deadline-runtime example builds and their cargo clippy ... -- -D warnings |
built; no warnings |
node scripts/test-worker-auction-deadlines.mjs spin --runtime "$(command -v spin)" |
5 PASS spin ... lines |
node scripts/test-worker-auction-deadlines.mjs cloudflare --runtime <wrangler 4.83.0> |
4 PASS cloudflare ... lines |
node --test scripts/release/phase1.test.mjs; shellcheck scripts/release/phase1-build.sh |
pass 27, fail 0 |
./scripts/test-cli.sh; cargo test --package trusted-server-openrtb-codegen --target aarch64-apple-darwin |
965 passed, 0 failed; 7 passed |
BID_DELAY=3 ./scripts/template-cache-local-test.sh with esi, inline and purge |
22 passed, 0 failed, 9 passed, 0 failed, 34 passed, 0 failed |
Setup problems on my side:
- The first Spin and Cloudflare deadline-runtime runs exited 1 with
failed to read component source from disk at path .../target/.... The script reads the repository'starget/directory, and my run created that link only after those runs. Both passed on rerun. - The Cloudflare run also needs the
Cargo.lockwasm-bindgen CLI (0.2.126) and CI'swrangler@4.83.0. I installed both into a scratch directory; this machine has 0.2.121 and 4.131.0.
Not run locally:
- The HTML EOF checks: this PR changes no publisher, HTML-processor or EOF code.
- The Docker integration and browser jobs.
GitHub CI reports all 30 checks passing at 468873720, including those. That is CI's result, not a run of mine.
| services: &RuntimeServices, | ||
| req: Request<EdgeBody>, | ||
| ) -> Result<Response<EdgeBody>, Report<TrustedServerError>> { | ||
| if !orchestrator.is_enabled() { |
There was a problem hiding this comment.
REVIEWER: should-fix On Fastly, a turned-off POST /auction still authorizes EID persistence, because the adapter sets it up before this gate runs.
Evidence, read at 468873720:
crates/trusted-server-adapter-fastly/src/app.rs:676callsec.ec_context.set_eid_sync_source(EidSyncSource::Auction);, and:677buildsPartnerRegistry::from_config(...)?. Both run beforehandle_auctionreaches this check.- With that source set,
ec/finalize.rs:79-111collects thets-eidsandsharedIdcookie EIDs for a returning, consented EC and callssync_eid_cookie_updates, which writes them to KV. - The adapter's own
filter_short_circuit_response_is_not_eligible_for_eid_persistence(app.rs:3679-3713) states the rule for requests that serve nothing: "No publisher page or auction was served, so the challenged request must not write EIDs". It assertseid_sync_source_of(&auction) == None. A turned-off/auctionserves no auction either. - The new text says the endpoint "calls no provider and emits no telemetry event" (
docs/guide/api-reference.md:201-202, andTESTING.md:128-129likewise). An operator reads that as the request doing nothing.
The spec keeps this as a call "open to review". As reviewer, I'd stop it: the switch is meant to turn the endpoint off.
Hypothesis, not run: the KV snapshot this loads also lets run_edgezero_pull_sync_after_send (main.rs:554, via build_pull_sync_context in ec/pull_sync.rs:86-91) send partner pull-sync requests after a turned-off answer.
- Check: in a Fastly
app.rstest, taketest_settings(), setauction.enabled = false, routebrowser_request(Method::POST, "/auction", "empty"), and asserteid_sync_source_of(&response) == None. Some(EidSyncSource::Auction)confirms the tag, and so the write path.Nonewithdraws this finding.
Correction:
- In the Fastly
Auctionarm, set the sync source and build the registry only whilestate.orchestrator.is_enabled(). Or return the turned-off answer before both. - Add the test above.
- If you keep the behaviour instead, say so in
api-reference.mdandTESTING.md, and name the possible pull sync in the spec.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b.
crates/trusted-server-adapter-fastly/src/app.rs: theAuctionarm now setsEidSyncSource::Auctionand buildsPartnerRegistry::from_configonly whilestate.orchestrator.is_enabled(). A turned-off/auctionreacheshandle_auctionwith no sync source and no registry, and gets the turned-off404.- New test
turned_off_auction_is_not_eligible_for_eid_persistence, the check you named:test_settings()withauction.enabled = false,browser_request(Method::POST, "/auction", "empty"), then404andeid_sync_source_of(&auction) == None. - The spec's call at line 90 now records the decision.
api-reference.md,TESTING.mdandCHANGELOG.mdsay a turned-off/auctionrecords none of the browser's EID cookies on Fastly.
Verification
- Before the fix, at
468873720plus the new test:cargo test -p trusted-server-adapter-fastly --target wasm32-wasip1 --bin trusted-server-adapter-fastly turned_off_auction_is_not_eligible_for_eid_persistenceexited 134. The wasm backtrace ends inassert_failed::<Option<EidSyncSource>>atapp.rs:2941, theeid_sync_source_of(&auction) == Noneassertion, after the status assertion passed. That confirms the finding. - After the fix, the same command with
dispatch_limits_returning_user_eid_sync_to_eligible_routesandfilter_short_circuit_response_is_not_eligible_for_eid_persistenceexited 0:test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 249 filtered out. The first still seesSome(EidSyncSource::Auction)with the auction on. - At head
5e5df5b1f:cargo test-fastlyexited 0: 7test result: ok.lines, 3708 passed, 0 failed, withturned_off_auction_is_not_eligible_for_eid_persistence ... ok.cargo test-fastly-reuseexited 0: 1test result: ok.line, 248 passed, 0 failed.
Pull sync, not tested. By reading only: with no sync source, the returning-user branch in ec/finalize.rs no longer calls sync_eid_cookie_updates, which is where this request loaded the KV snapshot that build_pull_sync_context (ec/pull_sync.rs:86) reads. I did not check every other place that could load it, and the route tests have no KV graph, so I make no pull-sync claim.
| /// turned-off `404`. Other proxy callers that do not stream, such as the | ||
| /// Google Tag Manager integration, still run it on HTML responses whatever | ||
| /// `rewrite_creatives` says. Asset rewriting is unconditional, and click |
There was a problem hiding this comment.
REVIEWER: should-fix This documents that non-streaming proxy callers still run the creative pass while rewrite_creatives = false. In that state, the pass writes URLs for the very endpoints this PR turns off, which the spec says cannot happen.
Evidence, read at 468873720:
proxy.rs:676-695(finalize_proxied_response) runsCreativeHtmlProcessoron anytext/htmlresponse andCreativeCssProcessoron anytext/cssone. Neither has arewrite_creativescheck.integrations/google_tag_manager.rs:917buildsProxyRequestConfig::new(target_url)without.with_streaming(), so GTM responses take that path.- With
rewrite_creatives = false, the pass writes/first-party/proxy?tsurl=asset URLs, and those now answer404. - With
rewrite_clicksunset,rewrites_proxied_clicks()istrue(auction_config_types.rs:197-199) while the click gate'srewrites_auction_clicks()isfalse. Links are wrapped to/first-party/click, and the click then gets the404.- The spec's switch table says it avoids exactly this wrap-then-404 case.
- It also contradicts the spec's "No other feature emits them" and "Proxied HTML only exists while
/first-party/proxyis on".
auction_rewrite_setting_does_not_change_proxied_html_or_css_rewriting(proxy.rs:4186-4227) asserts this output. The plan said to delete it;ead56f57bkept it. Its name, itsGET /first-party/proxyrequest and its messages describe a state that route can no longer reach.
The reach is narrow, by reading only: GTM answers with JavaScript, a GIF or a 204 on success. So only an upstream text/html or text/css answer, such as an error page, takes this pass.
Correction (preferred):
- Skip both creative processors in
finalize_proxied_responsewhile!settings.auction.rewrite_creatives./first-party/proxyalready needs that switch, so its behaviour doesn't change.- Any click wrapping that is left then always agrees with the click gate.
- Turn the kept test into one that asserts no
/first-party/URL appears. - Update this comment, the module doc (lines 44-49), the
CreativeHtmlProcessordoc (lines 1592-1601) anddocs/guide/configuration.md:2409-2411.
If you keep the behaviour instead:
- correct the spec's premise;
- rename the kept test after the GTM caller;
- file the follow-up issue the PR body lists, and link it here.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b, with the preferred correction.
proxy.rsfinalize_proxied_responseskips bothCreativeHtmlProcessorandCreativeCssProcessorwhile!settings.auction.rewrite_creatives. In that state the HEAD branch keeps the upstreamContent-Length, because a GET no longer rewrites the body.- Callers on this path, from a grep of
proxy_requestandstream_passthrough:/first-party/proxy, which already needs the switch, and the GTM integration (google_tag_manager.rs:917). testlight setsstream_passthrough = true, andhandle_asset_proxy_requestnever reaches the creative processors. - The kept test is now
creative_rewriting_off_passes_proxied_html_and_css_through_unchanged. Withrewrite_creatives = falseand eachrewrite_clicksofNone,Some(true)andSome(false), GET HTML and CSS come back byte-identical withContent-TypeandContent-Lengthkept, and HEAD keepsContent-Length. Its request path is/integrations/example/asset, not/first-party/proxy. proxied_html_click_wrapping_follows_explicit_rewrite_clicks, onmainbefore this PR, had threerewrite_creatives = falserows that asserted wrapping. Those rows are gone; it now coversrewrite_clickswhile the pass runs.- Docs: this comment, the module doc, the
CreativeHtmlProcessordoc,configuration.md(therewrite_clicksoverlay note: the leaf keeps today's behavior when it equalsrewrite_creatives),creative-processing.md, the Buffered note infirst-party-proxy.md, spec lines 13 and 61 plus a new acceptance criterion, andCHANGELOG.md.
Verification
- Before the fix the new test failed:
cargo test -p trusted-server-core --target aarch64-apple-darwin --lib -- proxy::tests::creative_rewriting_off_passes_proxied_html_and_css_through_unchangedexited 101 withassertion \left == right` failed: GET text/html; charset=utf-8 with rewrite_clicks=None: should keep the upstream Content-Length`. - After the fix:
cargo test -p trusted-server-core --target aarch64-apple-darwin --lib -- proxy::tests::exited 0,test result: ok. 155 passed; 0 failed. - At head
5e5df5b1f:cargo test-fastlyexited 0: 7test result: ok.lines, 3708 passed, 0 failed, withcreative_rewriting_off_passes_proxied_html_and_css_through_unchanged ... okandproxied_html_click_wrapping_follows_explicit_rewrite_clicks ... ok.
| [auction] | ||
| enabled = true |
There was a problem hiding this comment.
REVIEWER: should-fix Turning the auction on in the shared route settings leaves no adapter-level test of the default config. The new turned-off tests also can't tell which switch produced each 404.
Evidence from the diff:
- This adds
[auction] enabled = trueto the shared settings here. The PR does the same incrates/trusted-server-adapter-cloudflare/tests/routes.rs:49,crates/trusted-server-adapter-spin/tests/routes.rs:48andcrates/trusted-server-integration-tests/tests/parity.rs:60.- So the existing
first_party_*_is_routedtests andproxy_rebuild_get_route_paritynow all run with the auction on. - Before this PR they ran under the default, auction off.
- So the existing
- Every turned-off setup sets
enabled = falseandrewrite_creatives = falsetogether:turned_off_settings()here (:889-894) and inparity.rs:67-72,turned_off_router()in Cloudflare (:698-705) and Spin (:746-753), and the Fastlyturned_off_endpoints_answer_404_locally(app.rs:2877-2880). An adapter that gated/first-party/*onauction.enabled, or/auctiononrewrite_creatives, would pass all of them. - Only the core test
creative_endpoints_follow_their_switchescovers the spec's anti-goal "a default configuration loses a creative endpoint" and its criterion "the creative endpoints follow only their own switches", and it calls the handlers directly.
Correction: pick one.
- Keep the shared settings at the default, and give only the
/auctionrouted tests an auction-on copy. - Or add two cases per adapter and in parity:
- auction off with the default creative switches: each creative endpoint's body is not
ENDPOINT_TURNED_OFF_BODY, andPOST /auctionis turned off; - auction on with
rewrite_creatives = false:POST /auctionis not turned off.
- auction off with the default creative switches: each creative endpoint's body is not
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b, with the second option, in all four adapters and in parity.
- New
each_switch_turns_off_only_its_own_endpointsin Fastlyapp.rsand in the Axum, Cloudflare and Spintests/routes.rs, pluseach_switch_turns_off_only_its_own_endpoints_parityinparity.rs. - Each sends
TURNED_OFF_REQUESTSunder two settings:enabled = falsewith the default creative switches, which is the default auction config, andenabled = truewithrewrite_creatives = false./auctionmust answer the turned-off404exactly when the auction is off, and each creative request exactly whenrewrite_creativesis off. - "Turned off" means
404withENDPOINT_TURNED_OFF_BODY, so the "still on" side is decided by the body, never by the status alone. - The shared settings keep
enabled = true, so the existing routed/auctiontests keep exercising a running auction.
Mutation evidence. Each mutation ran against all five new tests, then the file was restored and the working diff hash checked identical to before:
handle_first_party_proxygated on!settings.auction.enabled: Axum, Cloudflare, Spin and parity exited 101 withGET /first-party/proxy with auction.enabled = false, rewrite_creatives = true: should follow only its own switch. Fastly exited 134 at that assertion (app.rs:2969).handle_auctiongated on!settings.auction.rewrite_creatives: the same five failed withPOST /auction with auction.enabled = false, rewrite_creatives = true: should follow only its own switch, Fastly with 134 atapp.rs:2969.
At head 5e5df5b1f
cargo test-fastlyexited 0: 7test result: ok.lines, 3708 passed, 0 failed, witheach_switch_turns_off_only_its_own_endpoints ... ok.cargo test-axumexited 0: 4test result: ok.lines, 62 passed, 0 failed;cargo test-cloudflareexited 0: 4test result: ok.lines, 59 passed, 0 failed;cargo test-spinexited 0: 3test result: ok.lines, 98 passed, 0 failed. Each raneach_switch_turns_off_only_its_own_endpoints ... ok.cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parityexited 0: 1test result: ok.line, 31 passed, 0 failed, witheach_switch_turns_off_only_its_own_endpoints_parity ... ok.
| For `/auction` and the four `/first-party/` creative routes, the predicate | ||
| names the switch that turns the endpoint on. The route stays registered while | ||
| its switch is off. Its listed methods then return `404` with the plain-text | ||
| body `This endpoint is turned off` and `Cache-Control: no-store, private`, and | ||
| the request never reaches the publisher fallback. Other methods on these paths | ||
| still go to the publisher fallback. On Fastly, an integration request filter | ||
| such as DataDome runs before routing, so its answer keeps precedence over this | ||
| `404`. | ||
|
|
There was a problem hiding this comment.
REVIEWER: should-fix docs/guide/first-party-proxy.md is the guide dedicated to these four endpoints. This PR doesn't update it, and it still describes them as always on. I've anchored the finding here, on the text that guide should link to, because the PR doesn't touch the file.
Evidence: at 468873720, grep -n "rewrite_creatives\|turned off\|404" docs/guide/first-party-proxy.md prints nothing. Its Core Endpoints, Configuration and Common Errors sections name no switch and no turned-off 404.
Correction:
- Add an availability line for each endpoint, or one note under Core Endpoints, giving its switch and the turned-off
404.- Link this section and Auction Configuration.
- Repeat the warning that creatives already on a page break once a switch is turned off.
- Add a
404 This endpoint is turned offentry to Common Errors.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b. docs/guide/first-party-proxy.md now has:
- under Core Endpoints, a table of each endpoint's switch, the turned-off
404with its body andCache-Control, links to Route availability and Auction Configuration, and a warning that creatives already on a page stop loading proxied assets or redirecting clicks once a switch is off; - a new Endpoint Turned Off entry in Common Errors;
- a Buffered note that HTML and CSS rewriting needs
rewrite_creatives = true.
Verification at head 5e5df5b1f: cd docs && npm run format exited 0 (All matched files use Prettier code style!); cd docs && npm run lint exited 0; cd docs && npm run build exited 0 (build complete in 6.68s.).
| Check the response and logs for these invariants: | ||
|
|
||
| - a disabled auction returns a no-bid response without provider dispatch; | ||
| - a disabled auction returns the turned-off `404` without provider dispatch; |
There was a problem hiding this comment.
REVIEWER: nit The walkthrough above this list never says to turn the auction on.
[auction].enableddefaults tofalse.- With this PR, the
curl --fail-with-body ... /auctionat lines 34-38 then exits non-zero on the turned-off404. Before the PR it got a200no-bid answer. - This PR adds exactly that precondition to
docs/guide/error-reference.md:699-700.
Correction: start line 30 with "Set [auction].enabled = true, configure each provider endpoint ...".
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b. Line 30 now starts "Set [auction].enabled = true, configure each provider endpoint to a controlled fixture, then send a Prebid-compatible request:".
Verification at head 5e5df5b1f: cd docs && npm run format exited 0 (All matched files use Prettier code style!); cd docs && npm run build exited 0 (build complete in 6.68s.).
| if !settings.auction.rewrites_auction_clicks() { | ||
| return Ok(endpoint_turned_off_response( | ||
| "/first-party/click", | ||
| "auction.rewrite_clicks", |
There was a problem hiding this comment.
REVIEWER: nit This can name a key the operator never set.
- With
rewrite_clicksunset andrewrite_creatives = false, the debug line reads "answering /first-party/click locally with 404 because auction.rewrite_clicks is off". - The gate is
rewrites_auction_clicks(), which isrewrite_clicks.unwrap_or(rewrite_creatives)(auction_config_types.rs:187-189). - The
endpoint_turned_off_responsedoc says the line names "the setting that turns it on". /first-party/proxy-rebuildhas the same problem at line 1944.
Correction: pass "auction.rewrite_clicks" only when rewrite_clicks.is_some(), and "auction.rewrite_creatives" otherwise.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b.
- A new private
auction_clicks_switch(settings)inproxy.rsreturns"auction.rewrite_clicks"whenrewrite_clicks.is_some(), and"auction.rewrite_creatives"otherwise. Both the/first-party/clickand the/first-party/proxy-rebuildgates pass it toendpoint_turned_off_response. - New test
auction_clicks_switch_names_the_setting_that_decides_click_wrappingcoversNone,Some(false)andSome(true).
Verification at head 5e5df5b1f: cargo test-fastly exited 0: 7 test result: ok. lines, 3708 passed, 0 failed, with auction_clicks_switch_names_the_setting_that_decides_click_wrapping ... ok.
| .extensions() | ||
| .get::<TerminalPrivateResponse>() | ||
| .is_some(), | ||
| "{label}: should reach the send boundary marked terminal-private" |
There was a problem hiding this comment.
REVIEWER: nit Two small gaps in the turned-off route tests.
- This message overclaims. It says the response reaches the send boundary, but the test only calls
route(&router, ...).edgezero_main's finalization andsend_edgezero_responsenever run. - No turned-off loop checks
Content-Type. None of the loops (this one, Axum, Cloudflare, Spin andturned_off_endpoints_parity) checksContent-Type: text/plain; charset=utf-8. The plan's Global Constraints list it together with the status, the body andCache-Control, and only the coreassert_endpoint_turned_offchecks it.
Correction:
- Reword this message to "should leave the router marked terminal-private".
- Add the
Content-Typecheck to each of those loops.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b.
- The message now reads "should leave the router marked terminal-private".
- Every turned-off loop now checks
Content-Type: text/plain; charset=utf-8: Fastlyturned_off_endpoints_answer_404_locally, the Axum, Cloudflare and Spinturned_off_endpoints_answer_404_locally, andturned_off_endpoints_parity.
Verification at head 5e5df5b1f
cargo test-fastlyexited 0: 7test result: ok.lines, 3708 passed, 0 failed, withturned_off_endpoints_answer_404_locally ... ok.cargo test-axumexited 0: 4test result: ok.lines, 62 passed, 0 failed;cargo test-cloudflareexited 0: 4test result: ok.lines, 59 passed, 0 failed;cargo test-spinexited 0: 3test result: ok.lines, 98 passed, 0 failed.cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parityexited 0: 1test result: ok.line, 31 passed, 0 failed, withturned_off_endpoints_parity ... ok.
| Auction traffic at `/auction` is protected by default. While | ||
| `[auction].enabled = false`, a protected `/auction` request still goes through | ||
| protection first. A challenge or block answers before the turned-off `404`, and | ||
| each such request can still cost one Protection API call. |
There was a problem hiding this comment.
REVIEWER: nit This paragraph isn't scoped to Fastly.
- Among the adapters, only
crates/trusted-server-adapter-fastly/src/app.rsusesIntegrationRequestFilter(rg -l IntegrationRequestFilter crates). - The new text at
docs/guide/api-reference.md:79-81says "On Fastly". - "each such request" also reads as challenged requests only. In fact any protected
/auctionrequest, allowed or not, can cost the verdict call.
Correction: "On Fastly, while [auction].enabled = false, a protected /auction request still goes through protection first. A challenge or block answers before the turned-off 404, and every protected request, allowed or not, can still cost one Protection API call."
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b, with your wording: "On Fastly, while [auction].enabled = false, a protected /auction request still goes through protection first. A challenge or block answers before the turned-off 404, and every protected request, allowed or not, can still cost one Protection API call."
Verification at head 5e5df5b1f: cd docs && npm run format exited 0 (All matched files use Prettier code style!); cd docs && npm run build exited 0 (build complete in 6.68s.).
| # Keep disabled until provider endpoints, routes, and profile values below are | ||
| # replaced with deployment-specific settings. | ||
| enabled = false | ||
| # While disabled, POST /auction is turned off and answers a 404. |
There was a problem hiding this comment.
REVIEWER: nit This line sits directly above the rewrite_creatives comment block with nothing between them, so it reads as that block's first line.
Correction: add a blank line after it. That fixes it without touching the [auction] ... enabled = false text that scripts/template-cache-local-test.sh:304-311 replaces.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b. A blank line now follows "# While disabled, POST /auction is turned off and answers a 404.", so it no longer reads as the first line of the rewrite_creatives block. The [auction] ... enabled = false text that scripts/template-cache-local-test.sh replaces is unchanged.
Verification at head 5e5df5b1f: BID_DELAY=3 ./scripts/template-cache-local-test.sh exited 0 for esi (22 passed, 0 failed), inline (9 passed, 0 failed) and purge (34 passed, 0 failed).
| // 11,676 characters (52,030 total). Keep a narrow guard: Prebid remains a separate artifact above 200 KB, and importing | ||
| // its runtime or private rendering helpers must still fail this regression. | ||
| expect(shimCode.length).toBeLessThan(52_500); | ||
| // Skipping the trustedServer bid and request while the auction is off adds | ||
| // about 140 characters, so the guard is 52.75 KB. | ||
| expect(shimCode.length).toBeLessThan(52_750); |
There was a problem hiding this comment.
REVIEWER: nit The comment's numbers don't support the new guard.
- By its own figures the shim is 52,030 characters. Adding about 140 gives 52,170, which is still under the old 52,500, yet the guard moved.
- My
npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=falseat468873720printed[trace-prebid-artifact] shim characters: 52602. That is 148 under the new guard, so the 52,030 figure is stale.
Correction: replace the stale total with the measured size, and say how much headroom the 52,750 guard leaves.
There was a problem hiding this comment.
CREATOR: fixed in 3ce2d715b, with the size updated again in 5e5df5b1f.
- The comment now gives the measured size instead of the stale 52,030 total, and says how much headroom the 52.75 KB guard leaves.
5e5df5b1falso makes the shim select ad units as Prebid does, which shrank it from 52,602 to 52,574 characters, so the comment now says 52,574 characters and 176 characters of headroom.
Verification at head 5e5df5b1f: npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false exited 0 and printed [trace-prebid-artifact] shim characters: 52574 and Tests 13 passed (13).
There was a problem hiding this comment.
CREATOR: fixed follow-up at 0f7792ecf. That commit drops the shim's handling of a single ad unit object, because real Prebid 10.26 rejects one too (TypeError: n.map is not a function), and the shim shrinks to 52,549 characters. The comment now says 52,549 characters and 201 of headroom under the 52.75 KB guard.
Verification at head 0f7792ecf: npx vitest run test/prebid-artifact-integration.test.mjs --reporter=verbose --silent=false exited 0 and printed [trace-prebid-artifact] shim characters: 52549 and Tests 13 passed (13).
- Set Fastly's /auction EID sync source and build its partner registry only while the auction is on, so a turned-off request writes no EIDs. - Pass HTML and CSS from proxy callers that do not stream through unchanged while rewrite_creatives is off, instead of writing URLs for turned-off endpoints, and keep Content-Length on HEAD in that state. - Add per-adapter and parity tests that each switch turns off only its own endpoints, and check Content-Type on every turned-off answer. - Name the setting that actually decides click wrapping in the click gates' turned-off log line. - Document the switches in the first-party proxy guide, record both review decisions in the spec, and fix the remaining doc nits.
The shim chose its ad units differently from Prebid 10.26's requestBids and filterAdUnits: a single adUnitCodes string selected every global unit, adUnitCodes did not narrow explicit adUnits, and a single ad unit object passed as adUnits made the shim throw before Prebid ran. Accept one unit or a list, fall back to pbjs.adUnits, and narrow by one code or a list unless adUnitCodes is absent or empty.
Prebid 10.26's requestBids rejects a single ad unit object passed as adUnits (TypeError: n.map is not a function), so wrapping one in the shim only added the shim's side effects before Prebid threw. Take explicit adUnits as given, as Prebid does, and drop the claim from the docs and the CHANGELOG.
PRfection phase: implementation
Closes #1669
Summary
When a switch is off, the endpoint it controls now answers a local
404withCache-Control: no-store, private, on every adapter:GET /first-party/proxy[auction].rewrite_creatives = trueGET,POST /first-party/sign[auction].rewrite_creatives = trueGET /first-party/clickrewrites_auction_clicks()(rewrite_clicks, orrewrite_creativeswhen it is unset)GET,POST /first-party/proxy-rebuild/first-party/clickPOST /auction[auction].enabled = trueUntil now the Prebid shim added a
trustedServerbid to every ad unit whatever[auction].enabledsaid. The server now tells it, through a newauctionEnabledflag in the injected config, when the auction is off. The shim then drops that bid and its bid adapter builds no request, so a disabled auction sends noPOST /auction, including through a publisher alias oftrustedServer.This PR holds the spec, the plan and the implementation. The spec and plan were first opened here for review on their own, and the implementation follows the plan task by task.
Documents
docs/superpowers/specs/2026-11-24-1669-creative-and-auction-endpoint-switches-design.mddocs/superpowers/plans/2026-11-26-1669-creative-and-auction-endpoint-switches.mdImplementation
http_util::endpoint_turned_off_responsebuilds the turned-off answer:404, bodyThis endpoint is turned off,Content-Type: text/plain; charset=utf-8;Cache-Control: no-store, privateplus the terminal-private marker;debuglog line.The five core handlers check their switch as their first statement and return that answer as
Ok:handle_first_party_proxy,handle_first_party_proxy_sign,handle_first_party_clickandhandle_first_party_proxy_rebuildinproxy.rs;handle_auctioninauction/endpoints.rs, where the check replaces the old disabled no-bid branch.The only adapter dispatch change is Fastly's
/auctionarm, which sets its EID sync source and builds its partner registry only while the auction is on, so a turned-off request writes no EIDs.Proxy finalization runs the creative HTML and CSS pass only while
rewrite_creatives = true. Proxy callers that do not stream, such as the Google Tag Manager integration, pass HTML and CSS through unchanged while it is off, instead of writing URLs for turned-off endpoints.The Prebid head injector adds
auctionEnabledfrom the compiled auction plan. While it isfalse, the shim leaves notrustedServerbid in any ad unit, and the adapter'sbuildRequestsreturns[], which also covers aliases. Its ad-unit selection now matches Prebid'srequestBids:adUnitCodes: []selects every global ad unit, a single code string narrows to that code, andadUnitCodesnarrows explicitadUnits.Docs and
CHANGELOG.md. One Breaking entry and one Fixed entry. The docs warn that creatives already on a page stop loading proxied assets or redirecting clicks once their switch is off. Thetrusted-server.example.tomlcomments say what each switch turns off.Two changes go beyond the plan:
auction_rewrite_setting_does_not_change_proxied_html_or_css_rewritingwas kept, then replaced. The plan said to delete it. It was kept because the Google Tag Manager integration proxies without streaming and still ran the creative pass whateverrewrite_creativessaid. Review round 1 made that pass followrewrite_creatives, and the test becamecreative_rewriting_off_passes_proxied_html_and_css_through_unchanged.prebid-artifact-integration.test.mjsmoves from 52,500 to 52,750 characters. The shim now measures 52,549 characters, which leaves 201 to spare. The guard still fails if Prebid's 200 KB runtime gets bundled.Tests
404./auctionanswers the404on an unparseable body and on an over-limitContent-Length, with no telemetry and no trace.policy_skippedassertions.turned_off_endpoints_answer_404_locallyon Fastly, Axum, Cloudflare and Spin checks status, body,Content-TypeandCache-Control. On Fastly it also checks the terminal-private marker.each_switch_turns_off_only_its_own_endpointson all four runs the default auction config andenabled = truewithrewrite_creatives = false, so each404is traced to its own switch.turned_off_auction_is_not_eligible_for_eid_persistenceon Fastly.late_filter_effects_cannot_make_a_turned_off_response_publiccovers late request-filter changes toCache-Control.POST /auction.turned_off_endpoints_parityandeach_switch_turns_off_only_its_own_endpoints_paritysend the same requests to Axum, Cloudflare and Spin.auctionEnabledtrue and false.adUnitCodesselection,adUnitCodes: [], aliases and GPT refresh.auctionEnabled: falseand atrustedServeralias, and sees no/auctionrequest. Its control without the flag sees one./first-party/proxyis gated onauction.enabledor/auctiononrewrite_creatives.Review round 1
Review 6101293433 raised four should-fix findings and six nits at
468873720.3ce2d715bfixes all ten, and each thread has a reply with its evidence. Two of the fixes reverse design calls the spec had recorded, and the spec now records the new ones:/auctionno longer records the browser's EID cookies.rewrite_creatives = false.5e5df5b1falso fixes the shim's remainingadUnitCodesdifferences from Prebid, which the earlier follow-up list named.0f7792ecfdrops that commit's handling of a single ad unit object, because real Prebid 10.26 rejects one too (TypeError: n.map is not a function). GTM's proxy path andfirst-party-proxy.md, the other two items, are fixed in3ce2d715b, so no follow-up is left.Calls for the reviewer to check
These are design calls the spec makes that nobody has confirmed yet:
/first-party/clickand/first-party/proxy-rebuildfollow click wrapping (rewrites_auction_clicks()), notrewrite_creativesalone.404./_ts/page-bidsand/__ts/page-bidsdo not change./auctionno longer emits theauction_disabledtelemetry event or the skipped server-side trace. Publisher page loads and/_ts/page-bidsstill record both.404carriesCache-Control: no-store, privateand the terminal-private marker. Fastly then restores the policy after late request-filter header changes./auctionrecords none of the browser's cookie EIDs, unlike today's disabled branch. Review round 1 decided this, and it is the one adapter dispatch change.trustedServerbid the publisher configured.auctionEnabledmeans the auction is on./auctionstill gets the verdict call, and a challenge answers before the404.requestBids, with the auction on as well as off.Process
superpowers:brainstorming: spec, approval gate and a cold builder read of the spec;superpowers:writing-plans: plan and self-review;superpowers:subagent-driven-development: implementation, with a review after each task and a whole-branch review at the end.CREATOR:orREVIEWER:.Validation
All local runs were at
0f7792ecfon macOS (arm64), with Viceroy 0.22.0, and every command exited 0. The same suite also passed at3ce2d715b, the review-fix commit, and at5e5df5b1f.cargo fmt --all -- --check, also for the integration-tests cratecargo build-fastly,build-axum,build-cloudflareand the Fastly release buildcargo test-fastlycargo test-fastly-reusecargo test-axumcargo test-cloudflarecargo test-spinnpx vitest runtemplate_build_digesttest and Clippyscripts/lint-wasm-clock.shts dev lint domains --changed-vs origin/mainscripts/test-cli.shtemplate-cache-local-test.sh(esi, inline, purge)The Cloudflare deadline runtime used the
Cargo.lockwasm-bindgen CLI (0.2.126) and CI'swrangler@4.83.0, installed in a scratch directory.The HTML EOF checks were not run locally, because this PR changes no publisher, HTML-processor or EOF code. CI runs them.
CI results for
0f7792ecfare reported by GitHub; earlier runs are not counted for this head.