Hmbown/CodeWhale · error

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

Error message

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

What it means

locate_note found more than one bullet with identical text. Ambiguity fails closed: guessing which duplicate to edit could silently rewrite the wrong piece of durable context, so the caller must disambiguate by retiring one copy first or revising the wording.

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 0c42157ee5)

Solutions

  1. Retire one of the duplicate notes first
  2. Or reword one so the needle is unique
  3. Then retry the revise/retire
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/tui/src/native_memory.rs:856 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/2e7df6807e2c0194. Report an issue: GitHub.