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(news): clamp bogus future publisher dates; resolve future-month story URLs
fudjia4a9e27f8e524
diff --git a/api/_lib/news-story.js b/api/_lib/news-story.jsindex 12c5c08e2..0850afd19 100644--- a/api/_lib/news-story.js+++ b/api/_lib/news-story.js@@ -15,11 +15,18 @@ export function validStoryKey(month, id) {}function recentMonths() {+ // Previous, current AND next month: publishers have shipped future-dated+ // stories (the aggregator now clamps those, but already-minted links carry+ // the bogus month), so a next-month URL must still reach the live lookup.const now = new Date();const cur = now.toISOString().slice(0, 7);- now.setUTCDate(1);- now.setUTCMonth(now.getUTCMonth() - 1);- return [cur, now.toISOString().slice(0, 7)];+ const shift = (n) => {+ const d = new Date(now);+ d.setUTCDate(1);+ d.setUTCMonth(d.getUTCMonth() + n);+ return d.toISOString().slice(0, 7);+ };+ return [cur, shift(-1), shift(1)];}function adjacentMonths(month) {diff --git a/api/_lib/news.js b/api/_lib/news.jsindex 7ab501022..e86a17367 100644--- a/api/_lib/news.js+++ b/api/_lib/news.js@@ -67,6 +67,19 @@ export function articleId(link) {return createHash('sha256').update(String(link)).digest('hex').slice(0, 16);}+// A publisher-stamped date meaningfully in the future is bogus (CoinPaper has+// shipped stories dated seven weeks ahead) and poisons everything keyed on the+// publication month: the permalink month the browser mints, the archive month+// file the cron writes, and the story-page lookup — a future-dated article got+// a permalink that 404'd while the story was live on the feed. Clamp to fetch+// time; honest timezone skew stays inside the 24h allowance.+export function clampFuturePubDate(iso) {+ if (!iso) return iso;+ const t = Date.parse(iso);+ if (!Number.isFinite(t) || t <= Date.now() + 24 * 3_600_000) return iso;+ return new Date().toISOString();+}+// WordPress and its plugins append syndication boilerplate to every excerpt:// "The post <title> appeared first on <site>.", "Continue reading…",// "Read more on …", trailing "[…]". None of it is article text — strip it@@ -257,7 +270,9 @@ export function parseFeed(xml, sourceKey) {.map(cleanImageUrl).find(Boolean) || null;const pubDate = str(it?.pubDate) || str(it?.published) || str(it?.updated) || str(it?.['dc:date']);- const iso = pubDate && !Number.isNaN(Date.parse(pubDate)) ? new Date(pubDate).toISOString() : null;+ const iso = clampFuturePubDate(+ pubDate && !Number.isNaN(Date.parse(pubDate)) ? new Date(pubDate).toISOString() : null,+ );const author =stripHtml(str(it?.['dc:creator']) || str(it?.author?.name) || str(it?.author) || '') || null;// Some feeds (e.g. Bitcoin Magazine) prefix descriptions with their own@@ -317,7 +332,7 @@ const JSON_ADAPTERS = {const title = stripHtml(a?.title);if (!title || !a?.code) return null;const link = `https://www.binance.com/en/support/announcement/detail/${a.code}`;- const iso = Number.isFinite(a.releaseDate) ? new Date(a.releaseDate).toISOString() : null;+ const iso = clampFuturePubDate(Number.isFinite(a.releaseDate) ? new Date(a.releaseDate).toISOString() : null);return {id: articleId(link),title,diff --git a/tests/news-lib.test.js b/tests/news-lib.test.jsindex 8f5719d4b..0dd6c013b 100644--- a/tests/news-lib.test.js+++ b/tests/news-lib.test.js@@ -8,6 +8,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';const {parseFeed, lexiconSentiment, extractTickers, articleId, stripHtml, getNews, findArticle,stripFeedBoilerplate, truncateWords, cleanImageUrl, metaContent, extractOgImage,+ clampFuturePubDate,} = await import('../api/_lib/news.js');const { isFeaturedSource, NEWS_SOURCES } = await import('../api/_lib/news-sources.js');@@ -81,6 +82,34 @@ describe('parseFeed', () => {});});+describe('clampFuturePubDate', () => {+ it('leaves past and near-future dates alone', () => {+ expect(clampFuturePubDate('2026-07-09T14:00:00.000Z')).toBe('2026-07-09T14:00:00.000Z');+ const soon = new Date(Date.now() + 3_600_000).toISOString();+ expect(clampFuturePubDate(soon)).toBe(soon);+ expect(clampFuturePubDate(null)).toBe(null);+ expect(clampFuturePubDate('not a date')).toBe('not a date');+ });++ it('clamps a bogus far-future publisher date to now', () => {+ // Real incident: CoinPaper stamped a live story 2026-08-31 in July,+ // minting a permalink month no lookup could ever satisfy.+ const bogus = new Date(Date.now() + 50 * 24 * 3_600_000).toISOString();+ const clamped = clampFuturePubDate(bogus);+ expect(clamped).not.toBe(bogus);+ expect(Date.parse(clamped)).toBeLessThanOrEqual(Date.now() + 1000);+ });++ it('is applied to feed items at parse time', () => {+ const future = RSS_FIXTURE.replace(+ 'Thu, 09 Jul 2026 14:00:00 GMT',+ new Date(Date.now() + 50 * 24 * 3_600_000).toUTCString(),+ );+ const [a] = parseFeed(future, 'coindesk');+ expect(Date.parse(a.pub_date)).toBeLessThanOrEqual(Date.now() + 1000);+ });+});+describe('enrichment', () => {it('detects tickers from $SYMBOL and known names', () => {expect(extractTickers('Bitcoin and $PEPE rally while Solana dips')).toEqual(diff --git a/tests/news-story-page.test.js b/tests/news-story-page.test.jsindex 85928fb8e..155cc6f72 100644--- a/tests/news-story-page.test.js+++ b/tests/news-story-page.test.js@@ -107,6 +107,20 @@ describe('GET /api/news/story-page', () => {expect(res.headers.location).toMatch(new RegExp(`^/markets/news/${prev}/${ARTICLE.id}`));});+ it('a future-month URL (publisher-stamped bogus date) still finds the live story and 301s', async () => {+ const nowMonth = new Date().toISOString().slice(0, 7);+ const next = (() => {+ const d = new Date(`${nowMonth}-01T00:00:00Z`);+ d.setUTCMonth(d.getUTCMonth() + 1);+ return d.toISOString().slice(0, 7);+ })();+ const liveArticle = { ...ARTICLE, pub_date: `${nowMonth}-08T09:00:00.000Z` };+ findArticle.mockResolvedValue(liveArticle);+ const res = await call(`/api/news/story-page?month=${next}&id=${ARTICLE.id}`);+ expect(res.statusCode).toBe(301);+ expect(res.headers.location).toMatch(new RegExp(`^/markets/news/${nowMonth}/${ARTICLE.id}`));+ });+it('404 turns the URL slug into a prefilled archive search', async () => {const res = await call('/api/news/story-page?month=2025-02&id=deadbeefdeadbeef&slug=regulated-crypto-exchanges-gain-ground',