Skip to content

feat(engine): opt-in cloak Turnstile-solver recovery tier (default-off)#293

Merged
us merged 2 commits into
mainfrom
feat/cloak-turnstile-tier
Jul 15, 2026
Merged

feat(engine): opt-in cloak Turnstile-solver recovery tier (default-off)#293
us merged 2 commits into
mainfrom
feat/cloak-turnstile-tier

Conversation

@us

@us us commented Jul 15, 2026

Copy link
Copy Markdown
Owner

What

A feature-gated, config-gated recovery tier that clears Cloudflare managed
Turnstile
challenges (Glassdoor-class sites) which the HTTP/LightPanda/Chrome/
chrome_proxy ladder cannot solve. Fired ONLY on a detected CF challenge, routed
straight to cloak (chrome_proxy, being default-fingerprint Chrome, cannot clear
Turnstile). Empirically verified: a stealth-browser sidecar + our residential
proxy returns real Glassdoor content where every off-the-shelf stealth tool froze.

Design (Model B)

The sidecar owns the stealth browser (mint), the cf_clearance cache, and the
curl_cffi warm replay. The engine's CloakRenderer just calls the sidecar's
mirror endpoint (x-hostname + x-proxy) with a DataImpulse sticky-sessid
proxy: a stable per-host sessid for warm reuse (~1-2s), a fresh one per retry for
a new exit IP. cf_clearance is IP+UA+TLS-bound, so keeping mint+replay in one
process (the sidecar) is strictly more robust than an engine-side replay.

  • decoupled CLOAK_ARM_FLOOR_MS (arm-firing floor) from the per-attempt solve budget
  • pre-fire circuit breaker + non-blocking concurrency shed (cloak_sem) + bounded 2-attempt retry
  • own RendererKind::Cloak so a cloak failure never trips other tiers
  • shared looks_like_cloudflare_challenge accept-gate (a still-challenged body is retryable)

Zero-impact guarantee

Off by default at every layer, mirroring the camoufox tier:

  • Cargo cloak feature absent from every default set
  • [renderer.cloak] is Option<CloakEndpoint> = None when unconfigured
  • cloak_in_ladder()'s !cfg!(feature="cloak") first line folds to constant false in lean
  • route_to_cloak cfg-const folds to false in lean → chrome_proxy firing byte-identical

A build/config without cloak is byte-identical to today. Verified: lean
cargo clippy --workspace --all-targets -- -D warnings + full lean test suite pass.

Tests

  • New cloak.rs unit tests (happy path, persistent-challenge → retryable error,
    fresh-sessid+bypass-cache recovery, non-2xx real content accepted, expired
    deadline → Timeout, /cache/stats health).
  • New config gating tests (absent config → None + not-in-ladder; mode=cloak
    without the feature → clean ConfigError).

Follow-ups (not in this PR)

  • SaaS paid-plan gate + recovery-budget grant (separate crw-saas PR, env-flag default-off).
  • Sidecar deployment (cloak-sidecar compose service) + live end-to-end enable.

us added 2 commits July 16, 2026 00:20
Adds a feature-gated (cloak), config-gated recovery tier that clears
Cloudflare managed-Turnstile challenges (Glassdoor-class sites) via a
stealth-browser sidecar's mirror endpoint. Fired ONLY on a detected CF
challenge and routed straight to cloak (chrome_proxy cannot clear Turnstile).

- Model B: the sidecar owns the browser, cf_clearance cache, and curl_cffi
  warm replay; the engine calls its mirror endpoint with a DataImpulse
  sticky-sessid proxy (stable per-host for warm reuse, fresh per retry)
- decoupled arm floor (CLOAK_ARM_FLOOR_MS) from the per-attempt solve budget
- pre-fire circuit breaker + concurrency shed (cloak_sem) + 2-attempt bound
- own RendererKind::Cloak so a cloak failure never trips other tiers

Off by default at every layer (Cargo feature absent from all defaults,
[renderer.cloak] Option=None, cloak_in_ladder() cfg-const false in lean),
so a build/config without it is byte-identical to today.
The cloak tier is an internal CF-challenge recovery arm fired automatically,
not a per-request `renderer` a user pins, so drop the RequestedRenderer::Cloak
variant. Keeps it out of the public js-rendering docs table (fixes the
RequestedRenderer drift check) and out of the customer-facing API surface.
RendererKind::Cloak (internal breaker/metrics) is unaffected.
@us us merged commit a7e2531 into main Jul 15, 2026
12 checks passed
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.

1 participant