Skip to content

fix(safety): never guess a boolean in the zero rung - #367

Merged
CameronBrooks11 merged 3 commits into
mainfrom
fix/zero-rung-bool
Oct 15, 2026
Merged

CameronBrooks11 merged 3 commits into
mainfrom
fix/zero-rung-bool

Conversation

@CameronBrooks11

@CameronBrooks11 CameronBrooks11 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

The zero rung of the safe-state ladder (zero_is_safe: true) built a
call for every required argument of every ACTUATE function, and
zero_value(BOOL) returned false. A boolean has no safe pole the
runtime can know: false disables an enable flag but releases a brake
flag. So rung 3 could release a brake as part of a stop.

zero_value(BOOL) now returns nullopt, like string and bytes. Rung 3
skips any function it could only call by guessing a boolean, and reports
it in the ladder's actions as not driven (success: false, error
"cannot zero required non-numeric argument ''") instead of sending
it. Numeric arguments are zeroed as before. The zero_is_safe entry in
docs/configuration-schema.md now says so.

A skipped call never reaches the CallRouter, and trigger() logged only
an INFO summary, so the skip was silent. trigger() now logs one WARN
per failed or skipped action, as the re-assert path does:

[SafeState] E-stop did not drive <device>/<function>: <reason>

A correction to the issue description: rung 3 has run only
CATEGORY_ACTUATE functions since #229 (actuating_functions_for in
core/control/safe_state.cpp), so it does not zero PID gains or write
any CONFIG function. ZeroRungSkipsNonActuateFunctions already pins
that. The boolean pole was the remaining defect.

Tests (tests/unit/safe_state_test.cpp):

  • ZeroRungNeverSendsBoolArgument registers an ACTUATE function whose
    only required argument is a bool, triggers the e-stop with
    zero_is_safe, and expects no provider call and one action reported
    as not driven. On the unfixed code it fails: the StrictMock records
    call("heater", 1, "set_output", {pwm: bool_value: false}).
  • TriggerWarnsForEachActionNotDriven captures the log for the same
    e-stop and expects the WARN line above. Before the logging change it
    fails: the log holds only "E-stop engaged" and the INFO summary.

All 14 SafeStateTest cases pass.

Closes #255

zero_value(BOOL) returned false, so rung 3 sent false for every
required bool argument of an ACTUATE function. On a brake flag that
means release. It now returns nullopt, like string and bytes: rung 3
reports such a function as not driven instead of calling it.

Closes #255
A zero-rung call that is skipped never reaches the CallRouter, and
trigger() logged only an INFO summary, so the skip was silent. Log one
WARN per failed or skipped action, naming the device, function and
reason, as the re-assert path does.

Refs #255
@CameronBrooks11
CameronBrooks11 enabled auto-merge (squash) October 15, 2026 20:41
@CameronBrooks11
CameronBrooks11 merged commit c82e0f7 into main Oct 15, 2026
29 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/zero-rung-bool branch October 15, 2026 20:53
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.

zero_is_safe releases brakes and zeroes PID gains — rung 3 writes to CONFIG functions and guesses boolean safe poles

1 participant