Skip to content

feat(safety): report safe_state_achieved for the e-stop ladder - #368

Merged
CameronBrooks11 merged 3 commits into
mainfrom
fix/estop-safe-state-verdict
Oct 15, 2026
Merged

CameronBrooks11 merged 3 commits into
mainfrom
fix/estop-safe-state-verdict

Conversation

@CameronBrooks11

@CameronBrooks11 CameronBrooks11 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

POST /v0/estop returned 200 with a per-action success and no
overall answer, so a caller had to read every action to learn whether
the stop landed. The response now carries safe_state_achieved.

safe_state_achieved is true only when a rung ran, issued at least
one call, and every call succeeded. It is false when any call of the
active rung failed, when the rung issued no call, and when
software_safe_state is "none". It is computed once in
SafeStateController::run_ladder, so the e-stop trigger and the
per-device re-assert (a latched device that answers again) report the
same verdict. It appears in:

  • the POST /v0/estop response body;
  • the [SafeState] E-stop ladder=... actions=... log line, at INFO
    when achieved and at WARN when not;
  • both re-assert log lines in Runtime::reissue_safe_state_for.

What the verdict does not say, and the docs now state: it covers only
the calls the rung issued, so under hooks it can be true while
actuating functions that no hook drives remain
(uncovered_actuating_functions in GET /v0/runtime/status). A call
succeeds when its provider reports it OK. That confirms the command
was accepted, not that the device was seen in the commanded state.

The field is additive in the OpenAPI contract (EstopResponse,
optional property, documented), the estop.200.json example carries
it, and docs/http-api.md describes it.

There is no fall-through to another rung and no per-hook criticality
key. A call that fails at run time fails mostly on transport, and a
second rung would go to the same unreachable device; there the
device's firmware watchdog is the backstop. A call that cannot dispatch
at all is reported at startup by the preflight.

Tests (tests/unit/safe_state_test.cpp):

  • OneFailedRungCallMeansSafeStateNotAchieved: two hook calls, the
    second fails at the provider; the verdict is false.
  • AllRungCallsSucceedingMeansSafeStateAchieved: one hook call
    succeeds; the verdict is true. With the field declared but not
    computed, this fails (Actual: false, Expected: true).
  • NoRungMeansSafeStateNotAchieved: no declared safe state; false.
  • RungThatIssuesNoCallMeansSafeStateNotAchieved: the zero rung on an
    inventory with no ACTUATE function issues nothing; false.
  • UnachievedVerdictIsLoggedAtWarn: captures the log and expects the
    summary at WARN with safe_state_achieved=false.

Each guard was broken once and caught by exactly one test:

  • the verdict ignoring call outcomes (return true in the all_of
    predicate) fails OneFailedRungCallMeansSafeStateNotAchieved;
  • dropping the !result.actions.empty() guard fails
    RungThatIssuesNoCallMeansSafeStateNotAchieved;
  • logging the unachieved summary at INFO fails
    UnachievedVerdictIsLoggedAtWarn.

The integration e-stop check asserts the field is present and boolean.

Closes #256

CameronBrooks11 and others added 3 commits October 15, 2026 01:35
POST /v0/estop returned 200 with a per-action success and no overall
answer. The response and the ladder and re-assert log lines now carry
safe_state_achieved: true only when a rung ran, issued at least one
call, and every call succeeded.

There is no fall-through to another rung.

Closes #256
The ladder summary line is now WARN when safe_state_achieved is false.
A test pins that a rung which issues no call is not achieved. The
docs say the verdict covers only the calls the rung issued, so under
hooks it can be true while undriven functions remain, and that a
successful call means the provider accepted it, not that the device
was seen in that state.

Refs #256
@CameronBrooks11
CameronBrooks11 enabled auto-merge (squash) October 15, 2026 21:01
@CameronBrooks11
CameronBrooks11 merged commit b5f392c into main Oct 15, 2026
29 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/estop-safe-state-verdict branch October 15, 2026 21:40
CameronBrooks11 added a commit that referenced this pull request Oct 16, 2026
Bumps `project(VERSION)` and `vcpkg.json` to 0.1.45 and rolls the
CHANGELOG. Ships, among others:
- `safety.on_startup`, default `safe_state`: the declared safe state
  runs once at every runtime start (#392, closes #362);
- Grafana and InfluxDB bound to loopback under `--with-observability`,
  with `--with-grafana-network` to open Grafana to the LAN (#359,
  closes #351);
- `install.sh` refuses a downgrade unless `--allow-downgrade` (#382,
  closes #366);
- the zero rung no longer sends a guessed boolean (#367), e-stop
  `safe_state_achieved` (#368), dispatchable coverage counts (#369),
  and startup warnings for fault-hook gaps (#370) and disarmed
  watchdogs (#371);
- `health.excluded_signals` (#377), signal unit and description in
  capabilities (#365);
- a half-open probe of an open provider circuit every 60 s, a restart
  that stops the old process first, and a restart clock that starts
  after it stops (#376, #391);
- automation status: `idle` outside AUTO, and `failed` cleared by a
  load or a new AUTO run (#373, #386);
- `install.sh`: provider liveness in the health phase (#355, #383),
  `manifest.json` restored on `--rollback` (#354), Grafana restarted
  on every observability run (#343), the datasource debug lines
  filtered from the journal (#360), and the uninstall prefix guard
  (#342);
- no ERROR lines for reads that fail during shutdown (#381).

The CHANGELOG opens 0.1.45 with upgrade notes: Grafana is on loopback
by default, `safety.on_startup` drives outputs at boot by default, and
downgrades need `--allow-downgrade`. The 0.1.44 note about restarting
grafana-server by hand is not repeated, since #343 restarts it on
every run.

The OpenAPI changes are additive: `SignalSpec.unit` and
`.description`, `EstopResponse.safe_state_achieved`,
`ParameterDefinition.source` and the runtime status
`startup_safe_state`. No provider-protocol change. anolis-workbench
vendors the OpenAPI file and needs a repin to this release.

Every commit in `git log v0.1.44..main` is in the CHANGELOG except
CI, test-only and docs-lint commits (#380, #384, #389).

After merge, tag `v0.1.45`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protective-stop ladder has no fallback: a failed rung leaves the machine partially actuated with no backstop

1 participant