# Ralph 24/7 Operations

This document is the operator playbook for the local Ralph swarm.

Current status on this machine:

- queue daemon is enabled
- Windows Scheduled Task `RalphInboxDaemon` is installed
- current runtime mode is `Codex enabled`
- Telegram notifications are supported through `ralph\config\telegram.local.json`

## What Ralph does

Ralph watches a Markdown inbox and turns each `.md` into:

1. a task pack
2. an isolated worktree
3. one implementer pass
4. multiple reviewer passes
5. optional Codex master review
6. optional fix pass
7. archived run artifacts

## Current default routing

- implementer: `opencode_glm5`
- reviewer 1: `opencode_qwen3coder_plus`
- reviewer 2: `opencode_glm47`
- Codex master: enabled as final gate

## Inbox workflow

Drop a task Markdown file here:

- `C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\ralph\tasks\inbox`

Or submit it through the helper:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Submit-RalphTask.ps1 `
  -SourceFile .\docs\YOUR_TASK.md
```

You can also submit raw text:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Submit-RalphTask.ps1 `
  -Text "# Task`n`nDo X, validate Y, report Z."
```

## Queue folders

- inbox: `ralph\tasks\inbox`
- processing: `ralph\tasks\processing`
- completed: `ralph\tasks\completed`
- failed: `ralph\tasks\failed`

## State and logs

Check live state:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Get-RalphStatus.ps1
```

Useful files:

- current daemon state: `ralph\state\inbox_daemon_state.json`
- current run state: `ralph\state\current_run.json`
- event log: `ralph\state\events.jsonl`
- background launcher state: `ralph\state\last_inbox_background.json`
- run artifacts: `ralph\runs\`
- background logs: `ralph\logs\`
- Telegram config: `ralph\config\telegram.local.json`

## Start and stop

Start daemon in background:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Start-RalphInboxBackground.ps1
```

Stop daemon:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Stop-RalphInboxDaemon.ps1
```

Send a Telegram smoke test:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Test-RalphTelegram.ps1
```

Install Scheduled Task:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Install-RalphScheduledTask.ps1
```

Remove Scheduled Task:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Uninstall-RalphScheduledTask.ps1
```

## Verify Codex master

Before trusting the full swarm, verify the local CLI:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Test-RalphCodex.ps1 -Full
```

Codex is only healthy if `full_ok = true`.

## What Codex is supposed to do

When available, Codex is not just another reviewer.

It is the final gate:

- it receives the task pack
- it reads the implementer diff and reviewer outputs
- it emits a structured JSON verdict
- the run only passes if Codex final verdict is `pass`

## If Codex ever degrades

If `Test-RalphCodex.ps1 -Full` starts failing again, stop the daemon and relaunch in degraded mode:

```powershell
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Stop-RalphInboxDaemon.ps1
powershell -ExecutionPolicy Bypass -File .\ralph\scripts\Start-RalphInboxBackground.ps1 -DisableCodexMaster
```
