commit 5ed0cf48d827b61184abe8ed960304cac2d660d1
parent f682e1a92f6acd681fadc2f0ae2e002d419e0507
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 13 Oct 2026 13:38:38 -0400
plans: release 27 S9, as shipped — the Claude Code balance
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,10 @@
# Changelog
## [Unreleased]
+- **Claude Code follows the generation balance: `/gen`, and the MCP's `generation_policy` and `generate`.** `generation_policy` shows where each generation task runs (`code` = this Claude Code session, `api` = the Claude API, `local` = the local model), on which model, the caps and the day's Claude API spend against the daily cap; with a preset or a task and route it moves the balance, only when you ask. `generate` runs a task as a `report-draft` job on the editor (a sweep, a revision of a report or its video, a narration, a research run with its autonomy, or a sweep continuing a research run), refuses one routed to Claude Code, and with `wait: true` follows the job and answers the iteration it made: its cost, the ops it applied and refused, its checks and where its files are, with what to review before it is made current. `/gen` (`.claude/commands/gen.md`, in the repo) wraps both: tasks routed away are run through `generate` and reviewed, tasks routed to Claude Code are done in the session. It replaces the stopgap's user-level `/gen`. Claude Code picks the tools up on its next start; they need the MCP registered with `ARCHILYZER_EDITOR_URL` and `WORKER_TOKEN`.
+- **`/sweep` follows the policy too.** When sweeps are routed to the API or the local model, the `/sweep` plan's first step is `generate`, then a review of what it made — read the iteration's report, spot-check its quotes with `get_transcript`, then recommend making it current or a revision — instead of running the sweep in the session. `via=code` (or `api`, `local`) in the request overrides the policy for that plan, and `article=` names the article. With no editor configured the plan is unchanged. `/ask` still answers in the conversation, and names the tasks the policy routes away.
+- **`archilyzer gen policy | preset | set | run`** is the same balance from a terminal: through the editor when it answers, else `settings.json` through the settings writer when no editor is listening (never beside one that is there but silent). `gen run <task> [<question or feedback>] --article <id> …` enqueues the job as `pnpm ops report-draft` does (`--wait` follows it) and exits 3, running nothing, when the task is routed to Claude Code; `--via` overrides once.
+- **Two new reads: `pnpm ops get generation-usage [<day>]`** (the day's Claude API spend and the daily cap) **and `pnpm ops get iterations <article>`** (an article's iterations and which is current). Needs a restart of the editor.
- **Research runs: the editor finds what an article's archive lacks and asks for it.** `pnpm ops report-draft --json '{"task": "research", "article", "question", "channels"?, "autonomy"?}'` runs a research iteration: a model searches the corpus, the web and archive.org (an item's file list included), then proposes each acquisition it needs (an archive.org import, a video, a new channel, a post, a transcription, a persist) with its reason, evidence links and estimated size. Under `propose` every one waits for your yes or no; under `limits` imports into existing channels under the caps run at once; under `auto` everything runs, through the editor's own queues and holds, until a cap. A new channel is always created on no site, an X channel is never put on one, and a Twitch VOD is never fetched, in every mode. The proposals are kept in the iteration's `proposals.json`.
- **`pnpm ops research-approve` settles a research run.** `{"article", "iteration", "ids": ["p01", …], "approve": true | false, "note"?}` runs the approved proposals through the editor (past the run's autonomy and caps, never past a standing rule) or rejects them; with no ids it answers the run's state. Every call first checks the jobs of what was enqueued, so the run moves from waiting to ready as they finish. `report-draft {"task": "sweep", "article", "iteration": <the research run>}` then continues it: a sweep over the run's channels and every channel it acquired into, its question by default (refused while the run still waits, unless `"force": true`).
- **New settings: `generation.research`** (SETTINGS.md): a research run's default autonomy (`propose`), and its limits — 20 items, 5 GB and 6 hours of transcription a run, new channels and post walks waiting for approval under `limits`. `generation.routes.research` says where a research run runs (`api` in the balanced preset); a settings file from before keeps its preset.
diff --git a/plans/release-27.md b/plans/release-27.md
@@ -515,6 +515,47 @@ Gates:
- `docs env|files|cli --check`, `settings example --check`: clean.
- Editor build (heavy slot, 5 GB cap): clean in 49 s, `/api/ops/research-approve` and `/api/ops/report-draft` built. No editor e2e: the route has no spec of its own (its door and the job are in `_researchRuns.test.ts`).
+### S9, as shipped (2026-10-13, lane F, `r27/gen-balance`)
+
+The Claude Code balance (D8), on `r27/gen-balance` from `r27/integration` `5962c543`, `b3f14445` (S11's backend) merged in.
+
+| Commit | What |
+| --- | --- |
+| `39a0b852` | editor reads `GET /api/ops/generation-usage[?day=]` and `GET /api/ops/iterations?article=[&n=]`; `pnpm ops get generation-usage` / `get iterations`; COMMANDS.md; `_generation.test.ts` |
+| `55fdbd11` | `mcp/src/generation.ts` (`generation_policy`, `generate`, `planGeneration`); `instructions.ts` routing (`routeFor`, `reviewGuidance`, the routed sweep plan, the ask's routed-tasks step); `via=` / `article=` in a plan request; the pinned tool list |
+| `945312e6` | `common/bin/gen.ts` and its four `archilyzer gen` rows; COMMANDS.md |
+| `7eb937b0` | `.claude/commands/gen.md`; mcp/README.md; WORKER_TOKEN / ARCHILYZER_EDITOR_URL docs (ENVIRONMENT.md) |
+| `6268f4d0` | after S11: `generate`'s `autonomy`, the continuation's refusal, a research iteration's summary; `gen run --autonomy` |
+| (this commit) | this record; the CHANGELOG bullets |
+
+- **`generation_policy`** reads `GET /api/ops/settings?key=generation` and `GET /api/ops/generation-usage`: each task's route and model, the caps, the day's API spend against the daily cap. With `preset`, or `task` + `route`, it writes `POST /api/ops/settings {patch: {generation: {routes}}}` — the whole routes object, since the writer merges one level. It renders no other field: no key-file path, no projects root.
+ - **Ruled here:** the release 19 rule keeps settings out of the MCP; the generation routes are its one exception (D8), only when the operator asks.
+- **`generate`** posts `report-draft` with the tool's own checks first (task, article, numbers, lists, `autonomy` only for research, `via` or `model`).
+ - The model is `model`, else `via`'s route's, else the editor's choice by the route.
+ - A task routed to `code` is refused before anything is enqueued. A sweep with an `iteration` (continuing a research run) says so in its own words.
+ - `wait: true` polls `GET /api/ops/job/<id>` every 5 s (a progress notification each, carrying the last log line) up to `wait_seconds` (90, at most 300). It then reads the `@@report-draft` line and `GET /api/ops/iterations?article=&n=`.
+ - The answer: status, cost per model, minutes, ops applied and refused (each refusal's why), the failing checks, the files on the editor's disk, and the review to do. A research iteration gets its phase, notes and proposals, the operator's approval and the continuation instead.
+ - A wait that runs out answers the job, article and iteration to resume with. Nothing is re-enqueued.
+- **The plans.** `sweep_plan` / `ask_plan` read the policy at plan time (`planGeneration`). With no editor configured there is no policy, and the plan is unchanged. An editor that fails adds a note, and the plan is this session's.
+ - A sweep routed to `api` or `local`: step 1 is `generate`, step 2 the review (read `sweep.md`, spot-check at least five quotes with `get_transcript`, read checks and refused ops, recommend making it current or a revision), step 3 report back. An unknown scope still halts first. A scope not given is asked for after the generate step, which names the channels as `<the slugs I choose>`.
+ - Routed to `code`, the plan is byte-identical to the unrouted one (tested), and `via=code` makes it so whatever the policy.
+ - **Ruled here:** an ask is answered in the conversation whatever the policy (the policy routes generation tasks, and an answer is not one). Its plan gains one last step naming the routed tasks, so a follow-up goes the right way. With every task routed to code, it is unchanged.
+ - **Ruled here:** making an iteration current stays the operator's (umtool's Iterations tab). The review recommends; it does not make current.
+- **`archilyzer gen policy|preset|set|run`.**
+ - Through the editor's ops API when it answers, with `pnpm ops`'s env.
+ - When nothing listens (connection refused), settings.json through `writeSettings` and the ledger off disk. An editor that is there but silent, or refuses the token, is an error, and the file is never written beside it.
+ - `run` asks the policy and exits 3 with nothing run when the task is routed to code. Otherwise it runs `pnpm ops report-draft` as a child (`--wait` follows it the same way).
+- **`.claude/commands/gen.md`** is over MCP tools only. The operator's user-level `/gen` is untouched; S10's docs retire it.
+
+Gates:
+- tsc clean (all packages).
+- mcp 342/342 (19 new: `generation.test.ts` 13; instructions 5, promptRequest 1; the pinned list gains `generation_policy`, `generate` after `notes`).
+- common 3991/3991 (7 new, `bin/gen.test.ts`); editor unit 285/285 (3 new, `_generation.test.ts`); `test:scripts` 852 pass + 3 skipped (1 new).
+- `docs env|files|cli --check`, `settings example --check`: clean.
+- Editor build (heavy slot, 5 GB cap): clean in 49 s; `/api/ops/generation-usage` and `/api/ops/iterations` built. No e2e: the two routes are read-only and covered by `_generation.test.ts` (their door, refusals and answers).
+
+Not done here: AGENTS.md's section on `.claude/commands/{ask,sweep}.md` does not name `gen.md` yet (S10's docs).
+
## Rollout
- Fast-forward `main`.