Skip to main content

Module halt

Module halt 

Source
Available on crate feature conformance only.
Expand description

Kill-switch conformance: grading a HaltStore, and the halt it carries between replicas (ADR 0019, ADR 0024).

A halt is the operator’s last control over agents that misbehave, so a store that loses one, or keeps one it was told to remove, fails at the worst moment. Adopters write their own stores; this grades one the way check grades an executor.


#[tokio::test]
async fn my_halt_store_conforms() {
    // Each call opens the same backing store, as a second replica would,
    // or this one after a restart. Start from an empty one.
    let open = || async { Arc::new(MyHaltStore::connect(URL).await) as Arc<dyn HaltStore> };
    check_store(&open).await.assert_pass();
    check_handlers(&open).await.assert_pass();
}
  • check_store grades the HaltStore contract: a write replaces the halt of its scope, a removal removes exactly its scope, scopes do not collide (two job halts, HaltScope::Root, whose tenant and root read alike joined by a : included), another handle (a replica, a restarted process) reads what was written, and a store that pushes delivers each write and each cancel to the other handle.
  • check_handlers builds handlers on the store, as replicas, and grades the kill switch end to end: a halt stops the tasks running on this replica and on another, refuses new work on both, survives a restart, is lifted everywhere by a resume on any replica, and a tenant’s halt spares the other tenants.

§What it cannot tell you

It cannot make the store fail, so the rule that a store which cannot be read answers with an error and not with no halts is not graded. It uses its own poll interval (50 ms) and its own executor, which honours cancellation, so it grades the store and the handler’s wiring, not your interval or whether your executor stops when told; the executor harness (check) grades that. It runs each check once, so it cannot find a race. A pushed signal is graded by its arrival after a write: a store whose listener announces itself with a spurious signal, late, could pass a push check it would fail; the harness waits half a second for such signals first.

Functions§

check_handlers
Grades the kill switch on handlers built on the store open opens: each call must open the same backing store, starting empty, as check_store requires. The store is left empty.
check_store
Grades the HaltStore that open opens. Each call to open must open the same backing store, starting empty, as another replica would, or this process after a restart. The store is left empty.