From 1772de77ad4cd2f1cad782d38a05e75c770ab4c6 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Thu, 12 Nov 2026 14:11:20 -0600 Subject: [PATCH] fix(pm-stack): gate pool-item updatedAt on a real ISO date (#5202) --- pm-stack/aggregator/src/projects.ts | 9 +++++++-- pm-stack/aggregator/test/projects.test.ts | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pm-stack/aggregator/src/projects.ts b/pm-stack/aggregator/src/projects.ts index 2aa51bd1b..b5aef8a9c 100644 --- a/pm-stack/aggregator/src/projects.ts +++ b/pm-stack/aggregator/src/projects.ts @@ -11,7 +11,7 @@ // the live source so the wire shape is parsed exactly once. import type { GhItem, OrchestrationSection, ProjectAudit, ProjectPoolItem, RefKey } from "./model.ts"; import { isValidRef, refKey } from "./model.ts"; -import { isRecord, isTimestampNotFuture } from "./validate.ts"; +import { isIsoDate, isRecord, isTimestampNotFuture } from "./validate.ts"; import { workItemRefSet } from "./work-items.ts"; export const PROJECT_ID = "PVT_kwDOAZNvF84Bouay"; @@ -468,7 +468,12 @@ export function isProjectPoolItem(v: unknown): v is ProjectPoolItem { (p.draft === undefined || typeof p.draft === "boolean") && (p.labels === undefined || (Array.isArray(p.labels) && p.labels.every((x) => typeof x === "string"))) && (p.author === undefined || typeof p.author === "string") && - (p.updatedAt === undefined || typeof p.updatedAt === "string") && + // updatedAt feeds Date.parse momentum/recency math downstream, so + // a present non-empty stamp must be a real ISO date: an impossible + // day (2026-02-30) would otherwise roll forward into fabricated + // recent activity (#5202). The collector spellings for a missing + // stamp - absent, or "" from updatedAt ?? "" - still pass. + (p.updatedAt === undefined || p.updatedAt === "" || isIsoDate(p.updatedAt)) && (p.closedAt === undefined || typeof p.closedAt === "string") && (p.mergedAt === undefined || typeof p.mergedAt === "string") && (p.state === "open" || p.state === "closed" || p.state === "merged") && diff --git a/pm-stack/aggregator/test/projects.test.ts b/pm-stack/aggregator/test/projects.test.ts index 989b6e8ba..a5c16d29c 100644 --- a/pm-stack/aggregator/test/projects.test.ts +++ b/pm-stack/aggregator/test/projects.test.ts @@ -165,6 +165,27 @@ const PROV = { aa: "x", }; +describe("isProjectPoolItem updatedAt gate (#5202)", () => { + const validItem = () => parseProjectItems(GQL)[0]; + + test("a valid ISO updatedAt passes", () => { + expect(isProjectPoolItem({ ...validItem(), updatedAt: "2026-02-25T00:00:00Z" })).toBe(true); + }); + + test("impossible and non-ISO updatedAt stamps are refused", () => { + for (const updatedAt of ["2026-02-30T00:00:00Z", "2026-04-31T00:00:00Z", "March 2, 2026", "not-a-date"]) { + expect(isProjectPoolItem({ ...validItem(), updatedAt })).toBe(false); + } + }); + + test("the collector missing-stamp spellings still pass: empty string and absent", () => { + expect(isProjectPoolItem({ ...validItem(), updatedAt: "" })).toBe(true); + const absent = { ...validItem() }; + delete absent.updatedAt; + expect(isProjectPoolItem(absent)).toBe(true); + }); +}); + describe("collector projects parsing (GraphQL -> feed section)", () => { test("parses items with fields, ref, and both URLs; skips unlinked drafts", () => { const pool = parseProjectItems(GQL);