Skip to content

Window dedup at 0.8 hides one of two different build commands (live false positive) #448

Closed

Description

@abogartz

The pair

Two active, injectable rows, same scope, Jaccard 0.8235 on contentTokens. The window-dedup pass treats them as copies and drops one. The one it drops is the plain npm run build; the row that keeps the slot is the niche build:example-images variant.

BabylonDocs build command: run "npm run build" from the repo root (package.json).
BabylonDocs build:example-images command: run "npm run build:example-images" from the repo root (package.json).

These are two different commands that both exist. Ranking favors recency and the pass keeps the first-ranked row of a clash, so the survivor is the newer, narrower row and the plain build command is what a session never sees. Asked "how do I build this?", the answer that arrives is the example-images target. Verified directly: dedupeWindow over this scope drops the same row for every query tried.

Reproduce: bun run bench:dedup prints both active candidates in full. Written up in bench/dedup-live-results.md.

Why the guards do not catch it

All three pass, so nothing downstream saves this pair:

  • both rows are above MIN_CONTENT;
  • same polarity — neither carries a negation;
  • same dropped-chunk multiset — and here both multisets are empty, so the guard passes trivially.

That third point is the interesting one, and it points at a second problem below.

Raising the threshold is not the fix — measured, then rejected

This was evaluated on 2026-11-19 so that nobody reaches for the constant again. The pair worth releasing scores 0.8235. The pair the suite deliberately pins, in test/dedupe-tool.test.ts, scores 0.8333:

the deploy runbook rotates the signing key every friday after the backup window
the deploy runbook rotates the signing key every monday after the backup window

That second pair is the opposite case: a fact that changed, where the ADR requires the newer row to take the slot and the stale one to go. The gap is 0.0098. A threshold does exist that keeps one and releases the other — it must sit above 0.8235 and at or below 0.8333 — but a window one hundredth wide is a constant fitted to two observations, and the next pair that lands in the gap is decided by noise. 0.9, the value that looked clean because this store has nothing between 0.824 and 1.000, releases both: the runbook pair stops being suppressed and the recency rule stops shipping.

Both rows have the same shape — one sentence, one long token swapped out. In one case the swap replaced a fact; in the other it added one. A token-overlap score cannot see that difference, so this is not a threshold problem. Recorded in docs/adr/0002-window-dedup.md as of 2026-11-19.

The second problem: what the pass actually suppresses

Suppression is only considered when two rows share the same multiset of dropped 1-2 character fragments. Two rows differing by a timestamp have different fragments, so they are never compared — every pr-watch cursor row in the store is exempt from this pass, and all 78 candidates in the repository's own review scope are stopped by that guard rather than by the threshold.

The ADR's stated motivation is rows that "differ only by a timestamp" crowding distinct facts out of the window. The guard introduced to stop DB 3 from swallowing DB 4 exempts exactly those. What still gets suppressed is prose with no digits or short fragments in it — where the false positive lives. So the pass currently runs least where the record says it is needed most, and its one visible effect on this store is a wrong one.

Options left

  1. Semantic comparison. Embeddings would separate "replaced a fact" from "added a fact" in a way a word bag cannot. Already tracked as Recall across fully rephrased queries needs semantic (embedding) search #420; this issue is a concrete failure that justifies it, and should be re-tested against whatever Recall across fully rephrased queries needs semantic (embedding) search #420 lands.
  2. Narrow the pass instead of tuning it. Given the guard analysis, the pass has essentially one behavior on this store: suppress prose that shares shape. Making it apply only where duplication is actually observed — or not at all, with the write gate's cross-type gap fixed in its place — may be cheaper than any threshold debate. Needs the same style of measurement before it is proposed.
  3. Accept and document. The ADR now records the limitation, the rejected threshold, and the guard inversion. If neither 1 nor 2 is worth doing, this issue can close against those bullets.

No preference recorded here. Option 2 is the one to measure next: it is cheap, and the guard finding suggests the pass is not doing what its own record claims.

Out of scope

The write gate letting a cross-type duplicate through — identical prose filed as a context and as a decision is promoted twice. That is a separate defect, named in bench/dedup-live-results.md, and it is why this pass is not redundant with the gate.

Activity

  1. abogartz commented on Nov 19, 2026

    @abogartz
    OwnerAuthor

    Fixed by #450, which takes neither of the options this issue opened with.

    The threshold was already ruled out by measurement. The fix turned out to be structural: a clash is classified by its leftover token sets before anything is dropped. Nothing left over either way is a copy and still collapses; one row wholly contained in the other names something the partner does not restate, so both are kept; a leftover on each side is the same statement about a changed world, so the newer still takes the slot.

    No threshold change. The pair above now returns both commands, plus a line saying why:

    AMBIGUOUS (BabylonDocs): rows 4 and 5 share shape but neither restates the other — only in 4: example-images, example, images. Action: neither supersedes the other. Pick by what you are doing; if both apply, use both.
    

    Replayed over 1,330 active rows in 241 scopes at window 5: one suppression reversed, one extra slot of 514, and it is this pair. The runbook friday/monday case pinned in test/dedupe-tool.test.ts still collapses to the newer row and emits no marker — that is the regression the change had not to cause, and it is pinned through the real handler.

    The guard inversion recorded here stands on its own and is not addressed by #450: rows differing by a timestamp have different dropped 1-2 character fragments, so they are never compared, and the pr-watch cursor rows this issue names as the pass's motivation remain exempt. #450 makes the surviving behavior correct; it does not make the pass fire where the ADR says it was meant to.

    Rollback is OPENCODE_MEMORY_AMBIGUOUS=0.

  2. abogartz commented on Nov 19, 2026

    @abogartz
    OwnerAuthor

    Fixed by #450, merged as ef45f6f, and released in 0.33.0.

    The pair here is one of the two candidates the replay still reports on the live store, which is the
    point: the runner names it so a future change cannot silently start suppressing it again. What changed
    is what the pass does with it. classifyPair in src/recall/dedupe.ts reads the leftover token sets
    and finds this pair is addition — example-images, example, images sit on one side only, so the
    shorter row is not a restatement of the longer one. Both commands are now kept, and memory_recall
    appends one line naming the difference instead of deciding:

    AMBIGUOUS (BabylonDocs): rows 4 and 5 share shape but neither restates the other — only in 4:
    example-images, example, images. Action: neither supersedes the other. Pick by what you are actually
    doing; if both apply, use both.
    

    Rollback is OPENCODE_MEMORY_AMBIGUOUS=0, verified against the pre-feature scan over 1,200 randomized
    window and limit combinations so switching it off reproduces the old result exactly.

    The threshold question raised here stays closed out as it was measured: 0.8 is kept, because the pair
    worth releasing scores 0.8235 and the §17 pair 0.8333 — a 0.0098 window fitted to two observations, and
    raising the default would be fitting to the same two.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions