---
id: 11074
title: Extract WakeSubstrateCoordinatorService as M4 per-task coordinator (fold bridge-daemon into orchestrator)
state: CLOSED
labels:
  - enhancement
  - ai
  - architecture
  - model-experience
assignees: []
createdAt: '2026-05-09T22:55:13Z'
updatedAt: '2026-06-07T17:09:33Z'
githubUrl: 'https://github.com/neomjs/neo/issues/11074'
author: neo-opus-ada
commentsCount: 1
parentIssue: null
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking: []
closedAt: '2026-05-10T15:45:16Z'
---
# Extract WakeSubstrateCoordinatorService as M4 per-task coordinator (fold bridge-daemon into orchestrator)

## Context

Operator confirmed 2026-05-10: *"of course we want heartbeat and bridge daemon inside our new orchestrator!"* — supersedes the originally-out-of-scope framing in `v13-path.md:94` (which said *"bridge-daemon's specialized HTTP/osascript-driven domain stays separate"*). Fold direction is in-scope.

Operator further surfaced 2026-05-10: *"sunset wakeups => KILL harness, restart, start a fresh session. important for nightshift mode... I challenge it should be in scope."* This ticket includes sunset-wake handling in the fold scope.

Sibling-precedent shape: #11062 (BackupCoordinatorService) + HeartbeatCoordinatorService (filed in same batch).

## The Problem

Bridge-daemon currently runs as a separate persistent-process daemon (`ai/scripts/bridge-daemon.mjs`):
- Operator must keep terminal open OR install launchd plist (anti-pattern per #11066/#11067 retraction)
- Tail-syncs SQLite GraphLog every ~2-3s for low-latency wake delivery
- Coalesces wake events per WAKE_SUBSCRIPTION
- Delivers via osascript (Antigravity / Claude Code / Codex Desktop) or tmux
- (Subprocess) Sunset detection + recovery dispatch via `checkSunsetted.mjs` + `resumeHarness.mjs`

Folding into orchestrator unifies persistent-process management — operator runs one daemon (orchestrator), no separate bridge process.

## Architectural Reality

**Bridge-daemon's work split:**
| Concern | Substrate |
|---|---|
| GraphLog tail-sync | SQLite polling (`getLastSyncId`, `getGraphLogEntries`) |
| Wake-event coalescing | Per-subscription coalescing window |
| osascript / tmux delivery | Operating-system-specific (macOS osascript) |
| Sunset detection | Subprocess `checkSunsetted.mjs` |
| Sunset recovery | Subprocess `resumeHarness.mjs` (KILL harness, spawn fresh session) |
| Idle-out nudge | Subprocess `idleOutNudge.mjs` |
| All-agent-idle trio-wake | Subprocess `trioWakeCooldown.mjs` |

**Folding shape:** WakeSubstrateCoordinatorService.getDueTask() returns trigger when pending wake events exist OR sunset detected; orchestrator's `cadenceEngine.runIfDue('wake', ...)` invokes the work. Tail-sync polling runs at orchestrator's poll cadence (3s default).

**Sunset wake scope (operator-challenged in-scope):** include sunset detection + `resumeHarness` recovery dispatch in this fold. Important for nightshift mode (operator-offline scenario where stale agent harnesses need automatic kill+restart).

**Open questions for pickup `/ticket-intake`:**
1. Does the wake-coalescing window play well with orchestrator's 3s poll cadence?
2. Subprocess-to-direct-import migration (#10795) — does this ticket include or sibling-defer?
3. PID-lock substrate (`bridge-daemon.pid`) retires; orchestrator's PID-file substrate absorbs single-instance enforcement

## Acceptance Criteria

- [ ] `/ticket-intake` validates premise + 3 open questions
- [ ] `ai/daemons/services/WakeSubstrateCoordinatorService.mjs` per #11062 sibling shape
- [ ] Bridge tail-sync + delivery + sunset detection + recovery dispatch all fold to coordinator-pattern
- [ ] `ai/scripts/bridge-daemon.mjs` deleted (entry-point obsoleted by fold)
- [ ] If `com.neomjs.bridge-daemon.plist.template` ever existed, deleted (it doesn't — was never created post-#11066/#11067 closure)
- [ ] `learn/agentos/wake-substrate/PersistentProcessManagement.md` scope-trimmed or retired
- [ ] Wire-in via `cadenceEngine.runIfDue`
- [ ] Cross-family review per `pull-request §6.1`
- [ ] Operator validation: bridge functionality preserved end-to-end (wake delivery + sunset recovery)
- [ ] **`v13-path.md:94` updated** — replace "out of scope: wake-event delivery" with M4-fold reference

## Dependencies

- **Hard:** Blocked by #11062 + #11065 merge for wire-in pattern
- **Coordination:** plist + docs cleanup ACs ride along
- **Sibling:** HeartbeatCoordinatorService (M4 fold sibling; both retire `learn/agentos/wake-substrate/` substrate together)

## Out of Scope

- Detailed prescription pre-staged here (would go stale per #11062/#11065 lesson)
- Cross-platform wake delivery beyond current macOS osascript + tmux scope (sibling-fileable when Linux/Windows operators arrive)
- Subprocess elimination of remaining wake-substrate scripts beyond what's needed for the fold (ride-along OR sibling-defer per pickup-time judgment)

## Related

- Parent landscape: #11022 → M4
- Siblings: #11062, #11065, HeartbeatCoord (filed in same batch), DreamCoord (filed in same batch), GoldenPathCoord (filed in same batch), GraphMaintenanceCoord (filed in same batch)
- Architectural conflict to resolve: `learn/agentos/v13-path.md:94` (says bridge stays separate; this ticket reverses that direction per operator clarification 2026-05-10)
- Source: `ai/scripts/bridge-daemon.mjs`, `ai/scripts/bridge-daemon-queries.mjs`
- Subprocess-companion work: #10795 (CLI-shape scripts → dual-mode imports)
- Closed-as-anti-pattern: #11066/#11067 (per-daemon plist packaging)
- Operator correction trail: PR #11067 closure comment + 2026-05-10 swarm broadcast

---

**Self-Identification:** @neo-opus-ada (Claude Opus 4.7, Claude Code) — landscape-visibility filing 2026-05-10 per operator directive. Includes operator-challenged sunset-wake scope (originally framed out-of-scope; in-scope per nightshift-mode importance).

Origin Session ID: c2912891-b459-4a03-b2af-154d5e264df1

## Timeline

- 2026-05-09T22:55:14Z @neo-opus-ada added the `enhancement` label
- 2026-05-09T22:55:14Z @neo-opus-ada added the `ai` label
- 2026-05-09T22:55:14Z @neo-opus-ada added the `architecture` label
- 2026-05-09T22:55:14Z @neo-opus-ada added the `model-experience` label
- 2026-05-09T22:55:15Z @neo-opus-ada added the `release:v13` label
- 2026-05-09T23:00:37Z @neo-opus-ada cross-referenced by PR #11069
- 2026-05-09T23:05:36Z @neo-opus-ada cross-referenced by #11075
- 2026-05-10T12:13:58Z @neo-opus-ada cross-referenced by #11077
- 2026-05-10T15:45:11Z @neo-opus-ada cross-referenced by #11065
- 2026-05-10T15:45:13Z @neo-opus-ada cross-referenced by #11073
### @neo-opus-ada - 2026-05-10T15:45:14Z

## Close-as-Superseded by Epic #11077 architectural reset

This ticket is part of the 5-coordinator hallucinated cluster (#11070-#11074) that I (@neo-opus-4-7) filed on 2026-05-09 by pattern-matching from `learn/agentos/v13-path.md:193` without reading `DreamService.mjs` source. The substrate-correct shape was the M4 architectural-convergence reset graduated via [Discussion #11076](https://github.com/orgs/neomjs/discussions/11076) → Epic [#11077](https://github.com/neomjs/neo/issues/11077) (closed 2026-05-10 via peer-V-B-A consensus).

The 5-coordinator framing was substrate-incorrect:
- **Cause:** pattern-matching `v13-path.md` names without empirical V-B-A on `DreamService.mjs` actual responsibilities
- **Fix shape:** Orchestrator unifies daemon supervision via `ProcessSupervisorService`; mutate_frontier event-driven Golden Path replaces polling; AgentOrchestrator rename — landed via #11088 / #11096 / #11101

Sister tickets #11070 (DreamCoordinatorService) + #11071 (GoldenPathCoordinatorService) + #11072 (GraphMaintenanceCoordinatorService) already closed-as-superseded. This ticket completes the cleanup symmetry.

**Empirical anchors:**
- Discussion #11076 (the V-B-A retraction; canonical friction → gold trace at architectural-ticket scale)
- Epic #11077 (the substrate-correct architectural reset that shipped what the 5 hallucinated tickets misframed)
- AGENTS.md §3.5 V-B-A core value (just-LIVE per #11098; codifies the discipline that should have caught this at filing-time)

— @neo-opus-4-7


- 2026-05-10T15:45:16Z @neo-opus-ada closed this issue
- 2026-05-12T02:08:26Z @neo-gemini-pro removed the `release:v13` label
- 2026-05-25T07:12:26Z @neo-opus-ada cross-referenced by PR #11957

