diff --git a/pm-stack/aggregator/src/feed.ts b/pm-stack/aggregator/src/feed.ts index f9d1732d92..4c2c3b71f9 100644 --- a/pm-stack/aggregator/src/feed.ts +++ b/pm-stack/aggregator/src/feed.ts @@ -12,6 +12,7 @@ import type { CheckoutDrift } from "./checkout-drift.ts"; import { isProjectAudit, isProjectPoolItem } from "./projects.ts"; import { isRepoCensus, type RepoCensus } from "./coverage.ts"; import { isSessionRecord } from "./registry.ts"; +import { isDependencyStatus } from "./orchestration-dependency.ts"; import { arrayOf, isFiniteNumber, @@ -381,14 +382,11 @@ function isTierElement(v: unknown): boolean { return isRecord(v) && typeof v.id === "string"; } -const DEPENDENCY_STATUSES: readonly string[] = ["in-progress", "queued", "stalled", "done", "unknown"]; - function isDependencyElement(v: unknown): boolean { if (!isRecord(v)) return false; return ( typeof v.task === "string" && - typeof v.status === "string" && - DEPENDENCY_STATUSES.includes(v.status) && + isDependencyStatus(v.status) && (v.ref === undefined || typeof v.ref === "string") && (v.taskRef === undefined || typeof v.taskRef === "string") && (v.workerSessionId === undefined || typeof v.workerSessionId === "string") && diff --git a/pm-stack/aggregator/src/model.ts b/pm-stack/aggregator/src/model.ts index 78f4a8f672..f1f11c705a 100644 --- a/pm-stack/aggregator/src/model.ts +++ b/pm-stack/aggregator/src/model.ts @@ -632,7 +632,7 @@ export interface DependencyRef { task: string; /** "owner/repo#123" when the prerequisite is a GitHub item. */ ref?: RefKey; - status: "in-progress" | "queued" | "stalled" | "done" | "unknown"; + status: import("./orchestration-dependency.ts").DependencyStatus; /** Session working the blocker, when one is. */ workerSessionId?: string; /** Human label for the worker, e.g. "opencode-laptop · Jules 4259…". */ diff --git a/pm-stack/aggregator/src/orchestration-dependency.ts b/pm-stack/aggregator/src/orchestration-dependency.ts new file mode 100644 index 0000000000..e46358afcf --- /dev/null +++ b/pm-stack/aggregator/src/orchestration-dependency.ts @@ -0,0 +1,10 @@ +// Wire vocabulary shared by orchestration publishers, the collector gate, +// and dashboard work-item derivation. "blocked" describes a prerequisite +// that is itself waiting, not an unknown or merely queued prerequisite. +const dependencyStatuses = ["in-progress", "queued", "stalled", "blocked", "done", "unknown"] as const; + +export type DependencyStatus = (typeof dependencyStatuses)[number]; + +export function isDependencyStatus(value: unknown): value is DependencyStatus { + return dependencyStatuses.some((status) => status === value); +} diff --git a/pm-stack/aggregator/src/work-items.ts b/pm-stack/aggregator/src/work-items.ts index 473b98d0aa..c1e2b14285 100644 --- a/pm-stack/aggregator/src/work-items.ts +++ b/pm-stack/aggregator/src/work-items.ts @@ -35,6 +35,7 @@ // done-recently. Lower sorts first; ties keep section order. import type { DependencyRef, Horizon, LinedUpTask, OrchestrationSection, RefKey, TierItem } from "./model.ts"; +import { isDependencyStatus } from "./orchestration-dependency.ts"; export type WorkItemStatus = "needs-drew" | "needs-orchestrator" | LinedUpTask["status"]; @@ -127,7 +128,7 @@ function asBlockers(value: unknown): DependencyRef[] { const blocker = d as Record; return ( typeof blocker.task === "string" && - ["in-progress", "queued", "stalled", "done", "unknown"].includes(String(blocker.status)) && + isDependencyStatus(blocker.status) && (blocker.ref === undefined || typeof blocker.ref === "string") ); }); diff --git a/pm-stack/aggregator/test/contract-corpus.test.ts b/pm-stack/aggregator/test/contract-corpus.test.ts index 40f7dad168..b2b4789e5d 100644 --- a/pm-stack/aggregator/test/contract-corpus.test.ts +++ b/pm-stack/aggregator/test/contract-corpus.test.ts @@ -29,6 +29,8 @@ import { } from "../src/feed.ts"; import { isProjectPoolItem, resolveEpicRefs } from "../src/projects.ts"; import { isSessionRecord } from "../src/registry.ts"; +import { resolveOrchestrationDocument } from "../src/orchestration-db.ts"; +import { assembleWorkItems, formatBlockers } from "../src/work-items.ts"; const CORPUS = join(import.meta.dir, "contract-corpus", "v1"); @@ -63,6 +65,35 @@ describe("contract corpus: orchestration section (incl. the #1110 object-provena expect(() => todayFromSection(normalized!)).not.toThrow(); }); + test("both readers preserve blocked dependencies and derived work items", async () => { + const document = await loadJson("orchestration.json"); + for (const source of ["db", "file"] as const) { + const result = await resolveOrchestrationDocument({ + source, + readDb: async () => document, + readFile: async () => document, + validate: orchestrationSectionProblem, + }); + expect(result.source).toBe(source); + const section = normalizeOrchestrationSection(result.document); + expect(section?.dependencies.map((dep) => dep.status)).toEqual(["queued", "blocked"]); + const item = assembleWorkItems(section!).find((row) => row.title === "Example dependent task"); + expect(item?.blockers).toHaveLength(1); + expect(formatBlockers(item?.blockers ?? [])).toBe("Example upstream work (blocked)"); + } + }); + + test("both top-level and nested unknown dependency literals still fail", async () => { + const section = normalizeOrchestrationSection(await loadJson("orchestration.json"))!; + const blocker = { ...section.dependencies[1], status: "unexpected" }; + expect(orchestrationSectionProblem({ ...section, dependencies: [blocker] })).toBe( + "dependencies (per-dependency shape)", + ); + const goal = section.goals[0]; + const task = { ...goal.linedUp[0], blockedBy: [blocker] }; + expect(normalizeOrchestrationSection({ ...section, goals: [{ ...goal, linedUp: [task] }] })).toBeNull(); + }); + test("the corpus pins the publisher's object provenance form (the #1110 contract)", async () => { const section = (await loadJson("orchestration.json")) as { provenance: unknown }; expect(typeof section.provenance).toBe("object"); diff --git a/pm-stack/aggregator/test/contract-corpus/v1/feed.json b/pm-stack/aggregator/test/contract-corpus/v1/feed.json index 4d46d58d04..53d7d9da5b 100644 --- a/pm-stack/aggregator/test/contract-corpus/v1/feed.json +++ b/pm-stack/aggregator/test/contract-corpus/v1/feed.json @@ -85,6 +85,12 @@ "ref": "example-owner/example-repo#807", "status": "queued", "taskRef": "example-owner/example-repo#818" + }, + { + "task": "Example upstream work", + "ref": "example-owner/example-repo#809", + "status": "blocked", + "taskRef": "example-owner/example-repo#819" } ], "goals": [ @@ -94,7 +100,22 @@ "momentum": "moving", "summary": "Example progress recorded since the previous run.", "progressedSinceLastRun": ["Example task closed via merged PR"], - "linedUp": [], + "linedUp": [ + { + "title": "Example dependent task", + "ref": "example-owner/example-repo#819", + "status": "blocked", + "horizon": "today", + "horizonWhy": "Waiting on the prerequisite", + "blockedBy": [ + { + "task": "Example upstream work", + "ref": "example-owner/example-repo#809", + "status": "blocked" + } + ] + } + ], "stalled": [], "gaps": [] } diff --git a/pm-stack/aggregator/test/contract-corpus/v1/manifest.json b/pm-stack/aggregator/test/contract-corpus/v1/manifest.json index b0ac2d13cd..52564f3ec2 100644 --- a/pm-stack/aggregator/test/contract-corpus/v1/manifest.json +++ b/pm-stack/aggregator/test/contract-corpus/v1/manifest.json @@ -4,7 +4,7 @@ "capturedAt": "2026-11-03", "notes": [ "The section captures were read from a real collector-published fleet-feed.json on 2026-11-03, then scrubbed before check-in; no raw feed is stored.", - "- orchestration.json mirrors the orchestration-pass run orch-2026-10-27T03:14:56Z, captured in PR #1244 (#1110: provenance as an OBJECT { sources, runId }); text and refs have been scrubbed.", + "- orchestration.json mirrors the orchestration-pass run orch-2026-10-27T03:14:56Z, captured in PR #1244 (#1110: provenance as an OBJECT { sources, runId }); text and refs have been scrubbed; synthetic blocked dependency examples added for #10508.", "- quota.json is a scrubbed QuotaView captured from the real fleet feed; provider/pool names and usage measurements are replaced with deterministic examples.", "- dns.json is a scrubbed DnsSection captured from the real fleet feed; domains and editorial values are replaced, while the real status variants and null semantics remain.", "- registry.json holds scrubbed SessionRecords captured from the real fleet feed; ids, labels, timestamps, model names, and task refs are synthetic.", diff --git a/pm-stack/aggregator/test/contract-corpus/v1/orchestration.json b/pm-stack/aggregator/test/contract-corpus/v1/orchestration.json index 48ca7c2369..7f2af745f2 100644 --- a/pm-stack/aggregator/test/contract-corpus/v1/orchestration.json +++ b/pm-stack/aggregator/test/contract-corpus/v1/orchestration.json @@ -31,6 +31,12 @@ "ref": "example-owner/example-repo#807", "status": "queued", "taskRef": "example-owner/example-repo#818" + }, + { + "task": "Example upstream work", + "ref": "example-owner/example-repo#809", + "status": "blocked", + "taskRef": "example-owner/example-repo#819" } ], "goals": [ @@ -40,7 +46,22 @@ "momentum": "moving", "summary": "Example progress recorded since the previous run.", "progressedSinceLastRun": ["Example task closed via merged PR"], - "linedUp": [], + "linedUp": [ + { + "title": "Example dependent task", + "ref": "example-owner/example-repo#819", + "status": "blocked", + "horizon": "today", + "horizonWhy": "Waiting on the prerequisite", + "blockedBy": [ + { + "task": "Example upstream work", + "ref": "example-owner/example-repo#809", + "status": "blocked" + } + ] + } + ], "stalled": [], "gaps": [] }