Skip to content

feat(renderer): send x-deadline-ms to the cloak sidecar mirror call#325

Merged
us merged 1 commit into
mainfrom
feat/cloak-deadline-header
Jul 18, 2026
Merged

feat(renderer): send x-deadline-ms to the cloak sidecar mirror call#325
us merged 1 commit into
mainfrom
feat/cloak-deadline-header

Conversation

@us

@us us commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Lets the cloak sidecar deliver a slow cold solve in-band instead of fail-opening at its conservative default. Pairs with the crw-saas sidecar PR that honors the header.

What

One unconditional header on mirror_once (crw-renderer/src/cloak.rs): x-deadline-ms = budget.as_millis(), where budget = deadline.remaining().min(CLOAK_DEFAULT_TIMEOUT_MS 35s) (the exact time the engine will wait). Sent on every call including attempt 0 (bypass=false), which is the generous-deadline first-request case this exists for.

Why

Today the sidecar cannot see how long the engine will wait, so it self-caps at a conservative ~23s and fail-opens even when the engine granted up to 35s. With the header, a ~24s cold solve returns real content in-band on the first request for cloak-entitled (generous-deadline) traffic; tight-deadline requests still fail-open gracefully.

Safety

  • Feature-gated (cloak): inert when the tier is compiled out or unconfigured; the whole function is under #[cfg(feature = "cloak")].
  • budget is guarded non-zero by the early return above, so x-deadline-ms: 0 is never emitted.
  • An older sidecar that ignores the header keeps working (falls back to its default); a newer sidecar reads it.
  • +6 lines, no other change.

Verification

cargo fmt --check + clippy -D warnings + cargo test --workspace (773 tests) all pass via the pre-commit hook. The paired sidecar was verified in-container honoring the header (generous-deadline first request returns in-band).

Ref: PLAN-cloak-deadline.md and the crw-saas cloak-sidecar PR.

Propagate the cloak arm's per-call budget (deadline.remaining().min(35s)) as an
x-deadline-ms header on every mirror_once request, unconditionally (including
attempt 0). Lets the sidecar deliver a slow cold solve in-band up to what the
engine will actually wait, instead of fail-opening at its conservative default.
Feature-gated (cloak) and inert when the tier is off. budget is guarded non-zero
above, so x-deadline-ms: 0 is never emitted.
@us
us merged commit 0de10e2 into main Jul 18, 2026
10 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant