diff --git a/crates/mind-body/src/projection/commit.rs b/crates/mind-body/src/projection/commit.rs index bf5ce57..cb787ea 100644 --- a/crates/mind-body/src/projection/commit.rs +++ b/crates/mind-body/src/projection/commit.rs @@ -111,8 +111,6 @@ pub(crate) enum Refusal { ReleaseNotByPromisee, /// A release cited to a line said before she made the promise. ReleaseBeforePromise, - /// A second promise to the same person from one draft (map 16.24.2). - OnePerPersonPerDraft, /// A reaffirmation naming a promise to someone else. ReaffirmsAnother, /// A reaffirmation naming a promise that is no longer open or blocked. @@ -240,9 +238,6 @@ pub(crate) struct Applied { pub reaffirmed: Vec, /// The entries a failed read blocked (`promise_block`, map 16.24.3), as they now stand. pub blocked: Vec, - /// The (draft, person) pairs that opened or reaffirmed a promise this turn: one each. - #[serde(skip)] - promised_by: Vec<(usize, Option)>, } /// The one applier: her state with one turn's proposals applied, as deltas to `state` as it stands at commit, and what @@ -312,15 +307,9 @@ fn apply_one(state: &mut Value, proposal: &Proposal, record: &Value, prose: &str state["commitments"] = json!([]); } match (proposal, resolved) { - (Proposal::PromiseOpen { words: promised, to, doable, reaffirms, needs, evidence }, Resolved::Sent { event, room, text: posted, .. }) => { - // One promise per person per draft (map 16.24.2; F.1's t17 pair). - let draft = match evidence { - Evidence::Draft(n) => *n, - _ => 0, - }; - if applied.promised_by.contains(&(draft, to.clone())) { - return Err(Refusal::OnePerPersonPerDraft); - } + (Proposal::PromiseOpen { words: promised, to, doable, reaffirms, needs, .. }, Resolved::Sent { event, room, text: posted, .. }) => { + // Distinct promises to one person each open their own entry (Soul's R7); a promise said again is one only by + // `reaffirms`. if let Some(id) = reaffirms { let listed = record["interpreter"]["promises"].as_array().into_iter().flatten().find(|shown| shown["id"].as_str() == Some(id.trim())).ok_or(Refusal::NoSuchPromise)?; let entries = state["commitments"].as_array_mut().expect("commitments is an array"); @@ -340,7 +329,6 @@ fn apply_one(state: &mut Value, proposal: &Proposal, record: &Value, prose: &str let keep = again.len().saturating_sub(REAFFIRMED_KEPT); entry["reaffirmed"] = json!(again[keep..]); applied.reaffirmed.push(entry.clone()); - applied.promised_by.push((draft, to.clone())); return Ok(()); } let entries = state["commitments"].as_array_mut().expect("commitments is an array"); @@ -359,7 +347,6 @@ fn apply_one(state: &mut Value, proposal: &Proposal, record: &Value, prose: &str } entries.push(entry.clone()); applied.opened.push(entry); - applied.promised_by.push((draft, to.clone())); Ok(()) } (Proposal::PromiseClose { promise, how, .. }, resolved) => { diff --git a/crates/mind-body/src/projection/commit/tests.rs b/crates/mind-body/src/projection/commit/tests.rs index e4d938d..a6bd3ea 100644 --- a/crates/mind-body/src/projection/commit/tests.rs +++ b/crates/mind-body/src/projection/commit/tests.rs @@ -168,16 +168,16 @@ fn b1_telling_the_person_she_cannot_do_it_withdraws_a_blocked_promise() { assert_eq!(applied.closed[0]["how"], "withdrawn"); } -/// B3 as K27 bounds it (map 16.24.2): a line can carry several promises, one per person: two to one person from one -/// draft open one entry, and the second is refused; the same words twice open once. +/// B3, Soul's R7: a line can carry several promises, and distinct promises to one person each open their own entry; the +/// same words to the same person twice open once. Nothing else merges them: a promise said again is one by `reaffirms`. #[test] -fn b3_one_line_opens_one_entry_per_person() { +fn b3_one_line_opens_one_entry_per_distinct_promise() { let other = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(META.into()), doable: true, reaffirms: None, needs: None, evidence: Evidence::Draft(1) }); let to_kiko = json!(Proposal::PromiseOpen { words: "the render tonight".into(), to: Some(KIKO.into()), doable: true, reaffirms: None, needs: None, evidence: Evidence::Draft(1) }); - let (state, applied) = apply(&json!({}), &record(json!([open(false), other, to_kiko]), json!([]), true), PROSE, "r1-t1", now()); + let (state, applied) = apply(&json!({}), &record(json!([open(false), other.clone(), to_kiko, other]), json!([]), true), PROSE, "r1-t1", now()); let opened: Vec<(&str, &str)> = state["commitments"].as_array().unwrap().iter().map(|entry| (entry["words"].as_str().unwrap(), entry["to"].as_str().unwrap())).collect(); - assert_eq!(opened, [("send the render tonight", META), ("the render tonight", KIKO)], "{applied:?}"); - assert_eq!(reasons(&applied), vec![json!("one_per_person_per_draft")]); + assert_eq!(opened, [("send the render tonight", META), ("the render tonight", META), ("the render tonight", KIKO)], "{applied:?}"); + assert_eq!(reasons(&applied), vec![json!("already_open")]); } /// B5: a keep or a withdrawal must reach the person promised: a line in the promise's room, or a direct message with them. diff --git a/crates/mind-body/src/projection/read/tests.rs b/crates/mind-body/src/projection/read/tests.rs index 84aa28a..6596689 100644 --- a/crates/mind-body/src/projection/read/tests.rs +++ b/crates/mind-body/src/projection/read/tests.rs @@ -11,7 +11,7 @@ fn her() -> Forms { #[test] fn a_repo_target_is_a_public_gamecult_repo_file_pull_request_or_commit() { for good in ["GameCult/Lodur", "GameCult/Lodur/docs/plan.md", "GameCult/Lodur#12", "GameCult/Lodur@4b2c9e1", "GameCult/Aetheria-legacy"] { - assert_eq!(repo_target(good), Some(good), "{good}"); + assert_eq!(repo_target(good).as_deref(), Some(good), "{good}"); } for bad in ["Other/Lodur", "GameCult/", "GameCult/../x", "GameCult/Lodur/../../etc", "GameCult/Lodur#x", "GameCult/Lodur@xyz", "GameCult/Lo dur", "https://eureka.gamecult.org/forge/GameCult/Lodur", "GameCult/Lodur?raw=1"] { assert_eq!(repo_target(bad), None, "{bad}"); @@ -87,7 +87,9 @@ fn a_repo_read_lists_no_open_pull_request_by_title() { /// and a search with nothing found is not found. #[test] fn k28_a_search_finds_an_older_change_by_her_words() { - assert_eq!(repo_target("GameCult/Bifrost?q=consent receipt"), Some("GameCult/Bifrost?q=consent receipt")); + assert_eq!(repo_target("GameCult/Bifrost?q=consent receipt").as_deref(), Some("GameCult/Bifrost?q=consent receipt")); + assert_eq!(repo_target("gamecult/Bifrost?q=consent receipt").as_deref(), Some("GameCult/Bifrost?q=consent receipt"), "the org case-blind, the words spaced once"); + assert_eq!(ReadRequest::Repo("GameCult/BIFROST?q=Consent Receipt".into()).normal(), ReadRequest::Repo("gamecult/bifrost?q=consent receipt".into()).normal()); for bad in ["GameCult/Bifrost?q=", "GameCult/Bifrost?x=1", "GameCult/Bifrost?q=a&state=open", "GameCult/Bifrost?q=../x"] { assert_eq!(repo_target(bad), None, "{bad}"); }