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
33 changes: 21 additions & 12 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Run one Deno test file or test: `deno test -A tests/integration/pg-store-read.te

CI (`.github/workflows/ci.yml`, Supabase CLI pinned at 3.0.0) runs check, unit, `supabase db start`, pgTAP and
integration. E2E is local only. After editing function code, restart `supabase functions serve`: a running server can
boot a half-written file and fail with BOOT_ERROR or "Unexpected eof".
boot a half-written file and fail with BOOT_ERROR or "Unexpected eof". The edge runtime's parser is older than
`deno check`'s: a regex literal holding a quote in `_shared/web-api.ts` passed `deno check` but would not boot, so serve
the function once after an edit, before a deploy.

## Architecture

Expand Down Expand Up @@ -101,17 +103,23 @@ past the snippet), so the MCP tool's output stays as it was.
boards on these tools: graph, claim_next, claims, links and search browse. It has no server code of its own. The design
is in `docs/superpowers/specs/2026-11-23-blackboard-skill-design.md`. Test a change to it the way the plan
`docs/superpowers/plans/2026-11-23-blackboard-skill.md` did: subagents run single cycles on a throwaway `board:toy-*`
board in `agent-memory-tool`, and the board is deleted afterwards. This repo holds the maintained copy; projects keep
only their board files.
board in `agent-memory-tool`, and the board is deleted afterwards (with `board-runner forget-usage <board file>` for its
token usage rows). This repo holds the maintained copy; projects keep only their board files.

**Board runner.** `runner/` is Python 3.11+, standard library only, with `unittest` tests (CI job `runner`). It drives a
board from a TOML board file. Design: `docs/superpowers/specs/2026-11-24-board-runner-design.md`.

- **Processes:** it keeps the lead as an interactive `claude` session in tmux, and starts one fresh `claude -p` worker
per intent, per configured slot.
- **Board-blind:** it never touches shared memory. Sessions run the skill in `runner` mode and end with a `BOARD-WORK`,
`BOARD-LEAD` or `BOARD-START` line, which `protocol.py` parses. A Stop hook (`hook.py`) appends each lead turn to
`events.jsonl`.
- **Board-blind:** it never reads shared memory. Sessions run the skill in `runner` mode and end with a `BOARD-WORK`,
`BOARD-LEAD` or `BOARD-START` line, which `protocol.py` parses. A Stop hook (`hook.py`) appends each lead turn, and
its transcript path, to `events.jsonl`.
- **Token usage:** its one write. `usage.py` reads raw token counts (never dollars) from each worker's, one-shot's and
the lead's transcripts, and `usage_sender.py` posts them to `web-api`'s `POST /usage` with the person's
`AGENT_MEMORY_TOKEN` (from the environment or the board file's `usage_env_file`). Rows go through
`usage-pending.jsonl` and are retried until accepted; only a 400, 413 or 422 drops one, so `/usage` answers scope
errors with 404 or 403. They land in the `board_usage` table (`record_board_usage` upserts on scope, board and run
label; agents never see it). Design: `docs/superpowers/specs/2026-11-27-token-usage-design.md`.
- **Scheduler:** `scheduler.py` is pure, with events in and actions out, so every scheduling rule is unit-tested with a
fake clock. `cli.py` is the I/O loop around it.
- **Tests:** change the scheduler test-first. Test runner-mode skill changes with subagents on toy boards, as above.
Expand All @@ -123,10 +131,10 @@ controls: `docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md`.

- **Data:** the server talks only to the `web-api` Edge Function (`supabase/functions/web-api/index.ts`, routes in
`_shared/web-api.ts`), never to Postgres. It adds the token from `.env` and forwards only an allow-list: GET routes
(`/api/scopes`, `boards`, `graph`, `memories`, `memories/:id`) and four POST routes (`hints`, `intents`, `amendments`,
`boards/control`), so the token never reaches the browser. It binds to `127.0.0.1` and checks `Host`. A POST must be
JSON, at most 16 KiB, and same-origin (`Sec-Fetch-Site`, or `Origin` when that is absent), else 403, and gets a 30 s
timeout (`web/lib/proxy.ts`).
(`/api/scopes`, `boards`, `graph`, `usage`, `memories`, `memories/:id`) and four POST routes (`hints`, `intents`,
`amendments`, `boards/control`; never `usage`, which only the runner writes), so the token never reaches the browser.
It binds to `127.0.0.1` and checks `Host`. A POST must be JSON, at most 16 KiB, and same-origin (`Sec-Fetch-Site`, or
`Origin` when that is absent), else 403, and gets a 30 s timeout (`web/lib/proxy.ts`).
- **web-api:** read routes on `PgMemoryStore` as the caller, with the embedder built lazily so only text search loads
it. Browse and ranked search from here do not count as an access. There is no history route.
- **Writes:** `POST /hints`, `/intents`, `/amendments` and `/boards/control` run as the caller through `store`, `relate`
Expand All @@ -141,8 +149,9 @@ controls: `docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md`.
`$BOARD_RUNNER_HOME`). The label is untrusted text from a `By:` line, so it must match the shape `new_label` makes,
and the real path must stay inside that board's `workers/`. The server picks the byte offsets, so the browser never
splits a UTF-8 sequence.
- **Live:** the browser polls `/graph` every `POLL_MS` (3 s) while the tab is visible and diffs each result. Hosted
`/graph` takes about 0.3 s whatever the board's size, mostly network and auth.
- **Live:** the browser polls `/graph` every `POLL_MS` (3 s) while the tab is visible and diffs each result, and
`/usage` at most every 30 s for the strip's token total and the drawer's per-run counts. Hosted `/graph` takes about
0.3 s whatever the board's size, mostly network and auth.
- **Tests:** pure helpers are split from DOM modules so they run under `deno task test:unit`. `deno task check`
type-checks `web/lib` and `web/server.ts`. The browser modules are checked by hand against a toy board. The skill's
paused branch, amendment fallback and `round:<n>` wording have not been run on a real board.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ separate bot member for agents, with a database rule that bot members cannot wri
| `/intents` | `scope`, `board`, `text`, `produce?`, `giveUp?`, `from?` | 201 `{ memory }`; 409 `Board is not running` unless running or paused |
| `/amendments` | `scope`, `board`, `text` | 201 `{ memory }`; 409 when the board is done |
| `/boards/control` | `scope`, `board`, `action?` (`pause`, `resume`, `stop`, `restart`), `maxIntents?` (number or `"none"`) | 200 `{ goal }`; 409 `Board is <state>` when the action is not allowed from there |
| `/usage` | one run's raw token counts (sent by the board runner, never the browser) | 201 `{ id }`; 404 or 403 for a scope the token cannot write |
| `/usage/delete` | `scope`, `board` | 200 `{ deleted }` |

`GET /usage?scope=&board=` returns a board's runs, newest first, and their summed `total`. The strip shows that total
("Tokens 12M in · 310k out", input counting cache reads and writes), and an intent's, fact's or goal's drawer shows the
runs that worked on it. These are raw token counts; no costs are stored or shown.

`text` is 1 to 2,000 characters; `produce` and `giveUp` at most 500. A board or memory the caller cannot read gives a
404 that reads the same whether it is absent or unreadable. If linking fails after a memory is stored, the route
Expand Down
Loading
Loading