tpt-rust5

Rust

Safety guardrails for the TUP platform — interlocks, rate limiters, and actuation gating between optimized setpoints and physical hardware.

0 stars0 forks0 watchers

Languages

Rust100.0%
README

tpt-rust5 — The Reflexes & Safety Guardrails

Final safety and control layer for the TUP platform. Before the Brain's optimal setpoints reach physical hardware, the Reflexes layer guarantees every command is mechanically safe, logically permitted, and properly prioritized.

See spec.txt for the full crate inventory and design rationale, and todo.md for the build checklist this workspace was produced from.

Why this exists

Rust has basic PID crates, but almost no infrastructure for industrial safety guardrails: interlocks, priority arbitration, rate limiting, and safe actuation gating. Without it, automated optimization can destroy physical hardware. tpt-rust5 fills that gap.

Core principles

  • Safety Over Optimization — an E-stop or mechanical interlock always overrides the Brain's most profitable mathematical solution.
  • Mechanical Empathy — valves cause water hammer, motors draw inrush current; rate limiters, deadbands, and hysteresis protect the hardware.
  • Absolute Auditability — every blocked, modified, or executed command carries a reason code produced by the deciding layer.

Crate layout

CrateRoleBuild profile
tpt-control-actionCore setpoint/state traits + TUP command envelope mappingno_std + alloc
tpt-control-limiterSaturation, deadband, hysteresisno_std + alloc
tpt-control-ratelimitSlew-rate limiter, ramp generatorno_std + alloc
tpt-safety-interlockBoolean permissive/blocking evaluation engineno_std + alloc
tpt-safety-envelopeAlarms, E-stop, safe-state degradationno_std + alloc
tpt-control-priorityPriority arbitration (Safety > Manual > Auto > Schedule)no_std + alloc
tpt-state-machineDeterministic, auditable FSMsno_std + alloc
tpt-control-dryrunShadow execution / diff against live statestd
tpt-control-auditReason-code logging + persistence backend traitno_std core, std feature
tpt-actuation-gateFinal pre-flight validation pipelinestd

Data flow

Read Path — receives proposed TUP Command Envelopes (from tpt-dispatch-solve in tpt-rust4) and reads live hardware state (from tpt-state-snapshot in tpt-rust3).

Write Path — passes validated, safe TUP Commands to tpt-protocol-daemon for execution.

proposed envelope ─┐
                   ▼
            tpt-control-priority  (arbitrate competing sources)
                   ▼
            tpt-safety-interlock  (permissives / blocking conditions)
                   ▼
     tpt-control-limiter ─ tpt-control-ratelimit  (mechanical empathy)
                   ▼
            tpt-safety-envelope  (alarms, E-stop always wins, safe-state)
                   ▼
            tpt-control-dryrun  (optional shadow verification)
                   ▼
            tpt-actuation-gate  ──► validated command ──► tpt-protocol-daemon
                   │
            tpt-control-audit  (reason code per decision point)

Known upstream gaps (external blockers)

These are documented in detail in docs/KNOWN_GAPS.md. In short:

  1. TUP Command Envelope (write direction)tpt-protocol's SPEC-TUP.md is telemetry-only today. The write/setpoint envelope does not yet exist upstream. tpt-rust5 defines the internal command model (CommandEnvelope in tpt-control-action) and is ready to map to the upstream schema the moment it lands; the mapping layer is the single place that will change.
  2. tpt-protocol-daemon command-ingest API — the daemon currently streams telemetry outbound only. The final hand-off in tpt-actuation-gate therefore emits a well-defined ValidatedCommand type rather than calling a not-yet-existing ingest API.

Live-state integration

tpt-rust3's tpt-state-snapshot and tpt-audit-trail are consumed through local traits (LiveStateProvider, PersistentAuditStore) so the workspace builds and tests fully with mock implementations. The real upstream crates drop in behind those traits once available.

License

Dual-licensed under MIT and Apache-2.0.