policies — API Reference¶
Policy plugin packages. The base class, PolicyRuntime, and registry live in
core.policy; the types below are the concrete plugins in policies/.
policy (core)¶
core.policy.PolicyBase(policy_id, config)
¶
Bases: ABC
Base control loop. Subclasses implement step(obs) → action.
Source code in core/policy.py
bind_effector(effector)
¶
core.policy.PolicyRuntime(policies, sensors, effectors, relay, hz=10.0)
¶
Runs the node's policy stack on a fixed tick.
Each tick: snapshot sensor readings into the relay, then for each enabled
policy build its observation, step, and apply the action to its effector via
the request lane. always_on policies are ordered first so reflexes run even if
a later cortical policy errors.
Source code in core/policy.py
tick()
¶
One control step (also called directly in tests).
Source code in core/policy.py
core.policy.create_policy(config)
¶
curve¶
policies.curve.policy.CurvePolicy(policy_id, config)
¶
Bases: PolicyBase
A reflex: drive every target channel by a curve over normalized inputs.
params: in_min[], in_max[] (aligned with observation), out_min, out_max.
kind "max_linear" (default): drive = out_min + (out_max-out_min) *
max_i clamp((x_i - in_min_i)/(in_max_i - in_min_i), 0, 1). Missing inputs are
ignored (fail-safe: an absent sensor never forces high output).
Source code in core/policy.py
threshold¶
policies.threshold.policy.ThresholdPolicy(policy_id, config)
¶
Bases: PolicyBase
A guard reflex: trip an effector off when a signal crosses a bound.
Instantiated as the overcurrent guard (ACS712 amps → servo power rail), but generic: any observed signal, any on/off effector driven over the levels lane (1.0 = armed/on, 0.0 = tripped/off).
Config keys (params): trip_above — trip when ANY observed signal exceeds this release_below — re-arm only when ALL signals fall below this (hysteresis: keep well under trip_above) latch — true: once tripped, stay tripped until the policy is disabled/re-enabled or the node restarts (default false)
Behavior notes, deliberate: - Emits an action ONLY on state transitions (trip / release). A guard that re-asserts "on" every tick would fight manual rail control via the effector API; returning {} between transitions leaves the rail alone (PolicyRuntime skips empty actions). - Missing observations never trip (an absent sensor is not an emergency) — but they also never release.