persona-delta-verbs: add behavioral tests killing mutation survivors
This commit is contained in:
parent
3bc296a535
commit
4285bf0bf8
2 changed files with 286 additions and 9 deletions
|
|
@ -1734,4 +1734,174 @@ mod tests {
|
|||
assert!(!rendered.contains(forbidden), "leaked `{forbidden}` in:\n{rendered}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_seed_exercises_optional_fields_and_empty_omissions() {
|
||||
let rich = json!({
|
||||
"personaId": "eureka",
|
||||
"publicName": "Eureka",
|
||||
"presentation": {
|
||||
"voiceSummary": "clear and dry",
|
||||
"jurisdiction": "GameCult",
|
||||
"homeContext": { "kind": "room", "id": "#swarm:gamecult.org", "label": "Swarm" },
|
||||
"publicHandles": [
|
||||
{ "system": "matrix", "handle": "@eureka:gamecult.org" },
|
||||
{ "system": "", "handle": "SKIP-NO-SYS" },
|
||||
{ "system": "SKIP-NO-HANDLE", "handle": "" }
|
||||
]
|
||||
},
|
||||
"activationProfile": {
|
||||
"underlyingOrganization": {},
|
||||
"stableDispositions": {},
|
||||
"behavioralDimensions": {},
|
||||
"presentationStrategy": {},
|
||||
"voiceStyle": {},
|
||||
"situationalState": {
|
||||
"valence": { "mean": 0.5, "plasticity": 0.3, "currentActivation": 0.6 }
|
||||
}
|
||||
},
|
||||
"thoughtMemory": {
|
||||
"shortTerm": [
|
||||
{
|
||||
"id": "st-full",
|
||||
"status": "active",
|
||||
"target": { "kind": "self", "id": "eureka" },
|
||||
"summary": "Full thought",
|
||||
"claim": "Claim A",
|
||||
"question": "Question A",
|
||||
"tension": "Tension A",
|
||||
"actionImplication": "Action A"
|
||||
},
|
||||
{
|
||||
"id": "st-bare",
|
||||
"status": "active",
|
||||
"target": {},
|
||||
"summary": "Bare thought"
|
||||
},
|
||||
{
|
||||
"id": "st-kind-only",
|
||||
"status": "active",
|
||||
"target": { "kind": "room", "id": "" },
|
||||
"summary": "Kind-only target"
|
||||
}
|
||||
]
|
||||
},
|
||||
"embodiment": {
|
||||
"senses": [
|
||||
{ "id": "s1", "status": "active", "label": "Matrix", "summary": "Reads rooms", "lacks": "audio" }
|
||||
],
|
||||
"actuators": [
|
||||
{ "id": "a1", "status": "active", "label": "Mouth", "summary": "Speaks" }
|
||||
]
|
||||
},
|
||||
"affect": {
|
||||
"socialBonds": [
|
||||
{
|
||||
"id": "b-claim", "status": "active",
|
||||
"object": { "kind": "person", "id": "p1" },
|
||||
"relationshipKind": "ally", "summary": "Bond 1",
|
||||
"lastEvidence": { "claim": "Claim only" }
|
||||
},
|
||||
{
|
||||
"id": "b-sum", "status": "active",
|
||||
"object": { "kind": "person", "id": "p2" },
|
||||
"relationshipKind": "ally", "summary": "Bond 2",
|
||||
"lastEvidence": { "summary": "Summary only" }
|
||||
},
|
||||
{
|
||||
"id": "b-empty-ev", "status": "active",
|
||||
"object": { "kind": "person", "id": "p3" },
|
||||
"relationshipKind": "ally", "summary": "Bond 3",
|
||||
"lastEvidence": { "claim": "", "summary": "" }
|
||||
}
|
||||
],
|
||||
"statusReads": [
|
||||
{
|
||||
"id": "sr-priv-ev", "status": "active",
|
||||
"target": { "kind": "person", "id": "p1" },
|
||||
"statusKind": "trust", "summary": "Read 1",
|
||||
"lastEvidence": { "claim": "LEAK-SR-EV", "extensions": { "privacy": "private" } }
|
||||
},
|
||||
{
|
||||
"id": "sr-claim", "status": "active",
|
||||
"target": { "kind": "person", "id": "p2" },
|
||||
"statusKind": "trust", "summary": "Read 2",
|
||||
"lastEvidence": { "claim": "Read claim" }
|
||||
},
|
||||
{
|
||||
"id": "sr-empty-ev", "status": "active",
|
||||
"target": { "kind": "person", "id": "p3" },
|
||||
"statusKind": "trust", "summary": "Read 3",
|
||||
"lastEvidence": { "claim": "", "summary": "" }
|
||||
}
|
||||
]
|
||||
},
|
||||
"candidateActions": {
|
||||
"actions": [
|
||||
{
|
||||
"id": "i-full", "status": "active", "actionType": "custom", "customActionType": "intention",
|
||||
"readiness": "ready", "target": { "kind": "self", "id": "eureka" },
|
||||
"summary": "Full intention", "rationale": "Why do this"
|
||||
},
|
||||
{
|
||||
"id": "i-bare", "status": "active", "actionType": "custom", "customActionType": "intention",
|
||||
"readiness": "waiting", "target": {},
|
||||
"summary": "Bare intention"
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
let rendered = render_seed(&rich, "2026-12-06T00:00:00Z", "r-1");
|
||||
for expected in [
|
||||
"Voice: clear and dry\n",
|
||||
"Jurisdiction: GameCult\n",
|
||||
"Home: room:#swarm:gamecult.org (Swarm)\n",
|
||||
"Handles: matrix:@eureka:gamecult.org\n",
|
||||
"- [st-full] (active, self:eureka): Full thought | claim: Claim A | question: Question A | tension: Tension A | action: Action A\n",
|
||||
"- [st-bare] (active): Bare thought\n",
|
||||
"- [st-kind-only] (active, room:): Kind-only target\n",
|
||||
"- sense [s1] Matrix: Reads rooms (lacks: audio)\n",
|
||||
"- actuator [a1] Mouth: Speaks\n",
|
||||
"Situational State:\n",
|
||||
"- [b-claim] p1 [ally] trust=0.50 tension=0.20: Bond 1 | lastEvidence: Claim only (was: )\n",
|
||||
"- [b-sum] p2 [ally] trust=0.50 tension=0.20: Bond 2 | lastEvidence: (was: Summary only)\n",
|
||||
"- [b-empty-ev] p3 [ally] trust=0.50 tension=0.20: Bond 3\n",
|
||||
"- [sr-priv-ev] person:p1 [trust, conf=0.50]: Read 1\n",
|
||||
"- [sr-claim] person:p2 [trust, conf=0.50]: Read 2 | lastEvidence: Read claim (was: )\n",
|
||||
"- [sr-empty-ev] person:p3 [trust, conf=0.50]: Read 3\n",
|
||||
"- [i-full] (intention, ready, self:eureka): Full intention | rationale: Why do this\n",
|
||||
"- [i-bare] (intention, waiting): Bare intention\n",
|
||||
] {
|
||||
assert!(rendered.contains(expected), "missing `{expected}` in:\n{rendered}");
|
||||
}
|
||||
for absent in [
|
||||
"SKIP-NO-SYS",
|
||||
"SKIP-NO-HANDLE",
|
||||
"LEAK-SR-EV",
|
||||
"xyzzy",
|
||||
"Stable Dispositions:",
|
||||
"Behavioral Dimensions:",
|
||||
"Presentation Strategy:",
|
||||
"Voice Style:",
|
||||
"Underlying Organization:",
|
||||
] {
|
||||
assert!(!rendered.contains(absent), "unexpected `{absent}` in:\n{rendered}");
|
||||
}
|
||||
|
||||
// Minimal document omits optional headers when absent, and actuators alone still render Embodiment.
|
||||
let actuators_only = json!({
|
||||
"personaId": "eureka",
|
||||
"publicName": "Eureka",
|
||||
"presentation": { "homeContext": {} },
|
||||
"embodiment": {
|
||||
"senses": [],
|
||||
"actuators": [{ "id": "a1", "status": "active", "label": "Mouth", "summary": "Speaks" }]
|
||||
}
|
||||
});
|
||||
let min_rendered = render_seed(&actuators_only, "2026-12-06T00:00:00Z", "r-2");
|
||||
assert!(min_rendered.contains("Embodiment:\n- actuator [a1] Mouth: Speaks\n"), "{min_rendered}");
|
||||
for absent in ["Voice:", "Jurisdiction:", "Home:", "Handles:"] {
|
||||
assert!(!min_rendered.contains(absent), "unexpected `{absent}` in:\n{min_rendered}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3118,7 +3118,7 @@ fn persona_memory_add_and_retire_round_trip_cas() {
|
|||
assert_eq!(inc.code, 0, "{} {}", inc.out, inc.err);
|
||||
assert!(inc.out.contains("id w-custom-1\n"), "{}", inc.out);
|
||||
|
||||
// 3. memory add (--kind memory -> crystallized)
|
||||
// 3. memory add (--kind memory -> crystallized, blank --question omitted)
|
||||
let mem = at(
|
||||
server.addr,
|
||||
&[
|
||||
|
|
@ -3126,6 +3126,7 @@ fn persona_memory_add_and_retire_round_trip_cas() {
|
|||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--kind", "memory",
|
||||
"--summary", "Direct crystallized memory",
|
||||
"--question", " ",
|
||||
],
|
||||
None,
|
||||
);
|
||||
|
|
@ -3155,8 +3156,12 @@ fn persona_memory_add_and_retire_round_trip_cas() {
|
|||
assert_eq!(st["claim"], "cursor lags on reconnect");
|
||||
assert_eq!(st["intensity"], 0.8);
|
||||
assert_eq!(st["valence"], -0.25);
|
||||
assert_eq!(st["tags"], json!(["room:#swarm:gamecult.org", "about:meta"]));
|
||||
assert_eq!(doc["thoughtMemory"]["memories"][0]["id"], mem_id);
|
||||
assert_eq!(doc["thoughtMemory"]["memories"][0]["status"], "crystallized");
|
||||
assert!(doc["thoughtMemory"]["memories"][0].get("question").is_none());
|
||||
assert!(doc["thoughtMemory"]["memories"][0].get("tags").is_none());
|
||||
assert_eq!(doc["thoughtMemory"]["incubation"][0]["question"], "Did keepalive expire?");
|
||||
assert_eq!(doc["thoughtMemory"]["incubation"][0]["target"], json!({ "kind": "person", "id": "meta", "label": "Meta" }));
|
||||
|
||||
// 4. memory retire --status crystallized moves shortTerm -> memories
|
||||
|
|
@ -3282,7 +3287,47 @@ fn persona_bond_mood_intention_round_trip_cas() {
|
|||
assert_eq!(b2["lastEvidence"]["claim"], "Shipped clean cuts together");
|
||||
assert_eq!(b2["lastEvidence"]["createdAt"], prior_updated);
|
||||
|
||||
// 3. mood set: feeling + axis init + update + clear
|
||||
// Second distinct person bond + --custom-kind update rules on existing custom vs non-custom bonds.
|
||||
let nibu = at(
|
||||
server.addr,
|
||||
&[
|
||||
"persona", "bond", "update",
|
||||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--person", "nibu", "--label", "Nibu", "--kind", "ally", "--status", "active",
|
||||
"--summary", "Peer bond",
|
||||
],
|
||||
None,
|
||||
);
|
||||
assert_eq!(nibu.code, 0, "{} {}", nibu.out, nibu.err);
|
||||
let non_custom_err = at(
|
||||
server.addr,
|
||||
&[
|
||||
"persona", "bond", "update",
|
||||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--person", "nibu", "--custom-kind", "should_fail",
|
||||
],
|
||||
None,
|
||||
);
|
||||
assert_eq!(non_custom_err.code, 2, "{} {}", non_custom_err.out, non_custom_err.err);
|
||||
let custom_ok = at(
|
||||
server.addr,
|
||||
&[
|
||||
"persona", "bond", "update",
|
||||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--person", "meta", "--custom-kind", "steward_partner_v2",
|
||||
],
|
||||
None,
|
||||
);
|
||||
assert_eq!(custom_ok.code, 0, "{} {}", custom_ok.out, custom_ok.err);
|
||||
let doc_bonds = fetch_persona_json(server.addr);
|
||||
let bonds_arr = doc_bonds["affect"]["socialBonds"].as_array().unwrap();
|
||||
assert_eq!(bonds_arr.len(), 2);
|
||||
assert_eq!(bonds_arr[0]["object"]["id"], "meta");
|
||||
assert_eq!(bonds_arr[0]["customRelationshipKind"], "steward_partner_v2");
|
||||
assert_eq!(bonds_arr[1]["object"]["id"], "nibu");
|
||||
assert_eq!(bonds_arr[1]["status"], "active");
|
||||
|
||||
// 3. mood set: feeling + source + axis init + update in place + clear
|
||||
let mood1 = at(
|
||||
server.addr,
|
||||
&[
|
||||
|
|
@ -3294,6 +3339,8 @@ fn persona_bond_mood_intention_round_trip_cas() {
|
|||
None,
|
||||
);
|
||||
assert_eq!(mood1.code, 0, "{} {}", mood1.out, mood1.err);
|
||||
let doc_mood1 = fetch_persona_json(server.addr);
|
||||
assert_eq!(doc_mood1["affect"]["moodDimensions"][0]["source"], "room:#swarm:gamecult.org");
|
||||
let mood2 = at(
|
||||
server.addr,
|
||||
&[
|
||||
|
|
@ -3306,12 +3353,23 @@ fn persona_bond_mood_intention_round_trip_cas() {
|
|||
None,
|
||||
);
|
||||
assert_eq!(mood2.code, 0, "{} {}", mood2.out, mood2.err);
|
||||
let mood3 = at(
|
||||
server.addr,
|
||||
&[
|
||||
"persona", "mood", "set",
|
||||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--feeling", "focused", "--value", "0.4", "--source", " ",
|
||||
],
|
||||
None,
|
||||
);
|
||||
assert_eq!(mood3.code, 0, "{} {}", mood3.out, mood3.err);
|
||||
|
||||
let doc3 = fetch_persona_json(server.addr);
|
||||
let feelings = doc3["affect"]["moodDimensions"].as_array().unwrap();
|
||||
assert_eq!(feelings.len(), 1);
|
||||
assert_eq!(feelings[0]["name"], "focused");
|
||||
assert_eq!(feelings[0]["value"], 0.9);
|
||||
assert_eq!(feelings[0]["value"], 0.4);
|
||||
assert!(feelings[0].get("source").is_none());
|
||||
let valence_vec = &doc3["activationProfile"]["situationalState"]["valence"];
|
||||
assert_eq!(valence_vec["mean"], 0.55);
|
||||
assert_eq!(valence_vec["plasticity"], 0.4);
|
||||
|
|
@ -3364,27 +3422,69 @@ fn persona_bond_mood_intention_round_trip_cas() {
|
|||
assert_eq!(act["riskLevel"], "low");
|
||||
assert_eq!(act["status"], "retired");
|
||||
assert_eq!(act["readiness"], "expired");
|
||||
assert_eq!(act["rationale"], "Verify peer traffic");
|
||||
assert!(act["expiresAt"].as_str().is_some());
|
||||
|
||||
// After drop, adding the same normalized summary succeeds with a fresh id.
|
||||
// After drop, adding the same normalized summary succeeds with a fresh id, and a second distinct active intention also succeeds.
|
||||
let readd = at(
|
||||
server.addr,
|
||||
&[
|
||||
"persona", "intention", "add",
|
||||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--summary", "check public matrix room",
|
||||
"--rationale", " ",
|
||||
],
|
||||
None,
|
||||
);
|
||||
assert_eq!(readd.code, 0, "{} {}", readd.out, readd.err);
|
||||
|
||||
// Dropping an unknown id fails exit 2.
|
||||
let missing_drop = at(
|
||||
let second = at(
|
||||
server.addr,
|
||||
&["persona", "intention", "drop", "--faculty", "Hands", "--agent", "a", "--session", "s", "i-nope"],
|
||||
&[
|
||||
"persona", "intention", "add",
|
||||
"--faculty", "Hands", "--agent", "eureka-persona", "--session", "s1",
|
||||
"--summary", "Review open PRs",
|
||||
],
|
||||
None,
|
||||
);
|
||||
assert_eq!(missing_drop.code, 2, "{} {}", missing_drop.out, missing_drop.err);
|
||||
assert_eq!(second.code, 0, "{} {}", second.out, second.err);
|
||||
let doc_int = fetch_persona_json(server.addr);
|
||||
assert!(doc_int["candidateActions"]["actions"][1].get("rationale").is_none());
|
||||
|
||||
// Non-intention candidateActions entries neither block intention add nor allow intention drop.
|
||||
let mut with_other = doc_int;
|
||||
with_other["candidateActions"]["actions"].as_array_mut().unwrap().extend([
|
||||
json!({
|
||||
"id": "act-speak", "status": "active", "actionType": "speak",
|
||||
"readiness": "ready", "riskLevel": "low",
|
||||
"target": { "kind": "self", "id": INSTANCE },
|
||||
"summary": "Non-intention speak",
|
||||
"createdAt": "2026-10-10T10:00:00Z", "updatedAt": "2026-10-10T10:00:00Z"
|
||||
}),
|
||||
json!({
|
||||
"id": "act-custom-other", "status": "active", "actionType": "custom", "customActionType": "other",
|
||||
"readiness": "ready", "riskLevel": "low",
|
||||
"target": { "kind": "self", "id": INSTANCE },
|
||||
"summary": "Non-intention custom",
|
||||
"createdAt": "2026-10-10T10:00:00Z", "updatedAt": "2026-10-10T10:00:00Z"
|
||||
}),
|
||||
]);
|
||||
seed_persona(server.addr, &with_other);
|
||||
for same_summary in ["Non-intention speak", "Non-intention custom"] {
|
||||
let ok = at(
|
||||
server.addr,
|
||||
&["persona", "intention", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", same_summary],
|
||||
None,
|
||||
);
|
||||
assert_eq!(ok.code, 0, "{same_summary}: {} {}", ok.out, ok.err);
|
||||
}
|
||||
for non_int_id in ["act-speak", "act-custom-other", "i-nope"] {
|
||||
let missing_drop = at(
|
||||
server.addr,
|
||||
&["persona", "intention", "drop", "--faculty", "Hands", "--agent", "a", "--session", "s", non_int_id],
|
||||
None,
|
||||
);
|
||||
assert_eq!(missing_drop.code, 2, "{non_int_id}: {} {}", missing_drop.out, missing_drop.err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -3716,6 +3816,7 @@ fn persona_deltas_reject_private_tags_and_bad_bounds_before_wire() {
|
|||
let cases: &[&[&str]] = &[
|
||||
&["persona", "memory", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "hi", "--tag", "private"],
|
||||
&["persona", "memory", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "hi", "--tag", "room:!r:g"],
|
||||
&["persona", "memory", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "hi", "--tag", "Room:!r:g"],
|
||||
&["persona", "memory", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", " "],
|
||||
&["persona", "memory", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "hi", "--importance", "1.5"],
|
||||
&["persona", "memory", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "hi", "--importance", "-0.1"],
|
||||
|
|
@ -3726,13 +3827,19 @@ fn persona_deltas_reject_private_tags_and_bad_bounds_before_wire() {
|
|||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--feeling", "calm"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--feeling", "calm", "--value", "1.2"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--value", "0.5"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--source", "room:#swarm:gamecult.org"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--axis", "valence"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--axis", "valence", "--activation", "1.2"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--axis", "valence", "--activation", "0.5", "--mean", "1.5"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--axis", "valence", "--activation", "0.5", "--plasticity", "-0.1"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--activation", "0.5"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--mean", "0.5"],
|
||||
&["persona", "mood", "set", "--faculty", "Hands", "--agent", "a", "--session", "s", "--plasticity", "0.5"],
|
||||
&["persona", "bond", "update", "--faculty", "Hands", "--agent", "a", "--session", "s", "--person", "meta"],
|
||||
&["persona", "bond", "update", "--faculty", "Hands", "--agent", "a", "--session", "s", "--person", "meta", "--trust", "1.5", "--summary", "x"],
|
||||
&["persona", "bond", "update", "--faculty", "Hands", "--agent", "a", "--session", "s", "--person", "meta", "--kind", "bogus", "--summary", "x"],
|
||||
&["persona", "bond", "update", "--faculty", "Hands", "--agent", "a", "--session", "s", "--person", "meta", "--status", "bogus", "--summary", "x"],
|
||||
&["persona", "intention", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", " "],
|
||||
&["persona", "intention", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "act", "--urgency", "1.5"],
|
||||
&["persona", "intention", "add", "--faculty", "Hands", "--agent", "a", "--session", "s", "--summary", "act", "--confidence", "-0.2"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue