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

# Architectural Follow-Up: DreamService LLM Extraction Modules

## Context
Following PR #10027, `DreamService` was successfully reduced from ~1,400 to ~570 lines by decoupling node ingestion, file generation, and garbage collection. However, the class still natively implements the raw LLM prompting, JSON extraction logic, and hallucination recovery loops for two critical phases:
1. `executeTriVectorExtraction`
2. `extractTopology`

## Proposed Architecture
To achieve the "~200-line Execution Controller" objective, we must extract these final cognitive operations into independent SDK modules:
*   **`SemanticGraphExtractor.mjs`**: Handles the `TriVector` parsing (Semantic Graph, Namespace, Roadmap Impact).
*   **`TopologyInferenceEngine.mjs`**: Handles scanning episodic documents for structural conflicts (Superseded, Duplicates) against active issues.

## Implementation Requirements
1.  Extract both methods into dedicated `Neo.core.Base` subclasses inside `ai/daemons/services/`.
2.  Wire these newly created services into the central SDK (`ai/services.mjs`).
3.  Prune `DreamService` down to orchestrate these passes via simple `await` calls.
4.  Ensure no Playwright regressions occur in deterministic testing.

## Avoided Pitfalls
*   **The Kitchen Sink Anti-Pattern**: Doing this extraction ensures future schema tweaks to the LLM (e.g., adding a new graph edge relationship type) do not bloat the fundamental process loop runner.

## Timeline

- 2026-04-15T12:17:05Z @tobiu added the `enhancement` label
- 2026-04-15T12:17:06Z @tobiu added the `ai` label
- 2026-04-15T12:17:06Z @tobiu added the `refactoring` label
- 2026-04-15T12:17:06Z @tobiu added the `architecture` label
- 2026-04-15T12:18:54Z @tobiu added parent issue #10013
- 2026-04-15T12:18:55Z @tobiu marked this issue as blocking #10014
- 2026-04-15T12:41:25Z @tobiu referenced in commit `e876e72` - "feat(ai): Modularize DreamService into standalone singletons (#10028)"
- 2026-04-15T12:41:33Z @tobiu cross-referenced by PR #10029
- 2026-04-15T13:06:23Z @tobiu referenced in commit `210a7c1` - "feat(ai): Modularize DreamService into standalone singletons (#10028) (#10029)"
- 2026-04-15T13:06:24Z @tobiu closed this issue
- 2026-04-18T15:20:25Z @tobiu assigned to @tobiu
- 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:04Z @neo-opus-ada added the `release:v13` label
- 2026-05-08T12:46:45Z @neo-opus-ada cross-referenced by #10961
- 2026-05-12T02:10:06Z @neo-gemini-pro removed the `release:v13` label

