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: 3 additions & 5 deletions pm-stack/aggregator/src/aa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
AaTestRun,
AaThreshold,
} from "./model.ts";
import { isIsoDate } from "./validate.ts";

// --- scalar coercion ---------------------------------------------------------
// The Supabase Management API serializes numeric columns as JSON
Expand Down Expand Up @@ -1097,13 +1098,10 @@ export function isAaSection(v: unknown): v is AaFeedSection {
if (typeof v !== "object" || v === null) return false;
const s = v as Partial<AaSection> & Partial<AaAbsentSection>;
if (s.status === "absent")
return (
typeof s.reason === "string" && typeof s.generatedAt === "string" && Number.isFinite(Date.parse(s.generatedAt))
);
return typeof s.reason === "string" && isIsoDate(s.generatedAt);
if (s.status !== "ok") return false;
return (
typeof s.generatedAt === "string" &&
Number.isFinite(Date.parse(s.generatedAt)) &&
isIsoDate(s.generatedAt) &&
typeof s.batch === "string" &&
Array.isArray(s.rankings) &&
s.rankings.length > 0 &&
Expand Down
4 changes: 2 additions & 2 deletions pm-stack/aggregator/src/dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// not the competitor.
import { addDaysYmd, chicagoYmd } from "./derive.ts";
import type { DnsEntry, DnsSection } from "./model.ts";
import { isIsoDate } from "./validate.ts";

/** Classification from the register's "Plan / status" cell. */
export function classifyDnsStatus(plan: string): DnsEntry["status"] {
Expand Down Expand Up @@ -75,8 +76,7 @@ export function isDnsSection(v: unknown): v is DnsSection {
if (typeof v !== "object" || v === null) return false;
const s = v as Partial<DnsSection>;
return (
typeof s.generatedAt === "string" &&
Number.isFinite(Date.parse(s.generatedAt)) &&
isIsoDate(s.generatedAt) &&
// totalAnnualListUsd is dereferenced with .toFixed on the /dns and
// usage render paths, so the gate must guarantee a finite number
// (#2412) — a missing/string/null/NaN total certifies a section the
Expand Down
8 changes: 8 additions & 0 deletions pm-stack/aggregator/test/aa-gate-2415.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,12 @@ describe("isAaSection gate depth (#2415)", () => {
undefDate.testRuns = [{ testRunKey: "run-1" }];
expect(isAaSection(undefDate)).toBe(false);
});

test("rejects impossible generatedAt dates Date.parse rolls over (#3441)", () => {
for (const generatedAt of ["2026-02-30T00:00:00Z", "2026-02-29T00:00:00Z", "2026-04-31T00:00:00Z"]) {
const s = completeSection();
s.generatedAt = generatedAt;
expect(isAaSection(s)).toBe(false);
}
});
});
7 changes: 7 additions & 0 deletions pm-stack/aggregator/test/aa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ describe("payload assembly + section shape", () => {
expect(isAaSection({ generatedAt: "x", batch: "y", rankings: [] })).toBe(false);
});

test("isAaSection rejects the absent form with impossible generatedAt dates (#3441)", () => {
expect(isAaSection(aaAbsent("Supabase unreachable", "2026-10-26T18:05:00Z"))).toBe(true);
for (const generatedAt of ["2026-02-30T00:00:00Z", "2026-02-29T00:00:00Z", "2026-04-31T00:00:00Z"]) {
expect(isAaSection(aaAbsent("Supabase unreachable", generatedAt))).toBe(false);
}
});

test("summarizeAa: usable-up-to + snapshot vintage", () => {
const summary = summarizeAa(FIXTURE_AA);
const lunaKey = FIXTURE_AA.testRuns[0].testRunKey;
Expand Down
9 changes: 9 additions & 0 deletions pm-stack/aggregator/test/slice3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ describe("dns register parser", () => {
expect(isDnsSection(withStatus("unused"))).toBe(true);
});

test("isDnsSection rejects impossible generatedAt dates Date.parse rolls over (#3441)", () => {
const good = dnsSectionFromRegister(REGISTER_MD, "2026-10-25T00:00:00Z", "test");
expect(good).not.toBeNull();
expect(isDnsSection(good)).toBe(true);
for (const generatedAt of ["2026-02-30T00:00:00Z", "2026-02-29T00:00:00Z", "2026-04-31T00:00:00Z"]) {
expect(isDnsSection({ ...good, generatedAt })).toBe(false);
}
});

});

// --- Identity registry (#906 §3) ---------------------------------------------
Expand Down