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
+25 -8
View File
@@ -69,9 +69,10 @@ fn conclude(peer: &str, text: &str) -> Action {
}
}
fn unconclude(text: &str) -> Action {
fn unconclude(peer: &str, text: &str) -> Action {
Action::Unconclude {
workspace: Workspace::Trusted,
peer: peer.to_string(),
text: text.to_string(),
}
}
@@ -139,13 +140,16 @@ fn a_replace_deletes_the_old_then_makes_the_new() {
&["x", "old"],
&["x", "new"],
);
assert_eq!(of(&r), vec![unconclude("old"), conclude(OWNER_PEER, "new")]);
assert_eq!(
of(&r),
vec![unconclude(OWNER_PEER, "old"), conclude(OWNER_PEER, "new")]
);
}
#[test]
fn a_remove_deletes() {
let r = record("e1", "remove", Some("memory.md"), &["x", "gone"], &["x"]);
assert_eq!(of(&r), vec![unconclude("gone")]);
assert_eq!(of(&r), vec![unconclude(AGENT, "gone")]);
let reorder = record(
"e2",
"consolidate",
@@ -156,6 +160,15 @@ fn a_remove_deletes() {
assert!(of(&reorder).is_empty());
}
#[test]
fn a_deletion_names_the_peer_of_its_file() {
// The same text in both files: each file's removal deletes its own peer's conclusion.
let user = record("e1", "remove", Some("user.md"), &["Uses tabs."], &[]);
assert_eq!(of(&user), vec![unconclude(OWNER_PEER, "Uses tabs.")]);
let memory = record("e2", "remove", Some("memory.md"), &["Uses tabs."], &[]);
assert_eq!(of(&memory), vec![unconclude(AGENT, "Uses tabs.")]);
}
#[test]
fn a_consolidate_deletes_the_dropped_and_not_the_moved() {
let mut r = record(
@@ -172,8 +185,8 @@ fn a_consolidate_deletes_the_dropped_and_not_the_moved() {
assert_eq!(
of(&r),
vec![
unconclude("old"),
unconclude("dropped"),
unconclude(AGENT, "old"),
unconclude(AGENT, "dropped"),
conclude(AGENT, "rewritten"),
conclude(AGENT, "new"),
]
@@ -224,11 +237,15 @@ fn notes_by_trust_and_flag() {
fn an_undo_is_the_same_diff_backwards() {
// An undo's before is the file now, its after the undone edit's before.
let cases = [
(&["x", "added"][..], &["x"][..], vec![unconclude("added")]),
(
&["x", "added"][..],
&["x"][..],
vec![unconclude(OWNER_PEER, "added")],
),
(
&["x", "new"][..],
&["x", "old"][..],
vec![unconclude("new"), conclude(OWNER_PEER, "old")],
vec![unconclude(OWNER_PEER, "new"), conclude(OWNER_PEER, "old")],
),
(
&["x"][..],
@@ -268,7 +285,7 @@ fn an_owners_undo_carries_the_undone_edits_session() {
assert_eq!(
actions(&replace_undo, None, AGENT, OWNER_PEER),
vec![
unconclude("new"),
unconclude(OWNER_PEER, "new"),
Action::Skip {
why: NO_SESSION.to_string()
}