{"record":{"id":"af1ff0f9aeb73e9a","repo":"Hmbown/CodeWhale","slug":"no-memory-note-matches-needle","errorCode":null,"errorMessage":"no memory note matches `{needle}`","messagePattern":"no memory note matches `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/native_memory.rs","lineNumber":855,"sourceCode":"}\n\n/// Find the single bullet whose text matches `needle`, comparing on the\n/// note body rather than the raw line so `- note` and indentation don't\n/// have to be reproduced by the caller.\n///\n/// Ambiguity fails closed. If a model asks to revise a note that appears\n/// twice, editing either one is a guess, and a wrong guess silently rewrites\n/// durable context.\nfn locate_note(body: &str, needle: &str) -> Result<usize> {\n    let matches: Vec<usize> = body\n        .lines()\n        .enumerate()\n        .filter(|(_, line)| bullet_text(line).is_some_and(|text| text == needle))\n        .map(|(index, _)| index)\n        .collect();\n    match matches.as_slice() {\n        [only] => Ok(*only),\n        [] => bail!(\"no memory note matches `{needle}`\"),\n        several => bail!(\n            \"`{needle}` matches {} notes; refusing to guess which to edit\",\n            several.len()\n        ),\n    }\n}\n\n/// The note body of a Markdown bullet, if the line is one.\nfn bullet_text(line: &str) -> Option<&str> {\n    let trimmed = line.trim();\n    trimmed\n        .strip_prefix(\"- \")\n        .or_else(|| trimmed.strip_prefix(\"* \"))\n        .map(str::trim)\n}\n\n/// Evidence is required on every in-place edit and held to the same bounds\n/// as a note. An unexplained rewrite of durable context is the thing the","sourceCodeStart":837,"sourceCodeEnd":873,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/native_memory.rs#L837-L873","documentation":"`locate_note` in the native memory store finds the bullet line whose exact text equals the given needle. When no note bullet matches exactly, it bails with this error instead of guessing. The needle is matched on normalized bullet text, so whitespace or wording differences cause misses.","triggerScenarios":"Calling `revise` or `retire` (or the remember tool's edit paths) with a needle string that does not exactly equal any existing note's bullet text — typically because the note was reworded, trimmed, or the caller passed a paraphrase or stale text.","commonSituations":"An agent/human cites the note from memory instead of reading it first; the note was edited earlier so the cached text is stale; extra leading '- ' or trailing punctuation differs; case mismatch.","solutions":["List the current memory notes and copy the exact bullet text to pass as the needle.","Match the note by its index instead of text if the store API allows positional edits.","Create the note via `remember` if it genuinely doesn't exist.","Normalize whitespace/case to match how normalize_note stores the text."],"exampleFix":"// before: paraphrased needle\nretire(\"user likes rust async\").await?;\n// after: read the store first and use the exact stored bullet\nlet note = store.list().await?.iter().find(|n| n.contains(\"rust\"));\nstore.retire(note.trim()).await?;","handlingStrategy":"validation","validationCode":"// Ensure the needle exists exactly once before editing\nlet notes = store.list().await?;\nlet hits: Vec<_> = notes.iter().filter(|n| n.as_str() == needle).collect();\nassert_eq!(hits.len(), 1, \"needle must match exactly one note\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always list notes and copy exact bullet text before revise/retire.","Prefer index-based note addressing when available.","Avoid paraphrasing note text from memory."],"tags":["memory","not-found","lookup"],"backgroundTag":"record-not-found","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}