Import researched Persona stress profiles

This commit is contained in:
Meta Vens 2026-06-06 10:12:59 +01:00
commit 0c8da17279
5 changed files with 372 additions and 0 deletions

View file

@ -810,6 +810,12 @@ export const voidSelfStateOperationSchema = z.discriminatedUnion("operation", [
responses: z.array(faceStressResponseSchema).min(1),
updatedAt: timestampSchema,
}).strict(),
z.object({
operation: z.literal("replace_stress_responses_by_tag"),
replaceTags: z.array(nonEmptyStringSchema).min(1),
responses: z.array(faceStressResponseSchema).min(1),
updatedAt: timestampSchema,
}).strict(),
z.object({
operation: z.literal("upsert_doctrine_stance"),
stance: faceDoctrineStanceSchema,

View file

@ -498,6 +498,19 @@ function applyTypedOperation(
.slice(0, 24);
state.personaAffect.updatedAt = operation.updatedAt;
return;
case "replace_stress_responses_by_tag": {
const replaceTags = new Set(operation.replaceTags);
state.personaAffect.stressResponses = state.personaAffect.stressResponses
.filter((response) => !response.tags.some((tag) => replaceTags.has(tag)));
for (const response of operation.responses) {
upsertBy(state.personaAffect.stressResponses, response, (entry) => entry.responseId);
}
state.personaAffect.stressResponses = state.personaAffect.stressResponses
.sort((left, right) => right.intensity - left.intensity)
.slice(0, 24);
state.personaAffect.updatedAt = operation.updatedAt;
return;
}
case "upsert_doctrine_stance":
upsertBy(state.personaAffect.doctrineStances, operation.stance, (entry) => entry.stanceId);
state.personaAffect.doctrineStances = state.personaAffect.doctrineStances