ReviewOS

also looking at this

stacks/drone

feat: add shared-clock scoped vehicle simulation sessions

#98
Merged chris wants to merge codex/cargo-fleet-runtime into main
42 files +2764 -127
resources/functions/drone/vehicles/types.tsmodified+7-2
Changes to resources/functions/drone/vehicles/types.ts
@@ -3,7 +3,8 @@ import type { GeodeticOrigin, Quaternion } from '../estimation/frames'
33import type { SensorVector } from '../sensors/types'
44import type { MissionAction, MissionObservation, MissionState } from '../missions/engine'
55
6export type VehicleKind = 'fixed-wing' | 'vtol' | 'ground' | 'surface' | 'subsea'
6export const vehicleKinds = ['quadcopter', 'fixed-wing', 'vtol', 'ground', 'surface', 'subsea'] as const
7export type VehicleKind = typeof vehicleKinds[number]
78export interface VehicleActuator { name: string, unit: 'normalized' | 'newton' | 'radian' | 'metres-per-second', min: number, max: number, neutral: number }
89export interface VehiclePlantState {
910 positionM: SensorVector
@@ -88,7 +89,7 @@ export type VehicleMissionTask =
8889 | { id: string, kind: 'takeoff' | 'waypoint' | 'land' | 'stop', positionM: SensorVector, acceptanceM: number, maxArrivalSpeedMps: number, settleMs: number, timeoutMs: number, next?: string }
8990 | { id: string, kind: 'return', acceptanceM: number, maxArrivalSpeedMps: number, settleMs: number, timeoutMs: number, next: string }
9091 | { id: string, kind: 'loiter', positionM: SensorVector, acceptanceM: number, maxArrivalSpeedMps: number, settleMs: number, timeoutMs: number, next: string }
91 | { id: string, kind: 'payload', operation: VehiclePayloadOperation, containerId: string | null, timeoutMs: number, next: string }
92 | { id: string, kind: 'payload', operation: VehiclePayloadOperation, containerId: string | null, timeoutMs: number, next: string, onFailure?: string }
9293 | { id: string, kind: 'branch', batteryAtLeast: number, then: string, otherwise: string }
9394 | { id: string, kind: 'abort' }
9495/** Explicit v2 profile; v1 quadcopter plans and traces retain their original contract. */
@@ -121,6 +122,8 @@ export interface VehicleMissionSnapshot {
121122 transition?: VehicleVtolTransitionCommand | null
122123 /** Present after entering an explicitly planned transition-failure hover/landing route. */
123124 recovery?: { failedEventId: string | null, failedTaskId: string, hoverTaskId: string, triggeredAtMs: number, cause: 'timeout' | 'controller-aborted' | 'operator-abort' | 'operator-pause' | 'operator-recover', abortRequestedAtMs?: number }
125 /** A declared one-way payload failure route. Landing it does not confirm delivery. */
126 payloadFailure?: { eventId: string, taskId: string, operation: VehiclePayloadOperation, containerId: string | null, reason: 'timeout' | 'rejected' | 'uncertain' | 'scope-mismatch', triggeredAtMs: number, approachTaskId: string, landingTaskId: string }
124127 reason: string
125128 elapsedMs: number
126129}
@@ -171,6 +174,8 @@ export interface VehicleFaults {
171174/** One execution owns its plant, controller, payload and measurement sequence. */
172175export interface VehicleNavigation { update(base: EstimatorSnapshot, measurement: VehicleMeasurement | null, nowMs: number): EstimatorSnapshot }
173176export interface VehicleSession {
177 /** Optional received link evidence on the runtime's monotonic clock, without receipt-time restamping. */
178 linkObservation?(nowMs: number): { capturedAtMs: number, connected: boolean }
174179 createNavigation?(): VehicleNavigation
175180 createPlant(): VehiclePlant
176181 createController(): VehicleController