Hmbown/CodeWhale · error

` ` matches notes; refusing to guess which to edit

Error message

`{needle}` matches {} notes; refusing to guess which to edit

What it means

Companion guard to the no-match error: when the needle text matches more than one memory note bullet, `locate_note` refuses to pick one and bails with this message, since editing/retiring the wrong duplicate would be destructive.

Solutions

  1. Deduplicate the store: retire/remove all but one copy, then retry with the unique remaining text.
  2. Edit notes by index rather than by text so each operation targets a specific line.
  3. Revise each duplicate to distinct text before operating on the intended one.
  4. Avoid re-remembering identical notes; check for an existing match first.

Example fix

// before: duplicate notes cause refusal
store.revise("deploy target is eu-west-1", new_text).await?;
// after: dedupe first
store.retire("deploy target is eu-west-1").await?; // removes one copy
store.retire("deploy target is eu-west-1").await?; // removes other
store.remember("deploy target is eu-west-1").await?;
store.revise("deploy target is eu-west-1", new_text).await?;
Defensive patterns

Strategy: validation

Validate before calling

// Refuse to operate on ambiguous needles
let count = store.list().await?.iter().filter(|n| n.as_str() == needle).count();
if count != 1 { bail!("needle '{needle}' is ambiguous ({count} matches); dedupe first"); }

Prevention

When it happens

Trigger: Calling `revise` or `retire` with a needle that exactly equals the bullet text of two or more stored notes (duplicate notes were accumulated via repeated `remember` calls with identical text).

Common situations: The same fact was remembered multiple times across sessions; near-identical notes exist because of repeated tool runs; deduplication was never run on the store.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/2e7df6807e2c0194. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/native_memory.rs:856

/// Find the single bullet whose text matches `needle`, comparing on the
/// note body rather than the raw line so `- note` and indentation don't
/// have to be reproduced by the caller.
///
/// Ambiguity fails closed. If a model asks to revise a note that appears
/// twice, editing either one is a guess, and a wrong guess silently rewrites
/// durable context.
fn locate_note(body: &str, needle: &str) -> Result<usize> {
    let matches: Vec<usize> = body
        .lines()
        .enumerate()
        .filter(|(_, line)| bullet_text(line).is_some_and(|text| text == needle))
        .map(|(index, _)| index)
        .collect();
    match matches.as_slice() {
        [only] => Ok(*only),
        [] => bail!("no memory note matches `{needle}`"),
        several => bail!(
            "`{needle}` matches {} notes; refusing to guess which to edit",
            several.len()
        ),
    }
}

/// The note body of a Markdown bullet, if the line is one.
fn bullet_text(line: &str) -> Option<&str> {
    let trimmed = line.trim();
    trimmed
        .strip_prefix("- ")
        .or_else(|| trimmed.strip_prefix("* "))
        .map(str::trim)
}

/// Evidence is required on every in-place edit and held to the same bounds
/// as a note. An unexplained rewrite of durable context is the thing the
/// journal exists to prevent.

View on GitHub (pinned to 433685b202)