---
id: 11844
title: 'Sub 8: Orchestrator-cluster co-location (ai/daemons/orchestrator/) + daemon.mjs naming + test mirror + package.json'
state: CLOSED
labels:
  - enhancement
  - ai
  - refactoring
  - architecture
assignees:
  - neo-opus-ada
createdAt: '2026-05-23T13:32:19Z'
updatedAt: '2026-05-23T14:57:05Z'
githubUrl: 'https://github.com/neomjs/neo/issues/11844'
author: neo-opus-ada
commentsCount: 0
parentIssue: 11831
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking:
  - '[x] 11846 Sub 10: Cross-daemon services bucket (ai/services/graph/ + ai/services/ingestion/)'
  - '[x] 11845 Sub 9: Sub-daemon cluster co-location (bridge + kb-alerting + kb-gc + kb-reconciliation) with daemon.mjs naming'
closedAt: '2026-05-23T14:57:05Z'
---
# Sub 8: Orchestrator-cluster co-location (ai/daemons/orchestrator/) + daemon.mjs naming + test mirror + package.json

## Parent Epic

#11831 — **Sub 8 of Epic (folder-structure cleanup; per-daemon co-location).**

## Scope

Move Orchestrator's cluster into self-contained `ai/daemons/orchestrator/`. Entry-script renamed to `daemon.mjs` per @tobiu chief-architect convention (folder context provides daemon identity; eliminates `orchestrator/orchestrator-daemon.mjs` redundancy). Orchestrator-private services (sole consumer = Orchestrator) move into `ai/daemons/orchestrator/services/`.

## Source moves

| From | To |
|---|---|
| `ai/daemons/Orchestrator.mjs` | `ai/daemons/orchestrator/Orchestrator.mjs` |
| `ai/daemons/TaskDefinitions.mjs` | `ai/daemons/orchestrator/TaskDefinitions.mjs` |
| `ai/scripts/orchestrator-daemon.mjs` | `ai/daemons/orchestrator/daemon.mjs` (rename) |
| `ai/daemons/services/BackupCoordinatorService.mjs` | `ai/daemons/orchestrator/services/BackupCoordinatorService.mjs` |
| `ai/daemons/services/CadenceEngine.mjs` | `ai/daemons/orchestrator/services/CadenceEngine.mjs` |
| `ai/daemons/services/HeavyMaintenanceLeaseService.mjs` | `ai/daemons/orchestrator/services/HeavyMaintenanceLeaseService.mjs` |
| `ai/daemons/services/PrimaryRepoSyncService.mjs` | `ai/daemons/orchestrator/services/PrimaryRepoSyncService.mjs` |
| `ai/daemons/services/ProcessSupervisorService.mjs` | `ai/daemons/orchestrator/services/ProcessSupervisorService.mjs` |
| `ai/daemons/services/SummarizationCoordinatorService.mjs` | `ai/daemons/orchestrator/services/SummarizationCoordinatorService.mjs` |
| `ai/daemons/services/TaskStateService.mjs` | `ai/daemons/orchestrator/services/TaskStateService.mjs` |
| `ai/daemons/DreamService.mjs` | `ai/daemons/orchestrator/services/DreamService.mjs` |
| `ai/daemons/SwarmHeartbeatService.mjs` | `ai/daemons/orchestrator/services/SwarmHeartbeatService.mjs` |

Note: `ai/scripts/bridge-daemon-queries.mjs` STAYS in `ai/scripts/` for this Sub — moves to `ai/daemons/bridge/queries.mjs` in Sub 9 (bridge cluster).

## Test moves (mirror source)

| From | To |
|---|---|
| `test/playwright/unit/ai/daemons/Orchestrator.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/Orchestrator.spec.mjs` |
| `test/playwright/unit/ai/scripts/orchestrator-daemon.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/daemon.spec.mjs` (rename match) |
| `test/playwright/unit/ai/daemons/DreamService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/DreamService.spec.mjs` |
| `test/playwright/unit/ai/daemons/DreamServiceGoldenPath.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/DreamServiceGoldenPath.spec.mjs` |
| `test/playwright/unit/ai/daemons/SwarmHeartbeatService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/SwarmHeartbeatService.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/BackupCoordinatorService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/BackupCoordinatorService.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/CadenceEngine.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/CadenceEngine.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/HeavyMaintenanceLeaseService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/HeavyMaintenanceLeaseService.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/PrimaryRepoSyncService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/PrimaryRepoSyncService.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/ProcessSupervisorService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/ProcessSupervisorService.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/SummarizationCoordinatorService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/SummarizationCoordinatorService.spec.mjs` |
| `test/playwright/unit/ai/daemons/services/TaskStateService.spec.mjs` | `test/playwright/unit/ai/daemons/orchestrator/services/TaskStateService.spec.mjs` |

## package.json

- `"ai:orchestrator"` script path: `./ai/scripts/orchestrator-daemon.mjs` → `./ai/daemons/orchestrator/daemon.mjs`

## .github/workflows

(none affected by Sub 8 — workflows only reference lint/check scripts which Sub 11 handles).

## Integration tests

(none affected by Sub 8 — integration tests touching Orchestrator-cluster files import via the unit-test path which mirrors source structure).

## Acceptance Criteria

1. All listed files moved.
2. Cross-codebase import paths updated (`grep -rn` post-move shows zero stale imports to the moved files).
3. All affected unit specs pass from their new locations.
4. `npm run ai:orchestrator` works.
5. Tier 1 Config Immutability suite + Orchestrator.spec.mjs + each moved service's spec pass.

**Authored by:** [Claude Opus 4.7] (Claude Code)

## Timeline

- 2026-05-23T13:32:20Z @neo-opus-ada assigned to @neo-opus-ada
- 2026-05-23T13:32:20Z @neo-opus-ada added the `enhancement` label
- 2026-05-23T13:32:20Z @neo-opus-ada added the `ai` label
- 2026-05-23T13:32:20Z @neo-opus-ada added the `refactoring` label
- 2026-05-23T13:32:20Z @neo-opus-ada added the `architecture` label
- 2026-05-23T13:32:31Z @neo-opus-ada added parent issue #11831
- 2026-05-23T13:41:34Z @neo-opus-ada changed title from **Sub 8: Move root-level *Service.mjs files into ai/daemons/services/ (folder-structure cleanup)** to **Sub 8: Orchestrator-cluster co-location (ai/daemons/orchestrator/{,services/}) + test mirror + package.json**
- 2026-05-23T13:53:35Z @neo-opus-ada changed title from **Sub 8: Orchestrator-cluster co-location (ai/daemons/orchestrator/{,services/}) + test mirror + package.json** to **Sub 8: Orchestrator-cluster co-location (ai/daemons/orchestrator/) + daemon.mjs naming + test mirror + package.json**
- 2026-05-23T13:53:54Z @neo-opus-ada cross-referenced by #11845
- 2026-05-23T13:54:06Z @neo-opus-ada cross-referenced by #11846
- 2026-05-23T13:57:01Z @neo-opus-ada marked this issue as blocking #11845
- 2026-05-23T13:57:02Z @neo-opus-ada marked this issue as blocking #11846
- 2026-05-23T14:14:11Z @neo-opus-ada referenced in commit `f81d189` - "refactor(agentos): orchestrator-cluster co-location ai/daemons/orchestrator/ + daemon.mjs (#11844)

Sub 8 of Epic #11831. Move Orchestrator's cluster into self-contained
ai/daemons/orchestrator/{,services/} folder. Entry-script renamed to
daemon.mjs (folder context provides daemon identity).

13 source moves + 12 test moves (mirror structure) + ai/services.mjs +
7 buildScripts/ai/ consumer-import updates + package.json ai:orchestrator
path update.

Tests: 119/119 pass (6.6s).

Subsequent subs filed: Sub 9 #11845, Sub 10 #11846, Sub 11 #11847, Sub 12 #11848."
- 2026-05-23T14:14:46Z @neo-opus-ada cross-referenced by PR #11849
- 2026-05-23T14:26:43Z @neo-opus-ada referenced in commit `e891c46` - "test(agentos): update laneC spec HeavyMaintenanceLeaseService path post-move (#11844)

Sub 8 #11844 moved HeavyMaintenanceLeaseService into
ai/daemons/orchestrator/services/. laneCManualScriptLeaseAdoption.spec.mjs
content-verifies that buildScripts/ai/{runSandman,syncKnowledgeBase,backup,
syncGithubWorkflow}.mjs import the lease service from the canonical path.
2 path assertions updated (regex on line 61 + toContain on line 173) to
match the new location.

The 7 laneC test failures were entirely path-string assertions; tests pass
post-update. Other 21 unit-test failures observed are PRE-EXISTING flakes
unrelated to Sub 8 (verified via git stash baseline) — grid/vdom/checkSunsetted
tests fail on origin/dev too, separate test-isolation/timing concerns."
- 2026-05-23T14:42:57Z @neo-opus-ada referenced in commit `c322215` - "fix(agentos): update MailboxService.spec dynamic import for SwarmHeartbeatService post-move (#11844)

Sub 8 co-located SwarmHeartbeatService into ai/daemons/orchestrator/services/
but my static-import sweep regex (`from '...'`) missed dynamic `await import(...)`
call-sites. CI unit job 26335211375 caught: MailboxService.spec.mjs:49
`await import('../../../../../../ai/daemons/SwarmHeartbeatService.mjs')`
threw `Cannot find module`.

Fix: insert `/orchestrator/services` into the dynamic-import path. Local
re-run: 59/59 tests pass.

V-B-A miss anchor: prior turn claimed "Sub 8 introduces ZERO new failures
with NEO_TEST_SKIP_CI=true"; CI's full unit run without that flag exposed
the stale dynamic-import. Next sweep tooling for cross-cutting moves must
cover dynamic `await import()` call-sites, not just static `from '...'`."
- 2026-05-23T14:57:05Z @tobiu referenced in commit `6cc9179` - "refactor(agentos): orchestrator-cluster co-location ai/daemons/orchestrator/ + daemon.mjs (#11844) (#11849)

* refactor(agentos): orchestrator-cluster co-location ai/daemons/orchestrator/ + daemon.mjs (#11844)

Sub 8 of Epic #11831. Move Orchestrator's cluster into self-contained
ai/daemons/orchestrator/{,services/} folder. Entry-script renamed to
daemon.mjs (folder context provides daemon identity).

13 source moves + 12 test moves (mirror structure) + ai/services.mjs +
7 buildScripts/ai/ consumer-import updates + package.json ai:orchestrator
path update.

Tests: 119/119 pass (6.6s).

Subsequent subs filed: Sub 9 #11845, Sub 10 #11846, Sub 11 #11847, Sub 12 #11848.

* test(agentos): update laneC spec HeavyMaintenanceLeaseService path post-move (#11844)

Sub 8 #11844 moved HeavyMaintenanceLeaseService into
ai/daemons/orchestrator/services/. laneCManualScriptLeaseAdoption.spec.mjs
content-verifies that buildScripts/ai/{runSandman,syncKnowledgeBase,backup,
syncGithubWorkflow}.mjs import the lease service from the canonical path.
2 path assertions updated (regex on line 61 + toContain on line 173) to
match the new location.

The 7 laneC test failures were entirely path-string assertions; tests pass
post-update. Other 21 unit-test failures observed are PRE-EXISTING flakes
unrelated to Sub 8 (verified via git stash baseline) — grid/vdom/checkSunsetted
tests fail on origin/dev too, separate test-isolation/timing concerns.

* fix(agentos): update MailboxService.spec dynamic import for SwarmHeartbeatService post-move (#11844)

Sub 8 co-located SwarmHeartbeatService into ai/daemons/orchestrator/services/
but my static-import sweep regex (`from '...'`) missed dynamic `await import(...)`
call-sites. CI unit job 26335211375 caught: MailboxService.spec.mjs:49
`await import('../../../../../../ai/daemons/SwarmHeartbeatService.mjs')`
threw `Cannot find module`.

Fix: insert `/orchestrator/services` into the dynamic-import path. Local
re-run: 59/59 tests pass.

V-B-A miss anchor: prior turn claimed "Sub 8 introduces ZERO new failures
with NEO_TEST_SKIP_CI=true"; CI's full unit run without that flag exposed
the stale dynamic-import. Next sweep tooling for cross-cutting moves must
cover dynamic `await import()` call-sites, not just static `from '...'`.

---------

Co-authored-by: tobiu <tobiasuhlig78@gmail.com>"
- 2026-05-23T14:57:05Z @tobiu closed this issue
- 2026-05-23T15:18:44Z @neo-opus-ada cross-referenced by PR #11850
- 2026-05-23T15:26:13Z @tobiu referenced in commit `91366d2` - "refactor(agentos): sub-daemon cluster co-location ai/daemons/{bridge,kb-alerting,kb-gc,kb-reconciliation}/ + daemon.mjs (#11845) (#11850)

Sub 9 of Epic #11831 — co-locates the four sub-daemon clusters into per-folder
mirrors of Sub 8's orchestrator pattern.

Source moves (8):
- ai/scripts/bridge-daemon.mjs            → ai/daemons/bridge/daemon.mjs
- ai/scripts/bridge-daemon-queries.mjs    → ai/daemons/bridge/queries.mjs (renamed)
- ai/daemons/KbAlertingService.mjs        → ai/daemons/kb-alerting/KbAlertingService.mjs
- ai/scripts/kb-alerting-daemon.mjs       → ai/daemons/kb-alerting/daemon.mjs
- ai/daemons/KbGarbageCollectionService.mjs → ai/daemons/kb-gc/KbGarbageCollectionService.mjs
- ai/scripts/kb-gc-daemon.mjs             → ai/daemons/kb-gc/daemon.mjs
- ai/daemons/KbReconciliationService.mjs  → ai/daemons/kb-reconciliation/KbReconciliationService.mjs
- ai/scripts/kb-reconciliation-daemon.mjs → ai/daemons/kb-reconciliation/daemon.mjs

Test moves (5 — ticket undercounted; included pre-existing bridge specs):
- bridge-daemon.spec.mjs         → ai/daemons/bridge/daemon.spec.mjs
- bridge-daemon-queries.spec.mjs → ai/daemons/bridge/queries.spec.mjs
- KbAlertingService.spec.mjs          → ai/daemons/kb-alerting/
- KbGarbageCollectionService.spec.mjs → ai/daemons/kb-gc/
- KbReconciliationService.spec.mjs    → ai/daemons/kb-reconciliation/

package.json: 3 npm script paths updated (ai:kb-alerting/kb-gc/kb-reconciliation).

Orchestrator wiring:
- Orchestrator.mjs:14-16  bridge-daemon-queries import → '../bridge/queries.mjs'
- TaskDefinitions.mjs:70  bridgeDaemon.args path → resolve('../daemons/bridge/daemon.mjs')
- TaskDefinitions.mjs:72  expectedCommand → 'daemons/bridge/daemon.mjs' (unique
  among the 5 daemon.mjs files post-Sub-8/9)
- bridge/daemon.mjs:179   enforceSingleton() process.command substring check
  updated to 'daemons/bridge/daemon.mjs' (was 'bridge-daemon.mjs')
- SummarizationCoordinatorService.mjs:8  bridge-daemon-queries import path
- KbAlertRuleEngine + KbGarbageCollectionEngine + KbReconciliationEngine: JSDoc @see paths
- CoalescingEngineService: code reference path
- multi-tenant integration spec:114 dynamic import path

V-B-A discipline from Sub 8 (#11844): swept BOTH static `from '...'` AND
dynamic `await import('...')` call-sites. Local full unit run: 2011 passed,
19 failed (all pre-existing — Authorization, checkAllAgentIdle, checkSunsetted,
QueryReRanker, TextEmbeddingService.retry, WriteSideInvariant, Grid family;
none reference moved files; confirmed via grep).

Co-authored-by: tobiu <tobiasuhlig78@gmail.com>"
- 2026-05-23T15:34:48Z @neo-opus-ada cross-referenced by PR #11851
- 2026-05-23T16:01:17Z @neo-opus-ada cross-referenced by PR #11852
- 2026-05-23T17:00:28Z @neo-opus-ada cross-referenced by PR #11853
- 2026-05-24T02:38:25Z @neo-opus-ada cross-referenced by PR #11877
- 2026-05-24T14:31:37Z @neo-opus-ada cross-referenced by PR #11913

