# A piece ## Ids and addresses An article plus the video project(s) made from it is ONE piece with one page; a project no article claims is a piece too. Ids are namespaced (`lib/pieces/ids.mjs`); a bare `x/y` never parses. | Piece | Id | Page | |---|---|---| | a store article | `a:articles/` | `/articles/` | | a site's report | `a:/` | `/sites//` (the MCP's and the notes' address) | | a project no article claims | `p:` | `/projects/` | | a research case | `c:` | `/research/` ([research.md](research.md)) | | a recurring report's series | `s:` | `/series/` ([recurring.md](recurring.md)) | **Which article claims a project**, in order: an iteration's `projectDir` (with `current.video` choosing the Cut tab's project), the manifest's `article` key, then a unique slug match in the article's workspace (only this raises `link-ambiguous`). A `projectDir` outside `REPORTS_ROOT` is "not reachable here". **A claimed project's own address lands on its article** (a 307: `/projects/` with no view segment → the article's address, the same `?tab=`, a `?note=`'s tab, `?project=` when it is not the Cut). The benches stay at the project's address. ## The frame - **The head**: the trail, the title, the meta line (an article's status — **in the making**, **published**, **draft** — dates, revisions), **Active ▾** / **Parked ▾** / **Done ▾** (Park, Mark done, Reactivate, with **Undo**), **⋯** (the piece id and the kind's actions), the status line (`4 clips · 2 other · 0:12 · not built`). - **Under it**: the stage stepper; "from the board ", "a video of <article>" or "an edition of <series>" when so; a living report's cadence chip with **Pause schedule** / **Resume schedule** and **Tick now**; an article's **policy** chip (preset, model, today's spend of the daily cap → `/settings/generation`). - **The Next card** (Overview): the piece's top Inbox call — what, why, "then N more calls", and its ONE action, filled. A parked or done piece's Next is **Reactivate**. "Nothing waiting on you" when nothing is. - **Tabs** are `?tab=` (no tab is the Overview; a bad one is the Overview); counts in Meter. Only the tab on show is read. - **Keys** (not while typing, nor on a focused video, nor in a menu): `1`–`9` open the tabs, `n` runs the Next card's action. ### The stepper ONE rule (`lib/pieces/tabs.mjs` `pieceSteps`), read by the stepper, `data-piece-stage` and Work's stage facet alike: the current step is the **furthest stage reached**; a skipped stage before it is to do with its reason ("no report yet"); a stage that cannot apply is dimmed with its reason (a project no article claims has no Article stage); a piece marked done has done every stage that applies. | Flow | Reached when | |---|---| | Research → Article → Video → Deliver | Research: iterations, or a board that seeded it · Article: a report · Video: a claimed project (or one not reachable here) · Deliver: looks done (a final video and a `share-*` batch, or published with its video) | | Spec → Cuts → Done (a song) | Spec: a `spec.json` · Cuts: one cut built · Done: all four (the derived `shipped`) | ## A report video (`/projects/<path>`, and an article's video tabs) | Tab | Holds | |---|---| | **Overview** | the Next card, the project's decisions, "This video" (cut, final video, channel, cited, enumerated), the article and its newest iterations, the research board, the README | | **Cut** | **Walk the cut** (the filled action) → the clip bench; **Takes — N**; the timeline rows (drag or alt+↑/↓; each row's ⋯), **Fetch N unfetched clips via the editor**, show every quote (`?all=1`), corrections for the next pass | | **Media** | every drafted field, below | | **Build** | the build chain: a preset (preview, fast, final), **show the command**, **run**, **cancel** ([build.md](build.md)); the final video and **open in mix** | | **Deliver** | cuts and share batches, the export formats, the podcast | | **Sources** | every cited recording: cues, coverage, availability, **Re-check availability**; tag the cited videos (a tag, a scope, **tag N videos** / **untag N videos**) | | **History** | revisions (snapshot, diff), provenance, notes (prose and sibling `.md`) | **⋯**: **Delete project**. `?note=<id>` opens the tab its anchor is drawn on (a row's or an edit's → Cut, a timed note → Build). A project-wide call links its tab (`stale-build` → Build, `no-punctuation` → Sources). ### Media - ONE lit list of every drafted field, grouped by section (Cut, On-screen, Teaser, Flips, Threads, Narration, YouTube; chips narrow it), each line its words, its **provenance** (the draft file, when, the model, "attempt 2 of 2 chosen", refused attempts' rules, "repaired"), **Approve draft** / **Reject** with a note, the alternatives with **Use this**. - Each section's head: what it writes and **Draft with <model>** (force, entries, the job, the last run) — only on a project an article iteration made ("Drafting is off: no article iteration made this project."; a running iteration: "Drafting waits for <article> i<n>, which is <status>."). - Above: the counts, **Review drafts — N** (the review bench), the Draft everything model and **Draft everything**, **Approve all N**, the final gate's line. Then the On-screen panel and the YouTube text. - Keys in the list: j/k light a field, `a` approves it, `r` rejects it (the cursor to its note first). - "Awaiting review" is ONE count (`awaitingReview`): a field a model drafted whose verdict is not given on its current value. The Inbox card, the tab's count, **Approve all** and the review bench read it. Verdicts are `<project>/drafts.review.json`; a final build refuses an unapproved or rejected draft. ### The benches One shell (`components/projects/bench/BenchShell.tsx`): a top bar (home, **← the piece**, the kind, **N of M**, ‹ prev / next ›, the keys), the work, the **verdict bar** (the question, its consequence in bold, the actions; the first is the filled one), the reader on the right. | Bench | Address | Keys | The bar | |---|---|---|---| | Clip ([clip-bench.md](clip-bench.md)) | `/projects/<p>/clip/<id>` | `y` confirm, `x` reject (then 1–7, the reason), `[ ] , .` nudge, space play, `p` `n` walk | "Extend c04 to the end of the sentence?" → **Extend to m:ss** (or **Fetch to m:ss**), **Keep the cut here**; else "Keep c04 in the cut?" — **Yes, confirmed**, **Reject ▾** (doesn't match, wrong speaker, irrelevant, repeats, weak, privacy, other) | | Claim ([claim-bench.md](claim-bench.md)) | `/projects/<p>/claim/<id>` | j/k cue | "Save the ruling on k01?" → **Save ruling**, **Next claim** | | Narration | `/projects/<p>/narration` | j/k card, `a`, `r` | "Approve the narration of t1?" → **Approve**, **Reject with a note** | | Takes | `/projects/<p>/takes` | `n` `p` listen, `l` `m` `x` | "Is <take> the take for <group>?" → **Like**, **Maybe**, **No** | | Drafts review | `/projects/<p>/review` | j/k field, `a`, `r` | "Approve the drafted on-screen text of m01?" → **Approve draft**, **Reject with a note** | **Extend to …** saves at once; **Reset** (`R`) puts the window it replaced back. ## An article (`/articles/<id>`, `/sites/<site>/<report>`) | Tab | Holds | |---|---| | **Overview** | the Next card; Iterations (newest five, **All iterations →**, the current report's question and scope) and the video's decisions; Article · N sections (**Read →**); Cut · i<n> (**Open the cut →**), other cuts, "Possible videos"; the board; the last **Refresh** ([refresh.md](refresh.md)) | | **Article** | the reader with its notes (below); its switch **article** · **source** (`?tab=source`: workspace files, the slide lint) · **evidence**; the linked projects; "No report yet" for one in the making | | **Iterations** | every iteration, below (a site's report has none) | | **Cut** · **Media** · **Build** · **Deliver** · **Sources** · **History** | the claimed project's tabs, as above; "No video project yet" when there is none | **⋯**: **Refresh…**, **Delete article** (a store article; a published one offers **delete anyway**, which unpublishes it first), and the video's **Delete project**; a living report's Edit cadence and Delete schedule. Addresses: `?note=<id>` opens the Article tab on an article note (else the video's tab where it is drawn); `?rv=`, `?status=`, `?ws=&rel=` open the Article tab; `?project=<id>` another cut the piece owns; `?refresh=1` the refresh plan. ### Iterations An article made by a model is a series of **iterations** (`i1`, `i2`, …: common's `lib/report/iterations.ts`). umtool **starts** them and never writes one: each is a `report-draft` job the EDITOR runs, asked over its ops API with the shared `WORKER_TOKEN` (`lib/articles/generation.ts`). | On an iteration | What happens | |---|---| | **Use this iteration** | the article's `report.json` becomes its report (common's `makeCurrent`: locked, validated; the audience and the attached video kept) | | **New iteration** → **Start iteration** | a `revise-report` or `revise-video` of it, from feedback, on a model | | **Copy with model** | the same kind, base, question or feedback, on another model (an API sweep: its extractor too) | | **Media drafts →** | the iteration's cut's Media tab | | **Make the video** | the chain (`lib/report/chain.mjs`) as a umtool job: its steps, each one's status, **Run the chain** (resume, or from a step), **Cancel the chain** | | **Cancel i<n>** | `job cancel` on its editor job | | **Run** | the run page of a sweep ([research.md](research.md#agent-runs-researchruns-and-researchrunsarticlen)) | | compare | tick two, then **Compare iN and iM** (`/articles/<id>/compare?a=&b=`: sections and findings side by side, ops applied and refused, failed checks, both cuts) | | **Delete iN** | the plan, then **Confirm delete** (common's `deleteIteration` under the registry's lock). Refused: the current article or video, the iteration the report came from, a running one, one another revises or copies | | **Refresh…** (the tab's head) | [refresh.md](refresh.md) | A `research` iteration carries its research queue: each acquisition with **Yes** / **No**, and **Continue into a sweep** once nothing is pending (OPERATING.md, "Research runs"). The tab's head: the count, which is the article and the video, the article's spend and the day's against the daily cap. ### Reading and noting (the Article tab) The article in a ~70ch column, its notes in a rail (a drawer below 1100px); its video under the title takes timed notes (`n` with the video focused, or **Mark**). | To note | Do | |---|---| | a passage | select it → **Note** (or `n`) | | a section | **+ note** on its heading | | a citation | click it → the evidence panel → **+ note on this citation** | | the article | **+ whole article** | A passage note keeps its quote and 32 characters either side and is found again in the text as it is now (exact, then normalised, then by its surviving context); one whose quote is gone is **orphaned**. Keys: j/k move, `r` resolves, `e` edits, `n` notes, Escape closes. `?status=` and `?note=` open the rail on a filter or a note. **Copy agent brief** copies `/api/notes/context` (the `umtool notes` digest; [notes.md](notes.md)). Open notes are `open-note` calls in the Inbox. ### Evidence A citation's panel: its quote, speaker, date, label and link; ±6 cues of its record, the cited ones marked (click to seek); media, best first — the site's prepared clip, a clip window the editor fetched, a saved video or audio file, else the `fetch_clip` line (umtool never runs yt-dlp for it). A post shows its text and capture. The walk (`…/evidence?c=<id>`) is the same panel one citation at a time: j/k (or ←/→), space plays, `n` notes. **Add to video** (with a linked project) puts the cited span at the end of its timeline as a clip; the manifest is snapshotted first, so the Cut tab's **Undo** takes it back, and a generated manifest gets an `edit` note. ## A song (`/projects/<path>`) | Tab | Holds | |---|---| | **Overview** | the Next card, the song's decisions, the four cut slots (**All cuts →**), This song (cuts, variants, verdicts, plans, cover, looks done; **copy this song**), Song tools, the README | | **Cuts** | the four cut cards (poster, verdicts, the slot's and the file's notes, variants), what matches no cut name | | **Spec** | the spec sheet, the plans and their notes, `clips.csv` | | **Cover** | the cover bench ("No cover generated for <id> yet" when none) | | **Notes** | the note on the song; every other note, each linking the tab it is on | A cut's page, `/projects/<path>/<cut>`, is the Cuts tab's view of one cut (the four cuts beside the title; the cut bench, loudness, provenance). **The canonical address is the full path**; a bare basename resolves when unique. `?note=<target>` opens the tab it is written on: `song` → Notes; `cut:` `file:` `moment:` `source:` `clip:` → Cuts; `plan:` → Spec; `thumb:` → Cover. The cut page keeps `?v=`, `?plan=`, `?notes=all`. ## Projects: kinds, ids, routing A **project** is a directory under `REPORTS_ROOT` holding one piece of work; umtool finds them by walking the tree ([folders.md](folders.md)). A **kind** is what it is; a **template** is which configuration of that kind. | kind | template | marker | what it is | |---|---|---|---| | `report-video` | `cited-timeline` | `video.manifest.json` | a sweep report said in the sources' own voices | | `song` | `um-song` | `spec.json`, `verdicts.json`, or any cut | filler sounds playing a game tune | | `sweep-report` | `sweep` | a `*sweep*.md` and no manifest | a report that is not yet a video | - **Detection**: `project.json` (`{kind, template}`) wins; otherwise every kind's `detect()` runs on the entry NAMES. Two matches is an `ambiguous-project` decision, never a guess. - **An id is a PATH** relative to `REPORTS_ROOT` (`ferret-rescue`, `quartering-uh-song/videos/yoshi`), never the basename. A bare basename resolves only when unique; two projects sharing it get a page listing both canonical paths. - **`shadowed`** — the first segment is `at` (`RESERVED_BROWSE`, held equal to `app/projects/`'s static pages by an e2e spec): listed with a blocking decision, opened at `/projects/at?path=…`. **`unroutable`** — the name fails `isSegment()`: an info decision, opened the same way. - **Delete project** (⋯; `POST /api/projects/delete`, `lib/report/delete.mjs`): the plan (the directory with its size and biggest parts, and a media copy `umtool storage` linked), then **Confirm delete** or **Keep it**. Refused: a link or a path through one, one a umtool job works in, an article's current video or a running iteration's project; a manifest naming an article with a video attached needs **delete anyway**. Nothing outside `REPORTS_ROOT` and `MEDIA_ROOT` is touched. **Adding a kind** — a registry entry and one view, nothing else: 1. `lib/projects/kinds.mjs`: `id`, `template`, `label`, `badge`, `detect(names)`, `stages`, `decisionKinds`, and optionally `summarise`, `signature`, `decisions`, `views`, `piece` (its stepper flow). 2. A component in `components/projects/` and a case in `ProjectView.tsx`. `e2e/projects.spec.ts` fails when a kind id is written outside `lib/projects/` and `components/projects/`, when `RESERVED_BROWSE` drifts from the real static pages, and when a kind injected through `E2E_UMTOOL_EXTRA_KINDS` does not reach the index, the chips and the CLI with no code edit. | File | What | |---|---| | `lib/projects/kinds.mjs` | the registry (plain ESM, server-only) | | `lib/projects/walk.mjs` | the folder walk, routing, collapsing | | `lib/projects/{report,song,sweep}.mjs` | per-kind reading | | `lib/projects.ts` | the app's façade: caching, dispatch, the index, `resolveProjectPath` | | `lib/pieces.ts`, `lib/pieces/*` | the piece graph, ids, the frame, the tabs and the stepper | | `lib/project-types.ts` | types only, no `node:` import ever | ## Discovered by getting it wrong once **`lib/projects/kinds.mjs` is server-only**, despite being plain ESM: it imports the per-kind modules and those read the disk, so a client component importing it drags `node:fs` into the browser bundle. It passed `tsc` and 500'd every page. A client component takes `lib/project-types.ts`. `pnpm build`, not typecheck, catches it. **Watch the import cycle.** `songIds()` lives in `lib/projects/song-ids.mjs` because in `song.mjs` it closes `song → walk → kinds → song`; Turbopack then evaluates `kinds.mjs` mid-initialisation and every song page 500s with "Cannot access 'CUT_NAMES' before initialization". Nothing prerenders, so a build does not see it; a page render does. **Do not write a root path out by hand.** The song-decision dispatch had the production path hard-coded, so under the e2e fixture no song decisions were produced at all and the Inbox looked clean because it was empty. **Caches live on `globalThis`.** A module-level cache is one copy per Next bundle, so an API route's invalidation never reached the page rendered next (a new project 404'd; a deleted piece stayed on Work for 15 s).