Diagnostic Stress Injection¶
MIF-017 degrades otherwise clean diagnostic frames with deterministic synthetic noise, dropout, and timestamp jitter. The surface validates ingestion resilience before ControlObservation and phase-lock consumers rely on perfect fixtures.
Model¶
Each frame carries a non-negative timestamp and physical channel samples.
NoiseSpec adds Gaussian noise with channel-specific sigma in physical units.
DropoutSpec removes channels by Bernoulli probability. JitterSpec applies
signed timestamp jitter by default, bounded by the documented 10-50 ns absolute
magnitude regression envelope. Legacy positive-only replay is still available
by setting signed=False in Python, signed=false in Julia, or
jitter_signed=false through the Rust/PyO3 constructor. Every degraded frame
has a StressInjectionRecord with source time, emitted time, signed jitter,
noisy channels, and dropped channels.
Stress injection fails closed after every stochastic transform. Finite input samples and finite channel noise parameters must still produce finite stressed samples; overflow, underflow to non-finite values, or any other non-finite post-noise result is rejected at the stress boundary before the degraded frame is emitted.
Python API¶
stress_inject
¶
Deterministic dirty-diagnostic stress injection (MIF-017).
DiagnosticFrame(t_ns, samples)
dataclass
¶
One timestamped physical diagnostic sample frame.
__post_init__()
¶
Validate timestamp and freeze finite diagnostic sample values.
NoiseSpec(sigma_by_channel)
dataclass
¶
Per-channel additive Gaussian noise scale in physical units.
__post_init__()
¶
Validate non-negative Gaussian-noise bounds by channel.
DropoutSpec(probability_by_channel)
dataclass
¶
Per-channel Bernoulli dropout probability.
__post_init__()
¶
Validate dropout probabilities by channel.
JitterSpec(min_ns=10, max_ns=50, probability=1.0, signed=True)
dataclass
¶
Timestamp jitter envelope in nanoseconds.
By default the sampled jitter is signed so the degradation model covers
early and late diagnostic arrivals. min_ns and max_ns describe the
absolute jitter magnitude. Set signed=False only for legacy one-sided
positive-jitter replay.
__post_init__()
¶
Validate jitter bounds and application probability.
StressInjectionConfig(seed, noise, dropout, jitter=JitterSpec())
dataclass
¶
Complete deterministic degradation configuration.
__post_init__()
¶
Validate deterministic stress-injection seed.
StressEnvelope(max_noise_sigma_by_channel=_DEFAULT_ALLOWED_SIGMA, max_dropout_probability=0.05, min_jitter_ns=10, max_jitter_ns=50, phase_lock_tolerance_rad=0.01)
dataclass
¶
Fail-closed regression bounds for MIF-017 stress campaigns.
__post_init__()
¶
Validate stress envelope limits used by campaign summaries.
StressInjectionRecord(frame_index, source_t_ns, emitted_t_ns, jitter_ns, noisy_channels, dropped_channels)
dataclass
¶
Audit record for one degraded diagnostic frame.
StressInjectionResult(frames, records)
dataclass
¶
Degraded frames plus audit records.
StressCampaignReport(stable, campaign_count, max_abs_phase_error_rad, max_jitter_ns, max_dropout_probability, failure_reasons)
dataclass
¶
Aggregate result for the 100-seed phase-lock regression.
DegradedSensorStream(config)
¶
Apply deterministic noise, dropout, and jitter to diagnostic frames.
validate_stress_config(config, envelope)
¶
Fail closed when stress settings exceed documented regression bounds.
evaluate_phase_lock_stability_campaigns(config, envelope=None, *, campaign_count=100, frames_per_campaign=32, dt_ns=128)
¶
Run the MIF-017 phase-lock invariant over at least 100 seeded campaigns.
Fail-Closed Envelope¶
validate_stress_config(...) rejects configurations that exceed the documented
noise, dropout, or jitter bounds. The default phase-lock campaign helper runs
at least 100 seeded campaigns and fails closed if the maximum absolute
phase_lock_error_rad exceeds 1.0e-2 rad or if all phase-lock samples drop
out in a campaign. Campaign timestamps must be spaced by more than twice the
maximum jitter bound so signed early/late arrivals cannot silently invert the
diagnostic order. The default campaign fixture starts at one interval rather
than zero so signed jitter cannot produce a negative emitted timestamp on the
first synthetic frame.
Dispatch¶
Use scpn_mif_core.diagnostics.dispatched_degraded_sensor_stream(...) for the
fastest available measured backend:
The Python path owns orchestration and regression reporting. Rust mirrors the fault-injection kernel through PyO3. Julia mirrors the behaviour for audit and Monte Carlo calibration scripts.
Benchmarks¶
The benchmark harness ships at bench/kernels/bench_diagnostic_stress_inject.py.
It measures one four-channel frame and a 4 096-frame batch across Python, Rust,
and Julia. The committed result is local comparison evidence, not CPU-isolated
production latency evidence; host load, governor, and runtime versions are
recorded in bench/results/diagnostic_stress_inject.json.