---
name: coo-escalate
description: Sends Telegram escalation to Rocky for blocked actions, low-confidence classifications, failure-mode triggers, or greylist confirmations.
agent: hermes-coo
type: programmatic
context_files:
  - HQ-Vault/_System/COO/state.json
  - HQ-Vault/_System/COO/Outbox.md
---

# coo-escalate skill

## Purpose

Single point of "Rocky must see this" delivery. Centralises Telegram formatting, dedup-guard, retry, fallback to vault-only if Telegram down.

Called by `coo-classify` (for safety blocks), `coo-dispatch` (for greylist), `coo-pulse` (for failure-mode triggers), and `coo-inbox-poll` (for unparseable REQs).

## Input

```yaml
type: blocked | greylist | failure-mode | low-confidence | wins
priority: P0 | P1 | P2
title: <one-line>
body: <full context — file paths, REQ ids, decision needed>
require_reply: bool
reply_timeout_min: 5  # only if require_reply=true
```

## Behaviour

### Step 1 — dedup

Compute hash(`type + title + first 200 chars of body`). If same hash escalated in last 2 hours (from `state.json.recent_escalations[]`), skip (return "duplicate, suppressed").

This prevents the "30 identical alerts every minute" failure mode that killed the hibernated-fleet Sentinel/Cog combo.

### Step 2 — format

Telegram message format:

```
{emoji} {type-upper} — {title}

{body, capped at 800 chars; if longer, truncate + append "see Outbox.md for full"}

Priority: {P0|P1|P2}
{if require_reply}
👉 Reply Y / N within {timeout} min, or default = no-action.
{/if}
```

Emoji map:
- blocked → 🚫
- greylist → 🟡
- failure-mode → 🔥
- low-confidence → 🤔
- wins → 🎉

### Step 3 — write to Outbox.md

Append to appropriate section:
- blocked → `## Blocked actions`
- greylist → (handled by `coo-dispatch`, not here)
- failure-mode → `## Surfaced findings`
- low-confidence → `## Decisions needed`
- wins → `## Wins`

With timestamp + same body as Telegram.

### Step 4 — send Telegram

Per `state.json.telegram_chat_id` (currently `7377499346`), bot per `state.json.telegram_bot_handle` (`@hq_coo_bot` once created; until then, fall back to `@opsman_lfcs_bot`).

```bash
hermes --profile coo send telegram --to {chat_id} --message "{formatted}"
```

If Telegram send fails (network, bot offline):
- Log to `dispatch-log.ndjson` with `result: warn`
- Append to `state.json.deferred_escalations[]` with retry-after timestamp
- Next `coo-inbox-poll` tick attempts retry

### Step 5 — if `require_reply` true

Open a reply-listener:

```bash
hermes --profile coo telegram listen --reply-to {message_id} --timeout {timeout_min}m
```

On reply:
- `Y` / `yes` / `proceed` / `do it` → return `{approved: true}`
- `N` / `no` / `cancel` / `decline` → return `{approved: false, reason: "rocky-declined"}`
- Other → escalate again with "unparseable reply: {text}, please reply Y or N"
- Timeout → return `{approved: false, reason: "timeout-no-reply"}`

### Step 6 — log

```json
{"ts":"...","agent":"hermes-coo","action":"escalate","target":"{title}","result":"ok|suppressed|failed","notes":"type={type}, priority={P0|P1|P2}, telegram_msg_id={...}, reply={approved|declined|timeout|none}"}
```

Append to `state.json.recent_escalations[]` (rolling 24h window, prune older entries).

## Priority guidance

- **P0** — production-down, money-losing, security-leaking. Send Telegram immediately regardless of time of day. Page through, no dedup-window. Example: "Marketplace Supabase deleted, signups silently failing."
- **P1** — important but not bleeding. Standard escalation. Default dedup (2h).
- **P2** — FYI surface, batched into next pulse if not already there. Don't disturb out-of-hours.

Heuristic: P0 if money or safety at stake. P1 if a goal is blocked. P2 if "Rocky should know about this eventually."

## Failure modes

- **Telegram bot offline** — defer with retry. Continue Outbox write. Surface "Telegram delivery deferred" in next pulse.
- **Out of hours + non-P0** — defer to next pulse rather than buzz at 3am.
- **Same escalation 5+ times in 24h** — auto-escalate to P0 (something's stuck in a loop). Send "RECURRING ESCALATION — investigate root cause."

## What good looks like

Rocky reads escalation once, knows priority, knows what to do, doesn't get spammed by duplicates. P0s reach him within 60 seconds of trigger.
