SQLite persistence core, StateDatabase, skeleton/pulse event model, and task/trace types — the storage substrate that backs Shadow Replay and risk-aware recovery.
The resilience system is Aleph's persistence and state layer. After the agent-loop migration, src/resilience/ only retains the database layer (StateDatabase) and shared types — governance, collaboration, perception, and recovery middleware have been removed; higher-level recovery is now orchestrated by the harness in src/agents/ together with the gateway event bus.
src/resilience/mod.rs after the 26.7.x migration only exports database and types:
pub mod database;pub mod types;
The historical recovery/, collaboration/, and shadow-replay submodules no longer exist. Their responsibilities now live in src/agents/swarm/tasks/, src/harness/trace.rs, and src/gateway/event_bus.rs.
Skeleton events represent state transitions that must survive crashes. They are written synchronously and used for recovery. Pulse events are high-frequency streaming data (token-by-token output) that is batched and can be dropped without affecting correctness.
AgentTraceEvent comes from the aleph_protocol crate (unified protocol); task_id and step_index are written by the dispatcher; event_kind() returns a stable string for indexing and filtering.
The integration test in src/routing/integration_tests.rs::observer_* verifies the full trace path: RoutingAttribution → OutcomeObserver::on_trace → RoutingExperienceStore::recall round-trips correctly.
is_recoverable() is true only for Running and Interrupted — those two statuses drive recovery decisions combined with RiskLevel and trace availability.
For each task where status = Running | Interrupted: │ ├── No traces available? │ └── Skip ("no execution traces available") │ ├── RiskLevel::Low? │ └── AutoResume (Shadow Replay + continue) │ └── RiskLevel::High? └── PendingConfirmation (wait for user approval)
Read-only operations (file search, code analysis) are safe to retry automatically; write operations (file modification, shell commands) need human confirmation because the system state may have changed since the interrupt.
Execution: every step writes a TaskTrace │ ▼harness::trace::TraceSink::on_trace(SessionCompleted { … }) │ ▼gateway event bus routes to OutcomeObserver (src/routing/observer.rs) │ ▼RoutingExperienceStore.record (src/routing/experience_store.rs, sqlite-vec k-NN)
OutcomeObserver is the VESR write side; RoutingRecall::build_routing_experience_message is the read side (once per run, at run-start). They are paired through RoutingAttribution.task_emb (OnceLock<Vec<f32>>).
26.7.21 hardening: when a policy file is missing or permissive_default disagrees with Default::default(), authorization is refused (never silently allowed). DiminishingReturnsDetector was removed from harness/tests/budget.rs — it was a deterministic completion judgment inside the loop, which R10 forbids. Hard stops are now bounded by max_iterations, the tool-loop verifier, and the model's own stop instead.
26.7.21+: the LLM judge for heartbeat probes — payload masks secrets. Heartbeat probes refuse to use dangerous tools or confirmation-gated tools. See Heartbeat for the full spec.
The historical stub RPCs (heartbeat.*_stub / cron.*_stub) have been realized; the full RPC is driven by the Daemon, backed by src/tasks/cron/ and src/tasks/heartbeat/ and wired at startup in src/bin/aleph-server/commands/start/builder/handlers/agents.rs::register_cron_handlers / register_heartbeat_handlers.