feat(ai-psychosis): promote domain_context to array for multi-domain support
This commit is contained in:
parent
011634583b
commit
a5bc53cb42
6 changed files with 72 additions and 11 deletions
|
|
@ -64,13 +64,13 @@ describe('session-end', () => {
|
|||
assert.equal(records[0].note, 'no_state_file');
|
||||
});
|
||||
|
||||
it('persists pushback_count and domain_context (v1.1.0)', () => {
|
||||
it('persists pushback_count and coerces v1.1.0 string domain to array', () => {
|
||||
dir = setupTestDir();
|
||||
createStateFile(dir, 's4', {
|
||||
start_epoch: Math.floor(Date.now() / 1000) - 120, start_iso: '2026-01-01T10:00:00Z',
|
||||
tool_count: 2, edit_count: 1,
|
||||
dep_flags: 0, esc_flags: 0, fatigue_flags: 0, val_flags: 0,
|
||||
pushback_count: 3, domain_context: 'relationship',
|
||||
pushback_count: 3, domain_context: 'relationship', // v1.1.0 string shape
|
||||
last_event_epoch: 0, burst_count: 0, last_warning_epoch: 0,
|
||||
});
|
||||
runHook('session-end.mjs', { session_id: 's4', cwd: '/tmp' }, dir);
|
||||
|
|
@ -78,7 +78,25 @@ describe('session-end', () => {
|
|||
const end = records.find(r => r.end);
|
||||
assert.ok(end);
|
||||
assert.equal(end.flags.pushback, 3);
|
||||
assert.equal(end.domain_context, 'relationship');
|
||||
// v1.2: end record always carries an array, even when state had a string.
|
||||
assert.deepEqual(end.domain_context, ['relationship']);
|
||||
});
|
||||
|
||||
it('writes v1.2 multi-domain array unchanged when state already has array', () => {
|
||||
dir = setupTestDir();
|
||||
createStateFile(dir, 's4b', {
|
||||
start_epoch: Math.floor(Date.now() / 1000) - 120, start_iso: '2026-01-01T10:00:00Z',
|
||||
tool_count: 2, edit_count: 1,
|
||||
dep_flags: 0, esc_flags: 0, fatigue_flags: 0, val_flags: 0,
|
||||
pushback_count: 1,
|
||||
domain_context: ['relationship', 'health'],
|
||||
last_event_epoch: 0, burst_count: 0, last_warning_epoch: 0,
|
||||
});
|
||||
runHook('session-end.mjs', { session_id: 's4b', cwd: '/tmp' }, dir);
|
||||
const records = readJsonl(join(dir, 'sessions.jsonl'));
|
||||
const end = records.find(r => r.end);
|
||||
assert.ok(end);
|
||||
assert.deepEqual(end.domain_context, ['relationship', 'health']);
|
||||
});
|
||||
|
||||
it('backward-compat: state without pushback_count yields flags.pushback === 0 (not NaN/undefined)', () => {
|
||||
|
|
@ -97,6 +115,7 @@ describe('session-end', () => {
|
|||
assert.equal(end.flags.pushback, 0);
|
||||
assert.notEqual(end.flags.pushback, undefined);
|
||||
assert.ok(!Number.isNaN(end.flags.pushback));
|
||||
assert.equal(end.domain_context, null);
|
||||
// v1.2: empty domain becomes [] (not null) — always an array on disk.
|
||||
assert.deepEqual(end.domain_context, []);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue