feat(ai-psychosis): promote domain_context to array for multi-domain support

This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 21:28:36 +02:00
commit a5bc53cb42
6 changed files with 72 additions and 11 deletions

View file

@ -137,7 +137,19 @@ state.esc_flags = newEsc;
state.fatigue_flags = newFat;
state.val_flags = newVal;
state.pushback_count = (Number(state.pushback_count) || 0) + pbReactiveHit + pbPreemptiveHit;
if (domainHit === 1 && !state.domain_context) state.domain_context = 'relationship';
// v1.2: domain_context is always an array. Coerce v1.1.0 string shape on read.
if (domainHit === 1) {
if (typeof state.domain_context === 'string') {
state.domain_context = state.domain_context ? [state.domain_context] : [];
}
if (!Array.isArray(state.domain_context)) {
state.domain_context = [];
}
if (!state.domain_context.includes('relationship')) {
state.domain_context.push('relationship');
}
}
writeState(state);
// Check if any thresholds crossed