From 6b4d37ddca3962c05346308872111f1af96169c0 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 06:50:06 -0600 Subject: [PATCH 1/3] feat(aggregator): add DNS register filters and auto-renew counts --- pm-stack/aggregator/src/dns.ts | 13 ++++++ pm-stack/aggregator/src/render.ts | 58 ++++++++++++++++++++----- pm-stack/aggregator/test/slice3.test.ts | 27 +++++++++--- 3 files changed, 81 insertions(+), 17 deletions(-) diff --git a/pm-stack/aggregator/src/dns.ts b/pm-stack/aggregator/src/dns.ts index 9ede55d8a1..63dcd86374 100644 --- a/pm-stack/aggregator/src/dns.ts +++ b/pm-stack/aggregator/src/dns.ts @@ -96,6 +96,8 @@ export interface DnsSummary { unused: DnsEntry[]; /** Entries renewing within `days` of `now` (spend horizon). */ renewingSoon: DnsEntry[]; + /** Counts derived from the register's per-entry auto-renew values. */ + autoRenew: { on: number; off: number; unknown: number }; } export function summarizeDns(section: DnsSection, now = new Date(), soonDays = 45): DnsSummary { @@ -107,11 +109,22 @@ export function summarizeDns(section: DnsSection, now = new Date(), soonDays = 4 // vanished from nextRenewal and renewingSoon (#1684). const today = chicagoYmd(now); const cutoff = addDaysYmd(today, soonDays); + const autoRenew = entries.reduce( + (counts, entry) => { + const value = entry.autoRenew.trim().toLowerCase(); + if (value === "on") counts.on++; + else if (value === "off") counts.off++; + else counts.unknown++; + return counts; + }, + { on: 0, off: 0, unknown: 0 }, + ); return { nextRenewal: entries.find((e) => e.renewal >= today) ?? entries[0] ?? null, active: entries.filter((e) => e.status === "active"), earmarked: entries.filter((e) => e.status === "earmarked"), unused: entries.filter((e) => e.status === "unused"), renewingSoon: entries.filter((e) => e.renewal >= today && e.renewal <= cutoff), + autoRenew, }; } diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index 2ca3b61b21..7153a9edd1 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -3063,16 +3063,39 @@ export function renderOverviewShell(provenance: Provenance, detail?: ProvenanceD // --- DNS register page (#906 §1, data from #902) ----------------------------- -function dnsTable(entries: DnsEntry[]): string { +function dnsTable(entries: DnsEntry[], renewingSoon: Set): string { const rows = entries .map( (e) => - `${esc(e.domain)}${esc(e.renewal)}${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}${esc(e.autoRenew)}${esc(e.plan)}${esc(e.review)}`, + `${esc(e.domain)}${esc(e.renewal)}${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}${esc(e.autoRenew)}${esc(e.plan)}${esc(e.review)}`, ) .join(""); - return `
${rows || ''}
Domain register
DomainNext renewalPrice (list)Auto-renewPlan / statusReview?
none
`; + return `
${rows || ''}
Domain register
DomainNext renewalPrice (list)Auto-renewPlan / statusReview?
none
`; } +const DNS_FILTER_SCRIPT = ``; + export function renderDns(section: DnsSection | null, provenance: Provenance, detail?: ProvenanceDetail): string { const chips = detail ? freshnessChips(detail, ["dns"]) : ""; if (!section) { @@ -3088,23 +3111,36 @@ export function renderDns(section: DnsSection | null, provenance: Provenance, de const s = summarizeDns(section); const next = s.nextRenewal; const soonTotal = Math.round(s.renewingSoon.reduce((sum, e) => sum + (e.priceUsd ?? 0), 0) * 100) / 100; + const renewingSoon = new Set(s.renewingSoon); + const filters = [ + ["all", "All", section.entries.length], + ["active", "Active", s.active.length], + ["earmarked", "Earmarked", s.earmarked.length], + ["unused", "Unused", s.unused.length], + ["renewing-soon", "Renewing soon", s.renewingSoon.length], + ] as const; + const filterChips = filters + .map( + ([filter, label, count], index) => + ``, + ) + .join(""); const body = `

DNS / domain register

${section.entries.length} domains · $${section.totalAnnualListUsd.toFixed(2)}/yr at list renewal prices · register parsed ${fmtDate(section.generatedAt)} (${esc(section.source)}). The register is maintained by the #902 pipeline — this page renders it, never edits it. Machine-first: /api/dns.json.

Next renewal
${ next - ? `${esc(next.domain)} — ${esc(next.renewal)}${next.priceUsd != null ? ` ($${next.priceUsd.toFixed(2)})` : ""}
${esc(next.plan)}` + ? `${esc(next.renewal)}${next.priceUsd != null ? ` · $${next.priceUsd.toFixed(2)}` : ""}
See the first row in the renewal-sorted register.` : "—" }
-
Renewing in 45 days
${s.renewingSoon.length} domain${s.renewingSoon.length === 1 ? "" : "s"} · $${soonTotal.toFixed(2)}
Auto-renew is ON across the account portfolio — this is upcoming spend, not lapse risk.
+
Renewing in 45 days
${s.renewingSoon.length} domain${s.renewingSoon.length === 1 ? "" : "s"} · $${soonTotal.toFixed(2)} at list price
+
Auto-renew
${s.autoRenew.on} ON · ${s.autoRenew.off} OFF · ${s.autoRenew.unknown} unknown
Portfolio shape
${s.active.length} in use · ${s.earmarked.length} unused but earmarked · ${s.unused.length} completely unused
-

Next renewals

${dnsTable(section.entries.slice(0, 10))} -

In use (${s.active.length})

${dnsTable(s.active)} -

Unused but earmarked (${s.earmarked.length})

No public-facing use, but the name or plan ties them to a project family (earmark as recorded in the register).

${dnsTable(s.earmarked)} -

Completely unused (${s.unused.length})

Nothing but registrar defaults — each still auto-renews until someone decides otherwise.

${dnsTable(s.unused)} -
Full register (${section.entries.length})${dnsTable(section.entries)}
`; - return layout("DNS register", body, provenance, "/dns", "", chips); +

Domain register (${section.entries.length})

+
${filterChips}
+${dnsTable(section.entries, renewingSoon)}`; + return layout("DNS register", body, provenance, "/dns", DNS_FILTER_SCRIPT, chips); } // --- AA cost explorer page (ainventory import data via the fleet feed) ----- diff --git a/pm-stack/aggregator/test/slice3.test.ts b/pm-stack/aggregator/test/slice3.test.ts index 8169a233c9..55d788c1f1 100644 --- a/pm-stack/aggregator/test/slice3.test.ts +++ b/pm-stack/aggregator/test/slice3.test.ts @@ -55,6 +55,16 @@ describe("dns register parser", () => { expect(summary.renewingSoon.map((e) => e.domain)).toEqual(["first.de"]); }); + test("auto-renew summary counts ON, OFF, and unknown values from entries", () => { + const entries = [ + { ...FIXTURE_DNS.entries[0], autoRenew: "ON" }, + { ...FIXTURE_DNS.entries[1], autoRenew: "OFF" }, + { ...FIXTURE_DNS.entries[2], autoRenew: "unknown" }, + ]; + const summary = summarizeDns({ ...FIXTURE_DNS, entries }, new Date("2026-12-28T00:00:00Z")); + expect(summary.autoRenew).toEqual({ on: 1, off: 1, unknown: 1 }); + }); + test("summary ages renewals by the Chicago day, not UTC (#1684)", () => { // 2026-10-31T01:30:00Z is 20:30 CDT on 2026-10-30 in Chicago: // the UTC day has already rolled over, the Chicago day has not. @@ -389,14 +399,19 @@ describe("pages manifest + slice-3 renders", () => { expect(html).toContain("DNS register"); }); - test("dns page renders the three views + next renewal", () => { + test("dns page renders each domain once with status filters and data-derived auto-renew counts", () => { const html = renderDns(FIXTURE_DNS, fixtureSource().provenance()); expect(html).toContain("Next renewal"); - expect(html).toContain("1110x.de"); - expect(html).toContain("Unused but earmarked"); - expect(html).toContain("Completely unused"); - expect(html).toContain("grandnag.us"); - expect(html).toContain("security.cab"); + for (const entry of FIXTURE_DNS.entries) { + expect(html.split(entry.domain).length - 1).toBe(1); + } + expect(html).toContain('data-dns-filter="active"'); + expect(html).toContain('data-dns-filter="earmarked"'); + expect(html).toContain('data-dns-filter="unused"'); + expect(html).toContain('data-dns-filter="renewing-soon"'); + expect(html).toContain("Auto-renew
3 ON · 0 OFF · 1 unknown"); + expect(html).not.toContain("Auto-renew is ON across the account portfolio"); + expect(html).not.toContain("
Full register"); }); test("dns page without a section says so honestly", () => { From 4ea7bc364cdc54b8d0f53797419013f6928ffb61 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 06:53:04 -0600 Subject: [PATCH 2/3] fix(aggregator): count malformed auto-renew values as unknown --- pm-stack/aggregator/src/dns.ts | 2 +- pm-stack/aggregator/test/slice3.test.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pm-stack/aggregator/src/dns.ts b/pm-stack/aggregator/src/dns.ts index 1e74365580..1c4e4fd7e2 100644 --- a/pm-stack/aggregator/src/dns.ts +++ b/pm-stack/aggregator/src/dns.ts @@ -127,7 +127,7 @@ export function summarizeDns(section: DnsSection, now = new Date(), soonDays = 4 const cutoff = addDaysYmd(today, soonDays); const autoRenew = entries.reduce( (counts, entry) => { - const value = entry.autoRenew.trim().toLowerCase(); + const value = typeof entry.autoRenew === "string" ? entry.autoRenew.trim().toLowerCase() : ""; if (value === "on") counts.on++; else if (value === "off") counts.off++; else counts.unknown++; diff --git a/pm-stack/aggregator/test/slice3.test.ts b/pm-stack/aggregator/test/slice3.test.ts index afac3899dd..c67cd783a1 100644 --- a/pm-stack/aggregator/test/slice3.test.ts +++ b/pm-stack/aggregator/test/slice3.test.ts @@ -56,13 +56,18 @@ describe("dns register parser", () => { }); test("auto-renew summary counts ON, OFF, and unknown values from entries", () => { + const missingAutoRenew = { + ...FIXTURE_DNS.entries[0], + autoRenew: undefined as unknown as string, + }; const entries = [ { ...FIXTURE_DNS.entries[0], autoRenew: "ON" }, { ...FIXTURE_DNS.entries[1], autoRenew: "OFF" }, { ...FIXTURE_DNS.entries[2], autoRenew: "unknown" }, + missingAutoRenew, ]; const summary = summarizeDns({ ...FIXTURE_DNS, entries }, new Date("2026-12-28T00:00:00Z")); - expect(summary.autoRenew).toEqual({ on: 1, off: 1, unknown: 1 }); + expect(summary.autoRenew).toEqual({ on: 1, off: 1, unknown: 2 }); }); test("summary ages renewals by the Chicago day, not UTC (#1684)", () => { From d4d0145e9bec1780b73f0387d79ad69ad86d502b Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 08:09:57 -0600 Subject: [PATCH 3/3] fix(aggregator): link next-renewal card to its actual register row (#1214) Codex P2 on PR #4365: the card assumed the next renewal is the first row of the renewal-sorted register, but summarizeDns skips past renewals and status filters can hide the row. The matching row now carries id=dns-next-renewal, the card links to that anchor, and following the link resets the status filter so the row is visible. The domain is not repeated in the card: #1214 renders each domain once. Regression test covers a past-first register. --- pm-stack/aggregator/src/render.ts | 19 +++++++++++++++---- pm-stack/aggregator/test/slice3.test.ts | 12 ++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index 110cc56b57..d2859952b3 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -3467,11 +3467,11 @@ export function renderOverviewShell(provenance: Provenance, detail?: ProvenanceD // --- DNS register page (#906 §1, data from #902) ----------------------------- -function dnsTable(entries: DnsEntry[], renewingSoon: Set): string { +function dnsTable(entries: DnsEntry[], renewingSoon: Set, nextRenewal?: DnsEntry | null): string { const rows = entries .map( (e) => - `${esc(e.domain)}${esc(e.renewal)}${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}${esc(e.autoRenew)}${esc(e.plan)}${esc(e.review)}`, + `${esc(e.domain)}${esc(e.renewal)}${e.priceUsd != null ? `$${e.priceUsd.toFixed(2)}` : "—"}${esc(e.autoRenew)}${esc(e.plan)}${esc(e.review)}`, ) .join(""); return `
${rows || ''}
Domain register
DomainNext renewalPrice (list)Auto-renewPlan / statusReview?
none
`; @@ -3497,6 +3497,17 @@ const DNS_FILTER_SCRIPT = ``; @@ -3534,7 +3545,7 @@ export function renderDns(section: DnsSection | null, provenance: Provenance, de
Next renewal
${ next - ? `${esc(next.renewal)}${next.priceUsd != null ? ` · $${next.priceUsd.toFixed(2)}` : ""}
See the first row in the renewal-sorted register.` + ? `${esc(next.renewal)}${next.priceUsd != null ? ` · $${next.priceUsd.toFixed(2)}` : ""}
See its row in the renewal-sorted register.` : "—" }
Renewing in 45 days
${s.renewingSoon.length} domain${s.renewingSoon.length === 1 ? "" : "s"} · $${soonTotal.toFixed(2)} at list price
@@ -3543,7 +3554,7 @@ export function renderDns(section: DnsSection | null, provenance: Provenance, de

Domain register (${section.entries.length})

${filterChips}
-${dnsTable(section.entries, renewingSoon)}`; +${dnsTable(section.entries, renewingSoon, next)}`; return layout("DNS register", body, provenance, "/dns", DNS_FILTER_SCRIPT, chips); } diff --git a/pm-stack/aggregator/test/slice3.test.ts b/pm-stack/aggregator/test/slice3.test.ts index c67cd783a1..508d095914 100644 --- a/pm-stack/aggregator/test/slice3.test.ts +++ b/pm-stack/aggregator/test/slice3.test.ts @@ -449,6 +449,18 @@ describe("pages manifest + slice-3 renders", () => { expect(html).not.toContain("
Full register"); }); + test("dns next-renewal card links to the actual next-renewal row, not the first row", () => { + const past = { ...FIXTURE_DNS.entries[0], domain: "past.example", renewal: "2020-01-01" }; + const upcoming = { ...FIXTURE_DNS.entries[0], domain: "upcoming.example", renewal: "2999-01-01" }; + const section = { ...FIXTURE_DNS, entries: [past, upcoming] }; + const html = renderDns(section, fixtureSource().provenance()); + expect(html).not.toContain("See the first row"); + expect(html).toContain('href="#dns-next-renewal"'); + const rowStart = html.indexOf('id="dns-next-renewal"'); + expect(rowStart).toBeGreaterThan(-1); + expect(html.slice(rowStart, rowStart + 500)).toContain("upcoming.example"); + }); + test("dns page without a section says so honestly", () => { const html = renderDns(null, fixtureSource().provenance()); expect(html).toContain("has not reached the dashboard yet");