Skip to content

fix(#36,#45): stable memory dedup key, memory add uses new schema#54

Merged
FZ2000 merged 2 commits intomainfrom
fix/memory-schema-and-dedup-36-45
Mar 8, 2026
Merged

fix(#36,#45): stable memory dedup key, memory add uses new schema#54
FZ2000 merged 2 commits intomainfrom
fix/memory-schema-and-dedup-36-45

Conversation

@FZ2000
Copy link
Copy Markdown
Owner

@FZ2000 FZ2000 commented Mar 8, 2026

Fixes #36, Fixes #45

#36 — Memory entries duplicate on every apc collect

Root cause: merge_memory() used str(id(e)) as a fallback key when neither 'id' nor 'entry_id' was present. str(id(e)) is a Python object address that changes every time an entry is loaded from disk, so the same entry would get a different key on each run and never be deduplicated. Fixed by replacing str(id(e)) with a deterministic SHA-256 of (content + source_tool + source_file + category).

#45 — apc memory add uses legacy schema vs collect's new schema

The add command created entries with 'entry_id' using a timestamp prefix (YYYYmmdd_HHMMSS_hash), making it impossible to detect duplicates from two identical add calls at different times. Now creates entries with the new schema: 'id' = SHA-256(manual:category:text), source_tool='manual', source_file='memory_add'. The same text added twice now produces the same id and is idempotent via merge_memory.

Tests

9 new tests in test_memory_bugs_36_45.py.

Frank added 2 commits March 7, 2026 18:22
- #36: Replace str(id(e)) fallback in merge_memory() with a stable
  SHA-256 hash of (content + source_tool + source_file + category).
  The old str(id(e)) is a Python object identifier that changes on
  every process start, causing identical entries loaded from disk to
  get different keys and never be deduplicated. The new fallback is
  deterministic across runs.
- #45: apc memory add now creates entries using the new schema:
    id        = SHA-256 of 'manual:category:text' (content-stable)
    source_tool = 'manual'
    source_file = 'memory_add'
    label     = 'Manual [category]'
  Replaces the legacy entry_id (timestamp prefix) which made it
  impossible to detect duplicate entries from two add calls with the
  same text but different timestamps.

Tests: 9 new tests in test_memory_bugs_36_45.py.
After #45 changed memory add to use the new schema (source_tool='manual'),
manually-added entries were displayed in the '[Collected Files]' section
showing only tool/file path, not the text content.

Separate manual entries (source_tool=='manual') from collected file entries
in memory list so manual adds continue to display their text content grouped
by category, matching the previous UX and the docker integration test.
@FZ2000 FZ2000 merged commit 9fd0364 into main Mar 8, 2026
5 checks passed
forge-fz2000 added a commit that referenced this pull request Mar 9, 2026
… diff

Removed incorrectly listed items that are NOT in main:
- apc skill remove / apc unsync (PR #72 was merged into a feature branch,
  not main)
- Windsurf/Copilot native sync support (same)
- --target/-t removal from apc install (same)

Added missing items that ARE in main since v0.1.1:
- Security fixes: input validation, chmod 600 MCP configs, scrub secrets
  from export (#27,#28,#30 via #50; #32,#35 via #52)
- Bug fixes: LLM write guard, expanduser paths, Copilot absolute paths
  (#37,#38-#43,#42 via #53; #36,#45 via #54)
- Fix: ~/.apc/skills/ always created after apc install
- Fix: --version reads from importlib.metadata
- Docs: README shell completion, CLI basics (#23,#26 via #67)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant