Skip to content

fix: production audit gaps — retry logic + tree batching#8

Merged
KJ-AIML merged 2 commits into
mainfrom
fix/production-audit-gaps-2026-05-27
May 27, 2026
Merged

fix: production audit gaps — retry logic + tree batching#8
KJ-AIML merged 2 commits into
mainfrom
fix/production-audit-gaps-2026-05-27

Conversation

@KJ-AIML

@KJ-AIML KJ-AIML commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses critical scaling and durability gaps from PRODUCTION_AUDIT_v2.md.

Changes

SQLite Write Retry (Issue #7)

  • now wraps all write paths (19 total):
  • Memory CRUD: insert, delete, update layer/confidence/timestamp
  • Tree: insert_node, clear_nodes, rebuild_tree_atomic
  • Provenance & OTel: save, clear, prune
  • Consolidation: consolidate, consolidate_and_log, consolidate_with_audit
  • Triggers & expiry: log_trigger, expire_old_memories
  • Removed unused decorator dead code

Tree Rebuild Batching

  • now caps batch size at 20 memories
  • For >20 memories, splits into batches and clusters each independently
  • Prevents massive LLM prompts that fail at scale

Test Compatibility

  • Added defensive calls in test fixtures
  • Enables future connection-pooling work without test breakage

Test Results

  • 490 tests passing, 2 skipped
  • Ruff check: clean
  • Format: clean

Notes

  • Connection pooling was attempted but reverted due to Windows file-locking issues with singleton SQLite connections. Will be revisited with a proper connection pool architecture.
  • Tree batching is LLM-path only; fallback keyword clustering was already scalable.

Closes #7

KJ-AIML added 2 commits May 27, 2026 14:31
- memctrl/store.py: _retry_write() now wraps all 19 write paths including
  consolidate, expire_old_memories, rebuild_tree_atomic, log_trigger.
  Removed dead _with_retry decorator.
- memctrl/tree.py: LLM clustering now batches memories into groups of 20
  to prevent massive prompt sizes. Each batch is clustered independently.
- tests: defensive .close() calls added to test fixtures for future
  connection-pooling compatibility.

Closes #7
@KJ-AIML KJ-AIML merged commit 76ee03a into main May 27, 2026
13 checks passed
@KJ-AIML KJ-AIML deleted the fix/production-audit-gaps-2026-05-27 branch May 27, 2026 07:41
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.

fix: production audit gaps — connection pooling and tree rebuild batching

1 participant