Skip to main content

stygian_charon/
lib.rs

1#![warn(missing_docs, rustdoc::broken_intra_doc_links)]
2#![deny(unsafe_code)]
3
4//! stygian-charon
5//!
6//! Defensive anti-bot diagnostics for Stygian.
7//! The crate classifies likely anti-bot providers from transaction evidence
8//! and from HTTP Archive (HAR) files.
9
10/// Mapping layer from runtime policy to acquisition strategy hints.
11pub mod acquisition;
12/// Adaptive SLO policy interfaces and regression-history implementation.
13pub mod adaptive;
14/// Versioned analyzer interfaces and profile selection.
15pub mod analyzer;
16/// Historical HAR replay across analyzer profiles.
17pub mod backtest;
18/// Diagnostic bundle API with redaction policy.
19pub mod bundle;
20/// Investigation report cache backends and cache key helpers.
21#[cfg(feature = "caching")]
22pub mod cache;
23/// Challenge-aware policy feedback loop (T83).
24#[cfg(feature = "caching")]
25pub mod challenge_feedback;
26/// Anti-bot change-detection feed (T88).
27///
28/// Detects canary, proxy, and extraction deltas and
29/// emits actionable incident packets via the metrics
30/// surface and the diagnostics payload.
31#[cfg(feature = "caching")]
32pub mod change_feed;
33/// Provider signature classification logic.
34pub mod classifier;
35/// Mode differential regression runner across snapshot capture modes.
36pub mod differential;
37/// HAR parsing and extraction utilities.
38pub mod har;
39/// Investigation reports and baseline/candidate diffing.
40pub mod investigation;
41/// Telemetry and metrics collection (feature-gated).
42#[cfg(feature = "metrics")]
43pub mod metrics;
44/// External observatory runner and comparison reports.
45pub mod observatory;
46/// Target-class playbooks as code (T85). Resolves per-target
47/// acquisition / proxy / pacing / escalation knobs with
48/// deterministic precedence.
49pub mod playbooks;
50/// Runtime policy planning based on investigation output.
51pub mod policy;
52/// Proof-of-work capability profile (T93).
53///
54/// Quantifies solve latency, success rate, retry count, and
55/// failure modes into a deterministic unit-interval score,
56/// with sparse-telemetry fallback and a policy mapper that
57/// nudges the runtime policy toward a posture matching the
58/// observed capability.
59///
60/// Persistence reuses the same `LruTtlStore` primitive
61/// T83 / T91 use (no new cache store; PoW key namespace is
62/// `charon:pow:...`).
63#[cfg(feature = "caching")]
64pub mod pow_profile;
65/// Challenge-style probe pack for adversarial and regression testing.
66pub mod probe;
67/// Release risk scoring and release-candidate trend reporting.
68pub mod release_risk;
69/// Normalized fingerprint snapshot schema types and compatibility checks.
70pub mod snapshot;
71/// Challenge-token lifecycle contracts (T91). Strict per-vendor
72/// TTL / nonce / single-use / session-binding invariants enforced
73/// before submission.
74#[cfg(feature = "caching")]
75pub mod token_lifecycle;
76/// Public types for transaction and report models.
77pub mod types;
78/// Vendor fingerprinting confidence classifier (T89).
79pub mod vendor_classifier;
80/// Vendor-to-playbook auto-resolution (T90).
81///
82/// Bridges the vendor classifier and the playbook resolver,
83/// with multi-vendor precedence, merge rules, and a `Manual`
84/// fallback that keeps existing manual mode selection working
85/// unchanged.
86pub mod vendor_resolver;
87
88pub use acquisition::{
89    AcquisitionModeHint, AcquisitionPolicy, AcquisitionStartHint, RuntimePolicyHints,
90    map_adapter_strategy, map_policy_hints, map_runtime_policy,
91};
92pub use adaptive::{AdaptivePolicyError, AdaptiveSloPolicy, RegressionHistoryPolicy};
93pub use analyzer::{AnalyzerProfile, AnalyzerVersion, ProviderAnalyzer};
94pub use backtest::{
95    BacktestCase, BacktestDisagreement, BacktestError, BacktestReport, BacktestSample,
96    run_profile_backtest,
97};
98pub use bundle::{
99    BundleCoherenceViolation, BundleError, BundleMetadata, BundleRedactionPolicy, DiagnosticBundle,
100    apply_redaction, build_diagnostic_bundle, build_diagnostic_bundle_with_snapshot,
101    diagnostic_bundle_from_investigation,
102};
103#[cfg(feature = "redis-cache")]
104pub use cache::RedisInvestigationCache;
105#[cfg(feature = "caching")]
106pub use cache::{InvestigationReportCache, MemoryInvestigationCache, investigation_cache_key};
107#[cfg(feature = "caching")]
108pub use challenge_feedback::{
109    ChallengeFeedbackPolicy, ChallengeMemory, ChallengeMemoryEntry, ChallengeOutcome,
110    MAX_RISK_DELTA, adjust_runtime_policy, build_runtime_policy_with_memory, challenge_memory_key,
111    memory_adjustment_for,
112};
113#[cfg(feature = "caching")]
114pub use change_feed::{
115    ChangeClassification, ChangeDeltaInput, ChangeDetector, ChangeEvent, ChangeEventSink,
116    ChangeFeedReport, ChangeFeedThresholds, DeltaSeverity, DeltaSource, DeltaSummary,
117    InMemoryChangeFeedSink, MitigationPath, record_change_event,
118};
119pub use classifier::{
120    classify_har, classify_har_with_profile, classify_transaction,
121    classify_transaction_with_profile,
122};
123pub use differential::{
124    ModeComparison, ModeDifferentialCorpus, ModeDifferentialError, ModeDifferentialPairResult,
125    ModeDifferentialRunReport, ModeDifferentialThresholds, run_mode_differential_regression,
126};
127pub use investigation::{
128    compare_reports, infer_requirements, infer_requirements_with_target_class, investigate_har,
129    investigate_har_with_profile,
130};
131#[cfg(feature = "caching")]
132pub use investigation::{investigate_har_cached, investigate_har_cached_with_target_class};
133#[cfg(feature = "live-validation")]
134pub use observatory::{LiveObservatoryProbe, run_external_observatory_live};
135pub use observatory::{
136    ObservatoryCase, ObservatoryComparison, ObservatoryError, ObservatoryEscalation,
137    ObservatoryReport, ObservatorySample, run_external_observatory_from_hars,
138};
139pub use policy::{analyze_and_plan, build_runtime_policy, plan_from_report};
140#[cfg(feature = "caching")]
141pub use pow_profile::{
142    DEFAULT_LATENCY_BUDGET_MS, DEFAULT_POW_CAPACITY, DEFAULT_POW_TTL, DEFAULT_RETRY_BUDGET,
143    DEFAULT_SAMPLE_WINDOW_SECS, MAX_POW_RISK_DELTA, MIN_OBSERVATIONS_FOR_SCORING,
144    PowCapabilityBand, PowCapabilityProfile, PowCapabilitySample, PowCapabilityScore,
145    PowCapabilityScorer, PowCapabilityStore, PowFailureMode, PowPolicyThresholds, ProfileWeights,
146    SPARSE_FALLBACK_SCORE, adjust_runtime_policy_for_pow, band_for_score, pow_profile_key,
147    score_from_profile,
148};
149pub use probe::{
150    ChallengeProbe, ProbeCategory, ProbeExpectation, ProbePackReport, ProbeRunResult,
151    challenge_probe_pack, run_probe_pack,
152};
153pub use release_risk::{
154    ReleaseCandidateRiskSnapshot, ReleaseRiskAssessment, ReleaseRiskBreakdown, ReleaseRiskInput,
155    ReleaseRiskLevel, ReleaseRiskThresholds, ReleaseRiskWeights, ReleaseTrendDirection,
156    ReleaseTrendPoint, ReleaseTrendReport, assess_release_risk, build_release_trend_report,
157    release_risk_input_from_reports,
158};
159pub use snapshot::{
160    FingerprintSignals, NormalizedFingerprintSnapshot, ScreenFingerprint, SnapshotCoherenceReport,
161    SnapshotCoherenceViolation, SnapshotCollectionError, SnapshotCompatibilityError,
162    SnapshotDeterminismOptions, SnapshotDriftReport, SnapshotMode, SnapshotSignalDrift,
163    SnapshotSignalDriftKind, TlsFingerprint, WebGlFingerprint,
164    collect_deterministic_snapshot_bytes, compare_snapshot_signal_drift,
165    evaluate_snapshot_coherence, normalize_snapshot_for_determinism,
166    validate_snapshot_compatibility,
167};
168#[cfg(feature = "caching")]
169pub use token_lifecycle::{
170    ChallengeClass, DEFAULT_NONCE_BOOK_CAPACITY, DEFAULT_NONCE_TTL, InvalidationKind,
171    InvalidationReason, NonceBook, NonceObservation, TokenContract, TokenLifecycleError,
172    TokenPolicy, TokenPolicyTable, TokenValidator, ValidationOutcome, builtin_token_policies,
173    nonce_book_key,
174};
175pub use types::{
176    AdapterStrategy, AntiBotProvider, AntiBotRequirement, BlockedRatioSlo, Detection,
177    ExecutionMode, HarClassificationReport, HarRequestSummary, HostSummary,
178    IntegrationRecommendation, InvestigationBundle, InvestigationDiff, InvestigationReport,
179    MarkerCount, ProviderScore, RequirementLevel, RequirementsProfile, RuntimePolicy, SessionMode,
180    TargetClass, TelemetryLevel, TransactionView,
181};
182pub use vendor_classifier::{
183    DEFAULT_HIGH_CONFIDENCE_THRESHOLD, Evidence, EvidenceBundle, EvidenceSource,
184    VendorClassification, VendorClassifier, VendorDefinition, VendorError, VendorId, VendorScore,
185    VendorSignal, parse_vendor_definition,
186};
187pub use vendor_resolver::{
188    AppliedRule, MergeStrategy, PlaybookResolverExt, ResolutionRationale, ResolutionRule,
189    StrategyMarker, VendorResolution, VendorResolver, VendorResolverError, VendorRuleMatch,
190    parse_resolution_rule,
191};