mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
- Added JSDoc and inline comments to `src/services/memory/index.js` to clarify module flow and internal invariants. - Fixed a race condition in `performSave` where `currentSavePromise` was cleared before the pending save was chained, potentially allowing concurrent writes. - Created `docs/memory-service-index-overview.md` with high-level architecture. - Verified changes with `npm test src/services/memory/index.js` and `npm run lint`. - Updated `TEST_LOG` and `task-logs` to reflect the fix. Co-authored-by: PR0M3TH3AN <[email protected]>
916 B
916 B
Memory Update — docs-code-investigator — 2026-02-27
Key findings
src/services/memory/index.jsuses a manual promise-based queue (performSave/saveMemoryStore) to serialize file writes. This is a critical pattern to preserve if refactoring persistence.- The memory store is an in-memory
Mapinitialized from a JSON file at startup. - Any mutation to the store must clear the retrieval cache (
cache.clear()) to maintain consistency.
Patterns / reusable knowledge
- When documenting complex async state managers, explicitly call out the concurrency control mechanism (in this case, the save queue).
- JSDoc
@fileoverviewis useful for high-level module context that doesn't fit in individual function docs.
Warnings / gotchas
- Running multiple agent processes without a coordinator will cause race conditions on
memory-store.jsonbecause the locking is process-local.