Skip to content

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

Merged
Zongwei9888 merged 1 commit into
HKUDS:mainfrom
Elon-Jiang:fix/memory-pointer-identity
Nov 16, 2026
Merged

Zongwei9888 merged 1 commit into
HKUDS:mainfrom
Elon-Jiang:fix/memory-pointer-identity

Conversation

@Elon-Jiang

Copy link
Copy Markdown
Contributor

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.

@Zongwei9888
Zongwei9888 merged commit 63c8acc into HKUDS:main Nov 16, 2026
@Zongwei9888

Copy link
Copy Markdown
Contributor

Merged on 2026-11-16 as 63c8acc ("Merge PR #287"). Thanks for finding this!

I reproduced it on main end to end. With [API reference](api.md) and [API reference](api.md.v2.md) in the pointer index, the deterministic pass after autodream rewrote MEMORY.md without the api.md pointer and its hook. The next pass brought it back only as an auto-generated line.

Using a tuple key and keeping prefix subsumption for prose only is a clean fix. The end-to-end test on consolidate_pointer_index is exactly the right one. The CHANGELOG conflict is resolved by folding your line into the 2026-11-16 entry.

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