From 4a2089fa7d84bd870cfd572f492b68f56ae64333 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 03:22:50 -0600 Subject: [PATCH] fix(pm-stack/aggregator): gate lined-up ref type and guard the Today objectives refUrl (#6174) --- pm-stack/aggregator/src/feed.ts | 9 ++- pm-stack/aggregator/src/render.ts | 7 ++- .../aggregator/test/orchestration.test.ts | 63 ++++++++++++++++++- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/pm-stack/aggregator/src/feed.ts b/pm-stack/aggregator/src/feed.ts index 5f5261e434..9d9f093c2f 100644 --- a/pm-stack/aggregator/src/feed.ts +++ b/pm-stack/aggregator/src/feed.ts @@ -227,7 +227,14 @@ function isLinedUpElement(v: unknown): boolean { typeof v.horizon === "string" && LINED_UP_HORIZONS.includes(v.horizon) && (v.status === undefined || (typeof v.status === "string" && LINED_UP_STATUSES.includes(v.status))) && - (v.horizonWhy === undefined || typeof v.horizonWhy === "string") + (v.horizonWhy === undefined || typeof v.horizonWhy === "string") && + // #6174: consumers dereference `ref` as a string (assembleWorkItems + // keys items by it; todayFromSection carries it to the render), so + // its type is gated here like the other dereferenced fields. A + // string that is not a GitHub ref stays valid at the gate — goal + // ids are legitimate lined-up refs in live data (#6149); consumers + // guard those with isValidRef at the render (#6149/#6205). + (v.ref === undefined || typeof v.ref === "string") ); } diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index 2b3cd7e742..938119a10c 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -3361,11 +3361,16 @@ export function renderTodayBody( const actions = today.actions?.length ? `

Pushed back into motion

${today.actions.map((a) => `
${esc(a.kind)} ${esc(a.target)}
${esc(a.summary)}
${esc(fmtDate(a.at))}
`).join("")}` : ""; + // #6174: an objective ref comes from publisher lined-up data and is + // only sometimes a GitHub ref — tracked-goal items carry their goal id, + // and refUrl throws on those, which 500ed the whole /today render (the + // Today-page sibling of the #6149 Needs-you fix). Mirror tierItemCard: + // GitHub refs link, everything else renders as plain code. const objectives = today.objectives.length ? today.objectives .map( (o, i) => - `
${i + 1}
${esc(o.title)} ${esc(o.chip)}${o.detail ? `
${esc(o.detail)}` : ""}${o.ref ? `
${esc(o.ref)}` : ""}
`, + `
${i + 1}
${esc(o.title)} ${esc(o.chip)}${o.detail ? `
${esc(o.detail)}` : ""}${o.ref ? `
${isValidRef(o.ref) ? `${esc(o.ref)}` : `${esc(o.ref)}`}` : ""}
`, ) .join("") : `

No objectives lined up for today.

`; diff --git a/pm-stack/aggregator/test/orchestration.test.ts b/pm-stack/aggregator/test/orchestration.test.ts index 9686f7adea..d7886e7123 100644 --- a/pm-stack/aggregator/test/orchestration.test.ts +++ b/pm-stack/aggregator/test/orchestration.test.ts @@ -4,7 +4,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { loadConfig } from "../src/config.ts"; import { validateStreamEvent } from "../src/events.ts"; -import { todayFromSection } from "../src/derive.ts"; +import { buildAttention, todayFromSection } from "../src/derive.ts"; import { ageMsText, diagnoseOrchestrationSection, @@ -14,7 +14,8 @@ import { normalizeOrchestrationSection, orchestrationSectionProblem, } from "../src/feed.ts"; -import type { OrchestrationSection } from "../src/model.ts"; +import type { LinedUpTask, OrchestrationSection, QuotaView } from "../src/model.ts"; +import { renderTodayBody } from "../src/render.ts"; import { liveSource } from "../src/sources/live.ts"; // #899: the orchestration section rides the fleet feed. The collector @@ -741,3 +742,61 @@ describe("live source diagnostics + provenance detail (#1139/#1138)", () => { expect(muse?.detail).toContain("1 recorded"); }); }); + +// #6174: the Today-page sibling of the #6149 Needs-you fix. A lined-up +// task whose ref is not a GitHub ref (a tracked goal id is the live-data +// shape) passed the section gate unchecked and reached refUrl unguarded +// in the objectives render, 500ing /today and /frag/today. +describe("#6174: lined-up refs on the Today objectives path", () => { + const QUOTA = { + pools: [], + burn: [], + choices: { hasHeadroom: [], burnBeforeReset: [], doNotStart: [] }, + } satisfies QuotaView; + + function sectionWithRef(ref: unknown): OrchestrationSection { + return { + ...SECTION, + goals: [ + { + ...SECTION.goals[0]!, + linedUp: [ + { + title: "Link the Citi accounts in Plaid", + ref: ref as LinedUpTask["ref"], + status: "queued", + horizon: "today", + horizonWhy: "due today", + }, + ], + }, + ], + }; + } + + function renderObjectives(section: OrchestrationSection): string { + const today = todayFromSection(section); + return renderTodayBody(today, buildAttention([], section), QUOTA, []); + } + + test("a goal-id lined-up ref passes the gate and renders as plain code, never a link", () => { + const section = sectionWithRef("goal_b647ff5c92f5"); + expect(isOrchestrationSection(section)).toBe(true); + const html = renderObjectives(section); + expect(html).toContain("Link the Citi accounts in Plaid"); + expect(html).toContain("goal_b647ff5c92f5"); + expect(html).not.toContain("github.com/goal_b647ff5c92f5"); + }); + + test("a valid GitHub lined-up ref still renders as a link on the objective", () => { + const section = sectionWithRef("developing-today/code#812"); + expect(isOrchestrationSection(section)).toBe(true); + const html = renderObjectives(section); + expect(html).toContain('href="https://github.com/developing-today/code/issues/812"'); + expect(html).toContain("developing-today/code#812"); + }); + + test("a non-string lined-up ref fails the gate (designed fallback, no render throw)", () => { + expect(isOrchestrationSection(sectionWithRef(12345))).toBe(false); + }); +});