test: require real checkpoint artifact evidence

This commit is contained in:
Eve
2026-04-24 08:37:57 +08:00
parent ef990d10b7
commit e5db414a00
2 changed files with 117 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env node
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import { execFileSync, spawnSync } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -124,6 +126,36 @@ function assertErrorCase(name, args, expectedStderr, input) {
function main() {
const results = fixtures.map(runFixture);
const realismWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), 'wrapper-realism-'));
try {
const realismInput = path.join(repoRoot, 'docs', '_artifacts', 'long_task_governor_wrapper_subagent_wait_example.json');
const stdout = execFileSync(process.execPath, [wrapperPath, '--compact', '--input', realismInput], {
cwd: realismWorkspace,
encoding: 'utf8',
});
const output = JSON.parse(stdout);
assert.equal(typeof output.externalizedCheckpointPath, 'string', 'realism: missing externalizedCheckpointPath');
assert.ok(output.externalizedCheckpointPath.length > 0, 'realism: empty externalizedCheckpointPath');
const artifactPath = path.join(realismWorkspace, output.externalizedCheckpointPath);
assert.ok(fs.existsSync(artifactPath), `realism: checkpoint artifact missing at ${artifactPath}`);
const artifactBody = fs.readFileSync(artifactPath, 'utf8');
assert.ok(artifactBody.trim().length > 0, 'realism: checkpoint artifact should be readable and non-empty');
assert.equal('task_name' in (output.progressEvidence ?? {}), false, 'realism: progressEvidence must not include task_name fallback');
assert.equal(artifactBody.includes('Wait for delegated log survey'), false, 'realism: checkpoint artifact must not fall back to taskRecord.task_name');
results.push({
name: 'real checkpoint artifact',
output: {
classification: output.classification,
silentCandidate: output.silentCandidate,
silentLaunchOk: output.silentLaunchOk,
requiredNextAction: output.requiredNextAction,
handoff: output.handoff,
},
});
} finally {
fs.rmSync(realismWorkspace, { recursive: true, force: true });
}
assertErrorCase('invalid json', ['--compact'], 'INVALID_JSON: input must be valid JSON', 'not-json\n');
assertErrorCase('missing input value', ['--input'], 'CLI_ERROR: --input requires a value');
assertErrorCase('unknown argument', ['--bogus'], 'CLI_ERROR: unknown argument: --bogus');