# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/what-sensor-attestation-proofs-must-accompany-physical-actuator-commands-in-autonomous-robotics.md # Remnant Warrant: https://corpusfetch.com/c/what-sensor-attestation-proofs-must-accompany-physical-actuator-commands-in-autonomous-robotics.warrant.json # Markdown SHA-256: 1cdeb3c0b9283bab9557d5fd84529a04c04645f8168c3fc6e705810833135897 # Code AST SHA-256: 2bde230e72aab1778e7a09dfa865ed6f7fafae87797e8f2b84c3cd466a5f0bd0 # Verified Classes: ActuatorVerdict, SensorReading, ActuatorCommand, ActuationManifest, HardwareRootOfTrustGuard # Defensive Guards: 0 fail-closed invariants (zero external deps) from dataclasses import dataclass from enum import Enum, auto import hashlib import json class ActuatorVerdict(Enum): SAFE_TO_ACTUATE = auto() HALT_SPOOFING_DETECTED = auto() HALT_SENSOR_DEGRADED = auto() HALT_NO_ATTESTATION = auto() @dataclass(frozen=True) class SensorReading: sensor_id: str raw_data_hash: str attestation_signature: str | None health_receipt_hash: str | None @dataclass(frozen=True) class ActuatorCommand: command_id: str nonce: str expected_sensor_id: str @dataclass(frozen=True) class ActuationManifest: verdict: ActuatorVerdict directive: str manifest_digest: str class HardwareRootOfTrustGuard: @staticmethod def _hash(data: str) -> str: return hashlib.sha256(data.encode("utf-8")).hexdigest() @classmethod def evaluate_actuation( cls, reading: SensorReading, command: ActuatorCommand ) -> ActuationManifest: # Gate 1: Hardware attestation presence if not reading.attestation_signature: return ActuationManifest( verdict=ActuatorVerdict.HALT_NO_ATTESTATION, directive="HALT: Sensor reading lacks hardware attestation. Engage physical failsafe.", manifest_digest=cls._hash(f"NO_ATTEST:{command.command_id}") ) # Gate 2: Sensor health if not reading.health_receipt_hash: return ActuationManifest( verdict=ActuatorVerdict.HALT_SENSOR_DEGRADED, directive="HALT: Sensor health receipt missing. Potential hardware tampering.", manifest_digest=cls._hash(f"DEGRADED:{reading.sensor_id}") ) # Gate 3: Sensor identity match if reading.sensor_id != command.expected_sensor_id: return ActuationManifest( verdict=ActuatorVerdict.HALT_SPOOFING_DETECTED, directive=f"HALT: Command expected sensor {command.expected_sensor_id}, received {reading.sensor_id}.", manifest_digest=cls._hash(f"SENSOR_MISMATCH:{command.command_id}") ) # Gate 4: Safe to actuate digest = cls._hash(json.dumps({ "command": command.command_id, "sensor": reading.sensor_id, "nonce": command.nonce, "attestation": reading.attestation_signature }, sort_keys=True)) return ActuationManifest( verdict=ActuatorVerdict.SAFE_TO_ACTUATE, directive="PROCEED: Hardware root of trust verified. Execute actuator command.", manifest_digest=digest )