pub struct CoherenceProbe { /* private fields */ }Expand description
Runner that executes the cross-context identity probes via CDP and
aggregates the results into a CoherenceDriftReport.
CoherenceProbe is the default-on entry point for cross-context
stealth coherence. Worker probes are best-effort: when the runtime
does not expose Worker/Blob/URL.createObjectURL, the worker
slot in the report is populated with
ContextObservation::Skipped rather than panicking.
§Idempotence
All probe methods are safely re-runnable on the same page; they
do not mutate the DOM beyond a transient iframe that is removed
at the end of the probe, and the worker is terminate()-ed and
its Blob URL is revokeObjectURL-ed before the probe returns.
§Feature flag
The coherence module is default-on; no feature gate is
required. The probe runner requires a live browser page (i.e.
the existing browser-cdp capability, which is the
stygian-browser default).
§Example
use stygian_browser::{BrowserPool, BrowserConfig, WaitUntil};
use stygian_browser::coherence::CoherenceProbe;
use std::time::Duration;
let pool = BrowserPool::new(BrowserConfig::default()).await?;
let handle = pool.acquire().await?;
let mut page = handle
.browser()
.expect("valid browser")
.new_page()
.await?;
page.navigate(
"https://example.com",
WaitUntil::DomContentLoaded,
Duration::from_secs(30),
)
.await?;
let probe = CoherenceProbe::default();
let report = probe.run(&page).await?;
println!(
"coherent={} hard_drift={} contexts={}/3",
report.is_coherent(),
report.has_hard_drift(),
report.observed_context_count(),
);Implementations§
Source§impl CoherenceProbe
impl CoherenceProbe
Sourcepub async fn run(&self, page: &PageHandle) -> Result<CoherenceDriftReport>
pub async fn run(&self, page: &PageHandle) -> Result<CoherenceDriftReport>
Run all three probes (top, iframe, worker) and build a
CoherenceDriftReport.
Per-context probe failures never abort the run; the failing
context is recorded as a Skipped
marker.
§Errors
Returns BrowserError only when CDP itself is unreachable
(no live browser connection). Per-probe script errors are
captured as skipped observations.
Sourcepub async fn run_with_freshness(
&self,
page: &PageHandle,
contract: &FreshnessContract,
) -> Result<CoherenceDriftReport>
pub async fn run_with_freshness( &self, page: &PageHandle, contract: &FreshnessContract, ) -> Result<CoherenceDriftReport>
Run all three probes and evaluate a
crate::freshness::FreshnessContract against the
top-level identity signature.
The contract is checked against the top-level
IdentitySurface signature; the resulting
crate::freshness::FreshnessReport is attached to the
returned drift report under super::CoherenceDriftReport::freshness.
§Errors
See Self::run.
Sourcepub async fn probe_top(&self, page: &PageHandle) -> ContextObservation
pub async fn probe_top(&self, page: &PageHandle) -> ContextObservation
Run only the top-level document probe.
Useful for unit tests or callers that want a single-context snapshot without paying for the iframe + worker probes.
§Errors
Returns BrowserError on CDP failure. Script errors
surface as a Skipped
observation.
Sourcepub async fn probe_iframe(&self, page: &PageHandle) -> ContextObservation
pub async fn probe_iframe(&self, page: &PageHandle) -> ContextObservation
Run only the same-origin iframe probe.
§Errors
Returns BrowserError on CDP failure. Script errors
surface as a Skipped
observation.
Sourcepub async fn probe_worker(&self, page: &PageHandle) -> ContextObservation
pub async fn probe_worker(&self, page: &PageHandle) -> ContextObservation
Run only the dedicated/shared worker probe.
§Errors
Returns BrowserError on CDP failure. Script errors
surface as a Skipped
observation.
Trait Implementations§
Source§impl Clone for CoherenceProbe
impl Clone for CoherenceProbe
Source§fn clone(&self) -> CoherenceProbe
fn clone(&self) -> CoherenceProbe
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more