LearnNewsExamplesServices
Frontmatter
id8346
titleRefactor DatabaseService to Config-based Opt-Out Auto-Sync
stateClosed
labels
enhancementai
assigneestobiu
createdAtJan 6, 2026, 1:45 AM
updatedAtJan 6, 2026, 2:10 AM
githubUrlhttps://github.com/neomjs/neo/issues/8346
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 6, 2026, 2:10 AM

Refactor DatabaseService to Config-based Opt-Out Auto-Sync

Closed v11.19.0 enhancementai
tobiu
tobiu commented on Jan 6, 2026, 1:45 AM

DatabaseService currently triggers an auto-sync/embed on startup. This is correct for the Server but needs to be disabled for CLI scripts to avoid double-runs.

Goal: Use KB_Config to allow scripts to Opt-Out of Auto-Sync.

Plan:

  1. config.mjs: Add autoSync: true to the default configuration.
  2. DatabaseService.mjs: Modify initAsync to check aiConfig.data.autoSync. If false, skip the sync logic.
  3. ai/examples/sync_knowledge_base.mjs: Import config.mjs and set aiConfig.data.autoSync = false at the top level.

This maintains the "batteries included" behavior for the Server while allowing scripts to disable the side effect.

tobiu added the enhancement label on Jan 6, 2026, 1:45 AM
tobiu added the ai label on Jan 6, 2026, 1:45 AM
tobiu assigned to @tobiu on Jan 6, 2026, 1:47 AM
tobiu changed title from Suppress DatabaseService Auto-Sync for External Scripts to Refactor DatabaseService to Opt-In Auto-Sync on Jan 6, 2026, 1:52 AM
tobiu changed title from Refactor DatabaseService to Opt-In Auto-Sync to Refactor DatabaseService to Config-based Opt-In Auto-Sync on Jan 6, 2026, 1:56 AM
tobiu changed title from Refactor DatabaseService to Config-based Opt-In Auto-Sync to Refactor DatabaseService to Config-based Opt-Out Auto-Sync on Jan 6, 2026, 1:58 AM
tobiu
tobiu Jan 6, 2026, 2:09 AM

Input from Gemini 3 Pro:

✦ I have successfully refactored DatabaseService to use a Config-based "Opt-Out" strategy for Auto-Sync.

Changes Implemented:

  1. ai/mcp/server/knowledge-base/config.mjs:

    • Added autoSync: true to the defaultConfig.
    • This ensures the MCP Server (and any default consumer) continues to auto-heal on startup.
  2. ai/mcp/server/knowledge-base/services/DatabaseService.mjs:

    • Updated initAsync to check aiConfig.data.autoSync.
    • If false, the automatic syncDatabase() / embedKnowledgeBase() calls are skipped.
  3. ai/services.mjs (SDK Entry Point):

    • Added KB_Config.data.autoSync = false at the top level.
    • This ensures that any script importing the AI SDK (e.g., agents, test runners) implicitly opts-out of the auto-sync behavior, preventing double-runs when they manage the database explicitly.

This solution centralizes the control, preserves "batteries-included" for the Server, and safely disables side effects for script execution.

tobiu closed this issue on Jan 6, 2026, 2:10 AM
tobiu referenced in commit 19bd72d - "Enhancement: Refactor DatabaseService to Config-based Opt-Out Auto-Sync #8346 on Jan 6, 2026, 11:24 AM
tobiu cross-referenced by #8347 on Jan 6, 2026, 11:34 AM