{
  "openapi": "3.1.0",
  "info": {
    "title": "DARKOZA Physical Intelligence API",
    "version": "0.13.0",
    "description": "Account-scoped robotics API with humanoid edge-device enrollment and one-way HTTPS telemetry ingest. Device snapshots are latest-only and tenant-scoped. Physical actuation and task dispatch remain disabled. Adds an account-scoped humanoid telemetry commissioning simulator with physically isolated storage. Adds an atomic account-scoped humanoid commissioning self-test with durable audit reports. Adds an atomic account-scoped humanoid commissioning self-test with durable audit reports."
  },
  "servers": [
    {
      "url": "/robotics-api"
    }
  ],
  "security": [
    {
      "darkozaAccountSession": []
    }
  ],
  "components": {
    "securitySchemes": {
      "darkozaAccountSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "access_token",
        "description": "Existing Darkoza account session. The server also requires the matching csrf_token cookie and validates the session against the account service. Host-prefixed cookie names are also accepted. Do not copy tokens into third-party clients."
      },
      "humanoidDeviceBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "DARKOZA enrolled edge token",
        "description": "One-time device token enrolled by the robot owner. POST requests also require X-Darkoza-Timestamp (Unix seconds) and a single-use X-Darkoza-Nonce."
      }
    },
    "schemas": {
      "Robot": {
        "type": "object",
        "required": [
          "robot_id",
          "vendor",
          "model",
          "embodiment",
          "capabilities"
        ],
        "properties": {
          "robot_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
          },
          "vendor": {
            "type": "string",
            "enum": [
              "abb",
              "agility",
              "anybotics",
              "boston_dynamics",
              "clearpath",
              "custom",
              "darkoza",
              "dji",
              "dobot",
              "figure",
              "franka",
              "generic",
              "kuka",
              "simulation",
              "tesla",
              "unitree",
              "universal_robots"
            ]
          },
          "model": {
            "type": "string",
            "maxLength": 120
          },
          "embodiment": {
            "type": "string",
            "enum": [
              "aerial",
              "fixed_manipulator",
              "humanoid",
              "industrial_arm",
              "industrial_mobile",
              "mobile_base",
              "mobile_manipulator",
              "other",
              "quadruped",
              "service_robot",
              "simulation",
              "tracked_vehicle",
              "underwater"
            ]
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "balance_state_telemetry",
                "battery_state_telemetry",
                "dexterity",
                "fall_detection_telemetry",
                "force_torque_telemetry",
                "human_detection",
                "imu_telemetry",
                "interaction",
                "joint_state_telemetry",
                "locomotion",
                "manipulation",
                "mapping",
                "navigation",
                "object_detection",
                "perception",
                "simulation",
                "speech",
                "telemetry",
                "whole_body_state_telemetry"
              ]
            },
            "maxItems": 19,
            "minItems": 1,
            "uniqueItems": true
          },
          "metadata": {
            "type": "object"
          },
          "connection_state": {
            "type": "string",
            "enum": [
              "disconnected",
              "simulated"
            ]
          }
        }
      },
      "TaskPlan": {
        "type": "object",
        "required": [
          "robot_id",
          "goal"
        ],
        "properties": {
          "robot_id": {
            "type": "string"
          },
          "goal": {
            "type": "string",
            "maxLength": 1000
          },
          "required_capabilities": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "balance_state_telemetry",
                "battery_state_telemetry",
                "dexterity",
                "fall_detection_telemetry",
                "force_torque_telemetry",
                "human_detection",
                "imu_telemetry",
                "interaction",
                "joint_state_telemetry",
                "locomotion",
                "manipulation",
                "mapping",
                "navigation",
                "object_detection",
                "perception",
                "simulation",
                "speech",
                "telemetry",
                "whole_body_state_telemetry"
              ]
            },
            "maxItems": 19
          },
          "approval_required": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        }
      },
      "SimulationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "robot_id",
          "scenario"
        ],
        "properties": {
          "robot_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
          },
          "scenario": {
            "type": "string",
            "enum": [
              "nominal_route",
              "sensor_loss",
              "heartbeat_loss",
              "obstacle_intrusion",
              "emergency_stop",
              "stale_command",
              "fleet_cooperative_delivery",
              "fleet_crossing_conflict",
              "fleet_member_dropout"
            ]
          }
        }
      },
      "MissionStep": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "step_id",
          "robot_id",
          "goal"
        ],
        "properties": {
          "step_id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_-]{1,39}$"
          },
          "robot_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
          },
          "goal": {
            "type": "string",
            "maxLength": 1000
          },
          "required_capabilities": {
            "type": "array",
            "maxItems": 19,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "balance_state_telemetry",
                "battery_state_telemetry",
                "dexterity",
                "fall_detection_telemetry",
                "force_torque_telemetry",
                "human_detection",
                "imu_telemetry",
                "interaction",
                "joint_state_telemetry",
                "locomotion",
                "manipulation",
                "mapping",
                "navigation",
                "object_detection",
                "perception",
                "simulation",
                "speech",
                "telemetry",
                "whole_body_state_telemetry"
              ]
            }
          },
          "depends_on": {
            "type": "array",
            "maxItems": 11,
            "uniqueItems": true,
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MissionPlan": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "title",
          "steps"
        ],
        "properties": {
          "title": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 1000
          },
          "steps": {
            "type": "array",
            "minItems": 2,
            "maxItems": 12,
            "items": {
              "$ref": "#/components/schemas/MissionStep"
            }
          }
        }
      },
      "MissionPlanResult": {
        "type": "object",
        "required": [
          "mission_id",
          "title",
          "steps",
          "status",
          "approval_required",
          "execution_enabled",
          "physical_actuation",
          "task_dispatch"
        ],
        "properties": {
          "mission_id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "planned"
            ]
          },
          "approval_required": {
            "type": "boolean",
            "const": true
          },
          "execution_enabled": {
            "type": "boolean",
            "const": false
          },
          "physical_actuation": {
            "type": "boolean",
            "const": false
          },
          "task_dispatch": {
            "type": "boolean",
            "const": false
          }
        }
      },
      "HumanoidTelemetrySection": {
        "type": "object",
        "required": [
          "state",
          "fresh",
          "age_s",
          "data"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "FRESH",
              "STALE",
              "NOT_SEEN"
            ]
          },
          "fresh": {
            "type": "boolean"
          },
          "age_s": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 86400
          },
          "data": {
            "oneOf": [
              {
                "type": "object"
              },
              {
                "type": "array"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "HumanoidTelemetrySnapshot": {
        "type": "object",
        "required": [
          "schema",
          "robot_id",
          "overall_state",
          "telemetry_only",
          "physical_actuation",
          "task_dispatch",
          "joint_state",
          "imu",
          "diagnostics",
          "battery",
          "tf",
          "force_torque",
          "safety_note"
        ],
        "properties": {
          "schema": {
            "type": "string",
            "const": "darkoza.humanoid-telemetry/v1"
          },
          "robot_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
          },
          "overall_state": {
            "type": "string",
            "enum": [
              "TELEMETRY_READY",
              "DEGRADED",
              "NO_FRESH_TELEMETRY"
            ]
          },
          "telemetry_only": {
            "type": "boolean",
            "const": true
          },
          "physical_actuation": {
            "type": "boolean",
            "const": false
          },
          "task_dispatch": {
            "type": "boolean",
            "const": false
          },
          "joint_state": {
            "$ref": "#/components/schemas/HumanoidTelemetrySection"
          },
          "imu": {
            "$ref": "#/components/schemas/HumanoidTelemetrySection"
          },
          "diagnostics": {
            "$ref": "#/components/schemas/HumanoidTelemetrySection"
          },
          "battery": {
            "$ref": "#/components/schemas/HumanoidTelemetrySection"
          },
          "tf": {
            "$ref": "#/components/schemas/HumanoidTelemetrySection"
          },
          "force_torque": {
            "$ref": "#/components/schemas/HumanoidTelemetrySection"
          },
          "safety_note": {
            "type": "string",
            "maxLength": 256
          }
        }
      },
      "HumanoidTelemetrySimulationRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "robot_id"
        ],
        "properties": {
          "robot_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
          },
          "scenario": {
            "type": "string",
            "enum": [
              "nominal",
              "degraded",
              "no_fresh"
            ],
            "default": "nominal"
          }
        }
      },
      "HumanoidCommissioningSelfTestRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "robot_id"
        ],
        "properties": {
          "robot_id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
          }
        }
      },
      "HumanoidCommissioningSelfTestReport": {
        "type": "object",
        "required": [
          "run_id",
          "robot_id",
          "status",
          "source_mode",
          "scenarios",
          "checks_passed",
          "checks_total",
          "checks",
          "simulation_rows_remaining",
          "physical_actuation",
          "task_dispatch",
          "created_at"
        ],
        "properties": {
          "run_id": {
            "type": "string",
            "pattern": "^hcr_[a-f0-9]{24}$"
          },
          "robot_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "PASS",
              "FAIL"
            ]
          },
          "source_mode": {
            "type": "string",
            "const": "SIMULATED_TEST_ONLY"
          },
          "scenarios": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "nominal",
                "degraded",
                "no_fresh"
              ]
            }
          },
          "checks_passed": {
            "type": "integer",
            "minimum": 0
          },
          "checks_total": {
            "type": "integer",
            "minimum": 1
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "check",
                "status",
                "detail"
              ],
              "properties": {
                "check": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "PASS",
                    "FAIL"
                  ]
                },
                "detail": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "simulation_rows_remaining": {
            "type": "integer",
            "const": 0
          },
          "physical_actuation": {
            "type": "boolean",
            "const": false
          },
          "task_dispatch": {
            "type": "boolean",
            "const": false
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "paths": {
    "/health": {
      "get": {
        "security": [],
        "summary": "Non-sensitive service health",
        "responses": {
          "200": {
            "description": "Planning-only service health"
          }
        }
      }
    },
    "/v1/capabilities": {
      "get": {
        "security": [],
        "summary": "Supported capability and vendor catalog",
        "responses": {
          "200": {
            "description": "Capability catalog"
          }
        }
      }
    },
    "/v1/robots": {
      "get": {
        "summary": "List robots belonging to the signed-in account",
        "responses": {
          "200": {
            "description": "Account-scoped robot list"
          },
          "401": {
            "description": "Authentication required"
          },
          "503": {
            "description": "Account verification unavailable"
          }
        }
      },
      "post": {
        "summary": "Register a disconnected or simulated robot profile",
        "description": "Requires Origin https://darkoza.com and a valid Darkoza access + CSRF cookie pair. Physical connections are rejected.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Robot"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Robot profile registered"
          },
          "400": {
            "description": "Invalid robot profile"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Origin rejected"
          },
          "409": {
            "description": "Robot ID already exists in this account"
          }
        }
      }
    },
    "/v1/tasks": {
      "get": {
        "summary": "List task plans belonging to the signed-in account",
        "responses": {
          "200": {
            "description": "Account-scoped task plans"
          },
          "401": {
            "description": "Authentication required"
          }
        }
      },
      "post": {
        "summary": "Create a task plan without executing it",
        "description": "Human approval is mandatory. The task is persisted as planned and cannot be dispatched by API v0.2.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskPlan"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Task plan created"
          },
          "400": {
            "description": "Invalid plan"
          },
          "401": {
            "description": "Authentication required"
          },
          "404": {
            "description": "Robot not found in this account"
          }
        }
      }
    },
    "/v1/execute": {
      "post": {
        "security": [],
        "summary": "Execution is disabled",
        "responses": {
          "403": {
            "description": "Physical execution disabled in this release"
          }
        },
        "description": "Physical execution and dispatch remain disabled. Returns HTTP 403."
      }
    },
    "/v1/bootstrap": {
      "post": {
        "summary": "Create a reference R0 profile for an empty account",
        "description": "Requires a valid Darkoza account session, matching CSRF cookie and Origin https://darkoza.com. Idempotent. Creates only a disconnected reference digital-twin profile, and only if the account has no robot profiles. Does not connect hardware or run a simulator.",
        "responses": {
          "201": {
            "description": "Reference R0 profile created"
          },
          "200": {
            "description": "Account already has robot profiles; no change"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Origin rejected"
          },
          "503": {
            "description": "Account verification unavailable"
          }
        }
      }
    },
    "/v1/simulation/status": {
      "get": {
        "summary": "Read the R0 simulation runtime status for the signed-in account",
        "description": "Read-only runtime status for the signed-in account. The separately available request-scoped Python kinematic twin is not ROS 2/Gazebo physics. Runtime telemetry is fail-closed when stale. Never dispatches commands or enables physical actuation.",
        "responses": {
          "200": {
            "description": "Process state and read-only ROS safety state; hardware_connected and physical_actuation are always false"
          },
          "401": {
            "description": "Authentication required"
          },
          "404": {
            "description": "No reference R0 simulation profile exists for this account"
          },
          "503": {
            "description": "Account verification unavailable"
          }
        }
      }
    },
    "/v1/simulations": {
      "get": {
        "summary": "List the signed-in account's latest 25 simulation runs",
        "description": "Requires the authoritative account session. Results are tenant-scoped and do not include hardware telemetry.",
        "responses": {
          "200": {
            "description": "Account-scoped simulation run history"
          },
          "401": {
            "description": "Authentication required"
          },
          "503": {
            "description": "Account verification unavailable"
          }
        }
      },
      "post": {
        "summary": "Run a bounded deterministic R0 software-kinematic scenario",
        "description": "Requires the authoritative account session, same-origin Origin and CSRF. Accepts only a registered vendor=simulation, embodiment=simulation profile belonging to the current account. The six R0 scenarios use the pure-Python kinematic twin; three fleet scenarios use a deterministic discrete-grid scheduler for three abstract agents. No arbitrary speed, network address, ROS topic, actuator or hardware command is accepted. Fleet grid coordinates are abstract cells, not metres. No ROS 2/Gazebo physics, distributed device communication, hardware-in-loop or certification.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SimulationRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Simulation result and safety evidence persisted"
          },
          "400": {
            "description": "Invalid scenario or request fields"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Wrong origin or non-simulation robot profile"
          },
          "404": {
            "description": "Robot profile not registered in this account"
          },
          "429": {
            "description": "Per-account retained simulation limit reached"
          }
        }
      }
    },
    "/v1/mission-plans": {
      "get": {
        "summary": "List the signed-in account's latest 25 multi-robot mission plans",
        "responses": {
          "200": {
            "description": "Account-scoped mission plans"
          },
          "401": {
            "description": "Authentication required"
          }
        }
      },
      "post": {
        "summary": "Atomically validate and store a 2-12 step multi-robot mission plan without dispatch",
        "security": [
          {
            "accountSession": []
          },
          {
            "csrfOrigin": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MissionPlan"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Planned mission and its approval-required task rows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MissionPlanResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid step, dependency or robot capability"
          },
          "401": {
            "description": "Authentication required"
          },
          "403": {
            "description": "Origin or robot profile blocked"
          },
          "404": {
            "description": "Robot not owned by this account"
          },
          "429": {
            "description": "Mission plan retention quota reached"
          }
        }
      }
    },
    "/v1/mission-plans/{mission_id}/assurance": {
      "get": {
        "summary": "Run a read-only structural assurance check for an account-owned multi-robot mission plan",
        "operationId": "getMissionPlanAssurance",
        "parameters": [
          {
            "name": "mission_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Structural assurance report; physical execution remains blocked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "PASS",
                        "FAIL"
                      ]
                    },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "plan_sha256": {
                      "type": "string"
                    },
                    "execution_gate": {
                      "type": "string",
                      "const": "BLOCKED"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Account authentication required"
          },
          "404": {
            "description": "Mission plan not found for this account"
          }
        }
      }
    },
    "/v1/humanoid/contract": {
      "get": {
        "summary": "Read the vendor-neutral humanoid telemetry integration contract",
        "description": "Public, read-only contract. Describes a robot-side ROS 2 telemetry gateway; it does not connect hardware or enable physical motion.",
        "responses": {
          "200": {
            "description": "Humanoid integration contract; vendor adapters and physical actuation remain unvalidated and disabled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schema": {
                      "type": "string",
                      "const": "darkoza.humanoid-integration/v1"
                    },
                    "adapter": {
                      "type": "object"
                    },
                    "telemetry_capabilities": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "ros2_interfaces": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "reference_model_catalog": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "physical_actuation": {
                      "type": "boolean",
                      "const": false
                    },
                    "task_dispatch": {
                      "type": "boolean",
                      "const": false
                    },
                    "execution_mode": {
                      "type": "string",
                      "const": "planning_only"
                    }
                  },
                  "required": [
                    "schema",
                    "adapter",
                    "physical_actuation",
                    "task_dispatch",
                    "execution_mode"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/humanoid/devices": {
      "get": {
        "summary": "List account-scoped humanoid edge devices",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Enrolled devices. Token secrets are never returned."
          },
          "401": {
            "description": "Account session required"
          }
        }
      },
      "post": {
        "summary": "Enroll a read-only humanoid edge gateway",
        "description": "Requires an account session and same-origin request. Returns a 256-bit random device token once; only its SHA-256 hash is stored.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "robot_id"
                ],
                "properties": {
                  "robot_id": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 80
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Device enrolled; token is revealed once."
          },
          "400": {
            "description": "Invalid or non-humanoid profile"
          },
          "401": {
            "description": "Account session required"
          },
          "403": {
            "description": "Origin rejected"
          }
        }
      }
    },
    "/v1/humanoid/devices/{device_id}": {
      "delete": {
        "summary": "Revoke a humanoid edge token",
        "description": "Immediately prevents future uploads and removes the current telemetry snapshot for the device.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "parameters": [
          {
            "name": "device_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^hd_[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Device token revoked"
          },
          "404": {
            "description": "Device not found in this account"
          }
        }
      }
    },
    "/v1/humanoid/telemetry": {
      "get": {
        "summary": "Read the latest account-scoped humanoid telemetry snapshot",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "parameters": [
          {
            "name": "robot_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Latest snapshot or no-data state"
          },
          "401": {
            "description": "Account session required"
          }
        }
      },
      "post": {
        "summary": "Ingest one read-only humanoid telemetry snapshot",
        "description": "Machine-to-machine HTTPS endpoint. Requires an enrolled device bearer token, a timestamp within 90 seconds and a single-use nonce. Stores only the latest snapshot per device. Rejects actuation/dispatch claims.",
        "security": [
          {
            "humanoidDeviceBearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-Darkoza-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{10,12}$"
            }
          },
          {
            "name": "X-Darkoza-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 20,
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HumanoidTelemetrySnapshot"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Snapshot accepted"
          },
          "400": {
            "description": "Invalid snapshot"
          },
          "401": {
            "description": "Invalid, expired, revoked or replayed device authentication"
          },
          "413": {
            "description": "Payload too large"
          }
        }
      }
    },
    "/v1/humanoid/telemetry/simulation": {
      "get": {
        "summary": "Read the latest simulated humanoid commissioning snapshot",
        "description": "Owner-session-only route. Returns only records from the separate simulation table; never reads physical device telemetry.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "parameters": [
          {
            "name": "robot_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SIMULATED snapshot or no-data state"
          },
          "401": {
            "description": "Account session required"
          },
          "404": {
            "description": "Profile not found in this account"
          }
        }
      },
      "post": {
        "summary": "Generate one simulated humanoid telemetry sample",
        "description": "Creates or advances a sample in humanoid_telemetry_sim_latest only. This endpoint does not enroll a device, use a device token or write to humanoid_telemetry_latest.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HumanoidTelemetrySimulationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SIMULATED sample generated"
          },
          "400": {
            "description": "Invalid scenario or non-humanoid profile"
          },
          "401": {
            "description": "Account session required"
          },
          "404": {
            "description": "Profile not found"
          }
        }
      },
      "delete": {
        "summary": "Clear simulated commissioning data",
        "description": "Deletes only the account-owned simulation snapshot. The physical device telemetry table is not modified.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "parameters": [
          {
            "name": "robot_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Simulation snapshot cleared"
          },
          "401": {
            "description": "Account session required"
          },
          "404": {
            "description": "Profile not found"
          }
        }
      }
    },
    "/v1/humanoid/commissioning/self-test": {
      "post": {
        "summary": "Run an atomic humanoid commissioning self-test",
        "description": "Requires the owner account session and same-origin mutation protection. Under one SQLite write transaction, temporarily writes and reads the nominal, degraded and no_fresh simulation scenarios, removes all temporary simulation rows, verifies physical tables are unchanged, then persists only a report row and audit event. Refuses to run if an existing simulation snapshot is present. Never sends hardware commands.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HumanoidCommissioningSelfTestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Commissioning report (status PASS or FAIL)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HumanoidCommissioningSelfTestReport"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Account session required"
          },
          "403": {
            "description": "Origin rejected"
          },
          "404": {
            "description": "Humanoid profile not found"
          },
          "409": {
            "description": "Existing simulation snapshot preserved; test not run"
          }
        }
      }
    },
    "/v1/humanoid/commissioning/reports": {
      "get": {
        "summary": "List account-scoped humanoid commissioning reports",
        "description": "Returns the most recent persisted commissioning reports for an account-owned humanoid profile.",
        "security": [
          {
            "darkozaAccountSession": []
          }
        ],
        "parameters": [
          {
            "name": "robot_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9._-]{1,63}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recent reports"
          },
          "401": {
            "description": "Account session required"
          },
          "404": {
            "description": "Profile not found"
          }
        }
      }
    }
  }
}
