darq 0.1.0

darq CLI + TUI — autonomous issue → PR pipeline with SAT and a learning loop.
Documentation
# Daemon IPC

> For project-wide conventions and anti-patterns, see [CLAUDE.md]../../../../CLAUDE.md and [agent-rules.md]../../../../docs/agent-rules.md.

## WHERE TO LOOK

| File | Role |
|------|------|
| `server.rs` | `SocketServer` — accepts connections, dispatches methods, streams events |
| `protocol.rs` | `Method` enum + `Request`/`Response` types (JSON, snake_case) |
| `client.rs` | `DaemonClient` — connect, send, call, `subscribe_events()` |
| `lifecycle.rs` | PID file, socket path, daemon detection, spawn, cleanup |
| `mod.rs` | `handle_start`/`handle_stop`/`handle_daemon_status` entry points |

## ARCHITECTURE

```
CLI/TUI → DaemonClient → UnixStream → SocketServer → Api/WorkflowEngine
                          EventBroadcaster → EventStream (separate connection)
```

**Methods**: `status`, `run_list`, `run_show`, `run_approve`, `run_cancel`, `workflow_start`, `workflow_chain`, `sweep`, `subscribe`, `stats`, `shutdown`

**Subscribe** must be the first command on a connection. Switches to push-based event streaming mode (one-way daemon → client).

**Background start**: Spawns detached child process via `setsid()`, waits for socket to appear (up to 5s).

**Socket permissions**: 0o600. PID liveness checked via `kill(pid, 0)`.

## LOCAL CONVENTIONS

- Long-running handlers like `workflow_chain` spawn a `tokio::spawn` task and return immediately with `{"queued": true}`
- `spawn_daemon` cleans up stale socket if daemon not alive before spawning
- Subscribe after other commands returns error `"subscribe must be the first command on a connection"`