From c810d9df9f833ebfc5ab898395b4c99eff2bc8ba Mon Sep 17 00:00:00 2001 From: Jordan Newell <58616955+JordanNewell@users.noreply.github.com> Date: Sat, 28 Nov 2026 09:46:09 -0500 Subject: [PATCH] chore: format markdown per org prettier gate --- README.md | 10 ++-- cabinet-lite/architecture.md | 30 ++++++------ cabinet-lite/configuration.md | 74 ++++++++++++++--------------- cabinet-lite/getting-started.md | 28 +++++------ cabinet-lite/intro.md | 12 ++--- cabinet-lite/lever-tiles.md | 10 ++-- cabinet-lite/pull-feed.md | 24 +++++----- cabinet-lite/troubleshooting.md | 12 ++--- fleet-bridge/clients/generic-mcp.md | 10 ++-- fleet-bridge/configuration.md | 54 ++++++++++----------- fleet-bridge/getting-started.md | 10 ++-- fleet-bridge/tools/agent-health.md | 21 ++++---- fleet-bridge/tools/hermes.md | 35 +++++++++----- fleet-bridge/tools/index.md | 16 +++---- fleet-bridge/tools/invoke-agent.md | 56 +++++++++++++++------- fleet-bridge/tools/list-agents.md | 7 ++- fleet-bridge/tools/start-session.md | 15 ++++-- fleet-bridge/troubleshooting.md | 2 +- tractum/concepts/consensus.md | 18 +++---- tractum/concepts/receipts.md | 32 ++++++------- tractum/self-hosting.md | 40 ++++++++-------- tractum/verification.md | 4 +- wranglebot/daemon.md | 14 +++--- wranglebot/getting-started.md | 4 +- wranglebot/guardrails.md | 26 +++++----- wranglebot/hooks.md | 16 ++++--- wranglebot/intro.md | 10 ++-- wranglebot/loop-breaking.md | 20 ++++---- wranglebot/reference/cli.md | 30 ++++++------ wranglebot/reference/exit-codes.md | 14 +++--- 30 files changed, 352 insertions(+), 302 deletions(-) diff --git a/README.md b/README.md index 48a2978..e8b5f39 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Documentation site for the Leverframe agent-infrastructure stack. Sections: -| Section | Product | Repo | -|---|---|---| -| `/fleet-bridge` | fleet-bridge — bridge OpenClaw/Hermes agents to any MCP client | [leverframe/fleet-bridge](https://github.com/leverframe/fleet-bridge) | -| `/wranglebot` | wranglebot — deterministic guardrails, loop-breaking, .curt emission | [leverframe/wranglebot](https://github.com/leverframe/wranglebot) | -| `/tractum` | tractum — verifiable multi-agent consensus with cryptographic receipts | [leverframe/tractum](https://github.com/leverframe/tractum) | +| Section | Product | Repo | +| --------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------- | +| `/fleet-bridge` | fleet-bridge — bridge OpenClaw/Hermes agents to any MCP client | [leverframe/fleet-bridge](https://github.com/leverframe/fleet-bridge) | +| `/wranglebot` | wranglebot — deterministic guardrails, loop-breaking, .curt emission | [leverframe/wranglebot](https://github.com/leverframe/wranglebot) | +| `/tractum` | tractum — verifiable multi-agent consensus with cryptographic receipts | [leverframe/tractum](https://github.com/leverframe/tractum) | ## Local development diff --git a/cabinet-lite/architecture.md b/cabinet-lite/architecture.md index eacc181..d008bcf 100644 --- a/cabinet-lite/architecture.md +++ b/cabinet-lite/architecture.md @@ -12,27 +12,27 @@ cabinet-lite is one Node (>= 24, ESM) process. TypeScript compiles to `dist/` (`tsc`, `module: nodenext`, strict). No framework, no dependencies at runtime — `node:http`, `node:fs`, and `fetch` only. -| Module | Role | -|---|---| -| `index.ts` | entrypoint: starts the server, logs the listen line, handles SIGINT/SIGTERM via `instance.stop()` | -| `server.ts` | HTTP server, snapshot assembly, SSE broadcast, plate refresh loop | -| `fleet.ts` | roster loading, health polling, transition detection | -| `plates.ts` | plate fetchers (`fetchCabinetTasks`, `fetchFleetHealth`) and their types | -| `feed.ts` | in-memory ring buffer (`Feed`, cap 500, newest first) | -| `ui/index.html` | static shell: all CSS inline, no build step | -| `ui/app.js` | browser client: SSE listener + renderers | +| Module | Role | +| --------------- | ------------------------------------------------------------------------------------------------- | +| `index.ts` | entrypoint: starts the server, logs the listen line, handles SIGINT/SIGTERM via `instance.stop()` | +| `server.ts` | HTTP server, snapshot assembly, SSE broadcast, plate refresh loop | +| `fleet.ts` | roster loading, health polling, transition detection | +| `plates.ts` | plate fetchers (`fetchCabinetTasks`, `fetchFleetHealth`) and their types | +| `feed.ts` | in-memory ring buffer (`Feed`, cap 500, newest first) | +| `ui/index.html` | static shell: all CSS inline, no build step | +| `ui/app.js` | browser client: SSE listener + renderers | ## HTTP surface Exactly four routes, served by a plain `http.createServer` handler. Everything else is `404 not found`. -| Route | Method | Meaning | -|---|---|---| -| `/` | GET | `ui/index.html` | -| `/ui/app.js` | GET | `ui/app.js` | -| `/api/snapshot` | GET | full snapshot as JSON | -| `/api/stream` | GET | SSE; each event is `event: snapshot` with the full snapshot as data | +| Route | Method | Meaning | +| --------------- | ------ | ------------------------------------------------------------------- | +| `/` | GET | `ui/index.html` | +| `/ui/app.js` | GET | `ui/app.js` | +| `/api/snapshot` | GET | full snapshot as JSON | +| `/api/stream` | GET | SSE; each event is `event: snapshot` with the full snapshot as data | The server listens on `127.0.0.1` only. There are no POST/PUT/DELETE handlers anywhere in v1 — read-only by absence. diff --git a/cabinet-lite/configuration.md b/cabinet-lite/configuration.md index 93c63d3..bc778bc 100644 --- a/cabinet-lite/configuration.md +++ b/cabinet-lite/configuration.md @@ -11,14 +11,14 @@ roster files. It has no config file of its own. ## Environment variables -| Var | Default | Meaning | -|---|---|---| -| `FLEET_BRIDGE_AGENTS` | (unset) | path to the OpenClaw roster JSON | -| `FLEET_BRIDGE_HERMES` | (unset) | path to the Hermes roster JSON | -| `FLEET_BRIDGE_GENERIC` | (unset) | path to the generic-runtime roster JSON | -| `CABINET_URL` | (unset) | Cabinet base URL, read-only; unset degrades the `needs_you` plate | -| `FLEET_HEALTH_URL` | (unset) | fleet-health aggregate base URL; unset degrades the `fleet_health` plate | -| `PORT` | `9100` | listen port (read once at startup) | +| Var | Default | Meaning | +| ---------------------- | ------- | ------------------------------------------------------------------------ | +| `FLEET_BRIDGE_AGENTS` | (unset) | path to the OpenClaw roster JSON | +| `FLEET_BRIDGE_HERMES` | (unset) | path to the Hermes roster JSON | +| `FLEET_BRIDGE_GENERIC` | (unset) | path to the generic-runtime roster JSON | +| `CABINET_URL` | (unset) | Cabinet base URL, read-only; unset degrades the `needs_you` plate | +| `FLEET_HEALTH_URL` | (unset) | fleet-health aggregate base URL; unset degrades the `fleet_health` plate | +| `PORT` | `9100` | listen port (read once at startup) | All roster paths are read at startup into memory; the files are re-read only on process restart. URLs accept any base the Node `fetch` can reach @@ -54,17 +54,17 @@ fleet-bridge's `agents.json` / `hermes-agents.json`. } ``` -| Field | Required | Meaning | -|---|---|---| -| `name` | yes | agent name — key for health lookups and feed entries | -| `role` | yes | one-line role, shown on the lever tile | -| `tier` | no | fleet tier (e.g. `worker`) | -| `model` | no | model the agent runs | -| `host` | yes | hostname reachable from the box | -| `port` | yes | gateway port — polled at the health path | -| `token` | yes | gateway token; never leaves the box (v2 use) | -| `runtime` | no | display label; defaults to `openclaw` | -| `healthPath` | no | probe path; defaults to `/health` | +| Field | Required | Meaning | +| ------------ | -------- | ---------------------------------------------------- | +| `name` | yes | agent name — key for health lookups and feed entries | +| `role` | yes | one-line role, shown on the lever tile | +| `tier` | no | fleet tier (e.g. `worker`) | +| `model` | no | model the agent runs | +| `host` | yes | hostname reachable from the box | +| `port` | yes | gateway port — polled at the health path | +| `token` | yes | gateway token; never leaves the box (v2 use) | +| `runtime` | no | display label; defaults to `openclaw` | +| `healthPath` | no | probe path; defaults to `/health` | ### Hermes roster (`FLEET_BRIDGE_HERMES`) @@ -83,15 +83,15 @@ fleet-bridge's `agents.json` / `hermes-agents.json`. } ``` -| Field | Required | Meaning | -|---|---|---| -| `name` | yes | agent name | -| `role` | yes | one-line role, shown on the lever tile | -| `model` | no | model the agent runs | -| `host` | yes | host the agent lives on | -| `ssh_user` | yes | SSH user for Hermes invocations (v2) | -| `binary` | yes | Hermes binary path/name on the host (v2) | -| `runtime` | no | display label; defaults to `hermes` | +| Field | Required | Meaning | +| ---------- | -------- | ---------------------------------------- | +| `name` | yes | agent name | +| `role` | yes | one-line role, shown on the lever tile | +| `model` | no | model the agent runs | +| `host` | yes | host the agent lives on | +| `ssh_user` | yes | SSH user for Hermes invocations (v2) | +| `binary` | yes | Hermes binary path/name on the host (v2) | +| `runtime` | no | display label; defaults to `hermes` | Hermes entries are not polled in v1 — they render static `idle` tiles and report `"ssh"` status in the snapshot. @@ -125,16 +125,16 @@ entries (same timeout, stagger, cache, live-down transitions) at their own } ``` -| Field | Required | Meaning | -|---|---|---| -| `name` | yes | agent name | -| `role` | yes | one-line role, shown on the lever tile | -| `host` | yes | hostname reachable from the box | -| `port` | yes | port on the host | +| Field | Required | Meaning | +| ------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| `name` | yes | agent name | +| `role` | yes | one-line role, shown on the lever tile | +| `host` | yes | hostname reachable from the box | +| `port` | yes | port on the host | | `healthPath` | yes in practice | probe path; omitting polls `/health`. Must return JSON (e.g. an object with `ok: true`) — text endpoints render the tile `down` | -| `runtime` | no | display label; defaults to `openclaw` | -| `model` | no | model the agent runs | -| `token` | no | optional gateway token (never leaves the box) | +| `runtime` | no | display label; defaults to `openclaw` | +| `model` | no | model the agent runs | +| `token` | no | optional gateway token (never leaves the box) | Entries without `runtime` default by file: OpenClaw and generic lines to `openclaw`, Hermes lines to `hermes`. The UI badge map styles diff --git a/cabinet-lite/getting-started.md b/cabinet-lite/getting-started.md index 57b6b62..8e4f6cb 100644 --- a/cabinet-lite/getting-started.md +++ b/cabinet-lite/getting-started.md @@ -26,23 +26,23 @@ npm start `package.json` scripts: -| Script | Command | Meaning | -|---|---|---| -| `build` | `tsc` | compile TypeScript to `dist/` | -| `start` | `node dist/index.js` | run the box | -| `dev` | `tsc --watch` | rebuild on change | -| `test` | build + `node --test "dist/test/*.test.js"` | run the test suite | +| Script | Command | Meaning | +| ------- | ------------------------------------------- | ----------------------------- | +| `build` | `tsc` | compile TypeScript to `dist/` | +| `start` | `node dist/index.js` | run the box | +| `dev` | `tsc --watch` | rebuild on change | +| `test` | build + `node --test "dist/test/*.test.js"` | run the test suite | ## Environment variables -| Var | Required | Default | Meaning | -|---|---|---|---| -| `FLEET_BRIDGE_AGENTS` | yes (for OpenClaw agents) | unset | path to the OpenClaw roster JSON | -| `FLEET_BRIDGE_HERMES` | yes (for Hermes agents) | unset | path to the Hermes roster JSON | -| `FLEET_BRIDGE_GENERIC` | no | unset | path to the generic-runtime roster JSON | -| `CABINET_URL` | no | unset | Cabinet base URL, consumed read-only; unset = `needs_you` plate degrades | -| `FLEET_HEALTH_URL` | no | unset | fleet-health aggregate base URL; unset = `fleet_health` plate degrades | -| `PORT` | no | `9100` | listen port | +| Var | Required | Default | Meaning | +| ---------------------- | ------------------------- | ------- | ------------------------------------------------------------------------ | +| `FLEET_BRIDGE_AGENTS` | yes (for OpenClaw agents) | unset | path to the OpenClaw roster JSON | +| `FLEET_BRIDGE_HERMES` | yes (for Hermes agents) | unset | path to the Hermes roster JSON | +| `FLEET_BRIDGE_GENERIC` | no | unset | path to the generic-runtime roster JSON | +| `CABINET_URL` | no | unset | Cabinet base URL, consumed read-only; unset = `needs_you` plate degrades | +| `FLEET_HEALTH_URL` | no | unset | fleet-health aggregate base URL; unset = `fleet_health` plate degrades | +| `PORT` | no | `9100` | listen port | Notes: diff --git a/cabinet-lite/intro.md b/cabinet-lite/intro.md index 63df0f9..d28679d 100644 --- a/cabinet-lite/intro.md +++ b/cabinet-lite/intro.md @@ -20,12 +20,12 @@ write path. The box is organized around four questions: -| Question | Surface | Status in v1 | -|---|---|---| -| What needs me? | The `needs_you` plate (attention banner) | live | -| Who's free? | Lever tiles with live/down/idle states | live | -| What happened? | The pull feed with runtime provenance | live | -| Act from here? | The invoke panel | wired, GO-gated OFF | +| Question | Surface | Status in v1 | +| -------------- | ---------------------------------------- | ------------------- | +| What needs me? | The `needs_you` plate (attention banner) | live | +| Who's free? | Lever tiles with live/down/idle states | live | +| What happened? | The pull feed with runtime provenance | live | +| Act from here? | The invoke panel | wired, GO-gated OFF | See [plates](./plates.md), [lever tiles](./lever-tiles.md), the [pull feed](./pull-feed.md), and the [invoke panel](./invoke-panel.md). diff --git a/cabinet-lite/lever-tiles.md b/cabinet-lite/lever-tiles.md index 4fb809d..b8144d1 100644 --- a/cabinet-lite/lever-tiles.md +++ b/cabinet-lite/lever-tiles.md @@ -14,11 +14,11 @@ name, its role, a lever slot graphic, and a runtime tag. The state dot in the tile's top-right corner is driven by the health cache: -| State | Dot | When | -|---|---|---| -| `live` | solid green (`#00C853`) | health result has no `error` and `ok` is true | -| `down` | red (`#E5484D`) plus a red-tinted tile border | health result carries an `error` (probe failed, timed out, non-JSON) | -| `idle` | gray, 40 percent opacity | no health result yet, or the entry is not health-displayed (see below) | +| State | Dot | When | +| ------ | --------------------------------------------- | ---------------------------------------------------------------------- | +| `live` | solid green (`#00C853`) | health result has no `error` and `ok` is true | +| `down` | red (`#E5484D`) plus a red-tinted tile border | health result carries an `error` (probe failed, timed out, non-JSON) | +| `idle` | gray, 40 percent opacity | no health result yet, or the entry is not health-displayed (see below) | Health semantics come from `fleet.ts`: each OpenClaw and generic entry is polled with HTTP GET at its `healthPath` (default `/health`), 5 s timeout, diff --git a/cabinet-lite/pull-feed.md b/cabinet-lite/pull-feed.md index a6e8bd8..5b71393 100644 --- a/cabinet-lite/pull-feed.md +++ b/cabinet-lite/pull-feed.md @@ -11,14 +11,14 @@ sidebar_position: 6 The feed is the "what happened" journal. Each entry (`FeedEntry` in `feed.ts`) carries: -| Field | Meaning | -|---|---| -| `ts` | timestamp, stamped by the server at insertion | +| Field | Meaning | +| --------- | ----------------------------------------------------------------------------------- | +| `ts` | timestamp, stamped by the server at insertion | | `runtime` | provenance label — `openclaw` / `hermes` / `mcp` today, any roster label in general | -| `agent` | agent name | -| `summary` | one-line description | -| `ms` | latency in milliseconds (`0` renders as an em dash) | -| `ok` | success flag | +| `agent` | agent name | +| `summary` | one-line description | +| `ms` | latency in milliseconds (`0` renders as an em dash) | +| `ok` | success flag | Storage is an in-memory ring buffer capped at 500 entries, newest first. Restarts reset the feed — it is a journal, not a store. @@ -35,11 +35,11 @@ carries runtime provenance. Each row renders a badge after the agent name: -| Label | Badge style | -|---|---| -| `openclaw` | amber (`b-oc`) | -| `hermes` | steel (`b-he`) | -| `mcp` | muted gray (`b-mcp`) | +| Label | Badge style | +| ------------- | ----------------------------------------------------------------------------------------------------------------- | +| `openclaw` | amber (`b-oc`) | +| `hermes` | steel (`b-he`) | +| `mcp` | muted gray (`b-mcp`) | | anything else | generic steel badge (`b-x`) with the label uppercased — e.g. a generic roster entry labeled `khoj` renders `KHOJ` | The RUNTIMES side-rail in the sidebar counts every distinct label across diff --git a/cabinet-lite/troubleshooting.md b/cabinet-lite/troubleshooting.md index 10f318b..09c2eb4 100644 --- a/cabinet-lite/troubleshooting.md +++ b/cabinet-lite/troubleshooting.md @@ -11,13 +11,13 @@ sidebar_position: 10 The `needs_you` and `fleet_health` plates degrade to a bordered error slot rather than crashing. The error strings in the slot map to causes: -| Error text | Cause | Fix | -|---|---|---| -| `CABINET_URL not configured` / `FLEET_HEALTH_URL not configured` | env var unset | set the URL and restart (URLs are read at startup) | -| `HTTP ` | backend answered non-2xx | check the backend's own health and auth | +| Error text | Cause | Fix | +| ---------------------------------------------------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------- | +| `CABINET_URL not configured` / `FLEET_HEALTH_URL not configured` | env var unset | set the URL and restart (URLs are read at startup) | +| `HTTP ` | backend answered non-2xx | check the backend's own health and auth | | `unexpected /api/tasks shape` / `unexpected /fleet-health shape` | backend returned JSON that does not match the plate schema | verify the backend version; the plate trusts nothing it cannot validate | -| timeout message | backend slower than the 5 s abort timeout | check network path or backend latency | -| DNS / ECONNREFUSED text | backend unreachable | check host, port, and routing from the box host | +| timeout message | backend slower than the 5 s abort timeout | check network path or backend latency | +| DNS / ECONNREFUSED text | backend unreachable | check host, port, and routing from the box host | Degraded plates retry every 30 s and recover on their own — no restart needed once the backend is healthy again. Before the first completed poll diff --git a/fleet-bridge/clients/generic-mcp.md b/fleet-bridge/clients/generic-mcp.md index acf822b..22f4227 100644 --- a/fleet-bridge/clients/generic-mcp.md +++ b/fleet-bridge/clients/generic-mcp.md @@ -16,11 +16,11 @@ client that can spawn a subprocess and speak stdio MCP can use it. Virtually every stdio MCP client uses the same three fields: -| Field | Value | -|---|---| -| `command` | `node` (or `npx`) | -| `args` | absolute path to `dist/index.js` (the built server) | -| `env` | optional: `FLEET_BRIDGE_AGENTS`, `FLEET_BRIDGE_HERMES`, timeout overrides | +| Field | Value | +| --------- | ------------------------------------------------------------------------- | +| `command` | `node` (or `npx`) | +| `args` | absolute path to `dist/index.js` (the built server) | +| `env` | optional: `FLEET_BRIDGE_AGENTS`, `FLEET_BRIDGE_HERMES`, timeout overrides | ```json { diff --git a/fleet-bridge/configuration.md b/fleet-bridge/configuration.md index 71d1c04..32c4399 100644 --- a/fleet-bridge/configuration.md +++ b/fleet-bridge/configuration.md @@ -15,10 +15,10 @@ environment variables. No CLI flags, no config wizard. At startup the bridge reads both rosters once, at module load: -| File | Contents | Path source | -|---|---|---| -| `agents.json` | OpenClaw agents (HTTP gateway) | `FLEET_BRIDGE_AGENTS`, default `/agents.json` | -| `hermes-agents.json` | Hermes agents (SSH + CLI) | `FLEET_BRIDGE_HERMES`, default `/hermes-agents.json` | +| File | Contents | Path source | +| -------------------- | ------------------------------ | -------------------------------------------------------------- | +| `agents.json` | OpenClaw agents (HTTP gateway) | `FLEET_BRIDGE_AGENTS`, default `/agents.json` | +| `hermes-agents.json` | Hermes agents (SSH + CLI) | `FLEET_BRIDGE_HERMES`, default `/hermes-agents.json` | Both files use the same top-level shape: `{"agents": [ ... ]}` — one array entry per agent. @@ -53,15 +53,15 @@ files `chmod 600`; they are gitignored and contain secrets. } ``` -| Field | Type | Required | Notes | -|---|---|---|---| -| `name` | string | yes | Unique. The value clients pass to `invoke_agent`, `agent_health`, and `start_session`. | -| `role` | string | yes | Free text, shown in `list_agents` output. | -| `tier` | string | no | Your own metadata (e.g. `pro`, `free`). Pass-through only; the bridge never reads it. | -| `model` | string | no | Model name sent in the chat-completions body. Defaults to `openclaw` when omitted, which is what OpenClaw gateways expect. Set a real model name to target any OpenAI-compatible gateway. | -| `port` | number | yes | Gateway port. The bridge calls `http://{host}:{port}/health` and `/v1/chat/completions`. | -| `host` | string | yes | IP or hostname of the gateway. | -| `token` | string | yes | Gateway auth token, sent as `Authorization: Bearer {token}`. | +| Field | Type | Required | Notes | +| ------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `name` | string | yes | Unique. The value clients pass to `invoke_agent`, `agent_health`, and `start_session`. | +| `role` | string | yes | Free text, shown in `list_agents` output. | +| `tier` | string | no | Your own metadata (e.g. `pro`, `free`). Pass-through only; the bridge never reads it. | +| `model` | string | no | Model name sent in the chat-completions body. Defaults to `openclaw` when omitted, which is what OpenClaw gateways expect. Set a real model name to target any OpenAI-compatible gateway. | +| `port` | number | yes | Gateway port. The bridge calls `http://{host}:{port}/health` and `/v1/chat/completions`. | +| `host` | string | yes | IP or hostname of the gateway. | +| `token` | string | yes | Gateway auth token, sent as `Authorization: Bearer {token}`. | `token` is a secret. It is stripped from `list_agents` output and never appears in any tool result. Never commit the file, never paste real tokens @@ -84,14 +84,14 @@ into examples or issues. } ``` -| Field | Type | Required | Notes | -|---|---|---|---| -| `name` | string | yes | Unique. Passed to `invoke_hermes` and `list_hermes_agents`. | -| `role` | string | yes | Free text, shown in `list_hermes_agents` output. | -| `model` | string | no | Display metadata only; the bridge never reads it. | -| `host` | string | yes | Host the bridge SSHes into. | -| `ssh_user` | string | yes | Remote SSH user. Key-based auth must already work (`BatchMode=yes` — no password prompts). | -| `binary` | string | yes | Absolute path to the Hermes CLI on the remote host. Invoked as `ssh {ssh_user}@{host} {binary} -z ''`. | +| Field | Type | Required | Notes | +| ---------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------- | +| `name` | string | yes | Unique. Passed to `invoke_hermes` and `list_hermes_agents`. | +| `role` | string | yes | Free text, shown in `list_hermes_agents` output. | +| `model` | string | no | Display metadata only; the bridge never reads it. | +| `host` | string | yes | Host the bridge SSHes into. | +| `ssh_user` | string | yes | Remote SSH user. Key-based auth must already work (`BatchMode=yes` — no password prompts). | +| `binary` | string | yes | Absolute path to the Hermes CLI on the remote host. Invoked as `ssh {ssh_user}@{host} {binary} -z ''`. | `ssh_user` and `binary` are stripped from `list_hermes_agents` output (they leak your infra layout to anyone with client access). `model` is displayed. @@ -153,12 +153,12 @@ root as skeletons. ## Environment variables -| Variable | Default | Purpose | -|---|---|---| -| `FLEET_BRIDGE_AGENTS` | `/agents.json` | Path to the OpenClaw roster. | -| `FLEET_BRIDGE_HERMES` | `/hermes-agents.json` | Path to the Hermes roster. | -| `FLEET_BRIDGE_HEALTH_TIMEOUT_MS` | `5000` | Abort timeout for `agent_health` HTTP calls. | -| `FLEET_BRIDGE_INVOKE_TIMEOUT_MS` | `60000` | Default timeout for `invoke_agent` / `invoke_hermes` when the call omits `timeout_ms`. | +| Variable | Default | Purpose | +| -------------------------------- | ------------------------------- | -------------------------------------------------------------------------------------- | +| `FLEET_BRIDGE_AGENTS` | `/agents.json` | Path to the OpenClaw roster. | +| `FLEET_BRIDGE_HERMES` | `/hermes-agents.json` | Path to the Hermes roster. | +| `FLEET_BRIDGE_HEALTH_TIMEOUT_MS` | `5000` | Abort timeout for `agent_health` HTTP calls. | +| `FLEET_BRIDGE_INVOKE_TIMEOUT_MS` | `60000` | Default timeout for `invoke_agent` / `invoke_hermes` when the call omits `timeout_ms`. | Non-numeric or non-positive values for the two timeout variables fall back silently to the default. A per-call `timeout_ms` tool argument overrides the diff --git a/fleet-bridge/getting-started.md b/fleet-bridge/getting-started.md index 67450c0..9090d36 100644 --- a/fleet-bridge/getting-started.md +++ b/fleet-bridge/getting-started.md @@ -29,11 +29,11 @@ npm run build # emits dist/index.js (tsc) `package.json` scripts: -| Script | Command | What it does | -|---|---|---| -| `build` | `tsc` | Compiles `index.ts` to `dist/index.js` | -| `start` | `node dist/index.js` | Runs the built server | -| `dev` | `tsx index.ts` | Runs the TypeScript source directly | +| Script | Command | What it does | +| ------- | -------------------- | -------------------------------------- | +| `build` | `tsc` | Compiles `index.ts` to `dist/index.js` | +| `start` | `node dist/index.js` | Runs the built server | +| `dev` | `tsx index.ts` | Runs the TypeScript source directly | The npm `bin` entry `fleet-bridge` (`bin/fleet-bridge.js`) is a two-line wrapper that imports `../dist/index.js` — build first, then `npx diff --git a/fleet-bridge/tools/agent-health.md b/fleet-bridge/tools/agent-health.md index 5c00973..94f0b2b 100644 --- a/fleet-bridge/tools/agent-health.md +++ b/fleet-bridge/tools/agent-health.md @@ -13,9 +13,9 @@ Check whether a specific fleet agent is healthy. Calls the agent gateway's ## Arguments -| Argument | Type | Required | Notes | -|---|---|---|---| -| `name` | string | yes | Agent name from `agents.json` | +| Argument | Type | Required | Notes | +| -------- | ------ | -------- | ----------------------------- | +| `name` | string | yes | Agent name from `agents.json` | ## Return value @@ -26,20 +26,25 @@ not transform it. ## Example call ```json -{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"agent_health","arguments":{"name":"researcher"}}} +{ + "jsonrpc": "2.0", + "id": 2, + "method": "tools/call", + "params": { "name": "agent_health", "arguments": { "name": "researcher" } } +} ``` Example result (gateway-specific): ```json -{"ok":true,"uptime":12345.6} +{ "ok": true, "uptime": 12345.6 } ``` ## Failure modes -| Error | Cause | -|---|---| -| `unknown agent: {name}` | Name not in `agents.json` | +| Error | Cause | +| -------------------------------------------------------- | ------------------------------------------------------------------------- | +| `unknown agent: {name}` | Name not in `agents.json` | | Abort/network error wrapped as `fleet-bridge error: ...` | Gateway unreachable, connection refused, or the call exceeded the timeout | The health call is bounded by an abort timeout controlled by diff --git a/fleet-bridge/tools/hermes.md b/fleet-bridge/tools/hermes.md index 043d1ff..b0c252f 100644 --- a/fleet-bridge/tools/hermes.md +++ b/fleet-bridge/tools/hermes.md @@ -51,11 +51,11 @@ context across calls. There is no session support for Hermes agents. ### Arguments -| Argument | Type | Required | Notes | -|---|---|---|---| -| `name` | string | yes | Hermes agent name from `hermes-agents.json` | -| `prompt` | string | yes | User message to send | -| `timeout_ms` | number | no | Timeout in milliseconds. Default: `60000`, or the `FLEET_BRIDGE_INVOKE_TIMEOUT_MS` value. | +| Argument | Type | Required | Notes | +| ------------ | ------ | -------- | ----------------------------------------------------------------------------------------- | +| `name` | string | yes | Hermes agent name from `hermes-agents.json` | +| `prompt` | string | yes | User message to send | +| `timeout_ms` | number | no | Timeout in milliseconds. Default: `60000`, or the `FLEET_BRIDGE_INVOKE_TIMEOUT_MS` value. | ### Return value @@ -91,14 +91,25 @@ ssh -o BatchMode=yes -o ConnectTimeout=10 {ssh_user}@{host} {binary} -z '","timeout_ms":120000},"_meta":{"progressToken":"t1"}}} +{ + "jsonrpc": "2.0", + "id": 3, + "method": "tools/call", + "params": { + "name": "invoke_agent", + "arguments": { + "name": "researcher", + "prompt": "what did I just ask you?", + "session_key": "", + "timeout_ms": 120000 + }, + "_meta": { "progressToken": "t1" } + } +} ``` ## Failure modes -| Error | Cause | -|---|---| -| `unknown agent: {name}` | Name not in `agents.json` — typo, or the roster failed to load (empty roster fallback) | -| `HTTP {status} from {name}: ...` | Gateway returned a non-OK status — bad token (401/403), gateway down, endpoint missing | -| `unexpected response shape from {name}` | Non-streaming response lacked `choices[0].message.content` | -| `fleet-bridge error: This operation was aborted` | Timeout exceeded; no reply is returned | -| Connection refused / fetch network error | Wrong `host`/`port`, or the gateway service is down | +| Error | Cause | +| ------------------------------------------------ | -------------------------------------------------------------------------------------- | +| `unknown agent: {name}` | Name not in `agents.json` — typo, or the roster failed to load (empty roster fallback) | +| `HTTP {status} from {name}: ...` | Gateway returned a non-OK status — bad token (401/403), gateway down, endpoint missing | +| `unexpected response shape from {name}` | Non-streaming response lacked `choices[0].message.content` | +| `fleet-bridge error: This operation was aborted` | Timeout exceeded; no reply is returned | +| Connection refused / fetch network error | Wrong `host`/`port`, or the gateway service is down | diff --git a/fleet-bridge/tools/list-agents.md b/fleet-bridge/tools/list-agents.md index 10de93e..5b2df05 100644 --- a/fleet-bridge/tools/list-agents.md +++ b/fleet-bridge/tools/list-agents.md @@ -24,7 +24,12 @@ A text content block containing JSON — the `agents.json` roster with only the ## Example call ```json -{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_agents","arguments":{}}} +{ + "jsonrpc": "2.0", + "id": 2, + "method": "tools/call", + "params": { "name": "list_agents", "arguments": {} } +} ``` Example result for the roster in [Configuration](../configuration.md): diff --git a/fleet-bridge/tools/start-session.md b/fleet-bridge/tools/start-session.md index 870b3e4..13e33d0 100644 --- a/fleet-bridge/tools/start-session.md +++ b/fleet-bridge/tools/start-session.md @@ -15,9 +15,9 @@ agent gateway under this key — the bridge itself stores nothing. ## Arguments -| Argument | Type | Required | Notes | -|---|---|---|---| -| `agent` | string | no | Agent name to validate. The returned key works for any agent, but pre-validation surfaces typos early. | +| Argument | Type | Required | Notes | +| -------- | ------ | -------- | ------------------------------------------------------------------------------------------------------ | +| `agent` | string | no | Agent name to validate. The returned key works for any agent, but pre-validation surfaces typos early. | ## Return value @@ -27,13 +27,18 @@ UUID string. ## Example call ```json -{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"start_session","arguments":{"name":"researcher"}}} +{ + "jsonrpc": "2.0", + "id": 2, + "method": "tools/call", + "params": { "name": "start_session", "arguments": { "name": "researcher" } } +} ``` Example result: ```json -{"session_key":"00000000-0000-4000-8000-000000000000"} +{ "session_key": "00000000-0000-4000-8000-000000000000" } ``` Then use it in `invoke_agent` as the `session_key` argument. The key is diff --git a/fleet-bridge/troubleshooting.md b/fleet-bridge/troubleshooting.md index a0d0e6d..50f9cde 100644 --- a/fleet-bridge/troubleshooting.md +++ b/fleet-bridge/troubleshooting.md @@ -89,7 +89,7 @@ Credentials never appear in tool output: If you think you are seeing a token in output, you are not — check the roster field names; the stripped-list shapes are the contract. -If a secret *does* leak outside tool output (e.g. you pasted a real token +If a secret _does_ leak outside tool output (e.g. you pasted a real token into an example file or issue), rotate it: change the gateway token, rebuild the roster, redeploy, restart. diff --git a/tractum/concepts/consensus.md b/tractum/concepts/consensus.md index e6f6126..fb6fa59 100644 --- a/tractum/concepts/consensus.md +++ b/tractum/concepts/consensus.md @@ -57,15 +57,15 @@ swarm = Swarm(config, consensus=Debate()) # revision round on disagreemen `ConsensusResult` fields: -| Field | Meaning | -|---|---| -| `final_answer` | The winning answer text | -| `method` | Strategy name: `weighted_vote` or `debate` | -| `agent_count` | How many responses were aggregated | -| `responses` | The `AgentResponse` list, each carrying its signed `statement` | -| `agreement` | Agreement score in 0.0 through 1.0 (1 = full convergence) | -| `rounds` | Rounds actually executed (1, or 2 for a run debate) | -| `disagreed` | Explicit disagreement flag | +| Field | Meaning | +| -------------- | -------------------------------------------------------------- | +| `final_answer` | The winning answer text | +| `method` | Strategy name: `weighted_vote` or `debate` | +| `agent_count` | How many responses were aggregated | +| `responses` | The `AgentResponse` list, each carrying its signed `statement` | +| `agreement` | Agreement score in 0.0 through 1.0 (1 = full convergence) | +| `rounds` | Rounds actually executed (1, or 2 for a run debate) | +| `disagreed` | Explicit disagreement flag | `Swarm.process(task)` returns the completed `Task` whose `result` is this dict (`to_dict()` form). Observer events stream alongside: wire an `on_event` callback to receive `AgentCompleted` (per agent, inside the gather) and `ConsensusResolved` (once, at the end). Observer errors are swallowed so a buggy observer can never surface as an agent failure. diff --git a/tractum/concepts/receipts.md b/tractum/concepts/receipts.md index 5feb81e..eb4418d 100644 --- a/tractum/concepts/receipts.md +++ b/tractum/concepts/receipts.md @@ -16,24 +16,24 @@ Every signature is computed over `canonical_json(payload)`: JSON with sorted key ## Payload versions -| Constant | Value | Contents | -|---|---|---| -| `CONSENSUS_PAYLOAD_V1` | `claudeway.consensus.v1` | `type`, `swarm`, `task_id`, `result` only | +| Constant | Value | Contents | +| ---------------------- | ------------------------ | ----------------------------------------------------------------------- | +| `CONSENSUS_PAYLOAD_V1` | `claudeway.consensus.v1` | `type`, `swarm`, `task_id`, `result` only | | `CONSENSUS_PAYLOAD_V2` | `claudeway.consensus.v2` | Adds `statements` (per-agent signed stances) and `quorum` (threshold k) | The aggregate signature covers the payload, so in a v2 receipt it covers the agent signatures too. v1 receipts remain valid forever; the verifier handles both. ## ConsensusReceipt fields -| Field | Meaning | -|---|---| -| `payload` | The canonical consensus facts (dict; shape above) | -| `algorithm` | Which `SignatureBackend` produced the aggregate signature (`ed25519`, `mldsa65`, ...) | -| `public_key` | Hex-encoded verification key of the operator signer | -| `signature` | Hex signature over sha256 of the canonical payload | -| `payload_hash` | Hex sha256 of the canonical payload | -| `signed_at` | UTC timestamp of signing | -| `metadata` | Free-form, transport-specific hints — **not signed** | +| Field | Meaning | +| -------------- | ------------------------------------------------------------------------------------- | +| `payload` | The canonical consensus facts (dict; shape above) | +| `algorithm` | Which `SignatureBackend` produced the aggregate signature (`ed25519`, `mldsa65`, ...) | +| `public_key` | Hex-encoded verification key of the operator signer | +| `signature` | Hex signature over sha256 of the canonical payload | +| `payload_hash` | Hex sha256 of the canonical payload | +| `signed_at` | UTC timestamp of signing | +| `metadata` | Free-form, transport-specific hints — **not signed** | Key methods and properties: `from_result(result, swarm_name="", task_id="", statements=None, quorum=None)` builds an unsigned receipt (statements are gathered from the responses' `statement` fields when omitted); `canonical_payload()` returns the exact string signatures are computed over; `is_signed` is true when signature, public key, and algorithm are all present; `to_dict()` serializes everything. @@ -45,10 +45,10 @@ Each statement is a dict signed by its agent's own key. Envelope keys (`algorith The `SignatureBackend` ABC is intentionally tiny: `generate_keypair()` returns `(private_key_hex, public_key_hex)`, `sign(message, private_key_hex)` returns a hex signature, `verify(message, signature_hex, public_key_hex)` returns a bool. Receipt and statement convenience methods (`sign_receipt`, `verify_receipt`, `sign_statement`, `verify_statement`) are inherited. -| Backend | `algorithm` | Dependency | Notes | -|---|---|---|---| -| `Ed25519Backend` (default) | `ed25519` | `cryptography` (already a base dep) | 64-byte signatures, no new native deps | -| `MLDSABackend` | `mldsa65` | `tractum[pq]` (`dilithium-py`, pure Python) | ML-DSA-65, FIPS 204, NIST level 3; ~3.3 KB signatures, ~2 KB public keys | +| Backend | `algorithm` | Dependency | Notes | +| -------------------------- | ----------- | ------------------------------------------- | ------------------------------------------------------------------------ | +| `Ed25519Backend` (default) | `ed25519` | `cryptography` (already a base dep) | 64-byte signatures, no new native deps | +| `MLDSABackend` | `mldsa65` | `tractum[pq]` (`dilithium-py`, pure Python) | ML-DSA-65, FIPS 204, NIST level 3; ~3.3 KB signatures, ~2 KB public keys | Receipts self-tag the algorithm when signed, so the same receipt shape works under either backend and consensus code never changes. diff --git a/tractum/self-hosting.md b/tractum/self-hosting.md index e6e8185..9023270 100644 --- a/tractum/self-hosting.md +++ b/tractum/self-hosting.md @@ -16,10 +16,10 @@ The repository has two compose files. Only the root one defines active services. `docker compose up killer-bench` reproduces the killer benchmark (Tractum vs CrewAI vs single Claude, blind judge, N runs) from cold. The reviewer brings only an Anthropic API key; compose handles the relay, the Python image, the deps, and stages the report to a mounted volume. -| Service | Image | Purpose | Ports | -|---|---|---|---| -| `relay` | `golang:1.26-alpine` (builds `fiatjaf/nak` from source into `/go/bin/nak`) | Reference Nostr relay (`nak serve`) for the test suite and `buzz_consensus_demo.py` | `10547:10547` | -| `killer-bench` | built from `benchmarks/Dockerfile` as `tractum/killer-bench:latest` | Runs `benchmarks/run.sh`, which validates the key, runs `examples/killer_demo.py`, and copies the report out | none | +| Service | Image | Purpose | Ports | +| -------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------- | +| `relay` | `golang:1.26-alpine` (builds `fiatjaf/nak` from source into `/go/bin/nak`) | Reference Nostr relay (`nak serve`) for the test suite and `buzz_consensus_demo.py` | `10547:10547` | +| `killer-bench` | built from `benchmarks/Dockerfile` as `tractum/killer-bench:latest` | Runs `benchmarks/run.sh`, which validates the key, runs `examples/killer_demo.py`, and copies the report out | none | Details: @@ -44,14 +44,14 @@ pip install tractum[runner] Configuration comes from environment variables with the `CLAUDWAY_` prefix (`api/config.py`, pydantic-settings, also reads a `.env` file). Active settings: -| Env var | Default | Meaning | -|---|---|---| -| `CLAUDWAY_API_HOST` | `0.0.0.0` | Bind host | -| `CLAUDWAY_API_PORT` | `8000` | Bind port | -| `CLAUDWAY_DEBUG` | `false` | Debug mode | -| `CLAUDWAY_SECRET_KEY` | `change-me-in-production` | JWT signing secret | -| `CLAUDWAY_ALGORITHM` | `HS256` | JWT algorithm | -| `CLAUDWAY_ACCESS_TOKEN_EXPIRE_MINUTES` | `30` | Token lifetime | +| Env var | Default | Meaning | +| -------------------------------------- | ------------------------- | ------------------ | +| `CLAUDWAY_API_HOST` | `0.0.0.0` | Bind host | +| `CLAUDWAY_API_PORT` | `8000` | Bind port | +| `CLAUDWAY_DEBUG` | `false` | Debug mode | +| `CLAUDWAY_SECRET_KEY` | `change-me-in-production` | JWT signing secret | +| `CLAUDWAY_ALGORITHM` | `HS256` | JWT algorithm | +| `CLAUDWAY_ACCESS_TOKEN_EXPIRE_MINUTES` | `30` | Token lifetime | Deprecated settings still present in the schema (`CLAUDWAY_DATABASE_URL`, `CLAUDWAY_REDIS_URL`, `CLAUDWAY_NATS_URL`, `CLAUDWAY_CLAUDE_FLOW_URL`, `CLAUDWAY_STRIPE_*`, `CLAUDWAY_RATE_LIMIT_*`) are not used by the current runtime — multi-tenancy, billing, templates, and gateway routes are archived under `api/platform-deprecated/` and their routers are commented out in `api/main.py`. A sample `.env` covering the full deprecated schema is in `.env.example`; treat it as reference, not as a required file. @@ -59,14 +59,14 @@ Deprecated settings still present in the schema (`CLAUDWAY_DATABASE_URL`, `CLAUD The app mounts one active router (`api/agents/router.py`) under the prefix `/v1/agents`, plus a health endpoint: -| Method | Path | Purpose | -|---|---|---| -| GET | `/health` | Liveness probe; returns `{"status": "healthy", "version": "0.1.0"}` | -| POST | `/v1/agents/` | Deploy a swarm (`DeployAgentRequest`: `name`, `description`, `agents`, optional `template_id`, `config`) — 201 | -| GET | `/v1/agents/` | List agents across swarms (`status`, `limit=100`, `offset=0` query params) | -| POST | `/v1/agents/{swarm_id}/task` | Submit a task to a swarm (`SendMessageRequest`: `task_description`, `task_data`, optional `user_id`) | -| POST | `/v1/agents/coordinator` | Create a coordinator with specialists (`CreateCoordinatorRequest`: `name`, `specialists`) — 201 | -| GET | `/v1/agents/status` | Runtime status snapshot | +| Method | Path | Purpose | +| ------ | ---------------------------- | -------------------------------------------------------------------------------------------------------------- | +| GET | `/health` | Liveness probe; returns `{"status": "healthy", "version": "0.1.0"}` | +| POST | `/v1/agents/` | Deploy a swarm (`DeployAgentRequest`: `name`, `description`, `agents`, optional `template_id`, `config`) — 201 | +| GET | `/v1/agents/` | List agents across swarms (`status`, `limit=100`, `offset=0` query params) | +| POST | `/v1/agents/{swarm_id}/task` | Submit a task to a swarm (`SendMessageRequest`: `task_description`, `task_data`, optional `user_id`) | +| POST | `/v1/agents/coordinator` | Create a coordinator with specialists (`CreateCoordinatorRequest`: `name`, `specialists`) — 201 | +| GET | `/v1/agents/status` | Runtime status snapshot | A `dashboard/` directory ships a Next.js frontend for the runner (separate `package.json`, run with its own toolchain; it is not part of the SDK wheel — `pyproject.toml` installs only the `tractum` package). diff --git a/tractum/verification.md b/tractum/verification.md index 72acf90..9c3d03f 100644 --- a/tractum/verification.md +++ b/tractum/verification.md @@ -27,9 +27,7 @@ With `pip install tractum[mcp]`, the `verify_consensus` tool does the full check "quorum": 3, "valid_statements": 3, "total_statements": 3, - "statements": [ - {"agent": "A", "valid": true, "reason": ""} - ] + "statements": [{ "agent": "A", "valid": true, "reason": "" }] } ``` diff --git a/wranglebot/daemon.md b/wranglebot/daemon.md index f219d87..5cc4df1 100644 --- a/wranglebot/daemon.md +++ b/wranglebot/daemon.md @@ -14,13 +14,13 @@ long as one agent run. ## Components -| File | Role | -| ---- | ---- | -| `cli.ts` | Argument parsing (`parseArgs`) and the `main()` orchestration loop behind `bin/wranglebot.mjs`. | -| `session.ts` | `SupervisorSession` — runs events through guardrails. | -| `pipeline.ts` | `createPipeline` — builds a `SupervisorSession` with a fresh session id. | -| `registry.ts` | `loadGuardrails` — discovers and instantiates guardrails. | -| `claude-stream.ts` | `runClaudeStream` — spawns Claude Code and parses its stream-json. | +| File | Role | +| ------------------ | ----------------------------------------------------------------------------------------------- | +| `cli.ts` | Argument parsing (`parseArgs`) and the `main()` orchestration loop behind `bin/wranglebot.mjs`. | +| `session.ts` | `SupervisorSession` — runs events through guardrails. | +| `pipeline.ts` | `createPipeline` — builds a `SupervisorSession` with a fresh session id. | +| `registry.ts` | `loadGuardrails` — discovers and instantiates guardrails. | +| `claude-stream.ts` | `runClaudeStream` — spawns Claude Code and parses its stream-json. | ## Lifecycle of one run diff --git a/wranglebot/getting-started.md b/wranglebot/getting-started.md index 82a801a..7cc0770 100644 --- a/wranglebot/getting-started.md +++ b/wranglebot/getting-started.md @@ -97,7 +97,9 @@ Claude Code PreToolUse hook so edit-tool calls are gated inline: ```json { "hooks": { - "PreToolUse": [{ "hooks": [{ "type": "command", "command": "wranglebot-hook" }] }] + "PreToolUse": [ + { "hooks": [{ "type": "command", "command": "wranglebot-hook" }] } + ] } } ``` diff --git a/wranglebot/guardrails.md b/wranglebot/guardrails.md index 6d040c8..e01cb13 100644 --- a/wranglebot/guardrails.md +++ b/wranglebot/guardrails.md @@ -44,11 +44,11 @@ options (`LoopBreakerOptions`, `ScopeGuardOptions`, `AstGateOptions`). ## Summary table -| Guardrail | What it does | -| --------- | ------------ | -| `ast-gate` | Tree-sitter parse of Edit/Write content (TS + Python). Denies `child_process`/`subprocess`; warns on destructive deletes outside the workdir, Python `eval`/`exec`, network egress. Parse errors fail open. | -| `scope-guard` | Real path containment (resolve + relative, Windows-safe). Denies writes outside the workdir/scope and to CI/config surfaces; warns on package-manifest writes. | -| `loop-breaker` | Deterministic kill signals: identical (tool, input) fingerprint, byte-identical shell output streaks, repeated test-failure hashes. All thresholds configurable. See [Loop-breaking](./loop-breaking.md). | +| Guardrail | What it does | +| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ast-gate` | Tree-sitter parse of Edit/Write content (TS + Python). Denies `child_process`/`subprocess`; warns on destructive deletes outside the workdir, Python `eval`/`exec`, network egress. Parse errors fail open. | +| `scope-guard` | Real path containment (resolve + relative, Windows-safe). Denies writes outside the workdir/scope and to CI/config surfaces; warns on package-manifest writes. | +| `loop-breaker` | Deterministic kill signals: identical (tool, input) fingerprint, byte-identical shell output streaks, repeated test-failure hashes. All thresholds configurable. See [Loop-breaking](./loop-breaking.md). | --- @@ -73,16 +73,16 @@ exception in the hook path also fails open (`src/hooks/cc-hook.ts`). **Rule table** (`AST_RULES`, data-only; extend the table, not the engine): -| Rule id | Action | Languages | Matches | -| ------- | ------ | --------- | ------- | -| `node-child-process` | deny | ts, tsx | Import/require/import of `child_process` or `node:child_process` | -| `python-subprocess` | deny | py | Import of `subprocess`; calls to `subprocess.run`, `subprocess.call`, `subprocess.check_call`, `subprocess.check_output`, `subprocess.Popen`, `subprocess.getoutput`, `subprocess.getstatusoutput` | -| `destructive-delete` | warn | ts, tsx, py | Calls to `fs.rmSync`, `fs.rm`, `fsPromises.rm`, `rimraf`, `shutil.rmtree`, `os.remove`, `os.removedirs`, `os.unlink`, plus bare `rmSync`, `rimraf`, `rmtree` | -| `python-eval-exec` | warn | py | Bare callees `eval` and `exec` | -| `network-egress` | warn | ts, tsx, py | Bare `fetch`; any callee whose first dotted segment is `axios`, `requests`, `httpx`, `urllib`, `http`, `https`, `got`, `superagent`, `node-fetch` | +| Rule id | Action | Languages | Matches | +| -------------------- | ------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `node-child-process` | deny | ts, tsx | Import/require/import of `child_process` or `node:child_process` | +| `python-subprocess` | deny | py | Import of `subprocess`; calls to `subprocess.run`, `subprocess.call`, `subprocess.check_call`, `subprocess.check_output`, `subprocess.Popen`, `subprocess.getoutput`, `subprocess.getstatusoutput` | +| `destructive-delete` | warn | ts, tsx, py | Calls to `fs.rmSync`, `fs.rm`, `fsPromises.rm`, `rimraf`, `shutil.rmtree`, `os.remove`, `os.removedirs`, `os.unlink`, plus bare `rmSync`, `rimraf`, `rmtree` | +| `python-eval-exec` | warn | py | Bare callees `eval` and `exec` | +| `network-egress` | warn | ts, tsx, py | Bare `fetch`; any callee whose first dotted segment is `axios`, `requests`, `httpx`, `urllib`, `http`, `https`, `got`, `superagent`, `node-fetch` | **Deletion path check:** for `destructive-delete`, if the first call argument -is a string literal that resolves *inside* the session workdir, no verdict is +is a string literal that resolves _inside_ the session workdir, no verdict is emitted for that call — deleting inside the workdir is fine. Relative paths resolve against the workdir; `~` paths and empty strings are undeterminable and still warn. diff --git a/wranglebot/hooks.md b/wranglebot/hooks.md index 0f79c1e..c866b07 100644 --- a/wranglebot/hooks.md +++ b/wranglebot/hooks.md @@ -20,7 +20,9 @@ command hook: ```json { "hooks": { - "PreToolUse": [{ "hooks": [{ "type": "command", "command": "wranglebot-hook" }] }] + "PreToolUse": [ + { "hooks": [{ "type": "command", "command": "wranglebot-hook" }] } + ] } } ``` @@ -42,12 +44,12 @@ command hook: Verdicts map onto the Claude Code hook contract (`hookSpecificOutput.permissionDecision`): -| ast-gate verdict | Hook output | Effect in Claude Code | -| ---------------- | ----------- | --------------------- | -| `allow` (or nothing to gate) | `permissionDecision: "allow"` with reason | Tool runs | -| `warn` | `permissionDecision: "ask"` with reason | Approval prompt shown to the user | -| `deny` | `permissionDecision: "deny"` with reason | Tool blocked | -| `rewrite` | `permissionDecision: "allow"` plus `updatedInput` | Tool runs with the replaced arguments | +| ast-gate verdict | Hook output | Effect in Claude Code | +| ---------------------------- | ------------------------------------------------- | ------------------------------------- | +| `allow` (or nothing to gate) | `permissionDecision: "allow"` with reason | Tool runs | +| `warn` | `permissionDecision: "ask"` with reason | Approval prompt shown to the user | +| `deny` | `permissionDecision: "deny"` with reason | Tool blocked | +| `rewrite` | `permissionDecision: "allow"` plus `updatedInput` | Tool runs with the replaced arguments | Fail-open is enforced in the hook path: if `gate.inspect` throws, the hook returns allow with an internal-error reason rather than blocking the edit. diff --git a/wranglebot/intro.md b/wranglebot/intro.md index 8fefefc..6d625ea 100644 --- a/wranglebot/intro.md +++ b/wranglebot/intro.md @@ -35,11 +35,11 @@ licensor. It is not MIT-licensed today. ## The exit-code contract -| Code | Meaning | -| ---- | ------- | -| `0` | Agent finished clean; no deny verdict was issued. | -| `1` | Setup or supervision error: bad CLI arguments, missing prompt, agent failed to spawn or exited non-zero. | -| `2` | The agent was denied — killed by a loop-breaker signal or blocked by a guardrail deny. | +| Code | Meaning | +| ---- | -------------------------------------------------------------------------------------------------------- | +| `0` | Agent finished clean; no deny verdict was issued. | +| `1` | Setup or supervision error: bad CLI arguments, missing prompt, agent failed to spawn or exited non-zero. | +| `2` | The agent was denied — killed by a loop-breaker signal or blocked by a guardrail deny. | Details and the full failure taxonomy: [Exit codes](./reference/exit-codes.md). diff --git a/wranglebot/loop-breaking.md b/wranglebot/loop-breaking.md index 5b0855b..7724ebe 100644 --- a/wranglebot/loop-breaking.md +++ b/wranglebot/loop-breaking.md @@ -25,10 +25,10 @@ match byte-for-byte. The Nth identical attempt: -| Attempts | Verdict | Reason | -| -------- | ------- | ------ | -| reaches `identicalWarnThreshold` (default 3) | `warn` | `loop-breaker: identical call attempted N times (warn threshold 3)` | -| reaches `identicalDenyThreshold` (default 5) | `deny` | `loop-breaker: kill — identical call attempted N times (deny threshold 5)` | +| Attempts | Verdict | Reason | +| -------------------------------------------- | ------- | --------------------------------------------------------------------------------- | +| reaches `identicalWarnThreshold` (default 3) | `warn` | `loop-breaker: identical call attempted N times (warn threshold 3)` | +| reaches `identicalDenyThreshold` (default 5) | `deny` | `loop-breaker: kill — identical call attempted N times (deny threshold 5)` | The deny check runs first, so attempts 3–4 warn and attempt 5 kills. @@ -74,12 +74,12 @@ This detector only warns; it never denies. All thresholds are constructor options (`LoopBreakerOptions`): -| Option | Default | Effect | -| ------ | ------- | ------ | -| `identicalWarnThreshold` | 3 | Identical-call attempts before warn | -| `identicalDenyThreshold` | 5 | Identical-call attempts before deny/kill | -| `noProgressWarnThreshold` | 3 | Consecutive identical shell outputs before warn | -| `failureDenyThreshold` | 4 | Repeats of the same failure signature before deny | +| Option | Default | Effect | +| ------------------------- | ------- | ------------------------------------------------- | +| `identicalWarnThreshold` | 3 | Identical-call attempts before warn | +| `identicalDenyThreshold` | 5 | Identical-call attempts before deny/kill | +| `noProgressWarnThreshold` | 3 | Consecutive identical shell outputs before warn | +| `failureDenyThreshold` | 4 | Repeats of the same failure signature before deny | ## What a kill means diff --git a/wranglebot/reference/cli.md b/wranglebot/reference/cli.md index ab37eba..b8d509e 100644 --- a/wranglebot/reference/cli.md +++ b/wranglebot/reference/cli.md @@ -10,9 +10,9 @@ sidebar_position: 10 `@wranglebot/cli` installs two binaries (`bin` field in `package.json`): -| Binary | Entry | Purpose | -| ------ | ----- | ------- | -| `wranglebot` | `bin/wranglebot.mjs` | Supervisor CLI | +| Binary | Entry | Purpose | +| ----------------- | ------------------------- | --------------------------- | +| `wranglebot` | `bin/wranglebot.mjs` | Supervisor CLI | | `wranglebot-hook` | `bin/wranglebot-hook.mjs` | Claude Code PreToolUse hook | ## wranglebot @@ -25,23 +25,23 @@ The usage string is literal, from `src/daemon/cli.ts`. ### Subcommands -| Subcommand | Description | -| ---------- | ----------- | -| `run` | The only subcommand. Spawns the agent under supervision. | +| Subcommand | Description | +| ---------- | -------------------------------------------------------- | +| `run` | The only subcommand. Spawns the agent under supervision. | ### Positional arguments -| Argument | Required | Description | -| -------- | -------- | ----------- | -| agent | yes | Exactly `claude-code` or `codex`. Any other value is rejected. | -| prompt | yes | One or more positional words, joined with single spaces into the prompt. Must be non-empty. | +| Argument | Required | Description | +| -------- | -------- | ------------------------------------------------------------------------------------------- | +| agent | yes | Exactly `claude-code` or `codex`. Any other value is rejected. | +| prompt | yes | One or more positional words, joined with single spaces into the prompt. Must be non-empty. | ### Flags -| Flag | Repeatable | Description | -| ---- | ---------- | ----------- | +| Flag | Repeatable | Description | +| --------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--workdir DIR` | no (last wins) | Project root: containment root for `scope-guard`, deletion-path root for `ast-gate`, `cwd` for the spawned agent, and flush directory for `.curt` output. Defaults to `process.cwd()`. | -| `--scope PATH` | yes | Additional allowed write root handed to `scope-guard` as `allowedPaths`. An entry covering a path also overrides the default denied patterns for that path. | +| `--scope PATH` | yes | Additional allowed write root handed to `scope-guard` as `allowedPaths`. An entry covering a path also overrides the default denied patterns for that path. | Any other flag beginning with `--` is an unknown-flag error. A flag value that is missing or starts with `--` is rejected. All argument errors exit `1` with @@ -53,8 +53,8 @@ by the Codex observer's spawn wrapper, not by argument parsing.) ### Environment variables -| Variable | Used by | Description | -| -------- | ------- | ----------- | +| Variable | Used by | Description | +| ------------ | -------------- | ------------------------------------------ | | `CODEX_PATH` | Codex observer | Path to the codex binary; default `codex`. | ### Runtime output diff --git a/wranglebot/reference/exit-codes.md b/wranglebot/reference/exit-codes.md index 140da92..45ee168 100644 --- a/wranglebot/reference/exit-codes.md +++ b/wranglebot/reference/exit-codes.md @@ -12,11 +12,11 @@ sidebar_position: 9 `bin/wranglebot.mjs` as `process.exitCode`). Final return: `return denied ? 2 : (code ?? 1)`. -| Code | Meaning | Produced by | -| ---- | ------- | ----------- | -| `0` | Agent finished clean; no deny verdict was issued and the agent itself exited `0`. | Clean Claude Code run | -| `1` | Setup or supervision error. | See taxonomy below | -| `2` | The agent was denied — a loop-breaker kill or a guardrail deny fired. `denied` is set on the first `deny` verdict, the agent process is killed immediately, and the code wins over any other outcome. | Any guardrail returning `deny` | +| Code | Meaning | Produced by | +| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | +| `0` | Agent finished clean; no deny verdict was issued and the agent itself exited `0`. | Clean Claude Code run | +| `1` | Setup or supervision error. | See taxonomy below | +| `2` | The agent was denied — a loop-breaker kill or a guardrail deny fired. `denied` is set on the first `deny` verdict, the agent process is killed immediately, and the code wins over any other outcome. | Any guardrail returning `deny` | `warn` verdicts never change the exit code. @@ -31,7 +31,7 @@ In order of occurrence: - `--workdir` or `--scope` missing its value (or the value itself starts with `--`) - empty prompt (no positional arguments) - Each prints `wranglebot: ` plus the usage line to stderr. + Each prints `wranglebot: ` plus the usage line to stderr. 2. **Claude Code spawn failure**: the child emits an `error` event; stderr prints `wranglebot: claude spawn failed: `. The child's exit code is then null, which the final expression maps to `1`. @@ -43,7 +43,7 @@ In order of occurrence: - non-zero codex exit, including Windows code `9009` for a missing binary: `codex ("") exited with code ` - no stdout stream: `codex ("") produced no stdout stream` - Any of these prints to stderr and sets the run code to `1`. + Any of these prints to stderr and sets the run code to `1`. Note the precedence: a deny always maps to `2` regardless of the agent's own exit code, but a codex error path exits `1` before any deny can be recorded