Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pm-stack/aggregator/src/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -468,7 +468,11 @@ 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 derive.ts momentum/recency math, which Date.parse's
// it: a bare string check lets impossible dates roll into fabricated
// activity (#5202). A present non-empty stamp must be a real ISO date;
// '' is the collector's missing-stamp form and counts as absent.
(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") &&
Expand Down
19 changes: 19 additions & 0 deletions pm-stack/aggregator/test/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,25 @@ describe("collector projects parsing (GraphQL -> feed section)", () => {
expect(isProjectPoolItem(pool[0])).toBe(true);
});

test("the pool gate refuses impossible updatedAt stamps (#5202)", () => {
const item = parseProjectItems(GQL)[0];
// Control: the collector's own stamp passes, and the missing-stamp
// forms (absent field, '') stay valid.
expect(isProjectPoolItem(item)).toBe(true);
expect(isProjectPoolItem({ ...item, updatedAt: "" })).toBe(true);
const { updatedAt: _dropped, ...withoutStamp } = item;
expect(isProjectPoolItem(withoutStamp)).toBe(true);
// Impossible calendar days and non-ISO strings are refused: before
// the gate they rolled over in Date.parse and fabricated this-week
// activity in derive.ts momentum math.
for (const bad of ["2026-02-29", "2026-02-30", "2026-04-31", "March 2, 2026", "not-a-date"]) {
expect(isProjectPoolItem({ ...item, updatedAt: bad })).toBe(false);
}
// A real leap day and a full ISO datetime still pass.
expect(isProjectPoolItem({ ...item, updatedAt: "2024-02-29" })).toBe(true);
expect(isProjectPoolItem({ ...item, updatedAt: "2026-03-01T12:00:00Z" })).toBe(true);
});

test("derived state + disagreement", () => {
const pool = parseProjectItems(GQL);
// Open, no orchestration presence -> Todo, which disagrees with In Progress.
Expand Down
Loading