Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(x-content): hold an X Article's body to the claims ledger, the voice lint and the link checks
nirholas90a00f6dbddb
diff --git a/api/_lib/x-content/editorial.js b/api/_lib/x-content/editorial.jsindex 10237a5c3..c4d801486 100644--- a/api/_lib/x-content/editorial.js+++ b/api/_lib/x-content/editorial.js@@ -80,7 +80,7 @@ export const PUSHY_CTAS = [];// Words that assert something absolute. Each needs a declared claim.-export const ABSOLUTES = /\b(?:first|only|fastest|largest|biggest|best|leading|never|always|every|no one|nobody|zero|unlimited|instant(?:ly)?|world'?s|#1|number one)\b/gi;+export const ABSOLUTES = /\b(?:first|only|fastest|largest|biggest|best|leading|never|always|every|no one|nobody|zero|unlimited|instant(?:ly)?|world['\u2019]s|#1|number one)\b/gi;function termHits(text, terms) {return terms.map((term) => text.match(term)?.[0]).filter(Boolean);@@ -136,10 +136,12 @@ export function assertionsIn(text) {// The claims ledger. Every number and absolute in the copy must sit inside a// claim's `says`, every claim must appear in the copy and carry evidence, and-// every @mention must record why the tag is true.-export function claimProblems(item) {+// every @mention must record why the tag is true. For an Article the copy+// includes its body (`articleText`, the prose from articleProse()), so a+// number in the fourth section is held to evidence like one in the title.+export function claimProblems(item, { articleText = '' } = {}) {const problems = [];- const texts = [...(item.posts || []).map((post) => post.text), item.kind === 'article' ? item.article?.title : null].filter(Boolean);+ const texts = [...(item.posts || []).map((post) => post.text), item.kind === 'article' ? item.article?.title : null, item.kind === 'article' ? articleText : null].filter(Boolean);const corpus = texts.join('\n').toLowerCase();const claims = item.claims || [];diff --git a/api/_lib/x-content/queue.js b/api/_lib/x-content/queue.jsindex 6832b5c0f..56a0337b7 100644--- a/api/_lib/x-content/queue.js+++ b/api/_lib/x-content/queue.js@@ -52,6 +52,24 @@ export function loadArticle(root, article) {return markdownToContentState(markdown, { articlePath: article.body });}+// The words an Article says, as a reader sees them: headings, paragraphs, list+// items and quotes. Code blocks and tables are left out because they are+// literal samples, not statements. Every number and absolute in it is held to+// the claims ledger and the language rules, the same as a post.+export function articleProse(root, item) {+ if (item?.kind !== 'article' || !item.article?.body) return '';+ if (!existsSync(resolve(root, item.article.body))) return '';+ const { blocks } = loadArticle(root, item.article).content_state;+ return blocks.filter((block) => block.type !== 'atomic').map((block) => block.text).filter(Boolean).join('\n');+}++// Every link an Article body makes, so each is resolved like a link in a post.+export function articleLinks(root, item) {+ if (item?.kind !== 'article' || !item.article?.body) return [];+ if (!existsSync(resolve(root, item.article.body))) return [];+ return loadArticle(root, item.article).content_state.entities.filter((entity) => entity.value.type === 'link').map((entity) => entity.value.data.url).filter((url) => /^https?:/i.test(url));+}+// A post may name the announcement-pack file its copy was reviewed in// (docs/announcements/<slug>.post.txt). In a checkout the inline text must match// that file byte for byte, so a pack edit cannot drift from what ships. The@@ -176,11 +194,15 @@ export function validateItem(item, root, { quality = qualityAt(root), now = Date}// Editorial standards that can be judged offline block at every stage.+ const articleText = articleProse(root, item);const texts = [item.kind === 'article' ? item.article?.title : null, ...(item.posts || []).map((post) => post.text)].filter(Boolean);for (const text of texts) {for (const finding of languageProblems(text)) if (finding.severity === 'blocking') problems.push(`${finding.rule}: ${finding.message}`);}- for (const finding of claimProblems(item)) if (finding.severity === 'blocking') problems.push(`${finding.rule}: ${finding.message}`);+ if (articleText) {+ for (const finding of languageProblems(articleText)) if (finding.severity === 'blocking') problems.push(`article body ${finding.rule}: ${finding.message}`);+ }+ for (const finding of claimProblems(item, { articleText })) if (finding.severity === 'blocking') problems.push(`${finding.rule}: ${finding.message}`);// A scenario is the item's claim that the feature works. It has to be// runnable as written, it has to be the item's probe, and the reel on thediff --git a/api/_lib/x-content/review.js b/api/_lib/x-content/review.jsindex d372114fb..1e7837830 100644--- a/api/_lib/x-content/review.js+++ b/api/_lib/x-content/review.js@@ -17,6 +17,7 @@ import { copyProblems, maxLengthOf } from './quality.js';import { buildReviewRequest, reviewWithEditor } from './editor.js';import { itemTexts, verifyItem } from './verify.js';import { bestPosts, outcomesStore } from './outcomes.js';+import { articleProse, loadArticle } from './queue.js';export const REVIEW_MAX_AGE_DAYS = 14;export const reviewPath = (id) => `data/x-content/reviews/${id}.json`;@@ -26,13 +27,20 @@ const fileHash = (root, path) => {return path && existsSync(absolute) ? createHash('sha256').update(readFileSync(absolute)).digest('hex') : null;};+// An Article's inline images, so replacing one makes its review stale even+// though the Markdown that names it did not change.+function articleImages(root, item) {+ if (!item.article?.body || !existsSync(resolve(root, item.article.body))) return [];+ return loadArticle(root, item.article).images.map((image) => ({ path: image.path, alt: image.caption || null }));+}+export function contentHash(item, root) {const media = (row) => ({ path: row.path, sha256: fileHash(root, row.path), alt: row.alt || null, probe: row.probe || null });const subject = {kind: item.kind,posts: (item.posts || []).map((post) => ({ text: String(post.text || '').trim(), media: (post.media || []).map(media) })),article: item.kind === 'article'- ? { title: item.article?.title, body: fileHash(root, item.article?.body), cover: item.article?.cover ? media(item.article.cover) : null }+ ? { title: item.article?.title, body: fileHash(root, item.article?.body), cover: item.article?.cover ? media(item.article.cover) : null, images: articleImages(root, item).map(media) }: null,claims: item.claims || [],mentions: item.mentions || {},@@ -50,7 +58,7 @@ export function loadReview(root, id) {}// Offline lint for every post in an item, as structured findings.-export function lintItem(item, { maximum } = {}) {+export function lintItem(item, { maximum, articleText = '' } = {}) {const findings = [];(item.posts || []).forEach((post, index) => {const where = index === 0 ? 'head' : `reply ${index}`;@@ -60,7 +68,10 @@ export function lintItem(item, { maximum } = {}) {if (item.kind === 'article' && item.article?.title) {for (const problem of languageProblems(item.article.title)) findings.push({ where: 'article title', ...problem });}- for (const problem of claimProblems(item)) findings.push({ where: 'claims', ...problem });+ if (item.kind === 'article' && articleText) {+ for (const problem of languageProblems(articleText)) findings.push({ where: 'article body', ...problem });+ }+ for (const problem of claimProblems(item, { articleText })) findings.push({ where: 'claims', ...problem });return findings;}@@ -96,7 +107,7 @@ export function editorFailure(message) {export async function reviewItem(item, { root, glossary = [], quality = {}, env = process.env, skipEditor = false }) {const maximum = maxLengthOf(quality);- const lint = lintItem(item, { maximum });+ const lint = lintItem(item, { maximum, articleText: articleProse(root, item) });for (const [index, post] of (item.posts || []).entries()) {for (const problem of await mediaQualityProblems(post, root)) lint.push({ where: index === 0 ? 'head' : `reply ${index}`, ...problem });}diff --git a/api/_lib/x-content/verify.js b/api/_lib/x-content/verify.jsindex 909c21569..946354643 100644--- a/api/_lib/x-content/verify.js+++ b/api/_lib/x-content/verify.js@@ -401,7 +401,11 @@ export async function probeChecks(item, { root, where = 'review' }) {}export async function verifyItem(item, { root, glossary = [], env = process.env }) {- const texts = itemTexts(item);+ // An Article's body is copy too: its words are spell-checked and its links+ // resolved, the same as a post's.+ const { articleLinks, articleProse } = await import('./queue.js');+ const body = articleProse(root, item);+ const texts = [...itemTexts(item), ...(body ? [body] : []), ...articleLinks(root, item)];const pages = createPageReader();const checks = [];try {diff --git a/docs/x-content-pipeline.md b/docs/x-content-pipeline.mdindex e5e779176..37dc42bc5 100644--- a/docs/x-content-pipeline.md+++ b/docs/x-content-pipeline.md@@ -123,7 +123,7 @@ X Articles require the posting account to be on X Premium.- `claims` is the fact ledger. Every number, ordinal, and absolute word (first, only, every, never, fastest) in the copy must sit inside some claim's `says`, every `says` must quote the copy, and every claim carries at least one piece of `evidence` (types below).- `mentions` maps each @handle in the copy to the reason the tag is true. A tag with no reason is blocked.- `textFrom` is optional. When set, `check` fails if the inline text differs from that announcement-pack file, so the copy that was reviewed is the copy that ships.-- An `article` item carries `"article": { "title", "body", "cover": { "path" } }`, and its optional `posts` quote the published Article.+- An `article` item carries `"article": { "title", "body", "cover": { "path" } }`, and its optional `posts` quote the published Article. The body is copy like any post: its prose (headings, paragraphs, lists and quotes; code blocks and tables are literal samples and exempt) goes through the same language lint and claims ledger, so a number in the fourth section needs evidence like one in the title, its links are resolved at review, and its words are spell-checked. Replacing an inline image makes the review stale, the same as editing the Markdown.Cadence lives at the top of the file: `slots` (each `{ tier, at }` in UTC), `windowMinutes` (how far a slot's opening may be jittered), `minimumMinutesApart`, `dailyCap`, and `quietHoursUtc` (a `["HH:MM", "HH:MM"]` pair, which may wrap midnight). `quality` sets the similarity limits, the maximum same-lane and same-pattern runs, and `maximumLength`: the longest a post may be, in weighted characters. @trythreews is on X Premium, so the queue sets it above the standard 280; a value under 280 is ignored. `approval` is the policy described below.diff --git a/tests/x-content.test.js b/tests/x-content.test.jsindex 6764db4da..2a42879e2 100644--- a/tests/x-content.test.js+++ b/tests/x-content.test.js@@ -630,6 +630,41 @@ describe('editorial', () => {.toMatch(/does not appear in the copy[\s\S]*has no evidence/);});+ it('holds every number and absolute in an Article body to the claims ledger', async () => {+ const { claimProblems } = await import('../api/_lib/x-content/editorial.js');+ const item = { kind: 'article', article: { title: 'How the gate works' }, posts: [{ text: 'The write-up: three.ws/a' }] };+ const articleText = 'The raster is 640 pixels wide.\nIt is the only cutter we ship.';+ const messages = claimProblems(item, { articleText }).map((row) => row.message).join('\n');+ expect(messages).toMatch(/"640" is an unverified number/);+ expect(messages).toMatch(/"only" is an absolute/);+ const declared = {+ ...item,+ claims: [+ { says: 'The raster is 640 pixels wide', evidence: [{ type: 'file', path: 'x', contains: 'y' }] },+ { says: 'the only cutter we ship', evidence: [{ type: 'file', path: 'x', contains: 'y' }] },+ ],+ };+ expect(claimProblems(declared, { articleText })).toEqual([]);+ // Without the body a claim quoting it has nothing to appear in.+ expect(claimProblems(declared).map((row) => row.message).join('\n')).toMatch(/does not appear in the copy/);+ });++ it('reads an Article body as prose, leaving code blocks out', async () => {+ const { articleProse } = await import('../api/_lib/x-content/queue.js');+ const dir = sandbox();+ mkdirSync(join(dir, 'data/x-content/articles'), { recursive: true });+ writeFileSync(join(dir, 'data/x-content/articles/a.md'), 'Opening line with 3 facts.\n\n## A heading\n\n- a list item\n\n```\nPOST /api 402\n```\n');+ const prose = articleProse(dir, { kind: 'article', article: { body: 'data/x-content/articles/a.md' } });+ expect(prose).toBe('Opening line with 3 facts.\nA heading\na list item');+ expect(articleProse(dir, { kind: 'post' })).toBe('');+ });++ it('reads "world\'s" as an absolute and "worlds" as a plain word', async () => {+ const { ABSOLUTES } = await import('../api/_lib/x-content/editorial.js');+ expect('private invite-only worlds'.match(ABSOLUTES)).toEqual(['only']);+ expect("the world's first".match(ABSOLUTES)).toEqual(["world's", 'first']);+ });+it('flags soft, badly cropped, undescribed, and stale media', async () => {const { mediaQualityProblems } = await import('../api/_lib/x-content/editorial.js');const { default: sharp } = await import('sharp');