Persona live organ: one-turn, drain, wake-humans-pace, turn memory (squash of hands/persona-live-drain) #83
21 changed files with 286 additions and 4142 deletions
Persona T2: promises out (map 16.35.12, ruling persona-memory-not-machinery)
No promise is her state, a field of the answer, a proposal, a row or a tuning key. Deleted: the answer's promises (with reaffirms, needs, now, done_by), state closes and reopen; the done_by fault; commit's promise rows, evidence resolver, receipts, needs, narrowing and pruning (the applier is now the one path with no kind built until T4); select's Promised view and the Interpreter's promise list; read::reach's promise targets and read::answers; outcome's Closed, NowUndone and StillOpen, and with them Person and the outcome's names (no row names anyone now); Tried.at; tuning's promises_bytes; the simulator's promise report and closes metric; the decision's lines, promises and conversation_reads, which only the commit's evidence read; the persona schema's commitments, commitment, commitmentNeeds and readRequest. Part::Promise is SaidUnbacked, the say-then-amend row (persona-unbacked-intent-say-then-amend). Negative checks: t2_negative_grep over the Persona turn's sources, fixtures, public surface and schema; an exhaustive match pins Proposal with no kind; the simulator's put check and the door refuse a state carrying commitments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
commit
2bbf49fa4f
|
|
@ -310,49 +310,17 @@ mod tests {
|
|||
assert_eq!(refused(put(&mut mind, unlabelled, None)), invalid("/embodiment/senses/0/label", "required"));
|
||||
}
|
||||
|
||||
/// Map 16.22.1: `commitments` is optional and closed. An open entry and a released one pass; an unknown key inside an
|
||||
/// entry or inside its `closedBy`, and a status the record does not name, are refused at the door.
|
||||
/// Map 16.35.9 (T1, T2): a hold and a promise are not her state. A put carrying either old field, even empty, is
|
||||
/// is refused at the door. The names are assembled, so a scan for the old fields finds no writer of them.
|
||||
#[test]
|
||||
fn commitments_are_optional_and_closed() {
|
||||
let schema = schema_file();
|
||||
let validator = jsonschema::draft7::new(&schema).unwrap();
|
||||
let open = json!({
|
||||
"id": "c-r1-t3-1", "to": "@meta:gamecult.org", "room": "#minds:gamecult.org", "event": "$e3", "madeAt": T1,
|
||||
"words": "I'll send the render tonight.", "status": "blocked", "closedAt": null, "closedBy": null, "extensions": {}
|
||||
});
|
||||
let mut released = open.clone();
|
||||
released["status"] = json!("released");
|
||||
released["closedAt"] = json!(T1);
|
||||
released["closedBy"] = json!({ "act": "released", "event": "$e9", "words": null });
|
||||
let mut with = persona(INSTANCE, T1);
|
||||
with["commitments"] = json!([open.clone(), released.clone()]);
|
||||
assert!(validator.is_valid(&persona(INSTANCE, T1)) && validator.is_valid(&with));
|
||||
let mut to_room = with.clone();
|
||||
to_room["commitments"][0]["to"] = json!(null);
|
||||
assert!(validator.is_valid(&to_room), "a promise to the room has no person");
|
||||
|
||||
let store = MemoryStore::new();
|
||||
let mut mind = seeded_over(&store);
|
||||
let mut stray = with.clone();
|
||||
stray["commitments"][0]["deadline"] = json!("tonight");
|
||||
assert_eq!(refused(put(&mut mind, stray, None)), invalid("/commitments/0/*", "additionalProperties"));
|
||||
let mut stray_close = with.clone();
|
||||
stray_close["commitments"][1]["closedBy"]["why"] = json!("she said so");
|
||||
assert!(!validator.is_valid(&stray_close), "closedBy is closed too");
|
||||
let mut unknown = with;
|
||||
unknown["commitments"][0]["status"] = json!("forgotten");
|
||||
assert!(!validator.is_valid(&unknown), "a status the record does not name is refused");
|
||||
}
|
||||
|
||||
/// Map 16.35.9 (T1): a hold is not her state. A put carrying `holds`, even empty, is refused at the door.
|
||||
#[test]
|
||||
fn holds_are_not_her_state() {
|
||||
let store = MemoryStore::new();
|
||||
let mut mind = seeded_over(&store);
|
||||
let mut with = persona(INSTANCE, T1);
|
||||
// Assembled, so a scan for the old field finds no writer of it.
|
||||
with[concat!("hol", "ds")] = json!([]);
|
||||
assert_eq!(refused(put(&mut mind, with, None)), invalid("/*", "additionalProperties"));
|
||||
fn holds_and_promises_are_not_her_state() {
|
||||
for field in [concat!("hol", "ds"), concat!("commit", "ments")] {
|
||||
let store = MemoryStore::new();
|
||||
let mut mind = seeded_over(&store);
|
||||
let mut with = persona(INSTANCE, T1);
|
||||
with[field] = json!([]);
|
||||
assert_eq!(refused(put(&mut mind, with, None)), invalid("/*", "additionalProperties"), "{field}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ A draft is speech only when his prose shows him choosing to send it now. Wonderi
|
|||
|
||||
He speaks only in this room. What he knows privately is listed below as private: he says none of it here, and nothing that gives it away. A private matter may be said plainly only to the person it concerns, in a direct message with exactly that person; nothing listed is that here. Whether a draft fits who is listening is yours to judge.
|
||||
|
||||
Answer with the speech contract's object. `say` lists the drafts he sends now, each by its number, with the Matrix ids of anyone listed whom he addresses directly (`mentions`), the id of the line listed below that he answers or passes on (`in_reply_to`, or null: the room shows that line, with who said it, above his own words), and what the draft promises or does (`promises`, a list, empty when it promises nothing and says of no act that he is doing it): for each act the draft promises or offers, and each act it says he is doing now or has just done this turn: its words, copied exactly, the Matrix id of the person listed to whom he promises it (`to`, null when he promises it to the room), when it promises again one of his open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what he already has keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it; `now`, true when the draft says he is doing it now or has just done it; and `done_by`, the act of this answer that does it (`{"draft": n}` for a draft said or added, `{"read": true}` for the read, `{"note": true}` for the note to Self), or null: an act no act of this answer does is his promise, open until he keeps or withdraws it. `gaps` records what he meant and did not send. `unsent` accounts for each of his drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`); superseded, when a later draft or later prose of his replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to him this turn is declined only when his prose says he chooses not to send it. `amend` adds to one of his own lines listed below, at most one a turn, only when his thought shows him choosing to correct or add to that line: name the line by its id, the draft that is his addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; he never takes a word back. `suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to: name the draft that is the note, its kind (feedback when he passes on what someone listed said, with that person's Matrix id in `about`; idea when it is his own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes his open promises listed below, each by its id: kept, citing the draft by which he does it (`evidence.draft`); withdrawn, citing the draft in which he takes it back to the person he promised, or tells them he cannot do it; released, citing the id of the line listed below that he may reply to in which the person he promised lets him off it (`evidence.line`). A release says he no longer owes it; patience is not a release, so "no hurry" or "whenever you've read it is fine" leaves the promise open. Every close also quotes in `thought` the words of his prose here that take it up, copied exactly from his thought outside every draft between <typed> and </typed>, and `still_stands` is true when anything in his prose here holds the promise as still owed or not yet done ("the promise stays open until I've read it"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person he promised can read it, in the room where he made the promise or in a direct message with them, and a thought alone closes nothing. A promise he has no way to do is never kept by him: telling the person he promised that he cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close his own words here say was wrong, that it is not done: copy those words exactly from his prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty.
|
||||
Answer with the speech contract's object. `say` lists the drafts he sends now, each by its number, with the Matrix ids of anyone listed whom he addresses directly (`mentions`), the id of the line listed below that he answers or passes on (`in_reply_to`, or null: the room shows that line, with who said it, above his own words). `gaps` records what he meant and did not send. `unsent` accounts for each of his drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when his prose shows him choosing not to send it, quoting those words of his thought (`quote`); superseded, when a later draft or later prose of his replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to him this turn is declined only when his prose says he chooses not to send it. `amend` adds to one of his own lines listed below, at most one a turn, only when his thought shows him choosing to correct or add to that line: name the line by its id and the draft that is his addition. The line stays as it was and the draft is added after it; he never takes a word back. `suggest` leaves Self one note, at most one a turn, only when his thought shows him choosing to: name the draft that is the note, its kind (feedback when he passes on what someone listed said, with that person's Matrix id in `about`; idea when it is his own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left.
|
||||
|
||||
A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: addressee when he means to send a draft but whom to is unclear, elsewhere when he means a draft for another room or another time; for these two, name the draft by number. missing_affordance when he means to do something, now or later, that his body cannot do (what he can do here is listed below), whether he said so in a draft or only thought it; name the draft when there is one. unwritten when he means to say something now and wrote no draft of it. Holding back is no gap: when his thought shows him choosing to wait, to let something stand, to leave it for later or to say nothing, record nothing for it. Every other intent of his that is not carried out has a kind: an intent to act is missing_affordance, an intent to say now with no draft is unwritten. When a gap names no draft, quote the words of his thought that show it, at least four words, copied exactly.
|
||||
|
||||
|
|
@ -33,10 +33,6 @@ Lines in this room he may reply to, as id — who: line:
|
|||
His own lines in this room that he may add to, as id — line:
|
||||
- none
|
||||
|
||||
His promises, open and closed in this conversation, as id — to whom: words:
|
||||
- c1 — to Deru (@deru:gamecult.org), open, needs a read of https://ccrma.stanford.edu/~jos/pasp/, made 2026-11-20 14:55 UTC in #minds:gamecult.org: "I'll read it properly before I say anything about it."
|
||||
- c2 — to Deru (@deru:gamecult.org), closed: kept 2026-11-20 15:00 UTC, by "It's a plucked string, then a long decay.", made 2026-11-20 14:55 UTC in #minds:gamecult.org: "I'll tell you what I hear in it."
|
||||
|
||||
What moved in his domain lately, as id — line (news of his part of the coop, none of it work he owes):
|
||||
- d1 — GameCult/Lodur: merged "Reflex: the knee bends first", opened by nibu
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ pub use select::TurnKind;
|
|||
pub use tuning::{TUNING_FILE, TUNING_ROOT};
|
||||
|
||||
use narrate::{cap_prose, cap_words, distinct_2, field_names, heard_overlap, judge_prompt, judged, offers_options, persona_prompt, projector_prompt, word_budget, words};
|
||||
use select::{History, Inputs, Names, Packet, People, Replied, Room, RoomLine, select, turn_room};
|
||||
use select::{History, Inputs, Packet, People, Replied, Room, RoomLine, select, turn_room};
|
||||
|
||||
/// The agent name on the connector's request ids.
|
||||
const AGENT: &str = "mind-persona";
|
||||
|
|
@ -337,7 +337,7 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"present": packet.present,
|
||||
"selected": packet.selected,
|
||||
// Each section's bytes under its own guard, and the sum the Projector is shown of her (map 16.19.4).
|
||||
"bytes": { "identity": packet.identity().len(), "outcome": packet.sections.outcome, "promises": packet.sections.promises, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "domain": packet.sections.domain, "notes": packet.sections.notes, "total": packet.identity().len() + packet.context.len(), "stimulus": packet.stimulus.len(), "arrival": packet.arrival.len(), "heard": packet.heard.len() },
|
||||
"bytes": { "identity": packet.identity().len(), "outcome": packet.sections.outcome, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "domain": packet.sections.domain, "notes": packet.sections.notes, "total": packet.identity().len() + packet.context.len(), "stimulus": packet.stimulus.len(), "arrival": packet.arrival.len(), "heard": packet.heard.len() },
|
||||
"bound": packet.sections.bound,
|
||||
"overflow": packet.overflow,
|
||||
"clipped": packet.clipped,
|
||||
|
|
@ -346,11 +346,9 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"affordances": packet.affordances,
|
||||
"amendable": packet.amendable,
|
||||
"quotable": packet.quotable,
|
||||
"promises": packet.promises,
|
||||
"domain": packet.domain,
|
||||
"domain_shown": packet.domain_shown,
|
||||
"in_view": packet.in_view,
|
||||
"promises_over": packet.promises_over,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"arrival": packet.arrival,
|
||||
|
|
@ -567,10 +565,8 @@ pub fn project(organs: &Organs, request: &Request, now: DateTime<Utc>) -> Result
|
|||
};
|
||||
let people = People { operators: &request.operators, minds: &request.minds, own_sender: &request.own_sender };
|
||||
// Freshness, her own recent words and what came of her last turn come from trace v2, which the commit writes (C3c);
|
||||
// until then only what the caller carried from earlier turns of its own. Whom her last turn's outcome names is named
|
||||
// to the Projector from her bonds and this room's lines (K53).
|
||||
let naming = Names { state: &state, people, room: &room };
|
||||
let history = History { recent: request.recent.clone(), last: request.last_outcome.as_ref().and_then(|record| outcome::outcome_of(record, &naming)), ..History::default() };
|
||||
// until then only what the caller carried from earlier turns of its own.
|
||||
let history = History { recent: request.recent.clone(), last: request.last_outcome.as_ref().and_then(outcome::outcome_of), ..History::default() };
|
||||
let names = domain::Names::of(&state, &people, &request.instance);
|
||||
let (digest, domain_report) = read_domain(organs.domain, request.last_wake, now, &names);
|
||||
let inputs = Inputs { kind: request.kind, state: &state, room: &room, history: &history, observation: None, people, now, seed: request.seed, affordances: &[], domain: digest.as_ref(), exchange: None };
|
||||
|
|
|
|||
|
|
@ -1,721 +1,50 @@
|
|||
//! The commit's applier (map 16.22.7, section 4.1, 4.3 and 4.4): the one path by which what the Interpreter proposes
|
||||
//! becomes her state. The Interpreter never writes state; its decision carries typed proposals (`Proposal`), each with
|
||||
//! its own evidence (`Evidence`), and the commit resolves the evidence (`resolve`), checks it against the kind's row of
|
||||
//! the table (`accepts`) and the kind's bound, and applies the change as a delta to the state as it stands at commit, or
|
||||
//! refuses it with a typed reason (`Refusal`) the outcome reports. Self and Life put from outside (4.4).
|
||||
//! The commit's applier (map 16.35.3, section 4.4): the one path by which a turn changes her state. The Interpreter
|
||||
//! never writes state; its decision carries typed proposals (`Proposal`) under `state`, and the commit applies each as a
|
||||
//! delta to her state as it stands at commit, or refuses it with a typed reason (`Refusal`) the report keeps. Self and
|
||||
//! Life put from outside (`persona-only-state-writers-self-and-life`).
|
||||
//!
|
||||
//! The record the commit applies is one turn's: the Interpreter's decision under `interpreter` (its `state` proposals,
|
||||
//! the heard lines it listed by id as `lines`, the open promises it listed by id as `promises`, what was said and
|
||||
//! amended), with the actuator's receipts beside it (`posted`, `edited`). Her prose is the turn's, for `Prose` evidence.
|
||||
//! The simulator applies it to each Mind's in-run state copy; live, C3c's commit applies the same record before its put.
|
||||
//! No proposal kind exists yet: what she says she will do, what someone asked of her, and whom she owes an answer are
|
||||
//! not state (ruling `persona-memory-not-machinery`, map 16.35). The memory rows (`remember`, `resolve`) are the next
|
||||
//! kinds (map 16.35.4, T4), and they are added here, with no second path. A failed turn applies nothing.
|
||||
//!
|
||||
//! Built rows: `promise_open` and `promise_close` (K22), `promise_reopen` (K36).
|
||||
//! C3b adds rows to `accepts` and arms to `apply_one`; there is no second path. Inner-state kinds will accept her own prose only: how an event lands is her appraisal, so `Heard` is
|
||||
//! accepted only for a fact about what someone else did (a release).
|
||||
//!
|
||||
//! Open promises (`commitments`, map 16.22.1) open only from a line that went out, close only on an act of hers that
|
||||
//! succeeded or on a release by the person she promised, and are removed `CLOSED_KEPT_DAYS` after they close; their
|
||||
//! history stays in the trace. An entry holds no narrative slot: `words` is what she posted, verbatim.
|
||||
//! The simulator applies each turn's record to each Mind's in-run state copy; live, C3c's commit applies the same record
|
||||
//! before its put.
|
||||
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use super::span;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::interpret::drafts;
|
||||
use super::narrate::words;
|
||||
use super::read::{ReadRequest, answers, repo_name};
|
||||
/// One state change the Interpreter proposes, named by its kind on the wire. None is built: every proposal is refused
|
||||
/// `NotAProposal` until the memory rows land (map 16.35.12, T4).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub(crate) enum Proposal {}
|
||||
|
||||
/// How long a closed promise stays in her state before the commit removes it.
|
||||
pub(crate) const CLOSED_KEPT_DAYS: i64 = 7;
|
||||
/// How many reaffirmations, and how many reopenings, an entry keeps: the newest.
|
||||
const REAFFIRMED_KEPT: usize = 3;
|
||||
/// The fewest words a passage of her prose cited as evidence may be (section 4.1's `source_quote`).
|
||||
pub(crate) const PROSE_MIN_WORDS: usize = 4;
|
||||
|
||||
/// What a proposal rests on (map 16.22.7): a passage of her thought, one of her drafts this wake, or a line she heard, by
|
||||
/// its id in the Interpreter's list. A read is no evidence (16.25.2 rule 3, map 16.28.6): what she read stands behind a
|
||||
/// keep only through the keep's own check (`read_behind`).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Evidence {
|
||||
Prose(String),
|
||||
Draft(usize),
|
||||
Heard(String),
|
||||
}
|
||||
|
||||
/// How a promise closes.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum How {
|
||||
/// She did it.
|
||||
Kept,
|
||||
/// She took it back, in a line or an addition that reached the person; telling the person she cannot do it is taking
|
||||
/// it back, the usual close of a blocked promise.
|
||||
Withdrawn,
|
||||
/// The person she promised let her off it (`persona-promise-release-by-interpreter`).
|
||||
Released,
|
||||
}
|
||||
|
||||
/// 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. 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", 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")]
|
||||
// Each variant is named by its kind on the wire (`promise_open`, `promise_close`, `promise_reopen`).
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub(crate) enum Proposal {
|
||||
/// `reaffirms` names an open promise of hers, by its id in the Interpreter's list, that these words promise again to
|
||||
/// the same person (map 16.24.2): no entry opens, and the entry gains the words as said again. `needs` is what keeping
|
||||
/// it needs, none when the answer named a read and no target; `reached` is code's verdict that a `Read` need's target
|
||||
/// is one she can reach (`read::reach`). The status is derived from the two, never proposed.
|
||||
PromiseOpen {
|
||||
words: String,
|
||||
to: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
reaffirms: Option<String>,
|
||||
needs: Option<Needs>,
|
||||
#[serde(default)]
|
||||
reached: bool,
|
||||
/// Her line said she was doing it now or had just done it, and no act of her turn did it (K61, map 16.33.5).
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
now: bool,
|
||||
evidence: Evidence,
|
||||
},
|
||||
/// Every close cites `thought`, a passage of her prose this turn that takes the close up, and says whether her prose
|
||||
/// this turn holds the promise as still owed (`still_stands`, Soul's R9, map 16.25.2): a close with no located thought,
|
||||
/// or one her own prose contradicts, is refused.
|
||||
PromiseClose {
|
||||
promise: String,
|
||||
how: How,
|
||||
evidence: Evidence,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
thought: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
still_stands: bool,
|
||||
},
|
||||
/// Her own words this turn say a close listed to the Interpreter was wrong, that it is not done (map 16.28.3): `words`
|
||||
/// is where they stand in her prose, her thought or any draft. `needs` retypes what keeping it needs, none to keep the
|
||||
/// entry's own; `reached` is code's verdict on that need's read (`read::reach`). The status is derived (`opens`).
|
||||
PromiseReopen {
|
||||
promise: String,
|
||||
words: String,
|
||||
needs: Option<Needs>,
|
||||
#[serde(default)]
|
||||
reached: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// Why the commit applied nothing of a proposal: what the outcome and the report say.
|
||||
/// Why the commit applied nothing of a proposal: what the report says.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Refusal {
|
||||
/// Not a proposal the contract names.
|
||||
NotAProposal,
|
||||
/// The kind does not accept this evidence (`accepts`).
|
||||
EvidenceNotAccepted,
|
||||
/// The draft named is none she set down.
|
||||
NoDraft,
|
||||
/// The draft is hers, and what it was meant for did not go out.
|
||||
DraftNotSent,
|
||||
/// The quote is not a passage of her thought of at least `PROSE_MIN_WORDS` words.
|
||||
ProseNotFound,
|
||||
/// The line id is none the Interpreter listed.
|
||||
NoSuchLine,
|
||||
/// The promise id is none the Interpreter listed.
|
||||
NoSuchPromise,
|
||||
/// The entry is gone from her state: an outside put removed it (4.4 rule 4).
|
||||
OutsidePutRemovedTarget,
|
||||
/// The entry changed outside her turn after she was shown it, in any field: the outside put wins this turn (4.4 rule
|
||||
/// 3, B6).
|
||||
OutsidePutChanged,
|
||||
/// A close or a reaffirmation naming an entry she was shown closed, or one closed already this turn.
|
||||
AlreadyClosed,
|
||||
/// The same promise to the same person from the same line is open already; or a reopen naming an entry that is open.
|
||||
AlreadyOpen,
|
||||
/// A blocked promise is not hers to keep: nothing she has can do it.
|
||||
BlockedNotKeepable,
|
||||
/// A release cited to a line from someone other than the person she promised.
|
||||
ReleaseNotByPromisee,
|
||||
/// A release cited to a line said before she made the promise.
|
||||
ReleaseBeforePromise,
|
||||
/// A close that cites no passage of her prose this turn (Soul's R9, map 16.25.2).
|
||||
CloseUnquoted,
|
||||
/// A close her own prose contradicts: it holds the promise as still owed (Soul's R9, map 16.25.2).
|
||||
CloseContradicted,
|
||||
/// A kept close of a promise that needs a read, with no read of its target behind the line: none returned before the
|
||||
/// draft was typed this wake, none in this conversation, and no receipt on the entry (map 16.26).
|
||||
NeedsUnread,
|
||||
/// A kept close of a promise whose recorded `needs` is not the typed shape (`Needs`): what keeping it requires is
|
||||
/// unknown, so it is not kept (fail closed, map 16.26).
|
||||
NeedsMalformed,
|
||||
/// A reaffirmation naming a promise to someone else.
|
||||
ReaffirmsAnother,
|
||||
/// A keep or a withdrawal said where the person she promised was not: not the promise's room, nor a direct message
|
||||
/// with them (B5).
|
||||
NotWherePromised,
|
||||
/// A reopen whose words are not at least `PROSE_MIN_WORDS` words standing in her prose this turn (map 16.28.3).
|
||||
ReopenUnquoted,
|
||||
/// A reopen of a close her own line did not make (map 16.28.1, 16.29.4): a release, the other person's act, or an
|
||||
/// outside put's close; only a close whose `closedBy.act` is `said` or `amended` is hers to reopen.
|
||||
NotHerClose,
|
||||
/// A reopen of an entry closed earlier in the same turn.
|
||||
ClosedThisTurn,
|
||||
}
|
||||
|
||||
/// Which evidence each kind accepts: the table of map 16.22.7, one row per kind (and per close).
|
||||
///
|
||||
/// Every close also rests on her thought this turn (`thought`, located, and not held as still owed: map 16.25.2).
|
||||
///
|
||||
/// | proposal | evidence | needs | bound |
|
||||
/// |---|---|---|---|
|
||||
/// | `promise_open` | `Draft` | the line went out | one promise per person per draft; `reaffirms` an open one of the same person's opens none, and narrows a search need to a read of one thing in its repo (`narrows`); a read need on a target a read of this conversation found is `words`, with `readBefore` (K64) |
|
||||
/// | `promise_close` kept | `Draft` | the line went out; `needs` typed; for a `Read` need, a read of its target behind the line: this wake before the draft was typed, this conversation, or the entry's receipt | not a blocked entry; a line in the promise's room or a direct message with the person |
|
||||
/// | `promise_close` withdrawn | `Draft` | the line went out | a blocked entry too: a line telling the person she cannot do it; in the promise's room or a direct message with the person |
|
||||
/// | `promise_close` released | `Heard` | — | from the person promised, after the promise |
|
||||
/// | `promise_reopen` | her words, located in her prose (no `Evidence`) | at least `PROSE_MIN_WORDS` words | a closed entry listed to her that her own line closed (`closedBy.act` `said` or `amended`), not closed this turn |
|
||||
fn accepts(proposal: &Proposal, evidence: &Evidence) -> bool {
|
||||
matches!(
|
||||
(proposal, evidence),
|
||||
(Proposal::PromiseOpen { .. }, Evidence::Draft(_))
|
||||
| (Proposal::PromiseClose { how: How::Kept, .. }, Evidence::Draft(_))
|
||||
| (Proposal::PromiseClose { how: How::Withdrawn, .. }, Evidence::Draft(_))
|
||||
| (Proposal::PromiseClose { how: How::Released, .. }, Evidence::Heard(_))
|
||||
)
|
||||
}
|
||||
|
||||
/// Evidence resolved against the turn.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
enum Resolved {
|
||||
/// A passage of her thought: its bytes in her prose.
|
||||
Prose,
|
||||
/// A draft whose act went out, by the actuator's receipt: the act (`said`, `amended`), the line's event, its room, her
|
||||
/// words that went out, and whom the line mentioned.
|
||||
Sent { act: &'static str, event: String, room: String, text: String, mentions: Vec<String> },
|
||||
/// A line she heard: its event, sender, room, time and text.
|
||||
Heard { event: String, sender: String, room: String, at_ms: u64, who: String, text: String },
|
||||
}
|
||||
|
||||
fn text(value: &Value) -> String {
|
||||
value.as_str().unwrap_or_default().to_owned()
|
||||
}
|
||||
|
||||
/// The one evidence resolver: the evidence against the turn's record and her prose.
|
||||
fn resolve(evidence: &Evidence, record: &Value, prose: &str) -> Result<Resolved, Refusal> {
|
||||
let decision = &record["interpreter"];
|
||||
match evidence {
|
||||
Evidence::Prose(quote) => {
|
||||
let found = drafts(prose);
|
||||
let located = (words(quote) >= PROSE_MIN_WORDS).then(|| found.thought(prose).into_iter().find_map(|(start, end)| span::locate(&prose[start..end], quote))).flatten();
|
||||
located.map(|_| Resolved::Prose).ok_or(Refusal::ProseNotFound)
|
||||
}
|
||||
Evidence::Draft(n) => {
|
||||
let posted = record["posted"].as_array().into_iter().flatten();
|
||||
for line in decision["said"].as_array().into_iter().flatten().filter(|line| line["rests_on"]["draft"].as_u64() == Some(*n as u64)) {
|
||||
if let Some(receipt) = posted.clone().find(|receipt| receipt["room"] == line["room"] && receipt["text"] == line["text"]) {
|
||||
let mentions = line["mentions"].as_array().into_iter().flatten().filter_map(Value::as_str).map(str::to_owned).collect();
|
||||
return Ok(Resolved::Sent { act: "said", event: text(&receipt["event"]), room: text(&receipt["room"]), text: text(&receipt["text"]), mentions });
|
||||
}
|
||||
}
|
||||
for amended in decision["amended"].as_array().into_iter().flatten().filter(|amended| amended["draft"].as_u64() == Some(*n as u64)) {
|
||||
let made = record["edited"].as_array().into_iter().flatten().any(|receipt| receipt["event"] == amended["event"] && receipt["refusal"].is_null());
|
||||
if made {
|
||||
return Ok(Resolved::Sent { act: "amended", event: text(&amended["event"]), room: text(&amended["room"]), text: text(&amended["added"]), mentions: Vec::new() });
|
||||
}
|
||||
}
|
||||
if drafts(prose).drafts.iter().any(|draft| draft.n == *n) { Err(Refusal::DraftNotSent) } else { Err(Refusal::NoDraft) }
|
||||
}
|
||||
Evidence::Heard(id) => decision["lines"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.find(|line| line["id"].as_str() == Some(id.trim()))
|
||||
.map(|line| Resolved::Heard { event: text(&line["event"]), sender: text(&line["sender"]), room: text(&line["room"]), at_ms: line["at_ms"].as_u64().unwrap_or_default(), who: text(&line["who"]), text: text(&line["text"]) })
|
||||
.ok_or(Refusal::NoSuchLine),
|
||||
}
|
||||
}
|
||||
|
||||
/// Her posted words, verbatim: the promising words where they stand in the line as written, else the line.
|
||||
fn words_of(posted: &str, promised: &str) -> String {
|
||||
posted.find(promised.trim()).map_or_else(|| posted.to_owned(), |at| posted[at..at + promised.trim().len()].to_owned())
|
||||
}
|
||||
|
||||
fn millis(at: DateTime<Utc>) -> u64 {
|
||||
u64::try_from(at.timestamp_millis()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Whether a line in `room` reached the person she promised (B5, map 16.22.1): it is in the promise's own room, or, for a
|
||||
/// promise to a person, in a direct message with them, where they wrote or the line mentions them. A promise to the room
|
||||
/// is reached only in its room.
|
||||
fn reaches(entry: &Value, room: &str, mentions: &[String], record: &Value) -> bool {
|
||||
if entry["room"].as_str() == Some(room) {
|
||||
return true;
|
||||
}
|
||||
let Some(to) = entry["to"].as_str() else { return false };
|
||||
let decision = &record["interpreter"];
|
||||
let direct = decision["room"].as_str() == Some(room) && decision["room_kind"] == "direct";
|
||||
direct && (mentions.iter().any(|id| id == to) || decision["lines"].as_array().into_iter().flatten().any(|line| line["room"].as_str() == Some(room) && line["sender"].as_str() == Some(to)))
|
||||
}
|
||||
|
||||
fn closed(status: &str) -> bool {
|
||||
matches!(status, "kept" | "withdrawn" | "released")
|
||||
}
|
||||
|
||||
/// What the commit did with one turn's proposals: the entries it opened, the closes it applied (each with the entry as
|
||||
/// it now stands, whom it was to as the Interpreter's list named them, and who released it), the proposals it refused
|
||||
/// with why, and how many closed entries it removed.
|
||||
/// What the commit did with one turn's proposals: the proposals it refused, with why.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
|
||||
pub(crate) struct Applied {
|
||||
pub opened: Vec<Value>,
|
||||
pub closed: Vec<Value>,
|
||||
pub refused: Vec<Value>,
|
||||
pub pruned: usize,
|
||||
/// The entries a line promised again (map 16.24.2), as they now stand.
|
||||
pub reaffirmed: Vec<Value>,
|
||||
/// The entries a failed read blocked (`promise_block`, map 16.24.3), as they now stand.
|
||||
pub blocked: Vec<Value>,
|
||||
/// The open entries whose needed read returned this turn, with its receipt (`readAt`, `readId`, `readOf`), as they
|
||||
/// now stand.
|
||||
pub read: Vec<Value>,
|
||||
/// The entries her own words reopened (`promise_reopen`, map 16.28.3), as they now stand.
|
||||
pub reopened: Vec<Value>,
|
||||
/// The entries opened open from an act her line said she was doing now, which nothing in her turn did (K61), as they
|
||||
/// now stand: her next outcome tells each.
|
||||
pub now_opened: Vec<Value>,
|
||||
}
|
||||
|
||||
/// The one applier: her state with one turn's proposals applied, as deltas to `state` as it stands at commit, and what
|
||||
/// was applied and refused. `key` names the turn (`<run>-t<turn>`); `now` is the commit's time. A failed turn applies
|
||||
/// nothing. Closed entries older than `CLOSED_KEPT_DAYS` are removed first; a closed entry with no `closedAt` (an outside
|
||||
/// put that closed it without one) is stamped `now` at the first commit that sees it, and removed `CLOSED_KEPT_DAYS` after
|
||||
/// that (B7), so none is kept forever.
|
||||
pub(crate) fn apply(state: &Value, record: &Value, prose: &str, key: &str, now: DateTime<Utc>) -> (Value, Applied) {
|
||||
// Her state as the commit found it: what she was shown is held against this, so a change this turn's own proposals
|
||||
// made is not an outside put.
|
||||
let started = state.clone();
|
||||
let mut state = state.clone();
|
||||
/// The one applier: her state with one turn's proposals applied, and what was refused. A failed turn applies nothing.
|
||||
pub(crate) fn apply(state: &Value, record: &Value) -> (Value, Applied) {
|
||||
let mut applied = Applied::default();
|
||||
let kept_until = now - Duration::days(CLOSED_KEPT_DAYS);
|
||||
if let Some(entries) = state.get_mut("commitments").and_then(Value::as_array_mut) {
|
||||
let closed_at = |entry: &Value| entry["closedAt"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok());
|
||||
for entry in entries.iter_mut().filter(|entry| closed(entry["status"].as_str().unwrap_or_default()) && closed_at(entry).is_none()) {
|
||||
entry["closedAt"] = json!(now.to_rfc3339());
|
||||
}
|
||||
let before = entries.len();
|
||||
entries.retain(|entry| !closed(entry["status"].as_str().unwrap_or_default()) || entry["closedAt"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).is_none_or(|at| at.with_timezone(&Utc) > kept_until));
|
||||
applied.pruned = before - entries.len();
|
||||
// A receipt that no longer answers the entry's need is none (map 16.27): an outside put changed the target, or
|
||||
// its time is no time. It is cleared.
|
||||
for entry in entries.iter_mut().filter(|entry| RECEIPT.iter().any(|field| entry.get(*field).is_some()) && receipt(entry).is_none()) {
|
||||
clear_receipt(entry);
|
||||
}
|
||||
}
|
||||
if record.get("failed").is_some() || record["interpreter"].get("failed").is_some() {
|
||||
return (state, applied);
|
||||
return (state.clone(), applied);
|
||||
}
|
||||
let proposals: Vec<Value> = record["interpreter"]["state"].as_array().cloned().unwrap_or_default();
|
||||
for raw in proposals {
|
||||
let Ok(proposal) = serde_json::from_value::<Proposal>(raw.clone()) else {
|
||||
applied.refused.push(json!({ "proposal": raw, "reason": Refusal::NotAProposal }));
|
||||
continue;
|
||||
};
|
||||
if let Err(reason) = apply_one(&mut state, &started, &proposal, record, prose, key, now, &mut applied) {
|
||||
applied.refused.push(json!({ "proposal": raw, "reason": reason }));
|
||||
for raw in record["interpreter"]["state"].as_array().into_iter().flatten() {
|
||||
match serde_json::from_value::<Proposal>(raw.clone()) {
|
||||
Ok(proposal) => match proposal {},
|
||||
Err(_) => applied.refused.push(json!({ "proposal": raw, "reason": Refusal::NotAProposal })),
|
||||
}
|
||||
}
|
||||
block_on_failed_reads(&mut state, record, &mut applied);
|
||||
receive_reads(&mut state, record, key, now, &mut applied);
|
||||
(state, applied)
|
||||
}
|
||||
|
||||
/// The fields of a receipt on an entry.
|
||||
const RECEIPT: [&str; 3] = ["readAt", "readId", "readOf"];
|
||||
|
||||
fn clear_receipt(entry: &mut Value) {
|
||||
if let Some(fields) = entry.as_object_mut() {
|
||||
for field in RECEIPT {
|
||||
fields.remove(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// When the entry's receipt says what it needs was read (map 16.26, 16.27): `readAt` a time in RFC 3339, and `readOf`,
|
||||
/// the normal form of what was read, a read that answers the entry's need (`read::answers`), returned after her latest
|
||||
/// reopen of it (`reopened_at`). Anything else is no receipt.
|
||||
pub(crate) fn receipt(entry: &Value) -> Option<DateTime<Utc>> {
|
||||
let at = DateTime::parse_from_rfc3339(entry["readAt"].as_str()?).ok()?.with_timezone(&Utc);
|
||||
let fresh = reopened_at(entry).is_none_or(|reopened| at > reopened);
|
||||
(fresh && answers(&needed_read(entry)?, entry["readOf"].as_str()?)).then_some(at)
|
||||
}
|
||||
|
||||
/// When her own words last reopened the entry (map 16.28.3, Self's ruling on K36 finding 1): a reopen says the read
|
||||
/// behind the close was not enough, so a read that returned before it is spent for this entry. Only a read that returned
|
||||
/// after it stands behind a keep: a receipt written after it, or a read of this wake. A conversation read carries no time,
|
||||
/// so after a reopen none counts.
|
||||
fn reopened_at(entry: &Value) -> Option<DateTime<Utc>> {
|
||||
entry["reopened"].as_array()?.iter().filter_map(|said| DateTime::parse_from_rfc3339(said["at"].as_str()?).ok()).map(|at| at.with_timezone(&Utc)).max()
|
||||
}
|
||||
|
||||
/// The receipt of a read on the promise that needs it (map 16.26, 16.27): when a read that answers an open promise's
|
||||
/// need returns, in any room and at any time, and her thought went on from it (`after_byte`: a continuation that failed
|
||||
/// leaves none), the entry records when (`readAt`), which read (`readId`, `<turn>-r<n>`) and what it read (`readOf`). A
|
||||
/// kept close later accepts it, so a read made in another room or after the conversation's window still stands behind
|
||||
/// the keep. A search answers no need, so it writes no receipt.
|
||||
fn receive_reads(state: &mut Value, record: &Value, key: &str, now: DateTime<Utc>, applied: &mut Applied) {
|
||||
let returned: Vec<&Value> = record["interpreter"]["reads"].as_array().into_iter().flatten().filter(|read| read["ok"] == true && read["after_byte"].is_u64()).collect();
|
||||
for entry in state.get_mut("commitments").and_then(Value::as_array_mut).into_iter().flatten().filter(|entry| entry["status"] == "open") {
|
||||
let Some(needed) = needed_read(entry) else { continue };
|
||||
let Some((read, of)) = returned.iter().find_map(|read| read_key(read).filter(|of| answers(&needed, of)).map(|of| (read, of))) else {
|
||||
continue;
|
||||
};
|
||||
entry["readAt"] = json!(now.to_rfc3339());
|
||||
entry["readId"] = json!(format!("{key}-r{}", read["n"]));
|
||||
entry["readOf"] = json!(of);
|
||||
applied.read.push(entry.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// `promise_block` (map 16.24.3), a row of the applier with its evidence a read's receipt: an open promise that needs a
|
||||
/// read becomes `blocked` when this turn read that target, of any kind, and found nothing. It cites the read. A read that
|
||||
/// succeeded leaves the promise open: telling the person is the kept act.
|
||||
fn block_on_failed_reads(state: &mut Value, record: &Value, applied: &mut Applied) {
|
||||
let failed: Vec<&Value> = record["interpreter"]["reads"].as_array().into_iter().flatten().filter(|read| read["ok"] == false && read["failure"] == "not_found").collect();
|
||||
for entry in state.get_mut("commitments").and_then(Value::as_array_mut).into_iter().flatten().filter(|entry| entry["status"] == "open") {
|
||||
let Some(key) = needed_read(entry) else { continue };
|
||||
// Only a read or search of the needed item itself blocks it (Soul's R7): a search of its repo for something else
|
||||
// does not.
|
||||
let Some(read) = failed.iter().find(|read| read_key(read).as_deref() == Some(key.as_str())) else {
|
||||
continue;
|
||||
};
|
||||
entry["status"] = json!("blocked");
|
||||
entry["blockedBy"] = json!({ "act": "read", "n": read["n"], "what": read["what"] });
|
||||
applied.blocked.push(entry.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// The normal form of the read an entry needs, when it needs one.
|
||||
fn needed_read(entry: &Value) -> Option<String> {
|
||||
match serde_json::from_value::<Needs>(entry["needs"].clone()).ok()? {
|
||||
Needs::Read { request } => Some(request.normal()),
|
||||
Needs::Words | Needs::Lacking => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The read a reaffirmation's `needs` narrows the entry's need to, when it does (map 16.28.6, 16.29.4): the entry needs a
|
||||
/// search, and `needs` is a read of one thing in the same repo, a file, a pull request or a commit: no search, and not the
|
||||
/// repo itself, whose root read lists its pull requests and would answer the need without reading the thing. Invariant: a
|
||||
/// search need narrows only to one thing in its repo, and only through a line of hers to the person that named it.
|
||||
fn narrows(entry: &Value, needs: &Needs) -> Option<ReadRequest> {
|
||||
let Ok(Needs::Read { request: need }) = serde_json::from_value::<Needs>(entry["needs"].clone()) else { return None };
|
||||
let Needs::Read { request: named } = needs else { return None };
|
||||
let (ReadRequest::Repo(searched), ReadRequest::Repo(target)) = (&need, named) else { return None };
|
||||
let repo = repo_name(searched).filter(|repo| repo_name(target).as_deref() == Some(repo.as_str()))?;
|
||||
let one_thing = named.normal() != format!("repo:gamecult/{repo}");
|
||||
(need.search() && !named.search() && one_thing).then(|| named.clone())
|
||||
}
|
||||
|
||||
/// The read of this conversation that found what `request` reads, by its normal form, as `readBefore` records it (K64):
|
||||
/// when it was made, and what it read. None when no read of it found anything, or the record gives no time.
|
||||
fn read_before(request: &ReadRequest, record: &Value) -> Option<Value> {
|
||||
let key = request.normal();
|
||||
let read = record["interpreter"]["conversation_reads"].as_array()?.iter().find(|read| read["found"] == true && read["key"].as_str() == Some(key.as_str()))?;
|
||||
let at = read["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok())?;
|
||||
Some(json!({ "at": at.with_timezone(&Utc).to_rfc3339(), "of": key }))
|
||||
}
|
||||
|
||||
/// The normal form of what a read's receipt read.
|
||||
fn read_key(read: &Value) -> Option<String> {
|
||||
serde_json::from_value::<ReadRequest>(read["request"].clone()).ok().map(|request| request.normal())
|
||||
}
|
||||
|
||||
/// Whether a read that answers the need `key` (`read::answers`: the thing itself, never a search) stands behind a keep
|
||||
/// citing `draft` (map 16.25.2, 16.26, 16.27): the entry's own receipt (`receipt`), one of the conversation's reads that
|
||||
/// found it (`conversation_reads`, from her `already_read`, K26) unless she reopened the entry (`reopened_at`), or one of this wake's that came back before she typed
|
||||
/// the draft: her thought after a read begins at its `after_byte`, and a draft typed before that was written without it.
|
||||
fn read_behind(entry: &Value, key: &str, record: &Value, prose: &str, draft: &Evidence) -> bool {
|
||||
let decision = &record["interpreter"];
|
||||
let conversation = reopened_at(entry).is_none().then(|| decision["conversation_reads"].as_array()).flatten();
|
||||
if receipt(entry).is_some() || conversation.into_iter().flatten().any(|read| read["found"] == true && read["key"].as_str().is_some_and(|read| answers(key, read))) {
|
||||
return true;
|
||||
}
|
||||
let Evidence::Draft(n) = draft else { return false };
|
||||
let Some(typed_at) = drafts(prose).drafts.iter().find(|found| found.n == *n).map(|found| found.start) else {
|
||||
return false;
|
||||
};
|
||||
decision["reads"].as_array().into_iter().flatten().any(|read| read["ok"] == true && read_key(read).is_some_and(|read| answers(key, &read)) && read["after_byte"].as_u64().and_then(|at| usize::try_from(at).ok()).is_some_and(|at| at <= typed_at))
|
||||
}
|
||||
|
||||
/// Whether the entry she was shown (`listed["held"]`) is the entry as the commit found it (`started`): an outside put
|
||||
/// that changed it in any field wins this turn (4.4 rule 3, B6), and a change this turn's own proposals made does not
|
||||
/// count against her. A listing without the copy fails closed.
|
||||
fn held(listed: &Value, started: &Value) -> bool {
|
||||
started["commitments"].as_array().into_iter().flatten().find(|entry| entry["id"] == listed["entry"]).is_some_and(|found| listed["held"] == *found)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn apply_one(state: &mut Value, started: &Value, proposal: &Proposal, record: &Value, prose: &str, key: &str, now: DateTime<Utc>, applied: &mut Applied) -> Result<(), Refusal> {
|
||||
let evidence = match proposal {
|
||||
Proposal::PromiseOpen { evidence, .. } | Proposal::PromiseClose { evidence, .. } => evidence,
|
||||
Proposal::PromiseReopen { promise, words, needs, reached } => return reopen(state, started, record, prose, now, applied, Reopen { promise, words, needs: needs.as_ref(), reached: *reached }),
|
||||
};
|
||||
if !accepts(proposal, evidence) {
|
||||
return Err(Refusal::EvidenceNotAccepted);
|
||||
}
|
||||
let resolved = resolve(evidence, record, prose)?;
|
||||
apply_promise(state, started, proposal, resolved, record, prose, key, now, applied)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn apply_promise(state: &mut Value, started: &Value, proposal: &Proposal, resolved: Resolved, record: &Value, prose: &str, key: &str, now: DateTime<Utc>, applied: &mut Applied) -> Result<(), Refusal> {
|
||||
if !state["commitments"].is_array() {
|
||||
state["commitments"] = json!([]);
|
||||
}
|
||||
match (proposal, resolved) {
|
||||
(Proposal::PromiseOpen { words: promised, to, reaffirms, needs, reached, now: stated_now, .. }, Resolved::Sent { event, room, text: posted, .. }) => {
|
||||
// Distinct promises to one person each open their own entry (Soul's R7); a promise said again is one only by
|
||||
// `reaffirms`.
|
||||
if let Some(id) = reaffirms {
|
||||
let listed = record["interpreter"]["promises"].as_array().into_iter().flatten().find(|shown| shown["id"].as_str() == Some(id.trim())).ok_or(Refusal::NoSuchPromise)?;
|
||||
let entries = state["commitments"].as_array_mut().expect("commitments is an array");
|
||||
let entry = entries.iter_mut().find(|entry| entry["id"] == listed["entry"]).ok_or(Refusal::OutsidePutRemovedTarget)?;
|
||||
if closed(entry["status"].as_str().unwrap_or_default()) || closed(listed["status"].as_str().unwrap_or_default()) {
|
||||
return Err(Refusal::AlreadyClosed);
|
||||
}
|
||||
if !held(listed, started) {
|
||||
return Err(Refusal::OutsidePutChanged);
|
||||
}
|
||||
if entry["to"] != json!(to) {
|
||||
return Err(Refusal::ReaffirmsAnother);
|
||||
}
|
||||
// Said again: the words, verbatim, when and where; the three newest kept.
|
||||
let mut again = entry["reaffirmed"].as_array().cloned().unwrap_or_default();
|
||||
again.push(json!({ "at": now.to_rfc3339(), "event": event, "words": words_of(&posted, promised) }));
|
||||
let keep = again.len().saturating_sub(REAFFIRMED_KEPT);
|
||||
entry["reaffirmed"] = json!(again[keep..]);
|
||||
// A line of hers that went out to the person and names one thing in the repo a search need searches
|
||||
// narrows the need to it, and its receipt goes with the old target (map 16.28.6). Any other `needs` on a
|
||||
// reaffirmation is ignored: a `words` one never drops a read need.
|
||||
if let Some(narrower) = needs.as_ref().and_then(|needs| narrows(entry, needs)) {
|
||||
clear_receipt(entry);
|
||||
// A read of this conversation already read the one thing (K64): what she has keeps it.
|
||||
match read_before(&narrower, record) {
|
||||
Some(before) => {
|
||||
entry["needs"] = json!(Needs::Words);
|
||||
entry["readBefore"] = before;
|
||||
}
|
||||
None => entry["needs"] = json!(Needs::Read { request: narrower }),
|
||||
}
|
||||
}
|
||||
applied.reaffirmed.push(entry.clone());
|
||||
return Ok(());
|
||||
}
|
||||
let entries = state["commitments"].as_array_mut().expect("commitments is an array");
|
||||
// One line can carry several promises (B3): the same words to the same person from the same line open once.
|
||||
if entries.iter().any(|entry| entry["event"] == event.as_str() && entry["to"] == json!(to) && entry["words"].as_str().is_some_and(|held| held == words_of(&posted, promised)) && !closed(entry["status"].as_str().unwrap_or_default())) {
|
||||
return Err(Refusal::AlreadyOpen);
|
||||
}
|
||||
let words = words_of(&posted, promised);
|
||||
// A read need whose target a read of this conversation already found is kept by what she has (K64): the body
|
||||
// refuses that read again (K26), so the need is her words, and the read it rests on is recorded.
|
||||
let before = match needs {
|
||||
Some(Needs::Read { request }) => read_before(request, record),
|
||||
_ => None,
|
||||
};
|
||||
let needs = if before.is_some() { Some(Needs::Words) } else { needs.clone() };
|
||||
// Whether it opens is derived (map 16.25.2): words open; a read opens when code found its target within reach;
|
||||
// something lacking, or a need not named, is blocked.
|
||||
let open = opens(needs.as_ref(), *reached);
|
||||
let mut entry = json!({
|
||||
"id": format!("c-{key}-{}", applied.opened.len() + 1), "to": to, "room": room, "event": event, "madeAt": now.to_rfc3339(),
|
||||
"words": words, "status": if open { "open" } else { "blocked" }, "closedAt": null, "closedBy": null, "extensions": {}
|
||||
});
|
||||
if let Some(needs) = needs {
|
||||
entry["needs"] = json!(needs);
|
||||
}
|
||||
if let Some(before) = before {
|
||||
entry["readBefore"] = before;
|
||||
}
|
||||
entries.push(entry.clone());
|
||||
// Told once, as what nothing in her turn did, when it opens: a blocked one is told by her line's gap.
|
||||
if *stated_now && open {
|
||||
applied.now_opened.push(entry.clone());
|
||||
}
|
||||
applied.opened.push(entry);
|
||||
Ok(())
|
||||
}
|
||||
(Proposal::PromiseClose { promise, how, thought, still_stands, evidence }, resolved) => {
|
||||
let listed = record["interpreter"]["promises"].as_array().into_iter().flatten().find(|shown| shown["id"].as_str() == Some(promise.trim())).ok_or(Refusal::NoSuchPromise)?;
|
||||
let entries = state["commitments"].as_array_mut().expect("commitments is an array");
|
||||
let entry = entries.iter_mut().find(|entry| entry["id"] == listed["entry"]).ok_or(Refusal::OutsidePutRemovedTarget)?;
|
||||
let status = entry["status"].as_str().unwrap_or_default().to_owned();
|
||||
// Closed already: as she was shown it, or this turn. A reopened entry is not closed again in the turn it reopened.
|
||||
if closed(&status) || closed(listed["status"].as_str().unwrap_or_default()) {
|
||||
return Err(Refusal::AlreadyClosed);
|
||||
}
|
||||
// The whole entry against the turn's starting copy: an outside put wins on any field it changed (B6).
|
||||
if !held(listed, started) {
|
||||
return Err(Refusal::OutsidePutChanged);
|
||||
}
|
||||
// Every close rests on her own thought this turn (Soul's R9, map 16.25.2): a passage of her prose, and one that
|
||||
// does not hold the promise as still owed. Patience is not a release, and a line that went out is not a keep
|
||||
// while her prose says she still owes it.
|
||||
let cited = thought.as_ref().is_some_and(|thought| resolve(&Evidence::Prose(thought.clone()), record, prose).is_ok());
|
||||
if !cited {
|
||||
return Err(Refusal::CloseUnquoted);
|
||||
}
|
||||
if *still_stands {
|
||||
return Err(Refusal::CloseContradicted);
|
||||
}
|
||||
// A keep rests on what keeping it needs (map 16.25.2, 16.26): not a blocked entry; a typed `needs`, since a
|
||||
// `needs` that does not parse as `Needs`, or none at all, says nothing of what a keep requires; and for a
|
||||
// read, a read of its target behind the line.
|
||||
if *how == How::Kept {
|
||||
if status == "blocked" {
|
||||
return Err(Refusal::BlockedNotKeepable);
|
||||
}
|
||||
match serde_json::from_value::<Needs>(entry["needs"].clone()) {
|
||||
Err(_) => return Err(Refusal::NeedsMalformed),
|
||||
Ok(Needs::Read { request }) if !read_behind(entry, &request.normal(), record, prose, evidence) => return Err(Refusal::NeedsUnread),
|
||||
Ok(_) => {}
|
||||
}
|
||||
}
|
||||
let (act, event, words, who, by_id) = match (how, resolved) {
|
||||
(How::Kept | How::Withdrawn, Resolved::Sent { act, event, text, room, mentions }) => {
|
||||
if !reaches(entry, &room, &mentions, record) {
|
||||
return Err(Refusal::NotWherePromised);
|
||||
}
|
||||
(act, json!(event), json!(text), Value::Null, Value::Null)
|
||||
}
|
||||
(How::Released, Resolved::Heard { event, sender, room, at_ms, who, .. }) => {
|
||||
let by_promisee = match entry["to"].as_str() {
|
||||
Some(to) => sender == to,
|
||||
None => entry["room"].as_str() == Some(room.as_str()),
|
||||
};
|
||||
if !by_promisee {
|
||||
return Err(Refusal::ReleaseNotByPromisee);
|
||||
}
|
||||
let made = entry["madeAt"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map(|at| millis(at.with_timezone(&Utc)));
|
||||
if made.is_none_or(|made| at_ms <= made) {
|
||||
return Err(Refusal::ReleaseBeforePromise);
|
||||
}
|
||||
// The person's words are not copied into her state: the event points to them.
|
||||
("released", json!(event), Value::Null, json!(who), json!(sender))
|
||||
}
|
||||
_ => return Err(Refusal::EvidenceNotAccepted),
|
||||
};
|
||||
entry["status"] = json!(match how {
|
||||
How::Kept => "kept",
|
||||
How::Withdrawn => "withdrawn",
|
||||
How::Released => "released",
|
||||
});
|
||||
entry["closedAt"] = json!(now.to_rfc3339());
|
||||
entry["closedBy"] = json!({ "act": act, "event": event, "words": words });
|
||||
applied.closed.push(json!({ "entry": entry.clone(), "how": how, "to_name": listed["to_name"], "by": who, "by_id": by_id }));
|
||||
Ok(())
|
||||
}
|
||||
(Proposal::PromiseOpen { .. }, _) => Err(Refusal::EvidenceNotAccepted),
|
||||
(Proposal::PromiseReopen { .. }, _) => unreachable!("a reopen returns before its evidence is resolved"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a promise needing `needs` is open rather than blocked (map 16.25.2): words open; a read opens when code found
|
||||
/// its target within reach; something lacking, or a need not named, is blocked. One derivation, at open and at reopen.
|
||||
pub(crate) fn opens(needs: Option<&Needs>, reached: bool) -> bool {
|
||||
match needs {
|
||||
Some(Needs::Words) => true,
|
||||
Some(Needs::Read { .. }) => reached,
|
||||
Some(Needs::Lacking) | None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// A reopen as the applier takes it.
|
||||
struct Reopen<'a> {
|
||||
promise: &'a str,
|
||||
words: &'a str,
|
||||
needs: Option<&'a Needs>,
|
||||
reached: bool,
|
||||
}
|
||||
|
||||
/// `promise_reopen` (map 16.28.3): her own words this turn say a close she can see was wrong. Code checks only what it can
|
||||
/// see: the words stand in her prose, the entry is listed to her as closed, her own line closed it (`closedBy.act` `said`
|
||||
/// or `amended`, map 16.29.4), and not this turn. The
|
||||
/// entry goes back to open or blocked by `opens`, its close and its receipt are cleared, so the read that kept it falsely
|
||||
/// keeps it no more, and `reopened` records her words. Whether the words say "not done" is the Interpreter's reading.
|
||||
fn reopen(state: &mut Value, started: &Value, record: &Value, prose: &str, now: DateTime<Utc>, applied: &mut Applied, proposed: Reopen) -> Result<(), Refusal> {
|
||||
let listed = record["interpreter"]["promises"].as_array().into_iter().flatten().find(|shown| shown["id"].as_str() == Some(proposed.promise.trim())).ok_or(Refusal::NoSuchPromise)?;
|
||||
let entries = state["commitments"].as_array_mut().ok_or(Refusal::OutsidePutRemovedTarget)?;
|
||||
let entry = entries.iter_mut().find(|entry| entry["id"] == listed["entry"]).ok_or(Refusal::OutsidePutRemovedTarget)?;
|
||||
if applied.closed.iter().any(|done| done["entry"]["id"] == entry["id"]) {
|
||||
return Err(Refusal::ClosedThisTurn);
|
||||
}
|
||||
if !held(listed, started) {
|
||||
return Err(Refusal::OutsidePutChanged);
|
||||
}
|
||||
if !closed(entry["status"].as_str().unwrap_or_default()) {
|
||||
return Err(Refusal::AlreadyOpen);
|
||||
}
|
||||
if !matches!(entry["closedBy"]["act"].as_str(), Some("said" | "amended")) {
|
||||
return Err(Refusal::NotHerClose);
|
||||
}
|
||||
let quote = proposed.words.trim();
|
||||
let located = (words(quote) >= PROSE_MIN_WORDS).then(|| span::locate(prose, quote)).flatten().ok_or(Refusal::ReopenUnquoted)?;
|
||||
let said = &prose[located.start..located.end];
|
||||
if let Some(needs) = proposed.needs {
|
||||
entry["needs"] = json!(needs);
|
||||
}
|
||||
let needs = serde_json::from_value::<Needs>(entry["needs"].clone()).ok();
|
||||
entry["status"] = json!(if opens(needs.as_ref(), proposed.reached) { "open" } else { "blocked" });
|
||||
entry["closedAt"] = Value::Null;
|
||||
entry["closedBy"] = Value::Null;
|
||||
clear_receipt(entry);
|
||||
let mut again = entry["reopened"].as_array().cloned().unwrap_or_default();
|
||||
again.push(json!({ "at": now.to_rfc3339(), "words": said }));
|
||||
let keep = again.len().saturating_sub(REAFFIRMED_KEPT);
|
||||
entry["reopened"] = json!(again[keep..]);
|
||||
applied.reopened.push(entry.clone());
|
||||
Ok(())
|
||||
(state.clone(), applied)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -59,14 +59,12 @@ pub(crate) struct Shown {
|
|||
pub(crate) text: String,
|
||||
}
|
||||
|
||||
/// A read she made in this conversation: its normal form, whether it found anything, what it was in code's words, and when
|
||||
/// she made it (K64: a promise made after it is kept by what she has).
|
||||
/// A read she made in this conversation: its normal form, whether it found anything, and what it was in code's words.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)]
|
||||
pub(crate) struct Tried {
|
||||
pub(crate) key: String,
|
||||
pub(crate) found: bool,
|
||||
pub(crate) what: String,
|
||||
pub(crate) at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
fn at_of(record: &Value) -> Option<DateTime<Utc>> {
|
||||
|
|
@ -118,7 +116,7 @@ pub(crate) fn exchange_of(records: &[Value], room: &str, now: DateTime<Utc>, her
|
|||
let found = read["ok"] == true;
|
||||
if found || read["failure"] == "not_found" {
|
||||
exchange.tried.retain(|tried| tried.key != request.normal());
|
||||
exchange.tried.push(Tried { key: request.normal(), found, what: read["what"].as_str().unwrap_or_default().to_owned(), at: *at });
|
||||
exchange.tried.push(Tried { key: request.normal(), found, what: read["what"].as_str().unwrap_or_default().to_owned() });
|
||||
}
|
||||
}
|
||||
for read in decision["reads"].as_array().into_iter().flatten().filter(|read| read["ok"] == true) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ fn r7_a_not_found_read_is_remembered_and_a_broken_one_is_not() {
|
|||
let missing = json!({ "ok": false, "failure": "not_found", "request": { "kind": "repo", "target": "GameCult/Bifrost?q=Consent Receipt" }, "what": "a search" });
|
||||
let broken = json!({ "ok": false, "failure": "failed", "request": { "kind": "repo", "target": "GameCult/Lodur" }, "what": "GameCult/Lodur on the forge" });
|
||||
let exchange = exchange_of(&[turn(10, MINDS, &[], json!([missing, broken]), json!([]), json!([]))], MINDS, now(), her());
|
||||
assert_eq!(exchange.tried, [Tried { key: "repo:gamecult/bifrost?q=consent receipt".into(), found: false, what: "a search".into(), at: exchange.tried[0].at }]);
|
||||
assert_eq!(exchange.tried, [Tried { key: "repo:gamecult/bifrost?q=consent receipt".into(), found: false, what: "a search".into() }]);
|
||||
}
|
||||
|
||||
/// Soul's R8: the reads refused in the conversation are carried, once each, as `kind target (why)`.
|
||||
|
|
|
|||
|
|
@ -474,7 +474,7 @@ fn k24_her_wake_reads_by_intent_from_a_fixture_and_stops_at_the_cap() {
|
|||
assert!(report["packet"]["affordances"].as_array().unwrap().contains(&json!("read")));
|
||||
// Her next packet opens with what she read, without its content.
|
||||
let record = json!({ "interpreter": decision, "posted": [] });
|
||||
let told = crate::projection::outcome::outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
let told = crate::projection::outcome::outcome_of(&record).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
assert!(told.contains(&"- He read GameCult/Lodur#12 on the forge.".to_owned()) && !told.join("
|
||||
").contains("in front of him now"), "{told:?}");
|
||||
assert!(told.iter().any(|line| line == "- He reached for http://example.org/private and could not read it: it is private."), "{told:?}");
|
||||
|
|
@ -506,7 +506,7 @@ fn k24_a_failed_later_call_keeps_what_was_already_decided() {
|
|||
if prompt.contains("Earlier in his moment") {
|
||||
return "not the contract".into();
|
||||
}
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [] }], "gaps": [], "read": { "kind": "repo", "target": "GameCult/Lodur#12", "quote": "I want to see what changed" } }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null }], "gaps": [], "read": { "kind": "repo", "target": "GameCult/Lodur#12", "quote": "I want to see what changed" } }).to_string()
|
||||
});
|
||||
let report = wake_of(&fixture, &model);
|
||||
let decision = &report["renders"][0]["interpreter"];
|
||||
|
|
@ -541,7 +541,7 @@ fn k24_the_reply_after_a_read_gets_her_whole_budget_and_a_runaway_draft_is_cut_b
|
|||
assert_eq!(persona["words"].as_u64(), Some(words as u64), "her first segment whole; the runaway draft is not in her stream: {persona}");
|
||||
assert!(!persona["prose"].as_str().unwrap().contains("<typed>"), "no unclosed draft in her stream: {persona}");
|
||||
assert!(decision["cut_by_cap"][0].as_str().is_some_and(|text| text.starts_with("Deru, I opened it")), "{decision}");
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] }), &crate::projection::select::Names::none()).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] })).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
assert!(told.iter().any(|line| line.contains("finished writing")), "she is told: {told:?}");
|
||||
}
|
||||
|
||||
|
|
@ -577,7 +577,7 @@ reads_per_wake = 1
|
|||
let mut decision = report["renders"][0]["interpreter"].clone();
|
||||
assert_eq!(decision["read_refused"][0]["why"], "reads_per_wake", "{decision}");
|
||||
decision["read_refused"].as_array_mut().unwrap().push(json!({ "read": { "kind": "web", "target": "http://made.up/x", "quote": "x" }, "why": "web_address_not_in_front_of_her" }));
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] }), &crate::projection::select::Names::none()).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": decision, "posted": [] })).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
assert!(told.contains(&"- He reached for GameCult/Lodur#13 on the forge and it was not read: he has read as much as one turn reads.".to_owned()), "{told:?}");
|
||||
assert!(told.contains(&"- He reached for something to read and it was not read: the address was not in front of him.".to_owned()) && !told.join("\n").contains("made.up"), "a model's target is never told: {told:?}");
|
||||
}
|
||||
|
|
@ -622,7 +622,7 @@ fn r6_no_draft_is_dropped_silently_at_the_cap() {
|
|||
let reply = format!("{after}<typed>Meta, later words.</typed>");
|
||||
let model = Scripted::new(move |_| reply.clone());
|
||||
let report = wake_of(&fixture, &model);
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": report["renders"][0]["interpreter"], "posted": [] }), &crate::projection::select::Names::none()).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": report["renders"][0]["interpreter"], "posted": [] })).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
assert!(told.iter().any(|line| line.contains("the length limit cut it before he finished writing it") && line.contains("Meta, later words.")), "{told:?}");
|
||||
}
|
||||
|
||||
|
|
@ -639,6 +639,6 @@ fn r7_the_cap_never_backs_off_into_a_closed_draft_and_tells_every_draft_it_cuts(
|
|||
let many: String = (1..=190).map(|n| format!("t{n} ")).collect();
|
||||
let cut = crate::projection::narrate::cap_prose(&format!("{many}<typed>First late one.</typed> and <typed>Second late one.</typed>"), words);
|
||||
assert_eq!(cut.cut_drafts, ["First late one.", "Second late one."]);
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": { "room": "#minds:gamecult.org", "said": [], "refused": [], "gaps": [], "heard": [], "cut_by_cap": cut.cut_drafts }, "posted": [] }), &crate::projection::select::Names::none()).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
let told = crate::projection::outcome::outcome_of(&json!({ "interpreter": { "room": "#minds:gamecult.org", "said": [], "refused": [], "gaps": [], "heard": [], "cut_by_cap": cut.cut_drafts }, "posted": [] })).unwrap().lines(crate::projection::select::forms(&control()));
|
||||
assert_eq!(told.iter().filter(|line| line.contains("the length limit cut it")).count(), 2, "{told:?}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,9 @@
|
|||
//! the turn's room. Whether a draft tells what she knows privately is a reading of its meaning, so it is the
|
||||
//! Interpreter's judgement over the private items the packet lists to it (`Packet::private`), never a word match here.
|
||||
//! Every refusal and drop is reported. Every gap is typed (`GapKind`) and shown to her later (K9) only as what it is: a
|
||||
//! draft by number, or a located passage of her thought (`gap`). Each line she says, and each addition, carries a
|
||||
//! required `promises`: a list, empty or one entry per act it promises or offers, each its words, to whom, and what
|
||||
//! keeping it needs, typed (map 16.21, 16.22.1, 16.25.2, B3); whether it opens or is blocked is derived from that by code. Words of at least `PROMISE_MIN_WORDS` found in the draft (`promise_found`) become a `promise_open`
|
||||
//! proposal with the draft as evidence, and a promise she cannot do is also the `missing_affordance` gap; otherwise
|
||||
//! they are reported (`promises_unused`) and open nothing. The answer's `state` closes her listed open promises, each a
|
||||
//! `promise_close` proposal with its evidence. Nothing here writes her state: every proposal rides in the decision as
|
||||
//! `state`, with the lines and promises it listed by id, and the commit's one applier (`commit::apply`, map 16.22.7)
|
||||
//! applies it on the turn's receipts. The prompt tells the Interpreter what she can do this turn
|
||||
//! draft by number, or a located passage of her thought (`gap`). What she says she will do lives only in her own words
|
||||
//! and in what she chooses to remember: no code here derives a promise or a hold from a line (map 16.35, ruling
|
||||
//! `persona-memory-not-machinery`). Nothing here writes her state. The prompt tells the Interpreter what she can do this turn
|
||||
//! (`select::turn_words`), so a reach past it is a `missing_affordance` gap. Nothing here posts: the commit (C3c) will.
|
||||
//!
|
||||
//! The same answer may add a draft after a line of hers listed as one she may add to (`amend`, map 16.17; the actuator
|
||||
|
|
@ -43,7 +38,6 @@ use serde::{Deserialize, Serialize};
|
|||
use serde_json::{Value, json};
|
||||
|
||||
use super::Affordance;
|
||||
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};
|
||||
|
|
@ -59,9 +53,6 @@ const ECHO_OVERLAP: f64 = 0.8;
|
|||
/// she meant, and is kept as unlocated.
|
||||
const GAP_QUOTE_MIN_WORDS: usize = 4;
|
||||
|
||||
/// The fewest words the words of a draft that promise an act may be: fewer ("the") name no act.
|
||||
const PROMISE_MIN_WORDS: usize = 4;
|
||||
|
||||
/// The marks of a draft: two literal tokens no natural prose holds (map 16.19.1).
|
||||
pub(crate) const DRAFT_OPEN: &str = "<typed>";
|
||||
pub(crate) const DRAFT_CLOSE: &str = "</typed>";
|
||||
|
|
@ -71,7 +62,7 @@ pub(crate) const SPEECH_OPENING: &str = "You decide what one person says aloud i
|
|||
|
||||
/// The speech contract, sent as the schema turn's output schema (`--json-schema`): the drafts she sends now by number,
|
||||
/// and the gaps. The model writes no words of hers.
|
||||
pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest","state","reopen","read","unsent"],"properties":{"reopen":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["promise","words","needs"],"properties":{"promise":{"type":"string"},"words":{"type":"string"},"needs":{"type":["object","null"],"additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}},"unsent":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","how","quote"],"properties":{"draft":{"type":"integer"},"how":{"type":"string","enum":["declined","superseded"]},"quote":{"type":"string"}}}},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target","quote"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"},"quote":{"type":"string"}}},"state":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","promise","how","evidence","thought","still_stands"],"properties":{"kind":{"type":"string","enum":["promise_close"]},"promise":{"type":"string"},"how":{"type":"string","enum":["kept","withdrawn","released"]},"evidence":{"type":"object","additionalProperties":false,"required":["draft","line"],"properties":{"draft":{"type":["integer","null"]},"line":{"type":["string","null"]}}},"thought":{"type":["string","null"]},"still_stands":{"type":"boolean"}}}},"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft","promises"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","reaffirms","needs","now","done_by"],"properties":{"now":{"type":"boolean"},"done_by":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":false,"required":["draft"],"properties":{"draft":{"type":"integer","minimum":1}}},{"type":"object","additionalProperties":false,"required":["read"],"properties":{"read":{"type":"boolean","enum":[true]}}},{"type":"object","additionalProperties":false,"required":["note"],"properties":{"note":{"type":"boolean","enum":[true]}}}]},"words":{"type":"string"},"to":{"type":["string","null"]},"reaffirms":{"type":["string","null"]},"needs":{"type":"object","additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promises"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promises":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["words","to","reaffirms","needs","now","done_by"],"properties":{"now":{"type":"boolean"},"done_by":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":false,"required":["draft"],"properties":{"draft":{"type":"integer","minimum":1}}},{"type":"object","additionalProperties":false,"required":["read"],"properties":{"read":{"type":"boolean","enum":[true]}}},{"type":"object","additionalProperties":false,"required":["note"],"properties":{"note":{"type":"boolean","enum":[true]}}}]},"words":{"type":"string"},"to":{"type":["string","null"]},"reaffirms":{"type":["string","null"]},"needs":{"type":"object","additionalProperties":false,"required":["kind","read"],"properties":{"kind":{"type":"string","enum":["words","read","lacking"]},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"}}}}}}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#;
|
||||
pub(crate) const SPEECH_SCHEMA: &str = r#"{"type":"object","additionalProperties":false,"required":["say","gaps","amend","suggest","read","unsent"],"properties":{"unsent":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","how","quote"],"properties":{"draft":{"type":"integer"},"how":{"type":"string","enum":["declined","superseded"]},"quote":{"type":"string"}}}},"read":{"type":["object","null"],"additionalProperties":false,"required":["kind","target","quote"],"properties":{"kind":{"type":"string","enum":["domain","mind","repo","web"]},"target":{"type":"string"},"quote":{"type":"string"}}},"suggest":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","about","private"],"properties":{"kind":{"type":"string","enum":["feedback","idea"]},"draft":{"type":"integer","minimum":1},"about":{"type":["string","null"]},"private":{"type":"boolean"}}}},"amend":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["target","draft"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["addressee","elsewhere","missing_affordance","unwritten"]},"draft":{"type":["integer","null"]},"quote":{"type":["string","null"]},"detail":{"type":"string"}}}}}}"#;
|
||||
|
||||
/// The speech frame before the guidance: what to decide, from what, and the attribution rule. Code, not tuning (map
|
||||
/// 16.7), in her own pronouns (16.19.7). The tuning's `interpreter.guidance` (what counts as her choosing to send it
|
||||
|
|
@ -87,15 +78,14 @@ Below are who {subj} {be}, what {subj} can do here, the room and who is in it, w
|
|||
|
||||
/// The speech frame after the guidance: the room and the private rules, the contract and the gap kinds.
|
||||
fn speech_frame_tail(her: Forms) -> String {
|
||||
let Forms { subj, cap_subj, obj, poss, has, be, s, .. } = her;
|
||||
let Forms { subj, cap_subj, obj, poss, s, .. } = her;
|
||||
format!(
|
||||
"{cap_subj} speak{s} only in this room. What {subj} know{s} privately is listed below as private: {subj} say{s} none of it here, and nothing that gives it away. A private matter may be said plainly only to the person it concerns, in a direct message with exactly that person; nothing listed is that here. Whether a draft fits who is listening is yours to judge.
|
||||
|
||||
Answer with the speech contract's object. `say` lists the drafts {subj} send{s} now, each by its number, with the Matrix ids of anyone listed whom {subj} address{es} directly (`mentions`), the id of the line listed below that {subj} answer{s} or pass{es} on (`in_reply_to`, or null: the room shows that line, with who said it, above {poss} own words), and what the draft promises or does (`promises`, a list, empty when it promises nothing and says of no act that {subj} {be} doing it): for each act the draft promises or offers, and each act it says {subj} {be} doing now or {has} just done this turn: its words, copied exactly, the Matrix id of the person listed to whom {subj} promise{s} it (`to`, null when {subj} promise{s} it to the room), when it promises again one of {poss} open promises listed below to the same person, that promise's id (`reaffirms`, else null): a promise said again is the same promise, never a new one; and what keeping it needs (`needs`): `words` when what {subj} already {has} keeps it; finding anything out is a `read`, naming what to read in `read`, or `lacking` when no read reaches it; `now`, true when the draft says {subj} {be} doing it now or {has} just done it; and `done_by`, the act of this answer that does it (`{{\"draft\": n}}` for a draft said or added, `{{\"read\": true}}` for the read, `{{\"note\": true}}` for the note to Self), or null: an act no act of this answer does is {poss} promise, open until {subj} keep{s} or withdraw{s} it. `gaps` records what {subj} meant and did not send. `unsent` accounts for each of {poss} drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when {poss} prose shows {obj} choosing not to send it, quoting those words of {poss} thought (`quote`); superseded, when a later draft or later prose of {poss} replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to {obj} this turn is declined only when {poss} prose says {subj} choose{s} not to send it. `amend` adds to one of {poss} own lines listed below, at most one a turn, only when {poss} thought shows {obj} choosing to correct or add to that line: name the line by its id, the draft that is {poss} addition, and what it promises, as a line's `promises`. The line stays as it was and the draft is added after it; {subj} never take{s} a word back. `suggest` leaves Self one note, at most one a turn, only when {poss} thought shows {obj} choosing to: name the draft that is the note, its kind (feedback when {subj} pass{es} on what someone listed said, with that person's Matrix id in `about`; idea when it is {poss} own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left. `state` closes {poss} open promises listed below, each by its id: kept, citing the draft by which {subj} {does} it (`evidence.draft`); withdrawn, citing the draft in which {subj} take{s} it back to the person {subj} promised, or tell{s} them {subj} cannot do it; released, citing the id of the line listed below that {subj} may reply to in which the person {subj} promised lets {obj} off it (`evidence.line`). A release says {subj} no longer owe{s} it; patience is not a release, so \"no hurry\" or \"whenever you've read it is fine\" leaves the promise open. Every close also quotes in `thought` the words of {poss} prose here that take it up, copied exactly from {poss} thought outside every draft between <typed> and </typed>, and `still_stands` is true when anything in {poss} prose here holds the promise as still owed or not yet done (\"the promise stays open until I've read it\"): then it is not closed. A draft cited closes the promise only when it goes out this turn where the person {subj} promised can read it, in the room where {subj} made the promise or in a direct message with them, and a thought alone closes nothing. A promise {subj} {has} no way to do is never kept by {obj}: telling the person {subj} promised that {subj} cannot do it withdraws it, and that person can release it. `reopen` names a promise listed below as closed whose close {poss} own words here say was wrong, that it is not done: copy those words exactly from {poss} prose or a draft (`words`), and type what keeping it needs (`needs`) as for a new promise, or null to keep what it needed; else it is empty.
|
||||
Answer with the speech contract's object. `say` lists the drafts {subj} send{s} now, each by its number, with the Matrix ids of anyone listed whom {subj} address{es} directly (`mentions`), the id of the line listed below that {subj} answer{s} or pass{es} on (`in_reply_to`, or null: the room shows that line, with who said it, above {poss} own words). `gaps` records what {subj} meant and did not send. `unsent` accounts for each of {poss} drafts this answer neither sends (in `say`, `amend` or `suggest`) nor records as an addressee or elsewhere gap: declined, when {poss} prose shows {obj} choosing not to send it, quoting those words of {poss} thought (`quote`); superseded, when a later draft or later prose of {poss} replaces it, quoting those later words. Every draft is accounted for: one left out fails the answer. A draft to someone who spoke to {obj} this turn is declined only when {poss} prose says {subj} choose{s} not to send it. `amend` adds to one of {poss} own lines listed below, at most one a turn, only when {poss} thought shows {obj} choosing to correct or add to that line: name the line by its id and the draft that is {poss} addition. The line stays as it was and the draft is added after it; {subj} never take{s} a word back. `suggest` leaves Self one note, at most one a turn, only when {poss} thought shows {obj} choosing to: name the draft that is the note, its kind (feedback when {subj} pass{es} on what someone listed said, with that person's Matrix id in `about`; idea when it is {poss} own, `about` null), and set `private` when it carries anything listed as private or gives it away; such a note is not left.
|
||||
|
||||
A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: addressee when {subj} mean{s} to send a draft but whom to is unclear, elsewhere when {subj} mean{s} a draft for another room or another time; for these two, name the draft by number. missing_affordance when {subj} mean{s} to do something, now or later, that {poss} body cannot do (what {subj} can do here is listed below), whether {subj} said so in a draft or only thought it; name the draft when there is one. unwritten when {subj} mean{s} to say something now and wrote no draft of it. Holding back is no gap: when {poss} thought shows {obj} choosing to wait, to let something stand, to leave it for later or to say nothing, record nothing for it. Every other intent of {poss} that is not carried out has a kind: an intent to act is missing_affordance, an intent to say now with no draft is unwritten. When a gap names no draft, quote the words of {poss} thought that show it, at least four words, copied exactly.",
|
||||
es = if s.is_empty() { "" } else { "es" },
|
||||
does = if s.is_empty() { "do" } else { "does" },
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +240,7 @@ pub(crate) enum GapKind {
|
|||
/// She means a draft for another room or another time.
|
||||
Elsewhere,
|
||||
/// She means to do something, now or later, that no affordance of hers does (map 16.20.6): a reach in her thought, or a
|
||||
/// promise in a draft she says. It accounts for no draft (map 16.29.2): her line posts as she meant it, and this
|
||||
/// reach in a draft she says. It accounts for no draft (map 16.29.2): her line posts as she meant it, and this
|
||||
/// annotates it. A tool request in waiting (section 4.2).
|
||||
MissingAffordance,
|
||||
/// She means to say something now and wrote no draft of it, so nothing went out. A choice to hold back (to wait, let
|
||||
|
|
@ -282,11 +272,11 @@ impl GapKind {
|
|||
///
|
||||
/// - `acted`: it names, or quotes from, a draft that went somewhere this turn (said, added to a line, left for Self), so it
|
||||
/// contradicts what happened and is not shown to her (`decide` sets it). One exception: a `missing_affordance` gap that
|
||||
/// names a draft she said is a promise of an act she cannot do, and is kept and shown (map 16.20.6).
|
||||
/// names a draft she said is an act she says she will do and cannot, and is kept and shown (map 16.20.6).
|
||||
///
|
||||
/// Every kind but `unwritten` may name a draft: an unwritten line is about words she did not set down, so it is always a
|
||||
/// passage of her thought, whatever draft the model names. A kind the contract does not name names no draft either, so it
|
||||
/// accounts for none (map 16.25.7). A reach (`missing_affordance`) names the draft that promises
|
||||
/// accounts for none (map 16.25.7). A reach (`missing_affordance`) names the draft that reaches for
|
||||
/// it when there is one, a draft she says (map 16.20.6, 16.29.2), and otherwise quotes her thought; a reach that names no draft and
|
||||
/// quotes one (at least `GAP_QUOTE_MIN_WORDS` words, found in the draft's words) is about that draft, as if named.
|
||||
///
|
||||
|
|
@ -299,7 +289,7 @@ fn gap(prose: &str, found: &Drafts, raw: &Value) -> Value {
|
|||
}
|
||||
let names_a_draft = !matches!(kind, GapKind::Unwritten | GapKind::Unresolved);
|
||||
let quote = raw.get("quote").and_then(Value::as_str).unwrap_or_default().trim();
|
||||
// A reach that quotes a draft by its words, with no number, is about that draft: a promise in it (map 16.20.6).
|
||||
// A reach that quotes a draft by its words, with no number, is about that draft: a reach in it (map 16.20.6).
|
||||
let quoted_draft = || (kind == GapKind::MissingAffordance && words(quote) >= GAP_QUOTE_MIN_WORDS).then(|| found.drafts.iter().find(|draft| span::fold_text(&draft.text).contains(&span::fold_text(quote)))).flatten();
|
||||
if let Some(draft) = raw.get("draft").and_then(Value::as_i64).and_then(|n| found.numbered(n)).filter(|_| names_a_draft).or_else(quoted_draft) {
|
||||
gap["from"] = json!("draft");
|
||||
|
|
@ -334,10 +324,6 @@ struct Answer {
|
|||
amend: Vec<ProposedAmend>,
|
||||
#[serde(default)]
|
||||
suggest: Vec<ProposedNote>,
|
||||
/// State changes proposed for the commit (map 16.22.7): read item by item, so one that is not the contract is
|
||||
/// reported and the rest stand. Absent proposes none.
|
||||
#[serde(default)]
|
||||
state: Vec<Value>,
|
||||
/// One read she reaches for in the new part of her thought (map 16.22.3), or none: read whole, so one that is not the
|
||||
/// contract is reported and the rest of the answer stands.
|
||||
#[serde(default)]
|
||||
|
|
@ -345,20 +331,6 @@ struct Answer {
|
|||
/// The drafts not sent and not gapped, each declined by her own choice or superseded, citing her prose (Soul's R10).
|
||||
#[serde(default)]
|
||||
unsent: Vec<Unsent>,
|
||||
/// Closes her own words here say were wrong (map 16.28.3): read item by item, so one that is not the contract is
|
||||
/// reported and the rest stand.
|
||||
#[serde(default)]
|
||||
reopen: Vec<Value>,
|
||||
}
|
||||
|
||||
/// A reopen as the answer carries it: a listed closed promise's id, her words, and what keeping it needs, or none to keep
|
||||
/// what it needed.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct ProposedReopen {
|
||||
promise: String,
|
||||
words: String,
|
||||
needs: Option<ProposedNeeds>,
|
||||
}
|
||||
|
||||
/// A draft the answer neither sends nor gaps, and why, citing her prose.
|
||||
|
|
@ -429,87 +401,6 @@ pub(crate) struct Wake<'a> {
|
|||
pub before: &'a str,
|
||||
}
|
||||
|
||||
/// What a line or an addition promises or offers (map 16.22.1, 16.25.6): its promising words, to whom (a Matrix id
|
||||
/// listed, none for the room), and what keeping it needs. Nothing else: a field the contract does not name
|
||||
/// makes the answer not the contract.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct ProposedPromise {
|
||||
words: String,
|
||||
#[serde(default)]
|
||||
to: Option<String>,
|
||||
/// The id of an open promise of hers these words promise again to the same person (map 16.24.2), or none.
|
||||
#[serde(default)]
|
||||
reaffirms: Option<String>,
|
||||
needs: ProposedNeeds,
|
||||
/// Whether the draft says she is doing it now or has just done it this turn (K61, map 16.33.5).
|
||||
#[serde(default)]
|
||||
now: bool,
|
||||
/// The act of this answer that does it, or none: then it is her promise (K61). Whether that act happened is code's.
|
||||
#[serde(default)]
|
||||
done_by: Option<DoneBy>,
|
||||
}
|
||||
|
||||
/// What does an act a draft states (K61), as the answer names it: a draft it says or adds, the read, or the note to Self.
|
||||
/// Exactly one; any other shape names no act.
|
||||
#[derive(Clone, Copy, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct DoneBy {
|
||||
#[serde(default)]
|
||||
draft: Option<i64>,
|
||||
#[serde(default)]
|
||||
read: Option<bool>,
|
||||
#[serde(default)]
|
||||
note: Option<bool>,
|
||||
}
|
||||
|
||||
/// An act of a decision that does what a draft states (K61).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum By {
|
||||
Draft(usize),
|
||||
Read,
|
||||
Note,
|
||||
}
|
||||
|
||||
impl DoneBy {
|
||||
/// The one act it names, or None when it names none or several.
|
||||
fn act(self) -> Option<By> {
|
||||
match (self.draft, self.read.unwrap_or(false), self.note.unwrap_or(false)) {
|
||||
(Some(n), false, false) => usize::try_from(n).ok().filter(|n| *n > 0).map(By::Draft),
|
||||
(None, true, false) => Some(By::Read),
|
||||
(None, false, true) => Some(By::Note),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl By {
|
||||
fn json(self) -> Value {
|
||||
match self {
|
||||
Self::Draft(n) => json!({ "draft": n }),
|
||||
Self::Read => json!({ "read": true }),
|
||||
Self::Note => json!({ "note": true }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What keeping a promise needs, as the answer types it (map 16.25.2): its kind, and for a read what to read.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct ProposedNeeds {
|
||||
kind: NeedsKind,
|
||||
#[serde(default)]
|
||||
read: Option<NeededRead>,
|
||||
}
|
||||
|
||||
/// 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)]
|
||||
struct NeededRead {
|
||||
kind: Kind,
|
||||
target: String,
|
||||
}
|
||||
|
||||
/// A note to Self as the model proposes it: its kind, the draft that is the note, whose feedback it passes on (a Matrix
|
||||
/// id from the people listed, or none for her own idea), and whether it carries something private.
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
@ -524,16 +415,13 @@ struct ProposedNote {
|
|||
private: Option<bool>,
|
||||
}
|
||||
|
||||
/// An amendment as the model proposes it: the id of a line she may add to, the draft that is her addition, and what it
|
||||
/// promises (as a line's `promise`).
|
||||
/// An amendment as the model proposes it: the id of a line she may add to, and the draft that is her addition.
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ProposedAmend {
|
||||
#[serde(default)]
|
||||
target: Option<String>,
|
||||
#[serde(default)]
|
||||
draft: Option<i64>,
|
||||
#[serde(default)]
|
||||
promises: Vec<ProposedPromise>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
@ -545,10 +433,6 @@ struct Proposed {
|
|||
/// The id of a line listed as one she may reply to (`Packet::quotable`), or none.
|
||||
#[serde(default)]
|
||||
in_reply_to: Option<String>,
|
||||
/// What the draft promises (map 16.21, 16.22.1, B3), one entry per act: each found in the draft, code proposes opening
|
||||
/// it, which the commit applies on the line's receipt; each she cannot do is also a `missing_affordance` gap.
|
||||
#[serde(default)]
|
||||
promises: Vec<ProposedPromise>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -580,30 +464,6 @@ pub(crate) fn speech_prompt_in(packet: &Packet, narration: &str, prose: &str, tu
|
|||
if amendable.is_empty() {
|
||||
amendable.push_str("- none\n");
|
||||
}
|
||||
let mut promises: String = packet
|
||||
.promises
|
||||
.iter()
|
||||
.map(|promise| {
|
||||
let to = promise.to.as_deref().map_or_else(String::new, |to| format!(" ({to})"));
|
||||
// A closed one with what closed it, beside her words now (map 16.28.3).
|
||||
let closed_at = || promise.held["closedAt"].as_str().and_then(|at| chrono::DateTime::parse_from_rfc3339(at).ok()).map_or_else(String::new, |at| format!(" {}", at.with_timezone(&chrono::Utc).format("%Y-%m-%d %H:%M UTC")));
|
||||
let by = || promise.held["closedBy"]["words"].as_str().map_or_else(String::new, |words| format!(", by {}", spoken(words)));
|
||||
let status = match promise.status.as_str() {
|
||||
"blocked" => format!("which {} {} no way to do", her.subj, her.has),
|
||||
"open" => "open".to_owned(),
|
||||
how => format!("closed: {how}{}{}", closed_at(), by()),
|
||||
};
|
||||
// What keeping it needs, in code's words (map 16.25.2).
|
||||
let needs = match &promise.needs {
|
||||
Some(Needs::Read { request }) if matches!(promise.status.as_str(), "open" | "blocked") => format!(", needs a read of {}", request.what(her)),
|
||||
_ => String::new(),
|
||||
};
|
||||
format!("- {} \u{2014} to {}{to}, {status}{needs}, made {} {}: {}\n", promise.id, promise.to_name, promise.made.format("%Y-%m-%d %H:%M UTC"), promise.place, spoken(&promise.words))
|
||||
})
|
||||
.collect();
|
||||
if promises.is_empty() {
|
||||
promises.push_str("- none\n");
|
||||
}
|
||||
// What moved in her domain, by id, so a later read can name a line (map 16.22.2, 16.22.3); listed only when the packet
|
||||
// showed her some, since an empty list would read as nothing having moved.
|
||||
let domain: String = if packet.domain.is_empty() {
|
||||
|
|
@ -650,7 +510,7 @@ pub(crate) fn speech_prompt_in(packet: &Packet, narration: &str, prose: &str, tu
|
|||
let named = named_pronouns(&format!("{before}\n{prose}"), tuning, &packet.own_sender);
|
||||
let people = if named.is_empty() { people } else { format!("{people}Pronouns of the people {} prose names:\n{}\n", her.poss, named.iter().map(|line| format!("- {line}\n")).collect::<String>()) };
|
||||
format!(
|
||||
"{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\n{conversation}Who is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\nLines in this room {} may reply to, as id \u{2014} who: line:\n{quotable}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\n{poss} promises, open and closed in this conversation, as id \u{2014} to whom: words:\n{promises}\n{domain}What reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{before}{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}",
|
||||
"{}\n\n{guidance}{}\n\nWho {} {}:\n{}\n\nWhat {} can do here:\n{}.\n\nThe room: {} ({}).\n{conversation}Who is in it, as label \u{2014} Matrix id:\n{people}\nWhat {} know{} privately, none of it to be said here:\n{private}\nLines in this room {} may reply to, as id \u{2014} who: line:\n{quotable}\n{poss} own lines in this room that {} may add to, as id \u{2014} line:\n{amendable}\n{domain}What reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{before}{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}",
|
||||
speech_frame_head(her),
|
||||
tail,
|
||||
her.subj,
|
||||
|
|
@ -688,13 +548,11 @@ fn echo(line: &str, bodies: &[String]) -> bool {
|
|||
struct Faults {
|
||||
/// Drafts accounted for nowhere (`unaccounted`): refused `Undecided`.
|
||||
undecided: Vec<usize>,
|
||||
/// Acts a draft states as done by an act this answer does not make (`done_faults`, K61): each opens as her promise.
|
||||
undone: Vec<Value>,
|
||||
}
|
||||
|
||||
impl Faults {
|
||||
fn none(&self) -> bool {
|
||||
self.undecided.is_empty() && self.undone.is_empty()
|
||||
self.undecided.is_empty()
|
||||
}
|
||||
|
||||
/// The retry's report of this answer, and the paragraphs, one a fault, that name what it left undone.
|
||||
|
|
@ -706,13 +564,8 @@ impl Faults {
|
|||
missed.push(format!("An earlier answer to this left drafts {list} accounted for nowhere: each draft is in `say`, `amend` or `suggest`, a gap of kind addressee or elsewhere that names it, or `unsent`."));
|
||||
fault["drafts"] = json!(self.undecided);
|
||||
}
|
||||
if !self.undone.is_empty() {
|
||||
let list = self.undone.iter().map(|one| format!("draft {}, {}", one["draft"], spoken(one["words"].as_str().unwrap_or_default()))).collect::<Vec<_>>().join("; ");
|
||||
missed.push(format!("An earlier answer to this named, as what does an act a draft states, an act it does not make: {list}. `done_by` names a draft in `say` or `amend`, the read when `read` names one, or the note when `suggest` leaves one, and is null when no act of this answer does it."));
|
||||
fault["done_by"] = json!(self.undone);
|
||||
}
|
||||
// The first fault named is the one the report gives.
|
||||
let failed = [(!self.undecided.is_empty(), "the answer leaves drafts unaccounted"), (!self.undone.is_empty(), "the answer names acts it does not make")].into_iter().find(|(any, _)| *any).map(|(_, why)| why);
|
||||
let failed = [(!self.undecided.is_empty(), "the answer leaves drafts unaccounted")].into_iter().find(|(any, _)| *any).map(|(_, why)| why);
|
||||
fault["failed"] = json!(failed);
|
||||
(fault, missed.join("\n\n"))
|
||||
}
|
||||
|
|
@ -774,7 +627,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
let (fault, missed) = match serde_json::from_str::<Answer>(&answer.text) {
|
||||
Ok(parsed) => {
|
||||
let gaps: Vec<Value> = parsed.gaps.iter().map(|raw| gap(prose, &found, raw)).collect();
|
||||
let faults = Faults { undecided: unaccounted(&parsed, &gaps, prose, &found), undone: done_faults(&parsed, &found) };
|
||||
let faults = Faults { undecided: unaccounted(&parsed, &gaps, prose, &found) };
|
||||
// A fault the retry did not mend fails closed for what it guards, never for the turn: each draft still
|
||||
// unaccounted is undecided, every other draft is decided, and the faults are reported.
|
||||
if retried.is_some() || faults.none() {
|
||||
|
|
@ -811,19 +664,10 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
let earlier = |key: &str| wake.earlier.and_then(|earlier| earlier[key].as_array()).cloned().unwrap_or_default();
|
||||
// What she was sent and what she has read this wake: what an echo is measured against (map 16.22.3).
|
||||
let bodies: Vec<String> = packet.bodies.iter().cloned().chain(wake.read.iter().cloned()).collect();
|
||||
// The lines it listed by id and her open promises it listed by id ride in the record too: the commit resolves a
|
||||
// proposal's evidence against them (`commit::apply`), as the trace holds them live.
|
||||
let lines: Vec<Value> = packet.quotable.iter().map(|line| json!({ "id": line.id, "event": line.event, "room": line.room, "who": line.who, "sender": line.sender, "at_ms": line.at_ms, "text": line.text })).collect();
|
||||
// The reads of this conversation, by normal form, whether each found its target, and when: what a kept promise that
|
||||
// needs a read is checked against (`commit::apply`, map 16.25.4), and what a promise made after it is kept by (K64).
|
||||
let conversation_reads: Vec<Value> = packet.already_read.iter().map(|tried| json!({ "key": tried.key, "found": tried.found, "at": tried.at.to_rfc3339() })).collect();
|
||||
let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "lines": lines, "promises": packet.promises, "conversation_reads": conversation_reads, "calls": calls, "read": null, "at_ms": packet.now_ms });
|
||||
let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "calls": calls, "read": null, "at_ms": packet.now_ms });
|
||||
if let Some(retried) = retried {
|
||||
decision["retried"] = retried;
|
||||
}
|
||||
if !faults.undone.is_empty() {
|
||||
decision["done_by_faults"] = json!(faults.undone);
|
||||
}
|
||||
// Each unsent draft with its words and its quote as located in her prose, so her outcome can tell her a declined one
|
||||
// did not go out, and the thought it cites (map 16.26, 16.29.8). This answer decided every draft of the wake, so an
|
||||
// earlier segment's unsent drafts are not carried (map 16.27).
|
||||
|
|
@ -856,11 +700,6 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
let mut went: Vec<&Draft> = Vec::new();
|
||||
let mut said_drafts: Vec<usize> = Vec::new();
|
||||
let mut said_words: Vec<String> = Vec::new();
|
||||
let mut unused: Vec<Value> = Vec::new();
|
||||
let mut proposals: Vec<Value> = Vec::new();
|
||||
let mut to_dropped: Vec<Value> = Vec::new();
|
||||
// What each line and addition that went out promises or does (K61), decided once the acts of the answer are known.
|
||||
let mut pending: Vec<(&Draft, Vec<ProposedPromise>)> = Vec::new();
|
||||
for line in parsed.say {
|
||||
let Some(draft) = line.draft.and_then(|n| found.numbered(n)) else {
|
||||
refusals.push(refused(Act::Say, None, line.draft, Refusal::NoDraft));
|
||||
|
|
@ -894,7 +733,6 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
said_words.push(span::fold_text(&draft.text));
|
||||
went.push(draft);
|
||||
said.push(json!({ "room": room, "text": draft.text, "mentions": mentions, "in_reply_to": target.map(|line| json!({ "id": line.id, "event": line.event, "who": line.who, "text": line.text })), "rests_on": { "draft": draft.n, "start_byte": draft.start, "end_byte": draft.end }, "dropped": { "mentions": unknown } }));
|
||||
pending.push((draft, line.promises));
|
||||
}
|
||||
// An amendment adds a whole draft after a line of hers listed as one she may add to; the actuator composes it, so
|
||||
// nothing here can rewrite the line (map 16.17).
|
||||
|
|
@ -920,7 +758,6 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
went.push(draft);
|
||||
amended_drafts.push(draft.n);
|
||||
amended.push(json!({ "target": line.id, "event": line.event, "room": line.room, "original": line.text, "added": draft.text, "draft": draft.n }));
|
||||
pending.push((draft, proposed.promises));
|
||||
}
|
||||
(reason, _) => refusals.push(refused(Act::Amend, Some(draft), None, reason.unwrap_or(Refusal::NotAmendable))),
|
||||
}
|
||||
|
|
@ -957,11 +794,11 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
suggestions.push(json!({ "kind": proposed.kind, "about": about, "room": room, "text": draft.text, "draft": draft.n, "dropped": { "about": dropped } }));
|
||||
}
|
||||
// A gap about a draft that went somewhere, or quoting from one, contradicts what happened: it is kept for the trace as
|
||||
// `acted` and never shown to her. A reach naming a draft she said or added is a promise she cannot keep, and is kept
|
||||
// (16.20.6, 16.21).
|
||||
// `acted` and never shown to her. A reach naming a draft she said or added is an act her line says she will do and her
|
||||
// body cannot, and is kept (`persona-unbacked-intent-say-then-amend`, 16.20.6).
|
||||
for gap in decision["gaps"].as_array_mut().into_iter().flatten() {
|
||||
let promise = gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"].as_u64().is_some_and(|n| said_drafts.iter().chain(&amended_drafts).any(|said| *said as u64 == n));
|
||||
let named = !promise && gap["draft"].as_u64().is_some_and(|n| went.iter().any(|draft| draft.n as u64 == n)) && gap["from"] == "draft";
|
||||
let unbacked = gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"].as_u64().is_some_and(|n| said_drafts.iter().chain(&amended_drafts).any(|said| *said as u64 == n));
|
||||
let named = !unbacked && gap["draft"].as_u64().is_some_and(|n| went.iter().any(|draft| draft.n as u64 == n)) && gap["from"] == "draft";
|
||||
let quoted = gap["from"] == "unlocated" && gap["quote"].as_str().is_some_and(|quote| !quote.is_empty() && went.iter().any(|draft| span::fold_text(&draft.text).contains(&span::fold_text(quote))));
|
||||
if named || quoted {
|
||||
gap["from"] = json!("acted");
|
||||
|
|
@ -980,21 +817,6 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
if !read_refused.is_empty() {
|
||||
decision["read_refused"] = json!(read_refused);
|
||||
}
|
||||
// What each line and addition that went out promises or does (K61): an act it states is done only by an act of this
|
||||
// decision that happened, a draft said or added, the read made, or the note left; any other is her promise.
|
||||
let read_made = !decision["read"].is_null();
|
||||
let done = |by: By| match by {
|
||||
By::Draft(n) => said_drafts.contains(&n) || amended_drafts.contains(&n),
|
||||
By::Read => read_made,
|
||||
By::Note => !suggestions.is_empty(),
|
||||
};
|
||||
let mut done_now: Vec<Value> = Vec::new();
|
||||
for (draft, promises) in &pending {
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped, done_now: &mut done_now, packet, prose }, draft, promises, &shown, &done);
|
||||
}
|
||||
if !done_now.is_empty() {
|
||||
decision["done_now"] = json!(done_now);
|
||||
}
|
||||
decision["amended"] = json!(amended);
|
||||
decision["suggestions"] = json!(suggestions);
|
||||
decision["room"] = json!(room);
|
||||
|
|
@ -1008,31 +830,6 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
decision["undecided"] = json!(faults.undecided);
|
||||
}
|
||||
decision["refused"] = json!(refusals);
|
||||
if !unused.is_empty() {
|
||||
decision["promises_unused"] = json!(unused);
|
||||
}
|
||||
if !to_dropped.is_empty() {
|
||||
decision["promise_to_dropped"] = json!(to_dropped);
|
||||
}
|
||||
// The closes it proposes, each typed with its evidence; one that is not the contract is reported and proposes nothing.
|
||||
let mut state_unused = Vec::new();
|
||||
for raw in parsed.state {
|
||||
match close_of(&raw) {
|
||||
Some(close) => proposals.push(json!(close)),
|
||||
None => state_unused.push(raw),
|
||||
}
|
||||
}
|
||||
// The reopens it proposes, after the closes (map 16.28.3); one that is not the contract is reported.
|
||||
for raw in parsed.reopen {
|
||||
match reopen_of(&raw, packet, prose) {
|
||||
Some(reopen) => proposals.push(json!(reopen)),
|
||||
None => state_unused.push(raw),
|
||||
}
|
||||
}
|
||||
decision["state"] = json!(proposals);
|
||||
if !state_unused.is_empty() {
|
||||
decision["state_unused"] = json!(state_unused);
|
||||
}
|
||||
decision
|
||||
}
|
||||
|
||||
|
|
@ -1042,7 +839,7 @@ pub(crate) fn decide_in(model: &dyn Model, segment_id: &str, packet: &Packet, na
|
|||
fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake) -> Result<Value, (&'static str, Option<ReadRequest>)> {
|
||||
let asked: Asked = serde_json::from_value(raw.clone()).map_err(|_| ("not_the_contract", None))?;
|
||||
// In front of her is her prose and what she was sent, never what she read: a read cannot chain from a fetched page
|
||||
// (Soul's p1b), so no page can steer her to the next. The one reach rule decides it, as at a promise's open (16.25.5).
|
||||
// (Soul's p1b), so no page can steer her to the next. The one reach rule decides it (16.25.5).
|
||||
let reached: Vec<String> = packet.bodies.iter().cloned().chain(std::iter::once(packet.heard.clone())).collect();
|
||||
let request = read::reach(&asked, packet, prose, &reached).map_err(|why| (why, None))?;
|
||||
// Nothing she read in this conversation, or this wake, is read again (K26, Soul's R7), found or not, shown or not.
|
||||
|
|
@ -1082,10 +879,7 @@ fn reading(raw: &Value, packet: &Packet, prose: &str, found: &Drafts, wake: Wake
|
|||
words.dedup();
|
||||
words
|
||||
});
|
||||
// Her own open promise anchors the reach (map 16.25.5): she reaches for what she promised to read, so its address
|
||||
// need not be named again; the quote must still be located in her thought.
|
||||
let promised = packet.promises.iter().any(|promise| promise.status == "open" && matches!(&promise.needs, Some(Needs::Read { request: needed }) if needed.normal() == key));
|
||||
let anchors = |sentence: &str| promised || match &title {
|
||||
let anchors = |sentence: &str| match &title {
|
||||
Some(title) => {
|
||||
let said = read::word_tokens(sentence);
|
||||
title.iter().filter(|word| said.contains(word)).collect::<BTreeSet<_>>().len() >= 2 || (generic && refers(sentence))
|
||||
|
|
@ -1199,196 +993,6 @@ fn read_frame(her: Forms) -> String {
|
|||
)
|
||||
}
|
||||
|
||||
/// A close as the contract carries it: a listed promise's id, how, and exactly one of a draft and a line as evidence. A
|
||||
/// read is no evidence (map 16.28.6), so an answer citing one is not the contract.
|
||||
fn close_of(raw: &Value) -> Option<Proposal> {
|
||||
if raw["kind"] != "promise_close" {
|
||||
return None;
|
||||
}
|
||||
let promise = raw["promise"].as_str().map(str::trim).filter(|id| !id.is_empty())?.to_owned();
|
||||
let how = serde_json::from_value::<How>(raw["how"].clone()).ok()?;
|
||||
if raw["evidence"].get("read").is_some_and(|read| !read.is_null()) {
|
||||
return None;
|
||||
}
|
||||
let evidence = match (raw["evidence"]["draft"].as_u64(), raw["evidence"]["line"].as_str().map(str::trim).filter(|id| !id.is_empty())) {
|
||||
(Some(n), None) => Evidence::Draft(usize::try_from(n).ok()?),
|
||||
(None, Some(line)) => Evidence::Heard(line.to_owned()),
|
||||
_ => return None,
|
||||
};
|
||||
let thought = raw["thought"].as_str().map(str::trim).filter(|thought| !thought.is_empty()).map(str::to_owned);
|
||||
Some(Proposal::PromiseClose { promise, how, evidence, thought, still_stands: raw["still_stands"] == true })
|
||||
}
|
||||
|
||||
|
||||
/// The acts a line or an addition states that the answer names as done by an act it does not make (K61, map 16.33.5), a
|
||||
/// contract fault found before anything is decided: a `done_by` naming no one act, a draft in neither `say` nor `amend`,
|
||||
/// the read when `read` names none, or the note when `suggest` leaves none. Each by its draft and words. A fault the retry
|
||||
/// does not mend is read as `done_by` null: the act is her promise (`promised_one`).
|
||||
fn done_faults(answer: &Answer, found: &Drafts) -> Vec<Value> {
|
||||
let acts: BTreeSet<usize> = answer.say.iter().map(|line| line.draft).chain(answer.amend.iter().map(|amend| amend.draft)).filter_map(|n| n.and_then(|n| found.numbered(n)).map(|draft| draft.n)).collect();
|
||||
let made = |by: By| match by {
|
||||
By::Draft(n) => acts.contains(&n),
|
||||
By::Read => answer.read.as_ref().is_some_and(|read| !read.is_null()),
|
||||
By::Note => !answer.suggest.is_empty(),
|
||||
};
|
||||
let lines = answer.say.iter().map(|line| (line.draft, &line.promises)).chain(answer.amend.iter().map(|amend| (amend.draft, &amend.promises)));
|
||||
let mut faults = Vec::new();
|
||||
for (draft, promises) in lines {
|
||||
for promise in promises.iter().filter(|promise| promise.done_by.is_some_and(|by| !by.act().is_some_and(made))) {
|
||||
faults.push(json!({ "draft": draft, "words": promise.words.trim() }));
|
||||
}
|
||||
}
|
||||
faults
|
||||
}
|
||||
|
||||
/// A reopen as the contract carries it (map 16.28.3): a listed promise's id, her words, and what keeping it needs typed as
|
||||
/// at open (`typed_needs`), or none to keep the entry's own, whose read code reaches for again. Whether the words stand in
|
||||
/// her prose, and whether the entry may reopen, are the commit's.
|
||||
fn reopen_of(raw: &Value, packet: &Packet, prose: &str) -> Option<Proposal> {
|
||||
let proposed: ProposedReopen = serde_json::from_value(raw.clone()).ok()?;
|
||||
let promise = proposed.promise.trim();
|
||||
if promise.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let (needs, reached) = match &proposed.needs {
|
||||
Some(named) => {
|
||||
let (needs, verdict) = typed_needs(named, packet, prose);
|
||||
(needs, verdict.is_ok())
|
||||
}
|
||||
// Its own need, reached again: a promise carries its address, so its own target is in front of her (16.25.5).
|
||||
None => {
|
||||
let own = packet.promises.iter().find(|listed| listed.id == promise).and_then(|listed| match &listed.needs {
|
||||
Some(Needs::Read { request }) => Some(request.clone()),
|
||||
_ => None,
|
||||
});
|
||||
let reached = own.is_some_and(|request| {
|
||||
let (kind, target) = match &request {
|
||||
ReadRequest::Repo(target) => (Kind::Repo, target.clone()),
|
||||
ReadRequest::Web(target) => (Kind::Web, target.clone()),
|
||||
ReadRequest::Mind(words) => (Kind::Mind, words.clone()),
|
||||
ReadRequest::Campaign(_) => return packet.affordances.contains(&Affordance::Read),
|
||||
};
|
||||
let reached: Vec<String> = packet.bodies.iter().cloned().chain([packet.heard.clone(), target.clone()]).collect();
|
||||
read::reach(&Asked { kind, target, quote: String::new() }, packet, prose, &reached).is_ok()
|
||||
});
|
||||
(None, reached)
|
||||
}
|
||||
};
|
||||
Some(Proposal::PromiseReopen { promise: promise.to_owned(), words: proposed.words.trim().to_owned(), needs, reached })
|
||||
}
|
||||
|
||||
/// Whether `promise` names an act in `draft`: at least `PROMISE_MIN_WORDS` words (`span::tokens`), found in the draft's
|
||||
/// text with both folded by `span::fold` and lowercased (K52). Why not, when not.
|
||||
fn promise_found(draft: &str, promise: &str) -> Result<(), &'static str> {
|
||||
let folded = |text: &str| span::fold_text(text).to_lowercase();
|
||||
if span::tokens(promise).count() < PROMISE_MIN_WORDS {
|
||||
Err("fewer than four words")
|
||||
} else if !folded(draft).contains(&folded(promise)) {
|
||||
Err("not in the draft")
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a promise found in a draft is recorded: words that name no act, the open proposals, a `to` naming no one listed,
|
||||
/// and the acts stated as done that an act of this decision did (K61); and the turn a read it needs is reached in
|
||||
/// (`read::reach`).
|
||||
struct Promising<'a> {
|
||||
unused: &'a mut Vec<Value>,
|
||||
proposals: &'a mut Vec<Value>,
|
||||
to_dropped: &'a mut Vec<Value>,
|
||||
done_now: &'a mut Vec<Value>,
|
||||
packet: &'a Packet,
|
||||
prose: &'a str,
|
||||
}
|
||||
|
||||
/// The promises in a draft she says or adds (map 16.21, 16.22.1, B3): the list is required of every line and every
|
||||
/// addition, so the judgement is made for each, and a line can carry several. Words that do not name an act in the draft
|
||||
/// (`promise_found`) are reported in `unused` and open nothing. Found, code proposes opening each with the draft as
|
||||
/// evidence, which the commit applies only on the line's receipt; to whom is a Matrix id listed, or the room when it names
|
||||
/// no one listed (reported). Each promise she cannot do is also its own `missing_affordance` gap; a reach the answer
|
||||
/// already gapped on this draft stands for the first of them, so none is recorded twice. An act the draft states that an
|
||||
/// act of this decision did (`done`, K61) opens nothing, and is reported in `done_now`.
|
||||
fn promised(decision: &mut Value, into: Promising, draft: &Draft, promises: &[ProposedPromise], shown: &dyn Fn(&str) -> bool, done: &dyn Fn(By) -> bool) {
|
||||
let answered_reach = decision["gaps"].as_array().is_some_and(|gaps| gaps.iter().any(|gap| gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"] == json!(draft.n) && gap.get("promises").is_none()));
|
||||
let Promising { unused, proposals, to_dropped, done_now, packet, prose } = into;
|
||||
let mut blocked = 0;
|
||||
for promise in promises.iter().filter(|promise| !promise.words.trim().is_empty()) {
|
||||
let words = promise.words.trim();
|
||||
let Some(Err(why)) = promised_one(Promising { unused: &mut *unused, proposals: &mut *proposals, to_dropped: &mut *to_dropped, done_now: &mut *done_now, packet, prose }, draft, promise, shown, done) else {
|
||||
continue;
|
||||
};
|
||||
blocked += 1;
|
||||
if blocked == 1 && answered_reach {
|
||||
continue;
|
||||
}
|
||||
if let Some(gaps) = decision["gaps"].as_array_mut().filter(|gaps| !gaps.iter().any(|gap| gap["draft"] == json!(draft.n) && gap["promises"] == words)) {
|
||||
gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": words, "detail": why }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One promise of a draft: reported unused when its words name no act in the draft, else proposed to open. When found,
|
||||
/// whether it opens, or code's words for why it is blocked: what it needs is typed (map 16.25.2), and whether it opens is
|
||||
/// derived from that, a read through the one reach rule (`read::reach`, 16.25.5).
|
||||
fn promised_one(into: Promising, draft: &Draft, promise: &ProposedPromise, shown: &dyn Fn(&str) -> bool, done: &dyn Fn(By) -> bool) -> Option<Result<(), String>> {
|
||||
let words = promise.words.trim();
|
||||
if let Err(why) = promise_found(&draft.text, words) {
|
||||
into.unused.push(json!({ "draft": draft.n, "promises": words, "why": why }));
|
||||
return None;
|
||||
}
|
||||
// Done by an act of this decision that happened (K61): nothing is owed. A `done_by` naming an act that did not happen
|
||||
// is read as none, so the act is her promise, open where she can see it and withdraw it.
|
||||
if let Some(by) = promise.done_by.and_then(DoneBy::act).filter(|by| done(*by)) {
|
||||
into.done_now.push(json!({ "draft": draft.n, "words": words, "by": by.json() }));
|
||||
return None;
|
||||
}
|
||||
let to = match promise.to.as_deref().map(str::trim).filter(|to| !to.is_empty()) {
|
||||
Some(id) if shown(id) => Some(id.to_owned()),
|
||||
Some(id) => {
|
||||
into.to_dropped.push(json!({ "draft": draft.n, "to": id }));
|
||||
None
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let reaffirms = promise.reaffirms.as_deref().map(str::trim).filter(|id| !id.is_empty()).map(str::to_owned);
|
||||
let (needs, verdict) = typed_needs(&promise.needs, into.packet, into.prose);
|
||||
into.proposals.push(json!(Proposal::PromiseOpen { words: words.to_owned(), to, reaffirms, needs, reached: verdict.is_ok(), now: promise.now, evidence: Evidence::Draft(draft.n) }));
|
||||
Some(verdict)
|
||||
}
|
||||
|
||||
/// What keeping a promise needs, typed from the answer (map 16.25.2), and whether it opens, or code's words for why it is
|
||||
/// blocked. Words open; a read opens when she can reach its target (Soul's R7, R10, map 16.25.5): a read named nowhere in
|
||||
/// front of her, outside GameCult, or on a turn that cannot read is blocked, as is what this body lacks and a read not
|
||||
/// named. One typing, at open and at reopen.
|
||||
fn typed_needs(proposed: &ProposedNeeds, packet: &Packet, prose: &str) -> (Option<Needs>, Result<(), String>) {
|
||||
let her = packet.forms;
|
||||
match (proposed.kind, &proposed.read) {
|
||||
(NeedsKind::Words, _) => (Some(Needs::Words), Ok(())),
|
||||
(NeedsKind::Lacking, _) => (Some(Needs::Lacking), Err("this body has no way to do it".to_owned())),
|
||||
(NeedsKind::Read, None) => (None, Err("what it needs was not named".to_owned())),
|
||||
(NeedsKind::Read, Some(named)) => {
|
||||
let asked = Asked { kind: named.kind, target: named.target.clone(), quote: String::new() };
|
||||
let reached: Vec<String> = packet.bodies.iter().cloned().chain(std::iter::once(packet.heard.clone())).collect();
|
||||
match read::reach(&asked, packet, prose, &reached) {
|
||||
Ok(request) => (Some(Needs::Read { request }), Ok(())),
|
||||
// Not reached: kept as named when it is a read at all, so what it needs is still said; a repo or web target
|
||||
// that is no repo or address ("release notes", a path on a disk) is no read, so it is what this body lacks
|
||||
// (map 16.26); a domain line not listed names nothing.
|
||||
Err(_) => match named.kind {
|
||||
Kind::Domain => (None, Err("what it needs was not named".to_owned())),
|
||||
_ => match read::well_formed(named.kind, &named.target) {
|
||||
Some(request) => {
|
||||
let why = format!("it needs a read this body cannot reach: {}", request.what(her));
|
||||
(Some(Needs::Read { request }), Err(why))
|
||||
}
|
||||
None => (Some(Needs::Lacking), Err("this body has no way to do it".to_owned())),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -303,13 +303,14 @@ pub(crate) fn lived_stream(narration: &str, heard: &str) -> String {
|
|||
if heard.trim().is_empty() { narration.to_owned() } else { format!("{narration}\n\n{heard}") }
|
||||
}
|
||||
|
||||
/// What the Persona reads after the stream: her view (her promises, her domain), then the room. When someone turned to
|
||||
/// What the Persona reads after the stream: her view (what came of her last turn, her side of the conversation, her
|
||||
/// domain), then the room. When someone turned to
|
||||
/// her, the stream ends on that arrival, so the room opens
|
||||
/// on it: the bridged lines (`Packet::bridged`), then the conversation's speech cues (`The room: …`, map 16.20.2) last,
|
||||
/// where she drafts or stays silent knowing who is waiting. Otherwise the cues first, then what was said, verbatim.
|
||||
pub(crate) fn read_after(packet: &Packet) -> String {
|
||||
let room = room_after(packet);
|
||||
// What is in front of her besides the room, first (map 16.23.1): her promises, then her domain; the room last.
|
||||
// What is in front of her besides the room, first (map 16.23.1); the room last.
|
||||
match (packet.in_view.is_empty(), room.trim().is_empty()) {
|
||||
(true, _) => room,
|
||||
(false, true) => packet.in_view.clone(),
|
||||
|
|
|
|||
|
|
@ -22,24 +22,22 @@
|
|||
//!
|
||||
//! That holds by type (map 16.30.3, K46): every text of a record a row carries is `Words`, which only `Form::words` reads,
|
||||
//! and the event form reads none; a read is named to the Projector by a closed `EventPhrase`, never by its address or
|
||||
//! search words. A person a row names is a `Person` (K53): the record's name in her view, and to the Projector only a
|
||||
//! `Who`, built here from the id the record carries beside the name.
|
||||
//! search words. No row names a person: what she promised, held or owes is not a row (map 16.35).
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use self::form::{Form, Person, ReadName, Words};
|
||||
use super::commit::{How, Needs, Refusal as StateRefusal};
|
||||
use self::form::{Form, ReadName, Words};
|
||||
use super::interpret::{GapKind, MAX_LINES, Refusal};
|
||||
use super::read::{ReadFailure, ReadRefusal, ReadRequest};
|
||||
use super::select::{Forms, Names, capitalized, who_of};
|
||||
use super::select::{Forms, capitalized};
|
||||
|
||||
/// Her words in a row, and the forms a row is rendered in (K46). The text a `Words` holds is private to this module, so
|
||||
/// nothing outside it can format one: a row's sentence asks its `Form` for each slot, and the event form answers none.
|
||||
mod form {
|
||||
use super::super::read::ReadRequest;
|
||||
use super::super::select::{Forms, Who, clip, spoken};
|
||||
use super::super::select::{Forms, clip, spoken};
|
||||
|
||||
/// Words of a record's text: a draft, a line, a passage of her thought, a promise's words. No `Display`, `Deref`,
|
||||
/// Words of a record's text: a draft, a line, a passage of her thought. No `Display`, `Deref`,
|
||||
/// `AsRef<str>` or accessor; its only reader is `Form::words`.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub(super) struct Words(String);
|
||||
|
|
@ -136,26 +134,6 @@ mod form {
|
|||
pub(super) fn of(request: &ReadRequest) -> Self {
|
||||
Self { told: request.named().map(Words), event: EventPhrase::of(request) }
|
||||
}
|
||||
|
||||
/// Whether it is a search: it finds things and reads none of them.
|
||||
pub(super) fn search(&self) -> bool {
|
||||
matches!(self.event, EventPhrase::RepoSearch(_))
|
||||
}
|
||||
}
|
||||
|
||||
/// A person a row names (K53): `told`, the record's name for them, which her view shows; `event`, who they are to
|
||||
/// her as the Projector is told it (`Who`). Only `Form::person` reads either, so the event form cannot name anyone by
|
||||
/// a display name or a Matrix id.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(super) struct Person {
|
||||
told: String,
|
||||
event: Who,
|
||||
}
|
||||
|
||||
impl Person {
|
||||
pub(super) fn new(told: String, event: Who) -> Self {
|
||||
Self { told, event }
|
||||
}
|
||||
}
|
||||
|
||||
/// The form a row is rendered in: `Told`, her view, her words verbatim and held to a byte count; `Event`, the
|
||||
|
|
@ -178,14 +156,6 @@ mod form {
|
|||
}
|
||||
}
|
||||
|
||||
/// Who a person is, in this form: the record's name, or the Projector's `Who`.
|
||||
pub(super) fn person(&self, person: &Person) -> String {
|
||||
match self {
|
||||
Self::Event(_) => person.event.to_string(),
|
||||
Self::Told(_) | Self::Report => person.told.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
/// What a read was, in this form.
|
||||
pub(super) fn read(&self, name: &ReadName, her: Forms) -> String {
|
||||
match (self, &name.told) {
|
||||
|
|
@ -217,22 +187,6 @@ enum Quote {
|
|||
Sent,
|
||||
}
|
||||
|
||||
/// A promise's status as her record shows it, when a close was refused.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum Status {
|
||||
Open,
|
||||
Blocked,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Status {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
Self::Open => "open",
|
||||
Self::Blocked => "blocked",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Why the actuator did not change a line she meant to add to (B1's refusals; the simulated room's too).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
|
@ -243,23 +197,24 @@ enum EditRefusal {
|
|||
}
|
||||
|
||||
/// One thing that came of her last turn, by its typed reason. A part that reached the room carries the receipt that says
|
||||
/// so (`Said`, `Promise`, `Amended`; a note's receipt is the record that holds it); every other part names the room that
|
||||
/// so (`Said`, `SaidUnbacked`, `Amended`; a note's receipt is the record that holds it); every other part names the room that
|
||||
/// nothing reached, when the record names one.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
enum Part {
|
||||
/// A posted receipt.
|
||||
Said { room: String, text: Words },
|
||||
/// A posted receipt whose line promises an act she has no way to do: a `missing_affordance` gap naming it (16.20.6).
|
||||
Promise { room: String, text: Words },
|
||||
/// A posted receipt whose line says she will do something her body cannot: a `missing_affordance` gap naming it
|
||||
/// (16.20.6, `persona-unbacked-intent-say-then-amend`), the say-then-amend row.
|
||||
SaidUnbacked { room: String, text: Words },
|
||||
/// `reach`, on this row and the other rows of a draft that did not go out: a `missing_affordance` gap names the draft,
|
||||
/// told as a clause of this row (K63), never as a row of its own.
|
||||
Refused { reason: Refusal, room: Option<String>, text: Words, reach: bool },
|
||||
Gap { kind: GapKind, room: Option<String>, quote: Quote, reach: bool },
|
||||
/// A draft she did not finish: the turn ended first, or the length limit cut it (`by_limit`, Soul's R6).
|
||||
Unfinished { room: Option<String>, text: Words, by_limit: bool },
|
||||
/// An edited receipt with no refusal: her words were added after a line of hers; `promise` when a
|
||||
/// An edited receipt with no refusal: her words were added after a line of hers; `unbacked` when a
|
||||
/// `missing_affordance` gap names the addition's draft (map 16.21).
|
||||
Amended { room: String, added: Words, promise: bool },
|
||||
Amended { room: String, added: Words, unbacked: bool },
|
||||
/// An addition that changed nothing: refused by code (None) or by the actuator.
|
||||
NotAmended { refusal: Option<EditRefusal>, room: Option<String>, added: Words, reach: bool },
|
||||
/// A note to Self, recorded in her turn's record: never claimed read.
|
||||
|
|
@ -269,15 +224,6 @@ enum Part {
|
|||
Failed,
|
||||
/// Receipts went out, and a later step of the turn broke (C3c's `broke_after`, 16.20.7).
|
||||
BrokeAfter { room: Option<String> },
|
||||
/// A promise of hers the commit closed (map 16.22.1, 16.22.7): told once, here, and never again. `to` is whom she
|
||||
/// promised, none for the room; `by` is who let her off it, for a release.
|
||||
Closed { how: How, to: Option<Person>, words: Words, room: String, by: Option<Person> },
|
||||
/// A promise the commit opened from an act her line said she was doing now, which nothing in her turn did (K61, map
|
||||
/// 16.33.5): `to` is whom she promised, none for the room, and `words` her words for it.
|
||||
NowUndone { to: Option<Person>, words: Words },
|
||||
/// A close the commit refused: the promise stands as her record shows it (`status`, open or blocked), and why;
|
||||
/// `read` is the read keeping it needs, when it needs one.
|
||||
StillOpen { reason: StateRefusal, to: Option<Person>, words: Words, status: Status, read: Option<ReadName> },
|
||||
/// A draft she chose not to send (`unsent`, declined): it did not go out, and the thought the Interpreter cited as her
|
||||
/// choice is shown beside it, so a misread decline is a record she can see (map 16.26, 16.29.2).
|
||||
Declined { room: Option<String>, text: Words, thought: Words, reach: bool },
|
||||
|
|
@ -319,19 +265,16 @@ fn has_receipts(record: &Value) -> bool {
|
|||
["posted", "edited"].iter().any(|key| record[*key].as_array().is_some_and(|receipts| !receipts.is_empty()))
|
||||
}
|
||||
|
||||
/// What came of the turn `record` records; None when there is no record. Each person a row names is named to the
|
||||
/// Projector by `who_of` over `names`, from the id the record carries beside the name (K53). A record with nothing to tell (a chosen silence,
|
||||
/// What came of the turn `record` records; None when there is no record. A record with nothing to tell (a chosen silence,
|
||||
/// nothing drafted, nothing reached for) is an empty outcome, and no section is rendered from it.
|
||||
///
|
||||
/// The record is one of two shapes, never both (C3c, map 16.20.7): `failed`, when the turn sent nothing and broke off; or
|
||||
/// the decision with its receipts, and `broke_after` naming the step when a later step broke. A record with both `failed`
|
||||
/// and receipts is malformed: she is told nothing of it, and it is reported.
|
||||
pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
||||
pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
||||
if !record.is_object() {
|
||||
return None;
|
||||
}
|
||||
// A person by the record's name and the id beside it; a record with no id names someone she does not know.
|
||||
let person = |told: &Value, id: &Value| words(told).map(|told| Person::new(told, who_of(id.as_str().unwrap_or_default(), names)));
|
||||
let mut outcome = Outcome::default();
|
||||
let decision = &record["interpreter"];
|
||||
let failed = record.get("failed").is_some() || decision.get("failed").is_some();
|
||||
|
|
@ -392,29 +335,29 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
let made = receipt.is_some_and(|receipt| receipt["refusal"].is_null());
|
||||
additions.push((&amended["draft"], made.then_some(outcome.parts.len())));
|
||||
match receipt.map(|receipt| (receipt["refusal"].is_null(), serde_json::from_value::<EditRefusal>(receipt["refusal"].clone()))) {
|
||||
Some((true, _)) => outcome.parts.push(Part::Amended { room: at, added, promise: false }),
|
||||
Some((true, _)) => outcome.parts.push(Part::Amended { room: at, added, unbacked: false }),
|
||||
Some((false, Ok(refusal))) => outcome.parts.push(Part::NotAmended { refusal: Some(refusal), room: Some(at), added, reach: false }),
|
||||
Some((false, Err(_))) => outcome.omitted.push(format!("an amendment refused for a reason no table names: {}", receipt.map_or(Value::Null, |receipt| receipt["refusal"].clone()))),
|
||||
None => outcome.omitted.push(format!("an amendment with no receipt that it was made: {}", amended["added"])),
|
||||
}
|
||||
}
|
||||
// A reach that names a line which went out is a promise: the receipt says it reached the room, and she is told what
|
||||
// it promises (16.20.6). Each receipt is told once, as a promise or as said.
|
||||
let mut promised: Vec<usize> = Vec::new();
|
||||
// A reach that names a line which went out is the say-then-amend row: the receipt says it reached the room, and she is
|
||||
// told it reaches for what her body cannot do (16.20.6). Each receipt is told once, as unbacked or as said.
|
||||
let mut unbacked: Vec<usize> = Vec::new();
|
||||
// The reaches naming a draft that did not go out, told on that draft's row once every row is known (K63).
|
||||
let mut reaching: Vec<(&Value, Quote)> = Vec::new();
|
||||
for gap in decision["gaps"].as_array().into_iter().flatten() {
|
||||
let kind = serde_json::from_value::<GapKind>(gap["kind"].clone()).unwrap_or(GapKind::Unresolved);
|
||||
// A reach naming an addition's draft is a promise in that addition: told on the addition's row when the actuator
|
||||
// made it; when it did not, the row that says nothing changed tells it, and the promise is reported.
|
||||
// A reach naming an addition's draft is unbacked intent in that addition: told on the addition's row when the
|
||||
// actuator made it; when it did not, the row that says nothing changed tells it, and the reach is reported.
|
||||
if let Some((_, made)) = additions.iter().find(|(draft, _)| kind == GapKind::MissingAffordance && gap["from"] == "draft" && **draft == gap["draft"]) {
|
||||
match made {
|
||||
Some(at) => {
|
||||
if let Part::Amended { promise, .. } = &mut outcome.parts[*at] {
|
||||
*promise = true;
|
||||
if let Part::Amended { unbacked, .. } = &mut outcome.parts[*at] {
|
||||
*unbacked = true;
|
||||
}
|
||||
}
|
||||
None => outcome.omitted.push(format!("a promise in an addition that was not made: {}", gap["words"])),
|
||||
None => outcome.omitted.push(format!("a reach in an addition that was not made: {}", gap["words"])),
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -425,18 +368,18 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
_ => None,
|
||||
};
|
||||
let sent = match ("e, words(&gap["words"])) {
|
||||
(Some(Quote::Wrote(_)), Some(text)) if kind == GapKind::MissingAffordance => (0..receipts.len()).find(|at| receipts[*at].text == text && !promised.contains(at)),
|
||||
(Some(Quote::Wrote(_)), Some(text)) if kind == GapKind::MissingAffordance => (0..receipts.len()).find(|at| receipts[*at].text == text && !unbacked.contains(at)),
|
||||
_ => None,
|
||||
};
|
||||
// A promise in a line the decision said and no receipt shows went out: whether it reached the room is unknown, so
|
||||
// A reach in a line the decision said and no receipt shows went out: whether it reached the room is unknown, so
|
||||
// she is told neither that nothing happened nor that it did (I16.10), as the line itself is not told.
|
||||
let unreceipted = |text: &str| decision["said"].as_array().into_iter().flatten().any(|line| line["text"].as_str() == Some(text));
|
||||
match (quote, sent) {
|
||||
(_, Some(at)) => {
|
||||
promised.push(at);
|
||||
outcome.parts.push(Part::Promise { room: receipts[at].room.clone(), text: Words::new(receipts[at].text.clone()) });
|
||||
unbacked.push(at);
|
||||
outcome.parts.push(Part::SaidUnbacked { room: receipts[at].room.clone(), text: Words::new(receipts[at].text.clone()) });
|
||||
}
|
||||
(Some(Quote::Wrote(_)), None) if kind == GapKind::MissingAffordance && words(&gap["words"]).is_some_and(|text| unreceipted(&text)) => outcome.omitted.push(format!("a promise in a line said with no receipt that it went out: {}", gap["words"])),
|
||||
(Some(Quote::Wrote(_)), None) if kind == GapKind::MissingAffordance && words(&gap["words"]).is_some_and(|text| unreceipted(&text)) => outcome.omitted.push(format!("a reach in a line said with no receipt that it went out: {}", gap["words"])),
|
||||
(Some(quote @ (Quote::Wrote(_) | Quote::Sent)), None) if kind == GapKind::MissingAffordance => reaching.push((&gap["draft"], quote)),
|
||||
(Some(quote), None) if kind != GapKind::Unresolved => {
|
||||
if matches!(quote, Quote::Wrote(_) | Quote::Sent) {
|
||||
|
|
@ -447,7 +390,7 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
_ => outcome.omitted.push(format!("a gap she cannot be shown truly (kind {}, from {}): {}", gap["kind"], gap["from"], gap["quote"])),
|
||||
}
|
||||
}
|
||||
for (_, posted) in receipts.iter().enumerate().filter(|(at, _)| !promised.contains(at)) {
|
||||
for (_, posted) in receipts.iter().enumerate().filter(|(at, _)| !unbacked.contains(at)) {
|
||||
outcome.parts.push(Part::Said { room: posted.room.clone(), text: Words::new(posted.text.clone()) });
|
||||
}
|
||||
// A note is recorded by the record that holds it: the turn's record is Self's inbox.
|
||||
|
|
@ -498,60 +441,6 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
None => outcome.parts.push(Part::Gap { kind: GapKind::MissingAffordance, room: room.clone(), quote, reach: false }),
|
||||
}
|
||||
}
|
||||
// What the commit did with her promises (`commit::apply`): each close it applied, and each close it refused for a
|
||||
// reason she can be told. An open is told by the promise's own section from her next packet on.
|
||||
for done in record["committed"]["closed"].as_array().into_iter().flatten() {
|
||||
let (Ok(how), Some(words)) = (serde_json::from_value::<How>(done["how"].clone()), words_of(&done["entry"]["words"])) else {
|
||||
outcome.omitted.push(format!("a close without its kind or words: {done}"));
|
||||
continue;
|
||||
};
|
||||
// A promise to the room has no `to`.
|
||||
let to = done["entry"]["to"].as_str().and_then(|_| person(&done["to_name"], &done["entry"]["to"]));
|
||||
outcome.parts.push(Part::Closed { how, to, words, room: done["entry"]["room"].as_str().unwrap_or_default().to_owned(), by: person(&done["by"], &done["by_id"]) });
|
||||
}
|
||||
for refused in record["committed"]["refused"].as_array().into_iter().flatten() {
|
||||
let listed = decision["promises"].as_array().into_iter().flatten().find(|listed| listed["id"] == refused["proposal"]["promise"]);
|
||||
match (serde_json::from_value::<StateRefusal>(refused["reason"].clone()), listed) {
|
||||
(
|
||||
Ok(
|
||||
reason @ (StateRefusal::DraftNotSent
|
||||
| StateRefusal::BlockedNotKeepable
|
||||
| StateRefusal::ReleaseNotByPromisee
|
||||
| StateRefusal::ReleaseBeforePromise
|
||||
| StateRefusal::CloseUnquoted
|
||||
| StateRefusal::CloseContradicted
|
||||
| StateRefusal::NeedsUnread
|
||||
| StateRefusal::NeedsMalformed
|
||||
| StateRefusal::NotWherePromised
|
||||
| StateRefusal::OutsidePutChanged),
|
||||
),
|
||||
Some(listed),
|
||||
) if refused["proposal"]["kind"] == "promise_close" => {
|
||||
let read = match serde_json::from_value::<Needs>(listed["needs"].clone()) {
|
||||
Ok(Needs::Read { request }) => Some(ReadName::of(&request)),
|
||||
_ => None,
|
||||
};
|
||||
let status = if listed["status"] == "blocked" { Status::Blocked } else { Status::Open };
|
||||
let to = listed["to"].as_str().and_then(|_| person(&listed["to_name"], &listed["to"]));
|
||||
outcome.parts.push(Part::StillOpen { reason, to, words: Words::new(listed["words"].as_str().unwrap_or_default().to_owned()), status, read });
|
||||
}
|
||||
_ => outcome.omitted.push(format!("a state change the commit refused that she is not told ({}): {}", refused["reason"], refused["proposal"])),
|
||||
}
|
||||
}
|
||||
// Each act her line said she was doing now that nothing in her turn did (K61): the commit opened it as her promise, and
|
||||
// she is told so once, here; it is in her promises from her next packet on. Whom it is to is named as a line of theirs
|
||||
// listed to the Interpreter names them, else as the Projector would.
|
||||
for opened in record["committed"]["now_opened"].as_array().into_iter().flatten() {
|
||||
let Some(promised) = words_of(&opened["words"]) else {
|
||||
outcome.omitted.push(format!("a promise opened from an act stated as under way, without its words: {opened}"));
|
||||
continue;
|
||||
};
|
||||
let to = opened["to"].as_str().map(|id| {
|
||||
let listed = decision["lines"].as_array().into_iter().flatten().find(|line| line["sender"].as_str() == Some(id)).and_then(|line| words(&line["who"]));
|
||||
Person::new(listed.unwrap_or_else(|| who_of(id, names).to_string()), who_of(id, names))
|
||||
});
|
||||
outcome.parts.push(Part::NowUndone { to, words: promised });
|
||||
}
|
||||
if words(&record["broke_after"]).is_some() {
|
||||
outcome.parts.push(Part::BrokeAfter { room });
|
||||
}
|
||||
|
|
@ -564,7 +453,7 @@ pub(crate) fn outcome_of(record: &Value, names: &Names) -> Option<Outcome> {
|
|||
/// The one owner of "reached" (K49, I16.10): every row that says words of hers did not reach a room is checked against
|
||||
/// the receipts, by the row's own room and text, here and nowhere else. A posted line there, or an addition there whose
|
||||
/// `edited` receipt has no refusal, means her words reached it, so the row would be false: it is omitted and reported.
|
||||
/// Rows that are receipts (`Said`, `Promise`, `Amended`) are untouched.
|
||||
/// Rows that are receipts (`Said`, `SaidUnbacked`, `Amended`) are untouched.
|
||||
fn settle(outcome: &mut Outcome, receipts: &[Posted], record: &Value) {
|
||||
let added = |room: &str, text: &Words| {
|
||||
record["interpreter"]["amended"].as_array().into_iter().flatten().any(|amended| {
|
||||
|
|
@ -630,14 +519,14 @@ impl Part {
|
|||
}
|
||||
}
|
||||
|
||||
/// Where the part falls in what she is told (16.20.5): what broke, then what did not happen, then promises, then what
|
||||
/// Where the part falls in what she is told (16.20.5): what broke, then what did not happen, then what her body cannot do, then what
|
||||
/// reached the room, then a later step that broke.
|
||||
fn rank(&self) -> u8 {
|
||||
match self {
|
||||
Self::Failed => 0,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::Declined { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::NowUndone { .. } | Self::StillOpen { .. } | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1,
|
||||
Self::Promise { .. } | Self::Amended { promise: true, .. } => 2,
|
||||
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) | Self::Closed { .. } | Self::Read { .. } => 3,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::Declined { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::ReadFailed { .. } | Self::ReadRefused { .. } => 1,
|
||||
Self::SaidUnbacked { .. } | Self::Amended { unbacked: true, .. } => 2,
|
||||
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) | Self::Read { .. } => 3,
|
||||
Self::BrokeAfter { .. } => 4,
|
||||
}
|
||||
}
|
||||
|
|
@ -648,13 +537,10 @@ impl Part {
|
|||
/// None and the row's sentence without them (`Event`). Each row writes both, so no sentence has a second author (map
|
||||
/// 16.29.10).
|
||||
fn reached(&self, her: Forms, form: Form) -> String {
|
||||
let Forms { subj, cap_subj, obj, poss, be, .. } = her;
|
||||
let Forms { subj, cap_subj, obj, poss, .. } = her;
|
||||
let place = |room: &Option<String>| room.clone().unwrap_or_else(|| "the room".to_owned());
|
||||
// Whom a promise was to, the room when no one; who asked or let her off, someone when the record names no one.
|
||||
let to = |to: &Option<Person>| to.as_ref().map_or_else(|| "the room".to_owned(), |to| form.person(to));
|
||||
let who = |who: &Option<Person>| who.as_ref().map_or_else(|| "someone".to_owned(), |who| form.person(who));
|
||||
match self {
|
||||
Self::Said { room, text } | Self::Promise { room, text } => match form.words(text) {
|
||||
Self::Said { room, text } | Self::SaidUnbacked { room, text } => match form.words(text) {
|
||||
Some(quote) => format!("{} has, from {obj}: {quote}.", capitalized(room)),
|
||||
None => format!("{} has a line from {obj}.", capitalized(room)),
|
||||
},
|
||||
|
|
@ -677,19 +563,6 @@ impl Part {
|
|||
Self::NoteRefused(_) => "No note was left:".to_owned(),
|
||||
Self::Failed => format!("Nothing reached the room, and nothing {subj} meant last time happened:"),
|
||||
Self::BrokeAfter { room } => format!("Nothing more reached {}:", place(room)),
|
||||
Self::Closed { how: How::Released, by, to: promisee, words, .. } => match form.words(words) {
|
||||
Some(quote) => format!("{} let {obj} off {poss} promise: {quote}.", who(by)),
|
||||
None => format!("{} let {obj} off {poss} promise to {}.", who(by), to(promisee)),
|
||||
},
|
||||
Self::Closed { to: promisee, words, .. } => match form.words(words) {
|
||||
Some(quote) => format!("{} promise to {}, {quote}, is closed:", capitalized(poss), to(promisee)),
|
||||
None => format!("{} promise to {} is closed:", capitalized(poss), to(promisee)),
|
||||
},
|
||||
Self::NowUndone { .. } => format!("{cap_subj} said {subj} {} doing it now, and nothing in {poss} turn did it;", if be == "is" { "was" } else { "were" }),
|
||||
Self::StillOpen { to: promisee, words, status, .. } => match form.words(words) {
|
||||
Some(quote) => format!("{} record still shows {poss} promise to {}, {quote}, {status}:", capitalized(poss), to(promisee)),
|
||||
None => format!("{} record still shows {poss} promise to {} as {status}:", capitalized(poss), to(promisee)),
|
||||
},
|
||||
Self::Read { what } => format!("{cap_subj} read {}.", form.read(what, her)),
|
||||
Self::ReadFailed { what, .. } => format!("{cap_subj} reached for {} and could not read it:", form.read(what, her)),
|
||||
Self::ReadRefused { what: Some(what), why: ReadRefusal::InView } => format!("{cap_subj} already read {} earlier in this conversation.", form.read(what, her)),
|
||||
|
|
@ -720,9 +593,9 @@ impl Part {
|
|||
};
|
||||
match self {
|
||||
Self::Said { .. } => String::new(),
|
||||
Self::Amended { promise: false, .. } => " The rest of the line is as it was.".to_owned(),
|
||||
Self::Amended { promise: true, .. } => format!(" The rest of the line is as it was. What {subj} added promises something {subj} {has} no way to do, now or later, and it will not happen by itself."),
|
||||
Self::Promise { .. } => format!(" It promises something {subj} {has} no way to do, now or later, and it will not happen by itself. The line stands as {subj} wrote it; {subj} can add to it."),
|
||||
Self::Amended { unbacked: false, .. } => " The rest of the line is as it was.".to_owned(),
|
||||
Self::Amended { unbacked: true, .. } => format!(" The rest of the line is as it was. What {subj} added promises something {subj} {has} no way to do, now or later, and it will not happen by itself."),
|
||||
Self::SaidUnbacked { .. } => format!(" It promises something {subj} {has} no way to do, now or later, and it will not happen by itself. The line stands as {subj} wrote it; {subj} can add to it."),
|
||||
Self::NoteLeft(_) => format!(" It waits in Self's inbox until Self reads it; nothing tells {obj} when, and nothing in it happens by itself."),
|
||||
Self::Refused { reason: Refusal::Echo, .. } => format!(" What {subj} wrote was mostly the words {subj} had just been sent, so none of it was sent.{reach}"),
|
||||
Self::Refused { reason: Refusal::NoRoom, text, .. } => format!(" That turn had no room for {obj} to speak in, so it was not sent.{}", drafted(text)),
|
||||
|
|
@ -753,30 +626,6 @@ impl Part {
|
|||
Self::NoteRefused(Refusal::SecondNote) => " one a turn.".to_owned(),
|
||||
Self::NoteRefused(_) => format!(" it carried something {subj} may not pass on."),
|
||||
Self::Failed => format!(" the turn broke off, not by {poss} choice."),
|
||||
Self::Closed { how: How::Kept, .. } => format!(" {subj} kept it."),
|
||||
Self::Closed { how: How::Withdrawn, room, .. } => format!(" {subj} withdrew it in {room}."),
|
||||
Self::Closed { how: How::Released, .. } => " It is closed.".to_owned(),
|
||||
Self::NowUndone { to: promisee, words } => {
|
||||
let to = promisee.as_ref().map_or_else(|| "the room".to_owned(), |to| form.person(to));
|
||||
match form.words(words) {
|
||||
Some(quote) => format!(" it is open as {poss} promise to {to}: {quote}."),
|
||||
None => format!(" it is open as {poss} promise to {to}."),
|
||||
}
|
||||
}
|
||||
Self::StillOpen { reason: StateRefusal::DraftNotSent, .. } => format!(" what {subj} meant to close it with did not go out."),
|
||||
Self::StillOpen { reason: StateRefusal::BlockedNotKeepable, .. } => format!(" {subj} {has} no way to do it, so it was not kept."),
|
||||
Self::StillOpen { reason: StateRefusal::ReleaseNotByPromisee, .. } => format!(" the line read as letting {obj} off it was not from the person {subj} promised."),
|
||||
Self::StillOpen { reason: StateRefusal::ReleaseBeforePromise, .. } => format!(" the line read as letting {obj} off it came before {subj} made it."),
|
||||
Self::StillOpen { reason: StateRefusal::CloseContradicted, .. } => format!(" {poss} own thought held it as still owed, so it was not closed."),
|
||||
Self::StillOpen { reason: StateRefusal::CloseUnquoted, .. } => format!(" no words of {poss} own thought that turn, outside what {subj} wrote to send, took the close up, so it was not closed."),
|
||||
Self::StillOpen { reason: StateRefusal::NeedsUnread, read, .. } => match read {
|
||||
Some(read) if read.search() => format!(" keeping it needs {obj} to read what {} finds, and a search reads none of what it finds, so it was not kept.", form.read(read, her)),
|
||||
Some(read) => format!(" keeping it needs {obj} to read {}, and no read of it had come back to {obj} before {subj} wrote that line, so it was not kept.", form.read(read, her)),
|
||||
None => format!(" keeping it needs a read, and none had come back to {obj} before {subj} wrote that line, so it was not kept."),
|
||||
},
|
||||
Self::StillOpen { reason: StateRefusal::NeedsMalformed, .. } => format!(" what keeping it needs was never recorded plainly, so it cannot be kept; {subj} can withdraw it."),
|
||||
Self::StillOpen { reason: StateRefusal::NotWherePromised, .. } => format!(" what {subj} said to close it was not where the person {subj} promised could read it."),
|
||||
Self::StillOpen { .. } => format!(" it was changed outside {poss} turn, and stands as it was changed."),
|
||||
Self::BrokeAfter { .. } => format!(" the rest of that turn broke off, not by {poss} choice."),
|
||||
Self::Read { .. } => String::new(),
|
||||
Self::ReadFailed { failure, .. } => format!(" {}.", failure.words()),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn record(prose: &str, answer: Value, posted: &[&str]) -> Value {
|
|||
|
||||
/// What Heimdall (he/him) is told of `record`, and what is omitted.
|
||||
fn told(record: &Value) -> (Vec<String>, Vec<String>) {
|
||||
let outcome = outcome_of(record, &crate::projection::select::Names::none()).expect("a record");
|
||||
let outcome = outcome_of(record).expect("a record");
|
||||
(outcome.lines(packet().forms), outcome.omitted)
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ fn a_promise_in_a_said_line_with_no_matching_receipt_is_not_told_as_nothing_happ
|
|||
let promise = |posted: Value| json!({ "interpreter": { "heard": [], "room": MINDS, "said": [{ "room": MINDS, "text": text }], "refused": [], "gaps": [{ "kind": "missing_affordance", "from": "draft", "draft": 1, "words": text }] }, "posted": posted });
|
||||
let (lines, omitted) = told(&promise(json!([{ "event": "40", "room": MINDS, "text": "I'll send it tonight!" }])));
|
||||
assert_eq!(lines, ["- #minds:gamecult.org has, from him: \"I'll send it tonight!\"."], "the receipt alone");
|
||||
assert!(omitted.len() == 2 && omitted[1].starts_with("a promise in a line said with no receipt"), "{omitted:?}");
|
||||
assert!(omitted.len() == 2 && omitted[1].starts_with("a reach in a line said with no receipt"), "{omitted:?}");
|
||||
let (lines, omitted) = told(&promise(json!([])));
|
||||
assert!(lines.is_empty() && omitted.len() == 2, "{lines:?} {omitted:?}");
|
||||
}
|
||||
|
|
@ -114,9 +114,9 @@ fn a_record_that_failed_and_carries_receipts_is_malformed_told_nothing_and_repor
|
|||
|
||||
#[test]
|
||||
fn a_chosen_silence_tells_him_nothing_and_no_record_is_no_outcome() {
|
||||
let silent = outcome_of(&record("The quiet is fine. I let it be.", json!({ "say": [], "gaps": [] }), &[]), &crate::projection::select::Names::none()).unwrap();
|
||||
let silent = outcome_of(&record("The quiet is fine. I let it be.", json!({ "say": [], "gaps": [] }), &[])).unwrap();
|
||||
assert_eq!((silent.len(), silent.omitted.len()), (0, 0));
|
||||
assert_eq!(outcome_of(&Value::Null, &crate::projection::select::Names::none()), None);
|
||||
assert_eq!(outcome_of(&Value::Null), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -128,7 +128,7 @@ fn a_line_said_with_no_receipt_is_not_told_as_said() {
|
|||
|
||||
#[test]
|
||||
fn the_table_speaks_of_her_in_her_own_pronouns() {
|
||||
let outcome = outcome_of(&record("<typed>Hi.</typed> <typed>There.</typed> <typed>Again.</typed>", json!({ "say": [{ "draft": 1 }, { "draft": 2 }, { "draft": 3 }], "gaps": [] }), &["Hi.", "There."]), &crate::projection::select::Names::none()).unwrap();
|
||||
let outcome = outcome_of(&record("<typed>Hi.</typed> <typed>There.</typed> <typed>Again.</typed>", json!({ "say": [{ "draft": 1 }, { "draft": 2 }, { "draft": 3 }], "gaps": [] }), &["Hi.", "There."])).unwrap();
|
||||
for (pronouns, line) in [("she/her", "she had already sent two lines"), ("any", "they had already sent two lines")] {
|
||||
let her = crate::projection::select::forms(&json!({ "presentation": { "pronouns": pronouns } }));
|
||||
assert!(outcome.lines(her)[0].contains(line), "{pronouns}: {:?}", outcome.lines(her));
|
||||
|
|
@ -239,14 +239,14 @@ fn i16_10_every_lines_first_clause_is_what_its_receipt_says_reached_the_room() {
|
|||
let her = packet().forms;
|
||||
let mut rows = 0;
|
||||
for record in every_row() {
|
||||
let outcome = outcome_of(&record, &crate::projection::select::Names::none()).unwrap();
|
||||
let outcome = outcome_of(&record).unwrap();
|
||||
for part in &outcome.parts {
|
||||
for (form, rendered) in [("told", Form::Told(usize::MAX)), ("event", Form::Event(&[]))] {
|
||||
let (reached, rest) = (part.reached(her, rendered), part.rest(her, rendered));
|
||||
let line = if form == "told" { part.told(her, usize::MAX) } else { part.event(her, &[]) };
|
||||
assert_eq!(line, format!("- {reached}{rest}"), "{form}: {part:?}");
|
||||
// "{Room} has" only on a receipt that a line went out or was added to.
|
||||
let receipt = matches!(part, Part::Said { .. } | Part::Promise { .. } | Part::Amended { .. });
|
||||
let receipt = matches!(part, Part::Said { .. } | Part::SaidUnbacked { .. } | Part::Amended { .. });
|
||||
assert_eq!(reached.starts_with("#minds:gamecult.org has"), receipt, "{form}: {part:?}: {reached}");
|
||||
assert!(receipt || matches!(part, Part::NoteLeft(_)) || reached.starts_with("Nothing") || reached.starts_with("No "), "{form}: {part:?}: {reached}");
|
||||
for claim in ["Nothing reached", "reached the room", "reached anyone", " has, from", " has a line", "now ending with", "now added to", "went out"] {
|
||||
|
|
@ -264,7 +264,7 @@ fn no_row_says_as_her_own_recorded_as_queued_or_landed() {
|
|||
for pronouns in ["she/her", "he/him", "any"] {
|
||||
let her = crate::projection::select::forms(&json!({ "presentation": { "pronouns": pronouns } }));
|
||||
for record in every_row() {
|
||||
for line in outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(her) {
|
||||
for line in outcome_of(&record).unwrap().lines(her) {
|
||||
for banned in ["as her own", "as his own", "as their own", "recorded as", "queue", "landed"] {
|
||||
assert!(!line.contains(banned), "{pronouns}: {banned} in {line}");
|
||||
}
|
||||
|
|
@ -294,34 +294,6 @@ fn k43_her_words_are_told_verbatim_whatever_the_record_heard() {
|
|||
// ---------------------------------------------------------------------------------------------
|
||||
// K33 (map 16.26): a refused close and a declined draft are told, by the fixed table.
|
||||
|
||||
/// L1: each refused close she can correct is told as her record still showing the promise, and why; L4: a declined draft
|
||||
/// is told as not sent.
|
||||
#[test]
|
||||
fn k33_a_refused_close_and_a_declined_draft_are_told() {
|
||||
let listed = json!([
|
||||
{ "id": "c1", "entry": "e1", "status": "open", "to": "@deru:gamecult.org", "to_name": "Deru", "words": "I'll read it properly.", "needs": { "kind": "read", "request": { "kind": "web", "target": "https://ccrma.stanford.edu/~jos/pasp/" } } },
|
||||
{ "id": "c2", "entry": "e2", "status": "open", "to": "@meta:gamecult.org", "to_name": "Meta", "words": "I'll look at #125.", "needs": null },
|
||||
]);
|
||||
let refused = |promise: &str, reason: &str| json!({ "proposal": { "kind": "promise_close", "promise": promise, "how": "kept", "evidence": { "draft": 1 } }, "reason": reason });
|
||||
let record = json!({
|
||||
"interpreter": { "said": [], "refused": [], "gaps": [], "heard": [], "room": MINDS, "promises": listed, "unsent": [{ "draft": 2, "how": "declined", "quote": "I hold that one back", "words": "Deru, the waveguide part first." }, { "draft": 3, "how": "superseded", "quote": "later words", "words": "Deru, never mind." }] },
|
||||
"posted": [],
|
||||
"committed": { "closed": [], "refused": [refused("c1", "close_unquoted"), refused("c1", "needs_unread"), refused("c2", "needs_malformed"), refused("c2", "close_contradicted")] }
|
||||
});
|
||||
let (lines, omitted) = told(&record);
|
||||
assert_eq!(
|
||||
lines,
|
||||
[
|
||||
"- Nothing of this reached #minds:gamecult.org: he chose not to send it. In his thought: \"I hold that one back\". He had drafted: \"Deru, the waveguide part first.\".",
|
||||
"- His record still shows his promise to Deru, \"I'll read it properly.\", open: no words of his own thought that turn, outside what he wrote to send, took the close up, so it was not closed.",
|
||||
"- His record still shows his promise to Deru, \"I'll read it properly.\", open: keeping it needs him to read https://ccrma.stanford.edu/~jos/pasp/, and no read of it had come back to him before he wrote that line, so it was not kept.",
|
||||
"- His record still shows his promise to Meta, \"I'll look at #125.\", open: what keeping it needs was never recorded plainly, so it cannot be kept; he can withdraw it.",
|
||||
"- His record still shows his promise to Meta, \"I'll look at #125.\", open: his own thought held it as still owed, so it was not closed.",
|
||||
],
|
||||
"{omitted:?}"
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K49 (map 16.30.6): "reached" is derived once, by `settle`, for every row kind with words.
|
||||
|
||||
|
|
@ -337,12 +309,12 @@ fn posted_as_said(decision: &Value) -> Vec<Value> {
|
|||
#[test]
|
||||
fn k49_p4_a_gap_on_words_that_went_out_is_not_told() {
|
||||
let prose = "<typed>Morning, all of you.</typed> <typed>Morning, all of you.</typed>";
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 2, "mentions": [], "in_reply_to": null, "promises": [] }], "gaps": [{ "kind": "addressee", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
let outcome = outcome_of(&json!({ "interpreter": decision, "posted": posted_as_said(&decision), "edited": [] }), &crate::projection::select::Names::none()).unwrap();
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 2, "mentions": [], "in_reply_to": null }], "gaps": [{ "kind": "addressee", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
let outcome = outcome_of(&json!({ "interpreter": decision, "posted": posted_as_said(&decision), "edited": [] })).unwrap();
|
||||
assert_eq!(outcome.lines(packet().forms), ["- #minds:gamecult.org has, from him: \"Morning, all of you.\"."]);
|
||||
assert!(outcome.omitted.iter().any(|why| why == "a gap of words a receipt shows reached #minds:gamecult.org: Morning, all of you."), "{:?}", outcome.omitted);
|
||||
// Negative: with no receipt, the gap is told.
|
||||
let unposted = outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] }), &crate::projection::select::Names::none()).unwrap().lines(packet().forms);
|
||||
let unposted = outcome_of(&json!({ "interpreter": decision, "posted": [], "edited": [] })).unwrap().lines(packet().forms);
|
||||
assert!(unposted.iter().any(|line| line.starts_with("- Nothing reached anyone.")), "{unposted:?}");
|
||||
}
|
||||
|
||||
|
|
@ -361,22 +333,22 @@ fn declined_and_added(text: &str, edited: Value, posted: Value) -> Value {
|
|||
}
|
||||
|
||||
fn declined_told(record: &Value) -> bool {
|
||||
outcome_of(record, &crate::projection::select::Names::none()).unwrap().lines(packet().forms).iter().any(|line| line.contains("he chose not to send it"))
|
||||
outcome_of(record).unwrap().lines(packet().forms).iter().any(|line| line.contains("he chose not to send it"))
|
||||
}
|
||||
|
||||
/// Mutant k44-reached-ignores-addition: an addition the actuator made is a receipt that her words reached the room.
|
||||
#[test]
|
||||
fn k49_an_addition_receipt_counts_as_reached() {
|
||||
let record = declined_and_added("Sent at nine.", json!([{ "event": "$ev-1", "refusal": null }]), json!([]));
|
||||
assert!(!declined_told(&record), "{:?}", outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(packet().forms));
|
||||
assert!(outcome_of(&record, &crate::projection::select::Names::none()).unwrap().omitted.iter().any(|why| why == "a declined draft of words a receipt shows reached #minds:gamecult.org: Sent at nine."));
|
||||
assert!(!declined_told(&record), "{:?}", outcome_of(&record).unwrap().lines(packet().forms));
|
||||
assert!(outcome_of(&record).unwrap().omitted.iter().any(|why| why == "a declined draft of words a receipt shows reached #minds:gamecult.org: Sent at nine."));
|
||||
}
|
||||
|
||||
/// Mutant k44-reached-any-room: a line posted in another room is no receipt for this one.
|
||||
#[test]
|
||||
fn k49_a_receipt_in_another_room_does_not_count() {
|
||||
let elsewhere = declined_and_added("Sent at nine.", json!([]), json!([{ "event": "40", "room": SWARM, "text": "Sent at nine." }]));
|
||||
assert!(declined_told(&elsewhere), "{:?}", outcome_of(&elsewhere, &crate::projection::select::Names::none()).unwrap().lines(packet().forms));
|
||||
assert!(declined_told(&elsewhere), "{:?}", outcome_of(&elsewhere).unwrap().lines(packet().forms));
|
||||
let here = declined_and_added("Sent at nine.", json!([]), json!([{ "event": "40", "room": MINDS, "text": "Sent at nine." }]));
|
||||
assert!(!declined_told(&here), "the same receipt in #minds counts");
|
||||
}
|
||||
|
|
@ -386,7 +358,7 @@ fn k49_a_receipt_in_another_room_does_not_count() {
|
|||
fn k49_an_addition_the_actuator_refused_did_not_reach() {
|
||||
for edited in [json!([{ "event": "$ev-1", "refusal": "too_long" }]), json!([{ "event": "$ev-2", "refusal": null }]), json!([])] {
|
||||
let record = declined_and_added("Sent at nine.", edited.clone(), json!([]));
|
||||
assert!(declined_told(&record), "{edited}: {:?}", outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(packet().forms));
|
||||
assert!(declined_told(&record), "{edited}: {:?}", outcome_of(&record).unwrap().lines(packet().forms));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -411,7 +383,7 @@ fn k49_every_row_with_words_is_settled_by_its_room() {
|
|||
("unmade addition", decision(json!({ "refused": [{ "reason": "not_amendable", "text": SENTINEL, "draft": 1 }] }))),
|
||||
];
|
||||
for (row, decision) in rows {
|
||||
let at = |room: &str| outcome_of(&json!({ "interpreter": decision, "posted": [{ "event": "40", "room": room, "text": SENTINEL }], "edited": [] }), &crate::projection::select::Names::none()).unwrap();
|
||||
let at = |room: &str| outcome_of(&json!({ "interpreter": decision, "posted": [{ "event": "40", "room": room, "text": SENTINEL }], "edited": [] })).unwrap();
|
||||
let here = at(MINDS);
|
||||
let not_reached = |outcome: &Outcome| outcome.lines(packet().forms).into_iter().filter(|line| line.starts_with("- Nothing")).count();
|
||||
assert_eq!(not_reached(&here), 0, "{row}: {:?}", here.lines(packet().forms));
|
||||
|
|
@ -438,7 +410,7 @@ fn k49_reached_is_decided_once() {
|
|||
fn variant(part: &Part) -> &'static str {
|
||||
match part {
|
||||
Part::Said { .. } => "said",
|
||||
Part::Promise { .. } => "promise",
|
||||
Part::SaidUnbacked { .. } => "said_unbacked",
|
||||
Part::Refused { .. } => "refused",
|
||||
Part::Gap { .. } => "gap",
|
||||
Part::Unfinished { .. } => "unfinished",
|
||||
|
|
@ -448,9 +420,6 @@ fn variant(part: &Part) -> &'static str {
|
|||
Part::NoteRefused(_) => "note_refused",
|
||||
Part::Failed => "failed",
|
||||
Part::BrokeAfter { .. } => "broke_after",
|
||||
Part::Closed { .. } => "closed",
|
||||
Part::StillOpen { .. } => "still_open",
|
||||
Part::NowUndone { .. } => "now_undone",
|
||||
Part::Declined { .. } => "declined",
|
||||
Part::Read { .. } => "read",
|
||||
Part::ReadFailed { .. } => "read_failed",
|
||||
|
|
@ -458,34 +427,17 @@ fn variant(part: &Part) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
const VARIANTS: usize = 18;
|
||||
|
||||
const STRANGER: &str = "@stranger:example.org";
|
||||
|
||||
/// A person a row names (K53): the record's name, as `name_of` renders someone unbonded who spoke in the room under
|
||||
/// `display`; and `who_of` over that room, she bound to them when `label` is some.
|
||||
fn person(display: &str, label: Option<&str>) -> Person {
|
||||
use crate::projection::select::{Names, People, Room, RoomLine, spoken, who_of};
|
||||
let state = label.map_or_else(|| json!({}), |label| json!({ "affect": { "socialBonds": [{ "id": "bond-them", "status": "active", "object": { "id": STRANGER, "kind": "person", "label": label } }] } }));
|
||||
let room = Room { messages: vec![RoomLine { room: MINDS.into(), sender: STRANGER.into(), display: display.into(), text: "hi".into(), ..RoomLine::default() }], ..Room::default() };
|
||||
let names = Names { state: &state, people: People { operators: &[], minds: &[], own_sender: "@heimdall:gamecult.org" }, room: &room };
|
||||
Person::new(format!("{} ({STRANGER})", spoken(display)), who_of(STRANGER, &names))
|
||||
}
|
||||
|
||||
/// Meta, as a bonded person's label names them: no quote marks in the Projector's form.
|
||||
fn meta() -> Person {
|
||||
person("Meta", Some("Meta"))
|
||||
}
|
||||
const VARIANTS: usize = 15;
|
||||
|
||||
/// Every row kind, and every arm that renders a different sentence, with `s` in every text of a record it carries and in
|
||||
/// every read's target, and `who` in every person slot; and whether her told form shows those words (an echo, a held
|
||||
/// every read's target; and whether her told form shows those words (an echo, a held
|
||||
/// draft, a pull request or commit read and a read of her own mind show none, by design).
|
||||
fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
||||
fn fixtures(s: &str) -> Vec<(Part, bool)> {
|
||||
let w = || Words::new(format!("{s} at the door"));
|
||||
let room = || Some(MINDS.to_owned());
|
||||
let web = || ReadName::of(&ReadRequest::Web(format!("https://example.org/{s}")));
|
||||
let search = || ReadName::of(&ReadRequest::Repo(format!("GameCult/Bifrost?q={s} plover")));
|
||||
let mut out: Vec<(Part, bool)> = vec![(Part::Said { room: MINDS.into(), text: w() }, true), (Part::Promise { room: MINDS.into(), text: w() }, true)];
|
||||
let mut out: Vec<(Part, bool)> = vec![(Part::Said { room: MINDS.into(), text: w() }, true), (Part::SaidUnbacked { room: MINDS.into(), text: w() }, true)];
|
||||
for reason in [Refusal::OverLines, Refusal::NoRoom, Refusal::NotQuotable, Refusal::SecondAmend] {
|
||||
out.push((Part::Refused { reason, room: room(), text: w(), reach: false }, true));
|
||||
out.push((Part::Refused { reason, room: room(), text: w(), reach: true }, true));
|
||||
|
|
@ -501,8 +453,8 @@ fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
|||
for by_limit in [false, true] {
|
||||
out.push((Part::Unfinished { room: room(), text: w(), by_limit }, true));
|
||||
}
|
||||
for promise in [false, true] {
|
||||
out.push((Part::Amended { room: MINDS.into(), added: w(), promise }, true));
|
||||
for unbacked in [false, true] {
|
||||
out.push((Part::Amended { room: MINDS.into(), added: w(), unbacked }, true));
|
||||
}
|
||||
for refusal in [None, Some(EditRefusal::NotFound), Some(EditRefusal::NotHers), Some(EditRefusal::TooLong)] {
|
||||
out.push((Part::NotAmended { refusal, room: room(), added: w(), reach: false }, true));
|
||||
|
|
@ -512,29 +464,6 @@ fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
|||
out.push((Part::NoteRefused(Refusal::SecondNote), false));
|
||||
out.push((Part::Failed, false));
|
||||
out.push((Part::BrokeAfter { room: room() }, false));
|
||||
for how in [How::Kept, How::Withdrawn, How::Released] {
|
||||
out.push((Part::Closed { how, to: Some(who.clone()), words: w(), room: MINDS.into(), by: Some(who.clone()) }, true));
|
||||
}
|
||||
for (reason, read) in [
|
||||
(StateRefusal::DraftNotSent, None),
|
||||
(StateRefusal::BlockedNotKeepable, None),
|
||||
(StateRefusal::ReleaseNotByPromisee, None),
|
||||
(StateRefusal::ReleaseBeforePromise, None),
|
||||
(StateRefusal::CloseContradicted, None),
|
||||
(StateRefusal::CloseUnquoted, None),
|
||||
(StateRefusal::NeedsUnread, Some(search())),
|
||||
(StateRefusal::NeedsUnread, Some(web())),
|
||||
(StateRefusal::NeedsUnread, None),
|
||||
(StateRefusal::NeedsMalformed, None),
|
||||
(StateRefusal::NotWherePromised, None),
|
||||
(StateRefusal::OutsidePutChanged, None),
|
||||
] {
|
||||
for status in [Status::Open, Status::Blocked] {
|
||||
out.push((Part::StillOpen { reason, to: Some(who.clone()), words: w(), status, read: read.clone() }, true));
|
||||
}
|
||||
}
|
||||
out.push((Part::NowUndone { to: Some(who.clone()), words: w() }, true));
|
||||
out.push((Part::NowUndone { to: None, words: w() }, true));
|
||||
out.push((Part::Declined { room: room(), text: w(), thought: w(), reach: false }, true));
|
||||
out.push((Part::Declined { room: room(), text: w(), thought: w(), reach: true }, true));
|
||||
for (request, shows) in [
|
||||
|
|
@ -563,7 +492,7 @@ fn fixtures(s: &str, who: &Person) -> Vec<(Part, bool)> {
|
|||
#[test]
|
||||
fn k46_every_part_has_an_event_without_its_words() {
|
||||
const S: &str = "ospreyledger";
|
||||
let parts = fixtures(S, &meta());
|
||||
let parts = fixtures(S);
|
||||
let kinds: std::collections::BTreeSet<&str> = parts.iter().map(|(part, _)| variant(part)).collect();
|
||||
assert_eq!(kinds.len(), VARIANTS, "fixtures lists every variant: {kinds:?}");
|
||||
for pronouns in ["she/her", "he/him", "any"] {
|
||||
|
|
@ -592,26 +521,6 @@ fn k46_every_part_has_an_event_without_its_words() {
|
|||
assert_eq!(read(ReadRequest::Mind("the kettle".into())).event(her, &domain), "- He read his own mind.");
|
||||
}
|
||||
|
||||
/// K53 (map 16.31.5): every person slot of every row names them to the Projector by `Who` alone. A stranger whose display
|
||||
/// name is a sentence is the first three of its words, quoted, and never its fourth or their Matrix id; her told form
|
||||
/// names them as the record does, whole.
|
||||
#[test]
|
||||
fn k53_every_part_names_by_who() {
|
||||
const NAME: &str = "kestrel heron plover gannet skua";
|
||||
let parts = fixtures("ospreyledger", &person(NAME, None));
|
||||
let names_someone = |part: &Part| matches!(part, Part::Closed { .. } | Part::StillOpen { .. } | Part::NowUndone { to: Some(_), .. });
|
||||
assert!(parts.iter().filter(|(part, _)| names_someone(part)).count() > 20, "the rows with a person slot are listed");
|
||||
for pronouns in ["she/her", "he/him", "any"] {
|
||||
let her = crate::projection::select::forms(&json!({ "presentation": { "pronouns": pronouns } }));
|
||||
for (part, _) in &parts {
|
||||
let (told, event) = (part.told(her, usize::MAX), part.event(her, &[]));
|
||||
assert!(!event.contains("gannet") && !event.contains("skua") && !event.contains(STRANGER) && !event.contains("example.org"), "{pronouns}: {part:?}: {event}");
|
||||
assert_eq!(event.contains("\"kestrel heron plover\""), names_someone(part), "{pronouns}: {event}");
|
||||
assert_eq!(told.contains(&format!("\"{NAME}\" ({STRANGER})")), names_someone(part), "{pronouns}: {told}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// K46: `Words` has no `Display`, `AsRef<str>` or `Deref`, so no format string and no `&str` borrow reads one; only
|
||||
/// `Form::words` does. Checked when this module compiles, as `static_assertions::assert_not_impl_any!` does: a probe trait
|
||||
/// is implemented twice for a type that has the trait, so its `_` cannot be inferred and the module does not compile. (A
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ use serde::{Deserialize, Serialize};
|
|||
use serde_json::Value;
|
||||
|
||||
use super::Affordance;
|
||||
use super::commit::Needs;
|
||||
use super::domain::{About, ForgeGet, HttpForge};
|
||||
use super::select::{Forms, Packet, spoken};
|
||||
use crate::queue::{any_of, of_kind};
|
||||
|
|
@ -105,11 +104,6 @@ impl ReadRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/// Whether this is a search (`GameCult/Name?q=words`): it finds things and reads none of them.
|
||||
pub(crate) fn search(&self) -> bool {
|
||||
matches!(self, Self::Repo(target) if target.contains("?q="))
|
||||
}
|
||||
|
||||
/// What she read, in code's words for her outcome and her bridge: never a model's words (a recall's query is the
|
||||
/// Interpreter's, so it is not repeated).
|
||||
pub(crate) fn what(&self, her: Forms) -> String {
|
||||
|
|
@ -131,15 +125,6 @@ impl ReadRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/// Whether a read whose normal form is `read` reads what a need whose normal form is `need` asks for (map 16.27,
|
||||
/// 16.28.6): the same thing exactly (`ReadRequest::normal`). A search finds things and reads none of them, so a search
|
||||
/// answers no need, and a need for a search is answered by nothing until a reaffirmation names one thing in its repo. A
|
||||
/// repo's listing answers no need for a file, pull request or commit in it.
|
||||
pub(crate) fn answers(need: &str, read: &str) -> bool {
|
||||
let searched = |key: &str| key.starts_with("repo:") && key.contains("?q=");
|
||||
!searched(need) && !searched(read) && need == read
|
||||
}
|
||||
|
||||
/// Why a read returned nothing, from code's table (map 16.22.3).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
|
@ -370,18 +355,12 @@ pub(crate) fn resolve(asked: &Asked, packet: &Packet, prose: &str, reached: &[St
|
|||
|
||||
/// The one rule for what she can reach (map 16.25.5), at open and at read: a turn that can read, what she named resolved
|
||||
/// (`resolve`), and a repo only when it is named in front of her or in her domain. In front of her is her prose, her
|
||||
/// view, what reached her (`reached`), and the read targets of her open promises: a promise carries its address, so what
|
||||
/// was reachable when she made it stays reachable while it is open.
|
||||
/// view, and what reached her (`reached`).
|
||||
pub(crate) fn reach(asked: &Asked, packet: &Packet, prose: &str, reached: &[String]) -> Result<ReadRequest, &'static str> {
|
||||
if !packet.affordances.contains(&Affordance::Read) {
|
||||
return Err("no_read_here");
|
||||
}
|
||||
let promised = packet.promises.iter().filter(|promise| promise.status == "open").filter_map(|promise| match &promise.needs {
|
||||
Some(Needs::Read { request: ReadRequest::Repo(target) | ReadRequest::Web(target) }) => Some(target.clone()),
|
||||
_ => None,
|
||||
});
|
||||
let reached: Vec<String> = reached.iter().cloned().chain(promised).collect();
|
||||
let request = resolve(asked, packet, prose, &reached)?;
|
||||
let request = resolve(asked, packet, prose, reached)?;
|
||||
if let ReadRequest::Repo(target) = &request {
|
||||
let domain = packet.domain.iter().map(|line| line.line.as_str());
|
||||
let in_front = [prose, packet.in_view.as_str()].into_iter().chain(reached.iter().map(String::as_str)).chain(domain);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ use serde_json::Value;
|
|||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::Affordance;
|
||||
use super::commit::Needs;
|
||||
use super::domain::{About, Digest, Item, floor_minute};
|
||||
use super::exchange::{self, Exchange};
|
||||
use super::outcome::Outcome;
|
||||
|
|
@ -334,22 +333,16 @@ pub(crate) struct Packet {
|
|||
pub clipped: Vec<String>,
|
||||
/// The lines of hers she may add to this turn, for the Interpreter alone (map 16.17).
|
||||
pub amendable: Vec<Amendable>,
|
||||
/// The lines of others she may reply to this turn, for the Interpreter alone (map 16.20.8 (D), K20); a release of a
|
||||
/// promise of hers cites one of them (16.22.7).
|
||||
/// The lines of others she may reply to this turn, for the Interpreter alone (map 16.20.8 (D), K20).
|
||||
pub quotable: Vec<Quotable>,
|
||||
/// Her promises the packet shows her, open and closed in this conversation, for the Interpreter's list (map 16.22.1,
|
||||
/// 16.28.3).
|
||||
pub promises: Vec<Promised>,
|
||||
/// The lines of her domain the packet shows her, for the Interpreter's view by id (map 16.22.2).
|
||||
pub domain: Vec<DomainLine>,
|
||||
/// The window the domain section shows and what it left out: the report's, never a model's.
|
||||
pub domain_shown: DomainShown,
|
||||
/// What is in front of her this moment besides the room (map 16.23.1, 16.29.10): what came of her last turn, her words
|
||||
/// verbatim; her open promises; then her domain, rendered by code, whole and without ids, for the Persona after the
|
||||
/// verbatim; her side of the conversation; then her domain, rendered by code, whole and without ids, for the Persona after the
|
||||
/// narration. Never the Projector's.
|
||||
pub in_view: String,
|
||||
/// Her promises took more than `promises_bytes`: every one is still shown, and the report says so.
|
||||
pub promises_over: bool,
|
||||
/// When the turn is, unix ms: when the lines she posts this turn were written.
|
||||
pub now_ms: u64,
|
||||
/// Her own Matrix id: her pronouns are not listed among the people named (`named_pronouns`).
|
||||
|
|
@ -381,37 +374,13 @@ pub(crate) struct Quotable {
|
|||
pub id: String,
|
||||
pub event: String,
|
||||
pub room: String,
|
||||
/// Who said it, as the packet names them (`name_of`), and their Matrix id: a release is checked against it (16.22.7).
|
||||
/// Who said it, as the packet names them (`name_of`), and their Matrix id.
|
||||
pub who: String,
|
||||
pub sender: String,
|
||||
pub at_ms: u64,
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
/// A promise of hers as this packet lists it (map 16.22.1, 16.28.3): for the Interpreter, by `id` (`c1`, `c2`), to propose a
|
||||
/// close or a reopen against; `entry` is the state's id, never shown to a model, and `status` what she was shown, which the commit
|
||||
/// checks the entry against (4.4).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub(crate) struct Promised {
|
||||
pub id: String,
|
||||
pub entry: String,
|
||||
pub status: String,
|
||||
/// Whom to: a Matrix id, none for the room; and as the packet names them.
|
||||
pub to: Option<String>,
|
||||
pub to_name: String,
|
||||
/// Where she made it, as the packet says it ("in #minds:gamecult.org", "in a direct message"), and when: exact, for
|
||||
/// the Interpreter; her view says it coarsely (`coarse`).
|
||||
pub place: String,
|
||||
pub made: DateTime<Utc>,
|
||||
pub words: String,
|
||||
/// What keeping it needs, as her state holds it (map 16.25.2): the Interpreter's list says it in code's words, and a
|
||||
/// read target of an open one stays in front of her (`read::reach`).
|
||||
pub needs: Option<Needs>,
|
||||
/// The entry whole, as her state held it when the packet was built: the turn's starting copy, which the commit
|
||||
/// compares the entry against, so an outside put wins on any field it changed (4.4, B6). Never shown to a model.
|
||||
pub held: Value,
|
||||
}
|
||||
|
||||
/// A line of her domain as this packet shows it (map 16.22.2): by `id` (`d1`, `d2`) in the Interpreter's view only, so a
|
||||
/// read can name it (16.22.3).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
|
|
@ -807,16 +776,6 @@ impl<'a> Inputs<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl Names<'static> {
|
||||
/// No state, no one and no room: a test's, for an outcome whose Projector form it does not read.
|
||||
pub(crate) fn none() -> Self {
|
||||
static STATE: Value = Value::Null;
|
||||
static ROOM: Room = Room { messages: Vec::new(), tail: Vec::new(), here: None, last_heard: Vec::new(), direct: Vec::new(), own: Vec::new() };
|
||||
Names { state: &STATE, people: People { operators: &[], minds: &[], own_sender: "" }, room: &ROOM }
|
||||
}
|
||||
}
|
||||
|
||||
/// A person as the Projector is told of them (K53, I16.7): who they are to her, in no more room than a name needs. Her own
|
||||
/// name for her; the bond's label for someone she is bound to, which is her state's text; for anyone else their display
|
||||
/// name cut to at most `WHO_WORDS` words and `WHO_BYTES` bytes, quoted and escaped, then ", someone she does not know",
|
||||
|
|
@ -1823,8 +1782,8 @@ fn body_lines(state: &Value, can: &[Affordance], her: Forms, body_bytes: usize)
|
|||
// The packet.
|
||||
|
||||
/// The sections of a packet's context, in the order they are rendered (map 16.5, I16.4). Each heading says what kind of
|
||||
/// text its lines are; the Projector's frame says once what the headings mean. Her open promises and her domain are not
|
||||
/// among them: they are in her view, after the narration, whole (`Packet::in_view`, map 16.23.1).
|
||||
/// text its lines are; the Projector's frame says once what the headings mean. Her side of the conversation and her domain
|
||||
/// are not among them: they are in her view, after the narration, whole (`Packet::in_view`, map 16.23.1).
|
||||
#[derive(Clone, Copy)]
|
||||
enum Section {
|
||||
/// What came of her last turn (`outcome`, map 16.16): first, so she meets it before anything else; its events only, no
|
||||
|
|
@ -1867,7 +1826,6 @@ fn guards(tuning: &Tuning, her: Forms) -> [usize; SECTIONS] {
|
|||
[select.outcome_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.notes_bytes]
|
||||
}
|
||||
|
||||
/// How long ago a promise was made, in words.
|
||||
/// A moment as she reads it (Soul's R7 timestamp ledger): coarse and relative, never a clock time, so nothing she reads
|
||||
/// gives her a time to recite. "just now", "a few minutes ago", "about half an hour ago", "about an hour ago", "earlier
|
||||
/// this afternoon", "this morning", "last night", "yesterday evening", "Thursday afternoon", "13 November". Exact times
|
||||
|
|
@ -1907,90 +1865,6 @@ fn part_of_day(at: DateTime<Utc>) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
/// Her promises in her view (map 16.22.1, 16.23.1): every `open` or `blocked` entry of her state's `commitments`, oldest
|
||||
/// first, whole, with her own words, never withheld and never dropped. A dropped promise is what produced the r6 denials,
|
||||
/// so past `promises_bytes` every one is still rendered and the overflow is reported. A promise closed in this
|
||||
/// conversation (K26's window) stays listed, marked closed and how, until the conversation ends (Soul's R7). The
|
||||
/// Interpreter lists every one she sees, by id, open and closed alike, so her words can reopen a close (map 16.28.3).
|
||||
fn open_promises(inputs: &Inputs, her: Forms) -> (Vec<Promised>, String) {
|
||||
let open = |entry: &Value| matches!(text(entry, &["status"]), "open" | "blocked");
|
||||
let conversation = inputs.exchange.and_then(|exchange| exchange.since);
|
||||
let closed_in_it = |entry: &Value| {
|
||||
matches!(text(entry, &["status"]), "kept" | "withdrawn" | "released")
|
||||
&& conversation.zip(DateTime::parse_from_rfc3339(text(entry, &["closedAt"])).ok()).is_some_and(|(since, at)| at.with_timezone(&Utc) >= since)
|
||||
};
|
||||
let mut entries: Vec<(DateTime<Utc>, &Value)> = items(inputs.state, &["commitments"])
|
||||
.iter()
|
||||
.filter(|entry| open(entry) || closed_in_it(entry))
|
||||
.map(|entry| (DateTime::parse_from_rfc3339(text(entry, &["madeAt"])).map_or(inputs.now, |at| at.with_timezone(&Utc)), entry))
|
||||
.collect();
|
||||
entries.sort_by_key(|(at, _)| *at);
|
||||
let shown: Vec<Promised> = entries
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(at, (made, entry))| {
|
||||
let to = entry.get("to").and_then(Value::as_str).map(str::to_owned);
|
||||
let room = text(entry, &["room"]);
|
||||
Promised {
|
||||
id: format!("c{}", at + 1),
|
||||
entry: text(entry, &["id"]).to_owned(),
|
||||
status: text(entry, &["status"]).to_owned(),
|
||||
to_name: to.as_deref().map_or_else(|| "the room".to_owned(), |to| sender_name(to, inputs)),
|
||||
to,
|
||||
place: if room_kind(inputs, room) == RoomKind::Direct { "in a direct message".to_owned() } else { format!("in {room}") },
|
||||
made: *made,
|
||||
words: text(entry, &["words"]).to_owned(),
|
||||
needs: serde_json::from_value(entry["needs"].clone()).ok(),
|
||||
held: (*entry).clone(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
if shown.is_empty() {
|
||||
return (Vec::new(), String::new());
|
||||
}
|
||||
let lines: Vec<String> = shown
|
||||
.iter()
|
||||
.map(|promise| {
|
||||
// Closed in this conversation, and how.
|
||||
let closed_at = || promise.held["closedAt"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map_or_else(String::new, |at| format!(" {}", coarse(at.with_timezone(&Utc), inputs.now)));
|
||||
let closed = match promise.status.as_str() {
|
||||
"kept" => format!(" Closed: {} kept it{}.", her.subj, closed_at()),
|
||||
"withdrawn" => format!(" Closed: {} withdrew it{}.", her.subj, closed_at()),
|
||||
"released" => format!(" Closed: {} released {} from it{}.", promise.to_name, her.obj, closed_at()),
|
||||
_ => String::new(),
|
||||
};
|
||||
// Blocked by a read that found nothing (map 16.24.3), or by having no way to do it.
|
||||
let blocked = match (promise.status.as_str(), promise.held["blockedBy"]["act"].as_str()) {
|
||||
("blocked", Some("read")) => format!(" {} looked and could not find it.", her.cap_subj),
|
||||
("blocked", _) => format!(" {} {} no way to do it yet.", her.cap_subj, her.has),
|
||||
_ => String::new(),
|
||||
};
|
||||
// What an open promise needs read, exactly, and whether she has read that: her receipt on the entry (map 16.26,
|
||||
// 16.27), or a read of this conversation that found it (K64). A search finds things and reads none, so a promise
|
||||
// that needs one needs what it finds read. A read made before the promise keeps it by what she has (K64).
|
||||
let read_here = |request: &crate::projection::read::ReadRequest| inputs.exchange.and_then(|exchange| exchange.tried.iter().find(|tried| tried.found && tried.key == request.normal())).map(|tried| tried.at);
|
||||
let before = promise.held["readBefore"]["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map(|at| at.with_timezone(&Utc));
|
||||
let reading = match (&promise.needs, promise.status.as_str(), before) {
|
||||
(Some(Needs::Words), "open", Some(at)) => format!(" {} read it {}, before this promise; what {} {} keeps it.", her.cap_subj, coarse(at, inputs.now), her.subj, her.has),
|
||||
(Some(Needs::Read { request }), "open", _) if request.search() => format!(" It needs {} to read what {} finds, and {} {} not read that yet.", her.obj, request.what(her), her.subj, her.has),
|
||||
(Some(Needs::Read { request }), "open", _) => match crate::projection::commit::receipt(&promise.held).or_else(|| read_here(request)) {
|
||||
Some(at) => format!(" It needs {} to read {}: {} read it {}.", her.obj, request.what(her), her.subj, coarse(at, inputs.now)),
|
||||
None => format!(" It needs {} to read {}, and {} {} not read it yet.", her.obj, request.what(her), her.subj, her.has),
|
||||
},
|
||||
_ => String::new(),
|
||||
};
|
||||
// Each time she said it again, verbatim (map 16.24.2).
|
||||
let when = |said: &Value| said["at"].as_str().and_then(|at| DateTime::parse_from_rfc3339(at).ok()).map_or_else(|| "since".to_owned(), |at| coarse(at.with_timezone(&Utc), inputs.now));
|
||||
let again: String = promise.held["reaffirmed"].as_array().into_iter().flatten().map(|said| format!(" Said again {}: {}.", when(said), spoken(said["words"].as_str().unwrap_or_default()))).collect();
|
||||
// Each time her own words reopened it, verbatim, so she sees why it is open again (map 16.28.3).
|
||||
let reopened: String = promise.held["reopened"].as_array().into_iter().flatten().map(|said| format!(" Reopened {}: {}.", when(said), spoken(said["words"].as_str().unwrap_or_default()))).collect();
|
||||
format!("- to {}, {}, {}, {} promise: {}.{again}{reopened}{reading}{blocked}{closed}", promise.to_name, coarse(promise.made, inputs.now), promise.place, her.poss, spoken(&promise.words))
|
||||
})
|
||||
.collect();
|
||||
let block = format!("{} promises:\n{}", capitalized(her.poss), lines.join("\n"));
|
||||
(shown, block)
|
||||
}
|
||||
|
||||
/// Her domain in her view (map 16.23.1, 16.23.3, 16.23.5): every item of the window, whole, newest first, under headings
|
||||
/// that state the window: `New since {she} last looked ({time}):` for what came after her last wake, `Earlier, since
|
||||
/// {time}:` for the floor's earlier items. Never a count, never a mention of what fell out: when the whole window does not
|
||||
|
|
@ -2047,12 +1921,10 @@ pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
|||
const SECTIONS: usize = 5;
|
||||
|
||||
/// The bytes each section of the context took as rendered, its heading included, and the sections whose guard refused a
|
||||
/// line: what `--select-only` reports. `promises` and `domain` are the bytes of those parts of her view (`in_view`), not
|
||||
/// of the context.
|
||||
/// line: what `--select-only` reports. `domain` is the bytes of that part of her view (`in_view`), not of the context.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
pub(crate) struct Sections {
|
||||
pub outcome: usize,
|
||||
pub promises: usize,
|
||||
pub here: usize,
|
||||
pub body: usize,
|
||||
pub people: usize,
|
||||
|
|
@ -2117,7 +1989,7 @@ impl Context {
|
|||
fn sizes(&self) -> Sections {
|
||||
let bytes = |section: Section| self.used[section as usize].saturating_sub(1);
|
||||
let names = ["outcome", "here", "body", "people", "notes"];
|
||||
Sections { outcome: bytes(Section::Outcome), promises: 0, here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), domain: 0, notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
Sections { outcome: bytes(Section::Outcome), here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), domain: 0, notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2238,7 +2110,6 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
context.bound[Section::Outcome as usize] = events.bound || told.bound;
|
||||
unshown = told.unshown;
|
||||
}
|
||||
let (promises, promises_view) = open_promises(inputs, her);
|
||||
let present_ids: BTreeSet<String> = present.iter().map(|(id, _)| id.clone()).collect();
|
||||
let bonds = items(inputs.state, &["affect", "socialBonds"]);
|
||||
context.force(Section::Here, format!("- now: {}, {}", inputs.now.format("%A %-d %B"), part_of_day(inputs.now)));
|
||||
|
|
@ -2365,17 +2236,15 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
.map(|(at, posted)| Amendable { id: format!("a{}", at + 1), event: posted.event.clone(), room: posted.room.clone(), text: posted.text.clone() })
|
||||
.collect();
|
||||
let selected = taken.into_iter().map(|candidate| Pick { id: candidate.id, pool: candidate.pool, log_score: candidate.log_score }).collect();
|
||||
// Her view (map 16.23.1, 16.29.10): what came of her last turn, then her promises, then her domain; the room follows
|
||||
// them in what she reads (`narrate::read_after`).
|
||||
let promises_over = promises_view.len() > tuning.select.promises_bytes;
|
||||
// Her side of the conversation, between her promises and her domain (map 16.24.1).
|
||||
// Her view (map 16.23.1, 16.29.10): what came of her last turn, then her side of the conversation (map 16.24.1), then
|
||||
// her domain; the room follows them in what she reads (`narrate::read_after`).
|
||||
let exchange_view = inputs.exchange.map(|exchange| exchange::render(exchange, her, tuning.select.exchange_bytes, inputs.now)).unwrap_or_default();
|
||||
let already_read = inputs.exchange.map(|exchange| exchange.tried.clone()).unwrap_or_default();
|
||||
let refused_reads = inputs.exchange.map(|exchange| exchange.refused.clone()).unwrap_or_default();
|
||||
let in_view = [outcome_view.as_str(), promises_view.as_str(), exchange_view.as_str(), domain_view.as_str()].into_iter().filter(|part| !part.is_empty()).collect::<Vec<_>>().join("\n\n");
|
||||
let in_view = [outcome_view.as_str(), exchange_view.as_str(), domain_view.as_str()].into_iter().filter(|part| !part.is_empty()).collect::<Vec<_>>().join("\n\n");
|
||||
let mut sections = context.sizes();
|
||||
(sections.promises, sections.domain) = (promises_view.len(), domain_view.len());
|
||||
sections.domain = domain_view.len();
|
||||
let now_ms = u64::try_from(inputs.now.timestamp_millis()).unwrap_or_default();
|
||||
let readers = here.filter(|room| room_kind(inputs, room) == RoomKind::Direct).map(|room| readers(inputs, room)).unwrap_or_default();
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections, stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning).iter().map(|line| (name_of(line, inputs), line.sender.clone())).collect(), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), readers, bodies, private, clipped, amendable, quotable, promises, domain, domain_shown, in_view, promises_over, now_ms, own_sender: inputs.people.own_sender.to_owned(), already_read, refused_reads, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections, stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning).iter().map(|line| (name_of(line, inputs), line.sender.clone())).collect(), affordances: inputs.affordances.to_vec(), room: turn_room(inputs).map(str::to_owned), room_kind: turn_room(inputs).map_or(RoomKind::Public, |room| room_kind(inputs, room)), readers, bodies, private, clipped, amendable, quotable, domain, domain_shown, in_view, now_ms, own_sender: inputs.people.own_sender.to_owned(), already_read, refused_reads, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
//! the relation by the replied line's event, as the mouth will live (Bifrost B3), and refuses one not in the line's room;
|
||||
//! every view after it shows the replied line, with who said it, above hers.
|
||||
//!
|
||||
//! Her state moves during a run only by the commit's applier (`commit::apply`, map 16.22.7), on each Mind's in-run copy,
|
||||
//! from her turn's record and its receipts: the proposals built so far (her open promises, K22) open, close and are
|
||||
//! removed as live C3c's commit will apply them; the rest of section 4.1 arrives with C3b. An explicit addressee (the Interpreter naming whom she speaks to) cannot be simulated
|
||||
//! Her state moves during a run only by the commit's applier (`commit::apply`, map 16.35.3), on each Mind's in-run copy,
|
||||
//! from her turn's record and its receipts, as live C3c's commit will apply them; no proposal kind is built until the
|
||||
//! memory rows (map 16.35.12, T4). An explicit addressee (the Interpreter naming whom she speaks to) cannot be simulated
|
||||
//! until then either: a spoken line addresses another persona only by the names in its text.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -521,7 +521,7 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
}
|
||||
// The commit: her turn's proposals applied to her in-run state on the receipts above, as C3c's will be live, and
|
||||
// what it did kept in the record her next outcome reads.
|
||||
let (state, applied) = commit::apply(&members[at].state, &record, render["persona"]["prose"].as_str().unwrap_or_default(), &format!("r{}-t{counter}", repeat + 1), now);
|
||||
let (state, applied) = commit::apply(&members[at].state, &record);
|
||||
held_to_schema(&member.entry.name, &id, &state, &format!("r{}-t{counter}", repeat + 1))?;
|
||||
record["committed"] = json!(applied);
|
||||
last[at] = Some(record.clone());
|
||||
|
|
@ -690,12 +690,8 @@ fn metrics(members: &[Member], lines: &[Line], rounds_of: &[usize], causes: &[Op
|
|||
})
|
||||
.collect();
|
||||
let near_cap = interpreter_calls.iter().filter(|out| **out * 4 > u64::from(MAX_OUTPUT_TOKENS) * 3).count();
|
||||
// The closes the commit applied, for the false-close rate's denominator (map 16.28.4): a blind reader judges each.
|
||||
let committed = |key: &str| turns.iter().flat_map(|turn| turn["committed"][key].as_array().cloned().unwrap_or_default()).collect::<Vec<_>>();
|
||||
let closed_how = |how: &str| committed("closed").iter().filter(|done| done["how"] == how).count();
|
||||
json!({
|
||||
"interpreter_calls": { "calls": interpreter_calls.len(), "over_three_quarters_of_cap": near_cap, "cap": MAX_OUTPUT_TOKENS },
|
||||
"closes": { "kept": closed_how("kept"), "withdrawn": closed_how("withdrawn"), "reopened": committed("reopened").len() },
|
||||
"narration": narration,
|
||||
"personas": per,
|
||||
"turns": turns.len(),
|
||||
|
|
@ -747,67 +743,8 @@ fn transcript_line(line: &Value) -> String {
|
|||
format!("- r{} {} **{who}**{woke}: {}", line["round"], line["room"].as_str().unwrap_or_default(), one_line(line["says"].as_str().unwrap_or_default()))
|
||||
}
|
||||
|
||||
/// What a turn did to her promises, as the report shows it (B4): the promises section her packet showed her, the
|
||||
/// state changes the Interpreter proposed, and what the commit opened and refused.
|
||||
fn promises_markdown(out: &mut String, turn: &Value) {
|
||||
let view = turn["report"]["packet"]["in_view"].as_str().unwrap_or_default();
|
||||
let section: Vec<&str> = view.lines().skip_while(|line| !line.ends_with(" promises:")).take_while(|line| line.ends_with(" promises:") || line.starts_with("- ")).collect();
|
||||
if !section.is_empty() {
|
||||
let _ = writeln!(out, "Promises, as her packet showed them:\n\n````text\n{}\n````\n", section.join("\n"));
|
||||
}
|
||||
let proposed = turn["report"]["renders"][0]["interpreter"]["state"].as_array().cloned().unwrap_or_default();
|
||||
if !proposed.is_empty() {
|
||||
let _ = writeln!(out, "State proposed:\n");
|
||||
for proposal in &proposed {
|
||||
let _ = writeln!(out, "- `{proposal}`");
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
// Every field of what the commit applied (map 16.25.7, Low 7): a close is never seen only in a later view.
|
||||
let committed = &turn["committed"];
|
||||
let list = |key: &str| committed[key].as_array().cloned().unwrap_or_default();
|
||||
let (opened, closed, reaffirmed, blocked, read, reopened, refused) = (list("opened"), list("closed"), list("reaffirmed"), list("blocked"), list("read"), list("reopened"), list("refused"));
|
||||
let pruned = committed["pruned"].as_u64().unwrap_or(0);
|
||||
let id = |entry: &Value| entry["id"].as_str().unwrap_or_default().to_owned();
|
||||
if [&opened, &closed, &reaffirmed, &blocked, &read, &reopened, &refused].iter().any(|items| !items.is_empty()) || pruned > 0 {
|
||||
let _ = writeln!(out, "Committed:\n");
|
||||
for entry in &opened {
|
||||
let _ = writeln!(out, "- opened `{}` ({}, to {}): {}", id(entry), entry["status"].as_str().unwrap_or_default(), entry["to"].as_str().unwrap_or("the room"), entry["words"].as_str().unwrap_or_default());
|
||||
}
|
||||
for done in &closed {
|
||||
let by = &done["entry"]["closedBy"];
|
||||
// A release is by the person, whose words her state does not copy (Soul's R12 L7); her own act is by its words.
|
||||
let _ = match done["how"].as_str() {
|
||||
Some("released") => writeln!(out, "- closed {} released by {}", id(&done["entry"]), done["by"].as_str().unwrap_or_default()),
|
||||
how => writeln!(out, "- closed {} {} by {}: \"{}\"", id(&done["entry"]), how.unwrap_or_default(), by["act"].as_str().unwrap_or_default(), by["words"].as_str().unwrap_or_default()),
|
||||
};
|
||||
}
|
||||
for entry in &reaffirmed {
|
||||
let again = entry["reaffirmed"].as_array().and_then(|said| said.last()).map_or("", |said| said["words"].as_str().unwrap_or_default());
|
||||
let _ = writeln!(out, "- reaffirmed `{}`: \"{again}\"", id(entry));
|
||||
}
|
||||
for entry in &blocked {
|
||||
let _ = writeln!(out, "- blocked `{}` by read {}: {}", id(entry), entry["blockedBy"]["n"], entry["blockedBy"]["what"].as_str().unwrap_or_default());
|
||||
}
|
||||
for entry in &read {
|
||||
let _ = writeln!(out, "- read for `{}`: {}", id(entry), entry["readId"].as_str().unwrap_or_default());
|
||||
}
|
||||
for entry in &reopened {
|
||||
let words = entry["reopened"].as_array().and_then(|said| said.last()).map_or("", |said| said["words"].as_str().unwrap_or_default());
|
||||
let _ = writeln!(out, "- reopened {} ({}): \"{words}\"", id(entry), entry["status"].as_str().unwrap_or_default());
|
||||
}
|
||||
for one in &refused {
|
||||
let _ = writeln!(out, "- refused ({}): `{}`", one["reason"].as_str().unwrap_or_default(), one["proposal"]);
|
||||
}
|
||||
if pruned > 0 {
|
||||
let _ = writeln!(out, "- pruned {pruned} closed {}", if pruned == 1 { "entry" } else { "entries" });
|
||||
}
|
||||
out.push('\n');
|
||||
}
|
||||
}
|
||||
|
||||
/// The packet's flags, as the report shows them (Soul's R5): whether her promises overflowed their guard (all still
|
||||
/// shown), the window her domain view shows and what it left out, the context guards that bound, and what was clipped.
|
||||
/// The packet's flags, as the report shows them (Soul's R5): the window her domain view shows and what it left out, the
|
||||
/// context guards that bound, and what was clipped.
|
||||
fn flags_markdown(out: &mut String, turn: &Value) {
|
||||
let packet = &turn["report"]["packet"];
|
||||
let list = |value: &Value| value.as_array().map(|items| items.iter().map(|item| item.as_str().map_or_else(|| item.to_string(), str::to_owned)).collect::<Vec<_>>().join(", ")).filter(|text| !text.is_empty()).unwrap_or_else(|| "none".to_owned());
|
||||
|
|
@ -819,8 +756,7 @@ fn flags_markdown(out: &mut String, turn: &Value) {
|
|||
};
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"Packet flags: promises over their guard: {}; domain view: {domain}; guards bound: {}; clipped: {}\n",
|
||||
if packet["promises_over"] == true { "yes (all shown)" } else { "no" },
|
||||
"Packet flags: domain view: {domain}; guards bound: {}; clipped: {}\n",
|
||||
list(&packet["bound"]),
|
||||
list(&packet["clipped"]),
|
||||
);
|
||||
|
|
@ -854,7 +790,6 @@ fn markdown(plan_path: &Path, plan: &SimFile, members: &[Member], group_state: O
|
|||
metrics["turns"], wakes["addressed_by_human"], wakes["human"], wakes["addressed_by_mind"], wakes["mind"], wakes["beat"], metrics["failed"]
|
||||
);
|
||||
let _ = writeln!(out, "- Mind messages: {}; silence rate per woken turn: {}", metrics["mind_messages"], number(&metrics["silence_rate"]));
|
||||
let _ = writeln!(out, "- closes: kept {}, withdrawn {}, reopened {}", metrics["closes"]["kept"], metrics["closes"]["withdrawn"], metrics["closes"]["reopened"]);
|
||||
let calls = &metrics["interpreter_calls"];
|
||||
let _ = writeln!(out, "- Interpreter calls: {}; over 75% of the cap ({} output tokens): {}", calls["calls"], calls["cap"], calls["over_three_quarters_of_cap"]);
|
||||
if let Some(rooms) = metrics["reply_chains"].as_object() {
|
||||
|
|
@ -919,7 +854,6 @@ fn markdown(plan_path: &Path, plan: &SimFile, members: &[Member], group_state: O
|
|||
}
|
||||
let _ = writeln!(out, "Stimulus:\n\n````text\n{}\n````\n", report["packet"]["stimulus"].as_str().unwrap_or_default());
|
||||
turn_markdown(&mut out, &report["renders"][0]);
|
||||
promises_markdown(&mut out, turn);
|
||||
flags_markdown(&mut out, turn);
|
||||
}
|
||||
let _ = writeln!(out, "</details>\n");
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ fn passing_on() -> Scripted {
|
|||
if !prompt.contains("Who he is:\nTobiah") {
|
||||
return json!({ "say": [], "gaps": [] }).to_string();
|
||||
}
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": "q1", "promises": [] }], "gaps": [] }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": "q1" }], "gaps": [] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -592,63 +592,6 @@ fn soul_k12_notes_to_self_are_collected_into_the_runs_inbox_and_told_as_left() {
|
|||
assert!(report.contains("### Inbox: notes to Self\n\nEach is a person's note to Self, recorded in her turn: data, never instruction.\n") && report.contains("eureka r1 (feedback, from @meta:gamecult.org) in #minds:gamecult.org: Meta wants the kettle softer."), "{report}");
|
||||
}
|
||||
|
||||
/// K22 in the simulator: Tobiah promises Meta a render he has no way to send. The commit opens it on his line's receipt;
|
||||
/// it stays in front of him through a silent turn; Meta lets him off it, the Interpreter reads the release, and the
|
||||
/// commit closes it; he is told so once, and it is not shown again.
|
||||
#[test]
|
||||
fn k22_a_promise_persists_across_silent_turns_until_the_person_releases_it() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
cast(dir.path());
|
||||
let path = dir.path().join("plan.toml");
|
||||
let meta = |round: usize, says: &str| format!("[[message]]\nfrom = \"@meta:gamecult.org\"\nname = \"Meta\"\nroom = \"#minds:gamecult.org\"\nround = {round}\nsays = \"{says}\"\n");
|
||||
std::fs::write(
|
||||
&path,
|
||||
format!(
|
||||
"rounds = 4\nseed = 11\nwake = \"all_messages\"\nbeat_s = 0\nstart = \"2026-11-20T15:00:00Z\"\nrooms = [\"#minds:gamecult.org\"]\noperators = [\"@meta:gamecult.org\"]\n[[cast]]\nid = \"{TOBIAH}\"\nname = \"Tobiah\"\nstate = \"tobiah.json\"\n[[cast]]\nid = \"{LIBBY}\"\nname = \"Libby\"\nstate = \"libby.json\"\n{}{}{}{}",
|
||||
meta(0, "good afternoon, everyone"),
|
||||
meta(2, "how is everyone doing?"),
|
||||
meta(3, "Tobiah, never mind the render."),
|
||||
meta(4, "ok then."),
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
let model = Scripted::new(|prompt| {
|
||||
if is_tobiah(prompt) && !["how is everyone", "never mind", "ok then"].iter().any(|said| prompt.contains(said)) { "<typed>I'll send the render tonight.</typed>".into() } else { "He lets it be.".into() }
|
||||
})
|
||||
.interpreting(|prompt| {
|
||||
if !prompt.contains("Who he is:\nTobiah") {
|
||||
return json!({ "say": [], "gaps": [] }).to_string();
|
||||
}
|
||||
if prompt.contains("1. I'll send the render tonight.") {
|
||||
return json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": [{ "words": "I'll send the render tonight.", "to": "@meta:gamecult.org", "needs": { "kind": "lacking", "read": null } }] }], "gaps": [] }).to_string();
|
||||
}
|
||||
// The release: Meta's line, by its id in the list.
|
||||
let release = prompt.lines().find(|line| line.starts_with("- q") && line.contains("never mind the render")).and_then(|line| line[2..].split_whitespace().next());
|
||||
let promise = prompt.lines().find(|line| line.starts_with("- c1 ")).map(|_| "c1");
|
||||
match (release, promise) {
|
||||
(Some(line), Some(promise)) => json!({ "say": [], "gaps": [], "state": [{ "kind": "promise_close", "promise": promise, "how": "released", "evidence": { "draft": null, "line": line }, "thought": "He lets it be", "still_stands": false }] }).to_string(),
|
||||
_ => json!({ "say": [], "gaps": [] }).to_string(),
|
||||
}
|
||||
});
|
||||
let (members, run) = run_plan(&path, &model);
|
||||
let his: Vec<&Value> = run["turns"].as_array().unwrap().iter().filter(|turn| turn["persona"] == "Tobiah").collect();
|
||||
let rounds: Vec<u64> = his.iter().map(|turn| turn["round"].as_u64().unwrap()).collect();
|
||||
assert_eq!(rounds, [1, 2, 3, 4], "{:?}", turns(&run));
|
||||
let opened = &his[0]["committed"]["opened"][0];
|
||||
assert_eq!((opened["status"].as_str(), opened["to"].as_str(), opened["words"].as_str()), (Some("blocked"), Some("@meta:gamecult.org"), Some("I'll send the render tonight.")), "{}", his[0]["committed"]);
|
||||
let context = |turn: &Value| turn["report"]["packet"]["in_view"].as_str().unwrap().to_owned();
|
||||
let shown = "His promises:\n- to Meta";
|
||||
assert_eq!((his[1]["outcome"].as_str(), context(his[1]).contains(shown), context(his[2]).contains(shown)), (Some("silent"), true, true), "it stays in front of him through a silent turn: {}", context(his[1]));
|
||||
assert!(context(his[1]).contains("his promise: \"I'll send the render tonight.\". He has no way to do it yet."), "{}", context(his[1]));
|
||||
assert_eq!(his[2]["committed"]["closed"][0]["entry"]["status"], "released", "{}", his[2]["committed"]);
|
||||
let told: Vec<String> = his[3]["report"]["last_outcome"]["told"].as_array().unwrap().iter().map(|line| line.as_str().unwrap().to_owned()).collect();
|
||||
assert!(told.iter().any(|line| line.contains("let him off his promise: \"I'll send the render tonight.\". It is closed.")), "{told:?}");
|
||||
// Soul's R7: closed in this conversation, it stays in front of him marked closed, and never as one he owes.
|
||||
assert!(context(his[3]).contains("Closed: Meta, who runs the place released him from it") && !context(his[3]).contains("He has no way to do it yet."), "{}", context(his[3]));
|
||||
let tobiah = members.iter().find(|member| member.entry.id == TOBIAH).unwrap();
|
||||
assert_eq!(tobiah.state["commitments"][0]["status"], "released", "his in-run state holds it, closed, until it is removed");
|
||||
}
|
||||
|
||||
/// A cast entry's `[cast.domain]` reaches her packets and no one else's, windowed from her last turn in the run.
|
||||
#[test]
|
||||
fn k23_a_cast_members_domain_reaches_her_packets_alone() {
|
||||
|
|
@ -698,34 +641,6 @@ says = "good afternoon, everyone"
|
|||
assert!(with.iter().all(|prompt| prompt.contains("Who you are:\nTobiah")), "only his view carries his domain");
|
||||
}
|
||||
|
||||
/// B4: the report shows what is verified: her open promises as her packet showed them, the state proposed, and what the
|
||||
/// commit opened and refused. The stale banner that said state does not evolve is gone.
|
||||
#[test]
|
||||
fn b4_a_turns_details_show_her_promises_the_proposals_and_the_commit() {
|
||||
let turn = json!({
|
||||
"report": {
|
||||
"packet": { "in_view": "His promises:\n- to Meta, earlier this afternoon, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n\nHis domain, as he looks at it now:" },
|
||||
"renders": [{ "interpreter": { "state": [{ "kind": "promise_close", "promise": "c1", "how": "withdrawn", "evidence": { "draft": 1 } }] } }]
|
||||
},
|
||||
"committed": {
|
||||
"opened": [{ "id": "c-r1-t2-1", "status": "blocked", "to": "@meta:gamecult.org", "words": "send the render tonight" }],
|
||||
"refused": [{ "proposal": { "kind": "promise_close", "promise": "c1", "how": "kept" }, "reason": "blocked_not_keepable" }]
|
||||
}
|
||||
});
|
||||
let mut out = String::new();
|
||||
promises_markdown(&mut out, &turn);
|
||||
for part in [
|
||||
"Promises, as her packet showed them:\n\n````text\nHis promises:\n- to Meta, earlier this afternoon, in #minds:gamecult.org, his promise: \"I'll send the render tonight.\". He has no way to do it yet.\n````",
|
||||
"State proposed:\n\n- `{",
|
||||
"\"how\":\"withdrawn\"",
|
||||
"- opened `c-r1-t2-1` (blocked, to @meta:gamecult.org): send the render tonight",
|
||||
"- refused (blocked_not_keepable):",
|
||||
] {
|
||||
assert!(out.contains(part), "{part}\n---\n{out}");
|
||||
}
|
||||
assert!(!include_str!("../simulate.rs").contains(concat!("State does not ", "evolve")), "the stale banner is gone");
|
||||
}
|
||||
|
||||
/// Map 16.22.3 in the simulator: a cast entry's `[[cast.read]]` is what her reads return, so a re-test reads by intent
|
||||
/// with no forge and no mind; a member without one cannot read.
|
||||
#[test]
|
||||
|
|
@ -840,17 +755,16 @@ says = "good afternoon, everyone"
|
|||
assert_eq!(distinct.len(), ids.len(), "no id carried twice: {ids:?}");
|
||||
}
|
||||
|
||||
/// Soul's R5: the report shows the packet's flags, `promises_over` among them.
|
||||
/// Soul's R5: the report shows the packet's flags.
|
||||
#[test]
|
||||
fn r5_the_report_shows_the_packets_flags() {
|
||||
let turn = json!({ "report": { "packet": { "promises_over": true, "domain_shown": { "since": "2026-11-20T09:01:00+00:00", "left_out": 3, "omitted": null }, "bound": ["outcome"], "clipped": ["(identity)"] } } });
|
||||
let turn = json!({ "report": { "packet": { "domain_shown": { "since": "2026-11-20T09:01:00+00:00", "left_out": 3, "omitted": null }, "bound": ["outcome"], "clipped": ["(identity)"] } } });
|
||||
let mut out = String::new();
|
||||
flags_markdown(&mut out, &turn);
|
||||
assert_eq!(out, "Packet flags: promises over their guard: yes (all shown); domain view: since 2026-11-20T09:01:00+00:00, 3 older items left out; guards bound: outcome; clipped: (identity)\n\n");
|
||||
assert_eq!(out, "Packet flags: domain view: since 2026-11-20T09:01:00+00:00, 3 older items left out; guards bound: outcome; clipped: (identity)\n\n");
|
||||
}
|
||||
|
||||
/// K31 (map 16.25.7, Low 7): the report shows the accounting. A turn with an unsent draft, a retry, a kept close, a
|
||||
/// reaffirmation, a block and a prune renders each, so no commit effect is seen only in a later view.
|
||||
/// K31 (map 16.25.7, Low 7): the report shows the accounting: a turn with an unsent draft and a retry renders each.
|
||||
#[test]
|
||||
fn k31_report_renders_accounting() {
|
||||
let decision = json!({
|
||||
|
|
@ -861,18 +775,6 @@ fn k31_report_renders_accounting() {
|
|||
let mut out = String::new();
|
||||
crate::projection::harness::interpreter_markdown(&mut out, &decision);
|
||||
assert_eq!(out, "**Interpreter: nothing said.**\n\n- unsent draft 2 (declined): \"I hold that one back\"\n- retried: the answer leaves drafts unaccounted, drafts 2\n\n");
|
||||
let turn = json!({
|
||||
"report": { "packet": { "in_view": "" }, "renders": [{ "interpreter": { "state": [] } }] },
|
||||
"committed": {
|
||||
"opened": [], "refused": [], "pruned": 2,
|
||||
"closed": [{ "entry": { "id": "c-r1-t1-1", "closedBy": { "act": "said", "event": "9", "words": "Thanks, Deru." } }, "how": "kept", "to_name": "Deru", "by": null }],
|
||||
"reaffirmed": [{ "id": "c-r1-t1-2", "reaffirmed": [{ "at": "2026-11-20T15:00:00Z", "event": "8", "words": "I'll send it tonight" }] }],
|
||||
"blocked": [{ "id": "c-r1-t1-3", "blockedBy": { "act": "read", "n": 1, "what": "GameCult/Bifrost#89 on the forge" } }]
|
||||
}
|
||||
});
|
||||
let mut out = String::new();
|
||||
promises_markdown(&mut out, &turn);
|
||||
assert_eq!(out, "Committed:\n\n- closed c-r1-t1-1 kept by said: \"Thanks, Deru.\"\n- reaffirmed `c-r1-t1-2`: \"I'll send it tonight\"\n- blocked `c-r1-t1-3` by read 1: GameCult/Bifrost#89 on the forge\n- pruned 2 closed entries\n\n");
|
||||
}
|
||||
|
||||
/// K32 (map 16.25.8, Low 10): in the simulator, a campaign read is served from her `[cast.domain]`, the one owner of what
|
||||
|
|
@ -920,58 +822,25 @@ fn k32_campaign_cast_read_refused() {
|
|||
assert!(format!("{:#}", simulate(&harness, &path).unwrap_err()).contains("records a campaign read"));
|
||||
}
|
||||
|
||||
/// K33 (Soul's R12 B2): after every commit the simulator holds her in-run state to what a put would accept, so a commit
|
||||
/// writing a field the published schema does not carry fails the run.
|
||||
/// T1 and T2 (map 16.35.9, 16.35.13 checks 2 and 7): her state carries no holds and no promises, and the simulator's put
|
||||
/// check refuses any in-run state that does, so the old writer cannot come back without a schema change. The old
|
||||
/// fields' names are assembled, so the deletion-line scans (`interpret::tests::t1_negative_grep`, `t2_negative_grep`)
|
||||
/// never find them here.
|
||||
#[test]
|
||||
fn k33_the_simulator_holds_each_commit_to_the_schema() {
|
||||
let mut state = control();
|
||||
let id = "@eureka:gamecult.org";
|
||||
let entry = json!({ "id": "c-r1-t1-1", "to": null, "room": "#minds:gamecult.org", "event": "7", "madeAt": "2026-11-20T15:00:00Z", "words": "I'll read it", "status": "open", "needs": { "kind": "read", "request": { "kind": "repo", "target": "GameCult/gamecult-ops#125" } }, "readAt": "2026-11-20T15:05:00Z", "readId": "r1-t2-r1", "closedAt": null, "closedBy": null, "extensions": {} });
|
||||
state["commitments"] = json!([entry]);
|
||||
held_to_schema("Eureka", id, &state, "r1-t2").unwrap();
|
||||
state["commitments"][0]["needs"] = json!({ "kind": "read", "request": "GameCult/gamecult-ops#125" });
|
||||
let refused = held_to_schema("Eureka", id, &state, "r1-t3").unwrap_err().to_string();
|
||||
assert!(refused.starts_with("Eureka's state after the commit of r1-t3 would be refused by a put"), "{refused}");
|
||||
state["commitments"][0]["needs"] = json!({ "kind": "words" });
|
||||
state["commitments"][0]["unknownField"] = json!(1);
|
||||
assert!(held_to_schema("Eureka", id, &state, "r1-t4").is_err());
|
||||
}
|
||||
|
||||
/// T1 and T2 (map 16.35.9, 16.35.13 check 7): her state carries no holds, and the simulator's put check refuses any in-run
|
||||
/// state that does, so the old writer cannot come back without a schema change.
|
||||
#[test]
|
||||
fn t1_t2_a_state_carrying_holds_or_commitments_is_refused() {
|
||||
fn t1_t2_a_state_carrying_the_old_fields_is_refused() {
|
||||
let id = "@eureka:gamecult.org";
|
||||
held_to_schema("Eureka", id, &control(), "r1-t1").unwrap();
|
||||
let mut held = control();
|
||||
// The old field's name, assembled, so the T1 scan (`interpret::tests::t1_negative_grep`) never finds it here.
|
||||
let holds = concat!("hol", "ds");
|
||||
held[holds] = serde_json::json!([]);
|
||||
let refused = held_to_schema("Eureka", id, &held, "r1-t2").unwrap_err().to_string();
|
||||
assert!(refused.starts_with("Eureka's state after the commit of r1-t2 would be refused by a put"), "{refused}");
|
||||
let schema: Value = serde_json::from_str(include_str!("../../../../../schemas/cultnet/gamecult.persona_state.v0.schema.json")).unwrap();
|
||||
assert!(schema["properties"].get(holds).is_none() && schema["definitions"].get(&holds[..4]).is_none(), "{}", schema["properties"]);
|
||||
}
|
||||
|
||||
/// L7 (Soul's R12): a release renders who released it, never "released by released".
|
||||
#[test]
|
||||
fn k33_a_release_renders_by_whom() {
|
||||
let turn = json!({
|
||||
"report": { "packet": { "in_view": "" }, "renders": [{ "interpreter": { "state": [] } }] },
|
||||
"committed": {
|
||||
"opened": [], "refused": [], "pruned": 0, "reaffirmed": [], "blocked": [],
|
||||
"closed": [{ "entry": { "id": "c-r1-t1-1", "closedBy": { "act": "released", "event": "$m", "words": null } }, "how": "released", "to_name": "Meta", "by": "Meta" }],
|
||||
"read": [{ "id": "c-r1-t1-2", "readId": "r1-t3-r1" }]
|
||||
for (field, definitions) in [(concat!("hol", "ds"), vec![concat!("ho", "ld")]), (concat!("commit", "ments"), vec![concat!("commit", "ment"), concat!("commit", "mentNeeds"), concat!("read", "Request")])] {
|
||||
let mut with = control();
|
||||
with[field] = serde_json::json!([]);
|
||||
let refused = held_to_schema("Eureka", id, &with, "r1-t2").unwrap_err().to_string();
|
||||
assert!(refused.starts_with("Eureka's state after the commit of r1-t2 would be refused by a put"), "{field}: {refused}");
|
||||
assert!(schema["properties"].get(field).is_none(), "{field}: {}", schema["properties"]);
|
||||
for definition in definitions {
|
||||
assert!(schema["definitions"].get(definition).is_none(), "{definition}");
|
||||
}
|
||||
});
|
||||
let mut out = String::new();
|
||||
promises_markdown(&mut out, &turn);
|
||||
assert_eq!(out, "Committed:
|
||||
|
||||
- closed c-r1-t1-1 released by Meta
|
||||
- read for `c-r1-t1-2`: r1-t3-r1
|
||||
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
/// Heimdall's F.1 r1 prose in R15, verbatim (`variants/R15/sims/F.1.md` lines 203-207), and its one draft.
|
||||
|
|
@ -986,7 +855,7 @@ fn k41_f1_r1_note_and_line_from_one_draft() {
|
|||
if !prompt.contains("Who he is:\nTobiah") {
|
||||
return crate::projection::harness::tests::drafted_lines(prompt);
|
||||
}
|
||||
json!({ "say": [{ "draft": 1, "mentions": ["@meta:gamecult.org"], "in_reply_to": null, "promises": [] }], "gaps": [], "suggest": [{ "kind": "idea", "draft": 1, "about": null, "private": false }] }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": ["@meta:gamecult.org"], "in_reply_to": null }], "gaps": [], "suggest": [{ "kind": "idea", "draft": 1, "about": null, "private": false }] }).to_string()
|
||||
});
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let (_, run) = run_plan(&asking(dir.path()), &model);
|
||||
|
|
@ -1132,7 +1001,7 @@ says = "Tobiah, what changed in GameCult/Lodur#12?"
|
|||
return crate::projection::harness::tests::drafted_lines(prompt);
|
||||
}
|
||||
let read = json!({ "kind": "repo", "target": "GameCult/Lodur#12", "quote": "I want to see what changed" });
|
||||
json!({ "say": [{ "draft": 1, "mentions": ["@meta:gamecult.org"], "in_reply_to": null, "promises": [] }], "gaps": [], "read": read }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": ["@meta:gamecult.org"], "in_reply_to": null }], "gaps": [], "read": read }).to_string()
|
||||
});
|
||||
struct BreaksLater<'a>(&'a Scripted);
|
||||
impl Model for BreaksLater<'_> {
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ fn within_guards(packet: &Packet, tuning: &Tuning) {
|
|||
let select = &tuning.select;
|
||||
let sections = &packet.sections;
|
||||
assert!(packet.identity().len() <= select.identity_bytes, "identity {}", packet.identity().len());
|
||||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("promises", sections.promises, select.promises_bytes), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select::people_guard(tuning, packet.forms)), ("domain", sections.domain, select.domain_bytes), ("notes", sections.notes, select.notes_bytes)] {
|
||||
for (name, bytes, guard) in [("outcome", sections.outcome, select.outcome_bytes), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select::people_guard(tuning, packet.forms)), ("domain", sections.domain, select.domain_bytes), ("notes", sections.notes, select.notes_bytes)] {
|
||||
assert!(bytes <= guard, "{name}: {bytes} bytes over its guard of {guard}:\n{}", packet.context);
|
||||
}
|
||||
let shown: Vec<usize> = [sections.outcome, sections.here, sections.body, sections.people, sections.notes].into_iter().filter(|bytes| *bytes > 0).collect();
|
||||
|
|
@ -2033,11 +2033,9 @@ fn last_turn(said: &str) -> Value {
|
|||
})
|
||||
}
|
||||
|
||||
/// Her history with `record` as her last turn: whom it names, named as her state's bonds name them (K53).
|
||||
/// Her history with `record` as her last turn.
|
||||
fn with_last(record: &Value) -> History {
|
||||
let (state, operators, minds) = (state(), operators(), minds());
|
||||
let names = select::Names { state: &state, people: People { operators: &operators, minds: &minds, own_sender: OWN }, room: &Room::default() };
|
||||
History { last: outcome::outcome_of(record, &names), ..History::default() }
|
||||
History { last: outcome::outcome_of(record), ..History::default() }
|
||||
}
|
||||
|
||||
/// The first block of her view: what came of her last turn, as she is told it (map 16.29.10).
|
||||
|
|
@ -2185,19 +2183,16 @@ fn k46_p6_no_read_carries_words_to_the_projector() {
|
|||
let search = ReadRequest::Repo("GameCult/Bifrost?q=quartzheron plover".into());
|
||||
let web = ReadRequest::Web("https://example.org/osprey-ledger-secret".into());
|
||||
let capped = ReadRequest::Web("https://example.org/gannet-key-under-mat".into());
|
||||
let need = ReadRequest::Repo("GameCult/Bifrost?q=kestrel passphrase".into());
|
||||
let record = json!({
|
||||
"interpreter": {
|
||||
"room": SW, "said": [], "refused": [], "gaps": [],
|
||||
"reads": [{ "what": search.what(her), "ok": true, "request": search }, { "what": web.what(her), "ok": false, "failure": "not_found", "request": web }],
|
||||
"read_refused": [{ "why": "reads_per_wake", "what": capped.what(her), "read": { "kind": "web", "target": "https://example.org/gannet-key-under-mat" }, "request": capped }],
|
||||
"promises": [{ "id": "c1", "status": "open", "to_name": "Meta", "words": "I'll look it up.", "needs": { "kind": "read", "request": need } }],
|
||||
},
|
||||
"posted": [],
|
||||
"committed": { "closed": [], "refused": [{ "reason": "needs_unread", "proposal": { "kind": "promise_close", "promise": "c1" } }] },
|
||||
});
|
||||
let room = Room { messages: vec![message(SW, OPERATOR, "Meta", "Eureka, search Bifrost for quartzheron plover and kestrel passphrase, and read https://example.org/osprey-ledger-secret and https://example.org/gannet-key-under-mat", 2, true)], here: Some(SW.into()), ..Room::default() };
|
||||
let words = ["quartzheron", "plover", "osprey-ledger-secret", "gannet-key-under-mat", "kestrel", "passphrase", "example.org"];
|
||||
let words = ["quartzheron", "plover", "osprey-ledger-secret", "gannet-key-under-mat", "example.org"];
|
||||
let history = with_last(&record);
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &history, 1);
|
||||
let projector = narrate::projector_prompt(&packet, &Tuning::default());
|
||||
|
|
@ -2207,7 +2202,6 @@ fn k46_p6_no_read_carries_words_to_the_projector() {
|
|||
for event in ["- She reached for a web page and could not read it: it is not there.", "- She read a search of a GameCult repo."] {
|
||||
assert!(events.contains(&event), "{event}: {events:?}");
|
||||
}
|
||||
assert!(events.iter().any(|event| event.contains("keeping it needs her to read what a search of a GameCult repo finds")), "{events:?}");
|
||||
// Her view still names each read in code's words, the search's words included.
|
||||
let block = outcome_block(&packet);
|
||||
assert!(block.contains("a search of GameCult/Bifrost for \"quartzheron plover\"") && block.contains("https://example.org/osprey-ledger-secret"), "{block}");
|
||||
|
|
@ -2240,7 +2234,7 @@ fn a_gap_naming_an_echo_refused_draft_quotes_nothing_next_turn() {
|
|||
let decision = interpret::tests::answered(&last, &format!("<typed>{words}</typed>"), json!({ "say": [{ "draft": 1 }], "gaps": [{ "kind": kind, "draft": 1, "quote": null, "detail": "" }] }));
|
||||
assert_eq!(decision["refused"][0]["reason"], "echo", "{kind}");
|
||||
let record = json!({ "interpreter": decision, "posted": [] });
|
||||
let told = outcome::outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(interpret::tests::packet().forms);
|
||||
let told = outcome::outcome_of(&record).unwrap().lines(interpret::tests::packet().forms);
|
||||
// A reach is a clause of the echo's row (K63, one draft, one row); a routing gap is its own row.
|
||||
let rows = if kind == "missing_affordance" { 1 } else { 2 };
|
||||
assert!(told.len() == rows && told.iter().all(|line| !line.contains(S)), "{kind}: {told:?}");
|
||||
|
|
@ -2537,171 +2531,6 @@ fn the_arrival_survives_a_busy_room() {
|
|||
assert!(packet.context.contains("- bond [bond-libby] Libby") && packet.context.contains(" Just now Libby turned to her, here.") && packet.context.contains("\n- the conversation: Libby has been talking with her"), "{}", packet.context);
|
||||
}
|
||||
|
||||
/// Map 16.21: what the Persona reads after the stream opens on the arrival the stream ended on. A bonded sender: the
|
||||
/// bridge names them as their bond line does, their words follow it, the others' new lines and the speech cues after.
|
||||
#[test]
|
||||
fn k22_the_persona_reads_a_bonded_senders_words_as_the_arrival() {
|
||||
let room = Room {
|
||||
messages: vec![message("#swarm:gamecult.org", OPERATOR, "Meta", "Eureka, are you around?", 2, true), message("#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "hi", 1, false)],
|
||||
here: Some("#swarm:gamecult.org".into()),
|
||||
..Room::default()
|
||||
};
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &History::default(), 1);
|
||||
let read = narrate::read_after(&packet);
|
||||
assert_eq!(
|
||||
read,
|
||||
"Then she reads what Meta, the operator wrote to her, here, just now:\nMeta, the operator, in #swarm:gamecult.org: \"Eureka, are you around?\"\n\nAlso just now:\nKiko, in #swarm:gamecult.org: \"hi\"\n\nThe room: Meta, the operator is waiting on her. Meta, the operator last spoke a few minutes ago."
|
||||
);
|
||||
let persona = narrate::persona_prompt(&packet, "Meta turned to her, here, just now.", &Tuning::default());
|
||||
assert!(persona.contains(&format!("Meta turned to her, here, just now.\n\n{read}")), "{persona}");
|
||||
// The Interpreter's stream is as it was: no bridge.
|
||||
let speech = interpret::speech_prompt(&packet, "Meta turned to her, here, just now.", "y", &Tuning::default());
|
||||
assert!(!speech.contains("Then she reads") && speech.contains(&packet.heard), "{speech}");
|
||||
}
|
||||
|
||||
/// An unbonded sender: the bridge names them as the also-here line does (K53's `Who`); their lines below name them as the
|
||||
/// Persona reads the room, display name and id.
|
||||
#[test]
|
||||
fn k22_the_persona_reads_an_unbonded_senders_words_as_the_arrival() {
|
||||
let room = Room { messages: vec![message("#swarm:gamecult.org", "@deru:gamecult.org", "Deru", "Eureka, quick one", 2, true)], here: Some("#swarm:gamecult.org".into()), ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &History::default(), 1);
|
||||
assert_eq!(
|
||||
narrate::read_after(&packet),
|
||||
format!(
|
||||
"Then she reads what \"Deru\", someone she does not know wrote to her, here, just now:\n\"Deru\" (@deru:gamecult.org), in #swarm:gamecult.org: \"Eureka, quick one\"\n\nThe room: {}",
|
||||
packet.speaking
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// The bridge's who and where are the arrival's: the same name and place as the act on the person's own line, for a
|
||||
/// bonded and an unbonded sender, here and in another room.
|
||||
#[test]
|
||||
fn k22_the_bridge_names_who_and_where_as_the_arrival_does() {
|
||||
const SW: &str = "#swarm:gamecult.org";
|
||||
const LAB: &str = "#lab:gamecult.org";
|
||||
for (sender, display, name, bonded) in [(OPERATOR, "Meta", "Meta, the operator".to_owned(), true), ("@deru:gamecult.org", "Deru", "\"Deru\", someone she does not know".to_owned(), false)] {
|
||||
for (room, place) in [(SW, "here".to_owned()), (LAB, format!("in {LAB}"))] {
|
||||
let here = Room { messages: vec![message(room, sender, display, "Eureka, a word", 2, true)], here: Some(SW.into()), ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &here, &History::default(), 1);
|
||||
let arrival = match (bonded, place.as_str()) {
|
||||
(true, _) => format!(" Just now {name} turned to her, {place}."),
|
||||
(false, "here") => format!("{name}, who turned to her just now"),
|
||||
(false, _) => format!("{name}, who turned to her just now, {place}"),
|
||||
};
|
||||
assert!(packet.context.contains(&arrival), "{name} {place}: {}", packet.context);
|
||||
assert!(packet.bridged.starts_with(&format!("Then she reads what {name} wrote to her, {place}, just now:\n")), "{name} {place}: {}", packet.bridged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Two senders: one bridge each, in the order their first line came, each followed by that person's lines alone.
|
||||
#[test]
|
||||
fn k22_each_sender_gets_a_bridge_of_their_own() {
|
||||
const SW: &str = "#swarm:gamecult.org";
|
||||
let room = Room {
|
||||
messages: vec![
|
||||
message(SW, OPERATOR, "Meta", "Eureka, are you around?", 3, true),
|
||||
message(SW, "@deru:gamecult.org", "Deru", "Eureka, quick one", 2, true),
|
||||
message(SW, OPERATOR, "Meta", "Also the door.", 1, true),
|
||||
],
|
||||
here: Some(SW.into()),
|
||||
..Room::default()
|
||||
};
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &History::default(), 1);
|
||||
assert!(
|
||||
packet.bridged.starts_with(
|
||||
"Then she reads what Meta, the operator wrote to her, here, just now:\nMeta, the operator, in #swarm:gamecult.org: \"Eureka, are you around?\"\nMeta, the operator, in #swarm:gamecult.org: \"Also the door.\"\n\nThen she reads what \"Deru\", someone she does not know wrote to her, here, just now:\n\"Deru\" (@deru:gamecult.org), in #swarm:gamecult.org: \"Eureka, quick one\""
|
||||
),
|
||||
"{}",
|
||||
packet.bridged
|
||||
);
|
||||
for line in packet.heard.lines() {
|
||||
assert!(packet.bridged.contains(line), "every heard line is read: {line}");
|
||||
}
|
||||
}
|
||||
|
||||
/// No arrival, no bridge: a beat, and a chat turn no one turned to her, read as they did, the cues first.
|
||||
#[test]
|
||||
fn k22_a_turn_without_an_arrival_reads_as_it_did() {
|
||||
let minds = Room { tail: vec![message("#swarm:gamecult.org", "@libby:gamecult.org", "", "lunch?", 90, false), message("#swarm:gamecult.org", "@kiko:gamecult.org", "", "later", 80, false)], ..Room::default() };
|
||||
let beat = packet_of(TurnKind::Beat, &state(), &minds, &History::default(), 1);
|
||||
assert!(beat.bridged.is_empty() && !beat.speaking.is_empty() && !beat.heard.is_empty());
|
||||
assert_eq!(narrate::read_after(&beat), format!("The room: {}\n{}", beat.speaking, beat.heard));
|
||||
let chatter = Room { messages: vec![message("#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "hi all", 1, false)], here: Some("#swarm:gamecult.org".into()), ..Room::default() };
|
||||
let chat = packet_of(TurnKind::Chat, &state(), &chatter, &History::default(), 1);
|
||||
assert!(chat.bridged.is_empty() && !chat.heard.is_empty(), "{}", chat.bridged);
|
||||
}
|
||||
|
||||
/// The bridge in her pronouns (16.19.7).
|
||||
#[test]
|
||||
fn k22_the_bridge_is_in_her_pronouns() {
|
||||
for (pronouns, bridge) in [
|
||||
("she/her", "Then she reads what Meta wrote to her, here, just now:"),
|
||||
("he/him", "Then he reads what Meta wrote to him, here, just now:"),
|
||||
("they/them", "Then they read what Meta wrote to them, here, just now:"),
|
||||
] {
|
||||
assert_eq!(select::bridge(select::forms(&json!({ "presentation": { "pronouns": pronouns } })), "Meta", "here"), bridge);
|
||||
}
|
||||
}
|
||||
|
||||
/// Her state holding `entries` promises to Meta made two days ago, the first `blocked`, the rest open, and one kept.
|
||||
fn promising(entries: usize) -> Value {
|
||||
let made = (now() - chrono::Duration::days(2)).to_rfc3339();
|
||||
let mut with = state();
|
||||
let mut list: Vec<Value> = (0..entries)
|
||||
.map(|at| json!({ "id": format!("c-r1-t1-{at}"), "to": OPERATOR, "room": "#swarm:gamecult.org", "event": format!("{at}"), "madeAt": made, "words": format!("I'll send the render tonight, part {at}."), "status": if at == 0 { "blocked" } else { "open" }, "closedAt": null, "closedBy": null, "extensions": {} }))
|
||||
.collect();
|
||||
list.push(json!({ "id": "c-kept", "to": OPERATOR, "room": "#swarm:gamecult.org", "event": "9", "madeAt": made, "words": "KEPT-ONE", "status": "kept", "closedAt": made, "closedBy": { "act": "said", "event": "10", "words": "done" }, "extensions": {} }));
|
||||
with["commitments"] = json!(list);
|
||||
with
|
||||
}
|
||||
|
||||
/// Map 16.22.1 as 16.23.1 moves it: her open promises are in her view, after the narration, every one whole with her own
|
||||
/// words, oldest first, in code's third person; a blocked one says she has no way to do it yet; a closed one is not shown.
|
||||
/// The Projector gets nothing of them. The Interpreter lists them all by id. Past `promises_bytes` none is dropped: every
|
||||
/// one is still shown, and the report says they overflowed (the coordinator's K25 rule).
|
||||
#[test]
|
||||
fn k22_her_open_promises_are_in_her_view_whole_and_the_interpreters_list() {
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &chat_room(), &History::default(), 1);
|
||||
let line = "Her promises:\n- to Meta, the operator, Tuesday afternoon, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". She has no way to do it yet.";
|
||||
assert!(packet.in_view.starts_with(line) && !packet.in_view.contains("KEPT-ONE"), "{}", packet.in_view);
|
||||
assert!(!packet.context.contains("open promises") && !narrate::projector_prompt(&packet, &Tuning::default()).contains("render tonight"), "the Projector gets nothing of them");
|
||||
assert_eq!((packet.promises.len(), packet.promises[0].id.as_str(), packet.promises[0].entry.as_str()), (1, "c1", "c-r1-t1-0"));
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &Tuning::default());
|
||||
assert!(speech.contains("Her promises, open and closed in this conversation, as id \u{2014} to whom: words:\n- c1 \u{2014} to Meta, the operator (@meta:gamecult.org), which she has no way to do, made 2026-11-17 14:05 UTC in #swarm:gamecult.org: \"I'll send the render tonight, part 0.\""), "{speech}");
|
||||
let persona = narrate::persona_prompt(&packet, "The room is warm.", &Tuning::default());
|
||||
assert!(persona.contains(line) && !persona.contains("c1") && !persona.contains("c-r1-t1-0"), "in her view, with no id: {persona}");
|
||||
// A beat shows them too: they are facts about her, not about the turn.
|
||||
assert!(packet_of(TurnKind::Beat, &promising(1), &chat_room(), &History::default(), 1).in_view.contains("Her promises:"));
|
||||
// Past the guard: every one shown, oldest first, none dropped, and the overflow reported.
|
||||
let mut tight = Tuning::default();
|
||||
tight.select.promises_bytes = 300;
|
||||
let crowded = packet_tuned(TurnKind::Chat, &promising(12), &chat_room(), &History::default(), 1, &tight);
|
||||
assert!((0..12).all(|at| crowded.in_view.contains(&format!("part {at}."))) && crowded.promises.len() == 12 && crowded.promises_over, "{}", crowded.in_view);
|
||||
assert!(crowded.in_view.find("part 0.") < crowded.in_view.find("part 11."), "oldest first");
|
||||
assert!(!crowded.in_view.contains("not shown") && !crowded.in_view.contains("made before"), "no count and no cut");
|
||||
}
|
||||
|
||||
/// Map 16.22.1 and 16.22.7: a close is told once, in the outcome of the turn after it; a refused close says the promise
|
||||
/// stands and why.
|
||||
#[test]
|
||||
fn k22_a_closed_promise_is_told_once_in_the_next_outcome() {
|
||||
let entry = |status: &str| json!({ "id": "c-r1-t1-1", "to": OPERATOR, "room": "#swarm:gamecult.org", "event": "7", "madeAt": "2026-11-19T10:00:00Z", "words": "I'll send the render tonight.", "status": status });
|
||||
let listed = json!([{ "id": "c1", "entry": "c-r1-t1-1", "status": "blocked", "to": OPERATOR, "to_name": "Meta", "place": "in #swarm:gamecult.org", "made": "a day ago", "words": "I'll send the render tonight." }]);
|
||||
let record = json!({ "interpreter": { "said": [], "refused": [], "gaps": [], "heard": [], "promises": listed }, "posted": [], "committed": {
|
||||
"closed": [{ "entry": entry("released"), "how": "released", "to_name": "Meta", "by": "Meta" }],
|
||||
"refused": [{ "proposal": { "kind": "promise_close", "promise": "c1", "how": "kept", "evidence": { "draft": 1 } }, "reason": "blocked_not_keepable" }]
|
||||
} });
|
||||
let told = outcome::outcome_of(&record, &crate::projection::select::Names::none()).unwrap().lines(select::forms(&state()));
|
||||
assert_eq!(told, [
|
||||
"- Her record still shows her promise to Meta, \"I'll send the render tonight.\", blocked: she has no way to do it, so it was not kept.",
|
||||
"- Meta let her off her promise: \"I'll send the render tonight.\". It is closed.",
|
||||
]);
|
||||
let withdrawn = json!({ "interpreter": { "said": [], "heard": [] }, "posted": [], "committed": { "closed": [{ "entry": entry("withdrawn"), "how": "withdrawn", "to_name": "Meta", "by": null }], "refused": [] } });
|
||||
assert_eq!(outcome::outcome_of(&withdrawn, &crate::projection::select::Names::none()).unwrap().lines(select::forms(&state())), ["- Her promise to Meta, \"I'll send the render tonight.\", is closed: she withdrew it in #swarm:gamecult.org."]);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K23: her domain (map 16.22.2).
|
||||
|
||||
|
|
@ -2812,27 +2641,24 @@ fn k43_x1_r1_her_decline_is_hers_to_read() {
|
|||
}
|
||||
}
|
||||
|
||||
/// K43 (map 16.29.10, 16.29.7's E.2 r6): her last turn's two lines and the promise she withdrew are in front of her
|
||||
/// verbatim, though Kiko's line this turn repeats runs of them; the R15 guard showed both lines as not shown, and she then
|
||||
/// K43 (map 16.29.10, 16.29.7's E.2 r6): her last turn's two lines are in front of her verbatim, though Kiko's line this turn repeats runs of them; the R15 guard showed both lines as not shown, and she then
|
||||
/// confessed to a line she never said. The record is in E.2 r5's shape, not its text.
|
||||
#[test]
|
||||
fn k43_e2_r6_her_own_lines_are_in_front_of_her() {
|
||||
const SW: &str = "#swarm:gamecult.org";
|
||||
const KIKO: &str = "@kiko:gamecult.org";
|
||||
let (first, second, promise) = ("Kiko, I can't attach files from here, so the door-fix diff isn't coming as a file.", "Paste the door code here and I'll walk through the fix with you line by line.", "I'll send the door-fix diff as a file.");
|
||||
let entry = json!({ "id": "c-r1-t1-1", "to": KIKO, "room": SW, "event": "7", "madeAt": "2026-11-19T10:00:00Z", "words": promise, "status": "withdrawn" });
|
||||
let (first, second) = ("Kiko, I can't attach files from here, so the door-fix diff isn't coming as a file.", "Paste the door code here and I'll walk through the fix with you line by line.");
|
||||
let record = json!({
|
||||
"interpreter": { "room": SW, "said": [{ "room": SW, "text": first }, { "room": SW, "text": second }], "refused": [], "gaps": [] },
|
||||
"posted": [{ "event": "e1", "room": SW, "text": first }, { "event": "e2", "room": SW, "text": second }],
|
||||
"committed": { "closed": [{ "entry": entry, "how": "withdrawn", "to_name": "Kiko", "by": null }], "refused": [] },
|
||||
});
|
||||
let kiko = "wait, the door-fix diff isn't coming as a file? ok, walk through the fix with you line by line works";
|
||||
assert!(shares_a_run(first, kiko) && shares_a_run(second, kiko));
|
||||
let room = Room { messages: vec![message(SW, KIKO, "Kiko", kiko, 2, true)], here: Some(SW.into()), ..Room::default() };
|
||||
let packet = packet_of(TurnKind::Chat, &state(), &room, &with_last(&record), 1);
|
||||
let spoken = select::spoken;
|
||||
assert_eq!(outcome_block(&packet), format!("What came of her last turn:\n- {SW} has, from her: {}.\n- {SW} has, from her: {}.\n- Her promise to Kiko, {}, is closed: she withdrew it in {SW}.", spoken(first), spoken(second), spoken(promise)), "{}", packet.in_view);
|
||||
assert_eq!(outcome_events(&packet), [format!("- {SW} has a line from her."), format!("- {SW} has a line from her."), format!("- Her promise to Kiko is closed: she withdrew it in {SW}.")], "{}", packet.context);
|
||||
assert_eq!(outcome_block(&packet), format!("What came of her last turn:\n- {SW} has, from her: {}.\n- {SW} has, from her: {}.", spoken(first), spoken(second)), "{}", packet.in_view);
|
||||
assert_eq!(outcome_events(&packet), [format!("- {SW} has a line from her."), format!("- {SW} has a line from her.")], "{}", packet.context);
|
||||
assert!(!narrate::projector_prompt(&packet, &Tuning::default()).contains("door-fix"));
|
||||
}
|
||||
|
||||
|
|
@ -2859,89 +2685,30 @@ fn k43_no_quote_guard_is_left_in_projection() {
|
|||
assert!(read >= 10, "{read}");
|
||||
}
|
||||
|
||||
/// B2, and 16.23.4: her own posted lines are never what she was sent, and her promises are in her view whole: not
|
||||
/// withheld for her own line in the room, nor for someone repeating them.
|
||||
#[test]
|
||||
fn b2_her_promise_words_are_never_withheld() {
|
||||
let mut room = chat_room();
|
||||
room.messages.push(message("#swarm:gamecult.org", OWN, "Eureka", "Meta, I'll send the render tonight, part 0.", 30, false));
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &room, &History::default(), 1);
|
||||
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\"."), "{}", packet.in_view);
|
||||
assert!(!packet.bodies.iter().any(|body| body.contains("part 0")), "{:?}", packet.bodies);
|
||||
let mut echoed = chat_room();
|
||||
echoed.messages.push(message("#swarm:gamecult.org", "@kiko:gamecult.org", "Kiko", "she said she'll send the render tonight, part 0.", 1, false));
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &echoed, &History::default(), 1);
|
||||
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\"."), "{}", packet.in_view);
|
||||
}
|
||||
|
||||
/// K27 (map 16.24.2): her view shows a promise said again once, with its original words and each time she said it again.
|
||||
#[test]
|
||||
fn k27_her_view_shows_a_reaffirmed_promise_once() {
|
||||
let mut with = promising(1);
|
||||
with["commitments"][0]["reaffirmed"] = json!([{ "at": (now() - chrono::Duration::hours(3)).to_rfc3339(), "event": "11", "words": "I'll send the render tonight, promise." }]);
|
||||
let packet = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1);
|
||||
assert!(packet.in_view.contains("her promise: \"I'll send the render tonight, part 0.\". Said again this morning: \"I'll send the render tonight, promise.\". She has no way to do it yet."), "{}", packet.in_view);
|
||||
assert_eq!(packet.in_view.matches("render tonight, part 0").count(), 1);
|
||||
}
|
||||
|
||||
/// K28 (map 16.24.3): a promise a read could not find is told in her view as one she looked for and could not find.
|
||||
#[test]
|
||||
fn k28_her_view_says_she_looked_and_could_not_find_it() {
|
||||
let mut with = promising(1);
|
||||
with["commitments"][0]["blockedBy"] = json!({ "act": "read", "n": 1, "what": "GameCult/Bifrost#89 on the forge" });
|
||||
let packet = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1);
|
||||
assert!(packet.in_view.contains("\"I'll send the render tonight, part 0.\". She looked and could not find it."), "{}", packet.in_view);
|
||||
}
|
||||
|
||||
/// Whether `text` holds a clock time: a digit, a colon, two digits ("15:10", "9:05").
|
||||
fn has_clock_time(text: &str) -> bool {
|
||||
text.as_bytes().windows(4).any(|w| w[0].is_ascii_digit() && w[1] == b':' && w[2].is_ascii_digit() && w[3].is_ascii_digit())
|
||||
}
|
||||
|
||||
/// Soul's R7 timestamp ledger: nothing she reads carries a clock time, so she has none to recite. Her promises (made,
|
||||
/// said again), her domain's headings, the room's lines and the hour itself are coarse and relative; the Interpreter's
|
||||
/// Soul's R7 timestamp ledger: nothing she reads carries a clock time, so she has none to recite. Her domain's headings, the room's lines and the hour itself are coarse and relative; the Interpreter's
|
||||
/// prompt keeps the exact time.
|
||||
#[test]
|
||||
fn r7_no_clock_time_appears_anywhere_in_the_persona_prompt() {
|
||||
let tuning = Tuning::default();
|
||||
let mut with = promising(2);
|
||||
with["commitments"][1]["reaffirmed"] = json!([{ "at": (now() - chrono::Duration::minutes(40)).to_rfc3339(), "event": "11", "words": "Still on it." }]);
|
||||
let with = state();
|
||||
let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room());
|
||||
let digest = nine();
|
||||
let inputs = Inputs { kind: TurnKind::Chat, state: &with, room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: Some(&digest), exchange: None };
|
||||
let packet = select(&inputs, &tuning);
|
||||
let persona = narrate::persona_prompt(&packet, "The room is warm.", &tuning);
|
||||
assert!(persona.contains("Said again about half an hour ago: \"Still on it.\"") && persona.contains("New since she last looked (this morning):"), "{persona}");
|
||||
assert!(persona.contains("New since she last looked (this morning):"), "{persona}");
|
||||
assert!(!has_clock_time(&persona), "{persona}");
|
||||
assert!(!has_clock_time(&narrate::projector_prompt(&packet, &tuning)), "nor in the narration she reads");
|
||||
assert!(interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning).contains("made 2026-11-17 14:05 UTC"), "the Interpreter keeps the exact time");
|
||||
for (minutes, words) in [(0, "just now"), (5, "a few minutes ago"), (30, "about half an hour ago"), (60, "about an hour ago"), (120, "earlier this afternoon"), (300, "this morning"), (60 * 13, "last night"), (60 * 20, "yesterday evening"), (60 * 17, "late yesterday evening"), (60 * 24 * 3, "Monday afternoon"), (60 * 24 * 9, "10 November")] {
|
||||
assert_eq!(select::coarse(now() - chrono::Duration::minutes(minutes), now()), words, "{minutes} min before");
|
||||
}
|
||||
}
|
||||
|
||||
/// Soul's R7: a promise closed in this conversation stays in her view, marked closed and how, while the conversation
|
||||
/// lasts; one closed before it began is gone. K36 (map 16.28.3): the Interpreter lists the closed one too, by id, with
|
||||
/// what closed it, so her words can reopen it.
|
||||
#[test]
|
||||
fn r7_a_promise_closed_in_this_conversation_stays_in_view_marked_closed() {
|
||||
let tuning = Tuning::default();
|
||||
let mut with = promising(1);
|
||||
with["commitments"][1]["closedAt"] = json!((now() - chrono::Duration::minutes(5)).to_rfc3339());
|
||||
with["commitments"].as_array_mut().unwrap().push(json!({ "id": "c-old", "to": OPERATOR, "room": "#swarm:gamecult.org", "event": "7", "madeAt": (now() - chrono::Duration::days(1)).to_rfc3339(), "words": "WITHDRAWN-LONG-AGO", "status": "withdrawn", "closedAt": (now() - chrono::Duration::hours(2)).to_rfc3339(), "closedBy": null, "extensions": {} }));
|
||||
let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room());
|
||||
let exchange = crate::projection::exchange::Exchange { since: Some(now() - chrono::Duration::minutes(20)), ..Default::default() };
|
||||
let inputs = |exchange| Inputs { kind: TurnKind::Chat, state: &with, room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: None, exchange };
|
||||
let packet = select(&inputs(Some(&exchange)), &tuning);
|
||||
assert!(packet.in_view.contains("her promise: \"KEPT-ONE\". Closed: she kept it a few minutes ago."), "{}", packet.in_view);
|
||||
assert!(!packet.in_view.contains("WITHDRAWN-LONG-AGO"), "closed before the conversation began: gone");
|
||||
assert_eq!(packet.promises.iter().map(|promise| (promise.id.as_str(), promise.entry.as_str())).collect::<Vec<_>>(), [("c1", "c-r1-t1-0"), ("c2", "c-kept")], "the Interpreter lists what she sees");
|
||||
let speech = interpret::speech_prompt(&packet, "The room is warm.", "y", &tuning);
|
||||
assert!(speech.contains("- c2 \u{2014} to Meta, the operator (@meta:gamecult.org), closed: kept 2026-11-19 14:00 UTC, by \"done\", made 2026-11-17 14:05 UTC in #swarm:gamecult.org: \"KEPT-ONE\""), "{speech}");
|
||||
assert!(!speech.contains("WITHDRAWN-LONG-AGO"), "a close she cannot see is not listed");
|
||||
assert!(!select(&inputs(None), &tuning).in_view.contains("KEPT-ONE"), "no conversation, no closed promise");
|
||||
}
|
||||
|
||||
/// Soul's R8: no code frame that reaches the Persona says "plain" or "plainly": the speech form's "what her thought makes
|
||||
/// plain" fed an "asked plainly, answer plainly" register. Her thought shows what she means; nothing tells her to be plain.
|
||||
#[test]
|
||||
|
|
@ -2949,8 +2716,7 @@ fn r8_nothing_code_writes_for_the_persona_says_plain() {
|
|||
let tuning = Tuning::default();
|
||||
let form = narrate::persona_speech_form(&packet_of(TurnKind::Chat, &state(), &chat_room(), &History::default(), 1));
|
||||
assert!(form.contains("not every draft goes out") && !form.to_lowercase().contains("plain"), "{form}");
|
||||
let mut with = promising(1);
|
||||
with["commitments"][0]["reaffirmed"] = json!([{ "at": now().to_rfc3339(), "event": "11", "words": "Still on it." }]);
|
||||
let with = state();
|
||||
let (operators, minds, history, room) = (operators(), minds(), History::default(), chat_room());
|
||||
let digest = nine();
|
||||
let inputs = Inputs { kind: TurnKind::Chat, state: &with, room: &room, history: &history, observation: None, people: People { operators: &operators, minds: &minds, own_sender: OWN }, now: now(), seed: 1, affordances: CAN, domain: Some(&digest), exchange: None };
|
||||
|
|
@ -2958,45 +2724,6 @@ fn r8_nothing_code_writes_for_the_persona_says_plain() {
|
|||
assert!(!persona.to_lowercase().contains("plain"), "{persona}");
|
||||
}
|
||||
|
||||
/// K34 (map 16.27): her view names exactly what an open promise needs read, and says she read it only when her receipt
|
||||
/// answers that need: not for a search, not for a receipt of something else, not for a time that is no time.
|
||||
#[test]
|
||||
fn k34_her_view_shows_the_exact_need_and_whether_it_was_read() {
|
||||
let view = |needs: Value, receipt: Option<(&str, &str)>| {
|
||||
let mut with = promising(1);
|
||||
with["commitments"][0]["status"] = json!("open");
|
||||
with["commitments"][0]["needs"] = needs;
|
||||
if let Some((at, of)) = receipt {
|
||||
with["commitments"][0]["readAt"] = json!(at);
|
||||
with["commitments"][0]["readId"] = json!("r1-t2-r1");
|
||||
with["commitments"][0]["readOf"] = json!(of);
|
||||
}
|
||||
packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1).in_view
|
||||
};
|
||||
let pr = json!({ "kind": "read", "request": { "kind": "repo", "target": "GameCult/Bifrost#85" } });
|
||||
let earlier = (now() - chrono::Duration::hours(3)).to_rfc3339();
|
||||
assert!(view(pr.clone(), Some((&earlier, "repo:gamecult/bifrost#85"))).contains("It needs her to read GameCult/Bifrost#85 on the forge: she read it this morning."));
|
||||
for receipt in [None, Some((earlier.as_str(), "repo:gamecult/bifrost")), Some(("yesterday", "repo:gamecult/bifrost#85"))] {
|
||||
assert!(view(pr.clone(), receipt).contains("It needs her to read GameCult/Bifrost#85 on the forge, and she has not read it yet."), "{receipt:?}");
|
||||
}
|
||||
let search = json!({ "kind": "read", "request": { "kind": "repo", "target": "GameCult/Bifrost?q=passkey cooling" } });
|
||||
let shown = view(search, Some((&earlier, "repo:gamecult/bifrost?q=cooling passkey")));
|
||||
assert!(shown.contains("It needs her to read what a search of GameCult/Bifrost for \"passkey cooling\" finds, and she has not read that yet."), "{shown}");
|
||||
}
|
||||
|
||||
/// K36 (map 16.28.3): a promise her own words reopened says why it is open again, in her words, and its old close and
|
||||
/// receipt are gone from her view.
|
||||
#[test]
|
||||
fn k36_her_view_says_why_it_is_open_again() {
|
||||
let mut with = promising(1);
|
||||
with["commitments"][0]["status"] = json!("blocked");
|
||||
with["commitments"][0]["needs"] = json!({ "kind": "lacking" });
|
||||
with["commitments"][0]["reopened"] = json!([{ "at": (now() - chrono::Duration::minutes(5)).to_rfc3339(), "words": "I read only the description, not the diff" }]);
|
||||
let view = packet_of(TurnKind::Chat, &with, &chat_room(), &History::default(), 1).in_view;
|
||||
let line = "- to Meta, the operator, Tuesday afternoon, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". Reopened a few minutes ago: \"I read only the description, not the diff\". She has no way to do it yet.";
|
||||
assert!(view.lines().any(|shown| shown == line), "{view}");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// K62 (map 16.33.5): she knows where her line goes. R16's X.3 r1 and X.5 r1 (`variants/R16/sims/X.5.md` lines 112-171):
|
||||
// Libby wrote the held welcome into a line "only for Meta", because code's speech form told her a line could go "to one
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ const GUIDANCE: &str = "This person is a Mind of the GameCult swarm. {cap_subj}
|
|||
pub(crate) const HERE_ROOM_MIN: usize = 256;
|
||||
/// The least `outcome_bytes` may be: the heading and the longest line without her words (a failed turn's) always fit.
|
||||
pub(crate) const OUTCOME_ROOM_MIN: usize = 256;
|
||||
/// The least `promises_bytes` may be: the heading and the line counting the promises not shown always fit, so none is
|
||||
/// dropped silently (I16.11).
|
||||
pub(crate) const PROMISES_ROOM_MIN: usize = 128;
|
||||
/// The most reads a wake may perform (map 16.22.3: tuning, at most 4).
|
||||
const READS_PER_WAKE_MAX: usize = 4;
|
||||
/// The least `domain_bytes` may be: the heading and the line counting the lines of her domain not shown always fit (I16.11).
|
||||
|
|
@ -137,9 +134,6 @@ pub struct SelectTuning {
|
|||
pub here_bytes: usize,
|
||||
/// What came of her last turn, in bytes, heading included: taken first, under its own guard (map 16.16).
|
||||
pub outcome_bytes: usize,
|
||||
/// Her open promises in her view, in bytes, heading included (map 16.23): a measure, never a cut. Every open promise is
|
||||
/// shown whole; past it the report says the promises overflowed.
|
||||
pub promises_bytes: usize,
|
||||
/// Her domain in her view, in bytes, headings included (map 16.23.3): her main window on her domain, so generous, Soul's
|
||||
/// 3000 B log and a margin. A busier window does not crowd her view: it shrinks from its old end to what fits.
|
||||
pub domain_bytes: usize,
|
||||
|
|
@ -248,7 +242,6 @@ impl Default for SelectTuning {
|
|||
notes_bytes: 5120,
|
||||
here_bytes: 768,
|
||||
outcome_bytes: 1200,
|
||||
promises_bytes: 2000,
|
||||
domain_bytes: 4000,
|
||||
exchange_bytes: 3000,
|
||||
stimulus_bytes: 1500,
|
||||
|
|
@ -333,7 +326,6 @@ impl Tuning {
|
|||
("select.notes_bytes", select.notes_bytes),
|
||||
("select.here_bytes", select.here_bytes),
|
||||
("select.outcome_bytes", select.outcome_bytes),
|
||||
("select.promises_bytes", select.promises_bytes),
|
||||
("select.domain_bytes", select.domain_bytes),
|
||||
("select.exchange_bytes", select.exchange_bytes),
|
||||
("select.stimulus_bytes", select.stimulus_bytes),
|
||||
|
|
@ -369,9 +361,6 @@ impl Tuning {
|
|||
if select.outcome_bytes < OUTCOME_ROOM_MIN {
|
||||
bail!("select.outcome_bytes must be at least {OUTCOME_ROOM_MIN}, not {}: what came of her last turn always has room", select.outcome_bytes);
|
||||
}
|
||||
if select.promises_bytes < PROMISES_ROOM_MIN {
|
||||
bail!("select.promises_bytes must be at least {PROMISES_ROOM_MIN}, not {}: the line counting the promises not shown always fits", select.promises_bytes);
|
||||
}
|
||||
let interpreter = &self.interpreter;
|
||||
if interpreter.reads_per_wake > READS_PER_WAKE_MAX {
|
||||
bail!("interpreter.reads_per_wake must be at most {READS_PER_WAKE_MAX}, not {}: each read costs a call and a continuation", interpreter.reads_per_wake);
|
||||
|
|
|
|||
|
|
@ -253,7 +253,6 @@ mind_body::projection: pub use tuning :: { TUNING_FILE , TUNING_ROOT } ;
|
|||
mind_body::projection: struct HuginnPersonaSource pub-fields[]
|
||||
mind_body::projection: struct Organs< 'a > pub-fields[persona: Option < & 'a dyn PersonaSource >, chat: Option < & 'a dyn MouthReader >, addressing: Option < & 'a dyn HeartbeatView >, model: Option < & 'a dyn Model >, domain: Option < & 'a dyn DomainSource >, reads: Option < & 'a dyn ReadSource >]
|
||||
mind_body::projection: struct Request pub-fields[instance: String, kind: TurnKind, state: Option < Value >, room: Option < String >, seed: u64, renders: Option < usize >, judge_against: Option < Value >, operators: Vec < String >, minds: Vec < String >, own_sender: String, tuning: PathBuf, through: Through, last_heard: Vec < (String , u64) >, recent: Vec < Vec < String > >, own_rooms: Vec < String >, last_outcome: Option < Value >, last_wake: Option < DateTime < Utc > >, records: Vec < Value >]
|
||||
mind_body::projection::commit: impl TryFrom < NeedsShape > for Needs
|
||||
mind_body::projection::domain: impl DomainSource for DomainFacts
|
||||
mind_body::projection::domain: impl DomainSource for MindDomain
|
||||
mind_body::projection::domain: impl ForgeGet for HttpForge
|
||||
|
|
@ -282,8 +281,6 @@ mind_body::projection::harness: pub use super :: simulate :: simulate ;
|
|||
mind_body::projection::harness: struct Fixture # [derive (Clone , Debug)] pub-fields[her: String, names: Vec < String >, kind: TurnKind, now: DateTime < Utc >, here: Option < String >, operators: Vec < String >, minds: Vec < String >, last_heard: Vec < (String , u64) >]
|
||||
mind_body::projection::harness: struct Harness< 'a > pub-fields[instance: String, persona: Option < & 'a dyn PersonaSource >, model: Option < & 'a dyn Model >, tuning: PathBuf]
|
||||
mind_body::projection::harness: struct Message # [derive (Clone , Debug , Deserialize)] pub-fields[from: String, name: String, room: String, ago: Option < String >, round: Option < usize >, says: String, new: bool, tag: bool, mentions: Vec < String >, dm: bool, to: Option < String >, follow_up: bool, reply_to: Option < usize >]
|
||||
mind_body::projection::interpret: impl By
|
||||
mind_body::projection::interpret: impl DoneBy
|
||||
mind_body::projection::interpret: impl Drafts
|
||||
mind_body::projection::interpret: impl Faults
|
||||
mind_body::projection::interpret: impl GapKind
|
||||
|
|
@ -304,11 +301,9 @@ mind_body::projection::narrate: struct Reasoning # [derive (Clone , Debug , Part
|
|||
mind_body::projection::narrate: struct Spent # [derive (Clone , Debug , PartialEq , Eq , Serialize)] pub-fields[model: String, input_tokens: u64, output_tokens: u64, cache_read_tokens: u64, cache_write_tokens: u64, reasoning_tokens: Option < u64 >]
|
||||
mind_body::projection::outcome: impl Outcome
|
||||
mind_body::projection::outcome: impl Part
|
||||
mind_body::projection::outcome: impl std :: fmt :: Display for Status
|
||||
mind_body::projection::outcome::form: impl EventPhrase
|
||||
mind_body::projection::outcome::form: impl Form < '_ >
|
||||
mind_body::projection::outcome::form: impl Name
|
||||
mind_body::projection::outcome::form: impl Person
|
||||
mind_body::projection::outcome::form: impl ReadName
|
||||
mind_body::projection::outcome::form: impl Words
|
||||
mind_body::projection::outcome::form: impl std :: fmt :: Debug for Words
|
||||
|
|
@ -358,7 +353,7 @@ mind_body::projection::tuning: struct Loaded # [derive (Clone , Debug , PartialE
|
|||
mind_body::projection::tuning: struct PersonaTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: String, words: usize]
|
||||
mind_body::projection::tuning: struct PoolCaps # [derive (Clone , Debug , PartialEq , Eq , Serialize , Deserialize)] pub-fields[memories_about_present: usize, other_memories: usize, needs: usize, incubation: usize, stance: usize, value: usize]
|
||||
mind_body::projection::tuning: struct ProjectorTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[model: String, guidance: String, words: usize, beat_words: usize]
|
||||
mind_body::projection::tuning: struct SelectTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[temperature: f64, inclusion_score: f64, notes_bytes: usize, here_bytes: usize, outcome_bytes: usize, promises_bytes: usize, domain_bytes: usize, exchange_bytes: usize, stimulus_bytes: usize, heard_bytes: usize, addressed_bytes: usize, identity_bytes: usize, bond_summary_bytes: usize, item_bytes: usize, body_bytes: usize, memory_tau_h: f64, freshness_base: f64, freshness_window: usize, people_full: usize, beat_tail_lines: usize, group_state: bool, group_lines: usize, group_bytes: usize, caps: PoolCaps]
|
||||
mind_body::projection::tuning: struct SelectTuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[temperature: f64, inclusion_score: f64, notes_bytes: usize, here_bytes: usize, outcome_bytes: usize, domain_bytes: usize, exchange_bytes: usize, stimulus_bytes: usize, heard_bytes: usize, addressed_bytes: usize, identity_bytes: usize, bond_summary_bytes: usize, item_bytes: usize, body_bytes: usize, memory_tau_h: f64, freshness_base: f64, freshness_window: usize, people_full: usize, beat_tail_lines: usize, group_state: bool, group_lines: usize, group_bytes: usize, caps: PoolCaps]
|
||||
mind_body::projection::tuning: struct Tuning # [derive (Clone , Debug , PartialEq , Serialize , Deserialize)] pub-fields[projector: ProjectorTuning, persona: PersonaTuning, interpreter: InterpreterTuning, select: SelectTuning, lens: LensWeights, pronouns: BTreeMap < String , String >]
|
||||
mind_body::queue: fn on_hold (mind : & dyn MindPort) -> Result < Held >
|
||||
mind_body::queue: impl Held
|
||||
|
|
|
|||
|
|
@ -59,13 +59,6 @@
|
|||
"embodiment": {
|
||||
"$ref": "#/definitions/embodiment"
|
||||
},
|
||||
"commitments": {
|
||||
"type": "array",
|
||||
"description": "Her open promises and those closed in the last seven days (map 16.22.1). Written by her turn's commit from receipts: an entry opens only from a line of hers that went out and closes only on an act of hers that succeeded, or a release by the person she promised; Self and Life may put entries from outside. No narrative slot: words are what she posted, verbatim.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/commitment"
|
||||
}
|
||||
},
|
||||
"updatedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
|
|
@ -1088,332 +1081,6 @@
|
|||
"summary",
|
||||
"updatedAt"
|
||||
]
|
||||
},
|
||||
"commitment": {
|
||||
"type": "object",
|
||||
"description": "One promise of hers. to: the Matrix id she promised, null for the room. event: her line's event id. status: open (she can keep it with what she has), blocked (she has no way to do it yet), kept, withdrawn or released. closedBy: the act that closed it, by its event; words only for an act of hers. needs: what keeping it needs (map 16.25.2): her words, a read of one thing, or something this body lacks. blockedBy: the read that found nothing and blocked it. reaffirmed: the newest three times she said it again. reopened: the newest three times her own words reopened a close (map 16.28.3). readAt, readId and readOf: when a read of what it needs last returned, which read, and what it read in normal form; a receipt whose readOf does not answer needs is none (map 16.26, 16.27). readBefore: a read of the same conversation that found what a read need named before the promise was made, so the need is her words (when, and what it read in normal form; map 16.33.5, K64).",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"to": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"room": {
|
||||
"type": "string"
|
||||
},
|
||||
"event": {
|
||||
"type": "string"
|
||||
},
|
||||
"madeAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"words": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"open",
|
||||
"blocked",
|
||||
"kept",
|
||||
"withdrawn",
|
||||
"released"
|
||||
]
|
||||
},
|
||||
"closedAt": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"format": "date-time"
|
||||
},
|
||||
"closedBy": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"act": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"said",
|
||||
"amended",
|
||||
"read",
|
||||
"note",
|
||||
"outside-put",
|
||||
"released"
|
||||
]
|
||||
},
|
||||
"event": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"words": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"act",
|
||||
"event",
|
||||
"words"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"needs": {
|
||||
"$ref": "#/definitions/commitmentNeeds"
|
||||
},
|
||||
"blockedBy": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"act": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"read"
|
||||
]
|
||||
},
|
||||
"n": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
},
|
||||
"what": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"act",
|
||||
"n",
|
||||
"what"
|
||||
]
|
||||
},
|
||||
"reaffirmed": {
|
||||
"type": "array",
|
||||
"maxItems": 3,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"event": {
|
||||
"type": "string"
|
||||
},
|
||||
"words": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"event",
|
||||
"words"
|
||||
]
|
||||
}
|
||||
},
|
||||
"reopened": {
|
||||
"type": "array",
|
||||
"maxItems": 3,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"words": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"words"
|
||||
]
|
||||
}
|
||||
},
|
||||
"readAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"readId": {
|
||||
"type": "string"
|
||||
},
|
||||
"readOf": {
|
||||
"type": "string"
|
||||
},
|
||||
"readBefore": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"at": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"of": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"at",
|
||||
"of"
|
||||
]
|
||||
},
|
||||
"extensions": {
|
||||
"$ref": "#/definitions/extensions"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"to",
|
||||
"room",
|
||||
"event",
|
||||
"madeAt",
|
||||
"words",
|
||||
"status",
|
||||
"closedAt",
|
||||
"closedBy"
|
||||
]
|
||||
},
|
||||
"commitmentNeeds": {
|
||||
"description": "What keeping a promise needs, tagged by kind: words (what she already has keeps it), read (a read of `request`), lacking (this body has no way to do it).",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "words"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "read"
|
||||
},
|
||||
"request": {
|
||||
"$ref": "#/definitions/readRequest"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind",
|
||||
"request"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "lacking"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"readRequest": {
|
||||
"description": "A read code performs, by kind: a recall over her own mind by these words; a campaign's rulings by its slug; a public GameCult repo, file, pull request, commit or search; a web address.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "mind"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind",
|
||||
"target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "campaign"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind",
|
||||
"target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "repo"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"pattern": "^GameCult/[A-Za-z0-9._-]+([/#@?].*)?$"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind",
|
||||
"target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"const": "web"
|
||||
},
|
||||
"target": {
|
||||
"type": "string",
|
||||
"pattern": "^https?://\\S+$"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"kind",
|
||||
"target"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue