Skip to content

Remember provider retry deadlines between navigations - #1712

Open
prk-Jr wants to merge 3 commits into
feat/s2s-eid-collection-corefrom
fix/1547-provider-retry-after
Open

prk-Jr wants to merge 3 commits into
feat/s2s-eid-collection-corefrom
fix/1547-provider-retry-after

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A provider miss or failed lookup currently writes no retry state, so an EC with no provider ID calls the vendor again on every permitted navigation. This change remembers the outcome on the EC row and skips the provider until its retry deadline expires.

Changes

File Change
crates/trusted-server-core/src/ec/kv_types.rs Add defaulted per-provider retry deadlines, named durations and shared deadline helpers.
crates/trusted-server-core/src/ec/coordinator/mod.rs Suppress providers until retry expiry, report skipped_retry_after, and add fake-clock/provider navigation regressions.
crates/trusted-server-core/src/ec/coordinator/results.rs Share outcome-to-retry-duration classification.
crates/trusted-server-core/src/ec/write_plan.rs Persist retry state with lower priority than IDs; test isolation, clearing, size bounds and near-full-row behavior.
crates/trusted-server-core/src/ec/after_response.rs Persist retry-only outcomes in the follow-up write.
crates/trusted-server-core/src/test_support.rs Scope an inherited large-response Clippy allowance to the intentional test-helper API.
docs/guide/configuration.md Document durations, size-cap priority and older-reader behavior.
docs/superpowers/specs/2026-10-30-s2s-eid-collection-design.md Update the retry contract and its compatibility/size-cap limits.

Closes

Closes #1547

Spec

Not a feature: bug fix following #1487. The existing collection design is updated to reflect retry memory.

Base and scope

Targets feat/s2s-eid-collection-core, starting at #1487 head 59161a541ab6d84bde085680c8726cdde52a5439. That PR introduces the coordinator and write planner affected by this bug. #1488 and #1489 do not already implement retry memory. Neither main nor rc/identity is the base or target.

Behavior

  • NoMatch records a one-hour per-provider retry deadline. HTTP 404/204 map to this outcome in the core framework at this base.
  • Request-build, transport, HTTP and response-parse failures, and timeouts, record five minutes instead.
  • Both page-load and after-response writes persist retry-only outcomes. A live retry deadline suppresses the provider's sources, including due refreshes; the provider becomes eligible at the exact deadline.
  • Success and fresh opt-out results clear that provider's retry state, respecting existing opt-out precedence. Skips never establish or renew it. Expired retry state is pruned alongside a real write.
  • Existing consent gates, EC attribution, conditional writes and row-size enforcement still apply. Expired IDs are still pruned. Retry metadata, including stored deadlines, is discarded before UID trimming under the size cap; a full row may therefore lose suppression, but a retry-only result cannot evict an ID.

Five minutes balances fewer repeated calls with recovery from transient outages. A known miss waits one hour to reduce repeated anonymous lookups, at the cost of delaying discovery of a newly available ID. These are distinct named durations, not new operator configuration keys.

The interim brake is the existing #1488 gate on #1547, documented here and already confirmed in the #1487 review thread. rate_limit_per_hour remains optional and unlimited by default. A new shared-IP default would change traffic budgets for unrelated ECs behind the same IP.

Schema compatibility

KvEntry.retry_after is a provider-ID-to-Unix-deadline map next to opt_outs, with serde(default) and omission when empty. Older rows deserialize with no retry state; the schema version is unchanged. Older readers ignore the unknown field and discard it when rewriting the row, so rollback or mixed-version writers lose suppression while rows remain readable.

Test plan

Review-fix commit: 4f9e5270aa07467a2cf3bd190d708b553ba7cae2. The committed files match the locally verified content. Rust 1.98.1 and Node 24.20.0 were selected; runtime fixtures used Viceroy 0.22.0 from this branch's .tool-versions, Spin 4.1.0 and Cargo.lock-matched wasm-bindgen 0.2.126.

  • Full local CI gate list in AGENTS.md: adapter lint/test matrix, cross-adapter parity, JS build/tests and formatting, docs/Markdown formatting, build-digest test/lint, wasm-clock lint, docs-proposal scripts, changed-line domain scan, Node pin guard, release scripts and response-diff tests.
  • Deadline fixtures: real Viceroy network fixture; Cloudflare and Spin fixture builds, lint and local-runtime execution.
  • Final targeted EC tests: 583 passed on native and WASM; JS: 3,311 passed; parity: 33 passed. Rust API docs and final formatting pass.
  • Regression controls: tests reject the original retry-only ID eviction and loss of a newly found ID. A disposable implementation that removed only new deadlines at the final eviction pass still failed the mixed-result regression. A separate test rejected clearing existing backoff when a retry-only result should cause no write.
  • Independent internal source review of the full PR plus final refinement: no material findings.
  • Hosted CI: all 25 checks passed on 4f9e5270aa07467a2cf3bd190d708b553ba7cae2.

The first sandboxed runtime attempt could not access system certificates or localhost. Those checks were rerun with the required local access and passed; no runtime gate was waived. Existing deliberately ignored tests remain ignored.

Earlier review and runtime evidence

Historical independent local review before review fixes: READY TO REQUEST REVIEW within the agreed targeted-check scope, with zero outstanding code or documentation findings. Its documentation precision finding was resolved by explaining the existing pruning/size-cap exception; the test-helper lint allowance was separately reviewed.

Local Axum verification used a separate integration worktree at native-identity head 6b4a5fdc0aca527eed1f8842eb7b87b89cca6cf8, with the core fix applied semantically. The #1487 Axum adapter itself rejects providers and lacks this identity wiring; none of the later native support is included in this PR.

A temporary ignored test served the real Axum application over localhost HTTP with persistent EC records and mocked origin/provider transport. The fictional provider at https://id.example.com/gs/v2/1234.json answered 204. With the same EC, vendor call counts across two document navigations and a third after expiry were 1, 1, 2, and the first two requests retained the same retry deadline. A two-second interval was supplied only through test-utilities configuration in that disposable integration copy; this PR retains the one-hour default. Disabling the retry guard in the disposable copy produced 1, 2, 3; restoring it confirmed 1, 1, 2 again.

This verifies the local Axum application/record flow with controlled upstream responses. It does not claim browser behavior, live vendor TLS/API validation or deployed behavior. No browser, remote proxy task, real credentials or operator configuration was used.

Checklist

  • Feature spec review rounds: not applicable to this bug fix.
  • Changes follow AGENTS.md conventions.
  • No unwrap() in production code.
  • Uses log macros rather than println!.
  • New behavior has regression tests.
  • No secrets or credentials committed.
  • Full adapter/JS/docs CI matrix: all 25 current-revision hosted checks passed.

@prk-Jr
prk-Jr marked this pull request as ready for review December 1, 2026 11:29
@prk-Jr prk-Jr linked an issue Dec 1, 2026 that may be closed by this pull request
4 tasks

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed c8467bc52 against feat/s2s-eid-collection-core (59161a541).

Approving so I'm not blocking, on the understanding that you'll handle the comments before merging. R1 is the one I care about. It brings back the per-navigation vendor calls this PR exists to remove, on near-full rows, and can cost a stored ID.

Also, "may remove stored IDs as before" in the description isn't quite right: these outcomes never wrote before, so they never removed anything.

Checks: focused core coordinator and write-plan tests plus the scratch reproduction described in R1.

Comment thread docs/guide/configuration.md Resolved

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

This PR adds a per-provider retry_after map to KvEntry. A NoMatch result sets a one-hour deadline, and failures or timeouts set a five-minute one. Both the page write and the after-response write persist it. due_sources suppresses the provider, refreshes included, until the deadline passes, and Found or a fresh OptedOut clears it. The backward-compatible serde default, the clearing and renewal rules, and the tests (fake clock, exact-expiry boundary, cross-provider isolation) are solid. One blocking problem remains: on a nearly full row, writing a retry deadline that only exists to save a vendor call can push the row over the size cap, and the cap then deletes a stored partner ID to make room.

Blocking

🔧 wrench

  • A retry-only write can evict stored partner IDs through the size cap: see inline at crates/trusted-server-core/src/ec/write_plan.rs:156

Non-blocking

⛏ nitpick

  • Internal PR-gating note in the user-facing configuration guide: see inline at docs/guide/configuration.md:983

Comment thread docs/guide/configuration.md Resolved

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.

Remember NoMatch and failed provider lookups to stop per-navigation vendor calls

3 participants