feat(agent-memory): Phase 7 — discovery marker#255
Open
jamby77 wants to merge 2 commits into
Open
Conversation
5cdeb4c to
c317978
Compare
524f3a8 to
e58dbb7
Compare
c317978 to
d5a95b9
Compare
e58dbb7 to
0d89d67
Compare
- MemoryDiscovery registers an agent_memory marker on the shared __betterdb:caches registry: type 'agent_memory', prefix, version, capabilities ['recall','consolidate','reinforce'], stats_key - Reuses the agent-cache discovery protocol constants (additively re-exported) so Monitor reads memory markers identically; writes via MemoryStore's .call client (no method-style client needed) - Heartbeat on an unref'd interval with a TTL'd heartbeat key; best-effort writes; name-collision detection against a different cache type - MemoryStore gains an opt-in discovery option and close() to stop the heartbeat and remove the marker - Re-export discovery constants/MarkerMetadata from @betterdb/agent-cache
…:mem
Register the agent_memory marker under the {name}:mem registry field and
heartbeat key so a memory store and an agent-cache sharing the same name
no longer collide on the same __betterdb:caches field / heartbeat key
(reported on the AgentMemory facade, which discovers both tiers).
d5a95b9 to
e27477f
Compare
0d89d67 to
73d91d7
Compare
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.
Stacked on #254 (Phase 6 — consolidate).
What
Phase 7 of
@betterdb/agent-memory: a discovery marker so BetterDB Monitor auto-discovers memory stores on any Valkey it watches, reusing the shared registry protocol from agent-cache.MemoryDiscoveryregisters a marker on__betterdb:cacheskeyed by store name:type: 'agent_memory',prefix,version,protocol_version,capabilities: ['recall','consolidate','reinforce'],stats_key: {name}:__mem_stats, plusstarted_at/pid/hostname.__betterdb:heartbeat:{name}key and the marker; sets__betterdb:protocolwithNX.MemoryStoregains an opt-indiscoveryoption (registers on construct) andclose()to stop the heartbeat and delete the marker.Design / reuse notes
DiscoveryManageruses a method-styleValkeyclient and hard-codes its cache type in the collision check, whileMemoryStoreis built on a.call-only client. Rather than refactor the merged manager (and its FakeClient tests), this reuses the protocol as the single source of truth — agent-cache now additively re-exports its discovery constants (REGISTRY_KEY,PROTOCOL_KEY,HEARTBEAT_KEY_PREFIX, TTL/interval,PROTOCOL_VERSION,MarkerMetadata) — and implements the register/heartbeat loop against.call, so Monitor reads the memory marker identically to a cache marker.close()awaits readiness before teardown.onWriteFailedhook is in place for the Phase 9 observability wiring).Tests
discovery.test.ts(8): marker shape/capabilities/stats_key · protocolNX+ heartbeat TTL · collision throws (and writes nothing) · same-type overwrite ·stopdeletes heartbeat ·tickHeartbeatre-writes · interval fires (fake timers) · best-effort on write failure.MemoryStore.discovery.test.ts(2): opt-in registers on construct +close()tears down · disabled → no registry I/O.@betterdb/agent-cacheunchanged behaviorally (253/253 still green after the additive export). agent-memory: 65/65 green ·tscclean · prettier clean.Note
Low Risk
Discovery is opt-in and additive; registry I/O is best-effort and mirrors existing agent-cache patterns without changing recall/remember paths.
Overview
Adds opt-in Valkey discovery for
@betterdb/agent-memoryso BetterDB Monitor can find memory stores the same way it finds agent caches.MemoryDiscoveryregisters anagent_memorymarker on the shared__betterdb:cachesregistry (field{name}:memto avoid clashing with an agent-cache of the same name), sets protocol/heartbeat keys from the agent-cache protocol, runs an unref’d heartbeat loop, throws on cross-type name collision, and treats registry writes as best-effort.MemoryStoreacceptsdiscovery?: boolean | MemoryDiscoveryConfig, starts registration asynchronously on construct, and addsclose()to await registration and tear down the heartbeat key.@betterdb/agent-cacheonly additively re-exports discovery constants/types (REGISTRY_KEY,PROTOCOL_KEY, heartbeat TTL/interval,MarkerMetadata, etc.); existing cache behavior is unchanged.Reviewed by Cursor Bugbot for commit 73d91d7. Bugbot is set up for automated code reviews on this repo. Configure here.