Skip to content

Boot Phases

The bridge starts via 13 ordered phases. Each phase initializes one subsystem, logs its duration, and populates a shared BootCtx object.

Phase sequence

#PhaseWhat it does
1configLoads .env, builds Config + MemoryConfig, configures logger
2memoryCreates and initializes MemoryManager
3transportSelects transport (ACP/API/tmux), builds FallbackPolicy + ModelHealthRegistry
4memory-ipcWires LLM callback for memory, starts MemoryIpcServer
5pipeline-depsCreates CronQueue, PipelineDeps, CodingMode, IdleSave
6platformsRegisters and starts Telegram + Discord (with background retry)
7capabilitiesAuto-discovers capabilities from manifests, starts MCP daemon
8startup-notificationSends "Back online" message, fires startup greeting
9heartbeatWrites bridge.lock, starts HeartbeatSystem (11 tasks), arms in-proc watchdog
10sleepCreates sleep handle for Dreamy
11dashboardStarts web UI (optional, failure non-fatal)
12agent-apiStarts A2A HTTP server
13shutdownRegisters SIGINT/SIGTERM handlers

Ordering invariant

Phase order is enforced by src/boot/phase-order.test.ts. Reordering requires updating the test in the same commit.

Resilience

  • Dashboard is optional — if phase 11 throws (port conflict, missing asset), bridge logs ERROR and continues without it
  • Platforms retry in background — if Telegram/Discord can't connect in 15s, a non-blocking retry loop spawns with exponential backoff (15s → 300s cap)
  • All other phases are essential — failure in memory, transport, or platforms crashes the bridge (correct behavior)

BootCtx

Shared state container defined in src/boot/context.ts. Each phase reads what it needs and writes its outputs. After all phases, syncBridgeFromCtx() copies fields onto the Bridge instance for shutdown's use.

Test factory: createBootCtx(overrides?) — per-phase unit tests pass a partial ctx and assert field population.

Startup log

On successful boot you'll see:

✓ config (12ms)
✓ memory (45ms)
✓ transport (230ms)
✓ memory-ipc (3ms)
✓ pipeline-deps (8ms)
✓ platforms (1200ms)
✓ capabilities (15ms)
✓ startup-notification (50ms)
✓ heartbeat (5ms)
✓ sleep (2ms)
✓ dashboard (18ms)
✓ agent-api (4ms)
✓ shutdown (1ms)