ReviewOS

also looking at this

stacks/drone

feat: add retained cargo fleet cancellation and recovery

#105
Merged chris wants to merge codex/cargo-fleet-operator-recovery into main
32 files +2496 -27
app/Commands/CargoFleetControl.tsadded+27-0
Changes to app/Commands/CargoFleetControl.ts
@@ -0,0 +1,27 @@
1import { defineCommand } from '@stacksjs/cli'
2import { printAsync, printErrorAsync } from '../../resources/functions/cli/output'
3import { cargoFleetSummary } from '../../resources/functions/drone/cargo/fleet'
4import { cargoFleetOperatorCases, simulateCargoFleetControl } from '../../resources/functions/drone/cargo/fleet-control'
5
6export default defineCommand({
7 name: 'cargo:fleet-control',
8 description: 'Exercise explicit modeled transport cancellation and recovery over the retained two-carrier world',
9 options: {
10 '--case <name>': { description: cargoFleetOperatorCases.join(', '), default: 'cancel-resume' },
11 },
12 async handle(options) {
13 try {
14 const fixture = simulateCargoFleetControl({ case: options.case })
15 const summary = { ...cargoFleetSummary(fixture.run), operatorCase: fixture.case }
16 if (summary.status !== 'completed') process.exitCode = 2
17 const wire = JSON.stringify(summary)
18 if (Buffer.byteLength(wire) + 1 > 16384) throw new RangeError('cargo-fleet-control-output-limit')
19 await printAsync(wire)
20 }
21 catch {
22 process.exitCode = 1
23 try { await printErrorAsync('Cargo fleet control unavailable: invalid case, execution or output failure') }
24 catch { /* A closed diagnostic pipe does not make the failed command succeed. */ }
25 }
26 },
27})