repositories / will

will

owned by bugabinga

test: pin storage thresholds so int tests are disk-independent

b1bca93abf3c11453e63411037c247f78a051382

will <will@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

The ops/main/runtime integration tests assumed >=20% free space on the
test filesystem (default warn threshold), asserting storageState 'ok'
and an ok->warn transition. On hosts with less free space they fail.

Pin thresholds to 0/0 for a deterministic 'ok' baseline, force warn via
meta patch, and cover the full ok/warn/stop state machine in the ops
test. Coverage ratchet raised to 90.8%.

Changed files (4)

+20 / −9 text lines

Diff layout

coverage-ratchet.json

Modified

+3 / −3 text lines

11{
2 "all": 89.3,
3 "updatedAt": "2026-09-12T05:03:56.343Z",
4 "note": "ratchet only rises; update committed with the change that raised it"
2 "all": 90.8,
3 "updatedAt": "2026-09-13T01:09:27.958Z",
4 "note": "ratchet only rises; commit the raise with the change that caused it"
55}

src/agent/runtime.int.test.ts

Modified

+5 / −4 text lines

270270 webDist,
271271 docsDist: webDist,
272272 mediaMaxBytes: 1000,
273 storageWarnPct: 20,
274 storageStopPct: 10,
273 // 0/0 pins the initial state to 'ok'; the test forces 'warn' by patching
274 // meta thresholds below, deterministic on any host filesystem.
275 storageWarnPct: 0,
276 storageStopPct: 0,
275277 workerUrl: join(import.meta.dirname, '../service/worker.ts'),
276278 })
277279 try {
287289 await state.update((d) => {
288290 d.storageNoticeState = 'ok'
289291 })
290 // force warn: patch service meta thresholds so freePct < warn
291 // (tmpfs is huge; use a near-100 warn pct)
292 // force warn: patch service meta thresholds so freePct < warn on any host
292293 const dbFile = join(dir, 'will.db')
293294 const { DatabaseSync } = await import('node:sqlite')
294295 const db = new DatabaseSync(dbFile)

src/service/main.int.test.ts

Modified

+4 / −2 text lines

3030 webDist,
3131 docsDist,
3232 mediaMaxBytes: 1000 << 10,
33 storageWarnPct: 20,
34 storageStopPct: 10,
33 // 0/0 pins storageState to 'ok' for every non-negative freePct; tests
34 // that need warn/stop patch the service meta thresholds explicitly.
35 storageWarnPct: 0,
36 storageStopPct: 0,
3537 workerUrl: join(here, 'worker.ts'),
3638 })
3739 const pubAddr = service.publicServer.address()

src/service/ops.int.test.ts

Modified

+8 / −0 text lines

233233test('quick check reports ok and jobs are recorded', async () => {
234234 const { ops } = await freshOps()
235235 assert.equal(await ops.quickCheck(), 'ok')
236 // Default thresholds depend on the host filesystem's free space; pin them
237 // so storageState is deterministic regardless of the environment.
238 ops.setStorageThresholds(0, 0)
236239 const status = await ops.status()
237240 assert.equal(status.schemaVersion, 1)
238241 assert.ok(status.storage.freePct >= 0)
239242 assert.equal(status.storageState, 'ok')
240243 assert.ok(status.lastQuickCheck)
244 // Any non-negative freePct sits below huge thresholds: warn, then stop.
245 ops.setStorageThresholds(1000, 0)
246 assert.equal((await ops.status()).storageState, 'warn')
247 ops.setStorageThresholds(1000, 1000)
248 assert.equal((await ops.status()).storageState, 'stop')
241249})
243251test('vacuum runs without error', async () => {