scripts/bench-status.mjs
scripts/bench-status.mjsBrowse 13 files
879 tokens
3,066 bytes
Token encoding: o200k_base
Snapshot bfcf687
← Back to SKILL.md
1#!/usr/bin/env node2// Usage: node bench-status.mjs [--all]3//4// The only reliable way to know what's in flight. Session restarts silently5// kill background launchers while their detached VMs keep measuring, and a6// dead launcher's log file still ends with a healthy-looking progress line —7// never infer liveness from log tails. This reads each run's status.json,8// checks whether the recorded launcher pid is alive, and prints the recovery9// action per run.10import fs from 'fs'11import path from 'path'12import { loadConfig } from './config.mjs'13 14const CONFIG = loadConfig({ requireScope: false })15const E2E = path.join(CONFIG.cacheDir, 'e2e')16const all = process.argv.includes('--all')17 18const dirs = fs.existsSync(E2E)19 ? fs20 .readdirSync(E2E)21 .filter((d) => d.startsWith('run-'))22 .map((d) => path.join(E2E, d))23 .sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs)24 : []25 26const DAY = 24 * 3600 * 100027let shown = 028for (const dir of dirs) {29 const sf = path.join(dir, 'status.json')30 if (!fs.existsSync(sf)) continue31 let st32 try {33 st = JSON.parse(fs.readFileSync(sf, 'utf8'))34 } catch {35 continue36 }37 const fresh = fs.statSync(sf).mtimeMs > Date.now() - DAY38 let alive = false39 if (st.pid) {40 try {41 process.kill(st.pid, 0)42 alive = true43 } catch {}44 }45 if (!all && !fresh && !alive) {46 continue47 }48 const ageMin = st.updatedAt49 ? Math.round((Date.now() - new Date(st.updatedAt).getTime()) / 60000)50 : null51 const vms = Object.values(st.vms || {})52 const rows = vms.reduce((s, v) => s + (v.rows || 0), 0)53 54 let action55 if (st.phase === 'done') {56 action = 'complete — bench-analyze.mjs re-reads it any time'57 } else if (String(st.phase).startsWith('prepared')) {58 action =59 'complete (--prepare: caches only) — launch the real run without --prepare'60 } else if (alive) {61 action = 'RUNNING — leave it alone'62 } else if (63 (rows > 0 || st.phase === 'measuring') &&64 ageMin !== null &&65 ageMin > 29066 ) {67 action =68 'DEAD and its VMs have expired — whatever was collected is in the ' +69 'run dir/results db; relaunch if more data is needed'70 } else if (rows > 0 || st.phase === 'measuring') {71 action =72 `DEAD but VMs may still hold data — node scripts/bench-collect.mjs ${dir}` +73 ' (measurement VMs time out ~5h after launch; collect before that)'74 } else {75 action =76 'DEAD before measurement — safe to relaunch (caches make it cheap); ' +77 'check for leaked builder VMs with sandbox-sweep.mjs'78 }79 80 console.log(81 `${path.basename(dir)}\n` +82 ` phase=${st.phase}` +83 (st.error84 ? ` error=${JSON.stringify(String(st.error).slice(0, 140))}`85 : '') +86 ` pid=${st.pid ?? '?'}(${alive ? 'alive' : 'dead'})` +87 (ageMin !== null ? ` updated=${ageMin}m ago` : '') +88 ` rows=${rows}${st.rowsExpected ? `/${st.rowsExpected}` : ''}\n` +89 ` -> ${action}`90 )91 shown++92}93if (!shown) {94 console.log('no recent runs (use --all to list everything)')95}96 Referenced from SKILL.md
SKILL.mdView in source ↗
Source excerpt starting at line 55.SKILL.mdView in source ↗55 the pending login and resume. After a 403 outage, expect in-flight runs to have died:56 run `node scripts/bench-status.mjs` and follow its recovery57 actions (measurement VMs will have hit their ~5h timeout if the
Source excerpt starting at line 289.289- **First move, always: `node scripts/bench-status.mjs`.** Session290 restarts silently kill background launchers while their detached VMs