session_slot and the scheduler tests held a temporary JSON Value across statements (E0716). Cron now pins DOM and DOW as AND, which the given tests had not. Gate counts from task 04 on move up by one. Co-Authored-By: Grok 4.6 <noreply@x.ai>
5.5 KiB
M5d-2 task 09: index ToolSummary as kind summary
Branch: m5d2. Check it: git branch --show-current prints m5d2 and git status --short
is empty; otherwise stop. Never switch branch.
Commit subject: memoryd: index ToolSummary as kind summary
Log row: the Task cell is M5d2/09-memoryd-summary-index.
Goal
memoryd indexes LogRecord::ToolSummary content as kind summary, with that record's
class and untrusted (spec 4.3, P26). recall finds it and tags memory or
memory-tainted as for any other session hit. Raw ToolResult bodies stay unindexed.
index_record today has _ => {}. It compiles. This task adds the arm.
Every place that changes
| Place | What happens there |
|---|---|
crates/memoryd/src/index.rs |
ToolSummary arm (edit I1); module doc |
crates/memoryd/tests/tool_summary_index.rs |
new, given |
| everything else | no change: not recall.rs headers (role "summary" uses the existing "the assistant said" branch) |
Files
- Copy, from
docs/plans/M5d2/files/(the same path under it): the new testcrates/memoryd/tests/tool_summary_index.rs. - Modify:
crates/memoryd/src/index.rs,docs/implementer-log.md. - Do not touch: any other file. Do not edit
tests/support/logs.rs.
Facts you need
- Kind
summary. Setkind: "summary".to_string()on theSource, not the log's"session". Role"summary". Time from the record.class/untrustedfrom theToolSummary, not frombase(the rolling session label). Skip whensummary.class > self.max_class, even ifbase.classis stillPrivate. Skip whencontent.trim()is empty. - The existing
if base.class > self.max_classstays. A secretToolResultraises the rolling label before the next record, so a following secret summary is also skipped that way. Still check the summary's own class. - Do not add
ToolSummaryto the rolling-label update inindex_log(that loop still looks atToolResultonly). The result already carried the same labels. - Recall headers.
kind"summary"is notmoved/dropped/noted, so the tag ismemoryormemory-tainted. Role"summary"is notownerorcall, so the line saysthe assistant said. The given tests look formemory · session mm-aandmemory-tainted. - The items the edits use. This table is complete.
Item What it does self.addFTS row plus sourcesSourcekind / role / class / untrusted
The edits, exactly
Each quoted "before" block occurs exactly once.
crates/memoryd/src/index.rs
I1. After the Assistant arm, before _ => {}. The lines
}
_ => {}
}
Ok(())
}
become
}
LogRecord::ToolSummary {
time,
content,
class,
untrusted,
..
} if !content.trim().is_empty() && *class <= self.max_class => {
let src = Source {
kind: "summary".to_string(),
time: time.to_rfc3339(),
role: "summary".to_string(),
class: *class,
untrusted: *untrusted,
..base.clone()
};
self.add(content, &src)?;
}
_ => {}
}
Ok(())
}
DataClass already implements Ord (Public < Private < Secret). If <= does not
compile, stop.
Optionally update the module doc "never a tool's result" to say summaries of opted-in results are indexed. A comment that does not fit its code: stop.
Steps
-
1. Copy the given test.
cp docs/plans/M5d2/files/crates/memoryd/tests/tool_summary_index.rs crates/memoryd/tests/ -
2. See it fail.
cargo test -p memoryd --test tool_summary_index, timeout 600000 ms: the tests compile (ToolSummaryexists) anda_tool_summary_is_found_as_kind_summaryfails:(no matches for "tea")or the unique phrase is missing.the_raw_tool_result_is_still_not_indexedmay pass (results were already unindexed). -
3. The edit. I1.
cargo check -p memorydprints no error and no warning. -
4. The tests.
cargo test -p memoryd --test tool_summary_index --test recall: every test passes, 5 intool_summary_index. -
5. Check.
git diff --statlists exactlycrates/memoryd/src/index.rs. -
6. Run the gate.
cargo fmt --all, thenmake gate, timeout 600000 ms. Last linegate: ok. Test count 1568 (1563 before, plus 5). -
7. Log and commit. Task cell
M5d2/09-memoryd-summary-index. Stage withgit add crates/memoryd docs/implementer-log.md Cargo.lock, then commit asAGENTS.mdsays.
Done when
make gateprintsgate: okwith 1568 tests.git diff HEAD~1 --statlists onlycrates/memoryd/src/index.rs,crates/memoryd/tests/tool_summary_index.rsand the log.
Stop and report if
- The branch check fails; a "before" block is not found exactly once; step 2 differs;
cargo checkwarns; a test fails; the gate count is not 1568; you indexToolResultcontent; you leavekindas"session"; a secret summary is searchable on a private index.
What the given tests pin
A summary's content is found and tagged memory · session …; the raw tool body is not; an
untrusted summary taints the recall (memory-tainted); a trusted summary does not taint; a
secret summary is skipped when max_class is Private.