From b5f3874f19ea605130c97eb8a761fda43640cea8 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Thu, 26 Nov 2026 18:55:37 +0000 Subject: [PATCH 01/14] docs: design for web UI hints, intents and run controls Co-Authored-By: Claude Opus 5.5 --- .../2026-11-26-web-ui-hints-intents-design.md | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md diff --git a/docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md b/docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md new file mode 100644 index 0000000..2b35cb9 --- /dev/null +++ b/docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md @@ -0,0 +1,178 @@ +# Web UI: hints, intents and run controls — design + +Status: approved in conversation, 2026-11-26. Builds on `2026-11-26-web-ui-design.md` (the read-only web UI). + +## Intent + +While watching a board, the person often knows something the agents don't, or has an idea worth trying. Today they +have to open a Claude session and run `/blackboard hint`, or write a memory by hand. They want to do it from the board +view, on the node it is about: + +- **Add hint:** "here is something useful" — advice the lead weighs at its next round. +- **Add intent:** "try doing X" — a new piece of work that a worker picks up, without waiting for the lead to think of + it. + +## Goals + +- An **Add hint** box in the drawer of every board node. +- An **Add intent** form in the drawer of the goal and of facts. +- Both write exactly the shapes the blackboard skill already writes, so the lead and workers need no new reading rules. +- **Board controls** on the goal's drawer: pause and resume the lead, stop, restart after a stop, and raise or lower + the intent limit — all through the database, so they work for a board run on any machine. +- A person in any Claude session can do the same through the skill: `/blackboard hint` already exists, and a new + `/blackboard intent ` matches the button. + +## Non-goals + +- Editing or deleting memories from the UI, dropping intents, or changing the rules or the goal's text (the only goal + changes are its state and its `Max intents` line, under Board controls). +- Hints that go straight to a worker. The person chose to keep hints as they are: advice for the lead. +- Writes from the Browse tab outside a board. + +## Anti-goals + +- A browser that can write arbitrary memories. The browser sends only text and the node it is about; the server builds + every word of the template, every tag and every link. +- A write the person cannot see landing: the new node must appear in the graph on the next poll, or the form says why + it failed. +- An intent the person added being quietly dropped by the lead. + +## Approaches + +1. **Dedicated write routes in `web-api` (chosen).** `POST /hints` and `POST /intents`. The server builds the skill's + templates, tags and links, and checks the board is running for intents. Narrow, and the templates live in one place + on the server. +2. **A generic "store a memory" route, with the browser building the text.** Less code, but the browser could write + any memory and the templates would drift from the skill's. Rejected. +3. **Add intent stores a "suggested intent" hint for the lead to turn into an intent.** Keeps the lead in charge of + wording and limits, but it is not direct — it waits a round and the lead may decline it. Rejected: the person asked + for direct intents. + +## What gets built + +### Shapes (match the skill exactly) + +- **Hint:** + ``` + Hint: + From: + ``` + Tags `board:`, `kind:hint`, `evergreen`. Linked `relates-to` the node it was added on when that node is an + intent, fact or hint; none when added on the goal (board-wide). +- **Intent:** + ``` + Intent: + Why: added by from the web UI<; building on fact when added on a fact> + Produce: + Give up when: + ``` + Tags `board:`, `kind:intent`, `state:open`, `round:`, `evergreen`, where `` is the progress memory's + current `Round:` (so it sits in the current round's band). Linked `derived-from` the fact it was added on, if any. +- Both are stored in the board's scope (the goal's scope), as the caller, category `observation`. + +### `web-api` + +- `POST /hints` body `{ scope, board, text, about? }`; `POST /intents` body `{ scope, board, text, produce?, giveUp?, + from? }` (`about` / `from` are memory ids). JSON only; anything else 415. +- Validation: `text` 1–2,000 characters after trimming, single-line for the first line of the template (newlines in + `text` are folded to spaces); `produce` / `giveUp` at most 500 each. `board` must match the board-name shape. The + goal is found as the board's `kind:goal` memory in `scope`; none → 404 in the store's not-found wording. `about` / + `from` must be a readable memory tagged `board:` (else the same 404); `from` must be a `kind:fact`. +- Intents only while the goal has `state:running` or `state:paused` (else 409 `Board is not running`). +- Store as the member through `PgMemoryStore.store`, then `relate`. A scope the caller can't write gives the store's + own error (user-safe). Response 201 `{ memory }`. +- Uses the embedder (store embeds content), so these routes construct it; reads still don't. +- The member name for `From:` / `Why:` comes from the caller's own identity, looked up before storing, so the content + is right on first store (no store-then-update). The builder picks the cleanest member-readable lookup. + +### Local server + +- The proxy allows exactly `POST /api/hints`, `POST /api/intents` and the board-control route(s) in addition to the + GET allow-list. +- Each POST must carry `Content-Type: application/json` and `Sec-Fetch-Site: same-origin` (or `Origin` equal to the + page's own origin when that header is absent); else 403. Body forwarded as is, at most 16 KiB. + +### Browser + +- Drawer, Memory tab, below the content: **Add hint** (textarea + button) on every node of a board. On the goal and on + facts, also **Add intent** ("Try …" line, optional "Done when", optional "Give up when"). +- Only shown on the Board tab (the drawer knows the board and scope there). Disabled while a request is in flight. On + success: clear the form, say "Added — it will appear in the graph shortly", and trigger an immediate graph poll. On + failure: show the server's error text. +- All text rendered with `textContent`. + +### Skill + +- `SKILL.md`: a new `intent ` command next to `hint`, writing the same intent shape (with `Why: added + by …`), linked `derived-from` any fact id named in the text. +- `lead.md` Drop rule: never drop an intent whose `Why:` says it was added by a person; only a fact closes it. It still + counts toward `Max intents` and the open-intent limit. + +## Board controls (added in the same conversation) + +The person wants to steer a run from the UI, and it must work for a board run on any machine, so every control is a +change to the goal memory in the database, never a local file. + +- **Pause lead / Resume lead.** Pause swaps the goal's `state:running` for `state:paused`; Resume swaps it back. + - While paused, the lead plans nothing new, proposes no candidates and writes no conclusion. It keeps renewing its + claim on the goal, and ends its round with `BOARD-LEAD paused free= open=`. + - Workers carry on: they finish what they hold and keep taking intents that are already open, including ones the + person adds. Once the open intents are done, no new work is issued until Resume. + - The runner keeps running. On `paused` it fills worker slots from `free` as for `running`, and asks the lead for a + round every 2 minutes instead of `round_every_minutes`, so Resume is seen within about 2 minutes. The runner stays + board-blind; the lead reads the state. +- **Stop.** The existing `/blackboard stop`: `state:stopped`. Workers end at their next step, the runner drains (lets + running workers finish) and exits. The UI asks for confirmation first. +- **Restart** (shown on a board stopped by hand): sets `state:stopped` back to `state:running` and says "now run + `board-runner run ` again". Not offered when the goal is `state:done`. +- **Intent limit.** A number box showing the goal's `Max intents` (or "no limit"), with Save. + - Saving rewrites the goal's `Max intents:` line, keeping every other line. + - Raising it on a board stopped at its limit (a conclusion contains `Stopped: intent limit`) is the skill's + `resume`: the new limit and `state:running` again, then the same "run `board-runner run` again" note. + - Lowering it on a running board makes the lead stop once the count reaches the new number. A lower limit than the + intents already written is allowed (the lead stops at its next round). + - A higher `max_intents` in the board file raises it again on the next `board-runner run` (existing start + behaviour); the UI says so in a hint line under the box. + +Where the rules change: + +- `SKILL.md`: `state:paused` added to the goal's states; new commands `pause ` and `resume-lead ` + (names to fit the existing command table), and `stop` unchanged. +- `lead.md`: a paused branch at the top of the round (after renewing the claim): read the board as usual for counts, + write nothing, end with `BOARD-LEAD paused free= open=`. +- `work.md` step 1: a goal that is `state:running` **or** `state:paused` lets the worker continue. +- `start.md`: a `state:paused` board on `board-runner run` counts as existing (`BOARD-START exists`). +- Runner: `protocol.py` parses `BOARD-LEAD paused free= open=`; `scheduler.py` treats it like `running` for + filling slots and switches the heartbeat to 2 minutes until a `running` result; tests first, as CLAUDE.md asks. +- `web-api`: `POST /boards/control` body `{ scope, board, action: 'pause' | 'resume' | 'stop' | 'restart', maxIntents? }` + (or one route per action — builder's call), acting on the goal as the caller through `update`; state transitions + allowed only from the states above (else 409 with the current state named). The status strip shows `paused`. + +## Constraints + +- Hosted: `web-api` must be redeployed; ask the person first (per CLAUDE.md). +- CPU: each write embeds once (well under 1 s); reads unchanged. +- Repo is public; tests use neutral strings. + +## Decided after the builder check + +- **Limits:** the person chose to accept a person's intent regardless of `Max intents`; the form shows "this board has + used of intents" before submitting. +- **Drop protection** covers only the lead's "pointless" Drop rule. Done and Unreachable still close every open intent + at board end; an intent that times out twice may be split by the lead into smaller intents linked `derived-from` it. +- **Marker:** a person's intent has a `Why:` line starting exactly `Why: added by `; the lead's rule matches that + prefix, and a test pins the server's text to it. +- **Folding:** newlines are folded to spaces in `text`, `produce` and `giveUp`, so no field can forge a template line. +- **Truncated boards** (over 400 nodes): the form warns that the new node may not appear in the graph. +- **Board-wide hints:** a hint on the goal, conclusion, progress or rules node has no link. Hints are allowed in any + board state; Add intent only while the board is running or paused. +- **Partial failure:** if linking fails after the store, the route deletes the memory it stored and returns the error. +- **Round tag:** read from the progress memory's `Round:`; when there is none, the intent gets no `round:` tag and the + time-gap grouping places it. An intent added mid-round joins that round. +- **Timeouts and duplicates:** POSTs get a 30 s proxy timeout; a duplicate from a retry after a timeout is accepted. + +## Left to the builder + +- How to get the caller's member name (see above). +- Exact error wording beyond the ones named. +- Form layout and styling in the drawer. From 1fd4fdf4cb64e3a246b94441fa70f697ab50a23e Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Thu, 26 Nov 2026 18:56:49 +0000 Subject: [PATCH 02/14] docs: plan for web UI hints, intents and run controls Co-Authored-By: Claude Opus 5.5 --- .../plans/2026-11-26-web-ui-hints-intents.md | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 docs/superpowers/plans/2026-11-26-web-ui-hints-intents.md diff --git a/docs/superpowers/plans/2026-11-26-web-ui-hints-intents.md b/docs/superpowers/plans/2026-11-26-web-ui-hints-intents.md new file mode 100644 index 0000000..753915b --- /dev/null +++ b/docs/superpowers/plans/2026-11-26-web-ui-hints-intents.md @@ -0,0 +1,185 @@ +# Web UI hints, intents and run controls — Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** From the board view, a person can add hints and intents and pause, resume, stop, restart and re-limit a run — all through the database, so it works for a board run on any machine. + +**Architecture:** Write routes on the `web-api` Edge Function build the blackboard skill's exact templates server-side and store/update as the caller (RLS decides). The local proxy admits exactly those POSTs with same-origin checks. The browser drawer gains forms; the goal's drawer gains a controls panel. The skill and runner learn a new goal state, `state:paused`: the lead plans nothing, workers carry on with open intents, the runner checks every 2 minutes. + +**Tech Stack:** Deno 2 (edge function, local server, tests), `npm:postgres`, vanilla JS ES modules, Python 3.11 stdlib for the runner. + +**Spec:** `docs/superpowers/specs/2026-11-26-web-ui-hints-intents-design.md` (builds on `2026-11-26-web-ui-design.md`). + +## Global Constraints + +- The browser sends only text, ids and an action; the server builds every word of a template, every tag and every link. +- Hint text: `Hint: ` / `From: `; tags `board:`, `kind:hint`, `evergreen`. +- Intent text: `Intent: ` / `Why: added by from the web UI[; building on fact ]` / + `Produce: ` / `Give up when: `; + tags `board:`, `kind:intent`, `state:open`, `round:` (omitted when no progress `Round:`), `evergreen`. +- A person's intent is marked by a `Why:` line starting exactly `Why: added by `. +- Newlines (`\r`, `\n`) in `text`, `produce`, `giveUp` fold to single spaces; `text` 1–2,000 chars after trimming, + `produce` / `giveUp` ≤ 500 each. +- Goal states: `state:running`, `state:paused`, `state:stopped`, `state:done`. Intents allowed while running or paused. +- Runner line: `BOARD-LEAD paused free= open=`; paused heartbeat 120 s. +- Errors reaching a client are user-safe; "not found" uses the store's wording (`Memory not found`) for absent and + unreadable alike. +- Every write runs as the caller through `withMember`; no migration. +- Proxy: POSTs need `Content-Type: application/json` and `Sec-Fetch-Site: same-origin` (or, when absent, an `Origin` + equal to the request's own origin); body ≤ 16 KiB; upstream timeout 30 s for POSTs (15 s for GETs stays). +- Browser: `textContent` only; never `window`; pure modules `// @ts-check`, no DOM. +- Skill changes keep every existing `BOARD-*` line unchanged; the skill is instructions only. +- Hosted `web-api` redeploy and any hosted toy-board run need the person's yes for that run. +- Repo is public: neutral test strings; literal-name cleanup. + +## Review Focus + +1. **Forged template lines.** A hint or intent text containing `\nWhy: added by …` or `\nBOARD-LEAD …` must land on + one line. (Task 3 tests.) +2. **Cross-site write.** A page on another origin POSTing to `localhost:8787/api/intents` must get 403 with no upstream + call, including a `text/plain` "simple request". (Task 4 tests.) +3. **Control on the wrong state.** Pause on a stopped board, Restart on a done board, Resume on a running board → 409 + naming the current state, goal unchanged. (Task 3 tests.) +4. **A paused board left behind.** A runner restarted on a paused board must keep running and keep checking, not exit + or treat it as not-running. (Tasks 1, 2.) +5. **Limit edit losing content.** Rewriting `Max intents:` must keep every other goal line byte for byte, and add the + line if absent. (Task 3 tests.) + +--- + +### Task 1: Runner understands a paused lead + +**Files:** Modify `runner/board_runner/protocol.py`, `runner/board_runner/scheduler.py`, `runner/README.md`. +Test: `runner/tests/test_protocol.py`, `runner/tests/test_scheduler.py`. + +**Interfaces:** Produces `LeadKind` gains `"paused"`; `parse_lead("BOARD-LEAD paused free=2 open=3")` → +`LeadResult("paused", free=2, open=3)`. Scheduler: a `paused` result fills slots from `free` exactly like `running`; +while the last lead result is `paused`, the heartbeat interval is `PAUSED_HEARTBEAT_SECONDS = 120` instead of +`round_every_minutes * 60`; any non-paused result restores it. The "no turn end for 2 heartbeats" warning uses the +active interval. + +- [ ] Step 1: failing tests — parse paused (and malformed `BOARD-LEAD paused` → `none`); scheduler: paused result + starts workers for `free`; next round sent after 120 s while paused, after `round_every_minutes` after a running + result; draining not set by paused. +- [ ] Step 2: run `cd runner && python3 -m unittest discover -s tests` — new cases FAIL. +- [ ] Step 3: implement. README: one line on `paused` under Use. +- [ ] Step 4: runner tests PASS. Step 5: commit `feat(runner): a paused lead keeps the run alive and is checked every 2 minutes`. + +### Task 2: Skill — paused state, new commands, drop protection + +**Files:** Modify `skills/blackboard/SKILL.md`, `lead.md`, `work.md`, `start.md`. + +**Interfaces:** Produces: +- SKILL.md: goal states include `state:paused`; commands `pause ` (running → paused), `resume-lead ` + (paused → running), `intent ` (the Global Constraints intent shape with `Why: added by from a Claude session`, linked `derived-from` any fact id named in the text, refused unless running or paused). `stop` unchanged. +- lead.md: right after the claim renewal, if the goal is `state:paused`: read intents for counts as usual, write + nothing (no intents, candidates, conclusion or progress rewrite), end with `(label: …)` then + `BOARD-LEAD paused free= open=`; in runner mode list this line with the others. Drop rule: never drop as + pointless an open intent whose `Why:` starts `Why: added by `. +- work.md step 1: continue when the goal is `state:running` or `state:paused`. +- start.md: a `state:paused` board counts as existing (`BOARD-START exists`). + +- [ ] Step 1: edit, in each file's voice. +- [ ] Step 2: `deno task check` PASS; `grep -n "BOARD-" skills/blackboard/*.md` shows every old line unchanged. +- [ ] Step 3: commit `feat(skill): pause and resume the lead; person intents; drop protection`. +- Behavioural check happens in Task 6's toy run. + +### Task 3: `web-api` write routes + +**Files:** Create `supabase/functions/_shared/board-writes.ts` (pure: templates, folding, goal-line edit, +transition table). Modify `supabase/functions/_shared/web-api.ts`, `supabase/functions/_shared/pg-store.ts` +(`memberName()`), `supabase/functions/web-api/index.ts` if needed. Test: `tests/unit/board-writes.test.ts`, +`tests/unit/web-api.test.ts`, `tests/integration/web-api.test.ts`. + +**Interfaces:** +- `PgMemoryStore.memberName(): Promise` — the caller's name via `agent_memory.member_name()` run as + the member (verify the member role can execute it; no migration). +- `WebStore` adds `memberName`, `store(scope, req)`, `relate(from, to, type)`, `update(id, u)`, `delete(id)` (real + `PgMemoryStore` signatures). +- Pure (`board-writes.ts`): `fold(s: string): string`; `hintContent(text, name): string`; + `intentContent({ text, name, produce?, giveUp?, fromFact? }): string`; `withMaxIntents(goal: string, n: number | 'none'): string`; + `transition(state: string, action: 'pause' | 'resume' | 'stop' | 'restart'): string | null` (pause: running→paused; + resume: paused→running; stop: running|paused→stopped; restart: stopped→running; else null). +- Routes (POST, JSON only else 415): + - `POST /hints` `{ scope, board, text, about? }` → 201 `{ memory }`. `about` on an intent, fact or hint → `relates-to` + from the hint; on goal / progress / rules / conclusion → no link. + - `POST /intents` `{ scope, board, text, produce?, giveUp?, from? }` → 201 `{ memory }`; `from` must be a `kind:fact` + on the board; link `derived-from` it. 409 `Board is not running` unless running or paused. `round:` from the + board's `kind:progress` `Round:` line. + - `POST /boards/control` `{ scope, board, action?, maxIntents? }` (at least one) → 200 `{ goal }`. `action` applies + `transition` (409 `Board is ` when null); `maxIntents` (positive integer or `"none"`) rewrites the line; + raising it on a goal that is `state:stopped` with a conclusion containing `Stopped: intent limit` also sets + `state:running`. Tag updates keep every other tag. + - Goal = the board's `kind:goal` memory in `scope` (browse by `tagsAll`); none → 404 `Memory not found`-style + wording consistent with the store. `about` / `from` must be readable and tagged `board:`, else 404. + - If `relate` throws after `store`, `delete` the stored memory, then return the error. +- Only these routes build the embedder (reads stay lazy). + +- [ ] Step 1: failing unit tests for the pure module: Review Focus 1 (folding, forged lines), marker prefix exactness, + defaults, `withMaxIntents` keeps other lines byte for byte and adds a missing line (Review Focus 5), every + `transition` pair (Review Focus 3). Route unit tests with a fake `WebStore`: shapes, 415, 409s, `about` link rules, + rollback on relate failure, limit-resume. +- [ ] Step 2: integration tests (`withWorld`): `rw` adds a hint and an intent to a fresh board and they come back with + the right content, tags and links; `ro` gets the store's write error; `none` gets 404; pause/resume/stop/restart + round-trip the goal's tags. +- [ ] Step 3: run both — FAIL. Step 4: implement. Step 5: `deno task check && deno task test:unit && deno task test:int` PASS. +- [ ] Step 6: commit `feat(web-api): add hints, intents and board controls`. + +### Task 4: Proxy admits the write routes + +**Files:** Modify `web/lib/proxy.ts`. Test: `tests/unit/web-server.test.ts`. + +**Interfaces:** `proxyApi` allows `POST` for exactly `hints`, `intents`, `boards/control`; GET allow-list unchanged; +any other method/path pair 405/404 as now. POST checks per Global Constraints (403 `cross-site request refused`; 415 +for a non-JSON content type; 413 over 16 KiB); forwards the body with `content-type: application/json`; 30 s timeout. + +- [ ] Step 1: failing tests: Review Focus 2 (cross-site, missing headers with foreign `Origin`, `text/plain`), body cap, + POST to a GET route 405, GET to a POST route 405, body forwarded byte for byte, token added. +- [ ] Step 2: FAIL. Step 3: implement. Step 4: PASS + `deno task check`. Step 5: commit `feat(web): proxy the write routes`. + +### Task 5: Browser — forms and controls + +**Files:** Modify `web/public/api.js` (`postJson(path, body, signal?)` throwing `ApiError`), `drawer.js`, +`board.js` (`pollNow()` on the object `mountBoard` returns; strip shows `paused`), `app.js` (pass scope/board and +`pollNow` in the drawer ctx), `style.css`. A pure helper module if logic warrants it (tested in +`tests/unit/web-public.test.ts`). + +**Interfaces / behaviour:** +- Board tab only (ctx has scope and board). Memory tab, below the content: + - **Add hint** (textarea + Add) on every node; `about` = the node id. + - **Add intent** ("Try …", optional "Done when", optional "Give up when") on the goal and on facts (`from` = the + fact); shown only while the board is running or paused; shows "this board has used of intents" (or "no + limit") before submitting. + - Truncated board → a warning that the new node may not appear. +- Goal drawer: **Controls** — Pause lead / Resume lead / Stop (confirm first, in-page, no browser dialog) / Restart + (stopped boards, not done), and the intent limit box with Save and the note about the board file. After Restart or a + limit-resume: "Now run `board-runner run ` again." +- Every form: disabled while in flight; success clears it, says "Added — it will appear in the graph shortly", calls + `pollNow()`; failure shows the server's error text. `textContent` only. + +- [ ] Step 1: implement. Step 2: `deno task check && deno task test:unit` PASS. +- [ ] Step 3: local smoke (local stack only, member/scope per `scripts/seed-web-toy.ts`, own server on `WEB_PORT=8788`): + add a hint and an intent, pause/resume, set the limit; the graph shows the new nodes and the strip shows `paused`. +- [ ] Step 4: commit `feat(web): add hints, intents and run controls from the drawer`. + +### Task 6: Deploy, end-to-end, docs + +**Files:** Modify `README.md` (Web UI section), `CLAUDE.md` (Web UI paragraph: no longer read-only), `runner/README.md`, +the design doc (status, builder's calls). + +- [ ] Step 1: **ask the person** to redeploy `web-api`; only on a yes: `supabase functions deploy web-api --use-api --project-ref --yes`. +- [ ] Step 2: **ask the person** for a toy-board run on hosted (`agent-memory-tool`, skill link pointed at the worktree + for the run, restored after). Check: the lead's `round:` tags increase by one per round; Pause → lead ends + `BOARD-LEAD paused`, workers finish open intents, runner checks every ~2 min; a person intent added while paused is + claimed by a worker; Resume → planning continues; a hint appears and the lead's next round mentions weighing it; + lowering the limit stops the board; raising it resumes. Delete the toy board afterwards. +- [ ] Step 3: run everything (check, unit, int, pgTAP, runner) — PASS. +- [ ] Step 4: docs. Step 5: commit `docs: web UI writes and run controls`. + +## Self-review + +- Spec coverage: shapes (T3), routes and validation (T3), proxy (T4), browser forms, controls, warnings (T5), skill + commands, paused branch, drop protection, start/work changes (T2), runner paused line and heartbeat (T1), redeploy + consent and toy check (T6), builder-check decisions (Global Constraints, T3, T5). +- Types: `transition` actions match the route's `action`; `LeadKind "paused"` matches lead.md's line; `pollNow` from + T5's board.js is what the drawer calls. From 66f183a369f63e18fefb111dced5d6d2bce3f29a Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:20:36 +0000 Subject: [PATCH 03/14] feat(runner): a paused lead keeps the run alive and is checked every 2 minutes Co-Authored-By: Claude Opus 5.5 --- runner/README.md | 3 +++ runner/board_runner/protocol.py | 5 +++- runner/board_runner/scheduler.py | 16 +++++++++--- runner/tests/test_protocol.py | 13 +++++++++- runner/tests/test_scheduler.py | 42 ++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 6 deletions(-) diff --git a/runner/README.md b/runner/README.md index 8905c1c..71c27c2 100644 --- a/runner/README.md +++ b/runner/README.md @@ -32,6 +32,9 @@ runner/board-runner status boards/my-board.toml - **Watch the lead:** `tmux attach -t board-`, and detach with Ctrl-b d. You can talk to the lead between rounds. The runner only sends a command after your input box has been empty for 30 seconds. - **Pause commands to the lead:** `touch ~/.board-runner//hold`. Delete the file to resume. +- **A paused board:** when the lead ends a round with `BOARD-LEAD paused`, the runner keeps running, keeps filling + worker slots from `free`, and asks the lead for a round every 2 minutes instead of every `round_every_minutes`, so a + resume is seen quickly. - **Ctrl-C once:** start no more workers, let the running ones finish, then exit. The board stays running, so a later `run` carries on with it. **Ctrl-C twice:** kill the workers now; their claims lapse after `claim_minutes`. - **The lead needs you:** if a lead turn ends without a `BOARD-LEAD` line, for example because the lead asked you diff --git a/runner/board_runner/protocol.py b/runner/board_runner/protocol.py index eb18b18..5c31279 100644 --- a/runner/board_runner/protocol.py +++ b/runner/board_runner/protocol.py @@ -12,7 +12,7 @@ from typing import Literal WorkKind = Literal["fact", "none", "partial", "stopped", "lost"] -LeadKind = Literal["running", "candidate", "done", "stopped", "outgrown", "refused", "none"] +LeadKind = Literal["running", "paused", "candidate", "done", "stopped", "outgrown", "refused", "none"] StartKind = Literal["created", "exists", "resumed", "not-running", "lost"] @@ -47,6 +47,7 @@ class StartResult: "stopped": re.compile(r"^BOARD-WORK stopped$"), } _LEAD_RUNNING = re.compile(r"^BOARD-LEAD running free=(\d+) open=(\d+)$") +_LEAD_PAUSED = re.compile(r"^BOARD-LEAD paused free=(\d+) open=(\d+)$") _LEAD_CANDIDATE = re.compile(r"^BOARD-LEAD candidate (\S+) free=(\d+) open=(\d+)$") _LEAD_PLAIN = re.compile(r"^BOARD-LEAD (done|stopped|outgrown)$") _LEAD_REFUSED = re.compile(r"^BOARD-LEAD refused (\S+) (\S+)$") @@ -85,6 +86,8 @@ def parse_lead(text: str | None) -> LeadResult: return LeadResult("none") if m := _LEAD_RUNNING.match(line): return LeadResult("running", free=int(m.group(1)), open=int(m.group(2))) + if m := _LEAD_PAUSED.match(line): + return LeadResult("paused", free=int(m.group(1)), open=int(m.group(2))) if m := _LEAD_CANDIDATE.match(line): return LeadResult("candidate", free=int(m.group(2)), open=int(m.group(3)), ref=m.group(1)) if m := _LEAD_PLAIN.match(line): diff --git a/runner/board_runner/scheduler.py b/runner/board_runner/scheduler.py index 14386b9..11fc66f 100644 --- a/runner/board_runner/scheduler.py +++ b/runner/board_runner/scheduler.py @@ -16,6 +16,7 @@ BACKOFF_SECONDS = 60 LEAD_BUSY_WARN_SECONDS = 15 * 60 MAX_FAILED_MEASUREMENTS = 5 +PAUSED_HEARTBEAT_SECONDS = 120 # --- events -------------------------------------------------------------- @@ -116,6 +117,7 @@ def __init__(self, bf: BoardFile, now: float, lead_label: str): self.wanted = False self.free_hint = 0 self.draining = False + self.lead_paused = False self.interrupts = 0 self.shutdown_sent = False self.measure = _Measurement() @@ -156,7 +158,7 @@ def poll_send(self, now: float) -> str | None: if self.lead_pending or self.needs_person or self.draining or self.shutdown_sent: return None measured = self.measure.results[0] if self.measure.results else None - heartbeat_due = now - self.last_sent >= self.bf.round_every_minutes * 60 + heartbeat_due = now - self.last_sent >= self._heartbeat_seconds() if measured is None and not self.wanted and not heartbeat_due: return None prompt = lead_prompt(self.bf.board, self.lead_label, measure=self.bf.measure is not None, measured=measured) @@ -191,8 +193,9 @@ def _lead_turn(self, result: LeadResult, now: float) -> list: ) ] self.needs_person = False + self.lead_paused = result.kind == "paused" actions: list = [] - if result.kind in ("running", "candidate"): + if result.kind in ("running", "paused", "candidate"): self.free_hint = result.free or 0 if result.kind == "candidate": actions += self._enqueue_candidate(result.ref or "") @@ -262,13 +265,14 @@ def _tick(self, now: float) -> list: if now - state.started_at >= state.worker.timeout_minutes * 60: state.killing = True actions += [KillWorker(index), Release(state.label or "", state.worker.timeout_minutes)] - if self.lead_pending and now - self.last_sent >= 2 * self.bf.round_every_minutes * 60: + heartbeat = self._heartbeat_seconds() + if self.lead_pending and now - self.last_sent >= 2 * heartbeat: # No Stop event for two heartbeats: the lead was interrupted, is stuck at a prompt, or died mid-turn. self.lead_pending = False self.needs_person = True actions.append( Warn( - f"The lead has had no turn end for {2 * self.bf.round_every_minutes} minutes; it may need you. " + f"The lead has had no turn end for {round(2 * heartbeat / 60)} minutes; it may need you. " f"Look with: tmux attach -t board-{self.bf.board}" ) ) @@ -291,6 +295,10 @@ def _interrupt(self) -> list: # --- helpers -------------------------------------------------------- + def _heartbeat_seconds(self) -> int: + """How often the lead is asked for a round: every 2 minutes while the board is paused, so a resume is seen.""" + return PAUSED_HEARTBEAT_SECONDS if self.lead_paused else self.bf.round_every_minutes * 60 + def _exclusive_hold(self) -> bool: m = self.measure return self.bf.measure is not None and self.bf.measure.exclusive and (m.current is not None or bool(m.queue)) diff --git a/runner/tests/test_protocol.py b/runner/tests/test_protocol.py index b61f133..a30666b 100644 --- a/runner/tests/test_protocol.py +++ b/runner/tests/test_protocol.py @@ -63,8 +63,19 @@ def test_refused(self): LeadResult("refused", holder="me", until="2026-11-25T10:00:00Z"), ) + def test_paused(self): + self.assertEqual(parse_lead("BOARD-LEAD paused free=2 open=3"), LeadResult("paused", free=2, open=3)) + def test_none(self): - for text in (None, "", "asked a question", "BOARD-LEAD running free=x", "BOARD-LEAD candidate free=1 open=1"): + for text in ( + None, + "", + "asked a question", + "BOARD-LEAD running free=x", + "BOARD-LEAD candidate free=1 open=1", + "BOARD-LEAD paused", + "BOARD-LEAD paused free=1", + ): with self.subTest(text=text): self.assertEqual(parse_lead(text), LeadResult("none")) diff --git a/runner/tests/test_scheduler.py b/runner/tests/test_scheduler.py index 843da30..4dc059f 100644 --- a/runner/tests/test_scheduler.py +++ b/runner/tests/test_scheduler.py @@ -26,6 +26,10 @@ def running(free, open_=None): return LeadTurn(LeadResult("running", free=free, open=free if open_ is None else open_)) +def paused(free, open_=None): + return LeadTurn(LeadResult("paused", free=free, open=free if open_ is None else open_)) + + def fact(): return WorkResult("fact", "confirmed", "i1") @@ -118,6 +122,44 @@ def test_heartbeat(self): self.assertIsNone(s.poll_send(1199)) self.assertEqual(s.poll_send(1200), ROUND) + def test_paused_fills_slots_from_free(self): + s = self.make() + self.assertEqual(s.on_event(paused(5), 1), [StartWorker(0), StartWorker(1)]) + + def test_paused_does_not_drain(self): + s = self.make() + s.on_event(paused(0), 1) + self.assertFalse(s.draining) + self.assertEqual(s.on_event(Tick(), 2), []) + + def test_paused_heartbeat_is_two_minutes(self): + s = self.make() + s.on_event(paused(0), 0) + self.assertIsNone(s.poll_send(119)) + self.assertEqual(s.poll_send(120), ROUND) + + def test_running_heartbeat_stays_round_every_minutes(self): + s = self.make() + s.on_event(running(0), 0) + self.assertIsNone(s.poll_send(120)) + self.assertEqual(s.poll_send(1200), ROUND) + + def test_resume_restores_the_heartbeat(self): + s = self.make() + s.on_event(paused(0), 0) + self.send(s, 120) + s.on_event(running(0), 130) + self.assertIsNone(s.poll_send(130 + 120)) + self.assertEqual(s.poll_send(120 + 1200), ROUND) + + def test_paused_lead_pending_warning_uses_the_paused_interval(self): + s = self.make() + s.on_event(paused(0), 0) + self.send(s, 120) + self.assertEqual(warns(s.on_event(Tick(), 120 + 239)), []) + actions = s.on_event(Tick(), 120 + 240) + self.assertTrue(any("no turn end for 4 minutes" in w.message for w in warns(actions))) + def test_pending_blocks_sends(self): s = self.make() s.on_event(running(0), 0) From a7057d3fa7f6bb71b35ed03b2f8041c486590c79 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:22:46 +0000 Subject: [PATCH 04/14] feat(skill): pause and resume the lead; person intents; drop protection Co-Authored-By: Claude Opus 5.5 --- skills/blackboard/SKILL.md | 54 +++++++++++++++++++++++++++++++++++--- skills/blackboard/lead.md | 40 +++++++++++++++++++++++----- skills/blackboard/start.md | 3 ++- skills/blackboard/work.md | 8 +++--- 4 files changed, 91 insertions(+), 14 deletions(-) diff --git a/skills/blackboard/SKILL.md b/skills/blackboard/SKILL.md index 94ca981..ba977ae 100644 --- a/skills/blackboard/SKILL.md +++ b/skills/blackboard/SKILL.md @@ -1,6 +1,6 @@ --- name: blackboard -description: Use when the user runs /blackboard, or asks to start, lead, join, work on, check, hint at or stop a shared board, blackboard or shared goal that several Claude Code sessions or models work on in parallel through the shared-memory MCP server. +description: Use when the user runs /blackboard, or asks to start, lead, join, work on, check, hint at, pause or stop a shared board, blackboard or shared goal that several Claude Code sessions or models work on in parallel through the shared-memory MCP server. --- # Blackboard @@ -23,8 +23,11 @@ reasons about the whole board and writes intents. Any number of sessions work, o | `work ` | Read `work.md` and follow it: one work cycle | | `hint ` | Below | | `status ` | Below | +| `pause ` | Below | +| `resume-lead ` | Below: undoes `pause` | +| `intent ` | Below | | `stop ` | Below | -| `resume [max_intents=]` | Below | +| `resume [max_intents=]` | Below: continues a board stopped at its intent limit, not a paused one | | `release label=