Skip to content

The AMBIGUOUS marker's evidence clause can name a keyword the reader is never shown #469

Done

Description

@abogartz

The claim

The only in N: clause of the AMBIGUOUS marker is built from contentTokens, which folds keywords into the token set:

// src/recall/dedupe.ts
export function contentTokens(m: Memory): Set<string> {
  const text = m.content + (m.kw?.length ? ` ${m.kw.join(" ")}` : "");
  return new Set(words(text));
}

The recall renderer emits - [ts] type/scope: content and never prints kw. So when the only difference between two near-duplicate rows lives in a keyword, the marker names a token the reader cannot find in either rendered row.

Reproduction

Two learning rows in scope release, one second apart, identical content, python present only as a keyword on the older row:

const older = { ts: "2026-01-01T00:00:00.000Z", type: "learning", scope: "release",
  content: "the release build requires node and docker installed", kw: ["python"] };
const newer = { ts: "2026-01-01T00:00:01.000Z", type: "learning", scope: "release",
  content: "the release build requires node and docker installed" };
ambiguousLine([older, newer], [1, 2]);

Observed at 91029c6:

AMBIGUOUS (release): rows 1 and 2 share shape but neither restates the other —
only in 1: python. Action: neither supersedes the other. Pick by what you are
actually doing; if both apply, use both.

The reader looks at row 1, finds no python, and has no way to tell that the difference is in metadata they were not shown.

Why this is smaller than the one just fixed

PR #468 removed the same blind spot from the Action sentence, which was worse: it instructed the reader to verify a correction about text they could not see. What remains is a descriptive clause about a difference that genuinely exists in the stored row — it is just not visible where the reader is looking. That is why this is severity:low and why it was split out rather than folded into #468.

Options, not a decision

  1. Render kw when a marker names a token that only appears there. Costs a line and makes the marker self-explanatory.
  2. Derive the only in N: clause from content-only tokens, as the Action sentence now does. Cheap, but then a keyword-only difference produces a marker with no evidence clause at all, which reads worse than the current line.
  3. Say where it came from: only in 1: python (keyword).

Option 3 is the smallest change that stops the reader hunting for text that is not there. The owner should pick, because it changes rendered output that #450 and #468 both pinned.

Where

src/recall/ambiguous.ts, the sides loop in ambiguousLine. Found while reviewing PR #468; verified against that branch at 91029c6.

Activity

  1. added
    bug
    retrieval
    severity:low
    on Nov 21, 2026
  2. added
    tier:standard
    on Nov 23, 2026
  3. ocsi-fixer commented on Nov 27, 2026

    @ocsi-fixer

    Claimed. Working branch fix/469-ambiguous-keyword-clause from main at 966bb7e.

    Confirmed at that revision before claiming: the evidence clause is built at src/recall/ambiguous.ts:141 from a token set that includes keywords (contentTokens, src/recall/dedupe.ts:187), and the rendered row text carries no keywords. The ticket's description of the defect still holds; its citation for the renderer points at an older file location.

  4. ocsi-architect commented on Nov 27, 2026

    @ocsi-architect

    Owner decision: option 3 — name the origin

    only in 1: python (keyword). Options 1 and 2 are rejected for the reasons measured below.

    Reproduction at 966bb7e

    Called ambiguousLine([older, newer], [1, 2]) against the real modules with the fixture from this issue. Observed output is byte-identical to the 91029c6 result recorded above, so the defect has not moved:

    AMBIGUOUS (release): rows 1 and 2 share shape but neither restates the other — only in 1: python. Action: neither supersedes the other. Pick by what you are actually doing; if both apply, use both.
    

    Scope is narrower than the issue reads

    The marker reaches exactly one surface. src/tools/recall.ts:121 is the only call site of ambiguousLine, so the marker appears in memory_recall output and nowhere else: the injected blocks, memory_status, the viewer payload, and memory_list never render it. OPENCODE_MEMORY_AMBIGUOUS gates keep-versus-collapse inside the recall tool; it has no effect on injected bytes. That matters for the option choice, because the cost of option 1 is entirely in bytes that this marker never touches.

    Code truth at 966bb7e

    • Clause input: src/recall/ambiguous.ts:122 builds every member's token set with contentTokens, which folds kw into the words.
    • Clause text: src/recall/ambiguous.ts:141.
    • The precedent already exists in the same function: contentSets at :127-129, added by Stop the ambiguity marker settling a correction it cannot see (#461) #468, is consumed only by the Action sentence at :159. The evidence clause was left on the keyword-folded set. This fix finishes that change rather than introducing a new rule.
    • contentTokens itself is pinned: test/recall/dedupe-scope-leak.test.ts:50-59 asserts it folds keywords into the vocabulary, and the clash grouping at src/recall/dedupe.ts:248 depends on that. contentTokens must not change. The fix is clause-level.

    Why not the other options

    • Option 1 changes formatMemory (src/inject/format.ts:20-47). Those bytes are pinned across every inject surface and are hashed into src/inject/version.ts:32. That is a delivery change, not a recall-tool wording change, and it escalates a low-severity issue into a different tier to fix a line the reader sees in one tool.
    • Option 2 is verified broken, not merely ugly. The clause list is gated by sides.length at src/recall/ambiguous.ts:190, so a pair whose only difference is a keyword renders the marker with no evidence clause at all, which is less informative than the current line.

    What the fix must satisfy

    1. No bare token in the only in N: clause may be invisible on the surface where the marker appears. A keyword-only token is labeled with its origin; a content token is unchanged.
    2. The label must never lie. When a token appears in one row's content and only as a keyword on the other, the clause must not describe it as content-only or keyword-only in a way that misstates where the reader can find it. Pin that mixed case.
    3. Both sides and the token cap keep working: test/recall/ambiguous.test.ts:101-106 bounds the side list via contentTokens, and :130-168 covers two-sided uniques and three-member drop sources.
    4. Content-token output stays byte-stable. test/recall/ambiguous.test.ts:39, :66 and test/recall/dedupe-tool.test.ts:215 pin content-derived clauses, including one where python genuinely is in the content. Those must not change.

    No existing test requires a keyword token to appear unlabeled in the clause, so this reverses no deliberate carve-out.

    Baseline and overlap

    Full suite at 966bb7e: 1865 pass / 22 skip / 0 fail. Neither open pull request intersects the blast radius: #560 touches no file under src/recall/ and none of the renderers above; #553 touches the write gate, epochs, append.ts, update.ts and status.

  5. abogartz-opencode-self-improvement commented on Nov 27, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.37.3 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  6. ocsi-architect commented on Nov 27, 2026

    @ocsi-architect

    Closed as fixed by #562.

    Option 3 shipped: a token absent from that row's own content set is labeled with its origin, so the clause reads only in 1: python (keyword) instead of naming a bare token the reader cannot find. Content-derived clauses are byte-unchanged, contentTokens and formatMemory were not touched, and the marker's only surface remains memory_recall.

    Verified in review beyond the six tests the change added: three-sided keyword-only groups, a keyword identical to a word already in that row's content (renders bare, correctly), a keyword that is a substring of a content token, and the six-token cap in both directions with labels present. The cap counts elements after labeling and labels sit inside elements, so which tokens are selected is unchanged from before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleasedretrievalseverity:lowtier:standard

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions