Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 0cc3214c84892c361adb4cb1ecedce772bd19f73
parent d3acb9de0cc988b196d69ada309f60d9b1de9656
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 15 Oct 2026 08:42:00 -0400

common, umtool: review fixes — the social posts' and publish.videoUrl's problems are warnings (`publishWarnings`: the lint warns, the build and the cut's edits go on; "Use this" on a post still refuses one past its count; YouTube's rules unchanged); the Social posts section says when publish.videoUrl is not in a post drafted before it and offers "Re-draft the posts" (forced, on the cut's iteration; a post you wrote is never replaced); Draft everything's social step removes a platform's old file when it has no post; a deck refused on a frame too small for it says "frame too small for the deck (W×H)"

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/lib/report/drafted.d.mts | 1+
Mcommon/lib/report/drafted.mjs | 39++++++++++++++++++++++++++++++---------
Mcommon/lib/report/drafted.test.ts | 22+++++++++++++++-------
Aumtool/components/projects/RedraftSocial.tsx | 45+++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/SocialPostSection.tsx | 23+++++++++++++++++++++--
Mumtool/components/projects/report/MediaTab.tsx | 6+++++-
Mumtool/e2e/media-draft.spec.ts | 16+++++++++++++++-
Mumtool/lib/report/chain-draft.mjs | 15+++++++++++++++
Mumtool/lib/report/chain-draft.test.mjs | 23+++++++++++++++++++++--
Mumtool/lib/report/chain-run.mjs | 23++++++++++++++++++-----
Mumtool/lib/report/drafted-writer.test.mjs | 16++++++++++++++++
Mumtool/lib/report/manifest.mjs | 9+++++----
Mumtool/report-to-video/lint.mjs | 5++++-
13 files changed, 211 insertions(+), 32 deletions(-)

diff --git a/common/lib/report/drafted.d.mts b/common/lib/report/drafted.d.mts @@ -48,3 +48,4 @@ export function pruneDrafted(manifest: unknown): string[]; export function clearEditedDrafts(before: unknown, after: unknown): { entry: string | null; field: string }[]; export function validateDrafted(manifest: unknown): string[]; export function validatePublish(manifest: unknown): string[]; +export function publishWarnings(manifest: unknown, o?: { only?: "x" | "bluesky" | "videoUrl" }): string[]; diff --git a/common/lib/report/drafted.mjs b/common/lib/report/drafted.mjs @@ -512,11 +512,12 @@ export function validateDrafted(manifest) { /** * `publish` (release 28; release 29 G2): what is published beside the video. - * `publish.youtube { title, description }`, two strings (M6 fills it); - * `publish.x` and `publish.bluesky` `{ post, thread? }` (the social task's: - * each post within its platform's count, ./social.mjs); `publish.videoUrl`, - * the video's public URL once it is up (the operator's: what a social post - * links, else the article's page). + * `publish.youtube { title, description }`, two strings (M6 fills it); its + * problems, and a key `publish` does not know, are ERRORS (the build refuses, + * as since release 28). `publish.x`, `publish.bluesky` `{ post, thread? }` and + * `publish.videoUrl` are not the video's: their problems are WARNINGS + * (`publishWarnings`), so a hand-edited post past its count never stops a + * build or an edit of the cut (review fix, release 29). * * @param {any} manifest * @returns {string[]} @@ -527,10 +528,6 @@ export function validatePublish(manifest) { if (!isObj(p)) return ["publish must be an object ({ youtube, x, bluesky, videoUrl })"]; const errors = []; for (const k of Object.keys(p)) if (!PUBLISH_KEYS.includes(k) && k !== "drafted") errors.push(`publish.${k} is not a publish key (${PUBLISH_KEYS.join(", ")})`); - if (p.videoUrl !== undefined && !(typeof p.videoUrl === "string" && /^https?:\/\/\S+$/i.test(p.videoUrl.trim()))) { - errors.push("publish.videoUrl must be the video's http(s) URL"); - } - for (const k of SOCIAL_PLATFORMS) if (p[k] !== undefined) errors.push(...validateSocialPost(k, p[k]).filter((e) => !e.endsWith(".drafted: the mark goes in the top-level drafted map"))); const y = p.youtube; if (y === undefined) return errors; if (!isObj(y)) return [...errors, "publish.youtube must be { title, description }"]; @@ -545,3 +542,27 @@ export function validatePublish(manifest) { if (typeof y.title === "string" && /[\r\n]/.test(y.title)) errors.push("publish.youtube.title must be one line"); return errors; } + +/** + * The social posts' and the video URL's problems (release 29 G2), as + * warnings: `publish.x` / `publish.bluesky` within their platform's count + * (./social.mjs), `publish.videoUrl` an http(s) URL. `only` limits them to one + * key (the field's own writer refuses on these). + * + * @param {any} manifest + * @param {{ only?: "x" | "bluesky" | "videoUrl" }} [o] + * @returns {string[]} + */ +export function publishWarnings(manifest, { only } = {}) { + const p = manifest?.publish; + if (!isObj(p)) return []; + const out = []; + if ((!only || only === "videoUrl") && p.videoUrl !== undefined && !(typeof p.videoUrl === "string" && /^https?:\/\/\S+$/i.test(p.videoUrl.trim()))) { + out.push("publish.videoUrl must be the video's http(s) URL"); + } + for (const k of SOCIAL_PLATFORMS) { + if (only && only !== k) continue; + if (p[k] !== undefined) out.push(...validateSocialPost(k, p[k]).filter((e) => !e.endsWith(".drafted: the mark goes in the top-level drafted map"))); + } + return out; +} diff --git a/common/lib/report/drafted.test.ts b/common/lib/report/drafted.test.ts @@ -18,6 +18,7 @@ import { pruneDrafted, reviewAddress, validateDrafted, + publishWarnings, validatePublish, } from "./drafted.mjs"; @@ -165,21 +166,28 @@ test("validatePublish: publish.youtube is two strings, YouTube's limits; nothing assert.deepEqual(validatePublish({ publish: [] }), ["publish must be an object ({ youtube, x, bluesky, videoUrl })"]); }); -test("validatePublish (release 29 G2): the social posts within their platform's count, a thread of at most 4, the video's URL", () => { +test("publishWarnings (release 29 G2): the social posts within their platform's count, a thread of at most 4, the video's URL — warnings, never validatePublish's errors", () => { const link = "https://archilyzer.example/articles/synth-basic/"; - assert.deepEqual(validatePublish({ publish: { x: { post: `A post.\n\n${link}` }, bluesky: { post: "A post.", thread: ["Two.", "Three."] }, videoUrl: "https://video.example/v/1" } }), []); + const fine = { publish: { x: { post: `A post.\n\n${link}` }, bluesky: { post: "A post.", thread: ["Two.", "Three."] }, videoUrl: "https://video.example/v/1" } }; + assert.deepEqual(publishWarnings(fine), []); + assert.deepEqual(validatePublish(fine), []); // X: a URL weighs 23 whatever its length, so 255 characters and a long link is 280. - assert.deepEqual(validatePublish({ publish: { x: { post: `${"a".repeat(255)}\n\n${link}${"z".repeat(80)}` } } }), []); - assert.deepEqual(validatePublish({ publish: { x: { post: `${"a".repeat(256)}\n\n${link}` } } }), ["publish.x.post is 281 characters as X counts them (at most 280)"]); + assert.deepEqual(publishWarnings({ publish: { x: { post: `${"a".repeat(255)}\n\n${link}${"z".repeat(80)}` } } }), []); + const long = { publish: { x: { post: `${"a".repeat(256)}\n\n${link}` } } }; + assert.deepEqual(publishWarnings(long), ["publish.x.post is 281 characters as X counts them (at most 280)"]); + assert.deepEqual(validatePublish(long), [], "a post past its count does not refuse the build"); // Bluesky counts graphemes: 300 flags are 300, not 600 code points. - assert.deepEqual(validatePublish({ publish: { bluesky: { post: "🇫🇷".repeat(300) } } }), []); - assert.deepEqual(validatePublish({ publish: { bluesky: { post: "🇫🇷".repeat(301) } } }), ["publish.bluesky.post is 301 graphemes (at most 300)"]); - assert.deepEqual(validatePublish({ publish: { x: { post: "", thread: ["a", "b", "c", "d", "e"], tags: 1 }, videoUrl: "video" } }), [ + assert.deepEqual(publishWarnings({ publish: { bluesky: { post: "🇫🇷".repeat(300) } } }), []); + assert.deepEqual(publishWarnings({ publish: { bluesky: { post: "🇫🇷".repeat(301) } } }), ["publish.bluesky.post is 301 graphemes (at most 300)"]); + const bad = { publish: { x: { post: "", thread: ["a", "b", "c", "d", "e"], tags: 1 }, videoUrl: "video" } }; + assert.deepEqual(publishWarnings(bad), [ "publish.videoUrl must be the video's http(s) URL", "publish.x.tags is not a social post field (post, thread)", "publish.x.post must be a post (a string)", "publish.x.thread has 5 posts (at most 4)", ]); + assert.deepEqual(publishWarnings(bad, { only: "videoUrl" }), ["publish.videoUrl must be the video's http(s) URL"]); + assert.deepEqual(validatePublish(bad), []); }); test("review addresses and keys: one address per field, a key that moves with the value", () => { diff --git a/umtool/components/projects/RedraftSocial.tsx b/umtool/components/projects/RedraftSocial.tsx @@ -0,0 +1,45 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { buttonVariants } from "@/components/ui/button"; + +// "Re-draft the posts" (release 29 review): the social draft again, forced, +// on the iteration the cut was made from — what the Social posts section +// offers when `publish.videoUrl` changed after the posts were drafted (the +// link is code's, fixed when they are drafted). A post you wrote or edited is +// never replaced: the draft is kept as an alternative. +export default function RedraftSocial({ article, n }: { article: string; n: number }) { + const router = useRouter(); + const [state, setState] = useState<"idle" | "busy" | "queued" | "failed">("idle"); + const [error, setError] = useState(""); + async function go() { + setState("busy"); + setError(""); + const r = await fetch("/api/articles/generate", { + method: "POST", + body: JSON.stringify({ task: "social", article, iteration: n, force: true }), + }).catch(() => null); + const b = r ? await r.json().catch(() => ({})) : {}; + if (!r?.ok) { + setState("failed"); + setError(b.error ?? "the editor did not answer"); + return; + } + setState("queued"); + router.refresh(); + } + return ( + <span className="inline-flex items-center gap-2"> + <button type="button" data-social-redraft="" className={buttonVariants({ variant: "outline", size: "sm" })} disabled={state === "busy" || state === "queued"} onClick={() => void go()}> + Re-draft the posts + </button> + {state === "queued" && <span className="text-muted">queued — the Social row follows it</span>} + {state === "failed" && ( + <span role="alert" className="text-reject-text"> + {error} + </span> + )} + </span> + ); +} diff --git a/umtool/components/projects/SocialPostSection.tsx b/umtool/components/projects/SocialPostSection.tsx @@ -5,6 +5,7 @@ import { Panel } from "@/components/ui/panel"; import { fmtAgo } from "@/lib/format"; import { SOCIAL_LIMITS, SOCIAL_NAMES, socialLength, type SocialPlatform } from "yt-dlp-transcript-common/lib/report/social.mjs"; import { SOCIAL_PLATFORMS, composeSocialText, socialPosts, socialTextName } from "umtool-report-to-video/social"; +import RedraftSocial from "./RedraftSocial"; // The promotion posts (release 29 G2): `publish.x` and `publish.bluesky`, the // first post (its link under it, added by code) and the thread under it, each @@ -12,11 +13,16 @@ import { SOCIAL_PLATFORMS, composeSocialText, socialPosts, socialTextName } from // graphemes). Copy takes what out/<platform>.txt holds -- the same text, // composed from the manifest. TEXT ONLY: nothing here posts. Nothing when // the cut has neither post. +// +// The link under a first post is fixed when it is drafted. When the cut's +// `publish.videoUrl` is set and a post does not carry it (it was drafted +// before, linking the article or nothing), the section says so and offers a +// re-draft on the iteration the cut was made from (review fix, release 29). -type Props = { dir: string; manifest: Record<string, unknown> }; +type Props = { dir: string; manifest: Record<string, unknown>; iteration?: { article: string; n: number } | null }; type Value = { post?: string; thread?: string[] }; -export default async function SocialPostSection({ dir, manifest }: Props) { +export default async function SocialPostSection({ dir, manifest, iteration = null }: Props) { const publish = (manifest.publish ?? {}) as Partial<Record<SocialPlatform, Value>>; const drafted = (manifest.drafted ?? {}) as Record<string, { model?: string } | undefined>; const platforms = (SOCIAL_PLATFORMS as readonly SocialPlatform[]).filter((p) => socialPosts(publish[p]).length > 0); @@ -24,8 +30,21 @@ export default async function SocialPostSection({ dir, manifest }: Props) { const written = Object.fromEntries( await Promise.all(platforms.map(async (p) => [p, await stat(path.join(dir, "out", socialTextName(p))).then((s) => s.mtimeMs, () => null)] as const)), ) as Record<SocialPlatform, number | null>; + const videoUrl = typeof (manifest.publish as { videoUrl?: unknown } | undefined)?.videoUrl === "string" ? String((manifest.publish as { videoUrl: string }).videoUrl).trim() : ""; + const stale = /^https?:\/\/\S+$/i.test(videoUrl) ? platforms.filter((p) => !String(publish[p]?.post ?? "").includes(videoUrl)) : []; + const yours = stale.filter((p) => !drafted[`publish.${p}`]); return ( <Panel title="social posts" aria-label="Social posts" aside={<span className="text-muted">text only — copy it, nothing is posted</span>}> + {stale.length > 0 && ( + <p data-social-stale={stale.join(" ")} className="m-0 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px] text-text-2"> + <span> + The {stale.map((p) => SOCIAL_NAMES[p]).join(" and ")} post{stale.length > 1 ? "s link" : " links"} the old address, not the video + (<span className="font-mono">{videoUrl}</span>): the link is set when a post is drafted. + {yours.length > 0 ? ` ${yours.map((p) => SOCIAL_NAMES[p]).join(" and ")}: yours — edit it, a re-draft never replaces it.` : ""} + </span> + {iteration && yours.length < stale.length && <RedraftSocial article={iteration.article} n={iteration.n} />} + </p> + )} <div className="grid gap-3 md:grid-cols-2"> {platforms.map((p) => { const posts = socialPosts(publish[p]); diff --git a/umtool/components/projects/report/MediaTab.tsx b/umtool/components/projects/report/MediaTab.tsx @@ -55,7 +55,11 @@ export default async function MediaTab({ project, detail }: ReportTabProps) { <YoutubeSection dir={project.dir} manifest={m as Record<string, unknown>} /> {/* --- the promotion posts (publish.x, publish.bluesky; text only) - */} - <SocialPostSection dir={project.dir} manifest={m as Record<string, unknown>} /> + <SocialPostSection + dir={project.dir} + manifest={m as Record<string, unknown>} + iteration={link.ok && link.status === "done" ? { article: link.article, n: link.n } : null} + /> </> ); } diff --git a/umtool/e2e/media-draft.spec.ts b/umtool/e2e/media-draft.spec.ts @@ -1,5 +1,5 @@ import { test, expect, type Page } from "@playwright/test"; -import { readFileSync } from "node:fs"; +import { readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { WARM_TIMEOUT, warm } from "./warm"; @@ -109,4 +109,18 @@ test("social (release 29 G2): a post for X and one for Bluesky with their thread await expect(panel.getByRole("region", { name: "X post" }).getByRole("button", { name: "Copy" })).toBeVisible(); // Its draft row on the Media tab, in Draft everything's order (the last). await expect(page.locator("[data-media-chip='social']")).toBeVisible(); + + // The video is up: its URL set after the posts were drafted. The section + // says they link the old address and re-drafts them (review fix). + const file = path.join(FIXTURE, "gen-projects", ARTICLE, "i4", "video.manifest.json"); + const videoUrl = "https://video.example/watch/mdraft-4"; + writeFileSync(file, JSON.stringify({ ...manifestOf(4), publish: { ...manifestOf(4).publish, videoUrl } }, null, 2) + "\n"); + await page.reload(); + const stale = panel.locator("[data-social-stale]"); + await expect(stale).toHaveAttribute("data-social-stale", "x bluesky"); + await stale.getByRole("button", { name: "Re-draft the posts" }).click(); + await expect(stale).toContainText("queued"); + expect(lastAsked()).toMatchObject({ task: "social", article: ARTICLE, iteration: 4, force: true }); + await expect.poll(() => manifestOf(4).publish.x.post, { timeout: 60_000 }).toMatch(/\n\nhttps:\/\/video\.example\/watch\/mdraft-4$/); + expect(manifestOf(4).publish.bluesky.post.endsWith(`\n\n${videoUrl}`)).toBe(true); }); diff --git a/umtool/lib/report/chain-draft.mjs b/umtool/lib/report/chain-draft.mjs @@ -21,6 +21,21 @@ export function deckChrome() { export const deckStepDetail = (added) => added ? "deck added: render.chrome with every setting its default (a snapshot of the cut before it is in revisions/)" : "deck already there: the cut's render.chrome is kept as it is"; +/** + * A refused deck step's line: "frame too small for the deck" when the deck's + * defaults do not fit the cut's frame (validateChrome's "… needs …px but a + * …px deck leaves …"), else the refusal itself. + * + * @param {string[]} errors validateChrome's sentences + * @param {{ width?: number, height?: number } | undefined} render + */ +export function deckRefusedDetail(errors, render) { + const size = render?.width && render?.height ? ` (${render.width}×${render.height})` : ""; + const small = (errors ?? []).find((e) => /needs \d+px but a \d+px deck leaves/.test(e)); + if (small) return `frame too small for the deck${size}: ${small} — no deck added, so the flips and threads are skipped`; + return `the deck was refused: ${(errors ?? []).join("; ")}`; +} + /** The audit file each task writes beside the manifest (narrate's kept its old name). */ export const draftFileOf = (task) => (task === "narrate" ? "narration-draft.json" : `${task}-draft.json`); diff --git a/umtool/lib/report/chain-draft.test.mjs b/umtool/lib/report/chain-draft.test.mjs @@ -12,12 +12,12 @@ import assert from "node:assert/strict"; import test, { after, before } from "node:test"; import { spawn } from "node:child_process"; import http from "node:http"; -import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; +import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; import os from "node:os"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { CHAIN_RUN, REPO_ROOT } from "./chain.mjs"; -import { deckChrome, deckStepDetail, draftOutcome, draftPrecheck, draftFileOf } from "./chain-draft.mjs"; +import { deckChrome, deckRefusedDetail, deckStepDetail, draftOutcome, draftPrecheck, draftFileOf } from "./chain-draft.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const KIT = path.join(HERE, "..", "..", "..", "common", "testing", "draft"); @@ -216,6 +216,25 @@ test("the social draft (release 29 G2): done, and its posts written to out/x.txt assert.equal(recorded("draft-social").detail, "2 social posts drafted; out/x.txt and out/bluesky.txt written"); assert.equal(readFileSync(path.join(PROJECT, "out", "x.txt"), "utf8"), `The post.\n\n${link}\n\n— 2/2 —\nTwo.\n`); assert.equal(readFileSync(path.join(PROJECT, "out", "bluesky.txt"), "utf8"), `The post.\n\n${link}\n`); + // A re-draft that leaves Bluesky with no post removes its old file (review fix). + put(file, { ...baseManifest, publish: { x: { post: `The post.\n\n${link}` } } }); + const again = await (await step("draft-social")).done; + assert.equal(again.code, 0, again.out); + assert.equal(recorded("draft-social").detail, "2 social posts drafted; out/x.txt written"); + assert.equal(existsSync(path.join(PROJECT, "out", "bluesky.txt")), false); + put(file, baseManifest); +}); + +test("the deck step on a frame too small for the deck says so, adds nothing, and the chain goes on", async () => { + const file = path.join(PROJECT, "video.manifest.json"); + put(file, { ...baseManifest, render: { ...baseManifest.render, width: 640, height: 360 } }); + const before = readFileSync(file, "utf8"); + const r = await (await step("deck")).done; + assert.equal(r.code, 0, r.out); + assert.equal(recorded("deck").status, "failed"); + assert.match(recorded("deck").detail, /^frame too small for the deck \(640×360\): .*needs \d+px but a \d+px deck leaves/); + assert.equal(readFileSync(file, "utf8"), before); + assert.match(deckRefusedDetail(["render.chrome.engine must be \"hyperframes\""], {}), /^the deck was refused: /); put(file, baseManifest); }); diff --git a/umtool/lib/report/chain-run.mjs b/umtool/lib/report/chain-run.mjs @@ -27,7 +27,7 @@ // (manifest.mjs addDeckChrome: a snapshot first) when the cut has none. import { spawn } from "node:child_process"; -import { copyFile, mkdir, readFile, rename, stat, writeFile } from "node:fs/promises"; +import { copyFile, mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; @@ -50,8 +50,8 @@ import { toManifestMain } from "yt-dlp-transcript-common/bin/reports-convert"; import { attachVideoMain } from "yt-dlp-transcript-common/bin/reports-attach-video"; import { checkMain } from "yt-dlp-transcript-common/bin/reports-check"; import { ALL_CHAIN_STEP_NAMES, CHAIN_WINDOW_PAD, REPO_ROOT, chainStepDef, configuredProjectsRoot, chainTask, chainWindows, originFromSweep } from "./chain.mjs"; -import { deckChrome, deckStepDetail, draftFileOf, draftOutcome, draftPrecheck } from "./chain-draft.mjs"; -import { addDeckChrome } from "./manifest.mjs"; +import { deckChrome, deckRefusedDetail, deckStepDetail, draftFileOf, draftOutcome, draftPrecheck } from "./chain-draft.mjs"; +import { ChromeRefused, addDeckChrome } from "./manifest.mjs"; import { socialTexts } from "umtool-report-to-video/social"; import { PIPELINE_DIR } from "./driver.mjs"; import { dedupeMedia, seedFromParent } from "./iterations.mjs"; @@ -376,7 +376,16 @@ async function youtubeText(ctx) { STEPS.deck = async (ctx) => { const file = path.join(ctx.project, "video.manifest.json"); if (!(await exists(file))) throw new StepFailed(`no video manifest at ${file}: run the chain's manifest step first`); - const r = await addDeckChrome(ctx.project, deckChrome()); + let r; + try { + r = await addDeckChrome(ctx.project, deckChrome()); + } catch (err) { + // The deck's defaults need a frame tall enough for the footage beside it: + // a sub-HD cut refuses it, and the step says so (the flips and threads are + // then skipped for want of a deck). + if (err instanceof ChromeRefused) throw new StepFailed(deckRefusedDetail(err.errors, JSON.parse(await readFile(file, "utf8")).render)); + throw err; + } return deckStepDetail(r.added); }; @@ -397,7 +406,11 @@ async function writeSocialFiles(ctx) { await mkdir(out, { recursive: true }); const written = []; for (const { name, text } of socialTexts(manifest)) { - if (text === null) continue; + // A platform with no post loses its old file, as the build's writer does. + if (text === null) { + await rm(path.join(out, name), { force: true }); + continue; + } await writeFile(path.join(out, name), text, "utf8"); written.push(`out/${name}`); } diff --git a/umtool/lib/report/drafted-writer.test.mjs b/umtool/lib/report/drafted-writer.test.mjs @@ -16,6 +16,7 @@ import { fileURLToPath } from "node:url"; import { MANIFEST_NAME, StructureRefused, moveEntry, updateChrome, updateNarration, updateOnscreen, updateTeaser, writeDraftedField, } from "./manifest.mjs"; +import { lintManifest } from "umtool-report-to-video/lint"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const full = () => JSON.parse(readFileSync(path.join(HERE, "../../../common/testing/draft/manifests/full.video.manifest.json"), "utf8")); @@ -143,3 +144,18 @@ test("writeDraftedField: Use this on a social post (release 29 G2) writes it as (e) => e instanceof StructureRefused && /publish\.bluesky\.post is 301 graphemes \(at most 300\)/.test(e.message), ); }); + +test("a social post past its count is a lint warning, never a refusal of the cut's edits (release 29 review)", async (t) => { + const m = drafted(); + m.publish.x = { post: "x".repeat(300) }; + m.publish.videoUrl = "not a url"; + const p = await project(t, m); + // A structural edit of the cut goes through. + await moveEntry(p.dir, "c03", 3); + const after = await p.read(); + assert.equal(after.publish.x.post.length, 300); + const lint = lintManifest(after, { validators: true }); + assert.ok(lint.warnings.some((w) => /publish\.x\.post is 300 characters as X counts them/.test(w)), lint.warnings.join("\n")); + assert.ok(lint.warnings.some((w) => /publish\.videoUrl must be the video's http\(s\) URL/.test(w))); + assert.ok(!lint.errors.some((e) => /publish\./.test(e)), lint.errors.join("\n")); +}); diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -39,7 +39,7 @@ import { parseMuteFrom } from "./playback.mjs"; import { DELIVERABLES_MODES } from "./storage.mjs"; import { createSnapshot, listSnapshots } from "./snapshots.mjs"; import { - DRAFTED_MANIFEST_FIELDS, clearEditedDrafts, isEntryField, pruneDrafted, validateDrafted, validatePublish, + DRAFTED_MANIFEST_FIELDS, clearEditedDrafts, isEntryField, publishWarnings, pruneDrafted, validateDrafted, validatePublish, } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; // Its own write queue, not lib/state.ts's. @@ -1144,8 +1144,8 @@ export async function updateNarration(dir, id, text, { token = null, at = null } * — and the entries are checked as the build checks * them (validateThreadEntries) * publish.youtube `{ title, description }` (validatePublish) - * publish.x, .bluesky `{ post, thread? }` (validatePublish: each post - * within its platform's count) + * publish.x, .bluesky `{ post, thread? }` (publishWarnings, refused + * here: each post within its platform's count) * * The cut's order ("timeline") is not taken this way: an order replaces every * entry, and is the cut task's to apply. @@ -1181,7 +1181,8 @@ export async function writeDraftedField(dir, { entry = null, field, value }, { t if (field === "publish.youtube" || field === "publish.x" || field === "publish.bluesky") { const key = field.slice("publish.".length); m.publish = { ...(m.publish && typeof m.publish === "object" ? m.publish : {}), [key]: copy() }; - const errors = validatePublish(m); + // The field's own writer refuses what its count refuses (the build only warns). + const errors = [...validatePublish(m), ...(key === "youtube" ? [] : publishWarnings(m, { only: key }))]; if (errors.length) throw new StructureRefused(errors); return { entry: null, field, value: m.publish[key] }; } diff --git a/umtool/report-to-video/lint.mjs b/umtool/report-to-video/lint.mjs @@ -86,7 +86,7 @@ import { qrUrlFor } from "./render-cards.mjs"; import { cardNarrationSeconds, hasNarration, narrationsOf, validateNarration } from "./narration.mjs"; import { validatePodcast } from "./build-podcast.mjs"; import { draftsReviewFromNarration, draftsReviewProblems, readDraftsReview } from "./drafts-review.mjs"; -import { orphanDrafts, validateDrafted, validatePublish } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; +import { orphanDrafts, publishWarnings, validateDrafted, validatePublish } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; export const TEASER_HOUSE_CHARS = 34; export const MIN_QR_PX_PER_MODULE_720P = 1.5; @@ -283,6 +283,9 @@ export function lintManifest(manifest, { const warnings = []; const render = manifest.render ?? {}; const height = Number(render.height) || 1080; + // The social posts and the video's URL are not the video's: a problem there + // is said, never a refusal (release 29 G2's review). + warnings.push(...publishWarnings(whole)); for (const { where, src } of imageSrcsOf(manifest, { only })) { if (path.isAbsolute(src) || src.startsWith("~")) {