feat(ai-psychosis): tier-2 user-info isolation alert (cross-session)
This commit is contained in:
parent
4fd5e7b24a
commit
61584f42d6
3 changed files with 105 additions and 0 deletions
|
|
@ -52,6 +52,11 @@ if (startEpoch > 0) {
|
|||
durationMin = Math.floor((nowTs - startEpoch) / 60);
|
||||
}
|
||||
|
||||
// v1.2: also persist user_info_class (read-only — set during prompt-analyzer).
|
||||
const userInfoClass = state.user_info_class || null;
|
||||
const valseekCount = Number(state.valseek_count) || 0;
|
||||
const turnCount = Number(state.turn_count) || 0;
|
||||
|
||||
// Append finalized session record
|
||||
appendJsonl(SESSIONS_LOG, {
|
||||
session_id: sid,
|
||||
|
|
@ -61,6 +66,9 @@ appendJsonl(SESSIONS_LOG, {
|
|||
tool_count: toolCount,
|
||||
edit_count: editCount,
|
||||
domain_context: domainContextArray,
|
||||
user_info_class: userInfoClass,
|
||||
valseek_count: valseekCount,
|
||||
turn_count: turnCount,
|
||||
flags: {
|
||||
dependency: depFlags,
|
||||
escalation: escFlags,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue