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
9 changes: 8 additions & 1 deletion pm-stack/aggregator/src/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
}

Expand Down
7 changes: 6 additions & 1 deletion pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3361,11 +3361,16 @@ export function renderTodayBody(
const actions = today.actions?.length
? `<h2>Pushed back into motion</h2>${today.actions.map((a) => `<div class="card"><span class="badge">${esc(a.kind)}</span> <strong>${esc(a.target)}</strong><br>${esc(a.summary)}<br><span class="muted">${esc(fmtDate(a.at))}</span></div>`).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) =>
`<div class="card obj"><div class="n">${i + 1}</div><div><strong>${esc(o.title)}</strong> <span class="badge src">${esc(o.chip)}</span>${o.detail ? `<br><span class="muted">${esc(o.detail)}</span>` : ""}${o.ref ? `<br><a href="${esc(refUrl(o.ref))}">${esc(o.ref)}</a>` : ""}</div></div>`,
`<div class="card obj"><div class="n">${i + 1}</div><div><strong>${esc(o.title)}</strong> <span class="badge src">${esc(o.chip)}</span>${o.detail ? `<br><span class="muted">${esc(o.detail)}</span>` : ""}${o.ref ? `<br>${isValidRef(o.ref) ? `<a href="${esc(refUrl(o.ref))}">${esc(o.ref)}</a>` : `<code>${esc(o.ref)}</code>`}` : ""}</div></div>`,
)
.join("")
: `<p class="muted">No objectives lined up for today.</p>`;
Expand Down
63 changes: 61 additions & 2 deletions pm-stack/aggregator/test/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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("<code>goal_b647ff5c92f5</code>");
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);
});
});