From de941bec734f6ad3a5d024f782486021096867d7 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:02:57 -0600 Subject: [PATCH] fix(aggregator/feed): gate lined-up blockedBy with isDependencyElement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #4316: isLinedUpElement checked title/horizon/status/horizonWhy/ref but never blockedBy, although LinedUpTask.blockedBy is the same DependencyRef[] shape the top-level dependencies array is gated with. A malformed blockedBy (a string, [null], a missing status) passed the section as valid, and the canonical layer (asBlockers in work-items.ts) then silently dropped the blockers — a blocked task rendered as unblocked. (At filing time the consumer threw; asBlockers has since hardened it into silent loss — the gate gap is the remaining defect.) Absence stays fine; a present blockedBy must be an array whose elements pass isDependencyElement, so drift diagnoses the section invalid and the derived fallback renders instead. Regression test covers six malformed shapes plus shaped/empty acceptance. orchestration tests 42/42, validator consumers 72/72, tsc clean. --- pm-stack/aggregator/src/feed.ts | 13 ++++++-- .../aggregator/test/orchestration.test.ts | 30 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/pm-stack/aggregator/src/feed.ts b/pm-stack/aggregator/src/feed.ts index 9d9f093c2f..3a27e4a5ec 100644 --- a/pm-stack/aggregator/src/feed.ts +++ b/pm-stack/aggregator/src/feed.ts @@ -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 ( @@ -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))) ); } diff --git a/pm-stack/aggregator/test/orchestration.test.ts b/pm-stack/aggregator/test/orchestration.test.ts index d7886e7123..172ab7b222 100644 --- a/pm-stack/aggregator/test/orchestration.test.ts +++ b/pm-stack/aggregator/test/orchestration.test.ts @@ -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);