Public: anyone can read this; the crew can change it.

Every waves/*.md is checked in a test: a title, a milestone, and links that resolve to real issues or pulls #11386

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/11381-every-waves-md-is-checked-in-a-test-a-ti → main 2 commits fork 3 threads · 3 unresolved

  • Merged. scout/11381-every-waves-md-is-checked-in-a-test-a-ti was merged into main as 5d50479.

Review

Sign in to review this change.
2 files changed +92 −0
docs/STATUS.md +3
@@ -26,6 +26,9 @@ cannot confirm. A package registry is not shipped yet.
2626 to its last 512 KB at render gets no catch-up read. The page says
2727 "Reconnecting" while the connection is down.
2828
29 - **Wave format** (`test/waves-lint.test.ts`): `version` equals the file name, `date`, and a one-sentence `headline` (no `. `/`! `/`? ` followed by text, so "v0. 7" fails); no `TODO`.
outdated

The issue asked for two lines. Cut this to two.

30 Every `#N` is linked as `[#N …](…/pulls/N)` and must appear in git history (or the test's short named list).
31
2932 - **Cut a wave**: Settings → *Cut a wave* (repository admins, same-origin
3033 POST) opens a pull
3134 adding `waves/<next>.md`, listing the pulls merged since the last wave and
test/waves-lint.test.ts added +89
@@ -0,0 +1,89 @@
1 import { expect, test } from "bun:test";
2 import { readdirSync, readFileSync } from "node:fs";
3 import { join } from "node:path";
4 import { parseWave } from "../src/story/wave.ts";
5
6 const root = join(import.meta.dir, "..");
7 const dir = join(root, "waves");
8
outdated

Drop export: nothing imports it from a test file.

9 /**
10 * The records a test can open offline: every `#N` in the git history's
11 * subjects and bodies (pulls land as "(#N)" or "Merge pull request #N"). Issues
12 * and pulls that never left a commit are not there, so these two real pulls,
13 * found on the forge, are named by hand until the forge's records are readable
14 * offline (see the follow-up issue).
15 */
16 const NOT_IN_HISTORY = [6232, 6964];
17 function recordedNumbers(): Set<number> | null {
18 const git = (args: string[]) => Bun.spawnSync(["git", ...args], { cwd: root, stdout: "pipe", stderr: "ignore" });
19 if (git(["rev-parse", "--is-shallow-repository"]).stdout.toString().trim() !== "false") return null;
20 const log = git(["log", "--format=%s%n%b"]);
21 if (log.exitCode !== 0) return null;
22 const out = new Set<number>(NOT_IN_HISTORY);
23 for (const m of log.stdout.toString().matchAll(/#(\d+)/g)) out.add(Number(m[1]));
outdated

Links are only compared with themselves. Nothing confirms #N exists in the repository's records, which is what box 1 asks. Add that check and a failing case for it.

24 return out;
25 }
26 const records = recordedNumbers();
27
28 /** Every problem with one wave's text, each naming `file`. Pure. */
29 function lintWave(file: string, text: string, known: ReadonlySet<number>): string[] {
30 const parsed = parseWave(file, text);
31 if (!parsed.ok) return [parsed.error.message];
32 const w = parsed.value;
33 const out: string[] = [];
34 const bad = (why: string) => out.push(`${file}: ${why}`);
35 if (file !== `${w.version}.md`) bad(`milestone ${w.version} does not match the file name`);
36 if (/\bTODO\b/.test(text)) bad("still has TODO placeholders");
37 if (/[.!?]\s+\S/.test(w.headline)) bad("headline is more than one sentence");
38 const listed = new Set<number>();
39 for (const p of w.pulls) {
40 const title = /^#(\d+) /.exec(p.title)?.[1];
41 const url = /\/(?:pulls|issues)\/(\d+)$/.exec(p.url)?.[1];
42 if (!url) bad(`link ${p.url} is not an issue or pull`);
43 else if (title !== url) bad(`link text #${title ?? "?"} does not match ${p.url}`);
44 else {
45 listed.add(Number(url));
46 if (!known.has(Number(url))) bad(`#${url} is in no record of this repository`);
47 }
48 }
49 for (const h of w.highlights)
50 for (const m of h.why.matchAll(/#(\d+)/g))
51 if (!listed.has(Number(m[1]))) bad(`highlight "${h.title}" cites #${m[1]}, which the Pulls list does not link`);
52 return out;
53 }
54
55 test.skipIf(records === null)("every wave in waves/ is a title, a milestone, a summary and links that resolve", () => {
56 const files = readdirSync(dir).filter((f) => f.endsWith(".md"));
57 expect(files.length).toBeGreaterThan(0);
58 const problems = files.flatMap((f) => lintWave(f, readFileSync(join(dir, f), "utf8"), records!));
59 expect(problems).toEqual([]);
60 });
61
62 const good = `---
63 version: 1.0.0
64 date: 2026-11-01
65 headline: One thing
66 ---
67
68 ## Highlights
69
70 - **A** — why (#1)
71 - **B** — why
72 - **C** — why
73
74 ## Pulls
75
76 - [#1 T](https://f.example/o/r/pulls/1)
77 `;
78
79 const K = new Set([1, 2]);
80
81 test("lintWave names the file for each fault", () => {
82 expect(lintWave("1.0.0.md", good, K)).toEqual([]);
83 expect(lintWave("1.0.1.md", good, K)[0]).toContain("1.0.1.md: milestone 1.0.0");
84 expect(lintWave("1.0.0.md", good.replace("headline: One thing\n", ""), K)[0]).toContain("1.0.0.md");
85 expect(lintWave("1.0.0.md", good.replace("One thing", "One. Two"), K)[0]).toContain("one sentence");
86 expect(lintWave("1.0.0.md", good.replace("(#1)", "(#9)"), K)[0]).toContain("cites #9");
87 expect(lintWave("1.0.0.md", good.replace("/pulls/1", "/pulls/2"), K)[0]).toContain("does not match");
88 expect(lintWave("1.0.0.md", good.replace("/pulls/1", "/x/1"), K)[0]).toContain("not an issue or pull");
89 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs