import { execFileSync, spawnSync } from 'node:child_process'; import fs from 'node:fs'; import path from 'node:path'; const runId = process.env.DADA_TDD_RUN_ID ?? `wp5-06-green-${new Date().toISOString().replace(/[^0-9]/g, '')}`; const testId = 'TDD-WP5-06-CLEAN-001-sticker-history'; const runDirectory = path.resolve('artifacts', 'tdd', runId, 'cases', testId); fs.mkdirSync(runDirectory, { recursive: true }); const command = ['exec', 'vitest', 'run', 'tests/integration/wp5-06-sticker-cleanup.test.ts']; const executable = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'; const result = spawnSync(executable, command, { encoding: 'utf8', shell: process.platform === 'win32' }); const status = result.status === 0 ? 'passed' : 'failed'; const evidence = { schema_version: '1.0', task_id: 'TASK-WP5-06', test_id: testId, run_id: runId, phase: 'green', status, command: 'pnpm exec vitest run tests/integration/wp5-06-sticker-cleanup.test.ts', commit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(), exit_code: result.status ?? 1, redaction: 'stdout/stderr intentionally excluded', }; fs.writeFileSync(path.join(runDirectory, 'evidence.json'), `${JSON.stringify(evidence, null, 2)}\n`); console.log(JSON.stringify(evidence)); process.exitCode = status === 'passed' ? 0 : 1;