From 23b2d7519735cd3fe3322f00ec1eb5ed1873e431 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 1 Dec 2026 20:11:06 +0100 Subject: [PATCH] interpreter: schema under the API's 24 optional properties; every section and list required, empty means nothing moved Co-Authored-By: Claude Sonnet 5.5 --- crates/mind-body/src/projection/interpret.rs | 82 ++++++++++---------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/crates/mind-body/src/projection/interpret.rs b/crates/mind-body/src/projection/interpret.rs index 594bb32..371cf70 100644 --- a/crates/mind-body/src/projection/interpret.rs +++ b/crates/mind-body/src/projection/interpret.rs @@ -23,7 +23,7 @@ const NAME_MIN: usize = 3; /// The frame of the call. `{name}` and her pronouns are filled by code, so one text serves every Mind. const FRAME: &str = "You are a private Interpreter. {name} has just lived a moment. Below is what the moment was like for {obj} (the narration), what {subj} thought about it (the thought), and an index of what in {poss} state can change. -Say which way {poss} state moved, as one JSON object of the schema. Every field is optional, and {} is the usual answer: change only what the thought shows moved. You give directions, never numbers: say up or down, and the commit decides how far. Use only the ids in the index; you make no need and no pressure. +Say which way {poss} state moved, as one JSON object of the schema. Give every section and every list: an empty list [] or empty object {} says nothing moved there, and all of them empty is the usual answer. Change only what the thought shows moved. You give directions, never numbers: say up or down, and the commit decides how far. Use only the ids in the index; you make no need and no pressure. Write every text you give in the third person, about {name}, in words of your own. Never carry another person's words from the room into a text: say what happened, not what they said. @@ -34,7 +34,9 @@ Write every text you give in the third person, about {name}, in words of your ow - self: a stance or value changes only when the thought shows {obj} changing {poss} mind about who {subj} {be}; it is rare. - intend: something {subj} means to do, within a week; a short third-person sentence, when it will be due in hours, and later or ready. Name an intention from the index as ready or drop it."; -/// The schema of the answer: the six families, each field optional. +/// The schema of the answer: the six families. The API grammar-compiles it and refuses more than 24 optional properties, so +/// every section and every list is required and an empty `[]` or `{}` is how the Interpreter says nothing moved there; only +/// scalars whose absence carries meaning stay optional. pub(crate) fn schema() -> String { let text = || json!({ "type": "string" }); let number = || json!({ "type": "number" }); @@ -42,44 +44,44 @@ pub(crate) fn schema() -> String { let strings = || json!({ "type": "array", "items": text() }); let list = |item: Value| json!({ "type": "array", "items": item }); let object = |properties: Value, required: &[&str]| json!({ "type": "object", "additionalProperties": false, "properties": properties, "required": required }); - json!({ - "type": "object", - "additionalProperties": false, - "properties": { - "notes": object(json!({ - "remember": list(object(json!({ "text": text(), "about": strings(), "importance": number(), "private": { "type": "boolean" } }), &["text"])), - "settle": list(object(json!({ "id": text(), "into": { "type": "string", "enum": ["resolved", "memory"] } }), &["id", "into"])), - "wonder": list(object(json!({ "text": text(), "about": strings() }), &["text"])), - }), &[]), - "people": object(json!({ - "bonds": list(object(json!({ "person": text(), "trust": direction(), "tension": direction(), "closeness": direction(), "kind": text(), "summary": text(), "why": text() }), &["person"])), - "reads": list(object(json!({ "person": text(), "kind": text(), "summary": text(), "confidence": number() }), &["person", "kind", "summary"])), - }), &[]), - "feeling": object(json!({ - "feelings": list(object(json!({ "name": text(), "strength": number(), "about": text() }), &["name", "strength"])), - "mood": object(json!({ "valence": direction(), "arousal": direction(), "dominance": direction() }), &[]), - }), &[]), - "drives": object(json!({ - "needs": list(object(json!({ "id": text(), "toward": { "type": "string", "enum": ["up", "down", "met"] } }), &["id", "toward"])), - "pressures": list(object(json!({ "id": text(), "toward": { "type": "string", "enum": ["up", "down", "eased"] } }), &["id", "toward"])), - }), &[]), - "self": object(json!({ - "stances": list(object(json!({ "id": text(), "principle": text(), "summary": text() }), &["principle", "summary"])), - "identity": object(json!({ - "publicName": text(), - "publicDescription": text(), - "presentation": object(json!({ "voiceSummary": text(), "pronouns": text() }), &[]), - "values": list(object(json!({ "id": text(), "label": text(), "summary": text(), "priority": number() }), &["label", "summary"])), - }), &[]), - }), &[]), - "intend": object(json!({ - "add": list(object(json!({ "summary": text(), "target": text(), "urgency": number(), "expires_in_hours": { "type": "integer" }, "readiness": { "type": "string", "enum": ["later", "ready"] } }), &["summary", "expires_in_hours"])), - "ready": strings(), - "drop": strings(), - }), &[]), - }, - "required": [], - }) + // An object whose every property is required: its sections and lists, which say nothing by being empty. + let whole = |properties: Value| { + let required: Vec = properties.as_object().into_iter().flatten().map(|(name, _)| name.clone()).collect(); + json!({ "type": "object", "additionalProperties": false, "properties": properties, "required": required }) + }; + whole(json!({ + "notes": whole(json!({ + "remember": list(object(json!({ "text": text(), "about": strings(), "importance": number(), "private": { "type": "boolean" } }), &["text", "about"])), + "settle": list(object(json!({ "id": text(), "into": { "type": "string", "enum": ["resolved", "memory"] } }), &["id", "into"])), + "wonder": list(object(json!({ "text": text(), "about": strings() }), &["text", "about"])), + })), + "people": whole(json!({ + "bonds": list(object(json!({ "person": text(), "trust": direction(), "tension": direction(), "closeness": direction(), "kind": text(), "summary": text(), "why": text() }), &["person"])), + "reads": list(object(json!({ "person": text(), "kind": text(), "summary": text(), "confidence": number() }), &["person", "kind", "summary"])), + })), + "feeling": whole(json!({ + "feelings": list(object(json!({ "name": text(), "strength": number(), "about": text() }), &["name", "strength"])), + "mood": object(json!({ "valence": direction(), "arousal": direction(), "dominance": direction() }), &[]), + })), + "drives": whole(json!({ + "needs": list(object(json!({ "id": text(), "toward": { "type": "string", "enum": ["up", "down", "met"] } }), &["id", "toward"])), + "pressures": list(object(json!({ "id": text(), "toward": { "type": "string", "enum": ["up", "down", "eased"] } }), &["id", "toward"])), + })), + "self": whole(json!({ + "stances": list(object(json!({ "id": text(), "principle": text(), "summary": text() }), &["principle", "summary"])), + "identity": object(json!({ + "publicName": text(), + "publicDescription": text(), + "presentation": object(json!({ "voiceSummary": text(), "pronouns": text() }), &[]), + "values": list(object(json!({ "id": text(), "label": text(), "summary": text(), "priority": number() }), &["label", "summary"])), + }), &["presentation", "values"]), + })), + "intend": whole(json!({ + "add": list(object(json!({ "summary": text(), "target": text(), "urgency": number(), "expires_in_hours": { "type": "integer" }, "readiness": { "type": "string", "enum": ["later", "ready"] } }), &["summary", "expires_in_hours"])), + "ready": strings(), + "drop": strings(), + })), + })) .to_string() }