diff --git a/.claude/settings.json b/.claude/settings.json deleted file mode 100644 index 8ab3f4cc..00000000 --- a/.claude/settings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extraKnownMarketplaces": { - "datum-local": { - "source": { - "source": "directory", - "path": "./vendor/claude-plugins" - } - } - }, - "enabledPlugins": { - "pstack@datum-local": true - } -} diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index acc19671..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -graphify-out/graph.json merge=graphify diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 765257f7..7096c09f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,9 +10,11 @@ on: permissions: contents: read +# A newer push supersedes an older run on the same pull request. Runs on main +# are never cancelled: two merges landing close together each keep their check. concurrency: group: ci-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: static: @@ -46,17 +48,18 @@ jobs: env: POSTGRES_USER: datum POSTGRES_PASSWORD: datum - POSTGRES_DB: datum + POSTGRES_DB: datum_test ports: - 5432:5432 options: >- - --health-cmd "pg_isready -U datum -d datum" + --health-cmd "pg_isready -U datum -d datum_test" --health-interval 5s --health-timeout 5s --health-retries 10 env: - DATABASE_URL: postgresql://datum:datum@127.0.0.1:5432/datum + # The suite refuses a database whose name has no "test" in it. + DATABASE_URL: postgresql://datum:datum@127.0.0.1:5432/datum_test PAYLOAD_SECRET: ci-payload-secret-not-for-production MOCK_MODE: 'true' NODE_OPTIONS: --no-deprecation @@ -76,6 +79,65 @@ jobs: - name: Test cms integration run: npm run test:int --workspace cms + e2e: + runs-on: ubuntu-latest + timeout-minutes: 45 + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: datum + POSTGRES_PASSWORD: datum + POSTGRES_DB: datum_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U datum -d datum_test" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + + env: + # Playwright starts its own dev server from this environment, and refuses + # a database whose name has no "test" in it. + DATABASE_URL: postgresql://datum:datum@127.0.0.1:5432/datum_test + PAYLOAD_SECRET: ci-payload-secret-not-for-production + MOCK_MODE: 'true' + NODE_OPTIONS: --no-deprecation + # The seed boots Payload too; on a migration-built database it must not + # run the dev schema push (which can also stop at a prompt and exit 0). + DISABLE_DEV_PUSH: 'true' + + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup Node.js + uses: actions/setup-node@v7 + with: + node-version: '22' + cache: npm + - name: Install dependencies + run: npm ci + - name: Migrate cms database + run: npm run payload --workspace cms -- migrate + # The specs need the templates (several of them), the demo workspace + # assets and the admin user that the seed installs. + - name: Seed cms database + run: npm run seed --workspace cms + - name: Install Playwright browser + run: npx playwright install --with-deps chromium + - name: Test cms end to end + run: npm run test:e2e --workspace cms + - name: Upload Playwright report + if: failure() + uses: actions/upload-artifact@v7 + with: + name: playwright-report + path: | + cms/playwright-report/ + cms/test-results/ + retention-days: 7 + build: runs-on: ubuntu-latest timeout-minutes: 30 @@ -118,15 +180,17 @@ jobs: ci: name: ci runs-on: ubuntu-latest - needs: [static, integration, build] + needs: [static, integration, e2e, build] if: always() steps: - name: Require all checks to succeed env: STATIC_RESULT: ${{ needs.static.result }} INTEGRATION_RESULT: ${{ needs.integration.result }} + E2E_RESULT: ${{ needs.e2e.result }} BUILD_RESULT: ${{ needs.build.result }} run: | test "$STATIC_RESULT" = success test "$INTEGRATION_RESULT" = success + test "$E2E_RESULT" = success test "$BUILD_RESULT" = success diff --git a/.gitignore b/.gitignore index 01aa2405..aef3bd2d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,5 +50,5 @@ yarn-error.log* .omc/ .playwright-mcp/ -# Graphify caches and machine-local outputs. Shared products are force-added. +# Graphify output is built locally with `graphify update .` and never committed. graphify-out/ diff --git a/.graphifyignore b/.graphifyignore index b5fa96af..d4444e7e 100644 --- a/.graphifyignore +++ b/.graphifyignore @@ -1,5 +1,4 @@ # Keep the Datum graph focused on maintained project code. -vendor/ .codex/ .agents/ graphify-out/ @@ -7,9 +6,6 @@ graphify-out/ .impeccable/ .omc/ -# One-off audit artefacts (96 screenshots and a capture log). -docs/audits/ - # Dependency lockfiles and generated database snapshots duplicate source data. package-lock.json cms/src/migrations/*.json diff --git a/AGENTS.md b/AGENTS.md index 603fc9ca..e8e38c1a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,6 +44,7 @@ npm run jobs:run --workspace cms # production content worker - Next loads `cms/.env`; the pipeline loads `cms/.env` then root `.env`. Shell variables win. - Use a per-worktree database for schema work. Decline dev-push prompts that would drop another branch's tables. - Integration tests need a migration-built database because Payload dev push is disabled under Vitest. +- The CMS test suites refuse to start unless the `DATABASE_URL` database name contains `test` (e.g. `datum_test`), or `DATUM_TEST_DATABASE_OK=true` is set. They rewrite workspace state and add append-only rows, and `cms/.env` is loaded by default. Never opt in on a database you care about. - Preserve append-only audit and information-gain records and the review gates in `articleReviewGate.ts`. - Mock mode is the local default. Do not trigger paid APIs unless the task explicitly requires live mode. @@ -59,13 +60,13 @@ Co-Authored-By: (the agent's name and attribution byline) ## graphify -This project has a knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships. +This project can build a local knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships. The graph is not tracked: build it with `graphify update .` after cloning (see `CONTRIBUTING.md`). A missing or dirty graphify-out/ is normal and is never committed. When the user types `/graphify`, use the installed graphify skill or instructions before doing anything else. Rules: - For codebase questions, first run `graphify query ""` when graphify-out/graph.json exists. Use `graphify path "" ""` for relationships and `graphify explain ""` for focused concepts. These return a scoped subgraph, usually much smaller than GRAPH_REPORT.md or raw grep output. -- Dirty graphify-out/ files are expected after hooks or incremental updates; dirty graph files are not a reason to skip graphify. Only skip graphify if the task is about stale or incorrect graph output, or the user explicitly says not to use it. +- Dirty graphify-out/ files are expected after hooks or incremental updates; dirty graph files are not a reason to skip graphify. If graph.json is missing, run `graphify update .` first. Only skip graphify if the task is about stale or incorrect graph output, or the user explicitly says not to use it. - If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing. - Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context. - After modifying code, run `graphify update .` to keep the graph current (AST-only, no API cost). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 49a928a4..acd687cd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,23 +8,25 @@ Thanks for contributing. This guide covers local setup, checks, and how we revie 2. Follow the [Quick start](README.md#quick-start) in the root README (`cp` env files, `docker compose up -d`, `npm install`, `npm run seed`). 3. Use `MOCK_MODE=true` unless you intentionally need live Anthropic/Ahrefs calls. -## Shared code graph +## Local code graph -Datum uses [Graphify's team setup](https://github.com/Graphify-Labs/graphify#team-setup). +Datum uses [Graphify](https://github.com/Graphify-Labs/graphify) to answer code +questions from a queryable graph. The graph is built on your machine and is not +committed: `graphify-out/` is git-ignored, and a missing or dirty graph is normal. The Codex skill and query-first instructions are checked into `.codex/` and -`AGENTS.md`. Install the CLI and Git hooks once per clone from the repo root -(Python 3.10+ and [uv](https://docs.astral.sh/uv/) are required): +`AGENTS.md`. Install the CLI once (Python 3.10+ and +[uv](https://docs.astral.sh/uv/) are required), then build the graph after cloning: ```bash uv tool install graphifyy==0.9.77 -graphify hook install -graphify hook status +graphify update . # local AST pass, no API cost ``` -The hooks rebuild the code graph in the background after commits and branch -switches, and register a merge driver for `graph.json`. Re-run `graphify hook -install` after upgrading or reinstalling the CLI to refresh its interpreter -path. If `graphify` is not found, run `uv tool update-shell` and open a new terminal. +If `graphify` is not found, run `uv tool update-shell` and open a new terminal. +Re-run `graphify update .` after code changes, a `git pull`, or a merge. Do not +run `graphify hook install` in this repository: it also registers a git merge +driver and writes a `.gitattributes` line for `graphify-out/graph.json`, which +only made sense while the graph was tracked. The checked-in `.codex/skills/graphify/SKILL.md` bootstrap only detects an existing installation; it never installs or upgrades packages automatically. @@ -35,35 +37,19 @@ review the generated diff before committing it. Do not restore `uv tool run --from graphifyy`, automatic install/upgrade commands, or `--break-system-packages` fallbacks. -Teammates can query the shared graph immediately after cloning: +Query the graph before searching raw source: ```bash graphify query "articleReviewGate brief approval" graphify explain "completeJSONLogged" -graphify update . # after code changes, git pull, or a merge; local AST only ``` -The graph covers code relationships without paid API calls. Documentation and -media need a separate semantic pass through `$graphify --update` in Codex; -`graphify update .` does not perform that pass. `.graphifyignore` excludes -vendored plugins, agent state, dependency lockfiles, and generated migration -JSON snapshots; migration TypeScript remains indexed. The AST parser may omit -unsupported files or files without symbols, so use source files to verify details. -Initial validation found no missing or dangling edge endpoints. It flagged three -self-links: `sameValue` and `upsertDomain` recurse, while the `create` test helper's -call to `payload.create` was misidentified as recursion. Treat graph edges as -navigation hints and confirm ambiguous calls in source. - -Share only the queryable graph, report, and portable manifest. The rest of -`graphify-out/` stays ignored, including caches, local HTML, and machine paths: - -```bash -git add -f graphify-out/graph.json graphify-out/GRAPH_REPORT.md graphify-out/manifest.json -``` - -The hooks finish asynchronously, so run `graphify update .` before staging these -files when the latest code changes must be included. A new clone must install -its own hooks; `.git/hooks/` and the merge-driver Git configuration are local. +The graph covers code relationships. Documentation and media need a separate +semantic pass through `$graphify --update` in Codex; `graphify update .` does not +perform that pass. `.graphifyignore` excludes agent state, dependency lockfiles, +and generated migration JSON snapshots; migration TypeScript remains indexed. +The AST parser may omit unsupported files or files without symbols, so treat +graph edges as navigation hints and confirm ambiguous calls in source. ## Commands @@ -90,7 +76,19 @@ npm test --workspace pipeline npx tsx --test pipeline/test/structuralChecks.test.ts ``` -Use **npm** for scripts and CI. `npm test --workspace cms` runs both CMS suites. Playwright starts its own dev server on `TEST_PORT` (default 3101), so do not start `npm run dev` in `cms/` first: Next refuses a second dev server in the same directory. To drive a server you already have running, pass its address: `TEST_BASE_URL=http://127.0.0.1:3000 npm run test:e2e --workspace cms`. +The CMS integration suite and the Playwright suite rewrite workspace state (audiences, profile, brand voice, webhook settings) and add rows that are never removed, so they refuse to start unless the `DATABASE_URL` database name contains `test`. Create a separate database for them, migrate it, and export its URL in the shell that runs the tests: + +```bash +createdb -O datum datum_test +export DATABASE_URL=postgresql://datum:datum@127.0.0.1:5432/datum_test +npm run payload --workspace cms -- migrate +``` + +`cms/.env` is loaded too, so a plain `npm run test:int` otherwise uses your working database and stops with an error. To run against a database whose name has no `test` in it anyway, set `DATUM_TEST_DATABASE_OK=true`; that database will be modified. Playwright applies the same rule, also with `TEST_BASE_URL`: the specs write to `DATABASE_URL` through Payload whichever server they drive. + +Use **npm** for scripts and CI. `npm test --workspace cms` runs both CMS suites. Playwright starts its own dev server on `TEST_PORT` (default 3101), so do not start `npm run dev` in `cms/` first: Next refuses a second dev server in the same directory. To drive a server you already have running, pass its address: `TEST_BASE_URL=http://127.0.0.1:3000 npm run test:e2e --workspace cms`; start that server with `SITE_URL` set to its own address, `DISABLE_DEV_PUSH=true` and the same `DATABASE_URL` as the tests. + +The Playwright suite needs a migrated **and seeded** test database (`DISABLE_DEV_PUSH=true npm run seed --workspace cms` installs the templates, demo workspace and admin user the specs use) and a browser: `npx playwright install chromium` once. CI runs it as the `e2e` job on the same steps. ## Schema / types diff --git a/DESIGN.md b/DESIGN.md index 2b2e1264..f65aa424 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -248,6 +248,11 @@ components: --- +> **Scope.** This is the visual reference for the public reader pages +> (`cms/src/app/(frontend)`), which still follow it. It was written as an analysis +> of Notion's design language and does not describe the admin. The admin's tokens +> live in `cms/src/components/ops/ops.css` and are checked by +> `cms/tests/int/dsContrast.int.spec.ts`. ## Overview diff --git a/README.md b/README.md index 46e620cd..d7ac9e44 100644 --- a/README.md +++ b/README.md @@ -152,8 +152,9 @@ For running the test suites. Set these in your shell, not in a committed `.env`. | Variable | Purpose | | --- | --- | +| `DATUM_TEST_DATABASE_OK` | `true` to let the CMS integration suite (and Playwright, when it starts its own server) run against a database whose name does not contain `test`. Without it they refuse to start, because they rewrite workspace state and add rows that are never removed. Prefer a separate database such as `datum_test`; see [CONTRIBUTING.md](CONTRIBUTING.md). | | `DISABLE_DEV_PUSH` | `true` to turn off Payload's dev schema push, which `next dev` otherwise runs on boot. Playwright's `test:e2e` script sets it automatically, because E2E runs on a migration-built database and the processes that boot Payload for seeding must not push over it; set it yourself in the shell that runs `npm run dev` when you point Playwright at that server via `TEST_BASE_URL` instead. | -| `TEST_BASE_URL` | Base URL Playwright drives instead of starting its own dev server — e.g. `http://127.0.0.1:3000` to test against a server you already started with `npm run dev`. Unset, Playwright starts its own on `TEST_PORT`. | +| `TEST_BASE_URL` | Base URL Playwright drives instead of starting its own dev server — e.g. `http://127.0.0.1:3000` to test against a server you already started with `npm run dev`. Unset, Playwright starts its own on `TEST_PORT` (and sets `SITE_URL` for it). A server you start yourself needs `SITE_URL` set to its own address, or the structured-data spec fails. | | `TEST_PORT` | Port for the dev server Playwright starts when `TEST_BASE_URL` is unset (default `3101`). | | `DEV_ALLOWED_ORIGINS` (cms/.env only) | Comma-separated extra hosts allowed to load `next dev` resources, for reaching a dev server by a name other than `localhost` or `127.0.0.1` (a LAN or tailnet hostname). Development only. | @@ -180,9 +181,8 @@ For running the test suites. Set these in your shell, not in a committed `.env`. - [docs/tenant-context.md](docs/tenant-context.md) explains the workspace profile, audiences, positioning and evidence bank, how they gate a run, and how they reach the prompts. - [docs/information-gain.md](docs/information-gain.md) explains claim scoring, the corpus, and the source review queue. - [docs/operations.md](docs/operations.md) documents the job queues, webhooks, scheduled publishing, caching, and the fixed limits. -- [docs/open-source-checklist.md](docs/open-source-checklist.md) lists the maintainer steps for making the repository public. -Agent helpers live under `.claude/` and `vendor/claude-plugins/`. Datum runs without them. +Agent helpers live under `.claude/`. Datum runs without them. The pstack plugin is not vendored; install it per user from [github.com/cursor/plugins](https://github.com/cursor/plugins) if you want it. ## License diff --git a/cms/.vscode/launch.json b/cms/.vscode/launch.json index 572ee15f..e597b292 100644 --- a/cms/.vscode/launch.json +++ b/cms/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Next.js: debug full stack", "type": "node", "request": "launch", - "program": "${workspaceFolder}/node_modules/next/dist/bin/next", + "program": "${workspaceFolder}/../node_modules/next/dist/bin/next", "runtimeArgs": ["--inspect"], "skipFiles": ["/**"], "serverReadyAction": { diff --git a/cms/.vscode/settings.json b/cms/.vscode/settings.json index dcc6e0a0..dad91bb5 100644 --- a/cms/.vscode/settings.json +++ b/cms/.vscode/settings.json @@ -31,7 +31,7 @@ "editor.formatOnSave": true }, "editor.formatOnSaveMode": "file", - "js/ts.tsdk.path": "node_modules/typescript/lib", + "js/ts.tsdk.path": "../node_modules/typescript/lib", "js/ts.tsdk.promptToUseWorkspaceVersion": true, "[javascript][typescript][typescriptreact]": { "editor.codeActionsOnSave": { diff --git a/cms/playwright.config.ts b/cms/playwright.config.ts index 971a037f..ab8af53a 100644 --- a/cms/playwright.config.ts +++ b/cms/playwright.config.ts @@ -6,9 +6,16 @@ import { defineConfig, devices } from '@playwright/test' */ import 'dotenv/config' +import { assertTestDatabase } from './tests/helpers/testDatabaseGuard' + const testPort = process.env.TEST_PORT || '3101' const testBaseURL = process.env.TEST_BASE_URL || `http://127.0.0.1:${testPort}` +// The specs seed users, create and archive articles and rewrite globals through +// Payload against `DATABASE_URL`, whether Playwright starts the server or +// `TEST_BASE_URL` points at one you started, so the guard always applies. +assertTestDatabase() + /** * See https://playwright.dev/docs/test-configuration. */ @@ -23,7 +30,7 @@ export default defineConfig({ // CI so dashboard redirect expectations cannot race another spec. workers: 1, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: [['list'], ['html', { open: 'never' }]], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ @@ -42,7 +49,12 @@ export default defineConfig({ ? undefined : { command: `npm run dev -- --hostname 127.0.0.1 --port ${testPort}`, + // Structured data only carries absolute URLs when SITE_URL is set + // (see `getConfiguredSiteUrl`), and frontend.e2e.spec.ts reads them. + env: { SITE_URL: testBaseURL }, reuseExistingServer: false, + // A cold dev server compiles the first page on request; CI is slower than a laptop. + timeout: 180_000, url: testBaseURL, }, }) diff --git a/cms/src/collections/Media.ts b/cms/src/collections/Media.ts index 0cc41099..18a67eef 100644 --- a/cms/src/collections/Media.ts +++ b/cms/src/collections/Media.ts @@ -15,5 +15,9 @@ export const Media: CollectionConfig = { required: true, }, ], - upload: true, + upload: { + // Media is world-readable and served from the app origin, so accept raster + // images only: an SVG or HTML upload would run in that origin. + mimeTypes: ['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/avif'], + }, } diff --git a/cms/src/components/ops/TopicDiscovery.tsx b/cms/src/components/ops/TopicDiscovery.tsx index aae3f8b1..614f335e 100644 --- a/cms/src/components/ops/TopicDiscovery.tsx +++ b/cms/src/components/ops/TopicDiscovery.tsx @@ -188,7 +188,7 @@ export function TopicDiscovery({ {c.alreadyTaken ? ( {' '} - {c.archived ? 'removed from the board' : 'already on the board'} + {c.archived ? 'removed from Content' : 'already in Content'} ) : null} @@ -376,7 +376,7 @@ export function TopicDiscovery({

The template decides the shape of the article — a how-to, a comparison, or a ranked list — and QA checks the draft against it, so pick the one that matches how - you would answer the topic. You can change it per article on the board later. + you would answer the topic. You can change it per article later.

)} diff --git a/cms/src/components/ops/ops.css b/cms/src/components/ops/ops.css index 43d55b1c..7522850e 100644 --- a/cms/src/components/ops/ops.css +++ b/cms/src/components/ops/ops.css @@ -1,4 +1,4 @@ -/* Datum ops views — tokens from root DESIGN.md (Notion) */ +/* Datum ops views — admin tokens are defined below; root DESIGN.md covers the public reader only */ /* ── Colour tokens (F1) ────────────────────────────────────────────────── `--ds-*` hold literal values so contrast is a property of this file rather @@ -72,7 +72,6 @@ --ops-green: var(--ds-success-text); --ops-green-deco: var(--ds-success-deco); --ops-sky: var(--ds-info-text); - --ops-sky-deco: var(--ds-info-deco); --ops-red: var(--ds-danger-text); --ops-red-deco: var(--ds-danger-deco); @@ -269,6 +268,8 @@ html[data-theme='dark'] { margin: 0; color: var(--ops-ink-muted); font-size: 14px; + flex-basis: 100%; + text-align: right; } .datum-ops__run-form { @@ -332,11 +333,6 @@ html[data-theme='dark'] { opacity: 0.5; } -.datum-ops__form-message { - flex-basis: 100%; - text-align: right; -} - @media (max-width: 760px) { .datum-ops__run-form, .datum-ops__run-form label:not(.datum-ops__cost-confirm) { @@ -904,17 +900,6 @@ html[data-theme='dark'] { letter-spacing: -0.02em; } -.datum-ops__field input[type='number'], -.datum-ops__field input[type='text'] { - width: 100%; - border: 1px solid var(--ops-hairline); - border-radius: var(--ops-radius-xs); - padding: 6px 8px; - background: var(--ops-canvas); - color: var(--ops-ink); - font: inherit; -} - .datum-ops__field input[type='checkbox'] { margin-right: 6px; } @@ -1481,10 +1466,6 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { max-width: 860px; } -.datum-ops__tpl-new { - border-top: 1px solid var(--ops-hairline); -} - .datum-ops__review-footer { margin-top: 24px; padding-top: 16px; @@ -2012,7 +1993,7 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { /* ── Run status panel ─────────────────────────────────────────────────── Starting a run used to produce one toast and then silence. This is the - board's running commentary: what is happening now, and what a finished + running commentary: what is happening now, and what a finished run actually achieved — including the articles it could not move. */ .datum-ops__runstatus { @@ -2049,12 +2030,6 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { margin: 0; } -.datum-ops__pill--running, -.datum-ops__pill--queued { - background: var(--ops-tint-primary); - color: var(--ops-primary-text); -} - .datum-ops__pill--succeeded { background: var(--ops-tint-green); color: var(--ops-green); @@ -2094,6 +2069,7 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { .datum-ops__tpl-new { padding: 14px 16px; + border-top: 1px solid var(--ops-hairline); border-bottom: 1px solid var(--ops-hairline); background: var(--ops-canvas-soft); } @@ -2118,9 +2094,8 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { } /* ── Global run bar ───────────────────────────────────────────────────── - Mounted from a Payload provider, so it is outside `.datum-ops` and cannot - inherit those tokens — every colour here resolves against Payload's own - theme variables, with a literal fallback for each. */ + Mounted from a Payload provider, so it is outside `.datum-ops`. It only uses + the `--ops-*` and `--ds-*` tokens (colour and motion), which live on :root. */ .datum-runbar { position: fixed; @@ -3006,9 +2981,7 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { font-size: 14px; } -/* ── First run ─────────────────────────────────────────────────────────── */ - -/* What is still missing before a run, one row per governance problem. */ +/* ── Setup checklist: tag on recommended (non-blocking) rows ──────────── */ .datum-first__optional { font-style: normal; @@ -3019,7 +2992,8 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { margin-right: 8px; } -/* ── Runtime banner (outside .datum-ops, so Payload theme tokens) ───────── */ +/* ── Runtime banner (outside .datum-ops; warning colours come from Payload's + theme, each with a literal fallback) ────────────────────────────── */ .datum-runtime { position: sticky; @@ -3083,6 +3057,7 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { .datum-ops__table th { font-weight: 600; opacity: 0.7; + white-space: nowrap; } /* ── Setup hub ─────────────────────────────────────────────────────────── */ @@ -3111,9 +3086,9 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { align-items: start; gap: 14px; padding: 16px 18px; - border: 1px solid var(--ops-hairline, var(--theme-elevation-150)); - border-radius: var(--ops-radius-lg, 8px); - background: var(--ops-canvas, transparent); + border: 1px solid var(--ops-hairline); + border-radius: var(--ops-radius-lg); + background: var(--ops-canvas); box-sizing: border-box; max-width: 100%; } @@ -3222,10 +3197,6 @@ body:has(.datum-runbar) [data-sonner-toaster][data-y-position='bottom'] { margin: 0; } -.datum-ops__table th { - white-space: nowrap; -} - /* The webhook signing secret: a password input with a deliberate reveal. */ .datum-secret-field__wrap { display: flex; diff --git a/cms/src/components/ops/setupChecklistData.ts b/cms/src/components/ops/setupChecklistData.ts index de9a5fe6..bb8152bd 100644 --- a/cms/src/components/ops/setupChecklistData.ts +++ b/cms/src/components/ops/setupChecklistData.ts @@ -1,10 +1,25 @@ import { suggestionDTO } from '../../lib/setupSuggestions/presentation' +import { sql } from '@payloadcms/db-postgres' import type { Payload } from 'payload' import { loadWorkspaceSetup, type WorkspaceSetupData } from '../../lib/loadWorkspaceReadiness' import { formatAuditTimestamp } from './articleStatus' import type { SetupChecklistData } from './SetupChecklist' +/** + * How many pages the last site fetch stored. The pages are crawled text and can + * be large, so the length is taken in SQL instead of loading the JSON to count it. + */ +async function countSitePages(payload: Payload): Promise { + const result = await payload.db.drizzle.execute<{ count: number | null }>(sql` + SELECT CASE WHEN jsonb_typeof(site_pages) = 'array' + THEN jsonb_array_length(site_pages) ELSE 0 END AS count + FROM ${payload.db.tables.workspace_profile} + LIMIT 1 + `) + return Number(result.rows[0]?.count ?? 0) +} + /** * Everything the setup hub renders, gathered once. * @@ -12,7 +27,8 @@ import type { SetupChecklistData } from './SetupChecklist' * the same way rather than each deciding what a row says. Readiness supplies * the states; the two extra reads are for the two names a person recognises — * the active voice and the primary audience — which readiness only tracks by - * id, and for the site-page crawl, which lives on the profile global. + * id, and for the site-page crawl, which lives on the profile global (its + * count is read in SQL so the crawled text never loads). * * The fetched-at stamp is formatted here, on the server, in UTC. A relative * "2 h ago" computed in the browser would disagree with the server's own @@ -22,14 +38,15 @@ export async function loadSetupChecklistData( payload: Payload, loadedSetup?: WorkspaceSetupData, ): Promise { - const [setup, profileDoc, suggestions] = await Promise.all([ + const [setup, profileDoc, sitePages, suggestions] = await Promise.all([ loadedSetup ?? loadWorkspaceSetup(payload), payload.findGlobal({ slug: 'workspace-profile', - select: { sitePages: true, sitePagesFetchedAt: true }, + select: { sitePagesFetchedAt: true }, depth: 0, overrideAccess: true, }), + countSitePages(payload), payload.find({ collection: 'setup-suggestions', where: { status: { equals: 'open' } }, @@ -58,9 +75,6 @@ export async function loadSetupChecklistData( } } - const sitePages = Array.isArray((profileDoc as { sitePages?: unknown }).sitePages) - ? ((profileDoc as { sitePages: unknown[] }).sitePages.length as number) - : 0 const fetchedAt = (profileDoc as { sitePagesFetchedAt?: string | null }).sitePagesFetchedAt ?? null diff --git a/cms/src/lib/loadWorkspaceReadiness.ts b/cms/src/lib/loadWorkspaceReadiness.ts index 9ca090fa..ba750d06 100644 --- a/cms/src/lib/loadWorkspaceReadiness.ts +++ b/cms/src/lib/loadWorkspaceReadiness.ts @@ -15,18 +15,9 @@ import { type WorkspaceReadiness, } from './workspaceReadiness' +/** What the setup data keeps of the newest run: whether one is still active. */ export interface PipelineRunSummary { - id: number | string - runId: string - source: 'admin' | 'cli' | 'selected' status: 'queued' | 'running' | 'succeeded' | 'failed' - mode: 'mock' | 'live' - configFingerprint: string - articles: number[] - finalStatuses: Record | null - errorSummary: string | null - createdAt: string - completedAt: string | null } export interface IcpOption { @@ -51,18 +42,6 @@ export interface WorkspaceSetupData { latestRun: PipelineRunSummary | null } -function relationshipIds(value: unknown): number[] { - if (!Array.isArray(value)) return [] - return value.flatMap((item) => { - if (typeof item === 'number') return [item] - if (item && typeof item === 'object' && 'id' in item) { - const id = item.id - return typeof id === 'number' ? [id] : [] - } - return [] - }) -} - export async function loadWorkspaceSetup(payload: Payload): Promise { const [ voices, @@ -112,18 +91,7 @@ export async function loadWorkspaceSetup(payload: Payload): Promise | null | undefined) ?? null, - errorSummary: rawRun.errorSummary ?? null, - createdAt: rawRun.createdAt, - completedAt: rawRun.completedAt ?? null, - } satisfies PipelineRunSummary) - : null + const latestRun: PipelineRunSummary | null = runs.docs[0] ? { status: runs.docs[0].status } : null const readiness = evaluateWorkspaceReadiness({ env: process.env, diff --git a/cms/src/lib/setupSuggestions/collect.ts b/cms/src/lib/setupSuggestions/collect.ts index 5c639ab2..777400ea 100644 --- a/cms/src/lib/setupSuggestions/collect.ts +++ b/cms/src/lib/setupSuggestions/collect.ts @@ -103,6 +103,16 @@ export async function collectSetupSuggestions( payload.find({ collection: 'articles', where: { status: { equals: 'published' } }, + // The comparison reads the keyword and the published text fields only. + select: { + keyword: true, + title: true, + body: true, + titleTag: true, + metaDescription: true, + ogTitle: true, + ogDescription: true, + }, pagination: false, depth: 0, overrideAccess: true, diff --git a/cms/tests/e2e/admin.e2e.spec.ts b/cms/tests/e2e/admin.e2e.spec.ts index 869d1bac..e96f04ec 100644 --- a/cms/tests/e2e/admin.e2e.spec.ts +++ b/cms/tests/e2e/admin.e2e.spec.ts @@ -134,6 +134,9 @@ test.describe('Admin Panel', () => { const toggler = page.locator('.template-default__nav-toggler').first() const settle = () => page.waitForTimeout(1000) + // A click before hydration is lost (the toggler has no handler yet), which + // is what made this flaky as the first spec on a cold dev server. + await expect(aside).toHaveClass(/nav--nav-hydrated/) await expect(aside).toHaveClass(/nav--nav-open/) await toggler.click() await expect(aside).not.toHaveClass(/nav--nav-open/) diff --git a/cms/tests/e2e/adminPerformance.e2e.spec.ts b/cms/tests/e2e/adminPerformance.e2e.spec.ts index 163421da..cead9675 100644 --- a/cms/tests/e2e/adminPerformance.e2e.spec.ts +++ b/cms/tests/e2e/adminPerformance.e2e.spec.ts @@ -1,8 +1,20 @@ import { randomUUID } from 'node:crypto' import { test, expect } from '@playwright/test' import type { Payload } from 'payload' +import type { Page } from '@playwright/test' import { opsPayload, retireArticles, seedArticle } from '../helpers/seedContentOps' +/** + * Navigate and wait for the admin to hydrate before interacting. Input before + * hydration is lost on a cold dev server: a controlled checkbox is reset, a + * search field has no change handler yet, a button has no click handler. + */ +async function gotoHydrated(page: Page, url: string) { + const response = await page.goto(url) + await expect(page.locator('aside.nav')).toHaveClass(/nav--nav-hydrated/) + return response +} + const marker = `pagination-${randomUUID()}` // Deliberately does not contain `marker`: the pagination test searches // `q=${marker}` and counts every row that matches, so a fixture whose keyword @@ -75,7 +87,7 @@ test.beforeEach(async ({ page }) => { test('content pagination, search, selection, and browser history', async ({ page }) => { const errors: string[] = [] page.on('pageerror', (error) => errors.push(error.message)) - await page.goto(`/admin/ops/content?filter=all&q=${marker}&page=1`) + await gotoHydrated(page, `/admin/ops/content?filter=all&q=${marker}&page=1`) await expect(page.locator('.datum-content__row')).toHaveCount(50) const checkbox = page.getByRole('checkbox').first() await checkbox.check() @@ -101,25 +113,38 @@ test('content pagination, search, selection, and browser history', async ({ page }) test('review loads model evidence once on expansion', async ({ page }) => { - const response = await page.goto(`/admin/ops/articles/${ids[0]}`) + const response = await gotoHydrated(page, `/admin/ops/articles/${ids[0]}`) expect(await response?.text()).not.toContain('DEFERRED_EVIDENCE_SENTINEL') + // `onToggle` is attached by React, so a click before hydration opens the + //
natively and never asks for the evidence (`gotoHydrated` waits). + // Only the evidence action's own requests count. The run bar also polls by + // POST (a server action) every 15 s, and any POST counted here would make + // the test fail whenever a poll lands inside it. That action's arguments + // carry the article id; the poll's do not. + const evidenceRequests: string[] = [] + page.on('request', (request) => { + if (request.method() === 'POST' && (request.postData() ?? '').includes('"articleId"')) { + evidenceRequests.push(request.postData() ?? '') + } + }) const entry = page .locator('.datum-ops__timeline-item') .filter({ hasText: 'generate call completed' }) await entry.getByText('Evidence', { exact: true }).click() await expect(entry.locator('pre')).toContainText('DEFERRED_EVIDENCE_SENTINEL') - let requests = 0 - page.on('request', (request) => { - if (request.method() === 'POST') requests++ - }) + // The filter above does match the evidence request: without this, a filter + // that matched nothing would make the zero below prove nothing. + expect(evidenceRequests).toHaveLength(1) await entry.getByText('Evidence', { exact: true }).click() await entry.getByText('Evidence', { exact: true }).click() await expect(entry.locator('pre')).toContainText('Full model response') - expect(requests).toBe(0) + // Give a re-fetch on re-open time to start before asserting there was none. + await page.waitForTimeout(500) + expect(evidenceRequests).toHaveLength(1) }) test('reports render summaries and switch period', async ({ page }) => { - await page.goto('/admin/ops/reports?period=all') + await gotoHydrated(page, '/admin/ops/reports?period=all') await expect(page.getByRole('heading', { name: 'Reports', exact: true })).toBeVisible() await expect(page.getByRole('heading', { name: 'Spend by stage' })).toBeVisible() await page.getByRole('button', { name: 'Month', exact: true }).click() @@ -130,7 +155,7 @@ test('reports render summaries and switch period', async ({ page }) => { test('typing survives an older search response and Back cancels pending debounce', async ({ page, }) => { - await page.goto(`/admin/ops/content?filter=all&q=${marker}&page=1`) + await gotoHydrated(page, `/admin/ops/content?filter=all&q=${marker}&page=1`) const search = page.getByRole('searchbox', { name: 'Search content' }) const firstQuery = `${marker} topic 1` const newerQuery = `${marker} topic 12` @@ -170,7 +195,7 @@ test('typing survives an older search response and Back cancels pending debounce }) test('search keeps the requested tab while its response is delayed', async ({ page }) => { - await page.goto(`/admin/ops/content?filter=all&q=${marker}&page=1`) + await gotoHydrated(page, `/admin/ops/content?filter=all&q=${marker}&page=1`) let release: () => void = () => { throw new Error('Tab request not intercepted') } diff --git a/cms/tests/e2e/redirects.e2e.spec.ts b/cms/tests/e2e/redirects.e2e.spec.ts index d53e3616..699c08bd 100644 --- a/cms/tests/e2e/redirects.e2e.spec.ts +++ b/cms/tests/e2e/redirects.e2e.spec.ts @@ -1,13 +1,27 @@ import { expect, test } from '@playwright/test' -test('legacy ops routes redirect', async ({ page }) => { - await page.goto('/admin/ops/topics') - expect(new URL(page.url()).pathname).toBe('/admin/ops/new') - await page.goto('/admin/ops/articles') - expect(new URL(page.url()).pathname).toBe('/admin/ops/content') +// Signed out, following a redirect ends on `/admin/login`, which says nothing +// about the redirect itself. Ask for the first response and read it: the +// status and `location` are what the config in `next.config.ts` promises. +// They are temporary (307) so a path can be reused later. +const legacyRoutes: Array<[from: string, to: string]> = [ + ['/admin/ops/topics', '/admin/ops/new'], + ['/admin/ops/articles', '/admin/ops/content'], // Brand voice moved in beside the other workspace assets it is edited with. - await page.goto('/admin/ops/governance/brand-voice') - expect(new URL(page.url()).pathname).toBe('/admin/ops/setup/brand-voice') - const r = await page.request.get('/my-route') + ['/admin/ops/governance/brand-voice', '/admin/ops/setup/brand-voice'], +] + +for (const [from, to] of legacyRoutes) { + test(`legacy ops route ${from} redirects to ${to}`, async ({ page }) => { + const response = await page.request.get(from, { maxRedirects: 0 }) + expect(response.status()).toBe(307) + const location = response.headers()['location'] + expect(location, 'location header').toBeTruthy() + expect(new URL(location, response.url()).pathname).toBe(to) + }) +} + +test('an unknown route is a 404, not a redirect', async ({ page }) => { + const r = await page.request.get('/my-route', { maxRedirects: 0 }) expect(r.status()).toBe(404) }) diff --git a/cms/tests/helpers/testDatabaseGuard.ts b/cms/tests/helpers/testDatabaseGuard.ts new file mode 100644 index 00000000..63668788 --- /dev/null +++ b/cms/tests/helpers/testDatabaseGuard.ts @@ -0,0 +1,39 @@ +/** + * The test suites rewrite workspace state (audiences, profile, brand voice, + * webhook settings, run rows) and append cost and audit rows that are never + * removed. Pointed at a developer's working database they destroy it, and + * `cms/.env` is loaded by default, so that is where they would point. This + * module is the one rule that stops it: the database name must say it is for + * tests, or the person running the suite must say so explicitly. + */ + +/** Set to `true` to run against a database whose name does not contain `test`. */ +export const TEST_DATABASE_OPT_IN = 'DATUM_TEST_DATABASE_OK' + +/** The database name in a Postgres connection string, or null if there is none. */ +export function databaseNameFromUrl(connectionString: string): string | null { + try { + const name = decodeURIComponent(new URL(connectionString).pathname.replace(/^\/+/, '')) + return name === '' ? null : name + } catch { + return null + } +} + +/** + * Throws unless the suite may use `env.DATABASE_URL`. A missing one is refused + * too: Payload would then connect with libpq's defaults (`PGDATABASE`, or a + * database named after the OS user), which can be a working database. + */ +export function assertTestDatabase(env: Record = process.env): void { + if (env[TEST_DATABASE_OPT_IN] === 'true') return + const url = env.DATABASE_URL + const name = url ? databaseNameFromUrl(url) : null + if (name !== null && name.toLowerCase().includes('test')) return + throw new Error( + `Refusing to run the tests against ${!url ? 'the default database (DATABASE_URL is not set)' : name === null ? 'a database whose name cannot be read from DATABASE_URL' : `the database "${name}"`}. ` + + 'The suites rewrite workspace state and add rows that are never removed. ' + + 'Either point DATABASE_URL at a database whose name contains "test" (for example datum_test), ' + + `or set ${TEST_DATABASE_OPT_IN}=true to accept that this database will be modified.`, + ) +} diff --git a/cms/tests/int/adminPerformance.int.spec.ts b/cms/tests/int/adminPerformance.int.spec.ts index 0c2184d8..7f84ddee 100644 --- a/cms/tests/int/adminPerformance.int.spec.ts +++ b/cms/tests/int/adminPerformance.int.spec.ts @@ -1,4 +1,5 @@ import { loadWorkspaceSetup } from '@/lib/loadWorkspaceReadiness' +import { loadSetupChecklistData } from '@/components/ops/setupChecklistData' import { loadSourceReviewArticles } from '@/components/ops/sourceReviewData' import { randomUUID } from 'node:crypto' import { @@ -106,6 +107,70 @@ describe('admin queries against Postgres', () => { } }) + it('counts site pages for the setup hub without loading their text', async () => { + const previous = await payload.findGlobal({ slug: 'workspace-profile', depth: 0 }) + await payload.updateGlobal({ + slug: 'workspace-profile', + overrideAccess: true, + data: { + sitePages: [ + { url: 'https://local.test/a', text: 'UNUSED_SITEPAGE_MARKER' }, + { url: 'https://local.test/b', text: 'UNUSED_SITEPAGE_MARKER' }, + { url: 'https://local.test/c', text: 'UNUSED_SITEPAGE_MARKER' }, + ], + }, + }) + const findGlobal = vi.spyOn(payload, 'findGlobal') + try { + const data = await loadSetupChecklistData(payload) + expect(data.workspace.sitePages).toBe(3) + const loaded = await Promise.all(findGlobal.mock.results.map((result) => result.value)) + expect(JSON.stringify(loaded)).not.toContain('UNUSED_SITEPAGE_MARKER') + } finally { + findGlobal.mockRestore() + await payload.updateGlobal({ + slug: 'workspace-profile', + data: { sitePages: previous.sitePages }, + }) + } + }) + + it('reads only the status of the newest run for the setup data', async () => { + const template = await payload.create({ + collection: 'templates', + overrideAccess: true, + data: { name: `${prefix} run template` }, + }) + const run = await payload.create({ + collection: 'pipeline-runs', + overrideAccess: true, + data: { + runId: `${prefix}-run`, + source: 'cli', + status: 'succeeded', + mode: 'mock', + template: template.id, + requestedCount: 1, + configFingerprint: 'UNUSED_RUN_MARKER', + configSnapshot: { marker: 'UNUSED_RUN_MARKER' }, + requestedBy: 'perf-test', + }, + }) + const find = vi.spyOn(payload, 'find') + try { + const setup = await loadWorkspaceSetup(payload) + const index = find.mock.calls.findIndex(([options]) => options.collection === 'pipeline-runs') + expect(index).toBeGreaterThanOrEqual(0) + const loaded = await find.mock.results[index].value + expect(loaded.docs.map((doc: object) => Object.keys(doc).sort())).toEqual([['id', 'status']]) + expect(setup.latestRun).toEqual({ status: 'succeeded' }) + } finally { + find.mockRestore() + await payload.delete({ collection: 'pipeline-runs', id: run.id, overrideAccess: true }) + await payload.delete({ collection: 'templates', id: template.id, overrideAccess: true }) + } + }) + it('never loads article research for the source-review lookup', async () => { const find = vi.spyOn(payload, 'find') try { diff --git a/cms/tests/int/dirtyGuard.int.spec.ts b/cms/tests/int/dirtyGuard.int.spec.ts index 9faeb526..8dedea5b 100644 --- a/cms/tests/int/dirtyGuard.int.spec.ts +++ b/cms/tests/int/dirtyGuard.int.spec.ts @@ -457,7 +457,8 @@ describe('useDirtyGuard', () => { const click = new MouseEvent('click', { bubbles: true, cancelable: true }) const prevented = !screen.getByRole('link', { name: 'Elsewhere' }).dispatchEvent(click) // jsdom's own "navigation not implemented" is the default action; nothing stopped it. - expect(click.defaultPrevented).toBe(prevented) + expect(prevented).toBe(false) + expect(click.defaultPrevented).toBe(false) expect(screen.queryByRole('alertdialog')).toBeNull() }) diff --git a/cms/tests/int/mediaUpload.int.spec.ts b/cms/tests/int/mediaUpload.int.spec.ts new file mode 100644 index 00000000..45ce6432 --- /dev/null +++ b/cms/tests/int/mediaUpload.int.spec.ts @@ -0,0 +1,52 @@ +import config from '@/payload.config' +import { getPayload, type Payload } from 'payload' +import { beforeAll, describe, expect, it } from 'vitest' + +import { Media } from '@/collections/Media' + +let payload: Payload + +const PNG = Buffer.from( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', + 'base64', +) +const SVG = Buffer.from( + '', +) +const HTML = Buffer.from('') + +const upload = (name: string, mimetype: string, data: Buffer) => + payload.create({ + collection: 'media', + data: { alt: 'upload test' }, + file: { data, mimetype, name, size: data.length }, + }) + +describe('media uploads', () => { + beforeAll(async () => { + payload = await getPayload({ config: await config }) + }) + + it('allows raster images only', () => { + expect(Media.upload).toMatchObject({ + mimeTypes: ['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/avif'], + }) + }) + + it('accepts a PNG upload', async () => { + const doc = await upload('media-upload-test.png', 'image/png', PNG) + try { + expect(doc.mimeType).toBe('image/png') + } finally { + await payload.delete({ collection: 'media', id: doc.id }) + } + }) + + it('refuses a script-free SVG upload (an SVG is served from the app origin)', async () => { + await expect(upload('media-upload-test.svg', 'image/svg+xml', SVG)).rejects.toThrow() + }) + + it('refuses an HTML upload', async () => { + await expect(upload('media-upload-test.html', 'text/html', HTML)).rejects.toThrow() + }) +}) diff --git a/cms/tests/int/pipelineRun.int.spec.ts b/cms/tests/int/pipelineRun.int.spec.ts index 05e02a9b..ecda5776 100644 --- a/cms/tests/int/pipelineRun.int.spec.ts +++ b/cms/tests/int/pipelineRun.int.spec.ts @@ -67,10 +67,10 @@ describe('pipeline run launch', () => { expect(results.filter((result) => result.status === 'fulfilled')).toHaveLength(1) expect(results.filter((result) => result.status === 'rejected')).toHaveLength(1) const rejection = results.find((result) => result.status === 'rejected') - expect( - rejection?.status === 'rejected' && - (rejection.reason instanceof ActivePipelineRunError || rejection.reason instanceof Error), - ).toBe(true) + // The loser must lose to the one-at-a-time rule, not to some other error. + expect(rejection?.status === 'rejected' && rejection.reason).toBeInstanceOf( + ActivePipelineRunError, + ) const active = await payload.find({ collection: 'pipeline-runs', @@ -201,6 +201,33 @@ describe('pipeline run launch', () => { requestedBy: 'admin@datum.local', readiness, } - await expect(createPipelineRun(payload, user, { ...baseInput, source: 'onboarding' as never })).rejects.toThrow() + // Earlier tests leave a run queued, and an `admin` run behind one refuses + // with `ActivePipelineRunError` before the source is ever looked at. Close + // them out so the only thing that can refuse this call is the source. + await payload.update({ + collection: 'pipeline-runs', + where: { status: { in: ['queued', 'running'] } }, + data: { status: 'succeeded' }, + overrideAccess: true, + }) + const rejection = await createPipelineRun(payload, user, { + ...baseInput, + source: 'onboarding' as never, + }).then( + () => null, + (error: unknown) => error, + ) + expect(rejection).toBeInstanceOf(Error) + expect(rejection).not.toBeInstanceOf(ActivePipelineRunError) + expect((rejection as Error).message).toMatch(/source/i) + + // Nothing was created for it. + const created = await payload.find({ + collection: 'pipeline-runs', + where: { runId: { equals: runId } }, + overrideAccess: true, + depth: 0, + }) + expect(created.docs).toHaveLength(0) }) }) diff --git a/cms/tests/int/runPolling.int.spec.ts b/cms/tests/int/runPolling.int.spec.ts index 13e5de48..4e783079 100644 --- a/cms/tests/int/runPolling.int.spec.ts +++ b/cms/tests/int/runPolling.int.spec.ts @@ -140,7 +140,17 @@ describe('run polling wake', () => { changeVisibility(false) await vi.advanceTimersByTimeAsync(0) expect(poll).toHaveBeenCalledTimes(2) + // A `stopped` flag alone would also make the later wake a no-op, so check + // that the listeners themselves are taken off, with the same functions + // that were put on. + const added = vi.spyOn(wakeTarget, 'addEventListener') + const removed = vi.spyOn(wakeTarget, 'removeEventListener') + expect(listeners.size).toBe(1) stop() + expect(listeners.size).toBe(0) + expect(removed).toHaveBeenCalledTimes(1) + expect(removed).toHaveBeenCalledWith('datum:run-queued', expect.any(Function)) + expect(added).not.toHaveBeenCalled() announce() await vi.advanceTimersByTimeAsync(30000) expect(poll).toHaveBeenCalledTimes(2) diff --git a/cms/tests/int/setupSuggestions.int.spec.ts b/cms/tests/int/setupSuggestions.int.spec.ts index ad4a1479..24bccc4a 100644 --- a/cms/tests/int/setupSuggestions.int.spec.ts +++ b/cms/tests/int/setupSuggestions.int.spec.ts @@ -394,3 +394,29 @@ it('QA signals accumulate across scans and repeated passes do not increase the a ), ).toBe(true) }) +it('reads only the published-article fields the comparison uses', async () => { + const article = await signalArticle() + await payload.update({ + collection: 'articles', + id: article.id, + overrideAccess: true, + data: { + reviewNotes: 'UNUSED_ARTICLE_MARKER', + research: { rankingPagesSummary: 'UNUSED_ARTICLE_MARKER' }, + }, + }) + const spy = vi.spyOn(payload, 'find') + try { + await collectSetupSuggestions(payload) + const call = spy.mock.calls.findIndex( + ([options]) => + options.collection === 'articles' && JSON.stringify(options.where).includes('published'), + ) + expect(call).toBeGreaterThanOrEqual(0) + const loaded = await spy.mock.results[call].value + expect(loaded.docs.length).toBeGreaterThan(0) + expect(JSON.stringify(loaded)).not.toContain('UNUSED_ARTICLE_MARKER') + } finally { + spy.mockRestore() + } +}) diff --git a/cms/tests/int/testDatabaseGuard.int.spec.ts b/cms/tests/int/testDatabaseGuard.int.spec.ts new file mode 100644 index 00000000..73b4428f --- /dev/null +++ b/cms/tests/int/testDatabaseGuard.int.spec.ts @@ -0,0 +1,66 @@ +import { describe, expect, it } from 'vitest' + +import { + assertTestDatabase, + databaseNameFromUrl, + TEST_DATABASE_OPT_IN, +} from '../helpers/testDatabaseGuard' + +const url = (name: string) => `postgresql://datum:datum@127.0.0.1:5432/${name}` + +describe('databaseNameFromUrl', () => { + it('reads the name, ignoring credentials and query', () => { + expect(databaseNameFromUrl(url('datum_test'))).toBe('datum_test') + expect(databaseNameFromUrl('postgres://u@h:5433/db?sslmode=require')).toBe('db') + }) + + it('returns null when there is no name or the URL is unreadable', () => { + expect(databaseNameFromUrl('postgresql://u@h:5432')).toBeNull() + expect(databaseNameFromUrl('postgresql://u@h:5432/')).toBeNull() + expect(databaseNameFromUrl('not a url')).toBeNull() + }) +}) + +describe('assertTestDatabase', () => { + it('allows a database whose name contains "test", in any case', () => { + expect(() => assertTestDatabase({ DATABASE_URL: url('datum_test') })).not.toThrow() + expect(() => assertTestDatabase({ DATABASE_URL: url('datum_test_ws_g') })).not.toThrow() + expect(() => assertTestDatabase({ DATABASE_URL: url('Datum_TEST') })).not.toThrow() + }) + + it('refuses a working database and names both ways out', () => { + expect(() => assertTestDatabase({ DATABASE_URL: url('datum') })).toThrow(/"datum"/) + expect(() => assertTestDatabase({ DATABASE_URL: url('datum') })).toThrow(/contains "test"/) + expect(() => assertTestDatabase({ DATABASE_URL: url('datum') })).toThrow( + new RegExp(`${TEST_DATABASE_OPT_IN}=true`), + ) + }) + + it('refuses a URL whose database name cannot be read', () => { + expect(() => assertTestDatabase({ DATABASE_URL: 'postgresql://u@h:5432' })).toThrow(/cannot be read/) + expect(() => assertTestDatabase({ DATABASE_URL: 'garbage' })).toThrow(/cannot be read/) + }) + + it('does not match "test" in the host or user, only the database name', () => { + expect(() => + assertTestDatabase({ DATABASE_URL: 'postgresql://testuser@testhost:5432/datum' }), + ).toThrow() + }) + + it('accepts any database with the explicit opt-in, and only the exact value "true"', () => { + expect(() => + assertTestDatabase({ DATABASE_URL: url('datum'), [TEST_DATABASE_OPT_IN]: 'true' }), + ).not.toThrow() + expect(() => + assertTestDatabase({ DATABASE_URL: url('datum'), [TEST_DATABASE_OPT_IN]: '1' }), + ).toThrow() + }) + + // Without one, Payload connects with libpq's defaults (PGDATABASE, or the OS + // user's name), which can be a working database. + it('refuses a missing DATABASE_URL unless opted in', () => { + expect(() => assertTestDatabase({})).toThrow(/DATABASE_URL is not set/) + expect(() => assertTestDatabase({ DATABASE_URL: '' })).toThrow(/DATABASE_URL is not set/) + expect(() => assertTestDatabase({ [TEST_DATABASE_OPT_IN]: 'true' })).not.toThrow() + }) +}) diff --git a/cms/vitest.setup.ts b/cms/vitest.setup.ts index 1de78b3c..59931627 100644 --- a/cms/vitest.setup.ts +++ b/cms/vitest.setup.ts @@ -3,6 +3,12 @@ // Load .env files import 'dotenv/config' +import { assertTestDatabase } from './tests/helpers/testDatabaseGuard' + +// Runs after `dotenv/config`, so it judges the `DATABASE_URL` the suite will +// really use, including one that only `cms/.env` supplies. +assertTestDatabase() + // The suite never calls a paid API. CI sets this in the workflow; locally the // mode would otherwise be whatever `cms/.env` or the shell says, and a few // specs reach real fetch and model paths when it is `false`. A spec that tests diff --git a/docs/audits/2026-09-11-ui-workflow-audit.md b/docs/audits/2026-09-11-ui-workflow-audit.md index cc679337..76f3f174 100644 --- a/docs/audits/2026-09-11-ui-workflow-audit.md +++ b/docs/audits/2026-09-11-ui-workflow-audit.md @@ -1,5 +1,7 @@ # UI and workflow audit — 2026-09-11 +> The screenshots (`docs/audits/screens/`) and the capture log and script this audit cites were removed from the tree. They are in git history at commit `7bb204f`. + Scope: the Payload admin under `/admin`, the operator journey from first login to a published article, the public reader, and the docs and env files that support them. Method: every screen was driven live on `localhost:3000` (per-worktree database `datum_local_env_keys`, seeded, demo workspace applied, one Listicle and one How-To piece run through the mock pipeline, the remaining statuses cloned by SQL), captured at 1600px and 390px, then cross-checked against the code path behind it. Screenshots live in `docs/audits/screens/` and are named `---.png`. Baseline: `5205dd6` (release 0.6.4). diff --git a/docs/audits/capture-log.json b/docs/audits/capture-log.json deleted file mode 100644 index 9239ca64..00000000 --- a/docs/audits/capture-log.json +++ /dev/null @@ -1,630 +0,0 @@ -[ - { - "name": "01-admin-landing", - "route": "/admin", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/content", - "title": "Content - Payload", - "h1": "Content", - "ms": 1407, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup", - "route": "/admin/ops/setup", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/setup", - "title": "Workspace setup - Payload", - "h1": "Your workspace", - "ms": 1348, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-workspace", - "route": "/admin/ops/setup/workspace", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/setup/workspace", - "title": "Workspace - Payload", - "h1": "Workspace", - "ms": 1259, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-audiences", - "route": "/admin/ops/setup/audiences", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/setup/audiences", - "title": "Audiences - Payload", - "h1": "Audiences", - "ms": 1324, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-audience-new", - "route": "/admin/ops/setup/audiences/new", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/setup/audiences/new", - "title": "Audience - Payload", - "h1": "New audience", - "ms": 1265, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-positioning", - "route": "/admin/ops/setup/positioning", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/setup/positioning", - "title": "Positioning - Payload", - "h1": "Positioning", - "ms": 1288, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-evidence", - "route": "/admin/ops/setup/evidence", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/setup/evidence", - "title": "Evidence bank - Payload", - "h1": "Evidence bank", - "ms": 1321, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "03-brand-voice", - "route": "/admin/ops/governance/brand-voice", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/governance/brand-voice", - "title": "Brand voice - Payload", - "h1": "Brand voice", - "ms": 1292, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "04-global-models", - "route": "/admin/globals/llm-settings", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/globals/llm-settings", - "title": "Editing - Models - Payload", - "h1": "Models", - "ms": 1405, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "04-global-scoring-policy", - "route": "/admin/globals/information-gain-policy", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/globals/information-gain-policy", - "title": "Editing - Information-gain policy - Payload", - "h1": "Information-gain policy", - "ms": 1391, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "04-global-webhooks", - "route": "/admin/globals/webhook-settings", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/globals/webhook-settings", - "title": "Editing - Webhooks - Payload", - "h1": "Webhooks", - "ms": 1278, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "05-global-workspace-profile", - "route": "/admin/globals/workspace-profile", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/globals/workspace-profile", - "title": "Editing - Workspace - Payload", - "h1": "Workspace", - "ms": 1635, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "05-global-positioning", - "route": "/admin/globals/positioning", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/globals/positioning", - "title": "Editing - Positioning - Payload", - "h1": "Positioning", - "ms": 1675, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "05-global-evidence-bank", - "route": "/admin/globals/evidence-bank", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/globals/evidence-bank", - "title": "Editing - Evidence bank - Payload", - "h1": "Evidence bank", - "ms": 1667, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "06-new-content", - "route": "/admin/ops/new", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/new", - "title": "New content - Payload", - "h1": "New content", - "ms": 1373, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "07-content-list", - "route": "/admin/ops/content", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/content", - "title": "Content - Payload", - "h1": "Content", - "ms": 1318, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "10-source-review", - "route": "/admin/ops/governance/source-review", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/governance/source-review", - "title": "Source review - Payload", - "h1": "Source review", - "ms": 1312, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "10-sources", - "route": "/admin/collections/evidence-sources", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/collections/evidence-sources?depth=1&limit=10", - "title": "Evidence Sources - Payload", - "h1": "Evidence Sources", - "ms": 1309, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "11-templates", - "route": "/admin/ops/templates", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/templates", - "title": "Templates - Payload", - "h1": "Templates", - "ms": 1286, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "12-reports-week", - "route": "/admin/ops/reports?period=week", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/reports?period=week", - "title": "Reports - Payload", - "h1": "Reports", - "ms": 1346, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "12-reports-all", - "route": "/admin/ops/reports?period=all", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/reports?period=all", - "title": "Reports - Payload", - "h1": "Reports", - "ms": 1343, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "13-collections-articles", - "route": "/admin/collections/articles", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/collections/articles?depth=1&limit=10", - "title": "Articles - Payload", - "h1": "Articles", - "ms": 1498, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "13-collections-pipeline-runs", - "route": "/admin/collections/pipeline-runs", - "vp": "desktop", - "status": 404, - "finalUrl": "/admin/collections/pipeline-runs", - "title": "Pipeline runs - Payload", - "h1": "Nothing found", - "ms": 1300, - "hOverflow": false, - "consoleErrors": [ - "Failed to load resource: the server responded with a status of 404 (Not Found)" - ] - }, - { - "name": "14-redirect-topics", - "route": "/admin/ops/topics", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/new", - "title": "New content - Payload", - "h1": "New content", - "ms": 1403, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "14-redirect-articles", - "route": "/admin/ops/articles", - "vp": "desktop", - "status": 200, - "finalUrl": "/admin/ops/content", - "title": "Content - Payload", - "h1": "Content", - "ms": 1463, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "15-public-home", - "route": "/", - "vp": "desktop", - "status": 200, - "finalUrl": "/", - "title": "Datum", - "h1": "Published articles", - "ms": 1248, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "01-admin-landing", - "route": "/admin", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/content", - "title": "Content - Payload", - "h1": "Content", - "ms": 1397, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup", - "route": "/admin/ops/setup", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/setup", - "title": "Workspace setup - Payload", - "h1": "Your workspace", - "ms": 1346, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-workspace", - "route": "/admin/ops/setup/workspace", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/setup/workspace", - "title": "Workspace - Payload", - "h1": "Workspace", - "ms": 1263, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-audiences", - "route": "/admin/ops/setup/audiences", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/setup/audiences", - "title": "Audiences - Payload", - "h1": "Audiences", - "ms": 1272, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-audience-new", - "route": "/admin/ops/setup/audiences/new", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/setup/audiences/new", - "title": "Audience - Payload", - "h1": "New audience", - "ms": 1243, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-positioning", - "route": "/admin/ops/setup/positioning", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/setup/positioning", - "title": "Positioning - Payload", - "h1": "Positioning", - "ms": 1245, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "02-setup-evidence", - "route": "/admin/ops/setup/evidence", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/setup/evidence", - "title": "Evidence bank - Payload", - "h1": "Evidence bank", - "ms": 1309, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "03-brand-voice", - "route": "/admin/ops/governance/brand-voice", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/governance/brand-voice", - "title": "Brand voice - Payload", - "h1": "Brand voice", - "ms": 1277, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "04-global-models", - "route": "/admin/globals/llm-settings", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/globals/llm-settings", - "title": "Editing - Models - Payload", - "h1": "Models", - "ms": 1389, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "04-global-scoring-policy", - "route": "/admin/globals/information-gain-policy", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/globals/information-gain-policy", - "title": "Editing - Information-gain policy - Payload", - "h1": "Information-gain policy", - "ms": 1391, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "04-global-webhooks", - "route": "/admin/globals/webhook-settings", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/globals/webhook-settings", - "title": "Editing - Webhooks - Payload", - "h1": "Webhooks", - "ms": 1287, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "05-global-workspace-profile", - "route": "/admin/globals/workspace-profile", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/globals/workspace-profile", - "title": "Editing - Workspace - Payload", - "h1": "Workspace", - "ms": 1607, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "05-global-positioning", - "route": "/admin/globals/positioning", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/globals/positioning", - "title": "Editing - Positioning - Payload", - "h1": "Positioning", - "ms": 1602, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "05-global-evidence-bank", - "route": "/admin/globals/evidence-bank", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/globals/evidence-bank", - "title": "Editing - Evidence bank - Payload", - "h1": "Evidence bank", - "ms": 1634, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "06-new-content", - "route": "/admin/ops/new", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/new", - "title": "New content - Payload", - "h1": "New content", - "ms": 1335, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "07-content-list", - "route": "/admin/ops/content", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/content", - "title": "Content - Payload", - "h1": "Content", - "ms": 1300, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "10-source-review", - "route": "/admin/ops/governance/source-review", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/governance/source-review", - "title": "Source review - Payload", - "h1": "Source review", - "ms": 1270, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "10-sources", - "route": "/admin/collections/evidence-sources", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/collections/evidence-sources?depth=1&limit=10", - "title": "Evidence Sources - Payload", - "h1": "Evidence Sources", - "ms": 1292, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "11-templates", - "route": "/admin/ops/templates", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/templates", - "title": "Templates - Payload", - "h1": "Templates", - "ms": 1262, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "12-reports-week", - "route": "/admin/ops/reports?period=week", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/reports?period=week", - "title": "Reports - Payload", - "h1": "Reports", - "ms": 1309, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "12-reports-all", - "route": "/admin/ops/reports?period=all", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/reports?period=all", - "title": "Reports - Payload", - "h1": "Reports", - "ms": 1330, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "13-collections-articles", - "route": "/admin/collections/articles", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/collections/articles?depth=1&limit=10", - "title": "Articles - Payload", - "h1": "Articles", - "ms": 1509, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "13-collections-pipeline-runs", - "route": "/admin/collections/pipeline-runs", - "vp": "mobile", - "status": 404, - "finalUrl": "/admin/collections/pipeline-runs", - "title": "Pipeline runs - Payload", - "h1": "Nothing found", - "ms": 1297, - "hOverflow": false, - "consoleErrors": [ - "Failed to load resource: the server responded with a status of 404 (Not Found)" - ] - }, - { - "name": "14-redirect-topics", - "route": "/admin/ops/topics", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/new", - "title": "New content - Payload", - "h1": "New content", - "ms": 1414, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "14-redirect-articles", - "route": "/admin/ops/articles", - "vp": "mobile", - "status": 200, - "finalUrl": "/admin/ops/content", - "title": "Content - Payload", - "h1": "Content", - "ms": 1359, - "hOverflow": false, - "consoleErrors": [] - }, - { - "name": "15-public-home", - "route": "/", - "vp": "mobile", - "status": 200, - "finalUrl": "/", - "title": "Datum", - "h1": "Published articles", - "ms": 1215, - "hOverflow": false, - "consoleErrors": [] - } -] \ No newline at end of file diff --git a/docs/audits/capture.mjs b/docs/audits/capture.mjs deleted file mode 100644 index f658a99d..00000000 --- a/docs/audits/capture.mjs +++ /dev/null @@ -1,88 +0,0 @@ -// Capture every audited route at desktop and mobile widths. -// Usage (repo root, dev server on :3000, PAYLOAD_AUTO_LOGIN=true): DESKTOP_W=1600 node docs/audits/capture.mjs [outDir] [routesFilter] -import { chromium } from 'playwright' -import fs from 'node:fs' -import path from 'node:path' - -const base = 'http://localhost:3000' -const outDir = process.argv[2] || 'docs/audits/screens' -const filter = process.argv[3] || '' -fs.mkdirSync(outDir, { recursive: true }) - -const routes = [ - ['01-admin-landing', '/admin'], - ['02-setup', '/admin/ops/setup'], - ['02-setup-workspace', '/admin/ops/setup/workspace'], - ['02-setup-audiences', '/admin/ops/setup/audiences'], - ['02-setup-audience-new', '/admin/ops/setup/audiences/new'], - ['02-setup-positioning', '/admin/ops/setup/positioning'], - ['02-setup-evidence', '/admin/ops/setup/evidence'], - ['03-brand-voice', '/admin/ops/setup/brand-voice'], - ['04-global-models', '/admin/globals/llm-settings'], - ['04-global-scoring-policy', '/admin/globals/information-gain-policy'], - ['04-global-webhooks', '/admin/globals/webhook-settings'], - // The workspace-profile, positioning and evidence-bank globals are hidden - // from the admin: each is edited at its `/admin/ops/setup/...` surface above. - ['06-new-content', '/admin/ops/new'], - ['07-content-list', '/admin/ops/content'], - ['10-source-review', '/admin/ops/governance/source-review'], - ['10-sources', '/admin/collections/evidence-sources'], - ['11-templates', '/admin/ops/templates'], - ['12-reports-week', '/admin/ops/reports?period=week'], - ['12-reports-all', '/admin/ops/reports?period=all'], - ['13-collections-articles', '/admin/collections/articles'], - ['13-collections-pipeline-runs', '/admin/collections/pipeline-runs'], - ['14-redirect-topics', '/admin/ops/topics'], - ['14-redirect-articles', '/admin/ops/articles'], - ['15-public-home', '/'], -] - -const extra = JSON.parse(process.env.EXTRA_ROUTES || '[]') -const all = [...routes, ...extra].filter(([n]) => !filter || n.includes(filter)) - -const viewports = [ - ['desktop', { width: Number(process.env.DESKTOP_W || 1440), height: 900 }], - ['mobile', { width: 390, height: 844 }], -] - -const browser = await chromium.launch() -const results = [] -for (const [vpName, viewport] of viewports) { - const context = await browser.newContext({ viewport, deviceScaleFactor: 1 }) - const page = await context.newPage() - const consoleErrors = [] - page.on('console', (m) => { if (m.type() === 'error') consoleErrors.push(m.text()) }) - // Warm auto-login cookie. - await page.goto(base + '/admin', { waitUntil: 'networkidle' }) - for (const [name, route] of all) { - const errsBefore = consoleErrors.length - const t0 = Date.now() - let status = 0 - try { - const resp = await page.goto(base + route, { waitUntil: 'networkidle', timeout: 60000 }) - status = resp?.status() ?? 0 - await page.waitForTimeout(500) - } catch (e) { - results.push({ name, route, vp: vpName, error: String(e).slice(0, 120) }) - continue - } - const finalUrl = page.url().replace(base, '') - const file = path.join(outDir, `${name}--${vpName}.png`) - await page.screenshot({ path: file, fullPage: true }) - const title = await page.title() - const h1 = await page.locator('h1').first().textContent().catch(() => null) - const bodyScrollW = await page.evaluate(() => document.documentElement.scrollWidth) - results.push({ - name, route, vp: vpName, status, finalUrl, title, h1: h1?.trim() ?? null, - ms: Date.now() - t0, - hOverflow: bodyScrollW > viewport.width, - consoleErrors: consoleErrors.slice(errsBefore).slice(0, 3), - }) - } - await context.close() -} -await browser.close() -fs.writeFileSync(path.join(outDir, '..', 'capture-log.json'), JSON.stringify(results, null, 2)) -for (const r of results) { - console.log([r.vp, r.name, r.status, r.finalUrl ?? r.error, r.h1 ?? '', r.ms ? r.ms + 'ms' : '', r.hOverflow ? 'H-OVERFLOW' : '', r.consoleErrors?.length ? `errs=${r.consoleErrors.length}` : ''].join(' | ')) -} diff --git a/docs/audits/screens/01-admin-landing--desktop.png b/docs/audits/screens/01-admin-landing--desktop.png deleted file mode 100644 index 419fa111..00000000 Binary files a/docs/audits/screens/01-admin-landing--desktop.png and /dev/null differ diff --git a/docs/audits/screens/01-admin-landing--mobile.png b/docs/audits/screens/01-admin-landing--mobile.png deleted file mode 100644 index 2226a505..00000000 Binary files a/docs/audits/screens/01-admin-landing--mobile.png and /dev/null differ diff --git a/docs/audits/screens/01-admin-landing-ready--desktop.png b/docs/audits/screens/01-admin-landing-ready--desktop.png deleted file mode 100644 index 226550fa..00000000 Binary files a/docs/audits/screens/01-admin-landing-ready--desktop.png and /dev/null differ diff --git a/docs/audits/screens/01-admin-landing-ready--mobile.png b/docs/audits/screens/01-admin-landing-ready--mobile.png deleted file mode 100644 index 0c7c7bfb..00000000 Binary files a/docs/audits/screens/01-admin-landing-ready--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup--desktop.png b/docs/audits/screens/02-setup--desktop.png deleted file mode 100644 index c18ff723..00000000 Binary files a/docs/audits/screens/02-setup--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup--mobile.png b/docs/audits/screens/02-setup--mobile.png deleted file mode 100644 index 8a217cf5..00000000 Binary files a/docs/audits/screens/02-setup--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-audience-existing--desktop.png b/docs/audits/screens/02-setup-audience-existing--desktop.png deleted file mode 100644 index 0393337c..00000000 Binary files a/docs/audits/screens/02-setup-audience-existing--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-audience-existing--mobile.png b/docs/audits/screens/02-setup-audience-existing--mobile.png deleted file mode 100644 index f63f9f6b..00000000 Binary files a/docs/audits/screens/02-setup-audience-existing--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-audience-new--desktop.png b/docs/audits/screens/02-setup-audience-new--desktop.png deleted file mode 100644 index ea8c4a66..00000000 Binary files a/docs/audits/screens/02-setup-audience-new--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-audience-new--mobile.png b/docs/audits/screens/02-setup-audience-new--mobile.png deleted file mode 100644 index 01b882cc..00000000 Binary files a/docs/audits/screens/02-setup-audience-new--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-audiences--desktop.png b/docs/audits/screens/02-setup-audiences--desktop.png deleted file mode 100644 index 4aa9c626..00000000 Binary files a/docs/audits/screens/02-setup-audiences--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-audiences--mobile.png b/docs/audits/screens/02-setup-audiences--mobile.png deleted file mode 100644 index 4a694e6d..00000000 Binary files a/docs/audits/screens/02-setup-audiences--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-evidence--desktop.png b/docs/audits/screens/02-setup-evidence--desktop.png deleted file mode 100644 index a7ab2baa..00000000 Binary files a/docs/audits/screens/02-setup-evidence--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-evidence--mobile.png b/docs/audits/screens/02-setup-evidence--mobile.png deleted file mode 100644 index 2c376313..00000000 Binary files a/docs/audits/screens/02-setup-evidence--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-evidence-filled--desktop.png b/docs/audits/screens/02-setup-evidence-filled--desktop.png deleted file mode 100644 index a7ab2baa..00000000 Binary files a/docs/audits/screens/02-setup-evidence-filled--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-evidence-filled--mobile.png b/docs/audits/screens/02-setup-evidence-filled--mobile.png deleted file mode 100644 index 2c376313..00000000 Binary files a/docs/audits/screens/02-setup-evidence-filled--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-positioning--desktop.png b/docs/audits/screens/02-setup-positioning--desktop.png deleted file mode 100644 index c7df0491..00000000 Binary files a/docs/audits/screens/02-setup-positioning--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-positioning--mobile.png b/docs/audits/screens/02-setup-positioning--mobile.png deleted file mode 100644 index 9e23f54c..00000000 Binary files a/docs/audits/screens/02-setup-positioning--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-positioning-filled--desktop.png b/docs/audits/screens/02-setup-positioning-filled--desktop.png deleted file mode 100644 index c7df0491..00000000 Binary files a/docs/audits/screens/02-setup-positioning-filled--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-positioning-filled--mobile.png b/docs/audits/screens/02-setup-positioning-filled--mobile.png deleted file mode 100644 index 9e23f54c..00000000 Binary files a/docs/audits/screens/02-setup-positioning-filled--mobile.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-workspace--desktop.png b/docs/audits/screens/02-setup-workspace--desktop.png deleted file mode 100644 index 263df05b..00000000 Binary files a/docs/audits/screens/02-setup-workspace--desktop.png and /dev/null differ diff --git a/docs/audits/screens/02-setup-workspace--mobile.png b/docs/audits/screens/02-setup-workspace--mobile.png deleted file mode 100644 index 0ab62350..00000000 Binary files a/docs/audits/screens/02-setup-workspace--mobile.png and /dev/null differ diff --git a/docs/audits/screens/03-brand-voice--desktop.png b/docs/audits/screens/03-brand-voice--desktop.png deleted file mode 100644 index 116193a2..00000000 Binary files a/docs/audits/screens/03-brand-voice--desktop.png and /dev/null differ diff --git a/docs/audits/screens/03-brand-voice--mobile.png b/docs/audits/screens/03-brand-voice--mobile.png deleted file mode 100644 index 7a7057ce..00000000 Binary files a/docs/audits/screens/03-brand-voice--mobile.png and /dev/null differ diff --git a/docs/audits/screens/03-brand-voice-active--desktop.png b/docs/audits/screens/03-brand-voice-active--desktop.png deleted file mode 100644 index 116193a2..00000000 Binary files a/docs/audits/screens/03-brand-voice-active--desktop.png and /dev/null differ diff --git a/docs/audits/screens/03-brand-voice-active--mobile.png b/docs/audits/screens/03-brand-voice-active--mobile.png deleted file mode 100644 index 7a7057ce..00000000 Binary files a/docs/audits/screens/03-brand-voice-active--mobile.png and /dev/null differ diff --git a/docs/audits/screens/04-global-models--desktop.png b/docs/audits/screens/04-global-models--desktop.png deleted file mode 100644 index b64c8585..00000000 Binary files a/docs/audits/screens/04-global-models--desktop.png and /dev/null differ diff --git a/docs/audits/screens/04-global-models--mobile.png b/docs/audits/screens/04-global-models--mobile.png deleted file mode 100644 index 7ac602e2..00000000 Binary files a/docs/audits/screens/04-global-models--mobile.png and /dev/null differ diff --git a/docs/audits/screens/04-global-scoring-policy--desktop.png b/docs/audits/screens/04-global-scoring-policy--desktop.png deleted file mode 100644 index a1cebb73..00000000 Binary files a/docs/audits/screens/04-global-scoring-policy--desktop.png and /dev/null differ diff --git a/docs/audits/screens/04-global-scoring-policy--mobile.png b/docs/audits/screens/04-global-scoring-policy--mobile.png deleted file mode 100644 index a08a486b..00000000 Binary files a/docs/audits/screens/04-global-scoring-policy--mobile.png and /dev/null differ diff --git a/docs/audits/screens/04-global-webhooks--desktop.png b/docs/audits/screens/04-global-webhooks--desktop.png deleted file mode 100644 index f86f3496..00000000 Binary files a/docs/audits/screens/04-global-webhooks--desktop.png and /dev/null differ diff --git a/docs/audits/screens/04-global-webhooks--mobile.png b/docs/audits/screens/04-global-webhooks--mobile.png deleted file mode 100644 index d18e9f46..00000000 Binary files a/docs/audits/screens/04-global-webhooks--mobile.png and /dev/null differ diff --git a/docs/audits/screens/05-global-evidence-bank--desktop.png b/docs/audits/screens/05-global-evidence-bank--desktop.png deleted file mode 100644 index 1f66e23d..00000000 Binary files a/docs/audits/screens/05-global-evidence-bank--desktop.png and /dev/null differ diff --git a/docs/audits/screens/05-global-evidence-bank--mobile.png b/docs/audits/screens/05-global-evidence-bank--mobile.png deleted file mode 100644 index a519ee29..00000000 Binary files a/docs/audits/screens/05-global-evidence-bank--mobile.png and /dev/null differ diff --git a/docs/audits/screens/05-global-positioning--desktop.png b/docs/audits/screens/05-global-positioning--desktop.png deleted file mode 100644 index 51e76e43..00000000 Binary files a/docs/audits/screens/05-global-positioning--desktop.png and /dev/null differ diff --git a/docs/audits/screens/05-global-positioning--mobile.png b/docs/audits/screens/05-global-positioning--mobile.png deleted file mode 100644 index 38f37751..00000000 Binary files a/docs/audits/screens/05-global-positioning--mobile.png and /dev/null differ diff --git a/docs/audits/screens/05-global-workspace-profile--desktop.png b/docs/audits/screens/05-global-workspace-profile--desktop.png deleted file mode 100644 index 957474e9..00000000 Binary files a/docs/audits/screens/05-global-workspace-profile--desktop.png and /dev/null differ diff --git a/docs/audits/screens/05-global-workspace-profile--mobile.png b/docs/audits/screens/05-global-workspace-profile--mobile.png deleted file mode 100644 index 0c9f8962..00000000 Binary files a/docs/audits/screens/05-global-workspace-profile--mobile.png and /dev/null differ diff --git a/docs/audits/screens/06-new-content--desktop.png b/docs/audits/screens/06-new-content--desktop.png deleted file mode 100644 index 8872f206..00000000 Binary files a/docs/audits/screens/06-new-content--desktop.png and /dev/null differ diff --git a/docs/audits/screens/06-new-content--mobile.png b/docs/audits/screens/06-new-content--mobile.png deleted file mode 100644 index 5486f403..00000000 Binary files a/docs/audits/screens/06-new-content--mobile.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list--desktop.png b/docs/audits/screens/07-content-list--desktop.png deleted file mode 100644 index 9580ad00..00000000 Binary files a/docs/audits/screens/07-content-list--desktop.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list--mobile.png b/docs/audits/screens/07-content-list--mobile.png deleted file mode 100644 index 2226a505..00000000 Binary files a/docs/audits/screens/07-content-list--mobile.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list-brief--desktop.png b/docs/audits/screens/07-content-list-brief--desktop.png deleted file mode 100644 index 90cd0d07..00000000 Binary files a/docs/audits/screens/07-content-list-brief--desktop.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list-brief--mobile.png b/docs/audits/screens/07-content-list-brief--mobile.png deleted file mode 100644 index 90bc0f93..00000000 Binary files a/docs/audits/screens/07-content-list-brief--mobile.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list-inprogress--desktop.png b/docs/audits/screens/07-content-list-inprogress--desktop.png deleted file mode 100644 index 63d2b3b1..00000000 Binary files a/docs/audits/screens/07-content-list-inprogress--desktop.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list-inprogress--mobile.png b/docs/audits/screens/07-content-list-inprogress--mobile.png deleted file mode 100644 index fee822cd..00000000 Binary files a/docs/audits/screens/07-content-list-inprogress--mobile.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list-mixed--desktop.png b/docs/audits/screens/07-content-list-mixed--desktop.png deleted file mode 100644 index 9580ad00..00000000 Binary files a/docs/audits/screens/07-content-list-mixed--desktop.png and /dev/null differ diff --git a/docs/audits/screens/07-content-list-mixed--mobile.png b/docs/audits/screens/07-content-list-mixed--mobile.png deleted file mode 100644 index 2226a505..00000000 Binary files a/docs/audits/screens/07-content-list-mixed--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-approved--desktop.png b/docs/audits/screens/08-review-approved--desktop.png deleted file mode 100644 index a66631f8..00000000 Binary files a/docs/audits/screens/08-review-approved--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-approved--mobile.png b/docs/audits/screens/08-review-approved--mobile.png deleted file mode 100644 index 483d539b..00000000 Binary files a/docs/audits/screens/08-review-approved--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-blocked--desktop.png b/docs/audits/screens/08-review-blocked--desktop.png deleted file mode 100644 index 07a6bb75..00000000 Binary files a/docs/audits/screens/08-review-blocked--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-blocked--mobile.png b/docs/audits/screens/08-review-blocked--mobile.png deleted file mode 100644 index cad520a8..00000000 Binary files a/docs/audits/screens/08-review-blocked--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-brief_review--desktop.png b/docs/audits/screens/08-review-brief_review--desktop.png deleted file mode 100644 index a62dd2b0..00000000 Binary files a/docs/audits/screens/08-review-brief_review--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-brief_review--mobile.png b/docs/audits/screens/08-review-brief_review--mobile.png deleted file mode 100644 index e8892fac..00000000 Binary files a/docs/audits/screens/08-review-brief_review--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-drafted--desktop.png b/docs/audits/screens/08-review-drafted--desktop.png deleted file mode 100644 index a2c11413..00000000 Binary files a/docs/audits/screens/08-review-drafted--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-drafted--mobile.png b/docs/audits/screens/08-review-drafted--mobile.png deleted file mode 100644 index f6351593..00000000 Binary files a/docs/audits/screens/08-review-drafted--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-needs_review--desktop.png b/docs/audits/screens/08-review-needs_review--desktop.png deleted file mode 100644 index 667882c6..00000000 Binary files a/docs/audits/screens/08-review-needs_review--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-needs_review--mobile.png b/docs/audits/screens/08-review-needs_review--mobile.png deleted file mode 100644 index 4142b995..00000000 Binary files a/docs/audits/screens/08-review-needs_review--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-needs_revision--desktop.png b/docs/audits/screens/08-review-needs_revision--desktop.png deleted file mode 100644 index 4173783e..00000000 Binary files a/docs/audits/screens/08-review-needs_revision--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-needs_revision--mobile.png b/docs/audits/screens/08-review-needs_revision--mobile.png deleted file mode 100644 index 51849b82..00000000 Binary files a/docs/audits/screens/08-review-needs_revision--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-published--desktop.png b/docs/audits/screens/08-review-published--desktop.png deleted file mode 100644 index a8f1e255..00000000 Binary files a/docs/audits/screens/08-review-published--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-published--mobile.png b/docs/audits/screens/08-review-published--mobile.png deleted file mode 100644 index 08b46f21..00000000 Binary files a/docs/audits/screens/08-review-published--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-qa_passed--desktop.png b/docs/audits/screens/08-review-qa_passed--desktop.png deleted file mode 100644 index b4ba2047..00000000 Binary files a/docs/audits/screens/08-review-qa_passed--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-qa_passed--mobile.png b/docs/audits/screens/08-review-qa_passed--mobile.png deleted file mode 100644 index 6e53a303..00000000 Binary files a/docs/audits/screens/08-review-qa_passed--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-researched--desktop.png b/docs/audits/screens/08-review-researched--desktop.png deleted file mode 100644 index f86900e2..00000000 Binary files a/docs/audits/screens/08-review-researched--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-researched--mobile.png b/docs/audits/screens/08-review-researched--mobile.png deleted file mode 100644 index 09f07cde..00000000 Binary files a/docs/audits/screens/08-review-researched--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-topic_selected--desktop.png b/docs/audits/screens/08-review-topic_selected--desktop.png deleted file mode 100644 index 2cc89fbd..00000000 Binary files a/docs/audits/screens/08-review-topic_selected--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-topic_selected--mobile.png b/docs/audits/screens/08-review-topic_selected--mobile.png deleted file mode 100644 index d246ae16..00000000 Binary files a/docs/audits/screens/08-review-topic_selected--mobile.png and /dev/null differ diff --git a/docs/audits/screens/08-review-verified--desktop.png b/docs/audits/screens/08-review-verified--desktop.png deleted file mode 100644 index c110af92..00000000 Binary files a/docs/audits/screens/08-review-verified--desktop.png and /dev/null differ diff --git a/docs/audits/screens/08-review-verified--mobile.png b/docs/audits/screens/08-review-verified--mobile.png deleted file mode 100644 index e673f2cd..00000000 Binary files a/docs/audits/screens/08-review-verified--mobile.png and /dev/null differ diff --git a/docs/audits/screens/09-raw-article-doc--desktop.png b/docs/audits/screens/09-raw-article-doc--desktop.png deleted file mode 100644 index 2ee63da0..00000000 Binary files a/docs/audits/screens/09-raw-article-doc--desktop.png and /dev/null differ diff --git a/docs/audits/screens/09-raw-article-doc--mobile.png b/docs/audits/screens/09-raw-article-doc--mobile.png deleted file mode 100644 index 55934ef4..00000000 Binary files a/docs/audits/screens/09-raw-article-doc--mobile.png and /dev/null differ diff --git a/docs/audits/screens/10-source-review--desktop.png b/docs/audits/screens/10-source-review--desktop.png deleted file mode 100644 index 569d9f4b..00000000 Binary files a/docs/audits/screens/10-source-review--desktop.png and /dev/null differ diff --git a/docs/audits/screens/10-source-review--mobile.png b/docs/audits/screens/10-source-review--mobile.png deleted file mode 100644 index 27220ee2..00000000 Binary files a/docs/audits/screens/10-source-review--mobile.png and /dev/null differ diff --git a/docs/audits/screens/10-sources--desktop.png b/docs/audits/screens/10-sources--desktop.png deleted file mode 100644 index 3c0403c3..00000000 Binary files a/docs/audits/screens/10-sources--desktop.png and /dev/null differ diff --git a/docs/audits/screens/10-sources--mobile.png b/docs/audits/screens/10-sources--mobile.png deleted file mode 100644 index 216c85e4..00000000 Binary files a/docs/audits/screens/10-sources--mobile.png and /dev/null differ diff --git a/docs/audits/screens/11-templates--desktop.png b/docs/audits/screens/11-templates--desktop.png deleted file mode 100644 index 44dfd660..00000000 Binary files a/docs/audits/screens/11-templates--desktop.png and /dev/null differ diff --git a/docs/audits/screens/11-templates--mobile.png b/docs/audits/screens/11-templates--mobile.png deleted file mode 100644 index a6580edd..00000000 Binary files a/docs/audits/screens/11-templates--mobile.png and /dev/null differ diff --git a/docs/audits/screens/12-reports-all--desktop.png b/docs/audits/screens/12-reports-all--desktop.png deleted file mode 100644 index 2bc922bb..00000000 Binary files a/docs/audits/screens/12-reports-all--desktop.png and /dev/null differ diff --git a/docs/audits/screens/12-reports-all--mobile.png b/docs/audits/screens/12-reports-all--mobile.png deleted file mode 100644 index a4ff7e8a..00000000 Binary files a/docs/audits/screens/12-reports-all--mobile.png and /dev/null differ diff --git a/docs/audits/screens/12-reports-week--desktop.png b/docs/audits/screens/12-reports-week--desktop.png deleted file mode 100644 index e85eaddb..00000000 Binary files a/docs/audits/screens/12-reports-week--desktop.png and /dev/null differ diff --git a/docs/audits/screens/12-reports-week--mobile.png b/docs/audits/screens/12-reports-week--mobile.png deleted file mode 100644 index e463b18d..00000000 Binary files a/docs/audits/screens/12-reports-week--mobile.png and /dev/null differ diff --git a/docs/audits/screens/13-collections-articles--desktop.png b/docs/audits/screens/13-collections-articles--desktop.png deleted file mode 100644 index 6525221b..00000000 Binary files a/docs/audits/screens/13-collections-articles--desktop.png and /dev/null differ diff --git a/docs/audits/screens/13-collections-articles--mobile.png b/docs/audits/screens/13-collections-articles--mobile.png deleted file mode 100644 index ec213e7e..00000000 Binary files a/docs/audits/screens/13-collections-articles--mobile.png and /dev/null differ diff --git a/docs/audits/screens/13-collections-pipeline-runs--desktop.png b/docs/audits/screens/13-collections-pipeline-runs--desktop.png deleted file mode 100644 index b08fd776..00000000 Binary files a/docs/audits/screens/13-collections-pipeline-runs--desktop.png and /dev/null differ diff --git a/docs/audits/screens/13-collections-pipeline-runs--mobile.png b/docs/audits/screens/13-collections-pipeline-runs--mobile.png deleted file mode 100644 index cc5c56ff..00000000 Binary files a/docs/audits/screens/13-collections-pipeline-runs--mobile.png and /dev/null differ diff --git a/docs/audits/screens/14-redirect-articles--desktop.png b/docs/audits/screens/14-redirect-articles--desktop.png deleted file mode 100644 index 107697c1..00000000 Binary files a/docs/audits/screens/14-redirect-articles--desktop.png and /dev/null differ diff --git a/docs/audits/screens/14-redirect-articles--mobile.png b/docs/audits/screens/14-redirect-articles--mobile.png deleted file mode 100644 index 09f67199..00000000 Binary files a/docs/audits/screens/14-redirect-articles--mobile.png and /dev/null differ diff --git a/docs/audits/screens/14-redirect-topics--desktop.png b/docs/audits/screens/14-redirect-topics--desktop.png deleted file mode 100644 index 1c6961c6..00000000 Binary files a/docs/audits/screens/14-redirect-topics--desktop.png and /dev/null differ diff --git a/docs/audits/screens/14-redirect-topics--mobile.png b/docs/audits/screens/14-redirect-topics--mobile.png deleted file mode 100644 index 4d370923..00000000 Binary files a/docs/audits/screens/14-redirect-topics--mobile.png and /dev/null differ diff --git a/docs/audits/screens/15-public-article--desktop.png b/docs/audits/screens/15-public-article--desktop.png deleted file mode 100644 index c754aaba..00000000 Binary files a/docs/audits/screens/15-public-article--desktop.png and /dev/null differ diff --git a/docs/audits/screens/15-public-article--mobile.png b/docs/audits/screens/15-public-article--mobile.png deleted file mode 100644 index 8a440ee5..00000000 Binary files a/docs/audits/screens/15-public-article--mobile.png and /dev/null differ diff --git a/docs/audits/screens/15-public-home--desktop.png b/docs/audits/screens/15-public-home--desktop.png deleted file mode 100644 index 8adf6387..00000000 Binary files a/docs/audits/screens/15-public-home--desktop.png and /dev/null differ diff --git a/docs/audits/screens/15-public-home--mobile.png b/docs/audits/screens/15-public-home--mobile.png deleted file mode 100644 index a656db5e..00000000 Binary files a/docs/audits/screens/15-public-home--mobile.png and /dev/null differ diff --git a/docs/audits/screens/15-public-home-with-article--desktop.png b/docs/audits/screens/15-public-home-with-article--desktop.png deleted file mode 100644 index 8adf6387..00000000 Binary files a/docs/audits/screens/15-public-home-with-article--desktop.png and /dev/null differ diff --git a/docs/audits/screens/15-public-home-with-article--mobile.png b/docs/audits/screens/15-public-home-with-article--mobile.png deleted file mode 100644 index a656db5e..00000000 Binary files a/docs/audits/screens/15-public-home-with-article--mobile.png and /dev/null differ diff --git a/docs/open-source-checklist.md b/docs/open-source-checklist.md deleted file mode 100644 index b33cf8dd..00000000 --- a/docs/open-source-checklist.md +++ /dev/null @@ -1,12 +0,0 @@ -# Opening this repository publicly — checklist for maintainers -# -# Complete these in the GitHub UI after merging open-source readiness changes: -# -# 1. Settings → General → Danger Zone → Change visibility → Public -# 2. Settings → General → Features → enable Issues (and Discussions if desired) -# 3. Settings → Code security → enable Dependabot alerts / private vulnerability reporting -# 4. Settings → Branches → protect `main`: require PR + require CI status check `ci` -# 5. Confirm SECURITY.md and advisories link work for the public repo -# 6. Optional: run a secret scan (gitleaks / trufflehog) on git history before going public -# -# Code-side readiness (LICENSE, README, CONTRIBUTING, CI, etc.) is handled in-repo. diff --git a/docs/superpowers/plans/2026-09-11-phase2-ui-workflow-polish.md b/docs/superpowers/plans/2026-09-11-phase2-ui-workflow-polish.md deleted file mode 100644 index d73b2b5c..00000000 --- a/docs/superpowers/plans/2026-09-11-phase2-ui-workflow-polish.md +++ /dev/null @@ -1,644 +0,0 @@ -# Phase 2: UI and workflow polish Implementation Plan - -> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. - -**Goal:** Close the findings in the 2026-09-11 UI and workflow audit: remove the disabled Codex integration and other dead code, give every article status an exit inside the admin, consolidate duplicate surfaces, and fix the layout, copy and docs defects. - -**Architecture:** The admin is Payload CMS 3 with custom ops views under `cms/src/components/ops/` mounted from `cms/src/payload.config.ts`. Server actions in that directory call the Payload local API; readiness comes from `cms/src/lib/workspaceReadiness.ts`; runs are created only through `cms/src/lib/createPipelineRun.ts` and executed by `cms/src/jobs/contentRun.ts`, which always scopes `runPipeline` to attached article ids. Status semantics live in one table, `cms/src/lib/articleStatusMeta.ts`. Work is sliced so each task leaves the app runnable and tested. - -**Tech Stack:** TypeScript, Next.js 16, Payload 3.88, Postgres, React 19, Vitest (CMS integration tests), Playwright (E2E), `node --test` via tsx (pipeline). - -**Spec:** `docs/audits/2026-09-11-ui-workflow-audit.md` (findings F-xxx, consolidation proposals C-x, legacy list L-x). The plan argues from it; where the plan and the audit disagree, the audit wins. - -## Global Constraints - -- Node 22+, npm workspaces. Never run `npm test --workspace cms`; use `npm run test:int --workspace cms`. File-scoped: `npm run test:int --workspace cms -- tests/int/.int.spec.ts`; pipeline: `npx tsx --test pipeline/test/.test.ts`; lint: `npm exec --workspace cms -- eslint `; typecheck: `npm run typecheck`. -- Integration tests run against `DATABASE_URL` in `cms/.env` (a migration-built database; dev push is disabled under Vitest). -- Article `status` metadata lives only in `cms/src/lib/articleStatusMeta.ts`; `pipeline/test/statusAlignment.test.ts` must keep passing. -- Every pipeline LLM call goes through `completeJSONLogged()`. `cms/src/lib/brandVoice.ts` stays dependency-free. -- After any collection or global schema change: `npm run generate:types --workspace cms`, commit `cms/src/payload-types.ts`, and add a migration under `cms/src/migrations/` (`npm run payload --workspace cms -- migrate:create `). -- Preserve append-only `article-audit`, `governance-audit`, `information-gain-runs`, and the gates in `cms/src/lib/articleReviewGate.ts` (the audit asks to surface `invalidateStaleInformationGain`, not remove it). -- Mock mode is the default locally; never require a live key to run a test. -- Copy rules: no CLI command names in operator-facing UI copy (`pipeline:run` must not appear in `cms/src/components/ops/*.tsx` after Task 4). Status labels come from `STATUS_META`. -- Commits follow Conventional Commits and end with `Co-Authored-By: Claude Fable 5.1 `. -- Do not edit `CHANGELOG.md`, release versions, or tags. - ---- - -### Task 1: Remove `codex/*` end to end (L-1, L-2, F-013) - -**Files:** -- Modify: `cms/src/lib/llmCatalog.ts` (delete `CODEX_MIRRORED_MODELS`, `codexMirror`, their entries in `LLM_CATALOG`) -- Modify: `cms/src/lib/llmProvider.ts` (delete `CODEX_MODEL_PREFIX`, `codexModelId`, the `codex-login` and `codex-disabled` requirement kinds, the `describeRequirement` branches; `providerForModel` returns only `anthropic` | `openai` | `unknown`) -- Delete: `cms/src/lib/codexCompletion.ts`, `cms/src/lib/codexAuth.ts`, `pipeline/src/codexCompletion.ts`, `pipeline/src/codexAuth.ts`, `pipeline/test/codexAuth.test.ts` -- Modify: `cms/src/lib/cmsLlm.ts:77-142` (remove the codex branch and comments), `cms/src/lib/workspaceReadiness.ts` (remove `needsCodexLogin`, `unsupportedModels`, the `codex-login` fingerprint branch; keep the shape of `runtime.blockers`), `cms/src/lib/loadWorkspaceReadiness.ts:191`, `cms/src/components/ops/RuntimeBanner.tsx:53-62`, `cms/src/components/ops/tenantActions.ts:621,640`, `pipeline/src/llm.ts:220-247` (delete `completeJSONCodex` and its catch), `pipeline/src/models.ts:46-50`, `pipeline/src/config.ts:46-60` (delete `codexAuthPresent`; the "may go live" test becomes: `MOCK_MODE` is false and the chosen provider key is set), `cms/src/globals/LlmSettings.ts:29` (description no longer mentions codex) -- Modify: `cms/package.json`, `pipeline/package.json` (drop `@openai/codex-sdk`), `cms/next.config.ts:20` (drop `@openai/codex-sdk` and `@openai/codex` from `serverExternalPackages`), `package-lock.json` via `npm install` -- Modify tests: `pipeline/test/llmClient.test.ts` (delete the `CodexNotLoggedInError` cases), `pipeline/test/llmProvider.test.ts:67` (delete the `codex-login` case), `pipeline/test/workspaceReadiness.test.ts:98-180,378-405` (delete the three codex cases), `cms/tests/int/cmsLlm.int.spec.ts` and `cms/tests/int/brandVoiceExtract.int.spec.ts` (delete the `CODEX_HOME` cases; keep the "mock mode never flips to live without a key" assertion by asserting on `ANTHROPIC_API_KEY` absence instead) -- Modify fixtures: any mock fixture keyed on a `codex/*` id (`grep -rn "codex/" cms/src pipeline/src`) re-keys to the `claude-*` id it mirrored -- Create: `cms/src/migrations/_drop_codex_model_options.ts` — Postgres cannot drop enum values, so `up()` only nulls any stored `codex/*` selection in `llm_settings` (`UPDATE llm_settings SET = NULL WHERE LIKE 'codex/%'` for each of the nine model columns) and `down()` is `SELECT 1` with a comment; regenerate `cms/src/payload-types.ts` -- Modify docs: `AGENTS.md:49` (delete the codex bullet), `README.md:120-124` (delete "Codex model choices"; line 51 "Legacy `codex/*` choices are mock-only" sentence), `docs/diagrams/pipeline-data-flow.html` and `.svg` caption "Anthropic · OpenAI · your Codex CLI" → "Anthropic · OpenAI" - -**Interfaces:** -- Produces: `providerForModel(id): 'anthropic' | 'openai' | 'unknown'`; `requirementForModel(id): { kind: 'env'; name: string } | null`; `RuntimeReadiness` without `needsCodexLogin`/`unsupportedModels` (Task 7 reads `runtime.blockers` and `runtime.missing`). - -- [ ] **Step 1: Inventory every codex reference** - -Run: `grep -rni "codex" --include=*.ts --include=*.tsx --include=*.md --include=*.json --include=*.html --include=*.svg cms pipeline docs README.md AGENTS.md | grep -v node_modules | grep -v payload-types.ts | grep -v package-lock.json | grep -v e2e-reports` -Expected: the list above, plus `cms/src/migrations/20260902_210000_codex_model_options.*` (leave that migration in place; history is immutable). - -- [ ] **Step 2: Write the failing tests first** - -In `pipeline/test/llmProvider.test.ts` replace the codex cases with: - -```ts -test('codex ids are unknown providers with no requirement', () => { - assert.equal(providerForModel('codex/gpt-5.4'), 'unknown') - assert.equal(requirementForModel('codex/gpt-5.4'), null) -}) -``` - -In `cms/tests/int/llmSettings.int.spec.ts` add: - -```ts -it('offers no codex/* option on any model field', () => { - const fields = LlmSettings.fields.filter((f) => f.type === 'select') - for (const field of fields) { - expect(field.options.map((o) => (typeof o === 'string' ? o : o.value))).not.toContainEqual(expect.stringMatching(/^codex\//)) - } -}) -``` - -Run both; expected: FAIL (codex ids still resolve to a codex provider; options still contain codex/*). - -- [ ] **Step 3: Remove the code, dependencies and fixtures listed in Files** - -Run `npm install` after editing the two `package.json` files so `package-lock.json` drops the six `@openai/codex` platform binaries. - -- [ ] **Step 4: Add the migration and regenerate types** - -Run: `npm run payload --workspace cms -- migrate:create drop_codex_model_options`, replace the generated body with the nine `UPDATE ... WHERE ... LIKE 'codex/%'` statements (column names from `cms/src/migrations/20260902_210000_codex_model_options.ts`), then `npm run payload --workspace cms -- migrate` and `npm run generate:types --workspace cms`. -Expected: `git diff --stat cms/src/payload-types.ts` shows only the removed `codex/*` enum members. - -- [ ] **Step 5: Run the suites** - -Run: `npm run typecheck && npm run lint && npm test && npm run test:int --workspace cms -- tests/int/llmSettings.int.spec.ts tests/int/cmsLlm.int.spec.ts tests/int/brandVoiceExtract.int.spec.ts tests/int/workspaceProfile.int.spec.ts` -Expected: all pass; `grep -rni "codex" cms/src pipeline/src` returns only the 2026-09-02 migration. - -- [ ] **Step 6: Commit** - -```bash -git add -A -git commit -m "refactor: remove disabled codex model integration - -Drops the codex/* model ids, the fail-closed completion boundary, the -login probe, the SDK dependency and every test pinned to the disabled -path. A migration nulls any stored codex selection; the enum values stay -because Postgres cannot drop them. - -Co-Authored-By: Claude Fable 5.1 " -``` - ---- - -### Task 2: Delete dead routes, files, exports and unreachable branches (L-3 to L-9, L-11) - -**Files:** -- Delete: `cms/src/app/my-route/route.ts`, `cms/src/components/ops/TopicDiscoveryView.tsx`, `cms/src/components/ops/ArticleBoardView.tsx`, `cms/src/app/(payload)/custom.scss`, `cms/src/components/ops/.omc/state/last-tool-error.json`, `e2e-reports/` (whole directory) -- Modify: `cms/src/payload.config.ts` (remove the two view registrations for `/ops/topics` and `/ops/articles`), `cms/src/app/(payload)/admin/importMap.js` (regenerate: `npm run payload --workspace cms -- generate:importmap`), `cms/src/app/(payload)/layout.tsx:10` (drop the `custom.scss` import), `cms/next.config.ts` (add `redirects()` returning `/admin/ops/topics → /admin/ops/new` and `/admin/ops/articles → /admin/ops/content`, both `permanent: false`), `.gitignore` (add `.omc/`) -- Modify: `cms/src/lib/brandVoice.ts:249` (delete `notTraitsOf`), `cms/src/lib/tenant/positioning.ts:21` (delete `OPEN_RULING_STATUSES`; keep `OpenRulingStatus` if it is used, else delete) -- Modify: `cms/src/components/ops/ContentRunForm.tsx` (remove the `source="onboarding"` branch and the `source` prop; the form always starts an `admin` run), `cms/src/jobs/contentRun.ts:69-91` (remove the `onboarding` source branch and `pauseForBrief: false`; `PipelineRuns.ts` `source` select loses the `onboarding` option — add a migration that maps stored `onboarding` rows to `admin` and regenerate types), `cms/src/lib/workspaceReadiness.ts:379-385` (delete `verification` from the readiness result and its `stale` fingerprint logic; delete `configFingerprint` consumers only if `verification` was their sole reader — check with grep, and if `configFingerprint` is still written to audit rows keep it) -- Modify: `cms/src/lib/articleReviewGate.ts:19-21` comment: replace the sentence claiming `ArticleReview.tsx` offers Approve at `qa_passed` with "`ArticleReview.tsx` shows a read-only 'Awaiting information gain' panel at `qa_passed`; the allow-list exists so no client can approve a draft that has not been scored." - -**Interfaces:** -- Produces: `ContentRunForm` props `{ templates, mode, pipelineReady, runActive, selectedTemplateId?: number }` (Task 7 passes `selectedTemplateId`). - -- [ ] **Step 1: Write the failing tests** - -Add to `cms/tests/int/pipelineRun.int.spec.ts`: - -```ts -it('rejects an onboarding source', async () => { - await expect(createPipelineRun(payload, user, { ...baseInput, source: 'onboarding' as never })).rejects.toThrow() -}) -``` - -Add `cms/tests/e2e/redirects.e2e.spec.ts`: - -```ts -import { expect, test } from '@playwright/test' -test('legacy ops routes redirect', async ({ page }) => { - const topics = await page.goto('/admin/ops/topics') - expect(new URL(page.url()).pathname).toBe('/admin/ops/new') - await page.goto('/admin/ops/articles') - expect(new URL(page.url()).pathname).toBe('/admin/ops/content') - const r = await page.request.get('/my-route') - expect(r.status()).toBe(404) -}) -``` - -Run the int test; expected: FAIL (onboarding accepted). - -- [ ] **Step 2: Make the deletions and edits in Files; regenerate the import map and types; add the `onboarding → admin` migration** - -- [ ] **Step 3: Run the suites** - -Run: `npm run typecheck && npm run lint && npm test && npm run test:int --workspace cms -- tests/int/pipelineRun.int.spec.ts tests/int/workspaceProfile.int.spec.ts tests/int/tenantActions.int.spec.ts` -Expected: pass. `git ls-files | grep -c e2e-reports` prints 0. - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "chore: remove dead routes, unreachable run paths and tracked artifacts - -Co-Authored-By: Claude Fable 5.1 " -``` - ---- - -### Task 3: One way to queue a run, with honest errors (C-4 server half, F-023, F-033) - -**Files:** -- Modify: `cms/src/components/ops/boardActions.ts` — extract the body of `runSelectedArticlesAction` after the readiness checks into an exported `queueRunForArticles(payload, user, docs, readiness): Promise<{ runId: string }>`; `runSelectedArticlesAction` calls it. Replace line 63's fixed string with `` `Finish setup before running the pipeline: ${readiness.governance.problems.join('; ')}.` ``. Replace `boardActions.ts:305-307` `catch { throw new Error('Could not load run status.') }` with `catch (error) { throw new Error(\`Could not load run status: ${errorMessage(error, 'unknown error')}\`) }`. -- Modify: `cms/src/components/ops/actions.ts` — `resetToDraftedAction` and `regenerateArticleAction` accept a third argument `options?: { queueRun?: boolean }` (default `true`); after the update they load readiness with `loadWorkspaceSetup`, and when `readiness.governance.ready && readiness.runtime.ready && readiness.mode === 'mock'` (or `options.confirmLiveCost === true` in live mode) call `queueRunForArticles` for that article. On `ActivePipelineRunError` they return `{ queued: false, reason: error.message }`; otherwise `{ queued: true, runId }`. Both keep their existing audit contexts. -- Modify: `cms/src/components/ops/contentRunActions.ts:62-65` — the generic catch returns `` { ok: false, error: `Could not start the run: ${errorMessage(error, 'unknown error')}` } `` (import `errorMessage` from `boardActions.ts` or move it to `cms/src/lib/errorMessage.ts` and import it in both). -- Modify: `cms/src/components/ops/ArticleReview.tsx:464` — `catch (error) { setError(error instanceof Error ? error.message : String(error)) }`. -- Test: `cms/tests/int/articleActions.int.spec.ts` (extend), `cms/tests/int/boardActions.int.spec.ts` (create) - -**Interfaces:** -- Produces: `queueRunForArticles(payload, user, docs: Article[], readiness: WorkspaceReadiness): Promise<{ runId: string }>` exported from `boardActions.ts`; `resetToDraftedAction(id, notes?, options?) → Promise<{ queued: boolean; runId?: string; reason?: string }>`; same shape for `regenerateArticleAction(id, note?, options?)`. - -- [ ] **Step 1: Write the failing tests** - -In `cms/tests/int/articleActions.int.spec.ts` (it already mocks `payload`, `next/headers`, `next/cache`) add a mock for `@/lib/loadWorkspaceReadiness` returning `{ readiness: { governance: { ready: true, problems: [] }, runtime: { ready: true, blockers: [] }, mode: 'mock' }, templates: [] }` and a mock for `@/lib/createPipelineRun`'s `createPipelineRun`, then: - -```ts -it('resetToDraftedAction queues a selected run for the article', async () => { - findByIDMock.mockResolvedValueOnce({ id: 1, status: 'needs_revision', template: 3 } as never) - const result = await resetToDraftedAction(1, 'fixed the intro') - expect(result.queued).toBe(true) - expect(createPipelineRunMock).toHaveBeenCalledWith(expect.anything(), expect.anything(), expect.objectContaining({ source: 'selected', articleIds: [1] })) -}) - -it('regenerateArticleAction reports when a run is already active', async () => { - createPipelineRunMock.mockRejectedValueOnce(new ActivePipelineRunError('A run is already active.')) - const result = await regenerateArticleAction(1, 'tighten it') - expect(result).toEqual({ queued: false, reason: 'A run is already active.' }) -}) -``` - -Create `cms/tests/int/boardActions.int.spec.ts` with the same mocking pattern and: - -```ts -it('names every governance problem instead of assuming brand voice', async () => { - loadWorkspaceSetupMock.mockResolvedValueOnce({ readiness: { runtime: { ready: true, blockers: [] }, governance: { ready: false, problems: ['Add an active audience', 'Set a target domain'] }, mode: 'mock' } } as never) - const result = await runSelectedArticlesAction({ articleIds: [1] }) - expect(result).toEqual({ ok: false, error: 'Finish setup before running the pipeline: Add an active audience; Set a target domain.' }) -}) -``` - -Run: `npm run test:int --workspace cms -- tests/int/articleActions.int.spec.ts tests/int/boardActions.int.spec.ts` -Expected: FAIL. - -- [ ] **Step 2: Implement the changes in Files** - -- [ ] **Step 3: Run tests, typecheck, lint on the touched files** - -Run: `npm run test:int --workspace cms -- tests/int/articleActions.int.spec.ts tests/int/boardActions.int.spec.ts tests/int/briefActions.int.spec.ts && npm run typecheck && npm exec --workspace cms -- eslint src/components/ops/actions.ts src/components/ops/boardActions.ts src/components/ops/contentRunActions.ts` -Expected: pass. - -- [ ] **Step 4: Commit** - -```bash -git add -A -git commit -m "feat(cms): queue a run after reset and regenerate; report real errors - -Co-Authored-By: Claude Fable 5.1 " -``` - ---- - -### Task 4: Run controls in the UI and honest "stalled" state (C-4 UI half, F-022, F-020, F-027, F-031) - -**Files:** -- Modify: `cms/src/components/ops/ArticleReview.tsx` - - Replace the generic "Status" block (lines 995-1016) and the `qa_passed` "Awaiting information gain" block (831-846) with one `RunNextStagePanel` rendered for every status where `isRunnableStatus(article.status)`: heading from `STAGE_LABEL[STATUS_META[status].stage]`, one sentence "Datum will `` this piece on the next run." and a primary button **Run next stage** calling `runSelectedArticlesAction({ articleIds: [article.id], confirmLiveCost })`. In live mode the button first shows a one-line cost confirmation ("This calls paid providers. Continue?") with Confirm / Cancel. - - `topic_selected`: merge "Assign template" (545) and "Start research" (582) into one panel: template select (unchanged options) plus a single button **Assign and start research** that calls `assignTemplateAction` then `runSelectedArticlesAction`; drop the SERP dump paragraph above the select (keep `researchHint` only if it is a one-line hint). - - `published`: a "Live" panel with the public link `/articles/` and the published date; `approved` keeps its panel (Task 6 extends it). - - Remove every literal `pipeline:run` from copy (lines 741, 823, 836): "re-enters QA on the next run", "writes a new draft on the next run". - - Header pill: when `STATUS_META[status].owner === 'run'` and `!activeRunIncludesArticle`, show "Stalled ·