From fafdebb6c2afe112f21531d5c1ff875605ec6a2a Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 15:07:21 -0600 Subject: [PATCH] fix(aggregator): validate lined-up blockedBy refs --- pm-stack/aggregator/src/feed.ts | 7 ++- .../aggregator/test/orchestration.test.ts | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/pm-stack/aggregator/src/feed.ts b/pm-stack/aggregator/src/feed.ts index 30e3ccb627..0c43f6366a 100644 --- a/pm-stack/aggregator/src/feed.ts +++ b/pm-stack/aggregator/src/feed.ts @@ -209,7 +209,12 @@ function isGoalMeasurement(v: unknown): boolean { // #2417: todayFromSection dereferences every lined-up / stalled // element, so a non-record element must fail here, at the gate — // presence of the arrays alone let [null] through to a TypeError. - g.linedUp.every(isRecord) && + g.linedUp.every( + (task) => + isRecord(task) && + (task.blockedBy === undefined || + (Array.isArray(task.blockedBy) && task.blockedBy.every(isDependencyElement))), + ) && g.stalled.every(isRecord) && (typeof g.progressedSinceLastRun === "string" || Array.isArray(g.progressedSinceLastRun)) ); diff --git a/pm-stack/aggregator/test/orchestration.test.ts b/pm-stack/aggregator/test/orchestration.test.ts index 201964fb70..025b94b361 100644 --- a/pm-stack/aggregator/test/orchestration.test.ts +++ b/pm-stack/aggregator/test/orchestration.test.ts @@ -153,6 +153,60 @@ describe("orchestration section validation", () => { expect(isOrchestrationSection(nullGoal)).toBe(false); }); + test("validates optional blockedBy dependencies on lined-up goals", () => { + const goal = SECTION.goals[0]!; + const linedUpTask = { + title: "Write the thing", + status: "blocked", + horizon: "today", + horizonWhy: "Waiting on a prerequisite", + }; + + for (const blockedBy of ["not-an-array", [null], [{}]]) { + const malformed = { + ...SECTION, + goals: [{ ...goal, linedUp: [{ ...linedUpTask, blockedBy }] }], + }; + expect(isOrchestrationSection(malformed)).toBe(false); + expect(orchestrationSectionProblem(malformed)).toBe("goals (per-goal shape)"); + expect(normalizeOrchestrationSection(malformed)).toBeNull(); + } + + const valid = { + ...SECTION, + goals: [ + { + ...goal, + linedUp: [ + { + ...linedUpTask, + blockedBy: [ + { + task: "Implement the control plane", + status: "in-progress", + ref: "developing-today/code#3404", + workerSessionId: "session-123", + workerLabel: "OpenCode laptop", + }, + { task: "Add hosted storage", status: "queued" }, + { task: "Resolve the design", status: "stalled" }, + { task: "Merge the schema change", status: "done" }, + { task: "Confirm provider behavior", status: "unknown" }, + ], + }, + ], + }, + ], + }; + expect(isOrchestrationSection(valid)).toBe(true); + + const absent = { + ...SECTION, + goals: [{ ...goal, linedUp: [linedUpTask] }], + }; + expect(isOrchestrationSection(absent)).toBe(true); + }); + test("rejects poisoned dependency elements and bad dependency shapes", () => { const nullDep = { ...SECTION, dependencies: [null] }; expect(isOrchestrationSection(nullDep)).toBe(false);