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): requested-month archive record beats a month-drifted live record
fudjiabae0c9e39837
diff --git a/api/_lib/news-story.js b/api/_lib/news-story.jsindex 0850afd19..7e0521629 100644--- a/api/_lib/news-story.js+++ b/api/_lib/news-story.js@@ -52,13 +52,27 @@ function adjacentMonths(month) {export async function resolveStory(month, id) {if (!validStoryKey(month, id)) return null;+ const inMonthArchive = async () => {+ const records = await loadMonth(month).catch(() => null);+ return records?.find((a) => a.id === id) || null;+ };+if (recentMonths().includes(month)) {const live = await findArticle({ id }).catch(() => null);- if (live) return { article: live, origin: 'live' };+ if (live) {+ if ((live.pub_date || '').slice(0, 7) === month) return { article: live, origin: 'live' };+ // The live record disagrees with the requested month. If the archive+ // has the story filed under the REQUESTED month, that durable record+ // wins — redirecting toward a live-feed month here while the archive+ // redirects back would loop the two URLs forever (seen in prod when a+ // publisher's bogus future date met a hand-corrected archive record).+ const archived = await inMonthArchive();+ if (archived) return { article: archived, origin: 'archive' };+ return { article: live, origin: 'live' };+ }}- const records = await loadMonth(month).catch(() => null);- const archived = records?.find((a) => a.id === id) || null;+ const archived = await inMonthArchive();if (archived) return { article: archived, origin: 'archive' };for (const near of adjacentMonths(month)) {diff --git a/api/news/story-page.js b/api/news/story-page.jsindex 5f39850e2..3ac884be0 100644--- a/api/news/story-page.js+++ b/api/news/story-page.js@@ -261,9 +261,12 @@ export default wrap(async (req, res) => {if (canonical && !canonical.startsWith(`/markets/news/${month}/`)) {// The story exists but lives in a different month (boundary drift or a// revised pub_date) — send crawlers and readers to the canonical URL.+ // Kept short-lived at the CDN: the canonical month is derived from a+ // record that can be corrected (live feed refresh, archive backfill),+ // and a cached wrong-direction redirect is worse than a re-resolve.res.statusCode = 301;res.setHeader('location', canonical);- res.setHeader('cache-control', 'public, max-age=300, s-maxage=3600');+ res.setHeader('cache-control', 'public, max-age=300, s-maxage=600');res.end();return;}diff --git a/tests/news-story-page.test.js b/tests/news-story-page.test.jsindex 155cc6f72..8ad5c4200 100644--- a/tests/news-story-page.test.js+++ b/tests/news-story-page.test.js@@ -107,6 +107,39 @@ describe('GET /api/news/story-page', () => {expect(res.headers.location).toMatch(new RegExp(`^/markets/news/${prev}/${ARTICLE.id}`));});+ it('never loops: requested-month archive record beats a month-drifted live record', async () => {+ // Prod incident: live feed carried the story with a bogus future month+ // while the archive held it under the correct month — /2026-07 301'd to+ // /2026-08 (live) and /2026-08 301'd back to /2026-07 (archive), forever.+ 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);+ })();+ // own id: the handler memoizes rendered pages per month/id+ const id = 'feedfacefeedface';+ const archivedNow = { ...ARTICLE, id, pub_date: `${nowMonth}-08T09:00:00.000Z` };+ const bogusLive = { ...ARTICLE, id, pub_date: `${next}-30T10:00:00.000Z` };+ findArticle.mockResolvedValue(bogusLive);+ loadMonth.mockImplementation(async (m) => (m === nowMonth ? [archivedNow] : []));+ // the URL the archive considers canonical must serve, not bounce away+ const res = await call(`/api/news/story-page?month=${nowMonth}&id=${id}`);+ expect(res.statusCode).toBe(200);+ // and the other month's URL must terminate too — 200 or a redirect to a+ // terminal page, never back toward a URL that redirects here+ const other = await call(`/api/news/story-page?month=${next}&id=${id}`);+ if (other.statusCode === 301) {+ expect(other.headers.location).not.toContain(`/markets/news/${next}/`);+ const followed = await call(+ `/api/news/story-page?month=${other.headers.location.split('/')[3]}&id=${id}`,+ );+ expect(followed.statusCode).toBe(200);+ } else {+ expect(other.statusCode).toBe(200);+ }+ });+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 = (() => {