# IoT Control Plane — Complete Machine Reference (llms-full.txt) Canonical site: https://iottodo.com Console & API origin: https://app.iottodo.com ## 1. Security Model (Assume Breach) - Four binaries separated by credentials: iot-gateway (MQTT-mTLS 8883), iot-api (/v1, /mcp, SSE), iot-worker (leased outbox jobs & allowlisted HTTPS egress), iot-authority (independent workspace, SQLite vault, signing keys, zero-framework approve.). - Three-layer device-side verification: - L1: Firmware hard_envelopes burned into signed firmware (immutable). - L2: Customer PolicyBundle signed by Authority with monotonic policy_revision. - L3: One-shot Ed25519 CommandGrant signed after Passkey approval on approve., bound by SHA-256("iot.tx-binding.v1" || ... || boot_nonce || uptime_deadline_ms). - Emergency safe_stop always bypasses daily commercial quotas (429) and AI circuit breakers. - unknown and timed_out commands are never auto-retried. ## 2. Stage 3 Capabilities & Strict Boundaries The Stage 3 and Stage 4 implementations are in the source tree. Centralized acceptance and field verification are pending. - 2D spatial floorplans (PNG/JPEG/WebP, 1..64 MiB, 1..8192 px per side, <=16,777,216 pixels, aligned 8 MiB upload) and declarative ui_templates publish atomically through iot.yaml plan/apply/commitSafetyRelaxation. - Point-in-time historical playback (/v1/projects/{project_id}/history/at) returns only retained observations; missing data is explicit unknown. - Scoped read-only share links (/s/{share_id}#<32B-base64url>): fragment scrubbed via replaceState before fetching, credentials: omit + Authorization: Bearer on same-origin /v1/shares/{share_id}[/events|/assets/{asset_id}], zero device controls, immediate SSE stop on revocation. - Audited remote diagnostics: five fixed read-only commands (log_tail, sys_info, net_diag, heap_stats, tsl_dump) approved via Passkey on approve., hash-chained recordings (iot.debug.chunk.v1). - Advisory anomaly attribution and range suggestions never mutate policy or actuate devices automatically. - Exported NDJSON audit logs verify offline only up to an externally saved trusted chain_head_hex anchor. - MCP budget: 14 / 18 / 18 / 19 tools across Stages 1-4 (max 20, zero approval tools). ## 3. Device Wire Protocol & Enrollment - Enrollment: POST /v1/projects/{project_id}/devices/enroll with Idempotency-Key and PKCS#10 DER CSR (or iot device add). Private keys never leave the device or local workstation. Note: portable_dev_bundle enrolls as custody_tier=none (approved_execution_qualified=false; out-of-range commands are rejected even with approval). - The platform maintains open-source reference firmware for one development board, the Waveshare ESP32-C6-Relay-1CH-U. Other MCUs can implement the public contracts and golden byte vectors in their native language. The open-source directories build standalone with zero private dependencies using their checked-in manifests and lockfiles (enforced in CI via scripts/check-oss-build.py). Independent MCU firmware can also implement directly against the public contracts and golden byte vectors. - Transport: TLS 1.3 mTLS to configurable broker_host:broker_port (no hardcoded IP). - MQTT 3.1.1: topics "up" and "down" only, QoS 1, retain=false, max packet 64 KiB. - Payload: deterministic CBOR (RFC 8949 §4.2). JSON, duplicate keys, non-canonical CBOR, or unknown critical fields are rejected. - All firmware must save the replay watermark and pending command identity together before actuating an ordinary command. If that write fails, leave the output untouched. If power fails before the outcome is saved, report unknown for the original command on recovery and never repeat the action. The reference firmware uses 16 bytes for seq_high and pending_seq, plus storage for the pending identity. Enforce factory hard_envelopes, dwell_and_slew limits, monotonic PolicyBundle revisions, one-shot boot_nonce CommandGrants, and hardware lease watchdogs that return outputs to safe_value on disconnect or timeout. Rust firmware can reuse the zero-heap no_std iot-safety-kernel. Other MCUs must enforce equivalent local checks against the public contracts and golden vectors. The hw_attested tier also requires hardware key attestation and signed safety-kernel evidence. - Public contracts and golden byte vectors: https://iottodo.com/contracts/index.json. Factory provisioning uses https://iottodo.com/contracts/factory-serial/v1.json. For device and claim rekey, use the signing formulas in https://iottodo.com/contracts/device-wire/rekey-v1.schema.json and verify against https://iottodo.com/contracts/device-qr/vectors/claim.json. ## 4. Custody Tiers (Server-Determined) - hw_attested: hardware non-exportable P-256 key (ATECC608C, TPM 2.0, ESP32-C5 eFuse ECDSA + RSA Secure Boot V2) + vendor attestation + signed safety-kernel firmware. - encrypted_nvs: on-chip key in encrypted flash + Secure Boot + Release Flash Encryption + watchdog evidence. - gateway: MQTT/HTTP or Modbus connector with verified power-loss & bus-loss fallback. - none: platform-enforced only; out-of-range actions rejected, no cross-device interlocks. - Excluded from hw_attested: bare ESP32-C3/C6, ATECC608B, AR2026-006 affected silicon (C61<=v1.1, H2/C5<=v1.2, P4<=v3.2, S31 v0.0). - Reference-board qualification is pending, including independent relay feedback. Industrial camera media actions are implemented in Stage 4 source. ## 5. Pricing & Quotas - Security is never paywalled. - Cloud Free initial defaults (configurable): 5 active devices, 2 projects, 30 days history, 10,000 daily calls, 1 GiB storage. - Solo Free (unlicensed): 1 workspace, 1 project, 5 active devices. - Cloud self-serve billing uses Creem checkout/portal managed inside workspace settings; Solo offline licenses are implemented in Stage 4 source (pending qualification). Downgrades include a 7-day grace period. ## 6. Canonical Project Spec Templates (MIT OR Apache-2.0) Catalog: https://iottodo.com/templates/catalog.json - smart-server-room: https://iottodo.com/templates/smart-server-room/iot.yaml (license: MIT OR Apache-2.0, verified_by_ci: false) - industrial-relay: https://iottodo.com/templates/industrial-relay/iot.yaml (license: MIT OR Apache-2.0, verified_by_ci: false) - greenhouse-ai: https://iottodo.com/templates/greenhouse-ai/iot.yaml (license: MIT OR Apache-2.0, verified_by_ci: false) ```yaml # SPDX-FileCopyrightText: IoT Platform contributors # SPDX-License-Identifier: MIT OR Apache-2.0 schema_version: project-spec/v1 project_name: Greenhouse AI control timezone: UTC products: - schema_version: tsl/v1 product_id: greenhouse_heater version: "1.0.0" worst_case_latency_ms: 500 properties: - {id: temperature, data_type: fixed_i64, scale: 1, access: r, unit: "°C", min_scaled: -300, max_scaled: 800} - {id: fan_rpm, data_type: i64, access: r, unit: rpm, min_scaled: 0, max_scaled: 6000} - {id: heater_power, data_type: i64, access: rw, unit: W, min_scaled: 0, max_scaled: 2000, safe_value: 0, on_boot: safe_value, lease_max_ms: 30000, max_continuous_ms: 300000} events: [] services: - id: set_heat risk: high inputs: {watts: i64} physical_writes: {heater_power: {argument: watts}} safety_invariants: device_local: hard_envelopes: [{property_id: heater_power, hard_min_scaled: 0, hard_max_scaled: 2000}] interlocks: - id: airflow_before_heat forbidden_when_all_true: - {property_id: heater_power, op: gt, value: 0} - {property_id: fan_rpm, op: lt, value: 800} dwell_and_slew: - {property_id: heater_power, min_dwell_sec: 10, max_delta_per_min_scaled: 900} release_ranges: properties: {heater_power: {min_scaled: 0, max_scaled: 800}} services: {set_heat: {allowed: true, params: {watts: {min_scaled: 0, max_scaled: 800}}}} slots: - slot_id: seedlings product_ref: greenhouse_heater@1.0.0 cardinality: single release_ranges: properties: {heater_power: {min_scaled: 0, max_scaled: 0}} services: {set_heat: {allowed: true, params: {watts: {min_scaled: 0, max_scaled: 0}}}} alert_ranges: {temperature: {min_scaled: 120, max_scaled: 300}} automation: rules: - id: cold_seedlings enabled: true execution_mode: shadow trigger: {slot_id: seedlings, property_id: temperature, op: lt, value: 160} action: {target_slot_id: seedlings, service_id: set_heat, params: {watts: 400}} schedules: - {id: predawn_heat, cron: "30 5 * * *", timezone: UTC, execution_mode: shadow, target_slot_id: seedlings, service_id: set_heat, params: {watts: 400}} alerts: - {id: seedling_temperature, slot_id: seedlings, severity: warn, for_duration_sec: 60, cooldown_sec: 600} ui_templates: - id: seedling_panel target: device_panel widgets: - {type: metric, label: Canopy temperature, binding: temperature} - {type: gauge, label: Measured fan speed, binding: fan_rpm} - {type: metric, label: Applied heater power, binding: heater_power} ``` ## 7. CLI Commands - iot dev --json - iot login - iot validate / plan / apply / export - iot device add / verify / rekey - iot firmware keygen / sign - iot approvals open - iot sim --replay --fault - iot mcp