ReviewOS

also looking at this

stacks/drone

test: exercise full host filesystem recovery

#58
Merged chris wants to merge codex/runtime-full-volume-recovery into main
13 files +644 -5
tests/unit/updates-host-writes.test.tsadded+32-0
Changes to tests/unit/updates-host-writes.test.ts
@@ -0,0 +1,32 @@
1import { expect, test } from 'bun:test'
2import { mkdir, mkdtemp, rm } from 'node:fs/promises'
3import { tmpdir } from 'node:os'
4import { join, resolve } from 'node:path'
5import { qualifyHostFileWriteLimit } from '../fixtures/updates/host-write-limit'
6
7// Public coordinator plus actual OS writes catches lost floors or false health
8// after a partial image copy. Physical media and other errno classes are separate.
9test('an actual short host-image write preserves accepted trust and needs fresh runtime confirmation after recovery', async () => {
10 const evidence = process.env.RUNTIME_HOST_FILE_LIMIT_EVIDENCE
11 const root = evidence ? resolve(evidence) : await mkdtemp(join(tmpdir(), 'drone-host-write-limit-'))
12 if (evidence) await mkdir(root, { mode: 0o700 })
13 let completed = false
14 try {
15 const result = await qualifyHostFileWriteLimit(join(root, 'campaign'))
16 expect(result.fileLimitBytes).toBe(1048576)
17 expect(result.partialImageBytes).toBe(1048576)
18 expect(result.authorizedImageBytes).toBeGreaterThan(result.partialImageBytes)
19 expect(result.errorCodes).toContain('EFBIG')
20 expect(result.acceptedRootVersion).toBe(2)
21 expect(result.acceptedTargetsVersion).toBe(3)
22 expect(result.releaseFloor).toBe(9)
23 expect(result.freshBootId).not.toBe(result.previousBootId)
24 expect(result.physicalDeploymentAllowed).toBe(false)
25 completed = true
26 }
27 finally {
28 if (completed && !evidence) await rm(root, { recursive: true, force: true })
29 else if (completed) console.log(`Host file-limit campaign retained at ${root}`)
30 else console.error(`Failed host file-limit campaign retained at ${root}`)
31 }
32}, 120000)