Skip to content

fix: treat a negated re-statement as a conflict, not a duplicate - #135

Merged
Grivn merged 6 commits into
mnemon-dev:masterfrom
wangzhengzhuo05:fix/negation-false-duplicate
Sep 14, 2026
Merged

Grivn merged 6 commits into
mnemon-dev:masterfrom
wangzhengzhuo05:fix/negation-false-duplicate

Conversation

@wangzhengzhuo05

@wangzhengzhuo05 wangzhengzhuo05 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Near-duplicate statements that flip an explicit English negation marker now report CONFLICT instead of DUPLICATE. This preserves the original contribution while recognizing straight and curly apostrophes consistently, respecting Unicode word boundaries, and avoiding false polarity changes from individual CJK characters.

Current master already preserves distinct facts during writes through #139. This PR keeps that exact-content identity rule: different text remains a separate memory, and UPDATE/CONFLICT suggestions do not delete records. The earlier import-preservation follow-up is retained in history and reconciled with the broader mainline policy. Both sets of import tests remain, with the superseded automatic-update expectation adjusted to preserve the new policy.

The original commit 4c31eb89d0a602ca37d75a3008ed7d3613b35930 and both follow-up commits are preserved without rebasing or squashing. The classifier remains advisory; this does not claim general multilingual contradiction detection.

Validation: product build, make test, focused search/import/write tests, Memory CLI E2E, and checks that the new multilingual recall intent behavior remains intact. All behavioral checks use scratch stores with the embedding provider disabled; no paid provider calls.

The original author disclosed AI assistance for the initial implementation and regression tests. Related issue: #133.

wangzhengzhuo05 and others added 4 commits September 12, 2026 20:09
Tokenize drops "not"/"no" as stopwords, so "X is allowed" and "X is not allowed"
produce identical token sets and classifySuggestion returned DUPLICATE above 0.9
token similarity — remember then silently skipped the correction.

Compare polarity from the raw text inside the near-duplicate branches only, so a
bare "not" in scientific prose still cannot force CONFLICT. A polarity mismatch on
a near-verbatim re-statement now returns CONFLICT and both facts are kept.

Verified with go test ./internal/memory/search/... -count=1.
Recognize straight and curly apostrophes consistently and use Unicode word boundaries so names such as Noté do not imply negation. Remove the character-only CJK check, which falsely classified ordinary words such as 非常 and 未来 as conflicts.

Validated with the full memory search suite. New regression cases fail on the original PR and pass with the fix, and a synthetic embedding case covers the second near-duplicate branch without a provider.
Import classified conflicts as added memories so heuristic conflicts preserve the existing record and its edges, matching remember. This intentionally changes the previous conflict replacement behavior; update the English and Chinese import docs while retaining ordinary updates and exact-duplicate skips.

Validated with go build -o mnemon ., make test, focused SQLite import tests, and fresh-store CLI comparisons. Tests cover old and newly negated conflict signals, duplicate and no-diff outcomes, update replacement, and explicit edges through skipped and added draft indices.
GRIVN added 2 commits September 15, 2026 02:10
Merge current master while retaining the original negation fix and both review commits. The mainline exact-content write policy subsumes the earlier import-conflict fix: keep imports and documentation on that policy and adapt the old UPDATE control to preserve both facts.

Retain both sets of SQLite and edge-mapping tests, and assert that forward and reverse negated corrections still report advisory CONFLICT. Validated with go test ./cmd/memory ./internal/memory/search -count=1.
Merge the released Homebrew postflight changes on top of the exact-content write-policy adaptation. Preserve the original PR and review commit ancestry while keeping the current mainline import behavior.

Validated with go build -o mnemon ., make test, and the Memory CLI E2E suite (258 checks passed), with embedding probes directed to an unavailable loopback endpoint.
@Grivn
Grivn merged commit 544d8c6 into mnemon-dev:master Sep 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants