---
id: 10013
title: '[Sub-Epic] DreamService Decomposition'
state: CLOSED
labels:
  - epic
  - ai
  - refactoring
  - architecture
assignees:
  - tobiu
createdAt: '2026-04-14T16:43:27Z'
updatedAt: '2026-05-12T02:10:10Z'
githubUrl: 'https://github.com/neomjs/neo/issues/10013'
author: tobiu
commentsCount: 0
parentIssue: 9999
subIssues:
  - '[x] 10028 Finalize DreamService Decomposition: Tri-Vector & Topology Extractors'
subIssuesCompleted: 1
subIssuesTotal: 1
blockedBy: []
blocking:
  - '[x] 10014 [Sub-Epic] Macro Knowledge Base & Semantic Gap Inference'
closedAt: '2026-04-15T12:07:07Z'
---
# [Sub-Epic] DreamService Decomposition

## Objective
Decompose the monolithic `DreamService.mjs` (~1400 lines) into a thin orchestrator backed by focused, independently testable services. This is a structural prerequisite for the Macro KB, Dynamic Topology, and Multi-Tenant Identity workstreams.

## Rationale
`DreamService` currently owns file ingestion, tri-vector extraction, topological conflict detection, capability gap inference, garbage collection, issue/discussion/PR ingestion, and Golden Path synthesis. Adding Macro DB queries, federated ChromaClient routing, batching, and userId-scoped queries would push it past 2000 lines of mixed concerns.

## Proposed Extraction

| New Service | Methods Extracted | Responsibility |
|---|---|---|
| `IssueIngestor` | `ingestIssueStates()`, `ingestDiscussionStates()`, `ingestPullRequestFeedback()` | Structural ingestion of tickets, discussions, PRs into the Native Edge Graph |
| `GapInferenceEngine` | `executeCapabilityGapInference()` | Deterministic gap detection + future Macro DB vector distance queries |
| `GoldenPathSynthesizer` | `synthesizeGoldenPath()` + scoring algebra | Hybrid GraphRAG priority scoring and `sandman_handoff.md` generation |
| `GraphMaintenanceService` | `runGarbageCollection()` | Hebbian decay, orphan pruning, semantic edge management |

`DreamService` itself becomes a ~200-line orchestrator sequencing these services through the REM pipeline phases.

## Acceptance Criteria
- [ ] Each extracted service extends `Neo.core.Base` with `Neo.setupClass()`
- [ ] Each service has full JSDoc with `@summary` tags
- [ ] `DreamService` orchestrator delegates to extracted services
- [ ] All existing Playwright tests pass without modification
- [ ] No behavioral change — pure structural refactor

Parent Epic: #9999
Origin Session ID: 69b726ca-97c8-406c-9106-c63b6642c4c0

## Timeline

- 2026-04-14T16:43:28Z @tobiu added the `epic` label
- 2026-04-14T16:43:28Z @tobiu added the `ai` label
- 2026-04-14T16:43:29Z @tobiu added the `refactoring` label
- 2026-04-14T16:43:29Z @tobiu added the `architecture` label
- 2026-04-14T16:43:52Z @tobiu added parent issue #9999
- 2026-04-14T16:44:30Z @tobiu marked this issue as blocking #10014
- 2026-04-15T11:55:34Z @tobiu referenced in commit `faea291` - "refactor: Decompose DreamService into modular services (#10013)"
- 2026-04-15T11:55:45Z @tobiu cross-referenced by PR #10027
- 2026-04-15T12:07:07Z @tobiu referenced in commit `8473a76` - "refactor: Decompose DreamService into modular services (#10013) (#10027)"
- 2026-04-15T12:07:07Z @tobiu closed this issue
- 2026-04-15T12:18:54Z @tobiu added sub-issue #10028
- 2026-04-18T15:22:11Z @tobiu assigned to @tobiu
- 2026-04-20T11:13:56Z @tobiu cross-referenced by #9748
- 2026-05-01T16:10:35Z @neo-gpt cross-referenced by #9999
- 2026-05-06T16:00:40Z @neo-opus-ada cross-referenced by #10822
- 2026-05-08T11:53:48Z @neo-opus-ada cross-referenced by #10957
- 2026-05-08T11:57:47Z @neo-gemini-pro cross-referenced by PR #10958
- 2026-05-08T12:28:11Z @neo-opus-ada cross-referenced by #10960
- 2026-05-08T12:44:00Z @neo-opus-ada added the `release:v13` label
- 2026-05-08T12:46:45Z @neo-opus-ada cross-referenced by #10961
- 2026-05-08T13:14:42Z @neo-opus-ada cross-referenced by PR #10963
- 2026-05-12T02:10:10Z @neo-gemini-pro removed the `release:v13` label

