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
13 changes: 10 additions & 3 deletions pm-stack/aggregator/src/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ const LINED_UP_STATUSES: readonly string[] = ["in-progress", "queued", "blocked"
// element fields directly (t.horizon, s.blocker), so a record alone is
// not enough — the fields it dereferences must be the right shapes, or
// the designed invalid-section fallback never happens and the consumer
// throws (or silently renders falsified state) instead. linedUp
// blockedBy stays out of scope here (#4316 owns the nested shape).
// throws (or silently renders falsified state) instead.
function isLinedUpElement(v: unknown): boolean {
if (!isRecord(v)) return false;
return (
Expand All @@ -234,7 +233,15 @@ function isLinedUpElement(v: unknown): boolean {
// 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")
(v.ref === undefined || typeof v.ref === "string") &&
// #4316: blockedBy is a DependencyRef[] — the same shape the
// top-level dependencies array is gated with (isDependencyElement).
// Ungated, a malformed blockedBy passed the section as valid and
// its blockers were silently dropped by the canonical layer
// (asBlockers), rendering a blocked task as unblocked. Absence is
// fine; a present value must be an array of dependency elements.
(v.blockedBy === undefined ||
(Array.isArray(v.blockedBy) && v.blockedBy.every(isDependencyElement)))
);
}

Expand Down
30 changes: 30 additions & 0 deletions pm-stack/aggregator/test/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,36 @@ describe("orchestration section validation", () => {
expect(() => todayFromSection(rich as OrchestrationSection)).not.toThrow();
});

test("rejects a lined-up task with a malformed blockedBy, accepts a shaped one (#4316)", () => {
const base = SECTION;
const goal = base.goals[0]!;
const task = { title: "Task A", status: "in-progress", horizon: "today", horizonWhy: "due" };
for (const blockedBy of [
"code#123",
[null],
[{ task: "Other" }],
[{ task: "Other", status: "bogus" }],
[{ task: "Other", status: "queued", ref: 42 }],
[{ status: "queued" }],
]) {
const section = { ...base, goals: [{ ...goal, linedUp: [{ ...task, blockedBy }] }] };
expect(isOrchestrationSection(section)).toBe(false);
}
const shaped = {
...base,
goals: [
{
...goal,
linedUp: [
{ ...task, blockedBy: [{ task: "Other", status: "queued", ref: "code#123" }] },
{ ...task, title: "Task B", blockedBy: [] },
],
},
],
};
expect(isOrchestrationSection(shaped)).toBe(true);
});

test("rejects poisoned dependency elements and bad dependency shapes", () => {
const nullDep = { ...SECTION, dependencies: [null] };
expect(isOrchestrationSection(nullDep)).toBe(false);
Expand Down
Loading