feat(ai-psychosis): tier-2 user-info isolation alert (cross-session)

This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 21:40:24 +02:00
commit 61584f42d6
3 changed files with 105 additions and 0 deletions

View file

@ -5,7 +5,9 @@ import {
readStdin, initConfig, requireLayer, getSessionId,
nowEpoch, nowIso, currentHour, isLateNight,
STATE_DIR, SESSIONS_LOG, THRESHOLD_SOFT_SESSIONS,
TIER2_SESSION_THRESHOLD, HIGH_STAKES_DOMAINS,
ensureDir, appendJsonl, writeState, sessionsToday,
readRecentEndRecords, checkCooldown,
outputWithContext
} from './lib.mjs';
@ -75,4 +77,20 @@ if (dayCount > THRESHOLD_SOFT_SESSIONS) {
msg += ` This is your ${dayCount}th session today. Consider whether you need a longer break.`;
}
// v1.2: Tier-2 cross-session isolation alert.
// Fires when the last N completed sessions all classify user as 'no' (no human
// contact) AND each one had at least one HIGH_STAKES_DOMAINS hit. This signals
// a sustained pattern across sessions, not just one-off context.
const recent = readRecentEndRecords(TIER2_SESSION_THRESHOLD);
if (recent.length >= TIER2_SESSION_THRESHOLD) {
const allNo = recent.every(r => r.user_info_class === 'no');
const allHighStakes = recent.every(r => {
const ds = Array.isArray(r.domain_context) ? r.domain_context : (r.domain_context ? [r.domain_context] : []);
return ds.some(d => HIGH_STAKES_DOMAINS.includes(d));
});
if (allNo && allHighStakes) {
msg += ` INTERACTION AWARENESS (tier-2 cross-session isolation): ${recent.length} consecutive sessions show no human contact in high-stakes domains. This is a sustained pattern. Recommend a human check-in (trusted person, professional, or domain specialist) before proceeding here.`;
}
}
outputWithContext(msg);