Skip to main content

Module escalation

Module escalation 

Source
Expand description

Default tiered escalation policy with challenge detection (feature = “escalation”) Default escalation policy adapter.

Implements EscalationPolicy with:

  • Automatic challenge detection (Cloudflare, DataDome, PerimeterX, CAPTCHA)
  • Per-domain tier cache (learning cache with configurable TTL)
  • Configurable max_tier and base_tier

§Challenge detection

DefaultEscalationPolicy::context_from_body inspects the response body for well-known markers and populates a ResponseContext automatically. Both has_cloudflare_challenge and DataDome/PerimeterX markers map to the has_cloudflare_challenge field (treated as “any anti-bot challenge”).

§Per-domain learning cache

When a request to a domain succeeds at a tier above base_tier, the policy records that tier with record_tier_success. Future calls to initial_tier_for_domain skip lower tiers automatically until the cache entry expires (cache_ttl).

§Example

use std::time::Duration;
use stygian_graph::adapters::escalation::{DefaultEscalationPolicy, EscalationConfig};
use stygian_graph::ports::escalation::{EscalationPolicy, EscalationTier, ResponseContext};

let policy = DefaultEscalationPolicy::new(EscalationConfig::default());

let ctx = ResponseContext {
    status: 403,
    body_empty: false,
    has_cloudflare_challenge: false,
    has_captcha: false,
};

assert!(policy.should_escalate(&ctx, EscalationTier::HttpPlain).is_some());

Structs§

DefaultEscalationPolicy
Default escalation policy with challenge detection and per-domain learning.
EscalatingScrapingService
A ScrapingService that tries multiple tiers in sequence, escalating from lightweight HTTP to a full stealth browser when anti-bot protections are detected.
EscalationConfig
Configuration for DefaultEscalationPolicy.