Skip to content

Chaos scenarios, retry jitter validation, timeout convergence tests, consensus reconciliation - #449

Merged
maugauwi-hash merged 2 commits into
ethos-protocol:mainfrom
Haroldwonder:fix/consensus-routing-backup-dr-reliability
Aug 31, 2026
Merged

Chaos scenarios, retry jitter validation, timeout convergence tests, consensus reconciliation#449
maugauwi-hash merged 2 commits into
ethos-protocol:mainfrom
Haroldwonder:fix/consensus-routing-backup-dr-reliability

Conversation

@Haroldwonder

@Haroldwonder Haroldwonder commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Four reliability/testing fixes, each independently scoped:

  • Closes Add Chaos Testing Scenario for Cascading Failures #370 — Combined-failure chaos scenarios. chaos.rs gains two scenarios: (1) cache + one replica down simultaneously, asserting fallback::cascade routes around both to a healthy target instead of erroring, with a heal/recovery check; (2) circuit breaker + bulkhead interacting under 20-way concurrent load, asserting no panics/deadlocks and that the breaker fast-rejects calls once tripped even after they've passed the bulkhead. This wires the previously-unused fallback.rs and bulkhead.rs modules into the crate, which surfaced a real bug in Bulkhead::acquire: it gated every request against max_queue_size, even ones with an immediately-free concurrency slot, so max_queue_size: 0 rejected all traffic outright regardless of max_concurrent. Fixed as part of this PR (see bulkhead.rs diff) since it's exactly the kind of latent bug this issue exists to catch. Documented in docs/chaos-testing.md, including honest gaps (both scenarios drive the modules directly rather than through the live HTTP router).

  • Closes Implement Retry Policy Jitter Bounds Validation #371 — Retry policy jitter/backoff validation. RetryPolicy::validate() checks max_attempts > 0, base_delay_ms <= max_delay_ms, and that multiplier is finite and positive (rejecting zero/negative/NaN/infinite, which would otherwise produce degenerate or blown-up backoff delays). Wired into the create_retry_policy endpoint. New tests cover boundary-valid and invalid configurations, plus delay-bounds tests for all three jitter modes (None/Full/EqualEqual previously had no boundedness test at all).

  • Closes Add Timeout Adaptation Convergence Test #372 — Timeout adaptation convergence tests. New tests confirm current_timeout converges to the steady-state latency within exactly min_samples iterations and then holds stable (no oscillation), the predictive EMA settles near the steady-state value, and a latency spike recovers to baseline once it ages out of the fixed-size rolling window (after window_size further samples). Documented in a new "Convergence Characteristics" section in docs/timeout-adaptation.md.

  • Closes Implement Consistency Verification Scheduled Reconciliation #373 — Scheduled consensus reconciliation. scheduler.rs now runs NodeCache::check_and_resolve() every 5 minutes, publishes the result as /metrics counters/gauge (ethos_protocol_consensus_checks_total, _conflicts_total, _consistent), and opens a Sev3 incident via incidents.rs when conflicts are found. This required wiring the previously-orphaned incidents.rs module into the crate (pub mod incidents; was missing) and mounting its HTTP API for the first time. Documented in docs/consistency-verification.md.

Test plan

  • cargo check --lib --bin ethos-protocol-backend — clean (only pre-existing, unrelated warnings)
  • cargo test --lib — 393 passed, 0 failed, including all new coverage and the fixed bulkhead::tests

…R automation

Closes ethos-protocol#373: schedule NodeCache::check_and_resolve every 5 minutes, publish
results as /metrics counters/gauge, and open an incident via incidents.rs
when conflicts are found.

Closes ethos-protocol#374: add a separate healthy-recovery threshold (hysteresis band) to
health_routing so an endpoint needs several consecutive successes to
re-enter rotation after being marked unhealthy, instead of flapping back in
on a single success.

Closes ethos-protocol#375: compute and store a SHA-256 checksum per backup at creation
time (BackupValidator::register_backup) and verify it during validation,
failing and opening an incident via incidents.rs on mismatch.

Closes ethos-protocol#376: expose admin-only, confirmation-token-gated endpoints wrapping
the DR runbook's failover trigger and backup-restore-validation steps
(dr_automation.rs), with an audit history endpoint for post-incident review.

Wires the previously-unused incidents.rs module into the crate and shares
an IncidentState across all four features so conflicts/mismatches/failovers
are tracked the same way a manually-filed incident would be.
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Haroldwonder Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…ethos-protocol#374-376 work

The previous commit on this branch mistakenly addressed ethos-protocol#374/ethos-protocol#375/ethos-protocol#376,
which are not assigned to this contributor and were already being worked
by others. Reverts backend/src/health_routing.rs, backup_validation.rs,
models.rs, routes.rs, and their docs to upstream, removes dr_automation.rs
and docs/dr-automation.md entirely, and trims the shared scaffolding
(AppState, SchedulerContext, lib.rs, main.rs, tests.rs) back down to just
what ethos-protocol#373's consensus reconciliation needs.

Adds the correct three issues:

Closes ethos-protocol#370: add two chaos scenarios combining multiple simultaneous
failure modes — cache + replica outage falling back via fallback::cascade
instead of erroring, and circuit breaker + bulkhead interacting under
concurrent load. Wires the previously-unused fallback.rs and bulkhead.rs
modules into the crate to support this, which surfaced (and this fixes) a
real bug in Bulkhead::acquire: it gated every request against
max_queue_size even when a concurrency slot was immediately free, so
max_queue_size: 0 rejected every request outright regardless of
max_concurrent.

Closes ethos-protocol#371: add RetryPolicy::validate() checking max_attempts, the
base/max delay relationship, and multiplier sanity (finite, positive), used
by the create-policy endpoint. Adds boundary/invalid-value tests and tests
asserting computed delays stay within configured bounds for all three
jitter modes.

Closes ethos-protocol#372: add convergence tests for AdaptiveTimeoutManager — steady-state
latency converges within min_samples iterations and then holds stable, the
predictive EMA settles near the steady-state value, and a latency spike
recovers to baseline once it ages out of the fixed-size rolling window.
Documents these characteristics in docs/timeout-adaptation.md.
@Haroldwonder Haroldwonder changed the title Consensus reconciliation, routing hysteresis, backup checksums, DR automation Chaos scenarios, retry jitter validation, timeout convergence tests, consensus reconciliation Aug 29, 2026
@maugauwi-hash
maugauwi-hash merged commit 7df4605 into ethos-protocol:main Aug 31, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants