fix(#36,#45): stable memory dedup key, memory add uses new schema#54
Merged
fix(#36,#45): stable memory dedup key, memory add uses new schema#54
Conversation
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.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.