Skip to content

Remember provider retry deadlines between navigations - #1712

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

prk-Jr wants to merge 2 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 and named durations.
crates/trusted-server-core/src/ec/coordinator/mod.rs Suppress providers until retry expiry; 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, clear and prune retry state; test provider isolation, clearing and size bounds.
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, the vendor gate 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. Expiry pruning and size-cap eviction may remove stored IDs as before.

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

Commit: f26038fb085783bd1cbb802a24efb6cb53c47b06. Its committed diff exactly matches the reviewed and tested working-tree patch.

Rust 1.98.1 and Node 24.20.0 were selected for the completed local checks below. The full CI gate suite is left to GitHub Actions at the author's request; no local gates were rerun for publication.

  • Red phase: seven behavioral regression tests failed for missing retry persistence or ignored schema state; the legacy-row compatibility test passed.
  • cargo test --locked -p trusted-server-core --lib ec::: 581 passed. Covers 204/404 misses, HTTP/transport/parse errors, request-build errors, actual fake-clock timeout, next-navigation suppression, exact expiry, differing intervals, success/opt-out clearing, provider isolation, due refreshes, after-response commit followed by a navigation, legacy deserialization, no skip renewal, cleanup on unrelated writes and the row-size cap.
  • cargo clippy --locked -p trusted-server-core --all-targets --all-features -- -D warnings: passed. An inherited result_large_err warning required a function-scoped allowance on the test-only router helper that intentionally returns a complete response; its API and behavior are unchanged.
  • cargo clippy --locked -p trusted-server-core --lib --all-features --target wasm32-wasip1 -- -D warnings: passed.
  • Rust formatting, formatting of the two changed Markdown files and git diff --check: passed.

Independent review and runtime evidence

Independent local review: 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: current-revision hosted checks pass.

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

);
continue;
}
if let Some(seconds) = lookup.status.retry_delay_seconds() {

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.

R1 · P2: retry-only metadata can evict another provider's stored UID. Before this PR a NoMatch or failure never wrote. Now it adds a retry_after entry (about 40 bytes) and always plans an update. On a row within those bytes of MAX_ENTRY_BYTES, enforce_size_cap has nothing written or ingested this navigation to trim, so it falls through to drop_largest_records(entry, &mut size, |_| true) (line 265) and deletes the largest stored record, which can be another provider's live UID.

That provider is then due on the next navigation. Its Found result is planned against a row that still holds the retry entry, doesn't fit, gets trimmed by drop_provider_uids, and produces no write. So it's called on every navigation with the result thrown away until this provider's deadline lapses, then the cycle repeats. That brings back the per-navigation vendor calls #1547 is meant to remove, and loses a real ID to store a backoff hint. I reproduced it with a scratch test: provider B's 1000-byte UID at MAX_ENTRY_BYTES - 20, provider A misses, B's UID is evicted, and B's re-found UID plan comes back None.

Suggested fix: give retry metadata the lowest priority under the cap. If the row doesn't fit after this navigation's changes, drop the retry entries added this navigation before any stored record, and if only retry state changed, skip the write. retry_after_metadata_respects_the_row_size_cap currently passes only because its filler record is evicted to keep the retry entry, so it'd flip to expecting the stored records to survive.

entry: Option<&KvEntry>,
now: UnixSeconds,
) -> (Vec<SourceDomain>, bool) {
// A failed refresh must also wait, even while its stored UID is live.

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.

R2 · Nonblocking: retry suppression is reported as skipped_not_due. Returning an empty due list here makes dispatch report Skipped(NotDue) ("none of its sources is due"). During a vendor outage, or for a vendor that 204s most traffic, backed-off lookups look exactly like healthy rows whose IDs are live. Opt-out memory, the precedent #1547 names, got its own SkipReason::OptedOut and label, checked in dispatch. Moving this check next to it with a SkipReason::RetryPending (skipped_retry_after) and adding that to spec §12.2 would keep the outcome log useful. At minimum, the due_sources doc comment should mention the new early return.

record.prune_expired(input.now);
}
entry.prune_opt_outs(input.now);
entry

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.

R3 · Nonblocking: retry policy is spread across three modules. The until > now liveness check is here and in coordinator/mod.rs:284-287, and the status is classified for retry twice (retry_delay_seconds in results.rs and the matches!(Found | OptedOut) in apply_lookups). Opt-outs keep this behind KvEntry methods (opted_out, remember_opt_out, prune_opt_outs). Matching that with retry_pending, record_lookup_outcome and prune_retry_after on KvEntry would keep the deadline-boundary rule in one place.

result or a fresh opt-out clears that provider's retry-after; ordinary skips
never renew it.

The first vendor implementation PR (#1488) is gated on the retry-after fix

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.

R4 · Nit: "The first vendor implementation PR (#1488) is gated on the retry-after fix (#1547)" is merge sequencing in the operator guide, and it goes stale once this merges. I'd drop it and keep the rate_limit_per_hour sentence. If it stays, link the references like the rest of the file does.

let now = UnixSeconds::new(crate::ec::current_timestamp());
let results = retry_navigation(&coordinator, &transport, &clock, &snapshot, now);
assert_eq!(
only_status(&results),

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.

R5 · Nit: this test uses inline paths (crate::ec::after_response::commit_after_response_lookups, crate::ec::page_load::AfterResponseWrite::for_test(), AfterResponseOutcome::Written, crate::ec::current_timestamp()) next to the page_load imports this PR added. Extending the module's test imports would read better.

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

2 participants