feat(engine): opt-in cloak Turnstile-solver recovery tier (default-off)#293
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_clearancecache, and thecurl_cffi warm replay. The engine's
CloakRendererjust calls the sidecar'smirror endpoint (
x-hostname+x-proxy) with a DataImpulse sticky-sessidproxy: 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.
CLOAK_ARM_FLOOR_MS(arm-firing floor) from the per-attempt solve budgetcloak_sem) + bounded 2-attempt retryRendererKind::Cloakso a cloak failure never trips other tierslooks_like_cloudflare_challengeaccept-gate (a still-challenged body is retryable)Zero-impact guarantee
Off by default at every layer, mirroring the
camoufoxtier:cloakfeature absent from everydefaultset[renderer.cloak]isOption<CloakEndpoint> = Nonewhen unconfiguredcloak_in_ladder()'s!cfg!(feature="cloak")first line folds to constantfalsein leanroute_to_cloakcfg-const folds tofalsein lean → chrome_proxy firing byte-identicalA build/config without cloak is byte-identical to today. Verified: lean
cargo clippy --workspace --all-targets -- -D warnings+ full lean test suite pass.Tests
cloak.rsunit tests (happy path, persistent-challenge → retryable error,fresh-sessid+bypass-cache recovery, non-2xx real content accepted, expired
deadline → Timeout,
/cache/statshealth).mode=cloakwithout the feature → clean ConfigError).
Follow-ups (not in this PR)
cloak-sidecarcompose service) + live end-to-end enable.