sequenceDiagram
autonumber
participant DM as Endless-dreaming daemon
participant DR as Drain state machine
participant CX as Codex agent
participant GA as Operator-Authority gate
participant CI as Smoke + browser verify
participant GH as GitHub
actor OP as Operator
DM->>DR: poll #morpheus todos (per cycle)
DR->>CX: planning prompt
CX-->>DR: plan
DR->>CX: coding prompt (branch morpheus/T#-slug)
CX->>GA: write / edit / shell — each gated
GA-->>CX: allow / deny (HR11)
CX-->>DR: diff
DR->>CI: run smoke + browser verify
CI-->>DR: pass
DR->>GA: pre-PR gate (repo CI)
GA-->>DR: pass
DR->>GH: git push + gh pr create
GH-->>OP: PR for review
OP->>GH: review / merge