Batch git commits in relate() to reduce noise from auto-edges #2
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/cognitive-memory#2
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Each
relate()call inedges.pytriggers its own git commit via_git_commit(). With the new auto-edge feature inmemory_store, a single store operation can now cause up to 4 git commits (1 for the memory file + up to 3 for auto-edges) plus 1 background sync.This makes
git lognoisy with opaque messages likerelate: abc12345 --BUILDS_ON--> def67890and slows down the store path due to serialized subprocess calls.Proposed Solution
Add an optional
skip_commitparameter torelate()inedges.py, allowing callers to batch multiple edge writes and issue a single git commit afterward. The MCPmemory_relatehandler would continue committing per-call (existing behavior), while_auto_create_edges()would skip per-edge commits and let_trigger_git_sync()handle persistence.Alternatively,
relate()could accept a batch mode or_auto_create_edges()could call a lower-level edge-write method that defers the commit.Scope
edges.py—relate()method needsskip_commitsupportmcp_server.py—_auto_create_edges()passesskip_commit=Truememory_relateMCP tool behavior must not changeFixed by adding
skip_commit=Trueparameter torelate()inedges.py. Auto-edge creation in_auto_create_edges()now passes this flag, skipping the per-edge_git_commit()subprocess calls. The fire-and-forget_trigger_git_sync()at the end ofmemory_storehandles persistence.Result:
memory_storewith auto-edges goes from 4 blocking git commits (~200-400ms) to 1 (the store's own commit). Thememory_relateMCP tool and CLI still commit per-edge (unchanged default behavior).