docs: M5d-1 and M5d-2 implementation plans for Ornith

Eight closed tasks for epochs and compaction, then ten for the scheduler,
ToolSummary, and tiers. Given tests first. Gate 1456 → 1507 → 1572.

Co-Authored-By: Grok 4.6 <noreply@x.ai>
This commit is contained in:
2026-10-02 21:54:37 -07:00
co-authored by Grok 4.6
parent 069cd1686a
commit 3726ae585f
48 changed files with 7319 additions and 0 deletions
@@ -0,0 +1,122 @@
//! Tests for `MemoryCommand::Tiers`: identity entries and notes with recall-hit counts. Do not edit.
#[path = "support/tmp.rs"]
mod tmp;
use bxcore::{DataClass, MemoryFile, Timestamp};
use memoryd::files::Store;
use memoryd::tiers;
use tmp::TempDir;
fn now() -> Timestamp {
Timestamp::parse("2026-10-03T08:00:00.000Z").unwrap()
}
struct Setup {
dir: TempDir,
store: Store,
}
fn setup(tag: &str) -> Setup {
let dir = TempDir::new(tag);
let starter = dir.write("etc/soul.md", "Soul.\n");
let store = Store::new(&dir.path().join("memory"));
store.init(&starter).unwrap();
Setup { dir, store }
}
fn write_recall(store: &Store, line: &str) {
std::fs::create_dir_all(store.path("recalls")).unwrap();
store
.append("recalls/2026-10.jsonl", &format!("{line}\n"))
.unwrap();
}
#[test]
fn identity_entries_list_with_zero_hits() {
let s = setup("tiers-id");
s.store
.write_entries(MemoryFile::Memory, &["I like tea.".to_string()])
.unwrap();
s.store
.write_entries(MemoryFile::User, &["The owner is Kyle.".to_string()])
.unwrap();
let text = tiers::list(&s.store, now()).unwrap();
assert!(
text.contains("identity memory.md hits 0 last -"),
"{text}"
);
assert!(text.contains("I like tea."), "{text}");
assert!(text.contains("identity user.md hits 0 last -"), "{text}");
assert!(text.contains("The owner is Kyle."), "{text}");
}
#[test]
fn notes_carry_counts_from_recalls() {
let s = setup("tiers-notes");
std::fs::write(
s.store.path("notes.md"),
"§ noted 2026-09-22T18:20Z in session mm-a · private\nlaunch window moved.\n",
)
.unwrap();
write_recall(
&s.store,
r#"{"time":"2026-10-03T07:00:00.000Z","session":"mm-now","query":"launch","hits":[{"kind":"noted","session":"mm-a","epoch":0,"record":0}]}"#,
);
write_recall(
&s.store,
r#"{"time":"2026-10-03T07:30:00.000Z","session":"mm-now","query":"window","hits":[{"kind":"noted","session":"mm-a","epoch":0,"record":0}]}"#,
);
let text = tiers::list(&s.store, now()).unwrap();
assert!(
text.contains(
"note session mm-a hits 2 last 2026-10-03T07:30:00.000Z private trusted"
),
"{text}"
);
assert!(text.contains("launch window moved."), "{text}");
}
#[test]
fn untrusted_notes_are_listed_and_marked() {
let s = setup("tiers-untrusted");
std::fs::write(
s.store.path("notes.md"),
"§ noted 2026-09-22T18:20Z in session mm-c · private · untrusted\nexample.org says the launch moved.\n",
)
.unwrap();
let text = tiers::list(&s.store, now()).unwrap();
assert!(
text.contains("note session mm-c hits 0 last - private untrusted"),
"{text}"
);
assert!(
text.contains("example.org says the launch moved."),
"{text}"
);
}
#[test]
fn a_recall_of_a_different_note_does_not_count() {
let s = setup("tiers-other");
std::fs::write(
s.store.path("notes.md"),
"§ noted 2026-09-22T18:20Z in session mm-a · private\nfirst note.\n§ noted 2026-09-22T18:21Z in session mm-b · private\nsecond note.\n",
)
.unwrap();
write_recall(
&s.store,
r#"{"time":"2026-10-03T07:00:00.000Z","session":"mm-now","query":"second","hits":[{"kind":"noted","session":"mm-b","epoch":0,"record":1}]}"#,
);
let text = tiers::list(&s.store, now()).unwrap();
assert!(
text.contains("note session mm-a hits 0 last - private trusted"),
"{text}"
);
assert!(
text.contains(
"note session mm-b hits 1 last 2026-10-03T07:00:00.000Z private trusted"
),
"{text}"
);
}
@@ -0,0 +1,191 @@
//! Tests that `ToolSummary` is indexed as kind `summary` and found by `recall`. Do not edit.
#[path = "support/logs.rs"]
mod logs;
#[path = "support/tmp.rs"]
mod tmp;
use bxcore::{CallId, DataClass, LogRecord, RecallArgs, Timestamp};
use logs::{assistant, result, user, write_log};
use memoryd::files::Store;
use memoryd::index::Index;
use memoryd::recall::recall;
use tmp::TempDir;
fn now() -> Timestamp {
Timestamp::parse("2026-09-24T21:00:00.000Z").unwrap()
}
fn summary(minute: u32, content: &str, untrusted: bool) -> LogRecord {
LogRecord::ToolSummary {
time: logs::at(minute),
call: CallId(1),
tool_call_id: "c0".to_string(),
content: content.to_string(),
class: DataClass::Public,
untrusted,
}
}
struct Setup {
dir: TempDir,
store: Store,
index: Index,
}
fn setup(tag: &str) -> Setup {
let dir = TempDir::new(tag);
let starter = dir.write("etc/soul.md", "Soul.\n");
let store = Store::new(&dir.path().join("memory"));
store.init(&starter).unwrap();
let index = Index::open(&dir.path().join("index/memory.sqlite3"), DataClass::Private).unwrap();
Setup { dir, store, index }
}
fn ask(s: &Setup, query: &str) -> memoryd::recall::Recalled {
let args = RecallArgs {
query: query.to_string(),
k: 10,
};
recall(&s.index, &s.store, &args, "mm-now", now()).unwrap()
}
#[test]
fn a_tool_summary_is_found_as_kind_summary() {
let s = setup("summary-found");
write_log(
s.dir.path(),
"mm-a",
&[
user(2, "fetch the launch page"),
assistant(
3,
None,
&[("http_fetch", r#"{"url":"https://example.org"}"#)],
),
result(4, "raw html body about tea", DataClass::Public, false),
summary(5, "the page is about tea and the launch window", false),
],
);
s.index
.catch_up(&s.dir.path().join("sessions"), &s.store.path("notes.md"))
.unwrap();
let got = ask(&s, "tea");
assert!(
got.text
.contains("the page is about tea and the launch window"),
"{got:?}"
);
assert!(
got.text.contains("memory · session mm-a"),
"tagged as a session hit: {}",
got.text
);
assert!(!got.untrusted);
}
#[test]
fn the_raw_tool_result_is_still_not_indexed() {
let s = setup("summary-no-raw");
write_log(
s.dir.path(),
"mm-a",
&[
user(2, "fetch"),
assistant(3, None, &[("http_fetch", "{}")]),
result(4, "UNIQUE_RAW_BODY_XYZ", DataClass::Public, false),
summary(5, "a short account of the page", false),
],
);
s.index
.catch_up(&s.dir.path().join("sessions"), &s.store.path("notes.md"))
.unwrap();
let got = ask(&s, "UNIQUE_RAW_BODY_XYZ");
assert!(
got.text.contains("(no matches"),
"raw tool result stays unindexed: {}",
got.text
);
}
#[test]
fn an_untrusted_summary_taints_the_recall() {
let s = setup("summary-taint");
write_log(
s.dir.path(),
"mm-a",
&[
user(2, "fetch"),
assistant(3, None, &[("http_fetch", "{}")]),
result(4, "page", DataClass::Public, true),
summary(5, "the fetched page mentions the launch window", true),
],
);
s.index
.catch_up(&s.dir.path().join("sessions"), &s.store.path("notes.md"))
.unwrap();
let got = ask(&s, "launch");
assert!(got.untrusted, "{got:?}");
assert!(got.text.contains("memory-tainted"), "{}", got.text);
}
#[test]
fn a_trusted_summary_does_not_taint() {
let s = setup("summary-trusted");
write_log(
s.dir.path(),
"mm-a",
&[
user(2, "fetch"),
assistant(3, None, &[("http_fetch", "{}")]),
result(4, "page", DataClass::Public, false),
summary(5, "the fetched page mentions the launch window", false),
],
);
s.index
.catch_up(&s.dir.path().join("sessions"), &s.store.path("notes.md"))
.unwrap();
let got = ask(&s, "launch");
assert!(!got.untrusted, "{got:?}");
assert!(got.text.contains("memory · session mm-a"), "{}", got.text);
assert!(!got.text.contains("memory-tainted"), "{}", got.text);
}
#[test]
fn a_secret_summary_is_skipped_when_the_index_is_private() {
let s = setup("summary-secret");
write_log(
s.dir.path(),
"mm-a",
&[
user(2, "fetch"),
assistant(3, None, &[("http_fetch", "{}")]),
LogRecord::ToolResult {
time: logs::at(4),
call: CallId(1),
tool_call_id: "c0".to_string(),
content: "secret page",
class: DataClass::Secret,
untrusted: false,
truncated: false,
},
LogRecord::ToolSummary {
time: logs::at(5),
call: CallId(1),
tool_call_id: "c0".to_string(),
content: "SECRET_SUMMARY_PHRASE",
class: DataClass::Secret,
untrusted: false,
},
],
);
s.index
.catch_up(&s.dir.path().join("sessions"), &s.store.path("notes.md"))
.unwrap();
let got = ask(&s, "SECRET_SUMMARY_PHRASE");
assert!(
got.text.contains("(no matches"),
"secret summary above max_class: {}",
got.text
);
}