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
8 changes: 8 additions & 0 deletions pm-stack/aggregator/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ export interface Config {
commentsFile: string;
/** Append-only roadmap annotation store (#1284), separate from comments. */
roadmapAnnotationsFile: string;
/** Checkout of developing-today/code on the aggregator host; the
* repo-file roadmap source (#1738) reads planning/roadmaps/*.md here. */
codeCheckout: string;
/** Checkout of dezren39/darwin-nix on the aggregator host; the
* repo-file roadmap source (#1738) reads ROADMAP.md here. */
nixCheckout: string;
/** Dashboard actions store (#1152/#1154/#1156) — triage write path. */
actionsFile: string;
/** Saved-views store (#1276) — named per-person filter sets. */
Expand Down Expand Up @@ -169,6 +175,8 @@ export function loadConfig(env: Record<string, string | undefined> = process.env
feedFile: s(env.PM_AGG_FEED_FILE, join(process.cwd(), "fleet-feed.json")),
commentsFile: s(env.PM_AGG_COMMENTS_FILE, join(process.cwd(), "comments.json")),
roadmapAnnotationsFile: s(env.PM_AGG_ROADMAP_ANNOTATIONS_FILE, join(process.cwd(), "roadmap-annotations.json")),
codeCheckout: s(env.PM_AGG_CODE_CHECKOUT, join(homedir(), "git", "code")),
nixCheckout: s(env.PM_AGG_NIX_CHECKOUT, join(homedir(), "code", "dezren39-nix")),
actionsFile: s(env.PM_AGG_ACTIONS_FILE, join(process.cwd(), "actions.json")),
viewsFile: s(env.PM_AGG_VIEWS_FILE, join(process.cwd(), "views.json")),
eventsFile: s(env.PM_AGG_EVENTS_FILE, join(process.cwd(), "events.json")),
Expand Down
3 changes: 3 additions & 0 deletions pm-stack/aggregator/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ export interface RoadmapRow {
links: Link[];
/** Grist UI link for this row's document (#1136), when known. */
gristUrl?: string;
/** Repo-file link for this row's source file + heading (#1738), when
* the row was parsed from a repo roadmap file rather than Grist. */
fileUrl?: string;
}

/** Where each facet's data came from, shown in the UI footer. */
Expand Down
3 changes: 2 additions & 1 deletion pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,7 @@ function roadmapCard(
.join(" ");
const cmt = counts ? commentBadge(row.subject, counts) : "";
const grist = row.gristUrl ? ` <a class="badge" href="${esc(row.gristUrl)}">Grist ↗</a>` : "";
const repoFile = row.fileUrl ? ` <a class="badge" href="${esc(row.fileUrl)}">Repo file ↗</a>` : "";
const expansion = drill ? roadmapDrilldown(drill, row, forecasts, spend) : "";
const notes = annotations?.get(row.subject) ?? [];
const annotationHtml = notes.length
Expand All @@ -1813,7 +1814,7 @@ function roadmapCard(
}
}
}
return `<div class="card"><a href="/item/${encodeURIComponent(row.subject)}">${esc(row.title)}</a>${cmt}<br><span class="badge ${esc(row.status.toLowerCase().replace(/[^a-z]/g, "-"))}">${esc(row.status)}</span> <span class="muted">${esc(row.area)} · ${esc(row.horizon)}</span>${horizonWarning}${statusClash}${refBadges}${grist}${annotationHtml}${expansion}${briefPanels}</div>`;
return `<div class="card"><a href="/item/${encodeURIComponent(row.subject)}">${esc(row.title)}</a>${cmt}<br><span class="badge ${esc(row.status.toLowerCase().replace(/[^a-z]/g, "-"))}">${esc(row.status)}</span> <span class="muted">${esc(row.area)} · ${esc(row.horizon)}</span>${horizonWarning}${statusClash}${refBadges}${grist}${repoFile}${annotationHtml}${expansion}${briefPanels}</div>`;
}

function roadmapAnnotationHtml(annotation: RoadmapAnnotation): string {
Expand Down
26 changes: 21 additions & 5 deletions pm-stack/aggregator/src/sources/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import { isRecord } from "../validate.ts";
import { buildAttentionFlags, buildQuotaActions, quotaActionFlags } from "../derive.ts";
import { validateRoadmapHorizon } from "../roadmap-horizon.ts";
import { describeRepoRoadmapSection, mergeRoadmapRows, readRepoRoadmaps } from "./repo-roadmap.ts";
import { summarizeDns } from "../dns.ts";
import {
applyCloudflareExport,
Expand Down Expand Up @@ -1329,13 +1330,28 @@ export function liveSource(
try {
const rows = await gristRoadmap(cfg);
if (rows.length > 0) {
provenance.roadmap = "live (Grist)";
let merged = rows;
let label = "live (Grist)";
if (cfg.projector.baseUrl) {
const enriched = await enrichWithRegistryLinks(cfg.projector.baseUrl, rows, (r) => r.subject);
provenance.roadmap = "live (Grist + projector links)";
return enriched;
merged = await enrichWithRegistryLinks(cfg.projector.baseUrl, rows, (r) => r.subject);
label = "live (Grist + projector links)";
}
return rows;
// #1738: merge the repos' own roadmap files in alongside the
// Grist rows. The repo-file read never throws (its failures
// are section states), but guard anyway: a broken repo source
// must never take the Grist roadmap down with it. Empty
// sections name their state + reason in the label (#1500).
try {
const repo = await readRepoRoadmaps(cfg);
const out = mergeRoadmapRows(merged, repo.rows);
merged = out.rows;
const sections = repo.sections.map(describeRepoRoadmapSection).join("; ");
label += ` + repo files (${sections}${out.collapsedCount ? `; ${out.collapsedCount} grist duplicate(s) collapsed` : ""})`;
} catch (err) {
label += ` + repo files (unreadable: ${err instanceof Error ? err.message : err})`;
}
provenance.roadmap = label;
return merged;
}
} catch (err) {
provenance.roadmap = `fixtures (grist unreachable: ${err instanceof Error ? err.message : err})`;
Expand Down
176 changes: 176 additions & 0 deletions pm-stack/aggregator/src/sources/repo-roadmap.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import { describe, expect, test } from "bun:test";
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
mergeRoadmapRows,
parseRepoRoadmapFile,
readRepoRoadmaps,
} from "./repo-roadmap.ts";
import type { RoadmapRow } from "../model.ts";

// An id.md-shaped code roadmap file: horizon lives in the ## heading,
// refs are bare #n against the file's own repo.
const CODE_FILE = `# Roadmap: id

The id program record.

## Now — the path to Phase 12

| Title | Status | Intent | Links |
| ------------------ | ----------- | ---------------------- | ----- |
| Many worlds per node | planned | 1,000 idle / 100 active worlds. | F12.12 #557 |
| Trusted CI signal | in-progress | A red check must mean something. | #241, [plan](https://github.com/developing-today/code/issues/999) |

## Ideas

| Title | Status | Intent | Links |
| --------------- | ------ | ------------- | ----- |
| Worlds on Workers | idea | A pkarr option. | #793 |
`;

const CODE_META = { repo: "developing-today/code", path: "planning/roadmaps/id.md" };

// A nix ROADMAP.md-shaped file: an "Areas" summary table (no Title
// column — must be skipped), then per-area sections whose tables carry
// the Horizon column; area comes from the section heading.
const NIX_FILE = `# Roadmap

Grouped by area.

## Areas

| Area | Current focus |
| ---------- | ------------- |
| [Widgets](#widgets) | All the widgets |

## Widgets

| Title | Horizon | Status | Intent | Links |
| ---------------- | ------- | -------- | ------------------- | ----- |
| Widget takeover | Now | planned | Take over widgets. | \`developing-today/code#237\` |
| Widget hygiene | Next | proposed | Sweep the widgets. | #376 |
`;

const NIX_META = {
repo: "dezren39/darwin-nix",
path: "ROADMAP.md",
program: "darwin-nix",
areaFromSections: true,
};

describe("parseRepoRoadmapFile — code planning/roadmaps shape", () => {
const rows = parseRepoRoadmapFile(CODE_FILE, CODE_META);

test("the id program appears with zero Grist rows", () => {
expect(rows.length).toBe(3);
expect(rows.every((r) => r.area === "id")).toBe(true);
expect(rows.every((r) => r.subject.startsWith("repo-file:developing-today/code/planning/roadmaps/id.md/"))).toBe(true);
});

test("horizon comes from the section heading; Ideas is its own bucket, not an error", () => {
expect(rows[0].horizon).toBe("Now");
expect(rows[2].horizon).toBe("Ideas");
expect(rows[2].horizonError).toBeUndefined();
});

test("bare and URL refs resolve against the file's repo; file link points at the heading", () => {
expect(rows[0].links).toEqual([{ ref: "developing-today/code#557", relation: "tracks" }]);
expect(rows[1].links.map((l) => l.ref).sort()).toEqual(["developing-today/code#241", "developing-today/code#999"]);
expect(rows[0].fileUrl).toBe(
"https://github.com/developing-today/code/blob/main/planning/roadmaps/id.md#now--the-path-to-phase-12",
);
expect(rows[0].source).toContain("repo file");
expect(rows[0].notes).toContain("1,000 idle");
});
});

describe("parseRepoRoadmapFile — nix ROADMAP.md shape", () => {
const rows = parseRepoRoadmapFile(NIX_FILE, NIX_META);

test("the Areas summary table is skipped; section tables parse with their Horizon column", () => {
expect(rows.length).toBe(2);
expect(rows.map((r) => r.title)).toEqual(["Widget takeover", "Widget hygiene"]);
expect(rows[0].area).toBe("Widgets");
expect(rows[0].horizon).toBe("Now");
expect(rows[1].horizon).toBe("Next");
});

test("qualified refs keep their repo; bare refs take the file's repo", () => {
expect(rows[0].links).toEqual([{ ref: "developing-today/code#237", relation: "tracks" }]);
expect(rows[1].links).toEqual([{ ref: "dezren39/darwin-nix#376", relation: "tracks" }]);
});

test("a file with no Title table parses empty", () => {
expect(parseRepoRoadmapFile("# Roadmap\n\nJust prose, no tables.\n", NIX_META)).toEqual([]);
});
});

const gristRow = (title: string, subject: string): RoadmapRow => ({
id: 7,
subject,
title,
area: "id",
status: "planned",
horizon: "Now",
source: "",
notes: "",
links: [{ ref: "developing-today/code#557", relation: "tracks" }],
});

describe("mergeRoadmapRows — dedupe prefers the repo row", () => {
test("a Grist duplicate collapses into the repo row with provenance noted", () => {
const repo = parseRepoRoadmapFile(CODE_FILE, CODE_META).map((r, i) => ({ ...r, id: -1 - i }));
const grist = [gristRow("Many Worlds Per Node!", "grist:doc/Roadmap/7"), gristRow("Only in Grist", "grist:doc/Roadmap/8")];
const { rows, collapsedCount } = mergeRoadmapRows(grist, repo);
expect(collapsedCount).toBe(1);
expect(rows.some((r) => r.subject === "grist:doc/Roadmap/7")).toBe(false);
expect(rows.some((r) => r.subject === "grist:doc/Roadmap/8")).toBe(true);
const twin = rows.find((r) => r.title === "Many worlds per node");
expect(twin?.notes).toContain("grist:doc/Roadmap/7");
expect(twin?.links).toEqual([{ ref: "developing-today/code#557", relation: "tracks" }]);
});
});

describe("readRepoRoadmaps — section states say why (#1500)", () => {
test("ok: both sources read, ids are unique negatives", async () => {
const root = await mkdtemp(join(tmpdir(), "repo-roadmap-"));
await mkdir(join(root, "code", "planning", "roadmaps"), { recursive: true });
await writeFile(join(root, "code", "planning", "roadmaps", "id.md"), CODE_FILE);
await mkdir(join(root, "nix"), { recursive: true });
await writeFile(join(root, "nix", "ROADMAP.md"), NIX_FILE);
const { rows, sections } = await readRepoRoadmaps({ codeCheckout: join(root, "code"), nixCheckout: join(root, "nix") });
expect(rows.length).toBe(5);
expect(new Set(rows.map((r) => r.id)).size).toBe(5);
expect(rows.every((r) => r.id < 0)).toBe(true);
expect(sections.map((s) => s.state)).toEqual(["ok", "ok"]);
});

test("missing: neither checkout carries the files", async () => {
const root = await mkdtemp(join(tmpdir(), "repo-roadmap-"));
const { rows, sections } = await readRepoRoadmaps({ codeCheckout: join(root, "code"), nixCheckout: join(root, "nix") });
expect(rows).toEqual([]);
expect(sections.map((s) => s.state)).toEqual(["missing", "missing"]);
expect(sections[0].reason).toContain("PM_AGG_CODE_CHECKOUT");
expect(sections[1].reason).toContain("PM_AGG_NIX_CHECKOUT");
});

test("parse-empty: files exist but carry no Title-table rows", async () => {
const root = await mkdtemp(join(tmpdir(), "repo-roadmap-"));
await mkdir(join(root, "code", "planning", "roadmaps"), { recursive: true });
await writeFile(join(root, "code", "planning", "roadmaps", "empty.md"), "# Roadmap: empty\n\nNo tables yet.\n");
await mkdir(join(root, "nix"), { recursive: true });
await writeFile(join(root, "nix", "ROADMAP.md"), "# Roadmap\n\nNothing parsed.\n");
const { sections } = await readRepoRoadmaps({ codeCheckout: join(root, "code"), nixCheckout: join(root, "nix") });
expect(sections.map((s) => s.state)).toEqual(["parse-empty", "parse-empty"]);
});

test("unreadable: a file where a directory is expected (and vice versa)", async () => {
const root = await mkdtemp(join(tmpdir(), "repo-roadmap-"));
await mkdir(join(root, "code", "planning"), { recursive: true });
await writeFile(join(root, "code", "planning", "roadmaps"), "not a directory");
await mkdir(join(root, "nix", "ROADMAP.md"), { recursive: true });
const { sections } = await readRepoRoadmaps({ codeCheckout: join(root, "code"), nixCheckout: join(root, "nix") });
expect(sections.map((s) => s.state)).toEqual(["unreadable", "unreadable"]);
});
});
Loading