Skip to content

feat(runtime): refuse-hookless — veto AUTO without safe-state hooks - #231

Merged
CameronBrooks11 merged 2 commits into
mainfrom
feat/refuse-hookless-auto
Jul 28, 2026
Merged

CameronBrooks11 merged 2 commits into
mainfrom
feat/refuse-hookless-auto

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Runtime side of anolishq/anolis-workbench#237. Locked decision D6. The last HARD safety-gate item — with #218 (CATEGORY_ACTUATE), #219 (/v0/estop), and #225 (boot-inert) already merged, this completes the gate.

Guarantee

Autonomous actuation cannot start without a declared safe-state path: the runtime refuses MANUAL -> AUTO when automation is enabled with actuating outputs but no safe-state mode_transition_hooks.

Change — BLOCK-AUTO (maintainer's choice)

  • evaluate_hookless_auto_gate (core/runtime/actuation_gate.{hpp,cpp}): refuses iff automation.enabled AND at least one discovered function is actuating (fail-closed via Surface CATEGORY_ACTUATE over device capabilities #218's registry::is_actuating — any function not explicitly read-only) AND no mode_transition_hooks are declared.
  • Enforced as a before-mode-change veto in init_automation: any transition into AUTO is refused (FAILED_PRECONDITION → HTTP 409) when the gate trips. This is the single choke point into AUTO (BT ticks are mode-gated; AUTO is only reachable via set_mode), re-evaluated against the live registry on each attempt. Manual control and POST /v0/estop stay available; FAULT is never blocked. A startup ERROR log names the actuating outputs.
  • safety.safe_state deliberately does NOT satisfy the gate — it fires only on manual /v0/estop, never on autonomous →FAULT. Only mode_transition_hooks count.

Behavior change

Automation configs with actuating outputs must now declare mode_transition_hooks to enter AUTO (a config whose functions are all read-only is unaffected). I updated the automation/scenario test fixtures and the doc quickstarts (automation.md, getting-started.md, README) accordingly, and added a note to safety.md.

Tests & verification (local)

  • 384/384 C++ unit (automation-on) + 336/336 (no-automation) — 8 gate unit tests pinning the fail-closed classifier (UNSPECIFIED/CONFIG refused, READ allowed, disabled allowed, empty-registry allowed, hook-satisfies).
  • New integration test: automation + actuators + no hooks → MANUAL->AUTO returns 409, and a manual /v0/call still succeeds (manual control survives). Existing automation/scenario AUTO tests pass with the added *->FAULT hook.
  • clang-format + clang-tidy + ruff + mypy clean.

Adversarial branch review

Verdict SHIP — the reviewer confirmed the predicate, veto semantics (FAULT-immune, live re-evaluation, single choke point), thread-safety, and no-automation guarding are all correct. Its should-fixes are addressed in fix(runtime): …: documented the requirement where users hit it (F1), corrected CHANGELOG claims (F2/F3), and strengthened the tests (F4–F6).

Follow-ups (noted, not in this PR)

  • Stronger predicate: require a hook whose to matches FAULT (vs any hook) — the D6 interim checks presence.
  • Re-check the gate on an in-AUTO provider restart that introduces a new actuator.

Guarantee that autonomous actuation cannot start without a declared safe-state
path (decision D6). New evaluate_hookless_auto_gate refuses when automation is
enabled, at least one discovered function is actuating (fail-closed via
registry::is_actuating — any function not explicitly read-only counts), and no
mode_transition_hooks are declared.

Enforced as a before-mode-change veto in init_automation: any transition into
AUTO is refused (FAILED_PRECONDITION -> HTTP 409) when the gate trips. This is
the single choke point into AUTO (BT ticks are mode-gated; AUTO is only
reachable via set_mode), so the guarantee holds for the process lifetime and
re-evaluates against the live registry across provider restarts. Manual control
and POST /v0/estop stay available, and FAULT is never blocked. A loud startup
ERROR log names the actuating outputs when the config is AUTO-refused.

The manual e-stop path (safety.safe_state) deliberately does not satisfy the
gate: it fires only on operator /v0/estop, never on autonomous transitions.

Automation test fixtures gain a *->FAULT safe-state hook so their AUTO tests
still pass; a new integration test asserts AUTO is refused without hooks while
manual control remains.

Implements the runtime side of anolishq/anolis-workbench#237.
- Document the safe-state-hooks requirement where users hit it: the automation
  quickstarts in docs/automation.md, docs/getting-started.md, and README.md
  showed automation enabled against the sim (which has actuators) with no
  mode_transition_hooks, so following them verbatim now 409s on AUTO (F1). Add
  the hook example + a pointer to safety.md; also close an unrelated unclosed
  fence in the README automation block.
- Make the CHANGELOG accurate: the gate re-evaluates per MANUAL->AUTO attempt
  (not continuously during AUTO), and it checks that hooks are declared, not yet
  that a hook targets FAULT (F2/F3, interim per D6).
- Strengthen the integration test to actually issue a manual /v0/call after the
  AUTO refusal, proving manual control survives (F4).
- Add an empty-registry unit case, and use realistic hooks (with a call) in the
  hook-satisfaction unit tests instead of an empty ModeTransitionHookConfig the
  loader would reject (F5/F6).

The stronger predicate (require a hook whose `to` matches FAULT) and re-checking
the gate on an in-AUTO provider restart are noted as follow-ups.
@CameronBrooks11
CameronBrooks11 merged commit c684aba into main Jul 28, 2026
25 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/refuse-hookless-auto branch July 28, 2026 16:33
CameronBrooks11 added a commit that referenced this pull request Jul 30, 2026
Ships the safety spine + health-staleness work that has accumulated on main
since v0.1.38:

- #228 surface FunctionPolicy category over /v0 capabilities (is_actuating)
- #229 POST /v0/estop software safe-state + actuation latch
- #230 install.sh --variant selection + verify-inert boot-inert
- #231 refuse-hookless: veto MANUAL->AUTO without safe-state hooks
- #234 cadence-derived device-liveness staleness (D7 phase 1)
- #235 per-signal quality/freshness into health, new FAULT state (D7 phase 2)

Bumps CMakeLists project VERSION + vcpkg.json, rolls CHANGELOG [Unreleased]
into [0.1.39] (adds the missing phase-2 entry), and updates the runtime_version
in the runtime-http contract examples.
CameronBrooks11 added a commit that referenced this pull request Jul 30, 2026
)

The refuse-hookless AUTO gate (#231) previously lifted its refusal when ANY
mode_transition_hook was declared. A config declaring only a non-FAULT hook
(e.g. AUTO->MANUAL) passed the gate but had no autonomous safe-state path on a
fault — so a behavior-tree fault could leave actuators at their last-commanded
values.

Strengthen the predicate: the gate is satisfied only by a declared hook that
actually fires on the AUTO->FAULT transition — `from` matching AUTO (AUTO/"*"/
omitted) AND `to` matching FAULT (FAULT/"*"/omitted), in either the before- or
after-transition list. This mirrors the runtime's two-filter hook dispatch
(hook_mode_matches(from, prev) && hook_mode_matches(to, next)): a hook covering
only AUTO->MANUAL, or an IDLE->FAULT hook that never fires from AUTO, no longer
satisfies the gate. Message reworded to name the AUTO->FAULT requirement (keeps
the mode_transition_hooks token the integration test asserts); the fail-closed
actuating-output enumeration is unchanged.

No behavior change for configs whose safe-state hook already covers AUTO->FAULT
(incl. the canonical bioreactor-v1 automation/full variants, which use a "*"
from). Pure runtime predicate; actuation_gate.cpp stays automation-namespace-free
and builds ON and OFF.

Closes #232
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.

1 participant