LearnNewsExamplesServices
Frontmatter
titlerefactor: Decompose DreamService into modular services (#10013)
authortobiu
stateMerged
createdAtApr 15, 2026, 1:55 PM
updatedAtApr 15, 2026, 2:07 PM
closedAtApr 15, 2026, 2:07 PM
mergedAtApr 15, 2026, 2:07 PM
branchesdevagent/10013-dream-service-decomposition
urlhttps://github.com/neomjs/neo/pull/10027
Merged
tobiu
tobiu commented on Apr 15, 2026, 1:55 PM

Architectural Refactoring: DreamService Decomposition

Resolves #10013

Problem Statement: The DreamService.mjs had grown into a monolithic ~1,400-line class, creating architectural debt, complex testing boundaries, and coupling across discrete service domains (e.g., node ingestion, AST parsing, markdown synthesis).

Implemented Solution:

  1. Service Extraction: Factored out IssueIngestor.mjs, GoldenPathSynthesizer.mjs, GapInferenceEngine.mjs, and GraphMaintenanceService.mjs into discrete, fully encapsulated modular classes inheriting from Neo.core.Base.
  2. SDK Centralization: Enhanced ai/services.mjs to natively export Memory_StorageRouter and Memory_TextEmbeddingService. All inner-loop daemons and synthesized services have been migrated to target the single-point SDK wrapper instead of fragile relative MCP imports (../../services.mjs).
  3. AST Validation Stability: Corrected multi-layer string interpolation physics (double backtick escaping issues) injected during the split, re-establishing strict Playwright deterministic stability.
  4. Volume Reduction: DreamService.mjs was pruned down to ~570 lines, focusing heavily on execution flow delegation rather than raw implementation.

Verification:

  • Playwright DreamService.spec.mjs and DreamServiceGoldenPath.spec.mjs execute successfully with 100% test passage.
  • Context isolation via SQLite database remains intact.

Follow-Up Actionability: This PR establishes the primary foundation. The codebase size was successfully reduced by ~60%, paving the way for follow-up tickets to target the eventual ~200-line "Pure Controller" topology state.

tobiu
tobiu commented on Apr 15, 2026, 1:58 PM

Input from Gemini 3.1 Pro (Antigravity):

✦ # PR Review Summary

Status: Approved

Excellent work decoupling the monolithic DreamService! The transition from a 1,400-line class down to specialized, encapsulated Neo.core.Base components (IssueIngestor, GoldenPathSynthesizer, etc.) establishes a much cleaner architectural runway for future enhancements. Bringing these inside the centralized ai/services.mjs SDK guarantees robust dependency and validation flow. Great execution.


📊 Evaluation Metrics

  • [ARCH_ALIGNMENT]: 95 - Strongly aligned. Migrates logic out of global daemon space into formal Neo.core.Base sub-services mapped behind the SDK.
  • [CONTENT_COMPLETENESS]: 90 - "Fat Ticket" methodology executed successfully with proper structural breakdown logic. JSDoc remains intact across the new files.
  • [EXECUTION_QUALITY]: 100 - Zero test regressions in the Playwright suite. Resolved all double-backtick string interpolation issues resulting from the refactor.
  • [PRODUCTIVITY]: 100 - Successfully pruned ~830 lines from DreamService, accomplishing the primary goal of the decomposition sprint.
  • [IMPACT]: 85 - Significant framework architecture cleanup. Eliminates scaling bottlenecks for inner-loop daemons.
  • [COMPLEXITY]: 75 - High mechanical complexity during split phase, but resulting output drastically lowers overall cognitive load for future readers.
  • [EFFORT_PROFILE]: Heavy Lift - Involved substantial codebase dissection and fixing complex AST escaping issues to preserve deterministic behavior.

🕸️ Context & Graph Linking

  • Target Epic / Issue ID: Resolves #10013
  • Related Graph Nodes: DreamService, IssueIngestor, GoldenPathSynthesizer, Native Edge Graph

🧠 Graph Ingestion Notes

  • [KB_GAP]: N/A
  • [TOOLING_GAP]: N/A
  • [RETROSPECTIVE]: Refactoring out major monolithic dependencies incrementally (from ~1,400 to ~570 lines) without blocking execution provides a mathematically stable checkpoint. Centralizing into an SDK (ai/services.mjs) is vastly superior to directly importing internal MCP classes (ai/mcp/server/...) because it maintains rigorous validation boundaries.

📋 Required Actions

To proceed with merging, please address the following:

  • Provide follow-up system enhancement tickets structurally linked to this Epic to outline how the remaining 370 lines of DreamService can be pruned into a pure ~200 line execution controller.

Once that is verified, this is clear to merge!