Skip to content

Stop pull sync from re-calling a partner for a full row - #1639

Open
dhruv8sh wants to merge 16 commits into
feat/s2s-eid-collection-providersfrom
fix/pull-sync-full-row
Open

dhruv8sh wants to merge 16 commits into
feat/s2s-eid-collection-providersfrom
fix/pull-sync-full-row

Conversation

@dhruv8sh

Copy link
Copy Markdown
Collaborator

Summary

  • When an EC row is at the 16 KiB cap, a pulled partner UID cannot be stored, so every navigation called the partner again and threw the answer away. Pull sync now skips a partner while the row has no room for its UID.
  • The partner becomes eligible again once expired IDs are pruned and the row has room. Batch sync's row_full already refused full rows without retrying, so the two now match.

Changes

File Change
crates/trusted-server-core/src/ec/coordinator/mod.rs Each pull-sync partner gets a byte reserve for the longest accepted UID (512 bytes); due_sources reports the source as NotDue when the row size plus the reserve exceeds MAX_ENTRY_BYTES. Tests: pull_sync_does_not_recall_a_partner_for_a_full_row, pull_uid_reserve_covers_the_longest_pulled_uid.
crates/trusted-server-core/src/ec/write_plan.rs serialized_len and member_len become pub(crate) so the coordinator can measure rows.
docs/guide/edge-cookies.md, docs/superpowers/specs/2026-10-30-s2s-eid-collection-design.md Describe the full-row rule in the pull sync section and the row size cap.

Known limit: the reserve assumes the UID needs no JSON escaping, so a UID made mostly of escaped characters could still be called once and then not fit.

Closes

Closes #1551

Spec

Not a feature (bug fix; follow-up from #1487, design in docs/superpowers/specs/2026-10-30-s2s-eid-collection-design.md).

Test plan

  • cargo test-fastly && cargo test-axum (also test-cloudflare, test-spin)
  • cargo clippy-fastly && cargo clippy-axum (also clippy-cloudflare, clippy-spin-native)
  • cargo fmt --all -- --check
  • JS tests: cd crates/trusted-server-js/lib && npx vitest run (no JS changes)
  • JS format: cd crates/trusted-server-js/lib && npm run format (no JS changes)
  • Docs format: prettier on the changed markdown
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve

Checklist

  • Feature PRs: spec linked above, ending in a review log of two or more agent review rounds (not a feature)
  • 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

A pull-sync partner's empty source on a row too full to take its UID was looked up on every navigation: the write planner dropped the UID for size, the source stayed empty and the EC ID went to the partner again. Pull sync now reserves the bytes its longest UID adds to a row and treats a source as not due when the row lacks that room, so the partner is not called until pruning frees space. This matches batch sync, which refuses the same row with row_full and is not retried.

Closes #1551.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
The edge cookies guide now says pull sync skips a partner whose empty source has no room left on the EC row, matching the design spec and the coordinator.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
Keep PR #1489's EC-hash wording for the pull-sync rate limit and this PR's full-row note in the edge cookies guide.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
@dhruv8sh dhruv8sh self-assigned this Nov 20, 2026
@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 linked an issue Nov 20, 2026 that may be closed by this pull request
3 tasks
@dhruv8sh
dhruv8sh marked this pull request as ready for review November 20, 2026 09:12
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
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.

The merge had no conflicts.

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.
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 e0ddbdbe4, a merge of #1489's new head 27651119e. It brings #1489's 30-day cap on mirrored UID expiry and the request time passed into finalize, #1488's hashed-email intake and ortb2.user.ext.eids forwarding, and #1506's repin of EdgeZero to rc/identity at d063a8e7 with main's Fastly SDK upgrade (#1671). The merge had no conflicts.

ChristianPavilonis added a commit that referenced this pull request Nov 25, 2026
…r for a full row

Source: fix/pull-sync-full-row at e0ddbdb.

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

The cutoff stops pulls on the unchanged test fixture, but it can also block recovery once IDs expire and prevent pull from triggering the existing repair for legacy over-cap rows. Please address the capacity check before merging. R4–R7 are non-blocking.

cargo fmt --all -- --check, Prettier on both changed docs, and the diff whitespace check passed. Fastly CI passed the new tests on an identical source tree. Those tests do not exercise recovery after expiry or an actual write refusal.

Comment thread docs/guide/edge-cookies.md Resolved
let pull_uid_reserve = pull_sync.then(|| {
sources
.iter()
.map(|source| pull_uid_reserve(&id, 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.

R6 · Non-blocking: Size the reserve for the one supported pull source. This scans multiple sources and defaults to zero, but the shipped pull-sync builder requires exactly one (trusted-server-identity-providers/src/pull_sync.rs:51–54). Use the validated single source rather than taking the maximum of source sizes. Other provider kinds can still claim multiple sources.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this one as is. The one-source rule lives in the pull-sync builder in trusted-server-identity-providers. Core's register only sees a kind string and a parsed source list, so taking the maximum keeps the reserve correct if that rule is ever relaxed. It costs one small serialization per source, once at startup. The unwrap_or(0) default is never used. Core's provider validation (ec/provider.rs) rejects an empty source list, and with no sources due_sources would have nothing to check anyway.

Takes #1489's new head 8e5642b, 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 fcdb9e80c, a merge of #1489's new head 8e5642b36, 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.

Pull sync now skips a pull-sync source when the stored row plus a fixed 512-byte UID reserve would pass MAX_ENTRY_BYTES, so a full row stops calling the partner on every navigation. The approach fits #1551, but the capacity check sizes the row differently from the write planner. The current head (fcdb9e80c) only merges #1489 since the last review, and the coordinator, write-plan and guide changes are identical to e0ddbdbe4. So the R1–R3 threads still apply. I'm requesting changes on the same grounds and won't repeat them inline.

Blocking

🔧 R1 confirmed by running it: expired UIDs keep the gate shut. due_sources measures serialized_len(entry) on the stored row. plan_write first prunes expired UIDs and opt-outs and drops emptied records (write_plan.rs:65-73), and pruning only persists alongside a real change. I added a throwaway test in coordinator/mod.rs that fills a consented row with records whose UIDs expired at t=500 and reads it back through seeded_snapshot at now=1000:

  • stored row: 15,630 bytes; the same row after the planner's pruning: 82 bytes; reserve: 1,138 bytes
  • head: the partner is not called (sent=0), status Skipped(NotDue)
  • with the new guard disabled: the partner is called and the UID is kept (Found { kept: 1 })

any_due agrees with due_sources, so on Fastly the after-response phase can also skip the row read. If nothing else writes to the row, for example because the expired records belong to a disabled provider or to one that keeps answering NoMatch, the partner is never pulled again. The pull was the write that would have done the pruning. The same mismatch double-counts the source's own dead record, which the write would replace. The docs say "pulling resumes once pruning frees room", but this PR takes away the write that pruning depends on. Fix: measure the row as the planner will see it. Clone it, run the same prune steps (prune_expired, prune_opt_outs, retain non-empty) and leave out the source's current record. Ideally factor the prune steps out of plan_write so the two can't drift apart. Then add a regression on this fixture.

🔧 R2 and R3 still apply. I checked both against the source. When the base row is over the cap, enforce_size_cap drops the largest other records so that the triggering write lands (write_plan.rs:244-249). The new check rejects every row over the cap before that can happen. KvEntry.ids has skip_serializing_if = "BTreeMap::is_empty", so the first insertion costs ,"ids":{} on top of what member_len counts.

Non-blocking

R4–R7 are still open. The R5 wording fix in the guide is worth taking: "On Fastly that limit" now comes right after the byte-room sentence.

Verification

  • Pinned head fcdb9e80c, base feat/s2s-eid-collection-providers at 8e5642b36 (merge base = base tip).
  • cargo test -p trusted-server-core --lib ec:: at head: 626 passed.
  • Control: disabling the new guard makes pull_sync_does_not_recall_a_partner_for_a_full_row fail, so the new test does protect the skip.
  • Expiry probe as above. I removed it afterwards and changed nothing on the branch.
  • CI on head: 25/25 checks passing.

Takes #1489's new head e6c0e51, 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 6dcdf16ed.

Takes #1489's new head e6c0e51, 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.

…ull-row

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
Prune expired UIDs and opt-outs before checking whether a pull-sync UID fits, keep pulling for rows already over the cap so the planner's legacy trim can land the UID, and count the bytes the first ids member adds. Share the planner's prune steps so the two checks cannot drift.

Signed-off-by: dhruv8sh <dhruv8sh@proton.me>
PR #1489's new head brings the cascaded owner review fixes from #1525 and #1526. 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.

Approving so this isn't waiting on me, on the understanding that the comments below get handled before this reaches main.

My blocking R1 to R3 from last round are fixed (expiry, legacy over-cap repair, first ids member), and tests that fail on the old guard cover them. R5 and R7 are done, and R4 is done except one doc line, which I left inline. One gap from my old R1: the new tests check the lookup status but never that the pulled UID gets stored. That's the first inline comment.

On R6, your reasoning holds. Core only sees a kind string and a source list, and the one-source rule lives in the providers crate. I'm fine resolving that thread.

Questions, none blocking:

  • The skip reports Skipped(NotDue), the same as a held source, so operators can't see "row full" in status telemetry the way batch sync shows row_full. Worth a distinct SkipReason?
  • The reserve is about 1.1 KiB, so a row within that distance of the cap stops pulling even for partners with 40-byte UIDs. Rows full of never-expiring single-UID records stay unpulled for the row's lifetime. #1551 allowed this approach, I just want it to be a deliberate trade-off.
  • The PR description is stale for 42c770eac. It lists only the first two tests and the serialized_len/member_len visibility change, and leaves out prune_for_write, the over-cap rule and the first-member bytes.

1,
"should pull once the stored UIDs have expired"
);
assert!(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests stop at the lookup status and never check what the planner writes

The fix depends on has_room_for_pull agreeing with plan_write: if the gate says yes, the planner keeps the pulled UID. None of the new tests runs the planner. This test and the over-cap one (line 2562) assert LookupStatus::Found { kept: 1, .. }, which validation sets before any write is planned. has_room_for_pull_counts_the_first_ids_member compares against serialized_len, not the planner's keep decision. So a later change to enforce_size_cap or prune_for_write could desync the two and every test would still pass. It also leaves the "second navigation stores the pulled UID" part of my earlier R1 open.

Suggest passing the results to planned_change(&snapshot, &results) (line 4802) in the expiry and over-cap tests, and asserting the RowChange::Update entry has ids["ids.example.com"].uid == "p-1" and fits the cap. Plus one boundary pair with a 512-byte UID: with exactly the reserve free (+8 for an empty ids) the gate passes and the planned row keeps it, and with one byte less the source reports Skipped(NotDue).

/// A row already over [`MAX_ENTRY_BYTES`] was written before the cap; the
/// planner drops its largest other records so the pulled UID lands, so it
/// has room.
fn has_room_for_pull(pruned: &KvEntry, source: &str, reserve: usize) -> bool {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capacity rule lives here but mirrors private planner rules

This re-derives three things write_plan owns: the legacy over-cap rule (write_plan.rs:250), "the pulled record replaces the source's current one", and the JSON shape of an empty ids map (FIRST_IDS_MEMBER_BYTES). To do that, the PR widens serialized_len, member_len and prune_for_write to pub(crate). The last two rounds each found a new place where these copies disagreed with plan_write, and sharing the prune steps fixed only one of them. A change to enforce_size_cap would quietly change which rows pull sync skips, with the same failure modes as before this PR: a row that never pulls again, or a partner called on every navigation.

Suggest moving this and FIRST_IDS_MEMBER_BYTES into write_plan.rs next to enforce_size_cap, as one pub(crate) function like fits_provider_record(entry, source, record_len, now) -> bool that prunes internally. The coordinator keeps the reserve computation and one call, and the three helpers go back to private. If you'd rather keep it here, the boundary test from my other comment is the minimum guard.

fn pull_uid_reserve_covers_the_longest_pulled_uid() {
// Arrange
let coordinator = single_pull_sync_coordinator();
let reserve = coordinator.providers[0]

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.

Nit: duplicated test setup

This four-line reserve lookup repeats in four tests (also lines 2410, 2500 and 2535). has_room_for_pull_counts_the_first_ids_member rebuilds the record pull_uid_reserve builds, line for line (compare 1313-1321 with 2575-2585). pull_sync_does_not_recall_a_partner_for_a_full_row keeps its own fill loop even though full_row(Expiry::Never, reserve, false) now does that.

Suggest a pull_reserve(&coordinator) helper, a shared longest_pull_record(owner) used by both pull_uid_reserve and the test so the test measures what the reserve measures, and full_row in the full-row test.

}
}

/// The most bytes a pull-sync partner's record for `source` adds to a row.

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.

Nit: my earlier R4 asked to drop "the most bytes", since an escaped UID can exceed this. The field doc got fixed, but this one didn't.

Suggested change
/// The most bytes a pull-sync partner's record for `source` adds to a row.
/// Bytes a pull-sync partner's record for `source` adds to a row when it
/// holds the longest UID pull sync accepts and that UID needs no escaping.

PR #1489's new head brings wave B: #1506's merge of main ab5c24f (#1501, js_asset_proxy rewriter ordering) and its repin of EdgeZero to rc/identity 8a73c0978806, carried up through the chain. The merge is clean. Cargo.lock changes only the 10 EdgeZero package sources, now at 8a73c097; the codegen crate's nested Cargo.lock is unchanged.
@aram356

aram356 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Round 12 identity realignment: rc/identity is now at db7dce634, and EdgeZero is pinned to its rc/identity at 8a73c097. This branch fast-forwarded from 42c770eac to 622c3c773:

Each merge message says what it carries and how any conflict was resolved.

PR #1489's new head brings #1506's move of the five auction endpoint test requests from test-publisher.com to publisher.example.com, for the URL-host lint. The merge is clean.

@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

My R1–R3 from the last round are fixed at 90853d4ae. The room check now measures the row after the planner's pruning, keeps legacy over-cap rows eligible so the planner can trim them, and counts the bytes of the first ids member. The PR's own diff is byte-identical to 42c770eac; everything since is base-chain merges. Approving.

Verification

  • cargo test -p trusted-server-core --lib ec:: (native host): 633 passed.
  • Controls: measuring the stored row instead of the pruned one fails pull_sync_pulls_once_expired_uids_free_the_row. Returning false for an over-cap row fails pull_sync_pulls_for_a_row_over_the_cap.
  • Gate against planner, at the boundary: I ran a throwaway test that pulls a 512-byte UID with openrtb_atype = i32::MAX and passes the results to planned_change. With exactly the reserve free (1,138 bytes, or 1,146 with an empty ids), the partner is called and the planned row keeps the UID at exactly 16,384 bytes. With one byte less, the partner isn't called. So the gate and the planner agree to the byte today.

Non-blocking

  • 🤔 Christian's planner-coverage thread holds, and I confirmed it by running it. If enforce_size_cap gets one byte stricter (serialized_len(entry) + 1), all of the PR's coordinator tests still pass, but the planner drops the pulled UID at the boundary. That's the "partner called on every navigation" failure this PR fixes. The boundary test above catches that change and the FIRST_IDS_MEMBER_BYTES = 0 change. It's worth adding as a regression test, or moving the rule into write_plan.rs as Christian suggests.
  • 🤔 An escaped UID repeats the call; it doesn't happen just once. The description's known-limit note says such a UID "could still be called once and then not fit". The planner drops it, the source stays empty and the gate still sees room, so the partner is called again on every navigation, up to pull_sync_rate_limit. That's the same as before this PR and rare enough to leave. The description should say so.

CI Status

  • All 21 checks at 90853d4ae were pending when I reviewed. The PR's own diff is unchanged since 42c770eac.

prk-Jr and others added 3 commits December 2, 2026 14:17
… boundary

The pull-sync room check re-derives the planner's size rules, but no test
ran the planner, so a change to enforce_size_cap could desync the two
unnoticed. The new test pulls a 512-byte UID with the widest atype into
rows with exactly the reserve free and one byte less, with and without an
existing ids member, and asserts the planner keeps the UID whenever the
gate pulls.
An escaped UID can add more than the reserve, so "the most bytes" overstated
what pull_uid_reserve measures.
PR #1489's new head brings #1506's repin of EdgeZero to rc/identity ef5cbf30, which renames Fastly backends to ez_b31v2_* and moves the yanked pin-project-lite, chacha20 and spin. The merge is clean. Cargo.lock changes only the EdgeZero package sources (now ef5cbf30) and the yanked pin-project-lite, chacha20 and spin; the codegen crate's nested Cargo.lock is unchanged.
aram356 added a commit that referenced this pull request Dec 3, 2026
PR #1540's new head brings the identity chain's commits since #1667 last merged it at afc4f5d, including the EdgeZero repins up to rc/identity ef5cbf30, which renames Fastly backends to ez_b31v2_* and moves the yanked pin-project-lite, chacha20 and spin, main's #1501, #1525's plain HTTP opt-in for auction providers, and this round's owner commits on #1535, #1613, #1616, #1617, #1625, #1627, #1635, #1637 and #1639.

Cargo.toml and crates/trusted-server-adapter-axum/Cargo.toml: #1667 pinned EdgeZero at d063a8e7, and the chain now pins rc/identity ef5cbf30, which keeps the client certificate API #1667 uses. The files merge cleanly to the chain's pin, so #1667 no longer carries its own.

crates/trusted-server-core/src/auction/mod.rs: #1501 from main, which the chain carries, moved the APS provider test literal into the shared aps_provider_map helper, and #1667 added `mtls: false` to that literal. The resolution calls the helper and adds `mtls: false` to it.

docs/guide/auction-orchestration.md: #1525 reworded the endpoint and allow_insecure_http rows of the provider field table, and #1667 added the mtls row below them. The resolution keeps #1525's rows followed by #1667's mtls row.

docs/guide/configuration.md: #1525 added the allow_insecure_http row to the provider field table and the plain HTTP warning after the loopback exception, and #1667 added the mtls row and the note that an mtls provider needs an https endpoint. The resolution keeps #1525's table with #1667's mtls row last, and #1525's warning followed by #1667's note.

docs/guide/error-reference.md: #1616's owner commit replaced "TLS is always verified" with the adapter and platform TLS policy wording, and #1667 added the outbound client identity bullet after it. The resolution keeps #1616's wording followed by #1667's bullet.

crates/trusted-server-core/src/auction/plan.rs (semantic fix): #1525's 23e4bdd removed the local is_false helper from plan.rs and serializes allow_insecure_http through crate::settings::is_false, and #1667's mtls field still named the local helper. The mtls field now uses crate::settings::is_false too.

crates/trusted-server-adapter-axum/tests/native_ec.rs (semantic fix): #1536's 9d41f0f added an APS ProviderConfig literal to the Axum native EC tests, and #1667 added the required mtls field to ProviderConfig. The literal now sets `mtls: false`.

Cargo.lock matches #1540's new head: next to #1667's, it changes only the EdgeZero package sources (d063a8e7 to ef5cbf30) and the yanked pin-project-lite, chacha20 and spin; the codegen crate's nested Cargo.lock is unchanged.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 15 identity realignment: rc/identity is now at 391a08578, and EdgeZero is pinned to its rc/identity at ef5cbf308. This branch fast-forwarded from c99d73a86 to 05e3e6669:

Each merge message says what it carries and how any conflict was resolved.

PR #1489's new head brings #1487's change that strips `ts-eids` from publisher-origin requests unless the operator opts in. The merge is clean.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 17 identity realignment: rc/identity is now at 0ed862633, and EdgeZero stays pinned to its rc/identity at ef5cbf308. This branch fast-forwarded from 05e3e6669 to 52f303822:

Each merge message says what it carries and how any conflict was resolved.

@aram356

aram356 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Merged #1614's /_ts/ local answers (48930c270) into this branch as 4fa1ff034, on top of 52f303822.

Trusted Server owns the /_ts/ namespace (#1740). A request for /_ts or any /_ts/ path that no route handles now gets a local 404 on Fastly, Axum, Cloudflare and Spin, and never reaches the publisher origin. The path is matched after percent-decoding. Paths outside the namespace, such as /_tsx or /articles/_ts/x, still go to the publisher origin, and every routed /_ts/ path answers as before.

This merge takes #1489's new head (8c5a63ff5), which carries 48930c270 and nothing else new to this branch. It was clean.

Checks on this head: no conflict markers; cargo fmt --all -- --check passes; the merge adds exactly #1614's change to this branch's files; it merges cleanly with every lower head in its stack. rc/identity (e72407155) passed the full CI gate list with the change.

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.

Stop pull sync from re-calling a partner for a row that is full

4 participants