Skip to content

Keep stable UIDs for up to 365 days - #1733

Draft
jevansnyc wants to merge 3 commits into
feat/1598-ec-route-fastlyfrom
feat/stable-id-max-age
Draft

jevansnyc wants to merge 3 commits into
feat/1598-ec-route-fastlyfrom
feat/stable-id-max-age

Conversation

@jevansnyc

@jevansnyc jevansnyc commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A stable ID (a SharedID, or a pull-sync partner's ID for the EC) is bounded to 30 days in the EC row and on the __Host-ts-eids-mirror cookie, like a vendor token. A publisher using Trusted Server for identity only loses it from the page after a month, although the row lasts a year.
  • Add uid_lifetime_days (1 to 365) on [[ec.partners]]. A source with a lifetime keeps each provider-written UID that long from the write and uses the lifetime as its mirror cap.
  • Without the setting, the sources of an enabled sharedid provider, and a pull-sync partner's source that no enabled provider owns, default to 365 days. Every other source behaves as before.

Based on feat/1598-ec-route-fastly (#1662), the top of the identity chain. The new type in settings.rs sits away from the code #1655 adds, so the two merge into rc/identity without a conflict.

Draft for discussion. It overlaps with #1548 and #1715, which bound every provider UID to 30 days from acquisition. The spec's "Related work" section proposes how the two fit together (make that maximum per source). This should not merge before that is agreed with their authors.

Changes

File Change
crates/trusted-server-core/src/settings.rs UidLifetimeDays (validated 1 to 365) and the optional uid_lifetime_days key on EcPartner.
crates/trusted-server-core/src/ec/registry.rs PartnerConfig::uid_lifetime(): the configured value, else 365 days for a stable source, else none. PartnerRegistry::mark_stable_uids.
crates/trusted-server-core/src/ec/coordinator/validate.rs A source's lifetime replaces a relative expiry; an exact vendor expiry still applies when earlier; an expired UID is not revived; the refresh time keeps its 30-day clamp.
crates/trusted-server-core/src/ec/mirror.rs The exp cap is computed per partner from its lifetime, else 30 days.
crates/trusted-server-identity-providers/src/lib.rs partner_registry marks the sources of an enabled sharedid provider as stable.
crates/trusted-server-core/src/ec/finalize.rs Doc comment only.
9 test fixtures (ec/*.rs, auction/endpoints.rs, adapter-fastly/src/post_delivery.rs) uid_lifetime_days: None in hand-built EcPartner literals.
docs/guide/configuration.md, docs/guide/edge-cookies.md, trusted-server.example.toml, CHANGELOG.md Document the key, the stable defaults and the mirror cap. The sharedid "Kept for" entries now match the code.
docs/superpowers/specs/2026-12-03-stable-uid-lifetime-design.md New spec.
docs/superpowers/specs/2026-10-30-s2s-eid-collection-design.md Two update notes pointing at the new spec.

Behaviour change on upgrade: a deployment with an enabled sharedid provider keeps SharedID UIDs for 365 days (was 30), and a mirrored pull-sync UID carries a 365-day exp (was 30). uid_lifetime_days = 30 on the partner restores the earlier period.

Closes

Closes #1739

Related: #1548, #1715, #1594.

Spec

Spec: docs/superpowers/specs/2026-12-03-stable-uid-lifetime-design.md

The spec has no agent review rounds yet. Its review log says so.

Test plan

  • cargo test-fastly && cargo test-axum
  • cargo clippy-fastly && cargo clippy-axum
  • cargo fmt --all -- --check
  • JS tests: cd crates/trusted-server-js/lib && npx vitest run
  • JS format: cd crates/trusted-server-js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other: see below

Run locally and passing:

  • cargo test -p trusted-server-core -p trusted-server-identity-providers --target x86_64-unknown-linux-gnu --lib (3964 and 137 tests on the Verify EC route acceptance on Fastly and cap mirrored expiry #1662 base)
  • cargo test-axum
  • cargo clippy-fastly, cargo clippy-axum, cargo clippy-cloudflare, cargo clippy-spin-native, cargo clippy-cli
  • cargo fmt --all -- --check, cd docs && npm run format, root markdown prettier check
  • scripts/lint-wasm-clock.sh, scripts/lint-core-block-on.sh

Not run locally, left to CI: cargo test-fastly and cargo test-fastly-reuse (no Viceroy in the environment used), cargo test-cloudflare, cargo test-spin, the wasm clippy variants for Cloudflare and Spin, the parity integration test, the WASM release build, and the JS suite (no JS change).

Checklist

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

Generated by Claude Code

@aram356

aram356 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

@jevansnyc Please don't stack on top rc branch this should target of one down stream PRs or main

jevansnyc and others added 2 commits December 4, 2026 10:04
A stable ID such as a SharedID or a pull-sync partner's ID is bounded to
30 days in the row and on the mirror, like a vendor token. The spec gives
a source a UID lifetime of its own, from 1 to 365 days, with 365 as the
default for stable sources, and records how it should meet the finite
lifetime work in #1548 and #1715.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PtcLmGQyykYkNRTJ5G9Ydb
Validation clamped every provider-stated expiry to 30 days and the
mirror capped every UID's exp at 30 days, so a SharedID or a pull-sync
partner's ID left the page after a month although its EC row lasts a
year.

Add uid_lifetime_days (1 to 365) on [[ec.partners]]. A source with a
lifetime keeps each provider-written UID that long from the write and
uses the lifetime as its mirror cap. A relative expiry is replaced; an
exact vendor expiry still applies when earlier; an expired UID is not
revived; the refresh time keeps its 30-day clamp.

Without the setting, the sources of an enabled sharedid provider, and a
pull-sync partner's source that no enabled provider owns, default to
365 days. Every other source is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PtcLmGQyykYkNRTJ5G9Ydb
@jevansnyc
jevansnyc force-pushed the feat/stable-id-max-age branch from e49e18c to ccefdf4 Compare December 4, 2026 19:23
@jevansnyc
jevansnyc changed the base branch from rc/identity to feat/1598-ec-route-fastly December 4, 2026 19:23
@jevansnyc

Copy link
Copy Markdown
Collaborator Author

@aram356 Retargeted to feat/1598-ec-route-fastly (#1662) and rebuilt the branch on it. That is the lowest branch in the chain with everything this touches: the provider-owner field from #1626 and the edge-cookies passage from #1662.

One thing for the rc/identity merge: the new UidLifetimeDays type in settings.rs is placed away from where #1655 adds MaxAgeDays, and a trial three-way merge of that file against rc/identity came back with no conflicts.


Generated by Claude Code

@aram356

aram356 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Merged #1614's /_ts/ local answers (48930c270) into this branch as 71a98ff81, on top of ccefdf479.

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 #1662's new head (1e8c9997f), 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; clippy-fastly, clippy-axum, clippy-cloudflare and clippy-spin-native pass. 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.

2 participants