test: isolate release checks and refresh docs
This commit is contained in:
+11
-6
@@ -608,7 +608,12 @@ async function cmdSelftest() {
|
||||
// 2–7. Изолированное состояние в tmp git-репо.
|
||||
const tmp = mkdtempSync(path.join(os.tmpdir(), 'helioz-selftest-'))
|
||||
try {
|
||||
const env = { ...process.env, HELIOZ_HOME: tmp }
|
||||
const env = {
|
||||
...process.env,
|
||||
HELIOZ_HOME: tmp,
|
||||
GIT_CONFIG_GLOBAL: os.devNull,
|
||||
GIT_CONFIG_SYSTEM: os.devNull,
|
||||
}
|
||||
const self = fileURLToPath(import.meta.url)
|
||||
const execScript = path.join(path.dirname(self), 'helioz-exec.mjs')
|
||||
const run = (args) => spawnSync(process.execPath, [self, ...args], { env, encoding: 'utf8' })
|
||||
@@ -623,14 +628,14 @@ async function cmdSelftest() {
|
||||
kimi: { invoke_read: stub, invoke_write: stub, stdin_prompt: true, roles: ['execute', 'verify'] },
|
||||
codex: { invoke_read: stub, invoke_write: stub, stdin_prompt: true, roles: ['execute', 'verify'] },
|
||||
}))
|
||||
execFileSync('git', ['-C', tmp, 'init', '-q'])
|
||||
execFileSync('git', ['-C', tmp, 'init', '-q'], { env })
|
||||
writeFileSync(path.join(tmp, 'seed.txt'), 'seed\n')
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'])
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=g@c', '-c', 'user.name=gate', 'commit', '-qm', 'seed'])
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'], { env })
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=g@c', '-c', 'user.name=gate', 'commit', '-qm', 'seed'], { env })
|
||||
// второй коммит: маркер требует base≠head с реальным diff (пустой diff = фордж, ревью kimi)
|
||||
writeFileSync(path.join(tmp, 'seed.txt'), 'seed\nwork\n')
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'])
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=g@c', '-c', 'user.name=gate', 'commit', '-qm', 'work'])
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'], { env })
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=g@c', '-c', 'user.name=gate', 'commit', '-qm', 'work'], { env })
|
||||
|
||||
// пустая очередь → exit 2 (fail-closed)
|
||||
eq(run(['--ready']).status, 2, 'пустая очередь обязана давать 2')
|
||||
|
||||
@@ -513,7 +513,13 @@ async function cmdSelftest() {
|
||||
}))
|
||||
writeFileSync(path.join(tmp, 'config', 'helioz.json'), JSON.stringify({ probe_timeout_sec: 5, run_timeout_sec: 5 }))
|
||||
const self = path.join(tmp, 'scripts', 'helioz-plan.mjs')
|
||||
const run = args => spawnSync(process.execPath, [self, ...args], { env: { ...process.env, HELIOZ_HOME: tmp }, encoding: 'utf8' })
|
||||
const env = {
|
||||
...process.env,
|
||||
HELIOZ_HOME: tmp,
|
||||
GIT_CONFIG_GLOBAL: os.devNull,
|
||||
GIT_CONFIG_SYSTEM: os.devNull,
|
||||
}
|
||||
const run = args => spawnSync(process.execPath, [self, ...args], { env, encoding: 'utf8' })
|
||||
|
||||
eq(run(['grill']).status, 2, 'без идеи допрос невозможен')
|
||||
eq(run(['grill', '--idea', 'починить сборку']).status, 0)
|
||||
@@ -543,8 +549,8 @@ async function cmdSelftest() {
|
||||
ok(existsSync(path.join(tmp, 'docs', 'MASTER-PLAN.md')), 'мастер-план на диске')
|
||||
const t1 = readFileSync(path.join(tmp, 'queue', 'tasks', 'T1.task.md'), 'utf8')
|
||||
ok(t1.includes('check_cmd:') && t1.includes('## Промт исполнителя') && t1.includes('## Промт проверяющего'))
|
||||
spawnSync('git', ['-C', tmp, 'init', '-q'])
|
||||
const gate = spawnSync(process.execPath, [path.join(tmp, 'scripts', 'helioz-gate.mjs'), '--ready', '--json'], { env: { ...process.env, HELIOZ_HOME: tmp }, encoding: 'utf8' })
|
||||
spawnSync('git', ['-C', tmp, 'init', '-q'], { env })
|
||||
const gate = spawnSync(process.execPath, [path.join(tmp, 'scripts', 'helioz-gate.mjs'), '--ready', '--json'], { env, encoding: 'utf8' })
|
||||
const ready = JSON.parse(gate.stdout || '{}')
|
||||
eq((ready.invalid || []).length, 0, 'гейт принял все рождённые задачи')
|
||||
ok((ready.ready || []).some(r => r.task === 'T1'), 'T1 готова к запуску')
|
||||
|
||||
@@ -13,6 +13,11 @@ import os from 'node:os'
|
||||
|
||||
const SCRIPTS = path.dirname(fileURLToPath(import.meta.url))
|
||||
const HOME = process.env.HELIOZ_HOME || path.dirname(SCRIPTS)
|
||||
const ISOLATED_GIT_ENV = {
|
||||
...process.env,
|
||||
GIT_CONFIG_GLOBAL: os.devNull,
|
||||
GIT_CONFIG_SYSTEM: os.devNull,
|
||||
}
|
||||
const now = () => new Date().toISOString()
|
||||
const sha256 = s => createHash('sha256').update(s).digest('hex')
|
||||
const results = []
|
||||
@@ -25,13 +30,13 @@ function mkHome() {
|
||||
const tmp = mkdtempSync(path.join(os.tmpdir(), 'helioz-probe-'))
|
||||
for (const d of ['queue/tasks', 'queue/dilemmas', '.helioz/state', 'docs', 'scripts', 'config']) mkdirSync(path.join(tmp, d), { recursive: true })
|
||||
for (const s of readdirSync(SCRIPTS)) if (s.endsWith('.mjs') || s.endsWith('.sh')) writeFileSync(path.join(tmp, 'scripts', s), readFileSync(path.join(SCRIPTS, s)))
|
||||
execFileSync('git', ['-C', tmp, 'init', '-q'])
|
||||
execFileSync('git', ['-C', tmp, 'init', '-q'], { env: ISOLATED_GIT_ENV })
|
||||
writeFileSync(path.join(tmp, 'seed.txt'), 'seed\n')
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'])
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=p@c', '-c', 'user.name=probe', 'commit', '-qm', 'seed'])
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'], { env: ISOLATED_GIT_ENV })
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=p@c', '-c', 'user.name=probe', 'commit', '-qm', 'seed'], { env: ISOLATED_GIT_ENV })
|
||||
writeFileSync(path.join(tmp, 'seed.txt'), 'seed\nwork\n')
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'])
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=p@c', '-c', 'user.name=probe', 'commit', '-qm', 'work'])
|
||||
execFileSync('git', ['-C', tmp, 'add', '-A'], { env: ISOLATED_GIT_ENV })
|
||||
execFileSync('git', ['-C', tmp, '-c', 'user.email=p@c', '-c', 'user.name=probe', 'commit', '-qm', 'work'], { env: ISOLATED_GIT_ENV })
|
||||
writeFileSync(path.join(tmp, 'config', 'helioz.json'), JSON.stringify({ quiet_hours: { start: '00:00', end: '23:59' }, council: { lenses: ['риск', 'цена отката', 'простота'], min_advisors: 3 }, probe_timeout_sec: 5, run_timeout_sec: 5 }))
|
||||
const stub = path.join(tmp, 'bin-adv')
|
||||
writeFileSync(stub, '#!/bin/sh\ncat >/dev/null 2>&1\necho "ВЫБОР: 1"; echo "ПОЧЕМУ: так."; echo "РИСК ОШИБКИ: нет."\n')
|
||||
@@ -44,10 +49,10 @@ function mkHome() {
|
||||
return tmp
|
||||
}
|
||||
const task = (id, p, extra = '') => `---\nid: ${id}\npaths:\n - ${p}\nexecutor: claude\nverifier: codex\ncheck_cmd: "true"\n${extra}---\n## Промт исполнителя\nx\n## Промт проверяющего\ny\n`
|
||||
const gate = (tmp, args) => spawnSync(process.execPath, [path.join(tmp, 'scripts', 'helioz-gate.mjs'), ...args], { env: { ...process.env, HELIOZ_HOME: tmp }, encoding: 'utf8' })
|
||||
const gate = (tmp, args) => spawnSync(process.execPath, [path.join(tmp, 'scripts', 'helioz-gate.mjs'), ...args], { env: { ...ISOLATED_GIT_ENV, HELIOZ_HOME: tmp }, encoding: 'utf8' })
|
||||
function receipt(tmp, id, executor = 'claude', verifier = 'codex') {
|
||||
const ex = path.join(tmp, 'scripts', 'helioz-exec.mjs')
|
||||
const env = { ...process.env, HELIOZ_HOME: tmp }
|
||||
const env = { ...ISOLATED_GIT_ENV, HELIOZ_HOME: tmp }
|
||||
const a = spawnSync(process.execPath, [ex, 'task', '--id', id, '--role', 'executor', '--cli', executor], { env, encoding: 'utf8' })
|
||||
const b = spawnSync(process.execPath, [ex, 'task', '--id', id, '--role', 'verifier', '--cli', verifier], { env, encoding: 'utf8' })
|
||||
if (a.status !== 0 || b.status !== 0) throw new Error(`receipt ${id}: helioz-exec failed ${a.status}/${b.status}`)
|
||||
|
||||
@@ -46,7 +46,7 @@ if [ "${1:-}" = "--selftest" ]; then
|
||||
case "$out" in SKIP:heartbeat*) ;; *) echo "FAIL: при свежем heartbeat получили '$out'"; exit 1;; esac
|
||||
# проба 3: протухший heartbeat + незакрытая задача → START
|
||||
node -e "require('fs').writeFileSync('$TMP/.helioz/state/heartbeat.json',JSON.stringify({at:new Date(Date.now()-3600e3).toISOString()}))"
|
||||
printf -- '---\nid: TW\npaths:\n - docs/w.md\ncheck_cmd: "true"\n---\n## Промт исполнителя\nx\n## Промт проверяющего\ny\n' > "$TMP/queue/tasks/TW.task.md"
|
||||
printf -- '---\nid: TW\npaths:\n - docs/w.md\nexecutor: claude\nverifier: codex\ncheck_cmd: "true"\n---\n## Промт исполнителя\nx\n## Промт проверяющего\ny\n' > "$TMP/queue/tasks/TW.task.md"
|
||||
out=$(HELIOZ_HOME="$TMP" bash "$0" --dry-run)
|
||||
[ "$out" = "START" ] || { echo "FAIL: при протухшем heartbeat получили '$out'"; exit 1; }
|
||||
# проба 4: протухший heartbeat, но очередь закрыта → SKIP
|
||||
|
||||
Reference in New Issue
Block a user