Skip to content

feat(memory): implement Living Memory system with file routing, CLI, and CI fixes (#741) - #769

Merged
AmitoVrito merged 6 commits into
mainfrom
feat/issue-741-living-memory-files-v2
Jul 14, 2026
Merged

AmitoVrito merged 6 commits into
mainfrom
feat/issue-741-living-memory-files-v2

Conversation

@DhruvGarg111

@DhruvGarg111 DhruvGarg111 commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Implements the Living Memory subsystem for SynapseKit — an intelligent, file-routed memory layer that manages persistent agent memory through diffable patches, occurrence tracking, and PII filtering.

Changes

Core Features

  • Living Memory types: MemoryPatch, OccurrenceRecord, MemoryFileCategory, diff engine, patch store, PII filter
  • File router: Categorizes memory content and resolves target file paths
  • LivingMemory orchestrator: Full lifecycle management — propose, approve, apply, revert patches
  • CLI handlers: synapsekit memory review|approve|reject|apply|revert|log subcommands
  • Comprehensive tests: Unit and integration tests for all components

CI & Test Fixes

  • Windows CI: Platform-conditional fake binary in test_edge_quantize (.bat on Windows, shebang on Unix) — fixes WinError 193
  • Skip guard: Use importlib.util.find_spec() instead of sys.modules check in test_onnx for reliable installed-package detection
  • Flaky test: Bump PythonREPLTool timeout from 2s to 10s to prevent subprocess startup failures under load
  • Linting: Apply ruff formatting fixes across 14 files (line length, redundant defaults, raw regex strings, unused imports/variables)
  • Typecheck: Remove redundant casts in decorators.py, add type narrowing assert for avg_cost in agent_registry.py

Test Results

4351 passed, 29 skipped, 0 failures (138s)

Closes #741

DhruvGarg111 and others added 6 commits July 13, 2026 19:57
- test_edge: create platform-appropriate fake binary (.bat on Windows,
  shebang script on Unix) to fix WinError 193
- test_onnx: use importlib.util.find_spec() instead of sys.modules check
  to reliably detect installed onnxruntime
- test_tools: bump PythonREPLTool timeout from 2s to 10s to prevent
  flaky failures under system load
- Apply ruff formatting fixes across 9 source files (line length,
  redundant defaults, raw regex strings, unused imports/variables)
- Remove unused 'import sys' from test_onnx.py (ruff F401)
- Remove redundant casts in decorators.py (mypy redundant-cast)
- Assert avg_cost is not None before _ema call (mypy arg-type)
PatchStore.update() no longer calls patch.sign() with an empty secret.
Callers already sign patches with the correct secret right before
calling update() (LivingMemory.apply/revert/_apply_patch_to_file), so
the unconditional resign was overwriting valid secret-signed
signatures with unsigned ones before persisting, breaking
patch.verify(secret) and allowing forged signatures to pass.

MemoryPIIFilter.filter_content() no longer reports content as clean
based solely on the underlying PIIDetector's check. PIIDetector only
recognizes a handful of built in PII patterns (email, phone, ssn,
credit_card, ip_address), while MemoryPIIFilter supports extra types
like api_key. filter_content() now also checks the extra redaction
patterns not covered by PIIDetector before deciding content is clean,
so content containing only an api_key is correctly flagged and
redacted.

filter_content() with redact=False also had a violation type parsing
bug: splitting on "(" and ")" and ":" produced "email)" instead of
"email" because rstrip(")") stripped the trailing paren from the
"instance(s)" suffix. Replaced with a regex extraction of the type
name from the violation string.

Added regression tests in tests/memory/test_living_memory.py covering
all three fixes, including negative cases (wrong secret fails to
verify, api_key mixed with a supported type still redacts both).

Co-authored-by: Dhruv Garg <[email protected]>
@AmitoVrito
AmitoVrito merged commit 66b2e39 into main Jul 14, 2026
5 checks passed
@AmitoVrito

Copy link
Copy Markdown
Collaborator

Thanks for this, Dhruv. Solid foundation for the Living Memory system.

Before merging I fixed three bugs found in review:

  1. PatchStore.update() was re-signing every patch with an empty secret right after callers had already signed it correctly, which broke signature verification and defeated the integrity check entirely. Removed the redundant sign call.
  2. The PII filter's clean check only looked at PIIDetector's small pattern set, so content containing only an API key slipped through unredacted. Extended the clean check to cover the filter's own redaction patterns too.
  3. The redact=False violation type parser mishandled the "(s)" suffix in "instance(s)" and returned "email)" instead of "email". Replaced it with a proper regex parse.

Added regression tests for all three and ran the full suite, everything green. Merged into main.

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.

v2.1: Living Memory Files — agents that propose diffs to your CLAUDE.md / memory files

2 participants