memoryd: sync begins when Honcho is turned on, and conclusions are matched by peer

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-28 13:40:48 -07:00
co-authored by ornith-1.5-35b-a3b
parent fb2afa1979
commit 5f4e0d9997
25 changed files with 720 additions and 80 deletions
+15 -15
View File
@@ -41,7 +41,7 @@ fn examples() -> Vec<(Record, &'static str)> {
&edit("2026-09-28-0002", 1),
unconclude(Workspace::Trusted, "Kyle takes his coffee black."),
),
r#"{"type":"decided","time":"2026-09-28T10:00:00.000Z","item":{"type":"edit","id":"2026-09-28-0002","part":1},"action":{"type":"unconclude","workspace":"trusted","text":"Kyle takes his coffee black."}}"#,
r#"{"type":"decided","time":"2026-09-28T10:00:00.000Z","item":{"type":"edit","id":"2026-09-28-0002","part":1},"action":{"type":"unconclude","workspace":"trusted","peer":"kyle","text":"Kyle takes his coffee black."}}"#,
),
(
decided(
@@ -329,11 +329,11 @@ fn a_conclusion_is_the_latest_one_not_undone() {
ledger
.append(decided(&first, conclude(Workspace::Trusted, text)))
.unwrap();
assert_eq!(ledger.conclusion(Workspace::Trusted, text), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", text), None);
ledger.append(sent(&first, &["c-1"])).unwrap();
let found = |id: &str, item: &Item| Some((item.clone(), id.to_string()));
assert_eq!(
ledger.conclusion(Workspace::Trusted, text),
ledger.conclusion(Workspace::Trusted, "kyle", text),
found("c-1", &first)
);
ledger
@@ -341,26 +341,26 @@ fn a_conclusion_is_the_latest_one_not_undone() {
.unwrap();
ledger.append(sent(&second, &["c-2"])).unwrap();
assert_eq!(
ledger.conclusion(Workspace::Trusted, text),
ledger.conclusion(Workspace::Trusted, "kyle", text),
found("c-2", &second)
);
ledger
.append(decided(&undo1, unconclude(Workspace::Trusted, text)))
.unwrap();
assert_eq!(
ledger.conclusion(Workspace::Trusted, text),
ledger.conclusion(Workspace::Trusted, "kyle", text),
found("c-2", &second)
);
ledger.append(sent(&undo1, &[])).unwrap();
assert_eq!(
ledger.conclusion(Workspace::Trusted, text),
ledger.conclusion(Workspace::Trusted, "kyle", text),
found("c-1", &first)
);
ledger
.append(decided(&undo2, unconclude(Workspace::Trusted, text)))
.unwrap();
ledger.append(sent(&undo2, &[])).unwrap();
assert_eq!(ledger.conclusion(Workspace::Trusted, text), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", text), None);
// The latest is the one sent last, not the one decided last.
let (early, late) = (edit("2026-09-28-0005", 0), edit("2026-09-28-0006", 0));
for item in [&early, &late] {
@@ -371,7 +371,7 @@ fn a_conclusion_is_the_latest_one_not_undone() {
ledger.append(sent(&late, &["c-late"])).unwrap();
ledger.append(sent(&early, &["c-early"])).unwrap();
assert_eq!(
ledger.conclusion(Workspace::Trusted, "y"),
ledger.conclusion(Workspace::Trusted, "kyle", "y"),
found("c-early", &early)
);
}
@@ -404,14 +404,14 @@ fn a_conclusion_is_found_only_by_its_workspace_and_text_once_sent() {
ledger.append(sent(&other, &["c-other"])).unwrap();
ledger.append(sent(&undo_elsewhere, &[])).unwrap();
let a = Some((sent_one.clone(), "c-a".to_string()));
assert_eq!(ledger.conclusion(Workspace::Trusted, "a"), a);
assert_eq!(ledger.conclusion(Workspace::Trusted, "b"), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "c"), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "A"), None);
assert_eq!(ledger.conclusion(Workspace::Untrusted, "a"), None);
assert_eq!(ledger.conclusion(Workspace::Fleet, "a"), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", "a"), a);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", "b"), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", "c"), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", "A"), None);
assert_eq!(ledger.conclusion(Workspace::Untrusted, "kyle", "a"), None);
assert_eq!(ledger.conclusion(Workspace::Fleet, "kyle", "a"), None);
ledger.append(sent(&undo_unsent, &[])).unwrap();
assert_eq!(ledger.conclusion(Workspace::Trusted, "a"), None);
assert_eq!(ledger.conclusion(Workspace::Trusted, "kyle", "a"), None);
}
#[test]