ReviewOS

also looking at this

stacks/drone

feat: model VTOL electrical consumption and battery authority

#81
Merged chris wants to merge codex/owned-vtol-electrical-energy into main
15 files +605 -28
tests/unit/vtol-cli.test.tsmodified+33-0
Changes to tests/unit/vtol-cli.test.ts
@@ -1,6 +1,19 @@
11import { expect, test } from 'bun:test'
22import { command } from '@stacksjs/testing'
33
4test('CI runs every standalone VTOL qualification outside the checkout', async () => {
5 const workflow = Bun.YAML.parse(await Bun.file(new URL('../../.github/workflows/ci.yml', import.meta.url)).text()) as {
6 jobs: { check: { steps: { run?: string, 'working-directory'?: string }[] } }
7 }
8 const steps = workflow.jobs.check.steps.filter(step => step.run?.startsWith('$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:hover'))
9 expect(steps.map(step => ({ command: step.run, directory: step['working-directory'] }))).toEqual([
10 { command: '$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:hover', directory: '${⁠{ runner.temp }}' },
11 { command: '$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:hover --scenario host-loss', directory: '${⁠{ runner.temp }}' },
12 { command: '$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:hover --electrical', directory: '${⁠{ runner.temp }}' },
13 { command: '$GITHUB_WORKSPACE/storage/runtime-build/cli/drone vtol:hover --scenario host-loss --electrical', directory: '${⁠{ runner.temp }}' },
14 ])
15})
16
417test('native VTOL hover command preserves nominal and lost-host outcomes with explicit development scope', async () => {
518 for (const [scenario, status] of [['hover', 'completed'], ['host-loss', 'host-lost']]) {
619 const result = await command(['vtol:hover', '--scenario', scenario!]).withTimeout(60000)
@@ -29,3 +42,23 @@ test('native VTOL command rejects unknown scenarios and preserves insufficient-d
2942 expect(report.mission.state).toBe('running')
3043 expect(report.board.actuators).toEqual([0, 0, 0, 0, 0, 0, 0, 0])
3144}, 180000)
45
46test('native VTOL electrical option preserves hover and host-loss scope with measured battery evidence', async () => {
47 for (const scenario of ['hover', 'host-loss']) {
48 const result = await command(['vtol:hover', '--scenario', scenario, '--electrical']).withTimeout(60000)
49 expect(result.exitCode).toBe(0)
50 const report = JSON.parse(result.stdout)
51 expect(report.demonstrationMatched).toBe(true)
52 expect(report.energy.evidence).toBe('modeled-vehicle-battery-v1')
53 expect(report.energy.model).toEqual({ evidence: 'modeled-vehicle-battery-v1', capacityWh: 50, maximumSourceW: 1061 })
54 expect(report.energy.lastObservation.energyUsedWh).toBeGreaterThan(0)
55 expect(report.energy.lastObservation.capturedAtMs).toBeLessThan(report.energy.lastObservation.observedAtMs)
56 expect(report.scope).toBe('development-hover-only')
57 expect(report.physicalFlightEnabled).toBe(false)
58 expect(report.board.actuators).toEqual([0, 0, 0, 0, 0, 0, 0, 0])
59 if (scenario === 'host-loss') {
60 expect(report.energy.lastObservation.observedAtMs).toBe(2980)
61 expect(report.board.fault).toBe('output-lease-expired')
62 }
63 }
64}, 180000)