feat(ai-psychosis): /interaction-report surfaces v1.2 fields

This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 21:53:41 +02:00
commit 6fe275825a
2 changed files with 105 additions and 10 deletions

View file

@ -23,6 +23,17 @@ function runReader(jsonlContent) {
}
}
function runReaderRaw(jsonlContent) {
const dir = mkdtempSync(join(tmpdir(), 'ia-report-'));
const path = join(dir, 'sessions.jsonl');
writeFileSync(path, jsonlContent);
try {
return execSync(`node ${SCRIPT} ${path}`, { encoding: 'utf8', timeout: 5000 });
} finally {
rmSync(dir, { recursive: true, force: true });
}
}
test('pushback_total matches sum across v1.1.0 records', () => {
const fixture = [
{ session_id: 'a', start: '2026-04-10T10:00:00Z', end: '2026-04-10T11:00:00Z',
@ -166,3 +177,22 @@ test('backward-compat: v1.0.0 records without pushback/domain do not produce NaN
assert.equal(result.flags_total.dependency, 1);
assert.equal(result.flags_total.fatigue, 1);
});
test('report-reader stdout surfaces v1.2 field names (SC-12)', () => {
// Run reader against a v1.2 fixture and assert stdout contains the field
// names that /interaction-report references in its output template.
const fixture = [
{ session_id: 'a', duration_min: 30,
domain_context: ['legal', 'health'],
user_info_class: 'no', valseek_count: 4, turn_count: 22,
flags: { dependency: 0, escalation: 0, fatigue: 0, validation: 0, pushback: 1 } },
];
const stdout = runReaderRaw(fixture.map(o => JSON.stringify(o)).join('\n') + '\n');
// SC-12 specifies these field names must be present in the report output:
assert.ok(stdout.includes('user_info_class'), 'stdout missing user_info_class field');
assert.ok(stdout.includes('valseek'), 'stdout missing valseek aggregation');
assert.ok(stdout.includes('stakes_signal'), 'stdout missing stakes_signal aggregation');
// Also assert at least one new domain name (legal) appears in domain_breakdown.
assert.ok(stdout.includes('legal'), 'stdout missing legal domain in breakdown');
assert.ok(stdout.includes('domain_breakdown'), 'stdout missing domain_breakdown structure');
});