GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(aggregator): validate orchestration section array elements at the… · developing-today/code@ce79e72

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pm-stack/aggregator
    • src
      • feed.ts
    • test
      • orchestration.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pm-stack/aggregator/src/feed.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/src/feed.ts
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,63 @@ function isGoalMeasurement(v: unknown): boolean {
191191
Array.isArray(g.linedUp) &&
192192
Array.isArray(g.stalled) &&
193193
Array.isArray(g.gaps) &&
194+
// #2417: todayFromSection dereferences every lined-up / stalled
195+
// element, so a non-record element must fail here, at the gate —
196+
// presence of the arrays alone let [null] through to a TypeError.
197+
g.linedUp.every(isRecord) &&
198+
g.stalled.every(isRecord) &&
194199
(typeof g.progressedSinceLastRun === "string" || Array.isArray(g.progressedSinceLastRun))
195200
);
196201
}
197202

203+
/**
204+
* Element gates for the section's remaining arrays (#2417). The
205+
* section gate used to check only that these arrays exist; poisoned
206+
* elements (null, primitives, shapeless objects) then reached
207+
* consumers that dereference them — buildAttention on tier items,
208+
* the projects view on dependencies, the today view on actions —
209+
* and threw TypeErrors instead of taking the designed invalid-section
210+
* fallback. The rules stay at the depth consumers need:
211+
*
212+
* - Tier items: a plain record with a string `id`. Deeper fields are
213+
* the per-item sanitizer's job (src/tier-items.ts, #1290) — a
214+
* malformed extension drops there, never the item, so the gate
215+
* must not reject on them.
216+
* - Dependencies: the declared consumed shape — required string
217+
* `task`, `status` in the DependencyRef union, and the optional
218+
* ref/worker fields string-typed when present.
219+
* - Actions: the four rendered string fields (at, kind, target,
220+
* summary).
221+
*/
222+
function isTierElement(v: unknown): boolean {
223+
return isRecord(v) && typeof v.id === "string";
224+
}
225+
226+
const DEPENDENCY_STATUSES: readonly string[] = ["in-progress", "queued", "stalled", "done", "unknown"];
227+
228+
function isDependencyElement(v: unknown): boolean {
229+
if (!isRecord(v)) return false;
230+
return (
231+
typeof v.task === "string" &&
232+
typeof v.status === "string" &&
233+
DEPENDENCY_STATUSES.includes(v.status) &&
234+
(v.ref === undefined || typeof v.ref === "string") &&
235+
(v.taskRef === undefined || typeof v.taskRef === "string") &&
236+
(v.workerSessionId === undefined || typeof v.workerSessionId === "string") &&
237+
(v.workerLabel === undefined || typeof v.workerLabel === "string")
238+
);
239+
}
240+
241+
function isActionElement(v: unknown): boolean {
242+
return (
243+
isRecord(v) &&
244+
typeof v.at === "string" &&
245+
typeof v.kind === "string" &&
246+
typeof v.target === "string" &&
247+
typeof v.summary === "string"
248+
);
249+
}
250+
198251
/**
199252
* The section's provenance (#1110). The contract is the publisher's
200253
* object form — `{ sources: string[], runId?: string }` — which every
@@ -231,11 +284,15 @@ export function orchestrationSectionProblem(v: unknown): string | null {
231284
if (!isProvenance(s.provenance)) return "provenance";
232285
if (typeof s.tiers !== "object" || s.tiers === null) return "tiers";
233286
if (!Array.isArray(s.tiers.needsDrew)) return "tiers.needsDrew";
287+
if (!s.tiers.needsDrew.every(isTierElement)) return "tiers.needsDrew (per-item shape)";
234288
if (!Array.isArray(s.tiers.needsOrchestrator)) return "tiers.needsOrchestrator";
289+
if (!s.tiers.needsOrchestrator.every(isTierElement)) return "tiers.needsOrchestrator (per-item shape)";
235290
if (!Array.isArray(s.dependencies)) return "dependencies";
291+
if (!s.dependencies.every(isDependencyElement)) return "dependencies (per-dependency shape)";
236292
if (!Array.isArray(s.goals)) return "goals";
237293
if (!s.goals.every(isGoalMeasurement)) return "goals (per-goal shape)";
238294
if (!Array.isArray(s.actions)) return "actions";
295+
if (!s.actions.every(isActionElement)) return "actions (per-action shape)";
239296
return null;
240297
}
241298

Collapse file

‎pm-stack/aggregator/test/orchestration.test.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/test/orchestration.test.ts
+74Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,80 @@ describe("orchestration section validation", () => {
124124
expect(() => todayFromSection(minimal)).not.toThrow();
125125
});
126126

127+
// #2417: the gate checked array presence only, so poisoned elements
128+
// (null / primitives / shapeless objects) passed into consumers and
129+
// threw TypeErrors. Every array's elements are now validated at this
130+
// boundary; a poisoned section must reject, normalize to null, and
131+
// diagnose as invalid with a stable failed-check name.
132+
test("rejects poisoned tier elements in both tier arrays", () => {
133+
for (const bad of [null, 42, {}]) {
134+
const drew = { ...SECTION, tiers: { ...SECTION.tiers, needsDrew: [bad] } };
135+
expect(isOrchestrationSection(drew)).toBe(false);
136+
expect(orchestrationSectionProblem(drew)).toBe("tiers.needsDrew (per-item shape)");
137+
expect(normalizeOrchestrationSection(drew)).toBeNull();
138+
const orch = { ...SECTION, tiers: { ...SECTION.tiers, needsOrchestrator: [bad] } };
139+
expect(isOrchestrationSection(orch)).toBe(false);
140+
expect(orchestrationSectionProblem(orch)).toBe("tiers.needsOrchestrator (per-item shape)");
141+
}
142+
});
143+
144+
test("rejects non-record elements in goal linedUp and stalled arrays", () => {
145+
const goal = SECTION.goals[0]!;
146+
for (const field of ["linedUp", "stalled"] as const) {
147+
const malformed = { ...SECTION, goals: [{ ...goal, [field]: [null] }] };
148+
expect(isOrchestrationSection(malformed)).toBe(false);
149+
expect(orchestrationSectionProblem(malformed)).toBe("goals (per-goal shape)");
150+
expect(normalizeOrchestrationSection(malformed)).toBeNull();
151+
}
152+
const nullGoal = { ...SECTION, goals: [null] };
153+
expect(isOrchestrationSection(nullGoal)).toBe(false);
154+
});
155+
156+
test("rejects poisoned dependency elements and bad dependency shapes", () => {
157+
const nullDep = { ...SECTION, dependencies: [null] };
158+
expect(isOrchestrationSection(nullDep)).toBe(false);
159+
expect(orchestrationSectionProblem(nullDep)).toBe("dependencies (per-dependency shape)");
160+
const noStatus = { ...SECTION, dependencies: [{ task: "Write the thing" }] };
161+
expect(isOrchestrationSection(noStatus)).toBe(false);
162+
const badStatus = { ...SECTION, dependencies: [{ task: "Write the thing", status: "bogus" }] };
163+
expect(isOrchestrationSection(badStatus)).toBe(false);
164+
const badRef = {
165+
...SECTION,
166+
dependencies: [{ task: "Write the thing", status: "queued", ref: 42 }],
167+
};
168+
expect(isOrchestrationSection(badRef)).toBe(false);
169+
const good = {
170+
...SECTION,
171+
dependencies: [{ task: "Write the thing", status: "queued", ref: "developing-today/code#1" }],
172+
};
173+
expect(isOrchestrationSection(good)).toBe(true);
174+
});
175+
176+
test("rejects poisoned action elements and actions missing rendered fields", () => {
177+
const nullAction = { ...SECTION, actions: [null] };
178+
expect(isOrchestrationSection(nullAction)).toBe(false);
179+
expect(orchestrationSectionProblem(nullAction)).toBe("actions (per-action shape)");
180+
const noSummary = {
181+
...SECTION,
182+
actions: [{ at: "2026-10-25T17:20:00.000Z", kind: "nudge", target: "task 1" }],
183+
};
184+
expect(isOrchestrationSection(noSummary)).toBe(false);
185+
const good = {
186+
...SECTION,
187+
actions: [
188+
{ at: "2026-10-25T17:20:00.000Z", kind: "nudge", target: "task 1", summary: "Nudged it." },
189+
],
190+
};
191+
expect(isOrchestrationSection(good)).toBe(true);
192+
});
193+
194+
test("a poisoned section diagnoses as invalid, never absent or live", () => {
195+
const poisoned = { ...SECTION, tiers: { ...SECTION.tiers, needsDrew: [null] } };
196+
const diagnosis = diagnoseOrchestrationSection(poisoned);
197+
expect(diagnosis.state).toBe("invalid");
198+
expect(diagnosis.failedChecks).toEqual(["tiers.needsDrew (per-item shape)"]);
199+
});
200+
127201
test("a fleet feed carrying the section still validates as a feed", () => {
128202
const feed = {
129203
version: 1,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.