feat(ai-psychosis): persist pushback + domain in sessions.jsonl
This commit is contained in:
parent
eca30b4682
commit
79a4249e0b
2 changed files with 42 additions and 2 deletions
|
|
@ -38,6 +38,8 @@ const depFlags = Number(state.dep_flags) || 0;
|
||||||
const escFlags = Number(state.esc_flags) || 0;
|
const escFlags = Number(state.esc_flags) || 0;
|
||||||
const fatFlags = Number(state.fatigue_flags) || 0;
|
const fatFlags = Number(state.fatigue_flags) || 0;
|
||||||
const valFlags = Number(state.val_flags) || 0;
|
const valFlags = Number(state.val_flags) || 0;
|
||||||
|
const pushbackCount = Number(state.pushback_count) || 0;
|
||||||
|
const domainContext = state.domain_context || null;
|
||||||
const startIso = state.start_iso || '';
|
const startIso = state.start_iso || '';
|
||||||
|
|
||||||
// Compute duration
|
// Compute duration
|
||||||
|
|
@ -54,11 +56,13 @@ appendJsonl(SESSIONS_LOG, {
|
||||||
duration_min: durationMin,
|
duration_min: durationMin,
|
||||||
tool_count: toolCount,
|
tool_count: toolCount,
|
||||||
edit_count: editCount,
|
edit_count: editCount,
|
||||||
|
domain_context: domainContext,
|
||||||
flags: {
|
flags: {
|
||||||
dependency: depFlags,
|
dependency: depFlags,
|
||||||
escalation: escFlags,
|
escalation: escFlags,
|
||||||
fatigue: fatFlags,
|
fatigue: fatFlags,
|
||||||
validation: valFlags
|
validation: valFlags,
|
||||||
|
pushback: pushbackCount
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ describe('session-end', () => {
|
||||||
runHook('session-end.mjs', { session_id: 's3', cwd: '/tmp' }, dir);
|
runHook('session-end.mjs', { session_id: 's3', cwd: '/tmp' }, dir);
|
||||||
const records = readJsonl(join(dir, 'sessions.jsonl'));
|
const records = readJsonl(join(dir, 'sessions.jsonl'));
|
||||||
const end = records.find(r => r.end);
|
const end = records.find(r => r.end);
|
||||||
assert.deepEqual(end.flags, { dependency: 3, escalation: 1, fatigue: 2, validation: 0 });
|
assert.deepEqual(end.flags, { dependency: 3, escalation: 1, fatigue: 2, validation: 0, pushback: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles missing state file gracefully', () => {
|
it('handles missing state file gracefully', () => {
|
||||||
|
|
@ -63,4 +63,40 @@ describe('session-end', () => {
|
||||||
assert.equal(records.length, 1);
|
assert.equal(records.length, 1);
|
||||||
assert.equal(records[0].note, 'no_state_file');
|
assert.equal(records[0].note, 'no_state_file');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('persists pushback_count and domain_context (v1.1.0)', () => {
|
||||||
|
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',
|
||||||
|
last_event_epoch: 0, burst_count: 0, last_warning_epoch: 0,
|
||||||
|
});
|
||||||
|
runHook('session-end.mjs', { session_id: 's4', cwd: '/tmp' }, dir);
|
||||||
|
const records = readJsonl(join(dir, 'sessions.jsonl'));
|
||||||
|
const end = records.find(r => r.end);
|
||||||
|
assert.ok(end);
|
||||||
|
assert.equal(end.flags.pushback, 3);
|
||||||
|
assert.equal(end.domain_context, 'relationship');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('backward-compat: state without pushback_count yields flags.pushback === 0 (not NaN/undefined)', () => {
|
||||||
|
dir = setupTestDir();
|
||||||
|
createStateFile(dir, 's5', {
|
||||||
|
start_epoch: Math.floor(Date.now() / 1000) - 60, start_iso: '2026-01-01T10:00:00Z',
|
||||||
|
tool_count: 1, edit_count: 0,
|
||||||
|
dep_flags: 0, esc_flags: 0, fatigue_flags: 0, val_flags: 0,
|
||||||
|
// pushback_count and domain_context intentionally absent (v1.0.0 state shape)
|
||||||
|
last_event_epoch: 0, burst_count: 0, last_warning_epoch: 0,
|
||||||
|
});
|
||||||
|
runHook('session-end.mjs', { session_id: 's5', cwd: '/tmp' }, dir);
|
||||||
|
const records = readJsonl(join(dir, 'sessions.jsonl'));
|
||||||
|
const end = records.find(r => r.end);
|
||||||
|
assert.ok(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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue