Skip to content

fix(memory): keep distinct topic pointers during consolidation - #287

Open
Elon-Jiang wants to merge 1 commit into
HKUDS:mainfrom
Elon-Jiang:fix/memory-pointer-identity
Open

Elon-Jiang wants to merge 1 commit into
HKUDS:mainfrom
Elon-Jiang:fix/memory-pointer-identity

Conversation

@Elon-Jiang

Copy link
Copy Markdown

Description

Memory consolidation can silently remove a valid topic link. For example,
consolidate(["- [API reference](api.md)", "- [API reference](api.md.v2.md)"])
currently keeps only the second pointer: the serialized identity of the first
is a prefix of the second and is treated as redundant prose. The real
consolidate_pointer_index() writer can persist that loss to MEMORY.md.
A literal | split between title and target can also make distinct pointers
share one serialized key.

Use a (title, target) tuple for pointer identity and apply prefix subsumption
only to prose keys. Existing case normalization, repeated-link/hook merging,
first-seen ordering, and index capacity limits remain unchanged.

Related Issues

Source-discovered regression in the pointer-index feature introduced in #233.
No overlapping open PR was found during the current-main check.

Changes Made

  • Represent topic identities structurally so distinct links do not collide.
  • Keep prose prefix deduplication separate from topic-pointer deduplication.
  • Add five regressions: both orders of prefix/delimiter examples and a real
    index rewrite that preserves both topic links and their readable contents.
  • Add English and Chinese changelog entries.

Checklist

  • Changes tested locally: 5 new tests fail on current main, 32 existing
    memory-layer tests pass; all 74 memory/compaction/autodream tests pass with
    the fix.
  • Full Python suite on Python 3.12.14 / macOS: 3063 passed, 12 skipped,
    1 failed
    . The sole failure,
    test_ctrl_c_clears_a_draft_before_it_interrupts, also fails on unchanged
    upstream e09d3c1 with the same locked dependencies. No test was excluded.
  • Required pre-commit run --all-files: all hooks pass (Ruff lint/format,
    whitespace/requirements checks, and actionlint).
  • Desktop/Web lint, 51 test files / 355 tests, typecheck, protocol check,
    and Web build pass.
  • Maintainer review.
  • Documentation updated through changelog entries.
  • Unit tests added.

Additional Notes

AI-assisted contribution. The unrelated TUI baseline failure is reported
above rather than presented as a passing full suite. No runtime dependencies
or provider calls are added.

This branch has not been deployed

No deployments
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.

1 participant