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/cargo/delivery.tsadded+236-0
Changes to resources/functions/drone/cargo/delivery.ts
@@ -0,0 +1,236 @@
1import type { SensorVector } from '../sensors/types'
2import type { CargoBodySeparation, CargoLoadSnapshot } from './types'
3import type { VehicleControllerContext, VehiclePayloadCommand, VehiclePlant, VehicleSession } from '../vehicles/types'
4import { createRigidBody } from '../controls/physics'
5import { multirotorModel } from '../controls/model'
6import { createMultirotorPlant, createMultirotorProfile } from '../vehicles/multirotor/profile'
7import { runVehicleSimulation } from '../vehicles/runtime'
8import { createRedundantVehicleLinks } from '../vehicles/links'
9import type { CargoDeliveryConfiguration } from './plan'
10import { planCargoDelivery } from './plan'
11import type { CargoDeliveryCustody } from './coordinator'
12import { createCargoDeliveryCoordinator } from './coordinator'
13
14const flightFaults = ['position-loss', 'imu-loss', 'vehicle-sensor-loss', 'rc-override', 'kill', 'host-loss'] as const
15const phaseFaultDefinitions = {
16 'after-release-host-loss': { phase: 'after-release', fault: 'hostLost' },
17 'after-release-position-loss': { phase: 'after-release', fault: 'dropPosition' },
18 'after-release-imu-loss': { phase: 'after-release', fault: 'dropImu' },
19 'after-release-vehicle-sensor-loss': { phase: 'after-release', fault: 'dropVehicleSensor' },
20 'after-release-rc-override': { phase: 'after-release', fault: 'rcOverride' },
21 'after-release-kill': { phase: 'after-release', fault: 'kill' },
22 'after-release-both-links-loss': { phase: 'after-release', fault: 'links' },
23 'after-receipt-host-loss': { phase: 'after-receipt', fault: 'hostLost' },
24 'after-receipt-kill': { phase: 'after-receipt', fault: 'kill' },
25 'after-receipt-position-loss': { phase: 'after-receipt', fault: 'dropPosition' },
26} as const
27const phaseFaults = Object.keys(phaseFaultDefinitions) as (keyof typeof phaseFaultDefinitions)[]
28function phaseFault(scenario: string) { return Object.hasOwn(phaseFaultDefinitions, scenario) ? phaseFaultDefinitions[scenario as keyof typeof phaseFaultDefinitions] : null }
29export const cargoDeliveryScenarios = ['nominal', 'recipient-absent', 'site-blocked', 'mechanism-jam', 'receipt-loss', 'foreign-receipt', 'primary-link-loss', 'both-links-loss', 'authority-containment', 'diversion-position-loss', 'diversion-kill', ...flightFaults, ...phaseFaults] as const
30type CargoDeliveryScenario = typeof cargoDeliveryScenarios[number]
31interface Parcel { massKg: number, positionM: SensorVector, velocityMps: SensorVector, onSurface: boolean, capturedAtMs: number }
32type DeliveryRelease = CargoBodySeparation & { atMs: number, eventId: string }
33type DeliveryLinkSnapshot = ReturnType<ReturnType<typeof createRedundantVehicleLinks>['snapshot']>
34interface DeliveryFaultInjection { phase: 'after-release' | 'after-receipt', anchoredAtMs: number | null, sourceCapturedAtMs: number | null, eventId: string | null, triggeredAtMs: number | null, independentTailMs: number, finalPhysicalAtMs: number }
35export interface CargoDeliveryResult {
36 version: 1
37 evidence: 'owned-cargo-delivery-simulation'
38 scenario: CargoDeliveryScenario
39 status: ReturnType<typeof runVehicleSimulation>['status'] | 'diverted'
40 physicalFlightEnabled: false
41 boardOutputsInhibited: true
42 identityAuthenticated: false
43 faultInjection?: DeliveryFaultInjection
44 configuration?: CargoDeliveryConfiguration
45 delivery: CargoDeliveryCustody
46 initialLoad: CargoLoadSnapshot
47 finalLoad: CargoLoadSnapshot
48 release: DeliveryRelease | null
49 parcel: Parcel | null
50 links: DeliveryLinkSnapshot
51 linkEvents: DeliveryLinkSnapshot[]
52 runtime: ReturnType<typeof runVehicleSimulation>
53}
54const fixtureConfiguration: CargoDeliveryConfiguration = { version: 1, id: 'cargo-shared-delivery', delivery: { origin: { latitudeDeg: 0, longitudeDeg: 0, ellipsoidHeightM: 100 }, site: { id: 'fixture-receiver-site', recipientId: 'fixture-recipient', containerId: 'parcel-100g', positionM: [3, 0, 0], radiusM: .35 }, releaseHeightM: 1 }, load: { massKg: .1, forwardM: .08 }, alternateM: [1.5, -2, 0], power: { availableWh: 40, maxW: 600, reservePercent: 30 } }
55function captureInput(input: unknown) {
56 if (!input || typeof input !== 'object' || Object.getPrototypeOf(input) !== Object.prototype || Reflect.ownKeys(input).some(key => key !== 'scenario' && key !== 'configuration')) throw new TypeError('cargo-delivery-input')
57 const d = Object.getOwnPropertyDescriptor(input, 'scenario'), config = Object.getOwnPropertyDescriptor(input, 'configuration')
58 if (d && (!d.enumerable || !Object.hasOwn(d, 'value') || !cargoDeliveryScenarios.some(value => value === d.value)) || config && (!config.enumerable || !Object.hasOwn(config, 'value') || config.value === undefined)) throw new TypeError('cargo-delivery-input')
59 return { scenario: (d?.value ?? 'nominal') as CargoDeliveryScenario, explicit: !!config, planned: planCargoDelivery(config ? config.value : fixtureConfiguration) }
60}
61
62/** Fictional local delivery with real modeled mass change and received, delayed evidence. No physical transport. */
63export function simulateCargoDelivery(input: unknown = {}): CargoDeliveryResult {
64 const captured = captureInput(input), { scenario, planned } = captured, configuration = planned.configuration
65 const selectedSite = configuration.delivery.site
66 const site = { ...selectedSite, northM: selectedSite.positionM[0], eastM: selectedSite.positionM[1], downM: selectedSite.positionM[2] }
67 const flightScenario = flightFaults.find(value => value === scenario) ?? 'nominal'
68 const selectedFault = phaseFault(scenario)
69 const faultInjection: DeliveryFaultInjection | null = selectedFault ? { phase: selectedFault.phase, anchoredAtMs: null, sourceCapturedAtMs: null, eventId: null, triggeredAtMs: null, independentTailMs: 1000, finalPhysicalAtMs: 0 } : null
70 const profile = createMultirotorProfile(flightScenario), baseSession = profile.createSession, baseFaults = profile.faults
71 profile.mission = planned.mission
72 profile.scenario = scenario
73 profile.scenarios = [...cargoDeliveryScenarios]
74 profile.name = 'Owned modeled cargo delivery'
75 if (scenario === 'authority-containment') profile.authorityFence = { ...profile.authorityFence, radiusM: 2 }
76 profile.faults = (selected, atMs, phase) => {
77 if (selected !== scenario) throw new TypeError('cargo-delivery-scenario-changed')
78 const base = baseFaults(flightScenario, atMs, phase), failureAtMs = observed?.mission.payloadFailure?.triggeredAtMs
79 const diversionFault = failureAtMs !== undefined && atMs >= failureAtMs + 200
80 if (phase === 'host' && faultInjection && faultInjection.anchoredAtMs !== null && atMs >= faultInjection.anchoredAtMs + 20) faultInjection.triggeredAtMs ??= atMs
81 const phaseActive = faultInjection !== null && faultInjection.triggeredAtMs !== null && atMs >= faultInjection.triggeredAtMs
82 const fault = phaseActive ? selectedFault?.fault : null
83 return { ...base, dropPosition: base.dropPosition || scenario === 'diversion-position-loss' && diversionFault || fault === 'dropPosition', kill: base.kill || scenario === 'diversion-kill' && diversionFault || fault === 'kill',
84 hostLost: base.hostLost || fault === 'hostLost', dropImu: base.dropImu || fault === 'dropImu', dropVehicleSensor: base.dropVehicleSensor || fault === 'dropVehicleSensor', rcOverride: base.rcOverride || fault === 'rcOverride' }
85 }
86 const body = createRigidBody({ positionM: [0, 0, -.1], groundDownM: -.1, carriedPointLoad: { id: site.containerId, ...configuration.load } })
87 const initialLoad = body.loadSnapshot(), adapted = createMultirotorPlant(body)
88 let physicalAtMs = 600, parcel: Parcel | null = null, release: DeliveryRelease | null = null
89 let armed: VehiclePayloadCommand | null = null, observed: VehicleControllerContext | null = null
90 let receiptAtMs: number | null = null
91 let mechanismAttempt: { eventId: string, atMs: number, jammed: boolean } | null = null
92 const coordinator = createCargoDeliveryCoordinator(configuration.delivery, {
93 evidence: 'modeled-cargo-mechanism',
94 request(command) { armed = structuredClone(command) },
95 cancel(eventId) { if (armed?.eventId === eventId) armed = null },
96 })
97 const linkScope = { vehicleId: 'carrier-a', bootId: 55, sessionId: 123 }, linkMonitor = createRedundantVehicleLinks(linkScope)
98 const linkQueue: { sourceId: 'primary' | 'backup', sequence: number, capturedAtMs: number, receivedAtMs: number }[] = [], linkEvents: DeliveryLinkSnapshot[] = []
99 let links = linkMonitor.snapshot(0), linkSequence = 0
100 function snapshot() {
101 const state = adapted.snapshot(), load = body.loadSnapshot()
102 return { ...state, details: { ...state.details, loadAttached: load.properties.phase === 'attached', loadMassKg: load.properties.totalMassKg } }
103 }
104 const plant: VehiclePlant = { snapshot, step(actuators, dtS, environment) {
105 if (dtS !== .004) throw new RangeError('cargo-delivery-physical-step')
106 adapted.step(actuators, dtS, environment)
107 physicalAtMs += 4
108 if (parcel && !parcel.onSurface) {
109 parcel.velocityMps[2] += multirotorModel.gravityMps2 * dtS
110 parcel.positionM = parcel.positionM.map((n, i) => n + parcel!.velocityMps[i]! * dtS) as SensorVector
111 parcel.capturedAtMs = physicalAtMs
112 if (parcel.positionM[2] >= site.downM) {
113 parcel.positionM[2] = site.downM; parcel.velocityMps = [0, 0, 0]; parcel.onSurface = true
114 if (Math.hypot(parcel.positionM[0] - site.northM, parcel.positionM[1] - site.eastM) <= site.radiusM) receiptAtMs = physicalAtMs
115 }
116 }
117 if (armed && mechanismAttempt === null && physicalAtMs > armed.issuedAtMs) {
118 if (physicalAtMs >= armed.expiresAtMs) { armed = null }
119 else {
120 mechanismAttempt = { eventId: armed.eventId, atMs: physicalAtMs, jammed: scenario === 'mechanism-jam' }
121 if (mechanismAttempt.jammed) { armed = null; return snapshot() }
122 const event = body.separateCarriedLoad()
123 release = { ...event, atMs: physicalAtMs, eventId: armed.eventId }; armed = null
124 if (event.outcome === 'separated') parcel = { ...event.parcel, onSurface: false, capturedAtMs: physicalAtMs }
125 }
126 }
127 return snapshot()
128 } }
129 profile.createSession = (): VehicleSession => {
130 const base = baseSession()
131 return { ...base, createPlant: () => plant,
132 linkObservation(nowMs) {
133 linkSequence++
134 for (const sourceId of ['primary', 'backup'] as const) {
135 if (nowMs >= 5000 && (scenario === 'both-links-loss' || sourceId === 'primary' && scenario === 'primary-link-loss')
136 || selectedFault?.fault === 'links' && faultInjection && faultInjection.triggeredAtMs !== null && nowMs >= faultInjection.triggeredAtMs) continue
137 linkQueue.push({ sourceId, sequence: linkSequence, capturedAtMs: nowMs, receivedAtMs: nowMs + (sourceId === 'primary' ? 20 : 40) })
138 }
139 linkQueue.sort((a, b) => a.receivedAtMs - b.receivedAtMs)
140 while (linkQueue[0] && linkQueue[0].receivedAtMs <= nowMs) {
141 const packet = linkQueue.shift()!
142 linkMonitor.ingest({ ...linkScope, ...packet, clockUncertaintyMs: 1, connected: true }, nowMs)
143 }
144 links = linkMonitor.snapshot(nowMs)
145 const previous = linkEvents.at(-1)
146 if (!previous || links.selectedSource !== previous.selectedSource || links.latchedLoss !== previous.latchedLoss) {
147 if (linkEvents.length >= 16) throw new RangeError('cargo-link-events-exhausted')
148 linkEvents.push(structuredClone(links))
149 }
150 return { ...links.authority }
151 },
152 observeIndependent(state, atMs) {
153 if (atMs !== physicalAtMs) throw new RangeError('cargo-delivery-world-epoch')
154 if (state.details.loadAttached !== (body.loadSnapshot().properties.phase === 'attached')) throw new TypeError('cargo-delivery-world-load')
155 },
156 renderMeasurement(state, atMs, reference) {
157 const m = base.renderMeasurement(state, atMs, reference)
158 const receiptCaptured = receiptAtMs !== null && atMs >= receiptAtMs + 100
159 return { ...m, values: { ...m.values, loadAttached: state.details.loadAttached === true, loadMassKg: Number(state.details.loadMassKg), siteId: site.id, recipientId: receiptCaptured && scenario === 'foreign-receipt' ? 'fixture-other-recipient' : site.recipientId,
160 siteClear: scenario !== 'site-blocked', recipientPresent: scenario !== 'recipient-absent' && !scenario.startsWith('diversion-'), mechanismOpen: release?.outcome === 'separated', mechanismJammed: mechanismAttempt?.jammed ?? false, mechanismEventId: mechanismAttempt?.eventId ?? '',
161 receiptEventId: receiptCaptured && scenario !== 'receipt-loss' ? release?.eventId ?? '' : '', receiptContainerId: site.containerId } }
162 },
163 createPayload: () => ({ ...coordinator.port, observe(context) { observed = structuredClone(context); coordinator.port.observe!(context) }, poll(nowMs) {
164 const ack = coordinator.port.poll(nowMs)
165 if (faultInjection && faultInjection.anchoredAtMs === null) {
166 const custody = coordinator.snapshot().delivery
167 const capturedAtMs = faultInjection.phase === 'after-receipt' ? custody.outcome === 'received' ? custody.receiptCapturedAtMs : null : custody.mechanismOutcome === 'open' ? custody.mechanismCapturedAtMs : null
168 const eventId = observed?.measurement?.values[faultInjection.phase === 'after-receipt' ? 'receiptEventId' : 'mechanismEventId']
169 if (capturedAtMs !== null && typeof eventId === 'string' && eventId.length > 0) {
170 faultInjection.anchoredAtMs = nowMs; faultInjection.sourceCapturedAtMs = capturedAtMs; faultInjection.eventId = eventId
171 }
172 }
173 return ack
174 } }),
175 }
176 }
177 const runtime = runVehicleSimulation(profile, { seconds: 100, neutralTailMs: faultInjection?.independentTailMs ?? 0 })
178 const delivery = coordinator.snapshot().delivery
179 return structuredClone({ version: 1, evidence: 'owned-cargo-delivery-simulation' as const, scenario, status: runtime.status === 'completed' && runtime.mission.payloadFailure ? 'diverted' as const : runtime.status, physicalFlightEnabled: false as const, boardOutputsInhibited: true as const, identityAuthenticated: false as const,
180 ...(captured.explicit ? { configuration } : {}), ...(faultInjection ? { faultInjection: { ...faultInjection, finalPhysicalAtMs: physicalAtMs } } : {}), delivery, initialLoad, finalLoad: body.loadSnapshot(), release, parcel, links, linkEvents, runtime })
181}
182
183/** A bounded command projection. Matches describe these model cases, never physical delivery. */
184export function cargoDeliverySummary(run: CargoDeliveryResult) {
185 const configuration = run.configuration ?? fixtureConfiguration, selectedSite = configuration.delivery.site
186 const site = { northM: selectedSite.positionM[0], eastM: selectedSite.positionM[1], radiusM: selectedSite.radiusM }
187 const rt = run.runtime, power = rt.trace.plan.power, measurements = rt.path.flatMap(row => row.measurement ? [row.measurement] : [])
188 const landingContact = rt.mission.state === 'completed' && rt.trace.rows.at(-1)?.observation.onGround === true
189 const neutral = rt.board.actuators.length === 4 && rt.board.actuators.every(n => n === 0) && rt.board.expiresAtMs === null
190 && (rt.authority.state === 'disarmed' || rt.authority.state === 'killed' || rt.authority.state === 'failsafe' || rt.status === 'host-lost' && rt.board.fault === 'output-lease-expired')
191 const separationSeen = run.release?.outcome === 'separated' && run.finalLoad.properties.phase === 'separated' && measurements.some(m => m.values.loadAttached === false && m.values.loadMassKg === 1.5)
192 const receiptEvent = run.release?.eventId
193 const selectedFault = phaseFault(run.scenario)
194 let worldMatched = false
195 if (run.scenario === 'nominal' || run.scenario === 'primary-link-loss') worldMatched = separationSeen && run.delivery.outcome === 'received' && run.status === 'completed'
196 && (run.scenario !== 'primary-link-loss' || run.linkEvents.some(event => event.selectedSource === 'backup') && run.links.selectedSource === 'backup' && !run.links.latchedLoss)
197 else if (run.scenario === 'recipient-absent') worldMatched = run.release === null && measurements.some(m => m.values.recipientPresent === false) && run.delivery.outcome === 'not-released'
198 else if (run.scenario === 'site-blocked') worldMatched = run.release === null && measurements.some(m => m.values.siteClear === false) && run.delivery.outcome === 'not-released'
199 else if (run.scenario === 'mechanism-jam') worldMatched = run.release === null && measurements.some(m => m.values.mechanismJammed === true) && run.delivery.mechanismOutcome === 'jammed'
200 else if (run.scenario === 'receipt-loss') worldMatched = separationSeen && run.parcel?.onSurface === true && Math.hypot(run.parcel.positionM[0] - site.northM, run.parcel.positionM[1] - site.eastM) <= site.radiusM
201 && measurements.every(m => m.values.receiptEventId === '') && run.delivery.outcome === 'uncertain'
202 else if (run.scenario === 'foreign-receipt') worldMatched = separationSeen && measurements.some(m => m.values.recipientId === 'fixture-other-recipient' && m.values.receiptEventId === receiptEvent) && run.delivery.outcome === 'uncertain'
203 else if (run.scenario === 'both-links-loss') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && run.links.latchedLoss && !run.links.authority.connected && rt.authority.events.some(event => event.reason === 'link-loss')
204 else if (run.scenario === 'position-loss') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.events.some(event => ['estimator-loss', 'stale-estimator'].includes(event.reason))
205 else if (run.scenario === 'imu-loss') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.events.some(event => event.reason === 'stale-interlocks') && rt.mission.reason === 'estimator-reference-changed'
206 else if (run.scenario === 'vehicle-sensor-loss') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.events.some(event => event.reason === 'stale-interlocks')
207 else if (run.scenario === 'rc-override') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.events.some(event => event.to === 'manual' && event.reason === 'rc-override')
208 else if (run.scenario === 'kill') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.state === 'killed'
209 else if (run.scenario === 'host-loss') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.lastCheckedAtMs === 4980 && rt.board.fault === 'output-lease-expired'
210 else if (selectedFault) {
211 const injection = run.faultInjection, fault = selectedFault.fault
212 const observedFault = fault === 'hostLost' ? rt.board.fault === 'output-lease-expired' && rt.mission.state === 'running'
213 : rt.authority.events.some(event => fault === 'kill' ? event.to === 'killed' : fault === 'rcOverride' ? event.to === 'manual' : fault === 'links' ? event.reason === 'link-loss' : fault === 'dropPosition' ? ['estimator-loss', 'stale-estimator'].includes(event.reason) : event.reason === 'stale-interlocks')
214 worldMatched = separationSeen && run.parcel?.onSurface === true && observedFault && !!injection && injection.anchoredAtMs !== null && injection.triggeredAtMs !== null && injection.triggeredAtMs >= injection.anchoredAtMs + 20
215 && injection.eventId === receiptEvent && injection.sourceCapturedAtMs !== null && injection.sourceCapturedAtMs >= run.release!.atMs && injection.sourceCapturedAtMs <= injection.anchoredAtMs
216 && (selectedFault.phase === 'after-receipt' ? run.delivery.outcome === 'received' && run.delivery.receiptCapturedAtMs !== null : run.delivery.outcome === 'uncertain' && run.delivery.receiptCapturedAtMs === null)
217 }
218 else if (run.scenario === 'authority-containment') worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.authority.events.some(event => event.reason === 'invalid-target-or-lease') && rt.path.every(row => Math.hypot(row.truthPositionM[0], row.truthPositionM[1]) <= 2)
219 else if (run.scenario.startsWith('diversion-')) worldMatched = run.release === null && run.delivery.outcome === 'not-released' && rt.mission.payloadFailure?.reason === 'rejected'
220 && rt.authority.events.some(event => event.atMs !== null && event.atMs >= rt.mission.payloadFailure!.triggeredAtMs + 200 && (run.scenario === 'diversion-kill' ? event.to === 'killed' : ['estimator-loss', 'stale-estimator'].includes(event.reason)))
221 const expectedStatus = run.scenario === 'nominal' || run.scenario === 'primary-link-loss' ? 'completed' : run.scenario === 'host-loss' || selectedFault?.fault === 'hostLost' ? 'host-lost' : selectedFault || run.scenario === 'both-links-loss' || run.scenario === 'authority-containment' || run.scenario.startsWith('diversion-') || flightFaults.some(value => value === run.scenario) ? 'blocked' : 'diverted'
222 const summary = structuredClone({ version: 1, evidence: run.evidence, scenario: run.scenario, status: run.status, demonstrationMatched: worldMatched && run.status === expectedStatus && (!['completed', 'diverted'].includes(expectedStatus) || landingContact) && neutral,
223 physicalFlightEnabled: false, boardOutputsInhibited: true, identityAuthenticated: false, ...(run.configuration ? { configuration } : {}), ...(run.faultInjection ? { faultInjection: run.faultInjection } : {}), delivery: run.delivery, landingContact,
224 load: { initial: run.initialLoad.properties, final: run.finalLoad.properties },
225 release: run.release ? { atMs: run.release.atMs, eventId: run.release.eventId, outcome: run.release.outcome, reason: run.release.reason } : null,
226 parcel: run.parcel, links: run.links, linkEvents: run.linkEvents,
227 mission: { state: rt.mission.state, taskId: rt.mission.taskId, reason: rt.mission.reason, payloadFailure: rt.mission.payloadFailure ?? null, traceRows: rt.trace.rows.length },
228 energy: { evidence: 'declared-mission-power-budget', measured: false, electricalModel: false, capacityWh: power.availableWh, maximumDeclaredW: power.maxW, reservePercent: power.reservePercent,
229 worstCaseMs: rt.budget.worstCaseMs, worstCaseRequiredWh: rt.budget.requiredWh, marginAboveReserveWh: power.availableWh * (1 - power.reservePercent / 100) - rt.budget.requiredWh },
230 board: { actuators: [...rt.board.actuators], expiresAtMs: rt.board.expiresAtMs, fault: rt.board.fault, physicalActuationEnabled: rt.board.physicalActuationEnabled },
231 authority: { hostAvailable: rt.status !== 'host-lost', state: rt.authority.state, reason: rt.authority.reason, lastCheckedAtMs: rt.authority.lastCheckedAtMs, leaseUntilMs: rt.authority.leaseUntilMs },
232 model: { loadMassKg: configuration.load.massKg, loadForwardM: configuration.load.forwardM, separation: 'zero-ejection-point-mass', parcel: 'ballistic-point-with-plane-capture', receiver: 'fictional-100ms-receipt', measurementDelayMs: 40, headingAlignment: 'initial-simulation-north' },
233 })
234 if (new TextEncoder().encode(JSON.stringify(summary)).byteLength + 1 > 16384) throw new RangeError('cargo-delivery-summary-unavailable')
235 return summary
236}