ReviewOS

also looking at this

stacks/drone

feat: coordinate modeled two-carrier cargo handover

#103
Merged chris wants to merge codex/cargo-fleet-coordination into main
25 files +1654 -13
app/Commands/CargoFleet.tsadded+25-0
Changes to app/Commands/CargoFleet.ts
@@ -0,0 +1,25 @@
1import { defineCommand } from '@stacksjs/cli'
2import { printAsync, printErrorAsync } from '../../resources/functions/cli/output'
3import { cargoFleetScenarios, cargoFleetSummary, simulateCargoFleet } from '../../resources/functions/drone/cargo/fleet'
4
5export default defineCommand({
6 name: 'cargo:fleet',
7 description: 'Run two owned modeled carriers through one finite station and captured intake, without physical dispatch',
8 options: {
9 '--scenario <name>': { description: cargoFleetScenarios.join(', '), default: 'nominal' },
10 },
11 async handle(options) {
12 try {
13 const summary = cargoFleetSummary(simulateCargoFleet({ scenario: options.scenario }))
14 if (summary.status !== 'completed') process.exitCode = 2
15 const wire = JSON.stringify(summary)
16 if (Buffer.byteLength(wire) + 1 > 16384) throw new RangeError('cargo-fleet-output-limit')
17 await printAsync(wire)
18 }
19 catch {
20 process.exitCode = 1
21 try { await printErrorAsync('Cargo fleet simulation unavailable: invalid scenario, execution or output failure') }
22 catch { /* A closed diagnostic pipe does not make the failed command succeed. */ }
23 }
24 },
25})