K22: open promises as typed state; the Interpreter proposes state, one applier writes it
Map 16.22.1 and 16.22.7 (rulings persona-unbacked-intent-say-then-amend, persona-promise-release-by-interpreter,
persona-state-third-person). An open promise is a fact about her that lasts until it closes, so it lives in her
persisted state, written by her turn's commit, never by the Interpreter.
- Schema: gamecult.persona_state.v0 gains the optional, closed `commitments` array (id, to, room, event, madeAt,
words, status open|blocked|kept|withdrawn|released, closedAt, closedBy, extensions). No narrative slot.
- Contract: each say and amend item carries a required `promise` (null, or words, to, doable) in place of K21's
`promises`; the answer gains `state[]` of promise_close proposals (kept, withdrawn, released) with evidence
`{draft}` or `{line}`. decide() types them as `commit::Proposal` with `commit::Evidence`; a found promise becomes
a promise_open proposal with Draft evidence, and a promise she cannot do is still the missing_affordance gap.
The decision records the lines and promises it listed by id, so the record is what the commit applies.
- commit.rs: one evidence resolver (Prose, Draft, Heard, Read) and one applier with the kind table: opens only on
a line's receipt; closes only on a sent draft (kept, withdrawn), never kept when blocked; a release only from the
person promised (or anyone in the room for a promise to the room), after madeAt; 4.4: deltas on the state as it
stands, an outside put wins on its entry (outside_put_same_field), a removed entry is not resurrected; closed
entries removed 7 days after closedAt; every refusal typed.
- Packet: a `{Her} open promises:` section after the outcome under its own guard (promises_bytes 600, floor 128),
newest that fit with the rest counted; quotes held to the outcome's withhold guard; the Interpreter's prompt lists
them by id (c1...) and its listed lines carry sender and time for the release check. The Projector frame says once
what the section is.
- Outcome: a close is told once (kept, withdrawn in a room, "{Name} let {obj} off {poss} promise"); a refused close
says the promise is still open and why.
- Simulator: state_after_turn is deleted; each turn's record is applied by commit::apply to the Mind's in-run state
on its receipts, and kept in the record her next outcome reads.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
deee0934a0
commit
978de248a8
16 changed files with 988 additions and 71 deletions
|
|
@ -310,6 +310,40 @@ 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.
|
||||
#[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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn declared_names_are_every_property_name_at_any_depth() {
|
||||
let schema = json!({
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
//! `project` cannot write and runs under a held brake.
|
||||
|
||||
pub mod harness;
|
||||
mod commit;
|
||||
mod interpret;
|
||||
mod narrate;
|
||||
mod outcome;
|
||||
|
|
@ -291,7 +292,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, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "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, "promises": packet.sections.promises, "here": packet.sections.here, "body": packet.sections.body, "people": packet.sections.people, "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,
|
||||
|
|
@ -300,6 +301,7 @@ fn packet_json(packet: &Packet) -> Value {
|
|||
"affordances": packet.affordances,
|
||||
"amendable": packet.amendable,
|
||||
"quotable": packet.quotable,
|
||||
"promises": packet.promises,
|
||||
"context": packet.context,
|
||||
"stimulus": packet.stimulus,
|
||||
"arrival": packet.arrival,
|
||||
|
|
|
|||
283
crates/mind-body/src/projection/commit.rs
Normal file
283
crates/mind-body/src/projection/commit.rs
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
//! 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 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.
|
||||
//!
|
||||
//! Built rows: `promise_open` and `promise_close` (K22). 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.
|
||||
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use ghostlight_persona_projection::SourceSpan;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::interpret::drafts;
|
||||
use super::narrate::words;
|
||||
|
||||
/// How long a closed promise stays in her state before the commit removes it.
|
||||
pub(crate) const CLOSED_KEPT_DAYS: i64 = 7;
|
||||
/// The fewest words a passage of her prose cited as evidence may be (section 4.1's `source_quote`).
|
||||
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, a line she heard, by
|
||||
/// its id in the Interpreter's list, or a read performed this wake (16.22.3).
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) enum Evidence {
|
||||
Prose(String),
|
||||
Draft(usize),
|
||||
Heard(String),
|
||||
Read(usize),
|
||||
}
|
||||
|
||||
/// 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.
|
||||
Withdrawn,
|
||||
/// The person she promised let her off it (`persona-promise-release-by-interpreter`).
|
||||
Released,
|
||||
}
|
||||
|
||||
/// 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")]
|
||||
pub(crate) enum Proposal {
|
||||
PromiseOpen { words: String, to: Option<String>, doable: bool, evidence: Evidence },
|
||||
PromiseClose { promise: String, how: How, evidence: Evidence },
|
||||
}
|
||||
|
||||
/// Why the commit applied nothing of a proposal: what the outcome and the report say.
|
||||
#[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,
|
||||
/// No read was performed this wake.
|
||||
NoSuchRead,
|
||||
/// 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: the outside put wins this turn (4.4 rule 3).
|
||||
OutsidePutSameField,
|
||||
/// Closed already, this turn.
|
||||
AlreadyClosed,
|
||||
/// The same promise to the same person from the same line is open already.
|
||||
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,
|
||||
}
|
||||
|
||||
/// Which evidence each kind accepts: the table of map 16.22.7, one row per kind (and per close).
|
||||
fn accepts(proposal: &Proposal, evidence: &Evidence) -> bool {
|
||||
matches!(
|
||||
(proposal, evidence),
|
||||
(Proposal::PromiseOpen { .. }, Evidence::Draft(_))
|
||||
| (Proposal::PromiseClose { how: How::Kept, .. }, Evidence::Draft(_) | Evidence::Read(_))
|
||||
| (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 and
|
||||
/// her words that went out.
|
||||
Sent { act: &'static str, event: String, room: String, text: String },
|
||||
/// A line she heard: its event, sender, room and time.
|
||||
Heard { event: String, sender: String, room: String, at_ms: u64, who: 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)| SourceSpan::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"]) {
|
||||
return Ok(Resolved::Sent { act: "said", event: text(&receipt["event"]), room: text(&receipt["room"]), text: text(&receipt["text"]) });
|
||||
}
|
||||
}
|
||||
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"]) });
|
||||
}
|
||||
}
|
||||
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"]) })
|
||||
.ok_or(Refusal::NoSuchLine),
|
||||
// No read is performed until K24 builds them, so no read resolves.
|
||||
Evidence::Read(_) => Err(Refusal::NoSuchRead),
|
||||
}
|
||||
}
|
||||
|
||||
fn millis(at: DateTime<Utc>) -> u64 {
|
||||
u64::try_from(at.timestamp_millis()).unwrap_or_default()
|
||||
}
|
||||
|
||||
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.
|
||||
#[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 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.
|
||||
pub(crate) fn apply(state: &Value, record: &Value, prose: &str, key: &str, now: DateTime<Utc>) -> (Value, Applied) {
|
||||
let mut state = state.clone();
|
||||
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 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();
|
||||
}
|
||||
if record.get("failed").is_some() || record["interpreter"].get("failed").is_some() {
|
||||
return (state, 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, &proposal, record, prose, key, now, &mut applied) {
|
||||
applied.refused.push(json!({ "proposal": raw, "reason": reason }));
|
||||
}
|
||||
}
|
||||
(state, applied)
|
||||
}
|
||||
|
||||
fn apply_one(state: &mut 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,
|
||||
};
|
||||
if !accepts(proposal, evidence) {
|
||||
return Err(Refusal::EvidenceNotAccepted);
|
||||
}
|
||||
let resolved = resolve(evidence, record, prose)?;
|
||||
if !state["commitments"].is_array() {
|
||||
state["commitments"] = json!([]);
|
||||
}
|
||||
match (proposal, resolved) {
|
||||
(Proposal::PromiseOpen { words: promised, to, doable, .. }, Resolved::Sent { event, room, text: posted, .. }) => {
|
||||
let entries = state["commitments"].as_array_mut().expect("commitments is an array");
|
||||
if entries.iter().any(|entry| entry["event"] == event.as_str() && entry["to"] == json!(to) && !closed(entry["status"].as_str().unwrap_or_default())) {
|
||||
return Err(Refusal::AlreadyOpen);
|
||||
}
|
||||
// Her posted words, verbatim: the promising words where they stand in the line as written, else the line.
|
||||
let words = posted.find(promised.trim()).map_or_else(|| posted.clone(), |at| posted[at..at + promised.trim().len()].to_owned());
|
||||
let entry = json!({
|
||||
"id": format!("c-{key}-{}", applied.opened.len() + 1), "to": to, "room": room, "event": event, "madeAt": now.to_rfc3339(),
|
||||
"words": words, "status": if *doable { "open" } else { "blocked" }, "closedAt": null, "closedBy": null, "extensions": {}
|
||||
});
|
||||
entries.push(entry.clone());
|
||||
applied.opened.push(entry);
|
||||
Ok(())
|
||||
}
|
||||
(Proposal::PromiseClose { promise, how, .. }, 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();
|
||||
if closed(&status) && applied.closed.iter().any(|done| done["entry"]["id"] == entry["id"]) {
|
||||
return Err(Refusal::AlreadyClosed);
|
||||
}
|
||||
if Some(status.as_str()) != listed["status"].as_str() {
|
||||
return Err(Refusal::OutsidePutSameField);
|
||||
}
|
||||
let (act, event, words, who) = match (how, resolved) {
|
||||
(How::Kept, _) if status == "blocked" => return Err(Refusal::BlockedNotKeepable),
|
||||
(How::Kept | How::Withdrawn, Resolved::Sent { act, event, text, .. }) => (act, json!(event), json!(text), 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))
|
||||
}
|
||||
_ => 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 }));
|
||||
Ok(())
|
||||
}
|
||||
(Proposal::PromiseOpen { .. }, _) => Err(Refusal::EvidenceNotAccepted),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
149
crates/mind-body/src/projection/commit/tests.rs
Normal file
149
crates/mind-body/src/projection/commit/tests.rs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
use chrono::{DateTime, Duration, Utc};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::*;
|
||||
|
||||
const MINDS: &str = "#minds:gamecult.org";
|
||||
const META: &str = "@meta:gamecult.org";
|
||||
const KIKO: &str = "@kiko:gamecult.org";
|
||||
const PROSE: &str = "She can't, not from here. <typed>I'll send the render tonight.</typed> <typed>Meta, I can't send it after all.</typed>";
|
||||
|
||||
fn now() -> DateTime<Utc> {
|
||||
DateTime::parse_from_rfc3339("2026-11-20T15:00:00Z").unwrap().with_timezone(&Utc)
|
||||
}
|
||||
|
||||
fn ms(at: DateTime<Utc>) -> u64 {
|
||||
u64::try_from(at.timestamp_millis()).unwrap()
|
||||
}
|
||||
|
||||
/// A turn that said draft 1 (posted as event "7") and nothing else, proposing `state`; heard Meta's line `q1` and Kiko's
|
||||
/// `q2`, an hour on; showed her `promises`.
|
||||
fn record(state: Value, promises: Value, posted: bool) -> Value {
|
||||
let later = ms(now() + Duration::hours(1));
|
||||
json!({
|
||||
"interpreter": {
|
||||
"said": [{ "room": MINDS, "text": "I'll send the render tonight.", "rests_on": { "draft": 1 } }],
|
||||
"amended": [], "state": state, "promises": promises,
|
||||
"lines": [
|
||||
{ "id": "q1", "event": "$m", "room": MINDS, "who": "Meta", "sender": META, "at_ms": later },
|
||||
{ "id": "q2", "event": "$k", "room": MINDS, "who": "Kiko", "sender": KIKO, "at_ms": later },
|
||||
{ "id": "q3", "event": "$old", "room": MINDS, "who": "Meta", "sender": META, "at_ms": ms(now() - Duration::hours(1)) }
|
||||
]
|
||||
},
|
||||
"posted": if posted { json!([{ "event": "7", "room": MINDS, "text": "I'll send the render tonight." }]) } else { json!([]) },
|
||||
"edited": []
|
||||
})
|
||||
}
|
||||
|
||||
fn open(doable: bool) -> Value {
|
||||
json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(META.into()), doable, evidence: Evidence::Draft(1) })
|
||||
}
|
||||
|
||||
fn close(how: How, evidence: Evidence) -> Value {
|
||||
json!(Proposal::PromiseClose { promise: "c1".into(), how, evidence })
|
||||
}
|
||||
|
||||
/// Her state holding one entry, as the commit opened it.
|
||||
fn holding(status: &str) -> Value {
|
||||
json!({ "commitments": [{ "id": "c-r1-t1-1", "to": META, "room": MINDS, "event": "7", "madeAt": now().to_rfc3339(), "words": "send the render tonight", "status": status, "closedAt": null, "closedBy": null, "extensions": {} }] })
|
||||
}
|
||||
|
||||
fn shown(status: &str) -> Value {
|
||||
json!([{ "id": "c1", "entry": "c-r1-t1-1", "status": status, "to": META, "to_name": "Meta", "place": "in #minds:gamecult.org", "made": "just now", "words": "send the render tonight" }])
|
||||
}
|
||||
|
||||
fn reasons(applied: &Applied) -> Vec<Value> {
|
||||
applied.refused.iter().map(|refused| refused["reason"].clone()).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_said_promise_she_cannot_do_opens_a_blocked_entry_on_its_receipt_and_none_without_one() {
|
||||
let (state, applied) = apply(&json!({}), &record(json!([open(false)]), json!([]), true), PROSE, "r1-t1", now());
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["status"].as_str(), entry["to"].as_str(), entry["event"].as_str(), entry["words"].as_str(), entry["id"].as_str()), (Some("blocked"), Some(META), Some("7"), Some("send the render tonight"), Some("c-r1-t1-1")), "{state}");
|
||||
assert_eq!(applied.opened.len(), 1);
|
||||
let (state, applied) = apply(&json!({}), &record(json!([open(true)]), json!([]), true), PROSE, "r1-t1", now());
|
||||
assert_eq!(state["commitments"][0]["status"], "open", "{applied:?}");
|
||||
// The line did not go out: nothing opens.
|
||||
let (state, applied) = apply(&json!({}), &record(json!([open(false)]), json!([]), false), PROSE, "r1-t1", now());
|
||||
assert_eq!((state.get("commitments"), reasons(&applied)), (None, vec![json!("draft_not_sent")]), "nothing applied writes nothing: {state}");
|
||||
// A failed turn applies nothing.
|
||||
let (state, applied) = apply(&json!({}), &json!({ "failed": "broke" }), PROSE, "r1-t1", now());
|
||||
assert_eq!((state, applied.opened.len()), (json!({}), 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_close_citing_a_draft_that_did_not_go_out_is_refused() {
|
||||
let (state, applied) = apply(&holding("open"), &record(json!([close(How::Withdrawn, Evidence::Draft(2))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!((state["commitments"][0]["status"].as_str(), reasons(&applied)), (Some("open"), vec![json!("draft_not_sent")]));
|
||||
let (_, applied) = apply(&holding("open"), &record(json!([close(How::Withdrawn, Evidence::Draft(9))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!(reasons(&applied), vec![json!("no_draft")]);
|
||||
// Withdrawn by a line that went out.
|
||||
let (state, applied) = apply(&holding("open"), &record(json!([close(How::Withdrawn, Evidence::Draft(1))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!((state["commitments"][0]["status"].as_str(), state["commitments"][0]["closedBy"].clone()), (Some("withdrawn"), json!({ "act": "said", "event": "7", "words": "I'll send the render tonight." })), "{applied:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_blocked_promise_is_not_hers_to_keep_and_can_be_released() {
|
||||
let (state, applied) = apply(&holding("blocked"), &record(json!([close(How::Kept, Evidence::Draft(1))]), shown("blocked"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!((state["commitments"][0]["status"].as_str(), reasons(&applied)), (Some("blocked"), vec![json!("blocked_not_keepable")]));
|
||||
let (state, applied) = apply(&holding("blocked"), &record(json!([close(How::Released, Evidence::Heard("q1".into()))]), shown("blocked"), true), PROSE, "r1-t2", now());
|
||||
let entry = &state["commitments"][0];
|
||||
assert_eq!((entry["status"].as_str(), entry["closedBy"].clone()), (Some("released"), json!({ "act": "released", "event": "$m", "words": null })), "the person's words are not copied: {applied:?}");
|
||||
assert_eq!((applied.closed[0]["by"].as_str(), applied.closed[0]["to_name"].as_str()), (Some("Meta"), Some("Meta")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_release_counts_only_from_the_person_promised_after_the_promise() {
|
||||
let release = |line: &str| apply(&holding("open"), &record(json!([close(How::Released, Evidence::Heard(line.into()))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!(release("q1").0["commitments"][0]["status"], "released");
|
||||
let (state, applied) = release("q2");
|
||||
assert_eq!((state["commitments"][0]["status"].as_str(), reasons(&applied)), (Some("open"), vec![json!("release_not_by_promisee")]));
|
||||
assert_eq!(reasons(&release("q3").1), vec![json!("release_before_promise")]);
|
||||
assert_eq!(reasons(&release("q9").1), vec![json!("no_such_line")]);
|
||||
// A promise to the room is released by anyone in it.
|
||||
let mut to_room = holding("open");
|
||||
to_room["commitments"][0]["to"] = Value::Null;
|
||||
let (state, _) = apply(&to_room, &record(json!([close(How::Released, Evidence::Heard("q2".into()))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!(state["commitments"][0]["status"], "released");
|
||||
}
|
||||
|
||||
/// Section 4.4: her commit applies deltas to the state as it stands. An outside put that unblocked her promise survives
|
||||
/// her commit, and wins on that entry this turn; an entry an outside put removed is not resurrected.
|
||||
#[test]
|
||||
fn an_outside_put_survives_her_commit_and_wins_on_its_entry() {
|
||||
let unblocked = holding("open");
|
||||
let to_kiko = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: Some(KIKO.into()), doable: false, evidence: Evidence::Draft(1) });
|
||||
let (state, applied) = apply(&unblocked, &record(json!([to_kiko]), shown("blocked"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!((state["commitments"][0]["status"].as_str(), state["commitments"][1]["status"].as_str()), (Some("open"), Some("blocked")), "{applied:?}");
|
||||
let (state, applied) = apply(&unblocked, &record(json!([close(How::Withdrawn, Evidence::Draft(1))]), shown("blocked"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!((state["commitments"][0]["status"].as_str(), reasons(&applied)), (Some("open"), vec![json!("outside_put_same_field")]));
|
||||
let (state, applied) = apply(&json!({ "commitments": [] }), &record(json!([close(How::Withdrawn, Evidence::Draft(1))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!((state["commitments"].as_array().map(Vec::len), reasons(&applied)), (Some(0), vec![json!("outside_put_removed_target")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_closed_entry_is_removed_seven_days_after_it_closed() {
|
||||
let (closed, _) = apply(&holding("open"), &record(json!([close(How::Released, Evidence::Heard("q1".into()))]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
let (kept, applied) = apply(&closed, &record(json!([]), json!([]), false), PROSE, "r1-t3", now() + Duration::days(6));
|
||||
assert_eq!((kept["commitments"].as_array().map(Vec::len), applied.pruned), (Some(1), 0));
|
||||
let (gone, applied) = apply(&closed, &record(json!([]), json!([]), false), PROSE, "r1-t3", now() + Duration::days(8));
|
||||
assert_eq!((gone["commitments"].as_array().map(Vec::len), applied.pruned), (Some(0), 1));
|
||||
// An open one is never removed for its age: no expiry.
|
||||
let (old, _) = apply(&holding("open"), &record(json!([]), json!([]), false), PROSE, "r1-t3", now() + Duration::days(30));
|
||||
assert_eq!(old["commitments"].as_array().map(Vec::len), Some(1));
|
||||
}
|
||||
|
||||
/// Map 16.22.7: each kind accepts only its row's evidence, so a line someone else wrote never opens or keeps a promise of
|
||||
/// hers; and evidence that is not the contract is refused. The rule that keeps her the subject: `Heard` is accepted
|
||||
/// only for what someone else did, a release.
|
||||
#[test]
|
||||
fn each_kind_accepts_only_its_rows_evidence() {
|
||||
let heard_open = json!(Proposal::PromiseOpen { words: "send the render tonight".into(), to: None, doable: true, evidence: Evidence::Heard("q1".into()) });
|
||||
let heard_keep = close(How::Kept, Evidence::Heard("q1".into()));
|
||||
let prose_release = close(How::Released, Evidence::Prose("She can't, not from here".into()));
|
||||
let read_keep = close(How::Kept, Evidence::Read(1));
|
||||
let (state, applied) = apply(&holding("open"), &record(json!([heard_open, heard_keep, prose_release, read_keep, { "kind": "feel", "evidence": { "heard": "q1" } }]), shown("open"), true), PROSE, "r1-t2", now());
|
||||
assert_eq!(reasons(&applied), vec![json!("evidence_not_accepted"), json!("evidence_not_accepted"), json!("evidence_not_accepted"), json!("no_such_read"), json!("not_a_proposal")]);
|
||||
assert_eq!((state["commitments"].as_array().map(Vec::len), state["commitments"][0]["status"].as_str()), (Some(1), Some("open")));
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ Kiko, in #swarm:gamecult.org: "She saw it. She hated it."
|
|||
--- projector prompt
|
||||
You are a private Projector. Write one person's present moment from inside it, in the first person and the present tense: the lived stream she will go on to continue in her own thought. Her interior is the point: what she feels, wants, fears and remembers, and how the people here sit with her, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
Render only what is established below: who she is and her present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of her own (nothing she did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of her last turn is what came of what she last meant to do, which she is only now finding out: whenever something she meant did not happen, the stream begins from it, as she notices it, never as a list; when all of it happened, it may pass in a clause or not at all. Her open promises are what she gave her word to do and has not done or taken back: facts about her that hold until they close, there in her awareness as a kept word is, never a list. Here and now is the hour, how her mood leans when it does, and the room as it stands. Her body is how the moment reaches her and how she can answer it: it is not news to her, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as she holds them, not as those people are. The notes about her were set down at another time, by others and by her own past self: all of it is material for the stream and never its wording. How her words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what she might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects.
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,14 @@
|
|||
//! 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`: the words of it that promise an act she cannot do, or null; when they are at least
|
||||
//! `PROMISE_MIN_WORDS` words found in the draft (`promise_found`), code records them as the `missing_affordance` gap
|
||||
//! (map 16.21), and otherwise they are reported (`promises_unused`) and record none. 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.
|
||||
//! required `promise`: null, or the words of it that promise an act, to whom, and whether she can do it (map 16.21,
|
||||
//! 16.22.1). 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
|
||||
//! (`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
|
||||
//! composes the edit), and leave Self one note (`suggest`, map 16.18; recorded in the turn's record, never a write to her
|
||||
|
|
@ -37,6 +40,7 @@ use ghostlight_persona_projection::SourceSpan;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::commit::{Evidence, How, Proposal};
|
||||
use super::narrate::{Model, heard_overlap, lived_stream, words};
|
||||
use super::select::{Forms, Packet, capitalized, spoken, turn_words, voiced};
|
||||
use super::tuning::Tuning;
|
||||
|
|
@ -63,7 +67,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"],"properties":{"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":["string","null"]}}}},"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":["string","null"]}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","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","state"],"properties":{"state":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","promise","how","evidence"],"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"]}}}}}},"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","promise"],"properties":{"target":{"type":"string"},"draft":{"type":"integer","minimum":1},"promise":{"type":["object","null"],"additionalProperties":false,"required":["words","to","doable"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"}}}}}},"say":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["draft","mentions","in_reply_to","promise"],"properties":{"draft":{"type":"integer","minimum":1},"mentions":{"type":"array","items":{"type":"string"}},"in_reply_to":{"type":["string","null"]},"promise":{"type":["object","null"],"additionalProperties":false,"required":["words","to","doable"],"properties":{"words":{"type":"string"},"to":{"type":["string","null"]},"doable":{"type":"boolean"}}}}}},"gaps":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","draft","quote","detail"],"properties":{"kind":{"type":"string","enum":["conditional","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
|
||||
|
|
@ -83,10 +87,11 @@ fn speech_frame_tail(her: Forms) -> String {
|
|||
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 the words of the draft that promise an act {subj} {has} no way to do, now or later, copied exactly (`promises`, or null when it promises none). `gaps` records what {subj} meant and did not send. `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 its words that promise an act {subj} {has} no way to do, copied exactly (`promises`, or null). 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.
|
||||
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 (`promise`, or null when it promises nothing): its words that promise an act, 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), and whether {subj} can do it with what {subj} can do here, now or later (`doable`). `gaps` records what {subj} meant and did not send. `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 `promise`. 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; 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 draft cited closes the promise only when it goes out this turn, and a thought alone closes nothing. A promise {subj} {has} no way to do is never kept by {obj}; it can be withdrawn or released.
|
||||
|
||||
A draft is said whole or not at all, and only once. At most two drafts a turn. Record a gap instead of guessing: conditional when {subj} {has} drafted something {subj} might say but {has} not chosen to, 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 three, 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" },
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +120,7 @@ impl Drafts {
|
|||
}
|
||||
|
||||
/// Her prose outside every draft: her thought, as byte ranges.
|
||||
fn thought(&self, prose: &str) -> Vec<(usize, usize)> {
|
||||
pub(crate) fn thought(&self, prose: &str) -> Vec<(usize, usize)> {
|
||||
let mut at = 0;
|
||||
let mut out = Vec::new();
|
||||
for &(start, end) in &self.regions {
|
||||
|
|
@ -320,6 +325,20 @@ 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>,
|
||||
}
|
||||
|
||||
/// What a line or an addition promises (map 16.22.1): its promising words, to whom (a Matrix id listed, none for the
|
||||
/// room), and whether she can do it with what she has.
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ProposedPromise {
|
||||
words: String,
|
||||
#[serde(default)]
|
||||
to: Option<String>,
|
||||
doable: bool,
|
||||
}
|
||||
|
||||
/// A note to Self as the model proposes it: its kind, the draft that is the note, whose feedback it passes on (a Matrix
|
||||
|
|
@ -336,8 +355,8 @@ 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 its
|
||||
/// words that promise an act she has no way to do (as a line's `promises`).
|
||||
/// 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`).
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ProposedAmend {
|
||||
#[serde(default)]
|
||||
|
|
@ -345,7 +364,7 @@ struct ProposedAmend {
|
|||
#[serde(default)]
|
||||
draft: Option<i64>,
|
||||
#[serde(default)]
|
||||
promises: Option<String>,
|
||||
promise: Option<ProposedPromise>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
|
|
@ -357,10 +376,10 @@ 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>,
|
||||
/// The words of the draft that promise an act she has no way to do (map 16.21): code derives the `missing_affordance`
|
||||
/// gap from them when they are found in the draft.
|
||||
/// What the draft promises (map 16.21, 16.22.1): found in the draft, code proposes opening it, which the commit applies
|
||||
/// on the line's receipt; a promise she cannot do is also the `missing_affordance` gap.
|
||||
#[serde(default)]
|
||||
promises: Option<String>,
|
||||
promise: Option<ProposedPromise>,
|
||||
}
|
||||
|
||||
pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tuning: &Tuning) -> String {
|
||||
|
|
@ -384,6 +403,18 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
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})"));
|
||||
let status = if promise.status == "blocked" { format!("which {} {} no way to do", her.subj, her.has) } else { "open".to_owned() };
|
||||
format!("- {} \u{2014} to {}{to}, {status}, made {} {}: {}\n", promise.id, promise.to_name, promise.made, promise.place, spoken(&promise.words))
|
||||
})
|
||||
.collect();
|
||||
if promises.is_empty() {
|
||||
promises.push_str("- none\n");
|
||||
}
|
||||
let found = drafts(prose);
|
||||
let mut numbered: String = found.drafts.iter().map(|draft| format!("{}. {}\n", draft.n, draft.text)).collect();
|
||||
if numbered.is_empty() {
|
||||
|
|
@ -398,7 +429,7 @@ pub(crate) fn speech_prompt(packet: &Packet, narration: &str, prose: &str, tunin
|
|||
let guidance = voiced(tuning.interpreter.guidance.trim(), her);
|
||||
let guidance = if guidance.is_empty() { String::new() } else { format!("{guidance}\n\n") };
|
||||
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}\nWhat reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{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{poss} open promises, as id \u{2014} to whom: words:\n{promises}\nWhat reached {}:\n{}\n\n{poss} lived moment:\n{}\n\n{poss} prose:\n{prose}\n\n{poss} drafts, by number:\n{numbered}",
|
||||
speech_frame_head(her),
|
||||
speech_frame_tail(her),
|
||||
her.subj,
|
||||
|
|
@ -445,7 +476,10 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
let found = drafts(prose);
|
||||
let gaps: Vec<Value> = parsed.gaps.iter().map(|raw| gap(prose, &found, raw)).collect();
|
||||
// What she was shown this turn rides in the record, so what she is told of it next turn quotes none of it (`outcome`).
|
||||
let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "heard": packet.bodies, "usage": answer.usage });
|
||||
// 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 })).collect();
|
||||
let mut decision = json!({ "said": [], "refused": [], "gaps": gaps, "heard": packet.bodies, "lines": lines, "promises": packet.promises, "usage": answer.usage });
|
||||
if let Some(open) = found.unfinished {
|
||||
decision["unfinished"] = json!(prose[open + DRAFT_OPEN.len()..].trim());
|
||||
}
|
||||
|
|
@ -462,6 +496,8 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
let mut went: Vec<&Draft> = Vec::new();
|
||||
let mut said_drafts: Vec<usize> = Vec::new();
|
||||
let mut unused: Vec<Value> = Vec::new();
|
||||
let mut proposals: Vec<Value> = Vec::new();
|
||||
let mut to_dropped: Vec<Value> = 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));
|
||||
|
|
@ -495,7 +531,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
said_drafts.push(draft.n);
|
||||
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 } }));
|
||||
promised(&mut decision, &mut unused, draft, line.promises.as_deref());
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped }, draft, line.promise.as_ref(), &shown);
|
||||
}
|
||||
// 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).
|
||||
|
|
@ -522,7 +558,7 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
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 }));
|
||||
promised(&mut decision, &mut unused, draft, proposed.promises.as_deref());
|
||||
promised(&mut decision, Promising { unused: &mut unused, proposals: &mut proposals, to_dropped: &mut to_dropped }, draft, proposed.promise.as_ref(), &shown);
|
||||
}
|
||||
(reason, _) => refusals.push(refused(Act::Amend, Some(draft), None, reason.unwrap_or(Refusal::NotAmendable))),
|
||||
}
|
||||
|
|
@ -579,9 +615,39 @@ pub(crate) fn decide(model: &dyn Model, request_id: &str, packet: &Packet, narra
|
|||
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),
|
||||
}
|
||||
}
|
||||
decision["state"] = json!(proposals);
|
||||
if !state_unused.is_empty() {
|
||||
decision["state_unused"] = json!(state_unused);
|
||||
}
|
||||
decision
|
||||
}
|
||||
|
||||
/// A close as the contract carries it: a listed promise's id, how, and exactly one of a draft and a line as evidence.
|
||||
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()?;
|
||||
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,
|
||||
};
|
||||
Some(Proposal::PromiseClose { promise, how, evidence })
|
||||
}
|
||||
|
||||
/// Her words compared as a promise is found in a draft: case-blind, and a curly apostrophe or single quote read as a
|
||||
/// straight one.
|
||||
fn folded(text: &str) -> String {
|
||||
|
|
@ -601,17 +667,43 @@ fn promise_found(draft: &str, promise: &str) -> Result<(), &'static str> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A promise in a draft she says or adds is a gap code derives (map 16.21): the field is required of every line and
|
||||
/// every addition, so the judgement is made for each. Words that do not name an act in the draft (`promise_found`) are
|
||||
/// reported in `unused` and record no gap; a reach the answer already gapped on this draft is not recorded twice.
|
||||
fn promised(decision: &mut Value, unused: &mut Vec<Value>, draft: &Draft, promises: Option<&str>) {
|
||||
let Some(promise) = promises.map(str::trim).filter(|promise| !promise.is_empty()) else {
|
||||
/// Where a promise found in a draft is recorded: words that name no act, the open proposals, and a `to` naming no one
|
||||
/// listed.
|
||||
struct Promising<'a> {
|
||||
unused: &'a mut Vec<Value>,
|
||||
proposals: &'a mut Vec<Value>,
|
||||
to_dropped: &'a mut Vec<Value>,
|
||||
}
|
||||
|
||||
/// A promise in a draft she says or adds (map 16.21, 16.22.1): the field is required of every line and every addition,
|
||||
/// so the judgement is made for each. Words that do not name an act in the draft (`promise_found`) are reported in
|
||||
/// `unused` and open nothing. Found, code proposes opening it 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). A promise
|
||||
/// she cannot do is also the `missing_affordance` gap; a reach the answer already gapped on this draft is not recorded
|
||||
/// twice.
|
||||
fn promised(decision: &mut Value, into: Promising, draft: &Draft, promise: Option<&ProposedPromise>, shown: &dyn Fn(&str) -> bool) {
|
||||
let Some(promise) = promise.filter(|promise| !promise.words.trim().is_empty()) else {
|
||||
return;
|
||||
};
|
||||
if let Err(why) = promise_found(&draft.text, promise) {
|
||||
unused.push(json!({ "draft": draft.n, "promises": promise, "why": why }));
|
||||
} else if let Some(gaps) = decision["gaps"].as_array_mut().filter(|gaps| !gaps.iter().any(|gap| gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"] == json!(draft.n))) {
|
||||
gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": promise, "detail": null }));
|
||||
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;
|
||||
}
|
||||
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,
|
||||
};
|
||||
into.proposals.push(json!(Proposal::PromiseOpen { words: words.to_owned(), to, doable: promise.doable, evidence: Evidence::Draft(draft.n) }));
|
||||
if promise.doable {
|
||||
return;
|
||||
}
|
||||
if let Some(gaps) = decision["gaps"].as_array_mut().filter(|gaps| !gaps.iter().any(|gap| gap["kind"] == json!(GapKind::MissingAffordance) && gap["from"] == "draft" && gap["draft"] == json!(draft.n))) {
|
||||
gaps.push(json!({ "kind": GapKind::MissingAffordance, "from": "draft", "draft": draft.n, "words": draft.text, "promises": words, "detail": null }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ fn an_amendment_off_the_list_a_second_one_or_one_reusing_a_draft_is_refused_and_
|
|||
#[test]
|
||||
fn the_interpreter_sees_his_lines_by_id_never_by_event_and_is_told_he_never_takes_a_word_back() {
|
||||
let prompt = speech_prompt(&amendable_packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("His own lines in this room that he may add to, as id \u{2014} line:\n- a1 \u{2014} \"I'll send the file tonight.\"\n- a2 \u{2014} \"Back soon.\"\n\nWhat reached him:"), "{prompt}");
|
||||
assert!(prompt.contains("His own lines in this room that he may add to, as id \u{2014} line:\n- a1 \u{2014} \"I'll send the file tonight.\"\n- a2 \u{2014} \"Back soon.\"\n\nHis open promises, as id"), "{prompt}");
|
||||
assert!(!prompt.contains("$ev-"), "the actuator's handle is never shown to a model: {prompt}");
|
||||
assert!(prompt.contains("The line stays as it was and the draft is added after it; he never takes a word back."), "{prompt}");
|
||||
assert!(speech_prompt(&packet(), "x", "y", &Tuning::default()).contains("may add to, as id \u{2014} line:\n- none\n"));
|
||||
|
|
@ -591,20 +591,20 @@ fn k17_a_said_promise_of_an_act_he_cannot_do_is_kept_as_a_gap_and_told_as_a_prom
|
|||
#[test]
|
||||
fn k21_a_lines_promises_words_found_in_it_are_the_promise_gap() {
|
||||
let prose = "<typed>Missed you too. I'll send the render tonight.</typed>";
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
|
||||
let decision = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promise": { "words": "I'll send the render tonight.", "to": null, "doable": false } }], "gaps": [] }));
|
||||
let gap = &decision["gaps"][0];
|
||||
assert_eq!((gap["kind"].as_str(), gap["from"].as_str(), gap["draft"].as_u64(), gap["promises"].as_str()), (Some("missing_affordance"), Some("draft"), Some(1), Some("I'll send the render tonight.")), "{decision}");
|
||||
let record = json!({ "interpreter": decision, "posted": [{ "event": "40", "room": MINDS, "text": "Missed you too. I'll send the render tonight." }] });
|
||||
let told = crate::projection::outcome::outcome_of(&record).unwrap().lines(packet().forms);
|
||||
assert_eq!(told, ["- #minds:gamecult.org has, from him: \"Missed you too. I'll send the render tonight.\". It promises something he has no way to do, now or later, and it will not happen by itself. The line stands as he wrote it; he can add to it."]);
|
||||
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll mail you the render." }], "gaps": [] }));
|
||||
let unfound = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promise": { "words": "I'll mail you the render.", "to": null, "doable": false } }], "gaps": [] }));
|
||||
assert_eq!((unfound["gaps"].as_array().unwrap().len(), unfound["promises_unused"].clone()), (0, json!([{ "draft": 1, "promises": "I'll mail you the render.", "why": "not in the draft" }])), "{unfound}");
|
||||
let none = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": null }], "gaps": [] }));
|
||||
let none = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promise": null }], "gaps": [] }));
|
||||
assert!(none["gaps"].as_array().unwrap().is_empty() && none.get("promises_unused").is_none(), "{none}");
|
||||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
let twice = answered(&packet(), prose, json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promise": { "words": "I'll send the render tonight.", "to": null, "doable": false } }], "gaps": [{ "kind": "missing_affordance", "draft": 1, "quote": null, "detail": "" }] }));
|
||||
assert_eq!(twice["gaps"].as_array().unwrap().len(), 1, "{twice}");
|
||||
let prompt = speech_prompt(&packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("(`promises`, or null when it promises none)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","promises"]"#), "{prompt}");
|
||||
assert!(prompt.contains("(`promise`, or null when it promises nothing)") && SPEECH_SCHEMA.contains(r#""required":["draft","mentions","in_reply_to","promise"]"#), "{prompt}");
|
||||
}
|
||||
|
||||
/// Soul's probe at 0cfc386: the reach names no draft and quotes the said one by its words. It is the promise on that draft,
|
||||
|
|
@ -683,7 +683,7 @@ fn k18_a_note_whose_answer_does_not_say_private_is_refused_as_private() {
|
|||
#[test]
|
||||
fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_one_too() {
|
||||
let prose = "<typed>Missed you too. I'll send the render tonight.</typed> <typed>Also the kettle sounds fine.</typed>";
|
||||
let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "in_reply_to": null, "promises": promises }], "gaps": [] }));
|
||||
let say = |draft: u64, promises: &str| answered(&packet(), prose, json!({ "say": [{ "draft": draft, "mentions": [], "in_reply_to": null, "promise": { "words": promises, "to": null, "doable": false } }], "gaps": [] }));
|
||||
let short = say(2, "the");
|
||||
assert_eq!((short["gaps"].as_array().unwrap().len(), short["promises_unused"].clone()), (0, json!([{ "draft": 2, "promises": "the", "why": "fewer than four words" }])), "{short}");
|
||||
assert_eq!(say(1, "the render tonight")["promises_unused"][0]["why"], "fewer than four words");
|
||||
|
|
@ -691,12 +691,12 @@ fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_
|
|||
let decision = say(1, promises);
|
||||
assert_eq!((decision["gaps"][0]["kind"].as_str(), decision["gaps"][0]["promises"].as_str(), decision.get("promises_unused")), (Some("missing_affordance"), Some(promises), None), "{promises}: {decision}");
|
||||
}
|
||||
let curly = answered(&packet(), "<typed>I\u{2019}ll send the render tonight.</typed>", json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promises": "I'll send the render tonight." }], "gaps": [] }));
|
||||
let curly = answered(&packet(), "<typed>I\u{2019}ll send the render tonight.</typed>", json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": null, "promise": { "words": "I'll send the render tonight.", "to": null, "doable": false } }], "gaps": [] }));
|
||||
assert_eq!(curly["gaps"][0]["kind"], "missing_affordance", "a curly apostrophe in the draft: {curly}");
|
||||
|
||||
// An addition's promise: the same derivation, kept (not `acted`), and told on the addition's row.
|
||||
let prose = "I should fix that. <typed>I'll send the file tomorrow instead, first thing.</typed>";
|
||||
let amend = |promises: Value| answered(&amendable_packet(), prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "promises": promises }] }));
|
||||
let amend = |promises: Value| answered(&amendable_packet(), prose, json!({ "say": [], "gaps": [], "amend": [{ "target": "a1", "draft": 1, "promise": if promises.is_null() { Value::Null } else { json!({ "words": promises, "to": null, "doable": false }) } }] }));
|
||||
let decision = amend(json!("I'll send the file tomorrow"));
|
||||
let gap = &decision["gaps"][0];
|
||||
assert_eq!((gap["kind"].as_str(), gap["from"].as_str(), gap["draft"].as_u64(), gap["promises"].as_str()), (Some("missing_affordance"), Some("draft"), Some(1), Some("I'll send the file tomorrow")), "{decision}");
|
||||
|
|
@ -713,5 +713,5 @@ fn k21_a_promise_is_four_words_or_more_found_case_blind_and_an_addition_carries_
|
|||
assert_eq!(amend(json!("send"))["promises_unused"][0]["why"], "fewer than four words");
|
||||
assert!(amend(Value::Null)["gaps"].as_array().unwrap().is_empty());
|
||||
let prompt = speech_prompt(&amendable_packet(), "x", "y", &Tuning::default());
|
||||
assert!(prompt.contains("and its words that promise an act he has no way to do, copied exactly (`promises`, or null)") && SPEECH_SCHEMA.contains(r#""required":["target","draft","promises"]"#), "{prompt}");
|
||||
assert!(prompt.contains("and what it promises, as a line's `promise`") && SPEECH_SCHEMA.contains(r#""required":["target","draft","promise"]"#), "{prompt}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,12 +156,12 @@ pub(crate) fn word_budget(kind: TurnKind, tuning: &Tuning) -> usize {
|
|||
/// no options and no steering toward a decision. A fix to Ghostlight's membrane is read and ported here on purpose;
|
||||
/// nothing reaches this frame from it. In her own pronouns (map 16.19.7): never a generic "they" beside a packet in "he".
|
||||
pub(crate) fn projector_frame(her: Forms) -> String {
|
||||
let Forms { subj, obj, poss, be, s, .. } = her;
|
||||
let Forms { subj, obj, poss, be, has, s, .. } = her;
|
||||
let cap_poss = capitalized(poss);
|
||||
format!(
|
||||
"{PROJECTOR_OPENING} Write one person's present moment from inside it, in the first person and the present tense: the lived stream {subj} will go on to continue in {poss} own thought. {cap_poss} interior is the point: what {subj} feel{s}, want{s}, fear{s} and remember{s}, and how the people here sit with {obj}, rendered as lived, not listed.
|
||||
|
||||
Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
Render only what is established below: who {subj} {be} and {poss} present under its headings. Anything absent from these is unavailable: render suspicion or speculation as uncertainty, never as remembered or perceived fact. Furnish no place, object or event these do not give: no act or event of {poss} own (nothing {subj} did, drafted, sent or decided) and no line anyone said that is not below. Each heading says what its lines are. What came of {poss} last turn is what came of what {subj} last meant to do, which {subj} {be} only now finding out: whenever something {subj} meant did not happen, the stream begins from it, as {subj} notice{s} it, never as a list; when all of it happened, it may pass in a clause or not at all. {cap_poss} open promises are what {subj} gave {poss} word to do and {has} not done or taken back: facts about {obj} that hold until they close, there in {poss} awareness as a kept word is, never a list. Here and now is the hour, how {poss} mood leans when it does, and the room as it stands. {cap_poss} body is how the moment reaches {obj} and how {subj} can answer it: it is not news to {obj}, and a lack in it is felt only when the moment reaches for something it cannot do. The people here are as {subj} hold{s} them, not as those people are. The notes about {obj} were set down at another time, by others and by {poss} own past self: all of it is material for the stream and never its wording. How {poss} words run is the stream's idiom, never its material: it shows in how the stream moves, and nothing in the stream remarks on it.
|
||||
|
||||
Render the two or three notes this moment touches and leave the rest. Do not recap the notes. Do not weigh options, list what {subj} might say or do, or steer toward a decision: end where the moment is, not on a resolution. Do not choose actions, emit schemas, expose field names or ids, or claim world effects."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
use serde_json::Value;
|
||||
|
||||
use super::commit::{How, Refusal as StateRefusal};
|
||||
use super::interpret::{GapKind, MAX_LINES, Refusal};
|
||||
use super::select::{Forms, capitalized, clip, spoken};
|
||||
|
||||
|
|
@ -73,6 +74,11 @@ 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. `by` is who let her
|
||||
/// off it, for a release.
|
||||
Closed { how: How, to: String, words: String, room: String, by: String },
|
||||
/// A close the commit refused: the promise stands, and why.
|
||||
StillOpen { reason: StateRefusal, to: String, words: String },
|
||||
}
|
||||
|
||||
/// What came of her last turn: what she is told, what she is not and why, and the lines that went out.
|
||||
|
|
@ -216,6 +222,25 @@ pub(crate) fn outcome_of(record: &Value) -> Option<Outcome> {
|
|||
if let Some(text) = words(&decision["unfinished"]) {
|
||||
outcome.parts.push(Part::Unfinished { room: room.clone(), text });
|
||||
}
|
||||
// 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(&done["entry"]["words"])) else {
|
||||
outcome.omitted.push(format!("a close without its kind or words: {done}"));
|
||||
continue;
|
||||
};
|
||||
let text = |value: &Value| value.as_str().unwrap_or_default().to_owned();
|
||||
outcome.parts.push(Part::Closed { how, to: text(&done["to_name"]), words, room: text(&done["entry"]["room"]), by: text(&done["by"]) });
|
||||
}
|
||||
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::OutsidePutSameField)), Some(listed)) if refused["proposal"]["kind"] == "promise_close" => {
|
||||
outcome.parts.push(Part::StillOpen { reason, to: listed["to_name"].as_str().unwrap_or("the room").to_owned(), words: listed["words"].as_str().unwrap_or_default().to_owned() });
|
||||
}
|
||||
_ => outcome.omitted.push(format!("a state change the commit refused that she is not told ({}): {}", refused["reason"], refused["proposal"])),
|
||||
}
|
||||
}
|
||||
if words(&record["broke_after"]).is_some() {
|
||||
outcome.parts.push(Part::BrokeAfter { room });
|
||||
}
|
||||
|
|
@ -240,9 +265,9 @@ impl Part {
|
|||
fn rank(&self) -> u8 {
|
||||
match self {
|
||||
Self::Failed => 0,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) => 1,
|
||||
Self::Refused { .. } | Self::Gap { .. } | Self::Unfinished { .. } | Self::NotAmended { .. } | Self::NoteRefused(_) | Self::StillOpen { .. } => 1,
|
||||
Self::Promise { .. } | Self::Amended { promise: true, .. } => 2,
|
||||
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) => 3,
|
||||
Self::Said { .. } | Self::Amended { .. } | Self::NoteLeft(_) | Self::Closed { .. } => 3,
|
||||
Self::BrokeAfter { .. } => 4,
|
||||
}
|
||||
}
|
||||
|
|
@ -268,6 +293,9 @@ 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, words, .. } => format!("{by} let {obj} off {poss} promise: {}.", quoted(words)),
|
||||
Self::Closed { to, words, .. } => format!("{} promise to {to}, {}, is closed:", capitalized(poss), quoted(words)),
|
||||
Self::StillOpen { to, words, .. } => format!("{} promise to {to}, {}, is still open:", capitalized(poss), quoted(words)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -313,6 +341,14 @@ 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::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 { .. } => 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."),
|
||||
}
|
||||
}
|
||||
|
|
@ -337,7 +373,7 @@ impl Part {
|
|||
/// someone else's from someone repeating hers back to her (Soul at 964ee50: Meta quoted her "the render tonight" back,
|
||||
/// and the old "(words that repeat what she had been sent)" told her that her own promise had been an echo, which she
|
||||
/// then confessed to).
|
||||
fn withheld(her: Forms) -> String {
|
||||
pub(crate) fn withheld(her: Forms) -> String {
|
||||
format!("({} words, not shown here)", her.poss)
|
||||
}
|
||||
|
||||
|
|
@ -355,7 +391,7 @@ const REPEAT_RUN: usize = 3;
|
|||
/// ("of the", "I think"). What it gives up: a quote of hers that shares three words in a row with what she was sent,
|
||||
/// or with what was said to her this turn (her own words quoted back included), is withheld; and someone's words of
|
||||
/// one or two words reach the Projector inside a short quote of hers.
|
||||
fn repeats(text: &str, sent: &[&str]) -> bool {
|
||||
pub(crate) fn repeats(text: &str, sent: &[&str]) -> bool {
|
||||
let tokens = |text: &str| -> Vec<String> { text.split(|c: char| !c.is_alphanumeric() && c != '\'').filter(|word| !word.is_empty()).map(str::to_lowercase).collect() };
|
||||
let mine = tokens(text);
|
||||
mine.len() >= REPEAT_RUN
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use serde_json::Value;
|
|||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::Affordance;
|
||||
use super::outcome::Outcome;
|
||||
use super::outcome::{self, Outcome};
|
||||
use super::tuning::{LensWeights, Tuning};
|
||||
use crate::address::localpart;
|
||||
|
||||
|
|
@ -328,8 +328,11 @@ 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).
|
||||
/// 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).
|
||||
pub quotable: Vec<Quotable>,
|
||||
/// Her open promises the packet shows her, for the Interpreter's list (map 16.22.1).
|
||||
pub promises: Vec<Promised>,
|
||||
/// What came of her last turn that the outcome's guard left out, whole: counted in the packet's last outcome line and
|
||||
/// reported here (map 16.20.5, I16.11), never shown to a model.
|
||||
pub unshown: Vec<String>,
|
||||
|
|
@ -353,11 +356,30 @@ pub(crate) struct Quotable {
|
|||
pub id: String,
|
||||
pub event: String,
|
||||
pub room: String,
|
||||
/// Who said it, as the packet names them (`name_of`).
|
||||
/// Who said it, as the packet names them (`name_of`), and their Matrix id: a release is checked against it (16.22.7).
|
||||
pub who: String,
|
||||
pub sender: String,
|
||||
pub at_ms: u64,
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
/// An open promise of hers as this packet lists it (map 16.22.1): for the Interpreter, by `id` (`c1`, `c2`), to propose a
|
||||
/// close 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 how long ago.
|
||||
pub place: String,
|
||||
pub made: String,
|
||||
pub words: String,
|
||||
}
|
||||
|
||||
/// What the messages to her cost past the caps: bytes over the stimulus and heard caps, the older messages to her the
|
||||
/// `addressed_bytes` ceiling left out, and the bytes clipped from a single message larger than the ceiling.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize)]
|
||||
|
|
@ -1674,6 +1696,8 @@ fn body_lines(state: &Value, can: &[Affordance], her: Forms, body_bytes: usize)
|
|||
enum Section {
|
||||
/// What came of her last turn (`outcome`, map 16.16): first, so she meets it before anything else.
|
||||
Outcome,
|
||||
/// Her open promises (map 16.22.1): facts about her that last until they close.
|
||||
Promises,
|
||||
/// The hour, her mood, the room as it stands.
|
||||
Here,
|
||||
/// Her senses and actuators, and what this turn can do: how the moment reaches her and how she can answer.
|
||||
|
|
@ -1688,6 +1712,7 @@ impl Section {
|
|||
fn heading(self, her: Forms) -> String {
|
||||
match self {
|
||||
Self::Outcome => format!("What came of {} last turn:", her.poss),
|
||||
Self::Promises => format!("{} open promises:", capitalized(her.poss)),
|
||||
Self::Here => "Here and now:".into(),
|
||||
Self::Body => format!("{} body:", capitalized(her.poss)),
|
||||
Self::People => format!("People here, as {} hold{} them:", her.subj, her.s),
|
||||
|
|
@ -1708,7 +1733,73 @@ const TURNED_BYTES: usize = NAME_BYTES + 40;
|
|||
/// No section's guard is another's, so no section's content can displace another's.
|
||||
fn guards(tuning: &Tuning, her: Forms) -> [usize; SECTIONS] {
|
||||
let select = &tuning.select;
|
||||
[select.outcome_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.notes_bytes]
|
||||
[select.outcome_bytes, select.promises_bytes, select.here_bytes, select.body_bytes, people_guard(tuning, her), select.notes_bytes]
|
||||
}
|
||||
|
||||
/// How long ago a promise was made, in words.
|
||||
fn ago(now: DateTime<Utc>, at: DateTime<Utc>) -> String {
|
||||
let minutes = (now - at).num_minutes().max(0);
|
||||
match minutes {
|
||||
0 => "just now".to_owned(),
|
||||
1..60 => format!("{minutes} min ago"),
|
||||
60..1440 => format!("{} h ago", minutes / 60),
|
||||
1440..2880 => "a day ago".to_owned(),
|
||||
_ => format!("{} days ago", minutes / 1440),
|
||||
}
|
||||
}
|
||||
|
||||
/// Her open promises (map 16.22.1): each `open` or `blocked` entry of her state's `commitments`, oldest first, as a fact
|
||||
/// about her in code's third person, under the section's own guard (`promises_bytes`, I16.8). Past the guard the newest
|
||||
/// that fit are shown and the older ones counted, never dropped silently (I16.11). Her words are her posted words; a
|
||||
/// quote that repeats a run of what she was sent this turn is withheld as the outcome's are (I16.7). The entries shown
|
||||
/// are the Interpreter's list, by id.
|
||||
fn open_promises(inputs: &Inputs, her: Forms, bodies: &[String], context: &mut Context) -> Vec<Promised> {
|
||||
let mut entries: Vec<(DateTime<Utc>, &Value)> = items(inputs.state, &["commitments"])
|
||||
.iter()
|
||||
.filter(|entry| matches!(text(entry, &["status"]), "open" | "blocked"))
|
||||
.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 sent: Vec<&str> = bodies.iter().map(String::as_str).collect();
|
||||
let promised: Vec<Promised> = entries
|
||||
.iter()
|
||||
.map(|(at, entry)| {
|
||||
let to = entry.get("to").and_then(Value::as_str).map(str::to_owned);
|
||||
let room = text(entry, &["room"]);
|
||||
Promised {
|
||||
id: String::new(),
|
||||
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: ago(inputs.now, *at),
|
||||
words: text(entry, &["words"]).to_owned(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let line = |promise: &Promised| {
|
||||
let words = if outcome::repeats(&promise.words, &sent) { outcome::withheld(her) } else { spoken(&promise.words) };
|
||||
let blocked = if promise.status == "blocked" { format!(" {} {} no way to do it yet.", her.cap_subj, her.has) } else { String::new() };
|
||||
format!("- to {}, {}, {}, {} promise: {words}.{blocked}", promise.to_name, promise.made, promise.place, her.poss)
|
||||
};
|
||||
let lines: Vec<String> = promised.iter().map(line).collect();
|
||||
let count = |more: usize| format!("- {more} older {} not shown here.", if more == 1 { "promise is" } else { "promises are" });
|
||||
let room = context.room(Section::Promises).saturating_sub(Section::Promises.heading(her).len() + 1);
|
||||
let cost = |shown: usize| lines[lines.len() - shown..].iter().map(|line| line.len() + 1).sum::<usize>() + if shown < lines.len() { count(lines.len() - shown).len() + 1 } else { 0 };
|
||||
let shown = (0..=lines.len()).rev().find(|&shown| cost(shown) <= room).unwrap_or(0);
|
||||
if shown < lines.len() {
|
||||
context.bound[Section::Promises as usize] = true;
|
||||
context.push(Section::Promises, count(lines.len() - shown));
|
||||
}
|
||||
let first = lines.len() - shown;
|
||||
let mut listed = Vec::new();
|
||||
for (at, line) in lines.into_iter().enumerate().skip(first) {
|
||||
if context.push(Section::Promises, line) {
|
||||
listed.push(Promised { id: format!("c{}", listed.len() + 1), ..promised[at].clone() });
|
||||
}
|
||||
}
|
||||
listed
|
||||
}
|
||||
|
||||
/// The people's guard: its heading and the bonds a packet shows in full, each a summary, its head, the act of turning to
|
||||
|
|
@ -1719,13 +1810,14 @@ pub(crate) fn people_guard(tuning: &Tuning, her: Forms) -> usize {
|
|||
Section::People.heading(her).len().saturating_add(select.people_full.saturating_mul(bond))
|
||||
}
|
||||
|
||||
const SECTIONS: usize = 5;
|
||||
const SECTIONS: usize = 6;
|
||||
|
||||
/// 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.
|
||||
#[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,
|
||||
|
|
@ -1746,7 +1838,7 @@ struct Context {
|
|||
|
||||
impl Context {
|
||||
fn new(guards: [usize; SECTIONS], her: Forms) -> Self {
|
||||
Self { sections: [Section::Outcome, Section::Here, Section::Body, Section::People, Section::Notes].map(|section| (section.heading(her), Vec::new())), guards, used: [0; SECTIONS], bound: [false; SECTIONS] }
|
||||
Self { sections: [Section::Outcome, Section::Promises, Section::Here, Section::Body, Section::People, Section::Notes].map(|section| (section.heading(her), Vec::new())), guards, used: [0; SECTIONS], bound: [false; SECTIONS] }
|
||||
}
|
||||
|
||||
fn cost(&self, section: Section, line: &str) -> usize {
|
||||
|
|
@ -1788,8 +1880,8 @@ 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), here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
let names = ["outcome", "promises", "here", "body", "people", "notes"];
|
||||
Sections { outcome: bytes(Section::Outcome), promises: bytes(Section::Promises), here: bytes(Section::Here), body: bytes(Section::Body), people: bytes(Section::People), notes: bytes(Section::Notes), bound: names.into_iter().zip(self.bound).filter_map(|(name, bound)| bound.then_some(name)).collect() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1840,7 +1932,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
.into_iter()
|
||||
.filter(|line| line.sender != inputs.people.own_sender && !line.event.is_empty() && Some(line.room.as_str()) == turn_room(inputs))
|
||||
.enumerate()
|
||||
.map(|(at, line)| Quotable { id: format!("q{}", at + 1), event: line.event.clone(), room: line.room.clone(), who: name_of(line, inputs), text: line.text.clone() })
|
||||
.map(|(at, line)| Quotable { id: format!("q{}", at + 1), event: line.event.clone(), room: line.room.clone(), who: name_of(line, inputs), sender: line.sender.clone(), at_ms: line.at_ms, text: line.text.clone() })
|
||||
.collect();
|
||||
// What came of her last turn, first and under its own guard, so nothing else can crowd it out (map 16.20.5, I16.11).
|
||||
// Quotes are clipped first: a line past the guard keeps its sentence and has its quote clipped, leaving each later
|
||||
|
|
@ -1875,6 +1967,7 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
unshown = (shown..outcome.len()).map(|at| outcome.line(at, her, usize::MAX, &bodies)).collect();
|
||||
}
|
||||
}
|
||||
let promises = open_promises(inputs, her, &bodies, &mut context);
|
||||
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, %H:%M UTC")));
|
||||
|
|
@ -2001,5 +2094,5 @@ pub(crate) fn select(inputs: &Inputs, tuning: &Tuning) -> Packet {
|
|||
.map(|(at, (event, room, text))| Amendable { id: format!("a{}", at + 1), event: event.clone(), room: room.clone(), text: text.clone() })
|
||||
.collect();
|
||||
let selected = taken.into_iter().map(|candidate| Pick { id: candidate.id, pool: candidate.pool, log_score: candidate.log_score }).collect();
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), 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)), bodies, private, clipped, amendable, quotable, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
Packet { kind: inputs.kind, seed: inputs.seed, lens, name, voice, context: context.render(), sections: context.sizes(), stimulus, heard, bridged, overflow, present: present_names, ids, selected, forms: her, people: people_in_view(inputs, tuning), 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)), bodies, private, clipped, amendable, quotable, promises, arrival, speaking: conversation.speaking.unwrap_or_default(), unshown }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +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 does not move during a run: the Interpreter (C3b) and the commit (C3c) are not built. `state_after_turn`
|
||||
//! is the seam where they will. 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.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
|
||||
//! until then either: a spoken line addresses another persona only by the names in its text.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
|
@ -33,6 +34,7 @@ use chrono::{DateTime, Duration, Utc};
|
|||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::commit;
|
||||
use super::harness::{Harness, Line, Message, OVERLAP_FLAG, cosine, pending_for, state_file, turn_markdown, usage_markdown, usage_total};
|
||||
use super::select::Draw;
|
||||
use super::tuning;
|
||||
|
|
@ -156,12 +158,6 @@ impl HeartbeatView for Names<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// The seam where the Interpreter (C3b) will turn her prose into proposals and the commit (C3c) will apply them, so her
|
||||
/// next turn starts from the state this one left. Until they exist it returns her state unchanged.
|
||||
fn state_after_turn(state: Value, _turn: &Value) -> Value {
|
||||
state
|
||||
}
|
||||
|
||||
fn speaker(line: &Line, member: &Member, operators: &[String], cast: &[String]) -> Speaker {
|
||||
if line.from == member.entry.id {
|
||||
Speaker::Her
|
||||
|
|
@ -472,16 +468,20 @@ fn run(harness: &Harness, plan: &SimFile, members: &mut [Member], repeat: usize)
|
|||
for (index, note) in render["interpreter"]["suggestions"].as_array().into_iter().flatten().filter(|_| failed.is_none()).enumerate() {
|
||||
inbox.push(json!({ "key": format!("r{}-t{counter}-s{index}", repeat + 1), "mind": localpart(&id), "round": round, "at": now.to_rfc3339(), "kind": note["kind"], "about": note["about"], "room": note["room"], "text": note["text"] }));
|
||||
}
|
||||
last[at] = Some(match &failed {
|
||||
let mut record = match &failed {
|
||||
Some(failed) => json!({ "failed": failed }),
|
||||
None => json!({ "interpreter": render["interpreter"], "posted": posted, "edited": edited, "refused_sends": refused_sends }),
|
||||
});
|
||||
};
|
||||
// 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);
|
||||
record["committed"] = json!(applied);
|
||||
last[at] = Some(record.clone());
|
||||
let line = (!spoken.is_empty()).then(|| spoken.join(" / "));
|
||||
let outcome = if failed.is_some() { "failed" } else if line.is_some() { "spoke" } else { "silent" };
|
||||
let (how, by) = why.map_or((None, vec![]), |why| (why.how, why.by));
|
||||
let turn = json!({ "round": round, "persona": member.entry.name, "id": id, "woke": cause, "how": how, "addressed_by": by, "kind": kind, "room": here, "outcome": outcome, "failed": failed, "said": line, "edited": edited, "report": report });
|
||||
let member = &mut members[at];
|
||||
member.state = state_after_turn(std::mem::take(&mut member.state), &turn);
|
||||
let turn = json!({ "round": round, "persona": member.entry.name, "id": id, "woke": cause, "how": how, "addressed_by": by, "kind": kind, "room": here, "outcome": outcome, "failed": failed, "said": line, "edited": edited, "committed": record["committed"], "report": report });
|
||||
members[at].state = state;
|
||||
turns.push(turn);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -530,7 +530,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": null }], "gaps": [] }).to_string()
|
||||
json!({ "say": [{ "draft": 1, "mentions": [], "in_reply_to": "q1", "promise": null }], "gaps": [] }).to_string()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -584,3 +584,59 @@ fn soul_k12_notes_to_self_are_collected_into_the_runs_inbox_and_told_as_left() {
|
|||
let report = simulate(&harness, &path).unwrap();
|
||||
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, "promise": { "words": "I'll send the render tonight.", "to": "@meta:gamecult.org", "doable": false } }], "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 } }] }).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"]["context"].as_str().unwrap().to_owned();
|
||||
let shown = "His open 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:?}");
|
||||
assert!(!context(his[3]).contains(shown), "a closed promise is not shown again: {}", 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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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), ("here", sections.here, select.here_bytes), ("body", sections.body, select.body_bytes), ("people", sections.people, select::people_guard(tuning, packet.forms)), ("notes", sections.notes, select.notes_bytes)] {
|
||||
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)), ("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();
|
||||
|
|
@ -2522,3 +2522,57 @@ fn k22_the_bridge_is_in_her_pronouns() {
|
|||
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: her open promises are a section of every packet, from her state, after the outcome and before Here and
|
||||
/// now, in code's third person; a blocked one says she has no way to do it yet; a closed one is not shown. The
|
||||
/// Interpreter lists the same ones by id. Past the section's own guard the newest are shown and the rest counted.
|
||||
#[test]
|
||||
fn k22_her_open_promises_are_a_section_of_every_packet_and_the_interpreters_list() {
|
||||
let packet = packet_of(TurnKind::Chat, &promising(1), &chat_room(), &History::default(), 1);
|
||||
let line = "Her open promises:\n- to Meta, the operator, 2 days ago, in #swarm:gamecult.org, her promise: \"I'll send the render tonight, part 0.\". She has no way to do it yet.\nHere and now:";
|
||||
assert!(packet.context.contains(line) && !packet.context.contains("KEPT-ONE"), "{}", packet.context);
|
||||
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 open promises, 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 2 days ago in #swarm:gamecult.org: \"I'll send the render tonight, part 0.\""), "{speech}");
|
||||
assert!(!narrate::projector_prompt(&packet, &Tuning::default()).contains("c-r1-t1-0"), "the state's id never reaches a model");
|
||||
// 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).context.contains("Her open promises:"));
|
||||
// Past the guard: the newest that fit, oldest first, and the rest counted, never dropped silently.
|
||||
let crowded = packet_of(TurnKind::Chat, &promising(12), &chat_room(), &History::default(), 1);
|
||||
let section = crowded.context.split("Here and now:").next().unwrap();
|
||||
assert!(section.len() <= Tuning::default().select.promises_bytes + "Here and now:".len(), "{section}");
|
||||
let counted: usize = section.lines().find_map(|line| line.strip_prefix("- ").and_then(|rest| rest.split(" older promises are not shown here.").next()).and_then(|n| n.parse().ok())).expect("a counted line");
|
||||
assert_eq!(counted + crowded.promises.len(), 12, "{section}");
|
||||
assert!(section.contains("part 11.") && !section.contains("part 0."), "the newest are kept: {section}");
|
||||
}
|
||||
|
||||
/// 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).unwrap().lines(select::forms(&state()));
|
||||
assert_eq!(told, [
|
||||
"- Her promise to Meta, \"I'll send the render tonight.\", is still open: 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).unwrap().lines(select::forms(&state())), ["- Her promise to Meta, \"I'll send the render tonight.\", is closed: she withdrew it in #swarm:gamecult.org."]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ 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 least `body_bytes` may be: the body heading, the longest turn line (`select::turn_words`) and one entry at the
|
||||
/// standard's upper target always fit.
|
||||
pub(crate) const BODY_ROOM_MIN: usize = 768;
|
||||
|
|
@ -130,6 +133,8 @@ 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 bytes, heading included: under their own guard (map 16.22.1, I16.8).
|
||||
pub promises_bytes: usize,
|
||||
pub stimulus_bytes: usize,
|
||||
/// What was said to her, verbatim, for the Persona stage: on a chat turn, the room's earlier lines too, before the new
|
||||
/// ones (map 16.20.3).
|
||||
|
|
@ -228,6 +233,7 @@ impl Default for SelectTuning {
|
|||
notes_bytes: 5120,
|
||||
here_bytes: 768,
|
||||
outcome_bytes: 1200,
|
||||
promises_bytes: 600,
|
||||
stimulus_bytes: 1500,
|
||||
heard_bytes: 2500,
|
||||
addressed_bytes: 8 * 1024,
|
||||
|
|
@ -310,6 +316,7 @@ 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.stimulus_bytes", select.stimulus_bytes),
|
||||
("select.heard_bytes", select.heard_bytes),
|
||||
("select.identity_bytes", select.identity_bytes),
|
||||
|
|
@ -343,6 +350,9 @@ 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 lens = &self.lens;
|
||||
let weights = [lens.body_and_hour, lens.person_present, lens.unresolved_want, lens.memory_surfacing, lens.wondering];
|
||||
if weights.iter().any(|weight| !weight.is_finite() || *weight < 0.0) || lens.body_and_hour <= 0.0 {
|
||||
|
|
|
|||
|
|
@ -311,7 +311,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, said: 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, 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, promises_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,6 +59,13 @@
|
|||
"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"
|
||||
|
|
@ -1081,6 +1088,107 @@
|
|||
"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.",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"extensions": {
|
||||
"$ref": "#/definitions/extensions"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"to",
|
||||
"room",
|
||||
"event",
|
||||
"madeAt",
|
||||
"words",
|
||||
"status",
|
||||
"closedAt",
|
||||
"closedBy"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue