Persona K34: Needs is read through its shape, so request on a words or lacking need is malformed; one NeedsKind

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-22 01:06:18 +01:00
commit bdb6f2fd69
2 changed files with 36 additions and 11 deletions

View file

@ -60,15 +60,48 @@ pub(crate) enum How {
/// What keeping a promise needs (map 16.25.2): her words alone, from what she already has; a read of `request`; or
/// something this body has no way to do. Code owns what each kind requires of a kept close (`apply_one`), and derives
/// whether the promise opens or is blocked from it. A field no kind names makes it no `Needs`, as P1 holds it (map 16.27).
/// whether the promise opens or is blocked from it. It is read through its shape (`NeedsShape`): a field no kind names,
/// `request` on a kind other than `read`, makes it no `Needs`, as P1 holds it (map 16.27).
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)]
#[serde(tag = "kind", rename_all = "snake_case", try_from = "NeedsShape")]
pub(crate) enum Needs {
Words,
Read { request: ReadRequest },
Lacking,
}
/// What kind of thing keeping a promise needs: `Needs` without its read.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "snake_case")]
pub(crate) enum NeedsKind {
Words,
Read,
Lacking,
}
/// `Needs` as it is written: its kind, and a request only for a read; nothing else.
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct NeedsShape {
kind: NeedsKind,
#[serde(default)]
request: Option<ReadRequest>,
}
impl TryFrom<NeedsShape> for Needs {
type Error = &'static str;
fn try_from(shape: NeedsShape) -> Result<Self, Self::Error> {
match (shape.kind, shape.request) {
(NeedsKind::Words, None) => Ok(Self::Words),
(NeedsKind::Lacking, None) => Ok(Self::Lacking),
(NeedsKind::Read, Some(request)) => Ok(Self::Read { request }),
(NeedsKind::Read, None) => Err("a read need names its request"),
(NeedsKind::Words | NeedsKind::Lacking, Some(_)) => Err("only a read need names a request"),
}
}
}
/// One state change the Interpreter proposes. `promise` names an open promise by its id in the Interpreter's list.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]

View file

@ -43,7 +43,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use super::Affordance;
use super::commit::{Evidence, How, Needs, Proposal};
use super::commit::{Evidence, How, Needs, NeedsKind, Proposal};
use super::read::{self, Asked, Kind, QUOTE_MIN_WORDS, ReadRequest, SPAN_MIN_WORDS};
use super::narrate::{Model, heard_overlap, lived_stream, words};
use super::select::{Forms, Packet, capitalized, named_pronouns, spoken, turn_words, voiced};
@ -427,14 +427,6 @@ struct ProposedNeeds {
read: Option<NeededRead>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "snake_case")]
enum NeedsKind {
Words,
Read,
Lacking,
}
/// A read a promise needs, as the answer names it: a read's kind and target, with no quote.
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]