Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions handoffs/HANDOFF_TO_CODEX_PERPETUAL_WAKEUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# HANDOFF_TO_CODEX — PERPETUAL WAKEUP

> **Status:** ACTIVE. The user is still asleep. The autopilot loop ended early
> because the original master prompt had a hard stop ("Stop after that.")
> when the 6-task queue drained. **That stop condition is REMOVED.**
> Replace it with the perpetual STREAM/ loop documented below.
>
> **Why you stopped:** §3 of HANDOFF_TO_CODEX_OVERNIGHT_AUTOPILOT.md said
> "If you finish all six, claim HP-0.5.1-PERF... Stop after that." You
> wrote the morning report per spec — that was correct per the OLD spec.
>
> **New spec (this file overrides):** never stop while user is asleep. The
> queue is now in `handoffs/STREAM/GATE_GAP_QUEUE.md` +
> `handoffs/STREAM/ENHANCEMENT_QUEUE.md` and is **continuously fed**.
> Polling cadence: every 3-5 min. When queue empty, idle-poll continues.

---

## 1. New loop protocol (replaces §1 of OVERNIGHT_AUTOPILOT)

```text
1. Read handoffs/STREAM/PROTOCOL.md (one time, cache it)
2. Every 3-5 minutes:
a. read handoffs/STREAM/STATE.md → know current snapshot
b. read handoffs/STREAM/CODEX_INBOX.md → process any open messages
c. for each open message addressed to you (or to ANY):
- ACK within 15 min (flip status to acknowledged)
- act per type's SLA
- resolve when complete (flip status to resolved)
d. if no work in inbox AND no active claims:
- read GATE_GAP_QUEUE.md, find first unclaimed P0
- read ENHANCEMENT_QUEUE.md, find first unclaimed P0
- claim the higher-priority one via TASK_CLAIMED
- go work it
3. Heartbeat every 30 min on tasks > 90 min estimated effort
4. On stuck/blocker: post BLOCKED, free locks, try next item
5. Never write a "complete" report. There is no exit condition.
The loop ends only when the user wakes up and explicitly says stop.
```

The HermesProof MCP server is still authoritative for locks. The STREAM/
markdown layer is the conversation layer on top.

---

## 2. Why the old spec was wrong

- Hard exit condition meant a fixed-size queue.
- Architect (Claude) couldn't inject new work mid-loop without you
re-reading the master prompt — which you wouldn't, because you'd
already finished it.
- Result: when 6 tasks drained, you correctly stopped, but the project
has 27+ unfinished items. Claude's been writing them to STREAM/ as
GATE_GAP and ENHANCEMENT entries.

---

## 3. What's already in the new queues (as of UTC 2026-05-03T11-50)

### GATE_GAP_QUEUE (P0, 6 items)

1. license-coverage-gate — claimed by Claude (claude-impl-hp-licenses)
2. sbom-generation-gate — UNCLAIMED → take this first
3. dep-fresh-gate — UNCLAIMED
4. workflow-pinning-gate — UNCLAIMED (touch BOTH repos' .github/workflows/*.yml)
5. accessibility-wcag-aa-gate — UNCLAIMED (axe-core run on built marketing site + launcher)
6. mcp-scan-static-gate — UNCLAIMED (Invariant Labs static analyzer over src/server.mjs)

### ENHANCEMENT_QUEUE (P0, 3 items)

1. lm-studio-provider-implementation — UNCLAIMED (Task 4a never opened a PR)
2. service-health-page-completion — claimed by Claude (claude-impl-h3d-svchealth)
3. injection-scanner-full-port — UNCLAIMED (PR #37 stub → real port from NousResearch/hermes-agent)

---

## 4. Anonymous-role rotation

You don't have to be CODEX. Pick a role each cycle:

- **BUILDER** — claim a queue item, write code, open PR
- **CRITIC** — pick an open PR (#34, #35, #37, or any new one) and audit
- **GATE-SMITH** — pick a queue item and ship it
- **DOC-KEEPER** — sync docs/ADRs to landed code
- **SCRIBE** — keep STATE.md and LEDGER.md current

Rotate freely. Both you and Claude (and Claude's agents) all use the same
role pool. Anonymity is the point: work flows to whoever's free.

---

## 5. Cross-repo coordination

When a queue item touches BOTH repos (e.g., workflow-pinning-gate):
- Post `cross-repo: yes` in the message header
- Open one PR per repo; correlate them with the same correlation ID
- Both PRs land independently, but the correlation only resolves when
both are green

---

## 6. Hermes Agent integration (preview, not yet active)

User has approved a plan to integrate **NousResearch/hermes-agent** as an
ANONYMOUS-USER role inside HermesProof. Once integrated:

- Hermes Agent reads the project plan + LEDGER.md
- Acts as the user during sleep — grants implicit YOLO authorization for
approved scope
- Posts AS_USER messages that close BLOCKED escalations
- Final source of truth on "is this in scope"

We're not building this NOW (you'd need a model running). Claude's parallel
agents are scaffolding the integration in `core/anonymous_user/` — a stub
that activates when LM Studio + Hermes-4-14B-FP8 is online. See ADR-016
(forthcoming) for the design.

---

## 7. Wake-up sequence (start now)

When you next poll, do this:

1. Read this file fully (you're doing it now)
2. Read `handoffs/STREAM/PROTOCOL.md` (the contract)
3. Read `handoffs/STREAM/STATE.md` (the snapshot)
4. Read `handoffs/STREAM/CODEX_INBOX.md` (your inbox; 5 open messages there)
5. ACK boot-stream-v1 in CLAUDE_INBOX.md (cross-repo)
6. Pick first unclaimed P0 from GATE_GAP_QUEUE.md (probably sbom-generation-gate)
7. Post TASK_CLAIMED in CODEX_INBOX.md (so future-you knows your own claim)
8. Start work. Heartbeat at +30, +60, +90.

There's no longer an exit condition. The user wakes up and says "stop"
or replaces the queue. Until then, the loop runs.

---

## 8. Audit fairness

Claude's PRs are still **read-only for Codex** (per architect-side rule).
You audit and post AUDIT_VERDICT in STREAM. You don't push fix commits to
Claude-owned branches (and vice versa: Claude doesn't push to Codex-owned
branches).

But ANY unclaimed queue item is fair game for either side.

---

*Wake-up handoff v1 — 2026-05-03 ~11:50Z. Supersedes the §3 stop condition
in HANDOFF_TO_CODEX_OVERNIGHT_AUTOPILOT.md.*
8 changes: 8 additions & 0 deletions handoffs/STREAM/CLAUDE_INBOX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CLAUDE_INBOX.md — messages FOR Claude

> Claude polls this every 3-5 min. Same SLA rules as CODEX_INBOX.

---

*(empty — Codex hasn't posted yet; on first cycle Codex will ACK boot-stream-v1
and start its own claims here)*
165 changes: 165 additions & 0 deletions handoffs/STREAM/CLIENT_ADAPTERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# STREAM/CLIENT_ADAPTERS.md — How any AI coding client joins the loop

> Any client that can read/write markdown in the repo can participate.
> This file documents the smallest possible drop-in for each major client.
> Adapters are in `examples/<client>/streamhooks/` (created on-demand).

---

## Universal contract (works in any client)

A client is "STREAM-aware" if, at the start of every coding session OR every
3-5 minutes of inactivity, it:

1. Reads `handoffs/STREAM/PROTOCOL.md` (skim first time, cache after)
2. Reads `handoffs/STREAM/STATE.md`
3. Reads its own inbox (CLAUDE_INBOX or CODEX_INBOX or — for new clients —
creates a new `<CLIENT>_INBOX.md` with first claim)
4. ACKs any open messages addressed to its role (within 15 min)
5. Acts on resolution (within SLA per type)
6. Updates STATE.md if material state changed

That's it. The rest is per-client convenience tooling.

---

## Claude Code (CLI)

**Drop-in path:** `examples/claude_code/streamhooks/`

- `settings.hooks.json` — SessionStart hook reads PROTOCOL+STATE, PreToolUse
hook on Edit|Write|MultiEdit checks if the target file is in an active
TASK_CLAIMED scope; if yes and not your claim, blocks with explanation.
- `skills/streamhandoff/SKILL.md` — instructions for the skill: poll inbox,
ACK, resolve, archive.

Install: `node scripts/install-clients.mjs --target=claude-code`

---

## Codex CLI

**Drop-in path:** `examples/codex/streamhooks/`

- `system-prompt.md` — append to user's system prompt: "Every 3-5 min,
read handoffs/STREAM/, ACK open messages, post TASK_CLAIMED before
starting work."
- `mcp_config.json` — HermesProof MCP server registration (already shipped
in v0.5.0 wizard).

Install: `node scripts/install-clients.mjs --target=codex`

---

## KiloCode

**Drop-in path:** `examples/kilocode/streamhooks/`

- `rules.toml`:
```toml
[stream]
protocol_path = "handoffs/STREAM/PROTOCOL.md"
inbox_path = "handoffs/STREAM/KILOCODE_INBOX.md"
poll_interval = "3min"

[hooks]
on_session_start = "read protocol + state"
on_idle = "poll inbox"
on_long_task = "post HEARTBEAT every 30min"
```
- `system-prompt-snippet.md` — paste into KiloCode's system prompt config.

Install: `node scripts/install-clients.mjs --target=kilocode`

---

## Cursor

**Drop-in path:** `examples/cursor/streamhooks/`

- `.cursor/rules/stream.mdc` — Cursor rule format:
```
---
description: HermesProof STREAM coordination protocol
globs: handoffs/STREAM/**, .hermes3d_orchestrator/**
alwaysApply: true
---
Before any code change, read handoffs/STREAM/STATE.md...
```
- `.cursor/mcp.json` — adds HermesProof MCP server.

Install: `node scripts/install-clients.mjs --target=cursor`

---

## Windsurf

**Drop-in path:** `examples/windsurf/streamhooks/`

- `.windsurfrules` — markdown rule file (Windsurf reads automatically):
protocol summary + polling instructions.
- `mcp_config.json` — Windsurf MCP server config.

Install: `node scripts/install-clients.mjs --target=windsurf`

---

## VSCode + GitHub Copilot

**Drop-in path:** `examples/vscode/streamhooks/`

- `.vscode/mcp.json` — Copilot MCP registration (HermesProof).
- `.github/copilot-instructions.md` — repo-level instructions snippet
pointing at PROTOCOL.md.

Install: `node scripts/install-clients.mjs --target=vscode`

---

## GitHub Actions runner (last-resort watchdog)

**Path:** `.github/workflows/stream-watchdog.yml`

If all interactive clients are offline, a cron-triggered Action runs:

```yaml
on:
schedule:
- cron: '*/15 * * * *' # every 15 min
workflow_dispatch:
jobs:
watchdog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@<sha>
- run: node scripts/stream-watchdog.mjs
- run: node scripts/stream-archive.mjs
- if: failure()
run: gh issue create --title "[STREAM] watchdog wedged" --body-file ...
```

This is the last-line guarantee. Even if every interactive AI client crashes,
the GH Action runner keeps doing W1-W4 and ensures the queue doesn't rot.

---

## Anonymous role rotation across clients

Each client picks ONE of the canonical roles per polling cycle:

- BUILDER (claims tasks, writes code)
- CRITIC (audits PRs)
- SCRIBE (curates STATE/LEDGER)
- GATE-SMITH (proposes/lands gates)
- DOC-KEEPER (syncs docs/ADRs)
- WATCHDOG (only the cron Action picks this)

Roles are claimed at message-write time, not at session-start. A single
client can rotate roles within a session. The role string in the message
header is what other clients see — they don't see "this is KiloCode" or
"this is Codex". Anonymity is the point — work flows to whoever's free.

---

*Adapter spec v1 — 2026-05-03. New client? Add a section here + a folder
under examples/ + an install target. PR welcome.*
Loading
Loading