LearnNewsExamplesServices
Frontmatter
id10222
titleRemove Memory Core Band-Aids and Polish Cache Coherence
stateClosed
labels
enhancementairefactoringarchitecturecore
assigneesneo-gemini-3-1-pro
createdAtApr 23, 2026, 11:16 AM
updatedAtApr 23, 2026, 11:46 AM
githubUrlhttps://github.com/neomjs/neo/issues/10222
authorneo-gemini-3-1-pro
commentsCount0
parentIssue10186
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 23, 2026, 11:46 AM

Remove Memory Core Band-Aids and Polish Cache Coherence

Closedenhancementairefactoringarchitecturecore
neo-gemini-3-1-pro
neo-gemini-3-1-pro commented on Apr 23, 2026, 11:16 AM

Context

With the successful merge of PR #10221 (resolving #10190) and empirical validation via full swarm restart cycles, the underlying Database cache coherence vulnerabilities have been resolved. The temporary band-aids put in place prior to the substrate fix (#10185 and #10182) are now obsolete and need to be removed to reduce operational complexity and avoid masking future regressions. Additionally, peer review on PR #10221 identified missing architectural documentation for future telemetry.

The Problem

During the cache coherence diagnostic phase, two temporary mitigations were introduced into Server.mjs:

  1. #10185 Retry Loop: Added to bindAgentIdentity to poll for graph nodes, attempting to mask the symptom of fresh-boot cache divergence.
  2. #10182 Self-Heal: Added to the CallToolHandler to late-bind identities if they were missed during boot.

Since #10190 natively fixed the cache coherence issue by stripping the lastSyncId guard, GraphService.getNode is now guaranteed to return accurate results without needing artificial delays or retries. Keeping these band-aids introduces technical debt and makes the code harder to reason about.

The Architectural Reality

  • ai/mcp/server/memory-core/Server.mjs: bindAgentIdentity contains an obsolete 3-retry polling loop with a 200ms sleep and vicinity tracker resets. The tool call handler contains the #10182 late-binding fallback.
  • ai/graph/Database.mjs: Lines 78 and 281 lack the "Anchor & Echo" rationale for the #10190 changes (removing the lastSyncId guard and the empty-vicinity mark), leaving a knowledge gap for future debugging. The syncCache JSDoc also omits the new invariant that fresh-boots are legitimate triggers that invalidate the cache.

The Fix

  1. Remove Retry Loop: Strip the 3-attempt polling logic from Server.mjs:bindAgentIdentity. A single GraphService.getNode({id: graphNodeId}) call is now sufficient since await GraphService.ready() ensures the cache is coherent.
  2. Remove Self-Heal: Strip the !this.stdioIdentity.agentIdentityNodeId fallback block from the CallToolRequestSchema handler in Server.mjs.
  3. Anchor & Echo: Add inline comments citing #10190 / ADR 0001 Bug A (at Database.mjs:78) and Bug B (at Database.mjs:281-283).
  4. JSDoc Extension: Update the syncCache JSDoc to explicitly state that lastSyncId=0 triggers a legitimate catch-up rather than a skip, and clarify that it invalidates stale entries rather than upserting new ones.

Acceptance Criteria

  • bindAgentIdentity in Server.mjs no longer contains a polling loop or vicinity cache deletion.
  • Tool dispatch in Server.mjs no longer contains the #10182 self-heal logic.
  • ai/graph/Database.mjs contains explicit inline comments detailing the "WHY" for both Bug A and Bug B resolutions.
  • syncCache JSDoc explicitly documents its invariant behavior regarding fresh boots and invalidation vs upserts.

Out of Scope

  • Modifying the underlying GraphLog or Database.mjs execution logic (this is strictly a cleanup and documentation pass).
  • Any modifications to the MailboxService or A2A handshakes.

Avoided Traps

  • Trap: Leaving the band-aids as "defense in depth." Why avoided: It masks potential future regressions in the Database coherence layer. If the cache is incoherent, we want the identity binding to fail so the substrate issue is surfaced immediately, rather than silently retrying.

Related

Origin Session ID: e068b094-fcae-436a-a9ab-c513246f7f71

tobiu referenced in commit e5ad843 - "fix(ai): remove memory core band-aids and polish cache coherence (#10222) (#10223) on Apr 23, 2026, 11:46 AM
tobiu closed this issue on Apr 23, 2026, 11:46 AM