Skip to content

feat(runtime): surface FunctionPolicy category over /v0 capabilities - #228

Merged
CameronBrooks11 merged 1 commit into
mainfrom
feat/surface-category-actuate
Jul 28, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
feat/surface-category-actuate

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Closes #218.

Problem

The runtime dropped the protocol's FunctionPolicy.Category when flattening device capabilities (build_capabilities didn't read function.policy().category(), the flattened FunctionSpec retained no policy, and encode_function_spec never emitted it). So no consumer could tell which device functions actuate hardware — the missing foundation for a software safe-state command and a refuse-hookless install gate.

Change (3-step plumbing + fail-closed classifier)

  1. FunctionSpec retains category (core/registry/device_registry.hpp), defaulting to CATEGORY_UNSPECIFIED.
  2. build_capabilities populates it from function.policy().category() (proto3 yields UNSPECIFIED when policy is absent — the fail-closed default) and logs a warning for any untagged function.
  3. encode_function_spec emits two new fields over GET /v0/devices/{provider}/{device}/capabilities:
    • category — enum string (UNSPECIFIED/READ/CONFIG/ACTUATE)
    • actuating — fail-closed bool via new registry::is_actuating()

Fail-closed rule: a function is actuating unless it explicitly declares CATEGORY_READ. So UNSPECIFIED (untagged, e.g. a third-party provider), CONFIG (persistent effect), and any unknown/future enum value all count as actuating. This is the locked D6 decision — an untagged provider must not be able to silently defeat the safety gates. is_actuating() is the single classifier the future consumers must use rather than checking == CATEGORY_ACTUATE.

Consumers (separate issues, not in this PR)

Tests & verification (local)

  • C++ unit suite: 363/363 pass. Extended the capabilities test to assert the fail-closed default (untagged → UNSPECIFIED/actuating) and added a mapping test covering ACTUATE/READ/CONFIG plus an out-of-range enum (99) → UNSPECIFIED/actuating, which guards against anyone narrowing is_actuating and keeps the JSON schema-valid.
  • OpenAPI structural + example validators pass; category/actuating added to the FunctionSpec schema (required) and the capabilities example fixture.
  • Live /v0 conformance: 19/19 — the runtime emits the fields and the bundled sim's tags validate against the enum.
  • Reviewed by an independent adversarial pass (proto access safety, fail-closed semantics, no other function-spec emitters missed, style).

Note: clang-format/clang-tidy weren't available in my local env, so the C++ fmt-check/lint lane runs in CI here. Hand-conformed to Google/120-col.

Follow-ups (tracked elsewhere)

  • The "every ADPP function MUST declare a FunctionPolicy.Category" conformance rule belongs in anolis-protocol (deferred, pairs with this).
  • anolis-workbench vendors this OpenAPI schema release-locked; its schema sync should refresh at the next runtime release (its response handling is presence-based, so these additive fields won't break a running workbench).

@CameronBrooks11
CameronBrooks11 force-pushed the feat/surface-category-actuate branch 2 times, most recently from abd96ea to d73947c Compare July 28, 2026 03:41
The runtime dropped the protocol's FunctionPolicy.Category at
build_capabilities, so nothing downstream could tell which device
functions actuate. Retain it on FunctionSpec, populate it from
function.policy().category() (proto3 yields CATEGORY_UNSPECIFIED when
absent), and emit it as `category` plus a fail-closed `actuating` flag
over GET /v0/devices/{p}/{d}/capabilities.

Add registry::is_actuating(): a function is actuating unless it
explicitly declares CATEGORY_READ, so UNSPECIFIED (untagged, e.g.
third-party providers), CONFIG, and any unknown future category all fail
closed. This is the shared dependency for the /v0/estop safe-state
command and the actuator half of the refuse-hookless install gate.

Untagged functions are warned at discovery. The formal "every ADPP
function MUST declare a category" conformance rule is a follow-up in
anolis-protocol.

Closes #218
@CameronBrooks11
CameronBrooks11 force-pushed the feat/surface-category-actuate branch from d73947c to bc64efe Compare July 28, 2026 03:47
@CameronBrooks11
CameronBrooks11 merged commit cf4d524 into main Jul 28, 2026
22 checks passed
@CameronBrooks11
CameronBrooks11 deleted the feat/surface-category-actuate branch July 28, 2026 04:18
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.
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.

Surface CATEGORY_ACTUATE over device capabilities

1 participant