# M5a task 09: `recall` **Branch:** `m5a` (run `git switch m5a`; `git status --short` must be empty, otherwise stop) **Commit subject:** `memoryd: recall, with source tags and the recall log` ## Goal `recall` (M5a spec, section 5): search the index and answer with at most `k` hits, best first (FTS5's `bm25`), each cut to 600 characters and headed by a **source tag**: `identity` (an entry moved out of an identity file), `memory` (trusted experience, and dropped entries), or `memory-tainted` (from a session that had read untrusted content). The result's label is the highest class among the hits, and untrusted if any hit is tagged `memory-tainted`. The model's query reaches SQLite **only as quoted terms**, so no FTS5 operator it writes is ever parsed. Every recall, and every query that found nothing, is logged in `memory/recalls/YYYY-MM.jsonl`. The one `rusqlite` call not used before: `stmt.query_map(params![..], |r| ..)`, collected into a `Result, _>`. ## Files - Copy (skeleton): `crates/memoryd/src/recall.rs` - Copy (test): `crates/memoryd/tests/recall.rs` - Modify: `crates/memoryd/src/lib.rs` (`pub mod recall;` after `pub mod notes;`), `docs/implementer-log.md` ## The skeleton Written: `SNIPPET`, `Recalled`, `Hit`, `LoggedHit`, `Logged`. Fill: `terms`, `when`, `day`, `Hit::tag`, `Hit::header`, `recall`, `search`. ## Steps - [ ] **1. Copy** the two files; edit `lib.rs`. - [ ] **2. See it fail.** `cargo test -p memoryd --test recall`: 6 failed. - [ ] **3. Fill** the seven functions. `cargo fmt --all`. - [ ] **4. See it pass.** The same command, three times: 6 passed each time. - [ ] **5. Run the gate.** `make gate`: `gate: ok`, 6 more tests than before (about 912). - [ ] **6. Log and commit.** `git add -A crates/memoryd docs/implementer-log.md Cargo.lock && git commit` ## Done when - `make gate` prints `gate: ok`. ## Stop and report if - A test fails after the functions follow their comments exactly. Do not edit a test.