# Release 27 — report and video generation inside the application Status: **RATIFIED 2026-10-13 — D1–D9 as recommended** (r27 = move + test; strict quotes for generated, `inexact` a warning for existing; the qwen sweep pipeline ported). Research runs were added at ratification (S3b, S11; below). S0 landed on `r27/integration`. This plan supersedes slices Q1–Q5 of `plans/local-llm-report-media.md`. Its Q0 record, rulings and scope changes stand, and are the inputs here. ## Start here (the implementing session) Read before acting: - `AGENTS.md`; - `plans/STATE.md` and `plans/FACTS.md`; - `plans/tools/implementer-rules.md` (an implementer subagent's brief and review); - this plan; - `plans/local-llm-report-media.md`'s record: Q0's limits for the local model, and the scope changes. **The stopgap to port**, read for behaviour and never run against the live corpus beyond its own read-only tools: - `~/reports/local-reports/`: `claude_api.py`, `agentloop.py`, `api_sweep.py`, `local_sweep.py`, `revise.py`, `local_narrate.py`, `seed_version.py`, `dedupe_media.py`, `gen.py`, `bin/*`, `RUNBOOK.html`; - the POC page `umtool/{app/drafts,lib/drafts.ts,components/drafts,app/api/drafts}`. Its lessons are in this plan's tables. Don't re-derive them. **The orchestrator** runs in the primary checkout: - Worktrees: `pnpm wt add --from r27/integration`, then `link-fixture-public.sh`. - Merges are `--no-ff`; `main` moves by `git merge --ff-only` after the gates. - Rollout scripts are copied from `~/reports/release-26/scripts/r26-*.sh` with MERGE and LIVE re-guarded. The umtool rollout as last run is `~/reports/local-reports/logs/umtool-rollout.sh`. **Rules that bind every slice:** - No Claude session links or trailers anywhere; commits end with the `Co-Authored-By` line alone. - Heavy work goes through the heavy slot (`node scripts/queue-lock.mjs --heavy [--estimate MB] --`), with the 6 GB floor, one `next build` at a time. - `/tmp` is RAM; scratch goes in the job directory. - No hand edits to `transcripts/**` (the registry and CLI write). - No yt-dlp or ASR by hand. - Never print the API key or the operator's source-scrub files. The key file is `~/.config/archilyzer/anthropic.env`, mode 600, read by code only. - Candace data is local-only and never goes in fixtures. - Tests use synthetic fixtures and the fake Anthropic and ollama servers. Real API calls happen only in the live smoke, within its $3. - Do not boot a second editor against the real corpus. **The GPU** is an 8 GB card shared by ollama (qwen3:8b), Orpheus TTS and parakeet: - prompts ≤ 8k tokens and `num_ctx` ≤ 12k (a 13.8k prompt hung the GPU); - qwen3:14b is impractical. **Sonnet 5.5** (the default API model) returns a 400 for any of these: a non-default temperature, a forced `tool_choice`, or `thinking: disabled`. Use `thinking: between_tools`. Its thinking blocks are signed, so never edit history once one is present. ## Added at ratification: research (operator, 2026-10-13) Research by local or API agents, as in the Candace work: find archive.org files and download them, add channels and individual posts or videos for complete context, then report. - Each run's autonomy is selectable: propose-and-approve, auto within limits, or autonomous. - It may propose archive.org imports, new channels, posts, and transcription or persisting. - It is part of release 27 (slices S3b and S11). ## Facts found (survey, 2026-10-13) - **No Anthropic HTTP client exists.** The digest's metered lane shells out to the Claude Code CLI (`common/lib/digestApps.ts` `claudeCode`). - **The ollama call** is `ollamaDirect.run` in `digestApps.ts`. `acquireLlmSlot` (`common/controller/llmWorkers.ts:76`) verifies the model tag. `"llm"` is a WorkerKind, not a queue; the new queues are `draft:local` and `draft:api`. - **GPU arbitration:** - `digestYield.ts` makes digests yield to transcription. - `ttsFile.ts:397,404` (`transcriptionOnGpu`, `waitForGpu`) makes TTS wait for transcription. - TTS and ollama do not arbitrate with each other: a shared arbiter is new work. - **Job and ops plumbing:** - Kinds are in `common/jobs/jobKinds.ts` (`JobKindMeta`). - Ops are adapters only (`editor/app/api/ops/_lib.ts`), one route per action. The action list is `scripts/archilyzer-ops.mjs` `ACTIONS`. - Jobs are read through `editor/app/api/ops/_jobs.ts`. - **Settings:** a new key goes into `siteSettingsSchema` (`common/lib/settingsSchema.ts:1708`, order = file order). Docs are regenerated with `archilyzer settings example`. - **The registry:** `common/lib/report/registry.ts` (`writeArticle` 486, `patchArticle` 441, `configureArticle` 344, `withArticleStoreLock` 265). History is git commits ("Revision N", `report/revisions.ts`). - **verify-quotes** scores token recall against a 0.6 threshold (`common/lib/citations/verify.ts:34`). That is why a reversed quote passed at 0.85. - **MCP handlers are module-private.** Only `TOOLS` and `createServer` are exported (`mcp/src/server.ts:336,1210`); use the SDK's in-memory transport. - **`moment_base` is null for private builds.** It comes from `momentBaseFor` (`server.ts:164`), and a private site has no `siteUrl` (`common/lib/corpus.ts:306`). - **umtool:** - `lib/jobs.ts` runs steps as detached process groups, with cancel and a 15-minute timeout. - `report-to-video/build-video.mjs` exports `buildVideo` (4100) and `build-podcast.mjs` exports `buildPodcast` (275). - The editor-call pattern is `narrate-via-editor.mjs` / `fetch-via-editor.mjs`. - The manifest writers are in `lib/report/manifest.mjs`. - e2e is `umtool/e2e/*.spec.ts`, with an editor stub on `EDITOR_STUB_PORT`. - **The four owed bugs, located:** - The title `foot` is never set (`convertManifest.ts:428`) and its render has no guard (`render-cards.mjs:112`). - A trailing Coverage section becomes a bare chapter card (`convertManifest.ts` ~264). - Window coverage ignores `pad` (`fetchWindows.ts:379`, `fetchWindowManaged.ts:171`). - `umtool build --dry` resolves paths from cwd (`umtool/lib/report/driver.mjs:14,416`). - Also: `prepare --article` always includes every published article (`common/publish/reportHost.ts:156`). - **Tests:** `node:test` via `tsx --test` per package, plus root `test:scripts` for `.mjs`. The gates are `pnpm typecheck`, `pnpm test`, `docs env|files|cli --check`, `settings example --check` and `pnpm e2e:all`. - **The test kit (S0):** `common/testing/` — the fake Anthropic and ollama servers, the synthetic corpus and sweep fixtures; see its README. Importable as `yt-dlp-transcript-common/testing/`. common's test glob now reaches three levels (`lib/report/draft/*.test.ts`). ## Why The work is proven, but it runs in the wrong place. Since 2026-10-11, reports, revisions, narration and videos have been made without Claude Code by a stopgap in `~/reports/local-reports/`: - 2,850 lines of Python and bash; - driven by the umtool POC page `/drafts`, which spawns those scripts. Real runs went through it on qwen3:8b and Claude Sonnet 5 / 5.5: - an article with its video and podcast; - revisions of a report and of a video; - a model compared against another on the same base. It now has to become the application. That means: - TypeScript in `common/`, run as editor jobs, driven from umtool; - tested like everything else, with the same gates; - no scripts outside the repo, and no `~/.config` files but the API key. ## What moves, and where | Stopgap (`~/reports/local-reports/`) | What it does | Becomes | |---|---|---| | `claude_api.py` | Messages API over HTTPS. Key from env or a mode-600 file, never printed. Retries. Top-level `cache_control` plus a system breakpoint, 5m/1h TTL. Sonnet 5.5 rules (no temperature, no forced `tool_choice` so a strict tool instead, `thinking: between_tools`, append-only history). Price table and USD meter. | `common/lib/llm/anthropic.ts` | | ollama calls (`local_sweep.chat`, `agentloop`) | `/api/chat` with a `format` schema or tools, `think:false`, `num_ctx` ≤ 12k, the 8k prompt cap, `done:false` read as a GPU fault | `common/lib/llm/ollama.ts` (extends `digestApps.ts`'s call) | | `agentloop.py` | A tool loop on either provider. Claude server `web_search` and `pause_turn`. Local context fitting. Budget stop. | `common/lib/llm/agent.ts` | | `mcpclient.py` | The MCP over stdio | the MCP's tools **in process** (D2) | | `agentloop.web_search/web_fetch` | Paced DuckDuckGo search and a page reader, both read-only | editor actions `web-search` / `web-fetch` and an in-process paced module | | `api_sweep.py` | `/sweep` as an agent: the `sweep_plan` text, Haiku `extract_batch`, report-file tools, convert, verify-quotes, the strict check, one bounded repair round, prompt rules (no quotes in claims, moment links) | task `sweep` (agent) | | `local_sweep.py` (778) | A code-driven qwen sweep. The model proposes terms, judges, extracts and groups; code enumerates, windows, verifies, cites and covers. | task `sweep` (pipeline), D4 | | `revise.py` | Report and video revisions through checked ops (drop, claim, merge, move, add, section, title, summary; drop, move, heading, narration, trim, add_clip, title), agent tools, quotes untouched | tasks `revise-report`, `revise-video` plus pure op engines | | `local_narrate.py` | Card narration under `NARRATION_HARD_RULE`, the writing rules and the house taste, plus grounding checks (numbers and names in the report, no quotes read out, no tags, banned phrases) | task `narrate` plus `grounding.ts` | | `bin/local-article` | Writes the article, fetches windows (`fetch-windows`), prepares and checks (other articles' gaps only a warning; captures this article's post screenshots), runs `to-manifest`, fixes the manifest | a umtool job chain over existing CLIs and functions, with `prepare --only` | | `bin/local-video` + `with-editor.sh` | Editor TTS, `build-video --skip-fetch`, podcast, `attach-video`, dedupe | the same chain (`buildVideo` / `buildPodcast` are callable) | | `seed_version.py`, `dedupe_media.py` | Carries narration and links voices from the parent; hard-links identical segments and voices (only files never written in place) | `umtool/lib/report/iterations.mjs` | | `fix_manifest.py`, `windows_of.py`, `write-article.ts`, `apply-narration.mjs` | Glue | gone (the fixes land in `to-manifest`) | | `gen.py` plus `~/.config/archilyzer/generation.json` | The routing policy (code / api / local per task, presets, models) | settings key `generation` (D6), MCP `generation_policy` | | `~/.claude/commands/gen.md` | `/gen` for Claude Code | `.claude/commands/gen.md` in the repo, over MCP tools only (D8) | | umtool `/drafts` (`lib/drafts.ts`, `DraftsPanel.tsx`) | Runs, versions, copy with model, compare, cancel, channel picker, policy panel | `/articles/new` and an article's **Iterations** tab (S8) | ## Shape - **Vocabulary: an iteration.** An article's iterations are `i1`, `i2`, …. - "version" is taken: `Report.version` is the format version, and the site history says "Revision N". - "draft" is taken: an unpublished article is a draft. - "take" is taken: umtool's alternative renders are takes. - FACTS.md gets the hazard. - **An iteration** is one generation's result plus its provenance: - **kind:** `sweep`, `revise-report` or `revise-video`; - the model, the parent iteration, the feedback or question, `copyOf`; - cost and tokens per model, ops applied and refused, minutes, checks. - **Iteration storage (D1).** - The report side is kept in the article registry at `transcripts/reports//iterations//`: `report.json`, `sweep.md`, `iteration.json` and the transcript of turns. Every write goes through `registry.ts`: locked, validated, atomic. - The article's own `report.json` is the **current** iteration, made current by "use this iteration". It is never written by a generation. - Video projects and renders live off the corpus disk, under `settings.generation.projectsRoot` (default `~/reports/articles//i/`). The iteration records its project path. - **Generation runs as editor jobs**, in two queues: - `report-draft` on `draft:local`. It yields to transcription AND to TTS: a new shared GPU arbiter, with `digestYield.ts`'s pattern extended to `ttsFile.ts`'s `waitForGpu`. It unloads ollama (`keep_alive: 0`) at the end. - `report-draft` on `draft:api`: network work with its own concurrency, never the GPU lane or the heavy slot. - Per-job and daily USD caps (D6). - One ops action, `pnpm ops report-draft {task, article, iteration?, model, …}`, plus `job cancel`. - The job writes the iteration through the registry. - **The pipeline steps stay code and run as a umtool job chain over an iteration:** - make current; fetch windows (editor); prepare `--only `; capture this article's post screenshots (editor); - `to-manifest`, seeded from the parent; voices (editor TTS); `buildVideo`; `buildPodcast`; `attach-video`; dedupe. - umtool's job runner already kills a step's process group. - **The corpus tools are the MCP's tools** (D2): - `mcp/` exports `callTool(name, args, source)` over the SDK's in-memory transport, so the agent sees exactly what Claude Code sees. - `source` is forced. - The read-only set plus `notes` (list and read). - `web-search` / `web-fetch` for the local model; Claude uses its server-side search. - **Moment links never depend on `moment_base`.** A private site's build has no `siteUrl` (`corpus.ts:306`), so `moment_base` falls back to the platform URL or null. Drafting builds citation links from `(slug, id, seconds)` against the article's citation origin. The prompt rule and the YouTube→moment rewrite stay as a backstop. - **Quotes.** - verify-quotes scores token recall against a 0.6 threshold (`citations/verify.ts:34`), which passed a reversed quote at 0.85. - A strict check is added: every quoted fragment verbatim (normalized) in the record's text within ±90 s. - It refuses a generated quote, and verify-quotes reports it as a new status `inexact` (D3). - Claims never carry quoted words. convertSweep makes every quoted span before a link that link's quote. This is enforced by the op engine and the prompts. - **Research** (added 2026-10-13, operator) means doing what the Candace work did, on qwen or the API: find relevant archive.org files and download them; add channels and individual posts or videos for complete context; then report. - **A research run is an iteration of kind `research`**, in phases: - **discover:** search the corpus, the web and archive.org, and read item file lists; - **propose:** acquisitions, each with its reason and evidence links; - **acquire:** each one an editor job, paced and polite, on the platform queues; - **wait:** resumable, showing the jobs it waits on; - **continue:** a `sweep` iteration over the widened scope, including the new channels. - **Autonomy is chosen per run** (default from settings): - `propose`: the operator approves each acquisition in umtool, yes or no per item; - `limits`: imports into existing channels under the caps run on their own, and the rest waits for approval; - `auto`: the agent enqueues it all itself, still through the editor. - **Limits** are `settings.generation.research.{maxItemsPerRun, maxGbPerRun, maxTranscribeHours}`, and whether new channels and post walks need approval. - **What it may propose:** - archive.org search and import (`searchArchiveOrgItems` in `common/controller/archiveOrgImport.ts:236`, plus `archive.org/metadata` reads, `import-archive-org`, `import-video`); - new channels (`create-channel`, always created on NO site: private); - posts (`fetch-posts` including the older walk, `capture-posts`, and a NEW `import-post {slug, url}` for one X or Bluesky post); - transcription and persisting (`transcribe-one`, priority bumps, `persist-videos`). - **Proposal state lives in the iteration** (`proposals.json`): each one's action, args, reason, evidence, status (proposed, approved, rejected, enqueued, done or failed) and jobId. - **Standing rules hold:** - polite scraping (one stream, real gaps, back off on a 429, the editor's holds and cooldowns); - no yt-dlp or gallery-dl by hand; - X channels never go on a site; - no re-fetching expired Twitch VODs; - subjects the operator marks local-only stay on no site. - **Claude Code integration** (D8): - MCP tools `generation_policy` and `generate`. `generate` enqueues `report-draft` through the editor, like `enqueue`. - `sweep_plan` / `ask_plan` read the policy. When a task routes to `api` or `local`, the plan tells Claude Code to call `generate`, wait, and REVIEW the result instead of doing the work itself. - The policy's presets (`code`, `balanced`, `api`, `local`) move the balance either way. - `.claude/commands/gen.md` in the repo wraps it. ## Slices | # | Slice | Contents | Depends on | Gate | |---|---|---|---|---| | S0 | Setup (orchestrator) | `r27/integration` from `main`. The FACTS.md naming hazard ("iteration"; "version", "revision", "draft", "take" are taken). Synthetic fixtures: sweep.md variants (quotes in claims, several quotes per link, posts only, paragraphs between findings), manifests, a fixture corpus record with cues. **No real transcripts.** Fake servers: Anthropic Messages (scripted turns, `pause_turn`, server tool blocks, 400s for the Sonnet 5.5 rules) and ollama (`/api/chat` with tools and `format`). | — | — | | S1 | Providers and agent loop | `common/lib/llm/{anthropic,ollama,structured,agent,meter,prices}.ts`. The key from `settings.generation.apiKeyFile` or env, never logged (test: the key string appears in no log, error or job record). Caching, TTL, strict-model rules, the strict structured answer, retries, `pause_turn`, budget stop, append-only once thinking blocks appear, local context fitting. | S0 | unit vs the fakes | | S2 | Checks and op engines | Strict check in `citations/verify.ts` plus the verify-quotes `inexact` status. `report/draft/grounding.ts` (narration). `report/draft/reportOps.ts`: the sweep.md model (claim / sep / rest split at the first quote; sections keep body order) and the ops, including merge chains. `videoOps.ts` (trim bounds, add_clip from citations, narration via grounding). | S0 | unit: **round-trip over every fixture**; op batches number against the start of the batch; refusals carry reasons | | S3 | Tools | `mcp/` exports `callTool` (in-memory transport, `source` forced, a read-only allowlist, `notes` list/read). Editor actions `web-search` / `web-fetch`: paced one at a time with 3 s gaps, read-only, through `_lib.ts` adapters, COMMANDS.md. An in-process paced module for jobs. | S0 | unit; the mcp suite unchanged | | S4 | Iterations store | `common/lib/report/iterations.ts`: create, list, read, `makeCurrent` (writes `report.json` through `writeArticle`), `copy` (same base, another model), lineage, `projectOf`. The registry's locking. `archilyzer reports iterations `. | S0 | unit: lineage, current, copy, locking under contention | | S5 | Tasks | `report/draft/tasks/{sweep-agent,sweep-pipeline,revise-report,revise-video,narrate}.ts` on S1–S4. Each returns an iteration. The prompts are read from `instructions.ts` and `authoringRules.ts` (rules moved there once). | S1 S2 S3 S4 | unit vs fakes over the fixture corpus; one recorded transcript per task | | S6 | Editor jobs, settings, ops | Job kinds `report-draft` (queues `draft:local`, `draft:api`). The GPU arbiter shared with TTS and transcription. Unloading ollama. Caps. `pnpm ops report-draft` + route + `job cancel`. Settings key `generation` (routes, models api/local/extractor, caps, cacheTtl, apiKeyFile, projectsRoot, web provider) plus SETTINGS.md. Usage rows for the metered lane (the digest "metered" precedent). | S5 | unit; one editor e2e spec (`report-draft` against the fakes) | | S7 | Pipeline chain and owed bugs | umtool chain over an iteration (above). `reports prepare --article --only`. Capture this article's posts. `to-manifest`: title `foot` (`convertManifest.ts:428` + a guard at `render-cards.mjs:112`), no silent Coverage end card, the parent seed. `fetch-windows` folds `pad` into coverage (`fetchWindows.ts:379`, `fetchWindowManaged.ts:171`). `umtool build --dry` resolves from the module, not cwd (`driver.mjs:14,416`). Dedupe (segments and voices only). | S4 | unit per bug; `umtool` build e2e | | S8 | umtool UI | `/articles/new`: question, a channel picker over the editor's channels, model, caps. The article's **Iterations** tab: the list, current article and current video, new iteration (target report or video, model, feedback), copy with model, per-step model, cancel, cost, live job progress from `/api/ops/job`. `/articles//compare?a=&b=`: side by side, with ops applied and refused. The policy panel (writes `generation` through the editor's settings action). `/drafts` redirects. | S6 S7 | e2e: `article-new.spec`, `article-iterations.spec`, `article-compare.spec` over the editor stub + fake LLM | | S9 | Claude Code balance | MCP `generation_policy` and `generate` (enqueue + follow). `instructions.ts`: the routing step in `sweep_plan` / `ask_plan`, plus review guidance. `.claude/commands/gen.md`. `archilyzer gen policy\|preset\|set\|run` (CLI over the same settings). | S6 | mcp unit; protocol test lists the tools | | S3b | Research tools | Agent and editor actions `archive-search` (over `searchArchiveOrgItems`) and `archive-item` (the metadata file list, sizes and formats), read-only and paced. The NEW editor action `import-post {slug, url}`: one X post through the existing gallery-dl path, or one Bluesky post by URI, into the channel's posts archive. Acquisition tools for the agent, each mapped to its existing editor action and checked against the run's autonomy and limits before it is enqueued. | S0 | unit against a fake archive.org and the editor stub | | S11 | Research runs | Task `research`: the phases, `proposals.json`, autonomy and limits, resuming while it waits on jobs. Approve, reject and enqueue through `pnpm ops research-approve {article, iteration, ids, approve}`. "Continue" starts the sweep iteration over the widened scope. The `generation.research` settings. The MCP `generate` accepts task `research`. umtool: the research queue in the Iterations tab (yes/no per proposal, live acquisition job status, continue) and the autonomy selector on `/articles/new`. | S5 S6 S3b; its UI after S8 | unit; e2e `article-research.spec` (fake LLM + editor stub) | | S10 | Migration, docs, retire | `archilyzer reports import-local-runs` (dry run by default): the stopgap's kept runs become iterations (D9), and `generation.json` becomes settings. OPERATING.md "Generate and iterate". `umtool/docs/authoring.md` "Generating with a model". REPORT.md. CHANGELOG. `plans/STATE.md`. The stopgap's RUNBOOK points here. Docs include "Research". The test runs (about 320 MB) are deleted after the operator's OK. | S8 S9 S11 | the import's dry run reviewed by the operator | **Dependency graph.** S0 → {S1, S2, S3, S3b, S4}; S5 ← S1–S4; S6 ← S5; S7 ← S4; S8 ← S6+S7; S9 ← S6; S11 ← S5+S6+S3b (its UI after S8); S10 ← S8+S9+S11. ``` S0 ─┬─ S1 ─┐ ├─ S2 ─┼─ S5 ─ S6 ─┬─ S8 ─────┐ ├─ S3 ─┤ ├─ S9 ─────┼─ S10 ├─ S3b ┼───────────┴─ S11 ────┘ └─ S4 ─┴─ S7 ──────── S8 ``` **Lanes.** At most three Opus implementers at once, each in its own worktree from `r27/integration`: - **Phase 1:** lane A S1; lane B S2 → S3 → S3b; lane C S4 → S7. - **Phase 2:** S5 then S6 (one implementer, since they share the job's surface). - **Phase 3:** S8 ∥ S9 ∥ S11 (S11's umtool queue lands after S8), then S10 (whose docs include "Research"). Each slice is merged `--no-ff` as it finishes, with its suites re-run. ## Gates (on the `r27/integration` tip) - `pnpm typecheck`, `pnpm test`, `docs env|files|cli --check`, `settings example --check`. - The four builds through the heavy slot (capped). - `pnpm e2e:all`: editor, export, umtool (with `article-new`, `article-iterations`, `article-compare` and `article-research`), the editor's `report-draft` spec, and homepage. A red is re-run alone; a red that stays red blocks. - **Live smoke** (operator's key, ≤ $3, through the UI): - a Sonnet 5.5 sweep on a small channel; - a report iteration and a video iteration; - a qwen narration; - a copy-with-model compare; - the chain to a video and podcast; - a cancel mid-step; - `/gen` from Claude Code routing one task to the API; - a small research run in `propose` mode on a public subject (archive.org search, one small item approved and imported, then continue into a sweep). - Privacy greps on `main..r27/integration`, counts only: - no session links; - no key-like strings (`sk-ant-`); - no Candace data; - no `~/.config/archilyzer` contents; - the source mirror's `--check`. ## Record ### S0, as shipped (2026-10-13, orchestrator) `r27/integration` from `main` `9f05d557`, in the worktree `r27-integration`. | Commit | What | | --- | --- | | `f88aaf8d` | `common/testing/`: the fake Anthropic and ollama servers, the synthetic corpus (`synth-kitchen`, `synth-other`, invented posts), six sweep.md variants, three derived reports and manifests, `regenerate.ts`; the `./testing/*` export; common's test glob reaches three levels | | (this commit) | FACTS "A generated report is an ITERATION"; this plan brought up to the ratified text (research: S3b, S11; the survey's facts; graph, lanes, smoke) | Gates: common tsc clean; common tests 3827/3827 (9 new, `testing/fakes.test.ts`). Found: as committed, the `paragraphs` fixture manifest shows two of the owed bugs (no title `foot`; Coverage a bare chapter card). S7 fixes them and regenerates it. ### S1, as shipped (2026-10-13, lane A, `r27/llm`) `common/lib/llm/`: the providers and the agent loop, with no settings read (everything comes in as options; S6 builds them from `settings.generation`). Raw `fetch`, no SDK; `fetch` and `sleep` are injectable. | Commit | What | | --- | --- | | `e664e9cc` | `prices.ts` (longest prefix; unknown Claude = Opus 5, local = free), `meter.ts` (`Meter`; writes 1.25x/2x by the API's split, else the run's TTL), `anthropic.ts` (`AnthropicClient`, `readApiKey`, `redact`; caching; the strict models' rules; retries), `ollama.ts` (`ollamaChat`, `unloadOllama`, `estimateTokens`, tools both ways), `config.ts` (`LlmConfig`, `providerOf`), `structured.ts` (`structuredAnswer`); tests | | `1beab231` | `agent.ts` (`runAgent`, `AgentTool`, `AgentEvent`, `TranscriptEntry`), `index.ts`; the agent tests and the key-leak test; the client's config made a `#private` field | | `8d1f2ed4` | `envVars.ts` declares `ANTHROPIC_API_KEY`; ENVIRONMENT.md regenerated | | `65a81a88` | the key-leak test's second key is not key-shaped | Rulings in the code: - **The key** is read from env `ANTHROPIC_API_KEY`, else `apiKeyFile` (`~` expanded; refused when group or others have any bit; `export` and quotes tolerated). - It is sent only in `x-api-key`. - Every message the client throws passes `redact` (the key and any 16-character run of it). - The config and the key are `#private`, so neither `inspect()` nor `JSON.stringify` shows them. - `env` is an option (tests pass `{}`). - **Strict models** are `claude-sonnet-5-5`, `claude-opus-5-5` and `claude-fable-5-1` / `claude-mythos-5-1`: - no `temperature`; - a forced `tool_choice` is refused before sending; - append-only history (no prune). - Only Sonnet 5.5 is sent `thinking: {type: "between_tools"}`; the others keep their default, and a `disabled` is dropped. - **Caching:** the top-level `cache_control` plus a system breakpoint, at the client's one TTL. - **Retries:** 408/429/5xx/529, `retry-after` (capped at 2 min) else 5 s × 2ⁿ (≤ 60 s), 5 by default. A 400 is not retried, except once without `temperature` when the model names it. - **`structuredAnswer`:** - A non-strict Claude model is forced to the `answer` tool. A 400 naming `tool_choice` falls back to the strict way. - A strict model gets `strict: true`, a closed schema, `tool_choice: auto` and one re-ask. - ollama uses `format`, retried once on a fault or a non-JSON answer. A prompt over the cap is never sent or retried. - **ollama:** the estimate is 3.5 chars a token over messages + tools + format (safer than the fake's 4). The cap is ≤ 8000 and `num_ctx` ≤ 12288, both clamped. `think: false` is sent only to thinking models (qwen3, qwq, deepseek-r1, gpt-oss, magistral, cogito) unless asked. - **`runAgent`:** - Claude's server web search is `web_search_20250305` (the stopgap's, proven live). A 400 naming `web_search` drops it, and the caller's own `web_search` tool, hidden while the server one is on, comes back. - Tool results are cut at 60 000 chars for Claude and 2 500 local. - A non-strict conversation is pruned past 90k context tokens (keeping 3), never once a thinking block exists. - The wrap-up is one text block after the tool results at `wrapUpAt` (0.85) of `maxUsd ?? meter.maxUsd`. - The budget is checked before each request and after tools. The local loop runs its tools one at a time. - **The transcript:** - Request entries carry only the messages added since the previous request, with `system`/`tools` on turn 0 and when they change. - Response entries carry the content, usage and USD. - Tool entries carry the input, the result clipped to 4 000 chars, the full length, the error flag and the ms. - Every string is clipped. - `digestApps.ts`'s `ollamaDirect` is unchanged (not required; its error and option semantics differ). Gates: tsc clean (all packages); common 3878/3878 (51 new in `lib/llm/`); mcp 306/306; `docs env --check` clean. No builds (no app code). Found and fixed: `inspect(client)` showed the config's `env`, key included (the key-leak test caught it). ### S4, as shipped (2026-10-13, lane C) The iterations store: `common/lib/report/iterations.ts`, on branch `r27/iterations-chain` from `r27/integration`. | Commit | What | | --- | --- | | `31ca0a7d` | `iterations.ts` (+ tests); `registry.ts` additions (articles in the making, `writeArticleHoldingLock`, `keepVideo`); `archilyzer reports iterations` (`bin/reports-iterations.ts`, its row, COMMANDS.md); compose/history/check tests; CHANGELOG | - **On disk:** `reports//iterations//` holds `iteration.json`, `report.json`, `sweep.md`, `turns.jsonl` and `proposals.json`. `iterations/current.json` holds `{report, reportFrom, video}`: which iteration the article is, whose report.json it holds (a `revise-video` iteration has none, so it takes its nearest ancestor's), and which iteration the attached video is. - **`iteration.json`** is zod (`iterationSchema`, loose, so a key a later slice adds survives an update). It holds `n`, `kind`, `model`, `parent`, `copyOf`, `feedback`/`question`, `scope {channels, from, to}`, `status`, `usage` by model (`usd`, tokens, cache tokens, calls), `ops {applied, refused}`, `minutes`, `checks`, `steps [{task, model, status, cost, minutes, …}]`, `projectDir`, `jobId` and the times. - Statuses: `queued`, `running`, `done`, `failed`, `cancelled`. `queued` was added for an iteration made before its job starts. - Parent and copyOf are always earlier iterations. A revision needs a done parent and feedback; a sweep or research run needs its question. - **Writes:** every one runs under `withArticleStoreLock`, is validated and atomic. `n` is allocated under the lock, and its directory is made non-recursively. - `writeIterationFile` takes the allowlist `ITERATION_FILES`. A `report.json` must parse as a report of this article; its problems are kept, and `makeCurrent` refuses them. - `makeCurrent` writes the article through `writeArticleHoldingLock` (writeArticle's body, for a holder of the lock). It drops the iteration's `audience` (the registry's alone) and keeps the article's attached `video` when the report has none. Only a `done` iteration is made current. The next `reports export` commits it as the next Revision (tested). - **An article in the making** (iterations, no report.json — S8's `/articles/new`) is INVISIBLE to the registry until its first `makeCurrent`. `listArticleDirs` and `readArticleState` leave it out, so compose, the homepage, the editor's Articles tab, umtool `/articles` and `reports check|prepare|export --article` never see it. `listPendingArticles` lists them, for S8. - **Never published:** a test each — the homepage compose (public and private: no iteration path, none of its words), an article's history (the tree stays `exports.json`, `report.json`, `report.md`) and its exports. Gates: tsc clean (all packages); common 3840/3840 (13 new); `docs cli --check` and `docs files --check` clean. Exported for S5/S6/S8/S11: - `createIteration`, `copyIteration`, `updateIteration`, `recordIterationStep`, `addIterationUsage`; - `writeIterationFile`, `appendIterationTurns`, `readIterationFile`; - `readIteration`, `readIterations`, `listIterations`, `currentIteration`, `lineage`, `reportSourceOf`; - `makeCurrent`, `setCurrentVideo`, `projectOf`, `iterationUsd`, `iterationLabel`, `parseIteration`, `listPendingArticles`, `ITERATION_FILES`. ### S7, as shipped (2026-10-13, lane C) The pipeline chain over an iteration, and the owed bugs, on `r27/iterations-chain` (after S4). | Commit | What | | --- | --- | | `7654e1c4` | to-manifest: the title card's `foot: ""` and render-cards' guard; no chapter card for a section with nothing to show; the derived fixtures regenerated | | `4e6db2af` | `reports prepare --article --only`; the window `pad` contract pinned (fetchWindows, fetchWindowManaged); umtool's driver finds the pipeline from its module | | `88302d19` | `umtool/lib/report/{chain,chain-run,iterations}.mjs` (+ tests), `umtool chain`; Turbopack opt-outs in the S0 kit's `derive.ts`/`regenerate.ts` | **The chain.** Ten steps: current, windows, prepare, posts, manifest, voices, video, podcast, attach, dedupe. - **One process each:** `node --import tsx umtool/lib/report/chain-run.mjs step `, so lib/jobs.ts runs it as a job (process group, cancel, per-step timeout), and `umtool chain [--from] [--dry] [--final] [--projects-root] [--site-origin]` runs the same argv from a terminal. - **Planning and executing are split.** `chain.mjs` plans in plain node (`planChain`, `chainSteps`, `chainStart`, `chainWindows`), and the Next app may import it. `chain-run.mjs` executes, under tsx, over common's TypeScript; the app never imports it. - **Recording and resuming.** Each step records `chain:` in the iteration's `steps` (running, then done, failed or cancelled, with minutes and one line). A chain resumes at the first step not done. - **Windows** are each cited moment's span, widened by the cut's fetchPad (3 s) and by the citation's own pad, so one editor fetch serves both the evidence clips and the cut. - **Posts:** only this article's missing screenshots, through the editor's `capture-posts`; then prepare runs again. - **Manifest:** written into `projectOf(projectsRoot, id, n)`. Its QR origin comes from the newest sweep.md in the lineage, or `--site-origin`. It copies the report and its stills, then seeds from the parent's project. - **Attach** records the iteration as the article's video (`setCurrentVideo`), runs `reports check`, and keeps its result in the iteration's `checks`. - **Defaults and secrets.** `projectsRoot` defaults to `~/reports/articles` until S6's setting. No secret rides in a step: the executor reads the editor's URL and token at run time, the way `pnpm ops` does. **`iterations.mjs`:** - `seedFromParent` carries narration by card id, else by heading, and hard-links the parent's voices. - `dedupeMedia` touches `out//segments/*.mp4` and `out/narration/*.{wav,json}` only, on the same device, linking through a temp and a rename. **The owed bugs, each with a test:** - **Title foot:** `foot: ""`, and render-cards renders a missing sub or foot empty. - **No silent end card:** a section that emits no timeline entry gets no chapter card, and a warning; the article keeps the section. That covers Coverage and `posts-only`'s Posts. - **`umtool build --dry`:** the driver finds `report-to-video/` from its own module. Under the Next server, where module URLs are chunk paths, it falls back to the cwd. - **`prepare --only`:** only this article's problems fail the run, and another article's are warnings. Only it is exported, over `articlesWorkHost(…, {only: true})`. - The media is still prepared for every published article. The articles' cache is one directory, and a prepare PRUNES every clip its run does not cite, so preparing one article alone would delete the others' clips. - **Window `pad`** — not changed; contract pinned. `from`/`to` ARE the window with its padding, and `pad` is provenance. - Every caller pads before it asks: fetch-via-editor.mjs, the MCP's fetch_clip, the chain. - Folding `pad` into coverage would double-pad all of them, and a refetch would rewrite the same file name. - The stopgap's failure was a request of the bare span with `pad: 3`, read as "please pad". Tests pin that a cached unpadded window never answers for a padded ask, and the contract is written on the item type and the cache check. Gates: - tsc clean. - Unit suites: common 3844/3844, `test:scripts` 850 pass + 3 skipped of 853, editor unit 264/264, mcp 306/306. - `docs cli|files|env --check` clean. - **Not run:** the umtool `build.spec.ts` e2e and the capped umtool build. Memory stayed under the 6000 MB floor; the heavy gate waited 9.5 min at 3.4–4.4 GB available, and the attempt was stopped. ### S2, as shipped (2026-10-13, lane B) Branch `r27/checks-tools`, from `r27/integration` `4b8dc576`. | Commit | What | | --- | --- | | `ee288e89` | `citations/verify.ts` strict check (`strictQuoteCheck`, `strictTextCheck`, `strictNormalize`, `quoteFragments`); verify-quotes status `inexact` (a warning: printed, counted, exit unchanged); `report/draft/{sweepModel,reportOps,videoOps,grounding}.ts` with their tests | | (this commit) | this record; the CHANGELOG bullet | - **The strict check** normalises both sides (NFKC, case, curly quotes, apostrophes removed, other punctuation a space), splits the quote on `…` / `...`, and matches each fragment on word boundaries in the cues overlapping ±90 s of the cited second. verify-quotes runs it on every track and takes a pass on any; `drift` and `en-orig-drift` keep precedence, so `inexact` is only a quote recall passes. A post is checked against its text. - **`sweepModel.ts`**: a finding is a `- `/`* ` item inside a section with at least one citing link (a link-less bullet stays a line). Lines before the title, the preamble, blank lines, indented continuations and odd heading spacing are kept, so `renderSweep(parseSweep(md)) === md` for any input. - **`reportOps.ts`**: `applyReportOps(doc, ops, ctx)` is async (the `add` checker is injected: `strictCheckerOver(cuesOf)`), returns a new doc, and reports `{index, op}` applied / `{index, op, why}` refused. A section a batch empties of findings and text is removed; a moved or added finding goes after the section's last finding, or into a new section before Coverage. `quotedClaimProblems(doc)` lints the quotes-in-claims shape (words between two quotes of one link's run that are not a joiner). - **`videoOps.ts`**: `applyVideoOps(manifest, ops, {report, parent?})` is pure; a narration's soft warnings come back on its applied entry. A clip added in the batch is bounded by its own citation's span. - **`grounding.ts`**: `checkNarration(text, {reference, quotes, evidence?})` → `{hard, soft}`; `groundingInputOf(report)`. The lints match a sentence to the evidence line sharing the most content words (at least two and half the sentence's). Gates: `pnpm -r exec tsc --noEmit` clean; common tests 3862/3862 (35 new). Found: `testing/draft/sweeps/inexact.md`'s far quote (200 s from its link) is a `drift` in verify-quotes, not an `inexact`: its ±5 s recall window shares only "the" with it (0.25), and drift is the stronger status. The strict check refuses it (the unit test says so); verify-quotes' `inexact` is the reversed quote. ### S3, as shipped (2026-10-13, lane B) | Commit | What | | --- | --- | | `be908bdd` | the test kit's `derive.ts` / `regenerate.ts` path joins opt out of Turbopack tracing — `test:scripts`' next-build-trace test was red from S0 | | `037c996c` | `mcp/src/callTool.ts` (`createCorpusTools`, exported as `yt-dlp-transcript-mcp/callTool`; the editor depends on the package); `common/lib/web/{pacer,search,fetchPage,tools}.ts`; the editor's `web-search` / `web-fetch` actions, ACTIONS rows, help, COMMANDS.md; `testing/web/fakeWeb.mjs`; `report/draft/agentTool.ts` (the AgentTool shape, until S5 imports lane A's) | | (this commit) | this record; the CHANGELOG bullet; the kit README row | - **`createCorpusTools({source, only?, editorDeps?})`** → `{source, tools, call(name, args), close()}`. A Client linked to `createServer(registry)` over `InMemoryTransport`, so the dispatch wrapper (the `(corpus: …)` note, the error shapes) is in the path. `source` is a handle, a `SourceSpec` or a built `ShardSource`. The allowlist is `CORPUS_TOOL_NAMES`: `list_channels`, `list_tags`, `list_reports`, `get_report`, `search_transcripts`, `enumerate_matches`, `get_transcript`, `get_post`, `get_thread`, `get_transcripts`, `get_video_metadata`, `channel_coverage`, `notes` (list and read; `reply` and its fields gone from the schema and refused), `list_sources`, `resolve_source`, `sweep_plan`, `ask_plan`. Not in it: `fetch_clip`, `enqueue` (work in the editor), `get_job` (the editor's jobs, not the corpus) and `open_link` (reads OTHER corpora by URL). A tool's error is thrown as `CorpusToolError` with the tool's words. - **The web.** `webPacer` is the process's one queue (the editor's two actions and every job's tools share it). `webSearch(query, {n, searchUrl, pacer})` → `[{title, url, snippet}]`; `webFetch(url, {maxChars, pacer, allowPrivate, resolve})` → `{url, finalUrl, status, contentType, title?, text, truncated}`; `fetchRefusal(url)` is the fence on its own; `webTools({pacer, searchUrl, allowPrivate})` → the `web_search` / `web_fetch` AgentTools. A backed-off request still waits out the rest of the 3 s gap. - **The editor actions** answer synchronously, through `ops()` (`_web.ts` maps a refusal before any request to a 400, a far-side failure to a 502). The search endpoint is DuckDuckGo's; S6's `generation` settings name the web provider. Gates: tsc clean; common 3870/3870 (8 new); mcp 314/314 (8 new, `protocol.test.ts`'s tool list unchanged); editor unit 267/267 (3 new); `test:scripts` 832 + 3 skipped, 1 failed before `be908bdd` (S0's next-build-trace) and green after it; `docs cli --check` clean. Not done here: the editor's `next.config.ts` `transpilePackages` does not list `yt-dlp-transcript-mcp` yet — S6, which imports it from a route, adds it (the unit test imports it under tsx). ### S3b, as shipped (2026-10-13, lane B) | Commit | What | | --- | --- | | `f7b2757c` | editor actions `archive-search`, `archive-item`, `import-post` (routes, ACTIONS rows, help, COMMANDS.md; the `import-post` action in `channels/[slug]/importPostAction.ts`); `describeArchiveOrgItem` in `archiveOrgImport.ts`; `SocialFetcher.fetchOne` (X through gallery-dl on the status URL, Bluesky through `getPosts`), `parsePostUrl`, `social/importPost.ts`; job kind `import-post`; `report/draft/research/{decide,tools}.ts`; `testing/archiveOrg/fakeArchiveOrg.mjs`; common's test glob reaches `lib/*/*/*/` | | (this commit) | this record; the CHANGELOG bullets | - **`decideAcquisition(proposal, autonomy, limits, spentSoFar)`** → `{decision: "enqueue"} | {decision: "approval", reason} | {decision: "refuse", reason}`. The standing rules (`standingRuleRefusal`) refuse in every mode: `create-channel` with any `sites` (an X channel's refusal says so), a Twitch VOD URL anywhere in the args, a `queueKey`, an action not in `ACQUISITION_ACTIONS`. Then `propose` waits on everything; the approval flags (`newChannelsNeedApproval`, `postWalksNeedApproval` — `fetch-posts` with `full` or `older`) hold under `limits` and `auto`; under `limits` a new channel and a priority bump always wait; a cap reached, or a download of unknown size (`estimate.gb` absent; a dry run is 0) or a transcription of unknown length, waits in both. One post is one item; a channel, a post fetch, a capture and a bump cost none. - **`acquisitionTools(ctx)`** → nine AgentTools named as the actions (`import-archive-org`, `import-video`, `create-channel`, `fetch-posts`, `capture-posts`, `import-post`, `transcribe-one`, `priority-bump` = `channel-priority` tier normal, `persist-videos`), each taking the action's own keys plus `reason`, `evidence`, `estimate`. Each records a `Proposal` in `ctx.ledger` (ids `p01`…; `note` carries why it waits or failed), and only an `enqueue` calls `ctx.editor.run(editorAction, body)` — the body is built from the action's own keys, so a `sites` the model adds never reaches the editor. `runApprovedProposal` (the operator's yes: past autonomy and caps, never past a standing rule), `rejectProposal`, `archiveReadTools` (`archive-search` / `archive-item` through the editor), `newLedger`. `ctx.onChange` is where S11 writes `proposals.json`. - **`import-post`** refuses at the door (route unit test) and in the job: not a post URL, no channel, not a posts channel, a channel of another platform, a fetcher with no `fetchOne` (x-playwright, x-nitter, forum), a post the URL names as another account's; after the read, a post the platform says is another account's is not written. The platform's hold and rate-limit cooldown refuse it before a job (`importPostHeld`, the holds a manual download meets). The job's log ends `@@import-post {…}`. Gates: tsc clean; common 3891/3891 (21 new); mcp 314/314; editor unit 270/270 (3 new); `test:scripts` 833 + 3 skipped; `docs cli --check` clean. Editor `next build` (heavy slot, 5 GB cap): clean, the five new `/api/ops` routes built. e2e `ops-api.spec.ts` alone: 13 passed, 0 failed (32 s; its prebuild rebuilt `editor/.next/e2e` in 66 s). Decided here: `import-post` takes a post of the channel's own account only (a reply or quote by another account would be misattributed in that archive). `import-post` is not replayable (a second import reads nothing anyway). ### S5, as shipped (2026-10-13, lane D) The generation tasks, on `r27/tasks-jobs` from `r27/integration` `f933f767` (phase 1 merged). | Commit | What | | --- | --- | | `277cc480` | `common/lib/report/draft/authoringRules.ts`; `report/draft/tasks/` (the five tasks, `run.ts`, `links.ts`, `quotes.ts`, `corpusSource.ts`, `project.ts`, `reportFile.ts`, `llmText.ts`, `index.ts` with `runTask`); `mcp/src/instructions.ts` reads the rules; `draft/agentTool.ts` re-exports lane A's type; `testing/draft/runs/*.json`; `mcp/src/draftTasks.test.ts` | | (this commit) | this record; the CHANGELOG bullet | - **A task** is `(input, deps)`. `deps` carries the LLM config, the corpus tools (`{source, tools, call}` — common cannot import the mcp package, so the caller builds them with `createCorpusTools`), the web tools, `cuesOf` / `postTextOf` / `postChannelOf` for convert and the quote check, an optional `verifyReport` (the editor's verify-quotes, which reads en-orig), the store's `paths`, a clock, a log and the signal. - **`runOnIteration`** is every task's life: the iteration must be `queued` (or `running`) and of the task's kind; it is marked running; the meter's spend per model is added to `usage`, the turns appended to `turns.jsonl`, and it ends `done`, `failed` (with `error`) or `cancelled` (the signal) with `minutes`, `ops` and `checks`. A model's failure is a `failed` iteration and a result; only a call that cannot start throws. Narration runs with `step`: a done iteration's `steps[]` gets `narrate`, its status untouched. - **sweep-agent:** the `sweep_plan` text (the request carries channels, batch size, extractor, report), the read tools (no notes, fetch_clip, enqueue, jobs), `extract_batch` (get_transcripts + the extractor model, cut at 400k chars, or the local cap), the report tools (each write kept in the store), Claude's server search plus the deps' web tools. Then the link backstop, convert, the strict check; one repair round with the report tools only, the transcript ±45 s inline and `min($0.25, cap/4)`; a finding still failing is dropped. - **The repair round is a fresh conversation**, not a continuation: `runAgent` starts from a user message, and the round needs only the problems and the report (cheaper than re-sending the run's context). - **sweep-pipeline:** `local_sweep.py` ported (terms, enumerate with the word fallback, read in 8s, windows of 90 s, 7000-char chunks, extract, the verbatim locate, the drops, the lint, group twice, the caps); every model call is a `structuredAnswer`, so the 8k cap refuses before sending. Converted and strict-checked; a failing finding is dropped and the markdown re-rendered (up to three rounds). - **revise-report / revise-video:** the parent's `sweep.md` (the nearest in the lineage) or cut (the nearest project with a manifest); `read_doc`, `apply_ops` (S2's engines; the add's strict checker over `cuesOf`), the read tools with `notes`, the web. A new finding whose quote fails after convert is dropped; the parent's quotes are never touched (an old `inexact` is a check, not a failure). A video revision's project is seeded from the parent's: the report and stills copied, the voices hard-linked; it has no report of its own. - **narrate:** per title and chapter card, the card's evidence, the rules without examples or the tag rule (`rulesForModel`), the taste; S2's grounding plus a word limit (35 / 45, refused at +10); one re-ask; the better attempt; failing sentences removed. A `revisions/-auto-before-narration.manifest.json` snapshot, then the manifest written whole; `narration-draft.json` beside it. - **Links** are `momentHref(origin, slug, id, s)`. Every get_transcripts result an agent sees has its `moment_base` rewritten to the origin's (the slug from the moment_base when it is in the archive's form, else asked of the corpus with get_video_metadata over the run's channels); the finished markdown's platform URLs and other origins' archive links are rewritten too. - **The corpus build:** `pickCorpusBuild(channels, {exportBuildsDir, want?})` (the newest public build holding them, a `-private` one only when alone) and `siteOriginOf(build, sitesDir)`; S6 wires them. - **`authoringRules.ts`:** the narration hard rule and writing rules (moved verbatim; `instructions.ts` re-exports them), the taste, the claim-quotes, verbatim, one-quote, post-citation, coverage and style rules, `momentLinkRule(origin)`, `EXTRACTOR_SYSTEM`, the unattended rule. The MCP's batch step now also states the claim-quotes and verbatim rules. Gates: - tsc clean (all packages). - common 3966 tests: 3963 pass; the three red were S6's settings in progress in the same tree (the shape test and the two generated-docs tests), green in S6's commit. New here: `tasks/tasks.test.ts` (7). - mcp 323/323 (9 new: `draftTasks.test.ts`, each task end to end over the synthetic corpus and the fakes, a cancel mid-request, the repair allowance, a drop after a failed repair). - editor unit 270/270; `test:scripts` 850 pass + 3 skipped. - No builds (no app code). ### S6, as shipped (2026-10-13, lane D) Editor jobs, settings and ops, on `r27/tasks-jobs` after S5. | Commit | What | | --- | --- | | `12a4f48c` | `controller/{reportDraft,gpuArbiter,generationUsage}.ts`; `lib/generationSettings.ts` + `settingsSchema`/`settingsDocs`; `queueKeys` `DRAFT_LOCAL_QUEUE`/`DRAFT_API_QUEUE`; job kind `report-draft`; `paths.generationUsageFile` (`GENERATION_USAGE_FILE`); `tasks/corpusCues.ts`; `ttsFile.ts` on the arbiter; the `report-draft` route, ACTIONS row, help, COMMANDS.md; `transpilePackages` gains the mcp package; the settings route refuses a key-looking `apiKeyFile` without echoing it; umtool's chain reads `generation.projectsRoot`; SETTINGS.md, settings.json.example, ENVIRONMENT.md; e2e `report-draft.spec.ts`; editor unit `_reportDraft.test.ts` | | `0a637826` | no key-shaped literal in the key rule or its tests | | (this commit) | this record; the CHANGELOG bullets | - **`pnpm ops report-draft {task, article, iteration?, model?, feedback?, question?, channels?, from?, to?, copyOf?, maxUsd?, source?, build?, cards?, force?}`** → `{ok, jobId, iteration}`. The controller (`enqueueReportDraft`) judges the body, picks the model (the asked one, else the task's route in `settings.generation`; a task routed to `code` with no model is refused), creates the iteration `queued` (a `copyOf` copies it; a narration names a done one and is a step), runs `runManagedFunction` on `draft:api` or `draft:local` by provider, and sets the iteration's `jobId`. A job cancelled or refused before it ran leaves no `queued` iteration behind (its `done` marks it). - **The job** resolves the corpus (`source`, else `build`, else `pickCorpusBuild` over the channels — a revision's and a narration's from its report's citations) and the citation origin (the build's site, else `generation.citationOrigin`, else the project site), builds the corpus tools through `deps.corpusTools` (the route passes `createCorpusTools`; common cannot import mcp), and runs the S5 task with the job's signal. Cues for convert and the strict check come from the same build (`corpusCuesOf`: get_transcript with timestamps); post text and the post-channel lookup from the corpus on disk; the editor's `verifyReportQuotes` adds only a `drift` / `en-orig-drift` (a record the disk does not hold is the build's to answer). The log ends `@@report-draft {article, iteration, task, status, summary, usd, minutes}`; a failed or cancelled task fails or cancels the job. - **The GPU arbiter** (`gpuArbiter.ts`): in-process holds (`holdGpu`) around each unit of work. Digests keep yielding to transcription (`digestYield`, unchanged); TTS (a GPU engine) waits for a transcription on a GPU worker and for a held draft call, and holds the GPU while its engine runs; a draft call waits for the transcription lane's signal and a held synthesis. A `draft:local` job's ollama config carries `gpuGatedFetch`: every `/api/chat` waits, then holds until the answer is read; the unload is never held. ollama is unloaded (`keep_alive: 0`) when a `draft:local` job ends, however it ends. `draft:api` touches none of it, nor the heavy slot. - **Caps (D6).** A job's cap is `maxUsd`, else its task's (`caps.sweep` 5, `revision` 2, `narration` 1), refused above `caps.max` (10). The daily cap (`caps.daily` 20, UTC) is read from the usage ledger at the ask and again at the job's turn; past it, refused naming the day's total. A finished API job appends a row per model (job, article, iteration, task, model, tokens, USD, day) to `paths.generationUsageFile` (`/.generation/usage.jsonl`, gitignored; the e2e server's is in its fixture). A local job has no dollar cap. - **`settings.generation`:** `preset` (named by the routes: the preset whose routes they are, else `custom` — choosing one is writing its routes), `routes`, `models {api, local, extractor}` (Sonnet 5.5, qwen3:8b, Haiku 4.5), `caps`, `cacheTtl`, `apiKeyFile` (a key-looking value is the default path, never stored; the ops settings route refuses it without echoing it), `anthropicBaseUrl` (a non-Anthropic base never receives the environment's key, only the file's), `ollamaUrl` (blank = the editor's `OLLAMA_URL`), `projectsRoot`, `web {provider, searchUrl}`, `citationOrigin`. `generation.research` is S11's. - **Decided here:** the ledger is a JSONL file, not a registry store (one line per model per job; the day's total is a scan). The daily cap refuses at the ask and at the turn; a job already running is not stopped by it (its own cap stops it). Gates: - tsc clean (all packages). - common 3976/3976 (10 new beyond S5: `gpuArbiter.test.ts` 4, `generationSettings.test.ts` 4, `generationUsage.test.ts` 1, the corpus-cues test); mcp 323/323; editor unit 276/276 (6 new, `_reportDraft.test.ts`: the body, the refusals, an API sweep to done with its ledger rows, the daily cap, a cancel mid-request, a local narration with its unload); `test:scripts` 851 pass + 3 skipped (the chain's projects-root test new). - `docs env|files|cli --check`, `settings example --check`: clean. - Editor build: the e2e prebuild's capped `next build` (heavy slot, 5 GB) at `12a4f48c`, 72 s, clean. (A standalone `next build` waited 33 min under the 6000 MB floor at 5.1–5.5 GB available and was stopped; the e2e run's build is the same app.) - e2e `report-draft.spec.ts` + `digest.spec.ts`, one run: 18 passed, 0 failed, 41.5 s (report-draft 3 in 0.6 s, digest 15 in 21.2 s). The first attempt timed out in the heavy-slot queue and was re-run. ### S11, as shipped — the backend (2026-10-13, lane G, `r27/research`) Research runs, on `r27/research` from `r27/integration` `5962c543`. The umtool queue lands after S8. | Commit | What | | --- | --- | | `ae2ed4dd` | `report/draft/tasks/research.ts`; `report/draft/research/state.ts`; `decide.ts` (the auto ruling); `controller/researchRuns.ts`; `report-draft` task `research` and the continuation; `settings.generation.research` and `routes.research`; the editor's `research-approve` route and `_researchEditor.ts`; ACTIONS row, help, COMMANDS.md, SETTINGS.md; tests and `testing/draft/runs/research.json` | | (this commit) | this record; the CHANGELOG bullets | - **The task** (`research`, an iteration of kind `research`): one agent run. - It reads the corpus (`list_channels`, `search_transcripts`, `enumerate_matches`, `get_video_metadata`, `channel_coverage`, `get_post`; a local model gets three of them), `editor_channels` (every channel the editor archives), the web, and archive.org through the editor's `archive-search` / `archive-item`. - It then calls S3b's acquisition tools. Each call is judged by `decideAcquisition`, then enqueued through the editor, left waiting, or refused. - `proposals.json` (`{format, version, autonomy, limits, spent, proposals}`) is written on every change. The iteration's `research` key is `{autonomy, phase, notes, continuedBy?}`. - A research iteration has no report. It ends `done` with its acquisitions, also when some still wait. - **Phases:** `discover` (the job runs), `wait` (a proposal waits for a yes or no, or an enqueued one's job has not ended), `ready` (nothing pending), `continued`. - Nothing waits in a process. Every read through `research-approve`, and every continuation, first refreshes the enqueued acquisitions from their editor jobs (`getJobEntry`). All of a proposal's jobs done makes it `done` with `doneAt`. One failed, cancelled, lost (`archived`) or unknown makes it `failed`, naming the job. - **Autonomy (ruled 2026-10-13):** - `auto` lifts the approval flags. The caps are hard ceilings: past one, or of unknown size, a proposal waits. - Under `limits`, `newChannelsNeedApproval` and `postWalksNeedApproval` decide whether a new channel or a post walk waits. A priority bump always waits. - An import's `estimate.transcribeHours` counts against `maxTranscribeHours`. - The standing rules refuse in every mode. - **`pnpm ops research-approve {article, iteration, ids?, approve?, note?}`** → `{outcomes, research}`: - `approve: true` runs each proposal through the editor (`runApprovedProposal`: past the autonomy and caps, never past a standing rule). - `false` rejects it, with the note as why. No ids: the run's state. - A run whose job is queued or running is refused: its proposals are the job's until it ends. - Writes are serialized per run in the process. - **Continue = `report-draft {task: "sweep", iteration: }`**, chosen over a new ops verb. - The sweep's parent is the research run. Its question is the run's, and its channels are the run's plus every channel a done acquisition wrote into (a created channel, an import's, a post's, a persisted item's); each can be given instead. - Refused while the run waits, unless `force` (what is done so far). - At the ask, a build must hold the widened channels (a channel on no site is in none until the operator puts it on a site and builds it). A build older than the last acquisition is answered as a `warnings` line. - The run records `continuedBy`. - **The research job's editor is the editor itself.** `_researchEditor.ts` calls the ops route handlers in process, with a Request carrying the editor's worker token. An acquisition therefore meets the same door, holds and queues as `pnpm ops`, and the editor needs no URL of its own. - **Settings:** - `generation.research {autonomy: "propose", maxItemsPerRun: 20, maxGbPerRun: 5, maxTranscribeHours: 6, newChannelsNeedApproval: true, postWalksNeedApproval: true}`. - `generation.routes.research`: `api` in `balanced` and `api`, `local` in `local`, `code` in `code`. A settings file without it takes the research route of the preset its other routes match, so its preset is unchanged. - A research job's cap is `caps.sweep`. Gates: - tsc clean (all packages). - common 3984/3984 (8 new: `research/runs.test.ts` 7, `generationSettings` 1; the S3b test now pins the auto ruling); mcp 323/323; editor unit 282/282 (6 new, `_researchRuns.test.ts`); `test:scripts` 851 pass + 3 skipped. - `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`). ### S8, as shipped (2026-10-13, lane E, `r27/umtool-ui`) The umtool UI, on `r27/umtool-ui` from `r27/integration` `5962c543`, with S11's backend merged in at `b3f14445`. | Commit | What | | --- | --- | | `e1bd5439` | `lib/articles/generation.ts` (the editor over ops, the iterations view, the policy, the chain view), `lib/articles/compare.ts`; routes `app/api/articles/{policy,channels,generate,iterations,job,chain}`; `/articles/new` (`NewArticleForm`, `PolicyPanel`), the Iterations tab (`IterationsView`, `IterationsTab`, `ChainPanel`, `ResearchSlot`) in `ArticlePage`, `/articles//compare`; `/articles`' in-the-making list; `/drafts` redirects, the POC's lib, panel and route deleted; the editor stub's generation routes, `iterations-fixture.mjs` (zeta), the e2e env | | `f8a3875f` | e2e `article-new`, `article-iterations`, `article-compare`; the chain's steps read down; `docs/sites.md` | | `3556e54a` | merge `r27/integration` (S11's backend) | | `afbd921e` | the research route in the stub's presets; `autonomy` passed through; a research run copied with a model | | `dc5a1c5d` | `/drafts` redirects at request time; the CHANGELOG bullets | | (this commit) | this record | - **umtool writes nothing of the corpus but through the registry.** A generation, a copy, a narration and a cancel are the editor's (`report-draft`, `job cancel`), asked over `/api/ops` with `WORKER_TOKEN` (`agentToken`: the environment, else the editor's env files), which never reaches the browser. **Use this iteration** is common's `makeCurrent` in a umtool route: the registry's locked, validated writer, as the chain's `current` step already is. - **The policy** is `settings.generation`, read with `GET /api/ops/settings?key=generation` and written with `POST /api/ops/settings {patch: {generation: {routes|models|caps|cacheTtl}}}`; a preset is written as its routes. The editor's read redacts `apiKeyFile` (its name matches the secret pattern), so the panel reads the PATH from the checkout's `settings.json` (as `chain.mjs` reads `projectsRoot`) and only stats it; umtool never writes it. The day's spend is common's `dayUsage` over `paths.generationUsageFile`, read-only. - **The task picker:** the controller picks the sweep by the model's provider, so `/articles/new`'s agent / pipeline choice filters the models (Claude / local). The cap is sent for an agent only, and only at or under `caps.sweep`. - **Per-step model:** narration only (`task: narrate` with `model`). The extractor has no per-job key in `report-draft`; it is the policy's `models.extractor`, set on the panel. - **Polling:** the list every 3 s while an iteration is queued or running or a narration step runs; a job's log (`/api/ops/job/?tail=12`) every 2.5 s; the chain every 2.5 s while its job runs. - **Make the video** is `planChain` with the policy's `projectsRoot`, started as a lib/jobs.ts job named `chain i` (one umtool job at a time, as every chain). - **An article in the making** (iterations, no report.json) opens on its Iterations tab (`?tab=iterations`; the meta says "in the making") and is listed on `/articles` above the store's table, never as a row of it. - **The research slot:** an iteration of kind `research` renders `ResearchSlot` (`data-research-slot`), its status only. S11's queue replaces its body. - **Labels (contracts):** buttons `Use this iteration`, `New iteration`, `Start iteration`, `Copy with model`, `Narrate`, `Make the video`, `Run the chain`, `Cancel the chain`, `Cancel i`, `Start`, `Save caps`, the presets by name; regions `iterations`, `generation policy`, `i video chain`; forms `new article`, `new iteration from i`; selects `route `, ` model`, `copy i on model`, `narration model for i`, `model for the new iteration from i`, `i chain from step`; checkboxes `compare i`; the link `Compare i and i`; attributes `data-iteration`, `data-status`, `data-current`, `data-pending-article`, `data-side`, `data-chain-step`, `data-step-status`. Gates: - tsc clean (all packages), after the merge too. - `test:scripts` 851 pass + 3 skipped of 854. common, editor unit and mcp not touched (no file of theirs changed). - `docs env|files|cli --check`: clean. - umtool build (heavy slot, 5 GB cap, the corpus linked and removed): clean, 37 s, at `afbd921e`. The e2e start-mode build at `dc5a1c5d`: clean. - e2e (umtool suite, two specs a run, foreground): - `article-new` + `article-compare` at `e1bd5439`: 5 passed, 1 failed, 37.3 s (a page-wide `alert` met Next's route announcer; the spec scopes it now). Re-run at `f8a3875f`: 6 passed, 16.3 s. - `article-iterations` + `articles`: 6 passed, 0 failed, 45.5 s. - After the merge, at `afbd921e`: `article-new` + `article-iterations` 7 passed, 40.2 s; `article-compare` + `articles` 5 passed, 11.4 s. At `dc5a1c5d`: `article-new` 3 passed, 30.0 s. Found: none outside the lane. ### 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/` 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 ``. - 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). ### S11, as shipped — the umtool queue (2026-10-13, lane G, after S8) | Commit | What | | --- | --- | | `68b5c81b` | umtool: `ResearchSlot` filled; `/api/articles/research` and `lib/articles/research.ts`; `/articles/new` starts with a sweep or with research (autonomy, channels optional, the limits shown); the editor stub's research runs; e2e `article-research.spec.ts`. common: a read of a running run writes nothing; the view carries the agent's notes | | (this commit) | this record; the CHANGELOG bullet | - **The queue** (a research iteration's card in the Iterations tab), read through the editor's `research-approve`, which refreshes the run first. It shows: - the phase, the autonomy, the spend against the limits, and the agent's closing notes; - each acquisition with its action, target, estimate, status, reason, evidence links (new tab) and `note`; - Yes and No (with an optional why) on each that waits, hidden while the run's job is going; - each enqueued acquisition's editor job, followed live through `/api/articles/job`. - The queue is re-read every 4 s while the run's job or an acquisition's job is going. - **Continue into a sweep** is shown when the run is done and nothing is pending (`ready` or `continued`). It posts `report-draft {task: "sweep", iteration: n, model}`; the model defaults to the sweep route's. - **`/articles/new`** has "start with": a sweep or research. A research start takes an autonomy (default `generation.research.autonomy`) and a model (the research route's) and needs no channel. A Claude model is capped at `caps.sweep`. - **The policy panel does not edit `generation.research`** (`writePolicy` is unchanged). The defaults are set through the editor's settings. - Rulings (orchestrator, 2026-10-13): `balanced` → api for research; continuation stays explicit in r27 (auto-continue is a later candidate); lane F passes `autonomy` through the MCP's `generate`. Gates: - tsc clean (all packages). - common 3984/3984; mcp 323/323; editor unit 282/282. - `test:scripts` 850 pass + 3 skipped, 1 red: `queue-lock.test.mjs`'s "--with" case, run while the orchestrator's e2e held the machine-wide queue. Alone it is 37/37. - `docs env|files|cli --check`, `settings example --check`: clean. - umtool build (heavy slot, 5 GB cap, the corpus linked for the build only and removed): clean, `/api/articles/research` built. It waited 22 min for the heavy slot behind the orchestrator's e2e. - e2e, foreground, two specs a run: `article-research` + `article-new` 4 passed, 1 failed (Continue's request was asserted before the stub recorded it; now polled); then `article-research` + `article-iterations` 6/6 (50.6 s). ### S10, as shipped (2026-10-13, lane H, `r27/migrate-docs`) Migration and docs, on `r27/migrate-docs` from `r27/integration` `1575479b`. | Commit | What | | --- | --- | | `bc8d7f08` | `common/bin/reports-import-local-runs.ts` (+ tests), its `archilyzer` row, COMMANDS.md | | `ed3ae443` | OPERATING.md "Generate and iterate" and "Research runs"; `umtool/docs/authoring.md` "Generating with a model"; REPORT.md "Iterations" and "Checking quotes" (from `lib/report/docs.ts`); the CHANGELOG pass; AGENTS.md (`gen.md` in the prefix rule); STATE "Now"; FACTS; `docs cli --check` knows `pnpm ops job ` | | `8e3329fa` | this record | | `fa22afd1` | merge `r27/integration` (S11's umtool queue) | | (this commit) | OPERATING.md and authoring.md checked against S11's queue and `/articles/new` (start with a sweep or research, Yes / No, Continue into a sweep); this record | - **`archilyzer reports import-local-runs [--apply] [--runs ] [--only ] [--move-projects] [--generation ]`** is a dry run unless `--apply`. Each run named (default: D9's two) becomes `i1` of its article through the iterations store, never by hand: - The article is `ui.json`'s `id`, else the run's name; the run's `report.json` gets that id (a different one is printed). - `iteration.json`: kind `sweep`, `run.json`'s model, question and channels; usage from `by_model`; minutes; checks `convert` and `verify-quotes`; `createdAt` the transcript's first stamp, `endedAt` run.json's time; `imported {from, run, at, extractor}`. - `turns.jsonl`: an import note, then `start` → a note (its settings under `stopgap`), `turn` → a response (text and the tool names as content, usage, USD), `tool` → a tool entry (`result` empty, the stopgap kept none; `chars`; `ms` from the stamps); anything else kept as it was. - An article the registry has: `makeCurrent` only when the run's report equals the article's with `audience` and `video` aside (otherwise the differing keys are printed and the article is unchanged); `setCurrentVideo` when the article has a video attached and the run has a project. - A run with no article: an article in the making, not made current. - The video project is copied (`--move-projects`: renamed, else copied and removed) to `projectOf(projectsRoot, id, 1)`, recorded as `projectDir`. - Refused, writing nothing for that run: no run directory, run.json or sweep.md; a report that does not parse; an article with iterations already; a project place that is taken. A run imported before is "already imported". - `generation.json`, when there is one: its routes (known tasks and routes only) and models over the current `settings.generation`, printed as a patch; applied through the editor's `POST /api/ops/settings`, else `writeSettings` when nothing listens (never beside an editor that is there and silent). - The dry run lists the `ui-test-*`, `shondo-*` and `local-test-*` runs, projects and registry drafts with their sizes (a hard-linked file counted once), and the runs neither imported nor named for deletion. Nothing is deleted. - **The dry run against the real stopgap and corpus** (read only; nothing written, checked with `find -newer`): both runs importable. `piratesoftware-ai-friends` → the article's `i1`, its report equal to the article's, made current for the article and the video, its project (72 MB, 90 files) copied to `~/reports/articles/piratesoftware-ai-friends/i1`. `api-shondo-recent` → `i1` of a new article in the making (report id `api-test-shondo-recent` becomes the article's). No `generation.json` on this machine. To delete after the OK: 15 items, 307 MB (8 runs, 4 projects, 3 registry drafts). Kept, named by neither list: `runs/api-shondo-fishing`. Output: the job's `r27h-import-dry.txt`. - **Ruled (orchestrator, 2026-10-13):** `runs/api-shondo-fishing` is neither imported nor deleted; it goes on the operator's list. The `api-shondo-recent` article id is the run name. - **Decided here:** the imported iteration's `createdAt` is the run's first transcript stamp, so it spans the run's earlier attempts in the same transcript (the piratesoftware run has three starts). The registry has no delete verb: the three test drafts are removed by hand after the OK. Gates: - tsc clean (all packages) before each commit. - common 4000/4001 at `bc8d7f08` (9 new, `reports-import-local-runs.test.ts`); the one red is `controller/relocateChannelMedia.test.ts` "reconcile: an extra and a changed file …", 44/44 when run alone. `cli-docs.test.ts` 9/9 after the checker change. - After the merge of `r27/integration` (S11's queue): tsc clean (all packages); common 4001/4001. - `docs cli|env|files --check`, `settings example --check`: clean. - No builds (no app code). ### The gate round, as run (2026-10-13, orchestrator) On `r27/integration` `37d1da7f` (every slice merged), then three umtool e2e fixture fixes (`5f986083`, `78c384df`, `a787531d`; nothing else changed). | Gate | Result | | --- | --- | | tsc, all packages | clean | | common / mcp / editor unit / `test:scripts` | 4001 / 342 / 285 / 852 + 3 skipped, all passing | | `docs env`, `docs files`, `docs cli`, `settings example --check` | clean | | builds (heavy slot, 5 GB cap) | editor 48 s, export 24 s, homepage 14 s, umtool 28 s (corpus linked for the build only) — and green at `1575479b` too | | e2e editor (at `1575479b`) | 690 passed, 12 skipped, 1 failed: `backfill.spec.ts` "a lane can be scoped…" — alone at `37d1da7f`: 22/22 | | e2e export / report / hub / homepage (at `1575479b`) | 276 / 46 / 39 / 110, all passing | | e2e umtool | run 1: 288 passed, 14 failed — the editor stub died; run 2 (stub fixed): 301 passed, 1 failed; run 3: same 1; `projects.spec.ts` + `article-compare.spec.ts` after the fixture fix: 26/26 | | privacy counts on `main..r27/integration` | no session links or trailers, no home paths, no operator names; `sk-ant-` only as the prefix named in one commit message; the earlier subject named twice in this plan's research paragraph (as in earlier plans on `main`); the key FILE path (`anthropic.env`) in settings docs and tests — never its contents | Found and fixed in the round: - **The umtool editor stub died mid-suite.** A spec read its request log half-written (a JSON parse error), its article was removed, and a stub job's timer then wrote into the missing directory; the uncaught error killed the stub, and every later spec that asked it anything failed (13 of the 14). The log is written atomically now, and a late timer error is logged, not fatal. - **`projects.spec`'s blocking count saw two more projects.** `/browse` scans the whole fixture root, `gen-projects/` included, and the iterations fixture's two video projects had no `siteOrigin` — a BLOCKING defect each. They carry one now (and so does the stub's video revision). Left: the umtool suite was not re-run whole after the last fixture fix (the two specs it could affect were); a `relocateChannelMedia` reconcile test and `queue-lock.test.mjs`'s `--with` case each failed once under machine load and pass alone; transcription leaves `/tmp/parakeet-stitch-*` behind (not this release's). ## Rollout - Fast-forward `main`. - Editor: build, restart, smoke (new job kinds and actions). - umtool: build, restart. - MCP: Claude Code picks up the new tools on its next start. - Homepage source-mirror publish. No public site changes. - Then `import-local-runs --apply` after the operator reads the dry run. - The stopgap stays read-only until the operator deletes it (D9). ## Pacing - Phase 1 is three parallel lanes, about 3–4 h each. - Phase 2 is about 4 h. - Phase 3 is about 4 h plus the gate round (about 1.5 h) and the rollout. - That's about two working days of agent time, within the weekly budget at the usual two heavyweight jobs and one marathon per 5 h window. - Each slice commits as it goes, so a session limit mid-slice loses nothing. - The stopgap keeps working throughout. Nothing in the live editor or umtool changes until the rollout. ## Decisions (for the operator) - **D1 — where iterations live.** - The report side in the registry (`transcripts/reports//iterations//`). - Video projects and renders under `settings.generation.projectsRoot` (default `~/reports/articles//i/`), off the corpus disk. - *Recommended.* - Alternative: everything under the article dir, renders included. That is about 50–100 MB per iteration on the corpus SSD. - **D2 — corpus tools for the agents.** - The MCP's own tools in process (an export over the in-memory transport). *Recommended:* one behaviour for Claude Code and the jobs. - Alternative: re-implement search, enumerate and transcript reads in `common/`. - **D3 — strict quotes.** - Generated quotes must pass the strict check (verbatim within ±90 s). - verify-quotes reports `inexact` as a warning for existing reports. - Compose and publish are unchanged until an audit of the 27 articles. - *Recommended.* - Alternative: compose refuses `inexact` now, which may hold articles. - **D4 — the free sweep.** - Port the code-driven qwen sweep pipeline (778 lines; the only sweep that fits qwen's 8k context). *Recommended.* - Alternative: drop it; qwen then only revises and narrates, and sweeps are Claude Code or the API. - **D5 — scope of tasks in r27.** - Move and test what the stopgap does (sweep, revise report/video, narrate, the pipeline). *Recommended.* - Leave release 28 for the plan's remaining media tasks (clip selection and order, on-screen titles, teaser, flips, threads, YouTube title and description, proposed verdicts) on the same machinery. - Alternative: all in r27, about two days more. - **D6 — spend caps and policy in settings.** - A per-job default ($5 sweep, $2 revision, $1 narration). - A daily API cap of $20; a job past it is refused with the day's total. - The routing policy as the `generation` settings key, replacing `generation.json`. - *Recommended.* - **D7 — web search for the local model.** - A paced DuckDuckGo HTML read (works today, no service to run). *Recommended.* - Alternative: a self-hosted SearXNG. - **D8 — Claude Code balance.** - MCP `generate` / `generation_policy`, with `sweep_plan` routing by the policy, and `/gen` in the repo. *Recommended.* - Alternative: keep `/gen` as a shell-command wrapper only. - **D9 — the stopgap's runs.** - Import `piratesoftware-ai-friends` and `api-shondo-recent` (and any others you name) as iterations. - Delete the `ui-test-*`, `shondo-*`, `local-test-*` runs and projects (about 320 MB). - Keep `~/reports/local-reports` read-only until you delete it after r27 is live. - *Recommended.* ### Rollout, as run (2026-10-13, orchestrator) - `main` fast-forwarded to `3c246ec9`; the editor (capped build, `pnpm install` first — the editor now depends on the mcp package) and umtool rebuilt and restarted; the standard smoke `SMOKE_FAIL=0`. - The homepage and the source mirror published: audit clean (34,854 objects, 6,628 files against the denylist, gitleaks clean), deployed to production, live check ok. - Two fixes found by the live smoke, each fast-forwarded and rolled out the same way: `0c7b088f` (a two-line finding — the claim on the bullet, its quote and link under it — is a finding; before it, a revision of a sweep written in that shape had its drops and merges refused, and a finding whose quote failed the strict check could not be dropped) and `73292cea` (a revision whose model never calls `apply_ops` gets one schema-bound ask for the batch; none at all is a failing `ops` check). Live: editor `7Z4ibm7rxcnlTmscBvHXL`, umtool `iiUn87jKOZyyVew6hWjE4`. ### The live smoke, as run (2026-10-13; the operator's key; $1.27 of the $3) Through umtool's own routes (what its pages call) on the live apps: | Step | Result | | --- | --- | | Sonnet 5.5 sweep, one small channel, a two-month window | done in 1.05 min, $0.17 (Sonnet + Haiku extractor); every quote strict-verbatim; links on the site's origin | | report iteration (Sonnet) | i2: done, but 15 drops refused — the two-line bug; after `0c7b088f`, i5: 32 applied, 2 refused, $0.24 | | `/gen` from a fresh MCP process | `generation_policy` read the balanced preset and the day's spend; `generate` routed revise-report to the API: i3 done, $0.02, the review instructions returned | | copy with model (qwen3:8b) and compare | i4/i6: qwen ended its turn empty (0 ops) — the `73292cea` fix; i7: one op proposed, refused by the engine (quoted words in a claim); the compare page renders | | the chain to a video and a podcast | all ten steps done on i5: 70 MB video, podcast m4a + mp3, attached | | qwen narration | 5 cards in 0.4 min, an undo snapshot kept; one line put the speaker's words in the narrator's mouth — the grounding gap Q0 recorded | | video iteration (qwen) | i8: 1 op applied (a clip dropped), the project seeded from i5 | | cancel mid-step | a running sweep cancelled after one turn: job and iteration `cancelled`, its $0.04 kept | | research, `propose` | three archive.org proposals with reasons, evidence and estimates; one 30 MB clip approved (fetched by torrent, seeded), two rejected with a note; phase wait → ready; continued into a sweep (i2, $0.22, quotes strict) | The smoke's articles (`r27-smoke-shondo`, `r27-smoke-cancel`, `r27-smoke-research`) are drafts or pending, on no site; the operator keeps or removes them. The imported clip is in `piratesoftware` and is transcribed by the usual policy. Owed to the operator: read `$T/r27h-import-dry.txt`, then `archilyzer reports import-local-runs --apply`; then the OK for the 15 test leftovers (307 MB; three registry drafts by hand); `runs/api-shondo-fishing` undecided. ### Follow-up: delete, as shipped (2026-10-13, lane I, `r27/delete`) The operator (2026-10-13): "add a delete path for all currently used paths for similar features." Nothing could remove an article, an iteration, its video project, a umtool report-video project or a take; test drafts could only go by hand under `transcripts/`. **The survey** (each thing, every place it lives or is named): - **An article:** `reports//` holds `report.json`, `video.mp4` and `poster.jpg` (real files: articles have no media tier; `attach-video` writes them in place), `stills/`, `history-git/`, `notes.json` and `iterations/`. `reports/index.json` lists the published ones. Its staged exports are `.export-index/articles/report-exports//`. Its prepared clips are in the shared `report-media/` cache, keyed by moment, not by article (the next prepare prunes what no published article cites). Its iterations' projects are `//i/`. A umtool project whose manifest says `"article": "articles/"` links to it. - A site's `pages` name the SITE's reports (`sites//reports//`): a different store and a different document. The release 26 move dropped each moved id from its site. On this machine, no site's pages name an article id (one site page, the site's own report). - **An iteration:** `iterations//` plus `current.json` (report, reportFrom, video). Its project is `projectOf(…)`, or the recorded `projectDir`. Other iterations name it as `parent` or `copyOf`. A running job, or a running step (narration, `chain:*`), is recorded in `iteration.json`. The usage ledger names it by number. - **A umtool project:** its directory under `REPORTS_ROOT`. A tiered project's `out/`, `clips/` and `share-*` may be absolute links to `//` (`storage.mjs`). Its `notes.json`, `revisions/` and `takes/` are inside it. The project index (`CACHE_DIR/index`) and the links cache are derived. A project is a leaf of the walk, and may be reached through a link. - **A take:** `takes//` (`take.json`, `preview.mp4`, `video.manifest.json`, `out/`). Its verdict is a row of `takes/verdicts.json`. Notes on it are in the project's `notes.json`. **Nothing records which take a deliverable was built from**, so "in use" is decided as: the take whose `video.manifest.json` is byte for byte the project's. | Commit | What | | --- | --- | | `528b08f8` | common `lib/report/delete.ts`: `planArticleDelete`, `deleteArticle`, `planIterationDelete`, `deleteIteration`, `formatDeletePlan`. Registry additions: `unpublishHoldingLock`, `parkArticleDirHoldingLock`. Iteration additions: `current.json` `highest`, `retireIterationHoldingLock`, `iterationDirNumbers` (+ tests) | | `304a8cd3` | `archilyzer reports delete [--iteration n] [--apply] [--force] [--json]` (`bin/reports-delete.ts`, its row, COMMANDS.md) | | `051d92fb` | editor `POST /api/ops/delete-article {id, force?, dryRun?}` and `delete-iteration {id, n, dryRun?}` (`_articleDelete.ts`); ACTIONS rows and help; COMMANDS.md | | `19e62dcc` | umtool `lib/report/delete.mjs` (projects and takes, + tests); routes `/api/articles/delete`, `/api/projects/delete`, `/api/report/takes/delete`; `components/DeletePlan.tsx` and the four controls; `/articles` and `/browse` say what went | | `c7620bc9`, `28565971` | umtool e2e `article-delete.spec.ts` and its fixture (`delete-fixture.mjs`; the spec writes its draft itself) | | `4b848a5d`, `ea1bc1cc` | REPORT.md (generated), OPERATING.md "Delete …", `umtool/docs/{projects,report-video,sites,e2e}.md`; ENVIRONMENT.md: `UMTOOL_MEDIA_DIR`, `REPORTS_DIR`, `SONG_REPORTS_DIR` (common reads them now) | | `c6efc792` | the delete removes what the plan made under the lock lists, plus the first plan's media copies | | (this commit) | this record; FACTS; CHANGELOG | **The design:** - **Plan, then apply.** A plan reads only. It lists every path that would go (with bytes, files and its biggest parts), what is kept and why, refusals (each `forceable` or not), and the store writes `force` makes first. Every surface shows the plan before it acts: the CLI is dry unless `--apply`, ops take `dryRun`, and umtool has **Confirm delete**. - **Under the lock:** the plan is made again; with `force`, the site pages are dropped (`patchSite`) and the article unpublished (`unpublishHoldingLock`). Then ONE rename parks the directory as `.deleting--` (`iterations/.deleting--` for an iteration; not an id, so no reader sees it). The bulk is removed after the lock is let go, so a delete of gigabytes never makes the lock look stale. A cut delete's park is listed and removed by the next plan. - **Refusals.** - **An article:** published, or a site page naming its id with no report of its own (forceable: force unpublishes and drops the page). Any iteration queued or running, or with a running step (never forceable). Its directory being a link. - **An iteration (no override):** the current article; the iteration the article's report came from (`reportFrom`); the current video; busy; a parent or original of another (named). - **A project:** a link, or reached through one; a umtool job in it; an article's current-video iteration project; a running iteration's project. A manifest naming an article with a video attached is forceable. - **A take:** a job in the project. The take the project's manifest is, is forceable. - **umtool's article route** also refuses while a `chain …` job runs here, and names (and keeps) each project whose manifest links the article. - **Roots.** Every removal is strictly inside the articles directory, the projects root, the export staging, or (for a link that is exactly its umtool media mirror, `/`) the media root. Each is re-checked against its root's real path before it is removed. Any other link is removed as a link, and its target kept and named. - The media root is umtool's `MEDIA_ROOT` in umtool, and `UMTOOL_MEDIA_DIR` (+ `REPORTS_DIR`) in the CLI and the editor. Unset, a mirror is kept and named. - A recorded `projectDir` outside the projects root is kept and named. - **Numbers are never reused.** `current.json` keeps `highest`, and `createIteration` allocates above it. The ledger and job logs name iterations by number. - **Kept, always:** the usage ledger, the shared `report-media/` cache, the git history of `transcripts/`, a deployed site until rebuilt. A take's verdict row and notes are kept too: the agent reads them, and a missing take shows as missing. - **Labels (contracts):** buttons `Delete article`, `Delete i`, `Delete project`, `Delete take `, `Confirm delete`, `Keep it`. Region `delete ` (`delete i3`, `delete the article `, `delete the project `, `delete take `). Lists `what goes`, `what is kept`, `refused`. Checkbox `delete anyway`. Attributes `data-delete-blocked`, `data-delete-path`, `data-delete-bytes`, `data-deleted`. Gates: - tsc clean (all packages), at every commit. - Unit suites: - common 4017/4017 (14 new: `lib/report/delete.test.ts` 11, `bin/reports-delete.test.ts` 3; the env test caught the three umtool variables); - editor unit 288/288 (`_articleDelete.test.ts` 3 new); - mcp 343/343; - `test:scripts` 858 pass + 2 skipped of 860 (`umtool/lib/report/delete.test.mjs` 5 new). - `docs cli|files|env --check`, `settings example --check`: clean. - Builds (heavy slot, 5 GB cap): - editor 54 s (`/api/ops/delete-article`, `/api/ops/delete-iteration`); - umtool 30 s, the corpus linked for the build only and removed (`/api/articles/delete`, `/api/projects/delete`, `/api/report/takes/delete`). - e2e (umtool, foreground, two specs a run): - `article-delete` + `article-iterations`: 7/7, 39.3 s at `19e62dcc`; 7/7, 39.3 s at `c6efc792`. - `projects` + `articles`: 24 passed, 1 failed (`articles.spec` counts the store's rows, and the fixture's draft `omega` was a third). The spec now writes and removes `omega` itself (`28565971`); `article-delete` + `articles` then went 5/5. - `takes` + `sites`: 9/9. - The editor's `ops-api.spec.ts` covers no route of this lane and was not run; the two routes have unit tests instead. - **The dry run for the six test articles** (read-only, against the live corpus; `$T/r27i-delete-dry.txt`): none refused. | Article | Paths | Size | | --- | --- | --- | | `local-test-shondo-baking` | 1 | 18.6 MiB | | `local-test-shondo-fishing` | 2 (+ staged exports) | 25.8 MiB | | `ui-test-shondo-cats` | 1 | 23.4 MiB | | `r27-smoke-shondo` | 4 (+ `~/reports/articles/…/i5`, `i8`, exports) | 196 MiB | | `r27-smoke-cancel` | 1, in the making | 38 KiB | | `r27-smoke-research` | 1, in the making | 332 KiB | - About 264 MiB in all. No umtool project's manifest names any of the six. - The lock file and every directory were checked unchanged after the run. Left: - `busy.mjs`'s `/proc` scan (pipeline processes started outside umtool's job registry) is the CLI's, not a route's. The project route sees umtool's own jobs only, as the storage movers' routes do. - A take that fails validation (listed under **skipped**) has no delete button. `planTakeDelete` takes it by directory name. - The registry's per-article `.deleting-…` park is listed and removed by the next plan of the same article. Nothing sweeps a park whose article id is never deleted again. ### Follow-up rollout and the clean-up, as run (2026-10-13, orchestrator) - `archilyzer reports import-local-runs --apply` (run by the operator): `piratesoftware-ai-friends` i1 (current for the article and the video; project copied to `~/reports/articles/piratesoftware-ai-friends/i1`) and `api-shondo-recent` i1 (pending). - The operator's OK: the stopgap's test leftovers outside the corpus deleted (8 runs, 4 video projects, and `runs/api-shondo-fishing`); a delete path asked for (lane I, above). - `r27/delete` merged (`e20f1a37`), `main` fast-forwarded; the editor (`ja-ufAZ3iQDJKsSke3WV1`) and umtool (`ohTb3fC5zxfOU26zLBP9d`) rebuilt and restarted. - Through `archilyzer reports delete --apply`: `local-test-shondo-baking`, `local-test-shondo-fishing`, `ui-test-shondo-cats`, `r27-smoke-shondo` (with its i5/i8 projects and staged exports), `r27-smoke-cancel`, `r27-smoke-research` — none published, no `--force`; nothing left behind; the published list unchanged (27). ## Not in this release - Release 28: the remaining media tasks (clip selection and order, on-screen titles, teaser, flips, threads, YouTube title and description, proposed verdicts) on the same machinery. - The A7 leftovers: 42 post screenshots and 2 windows (`~/reports/release-26/scripts/a7-fill-media.sh`). - Deleting the candalyzer site. - The hub tombstone. - The owed items listed in `plans/local-llm-report-media.md`'s record.