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

/changelog advertises its Atom feed for autodiscovery and the feed lists releases by wave #15986

Merged opened this

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

Merged

scout/forge:scout/15977-changelog-advertises-its-atom-feed-for-a → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/15977-changelog-advertises-its-atom-feed-for-a was merged into main as 3bbbd04.

Review

Sign in to review this change.
4 files changed +41 −9
docs/features/changelog.md +1 −1
@@ -38,7 +38,7 @@ A squash keeps the people behind its commits: the landed message carries every d
3838
3939 ## As a feed (#8213)
4040
41 `GET /changelog.atom` is the same list as an Atom feed, public, for a feed reader. It holds the newest 20 live landings of the forge's own repository (`FORGE_REPO`, public only), newest first, one entry each titled `Went live: <title>` with a one-sentence summary (`Landed in <repo> as pull #<n> on <date> and is live.`) and linked to that release's row on the page, `/changelog?release=release-<owner>-<name>-<n>#release-<owner>-<name>-<n>` (the row's `id`, from `release/anchor.ts`). The `release=` part opens a gathered line that holds the row, so the link lands on a row you can see without any script. what has landed but is not yet live is left out. A landing a wave covers collapses into one entry per wave (not per release or per landing): the wave's headline is the title, its highlights the summary, the link goes to the wave's page, and the entry is dated at the wave's newest landing. Waves are read from the forge repository's default branch, so the `ETag` moves with that branch's tip as well as with the list. The tip is read on every request, the 304 path included; the five-minute cache is what keeps git off the hot path. The 20 is the feed's own cap (`CHANGELOG_ENTRIES` in `web/feeds.ts`); the page and `/api/v1/changelog` are not capped. It is cached for five minutes (`cache-control: public, max-age=300`) and carries a weak `ETag`, so a reader that sends `If-None-Match` gets a 304. The page links it with `rel="alternate"`.
41 `GET /changelog.atom` is the same list as an Atom feed, public, for a feed reader. It holds the newest 20 live landings of the forge's own repository (`FORGE_REPO`, public only), newest first, one entry each titled `Went live: <title>` with a one-sentence summary (`Landed in <repo> as pull #<n> on <date> and is live.`) and linked to that release's row on the page, `/changelog?release=release-<owner>-<name>-<n>#release-<owner>-<name>-<n>` (the row's `id`, from `release/anchor.ts`). The `release=` part opens a gathered line that holds the row, so the link lands on a row you can see without any script. what has landed but is not yet live is left out. A landing a wave covers collapses into one entry per wave (not per release or per landing): the wave's headline is the title, its highlights the summary, the link goes to the wave's page, and the entry is dated at the wave's newest landing. Waves are read from the forge repository's default branch, so the `ETag` moves with that branch's tip as well as with the list. The tip is read on every request, the 304 path included; the five-minute cache is what keeps git off the hot path. The 20 is the feed's own cap (`CHANGELOG_ENTRIES` in `web/feeds.ts`); the page and `/api/v1/changelog` are not capped. It is cached for five minutes (`cache-control: public, max-age=300`) and carries a weak `ETag`, so a reader that sends `If-None-Match` gets a 304. A kept release (a `v*` tag, listed in the feed as `Released v<version>`) whose version matches a wave of the forge's own repository is titled `Released v<version>: <headline>`, carries `<category term="<version>" label="Wave <version>"/>` and links the wave's page; a release with no wave keeps its subject as the title and links `/changelog`. The entry a wave's landings collapse into carries the same category. Tested in `test/changelog-atom.test.ts` and `test/changelog-atom-releases.test.ts`. The page links it with `rel="alternate"`.
4242
4343 An agent reads the same data as JSON, not Atom: MCP `releases` with `{shipped: true}` or `GET /api/v1/changelog` (see above). The terminal has no screen for the feed, since a feed is for a reader program; its Changelog screen is the release-commit view, with `w` for the waves.
4444
src/web/feeds.ts +13 −6
@@ -258,17 +258,23 @@ interface FeedItem {
258258 * as `/api/v1/changelog` lists it under `releases`. Its id names the repository and version, so
259259 * a tag read twice is one entry to a reader.
260260 */
261 export function releaseItem(origin: string, own: string, r: PublicRelease): FeedItem {
262 const link = `${origin}/changelog${r.repo === own ? "" : `?repo=${encodeURIComponent(r.repo)}`}`;
263 const said = r.subject.trim() === "" || r.subject === `v${r.version}` ? "" : `: ${plainTitle(r.subject)}`;
261 export function releaseItem(origin: string, own: string, r: PublicRelease, wave?: Wave): FeedItem {
262 const [o = "", n = ""] = own.split("/");
263 const page = `${origin}/changelog${r.repo === own ? "" : `?repo=${encodeURIComponent(r.repo)}`}`;
264 const ownWave = r.repo === own ? wave : undefined;
outdated

Principle 8 and clean code: two nested ternaries on one long line each. Name the wave link and the wave title as consts.

265 // A release the repository's waves tell the story of names that wave and links its page.
266 const link = ownWave === undefined ? page : `${origin}${wavePath(o, n, ownWave.version)}`;
267 const plainSubject = r.subject.trim() === "" || r.subject === `v${r.version}` ? "" : `: ${plainTitle(r.subject)}`;
268 const said = ownWave === undefined ? plainSubject : `: ${ownWave.headline.trim()}`;
269 const category = ownWave === undefined ? "" : `\n <category term="${xml(ownWave.version)}" label="${xml(`Wave ${ownWave.version}`)}"/>`;
264270 return {
265271 at: r.servedAt,
266272 body: ` <entry>
267273 <id>urn:forge:release:${xml(`${r.repo}@${r.version}`)}</id>
268274 <title>${xml(`Released v${r.version}${said}`)}</title>
269275 <updated>${xml(stamp(r.servedAt))}</updated>
270 <link rel="alternate" type="text/html" href="${xml(link)}"/>
271 <summary>${xml(`${r.repo} v${r.version}, commit ${shortOf(r.commit)}, released on ${stamp(r.servedAt).slice(0, 10)}.`)}</summary>
276 <link rel="alternate" type="text/html" href="${xml(link)}"/>${category}
277 <summary>${xml(`${r.repo} v${r.version}${ownWave === undefined ? "" : ` (wave ${ownWave.version})`}, commit ${shortOf(r.commit)}, released on ${stamp(r.servedAt).slice(0, 10)}.`)}</summary>
272278 </entry>`,
273279 };
274280 }
@@ -337,6 +343,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> {
337343 <title>${xml(wave.headline.trim())}</title>
outdated

No test fails without this category line on landing entries. Assert it in test/changelog-atom.test.ts.

338344 <updated>${xml(stamp(l.at))}</updated>
339345 <link rel="alternate" type="text/html" href="${xml(`${origin}${wavePath(ownerName, repoName, wave.version)}`)}"/>
346 <category term="${xml(wave.version)}" label="${xml(`Wave ${wave.version}`)}"/>
340347 <summary>${xml(summary)}</summary>
341348 </entry>` }];
342349 }
@@ -352,7 +359,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> {
352359 <summary>${xml(`Landed in ${l.repo} as pull #${l.number} on ${stamp(l.at).slice(0, 10)} and is live.`)}</summary>
353360 </entry>` }];
354361 });
355 const items = [...landed, ...releases.map((r) => releaseItem(origin, own, r))]
362 const items = [...landed, ...releases.map((r) => releaseItem(origin, own, r, r.repo === own ? waves.find((w) => w.version === r.version) : undefined))]
356363 .sort((a, b) => Date.parse(stamp(b.at)) - Date.parse(stamp(a.at)))
357364 .slice(0, CHANGELOG_ENTRIES);
358365 if (alone && answer.commit !== null) items.push(runningItem(origin, answer.commit, named ?? answer.commit, answer.liveSince));
test/changelog-atom-releases.test.ts +16 −2
@@ -17,6 +17,7 @@ import { repoDir } from "../src/git/repos.ts";
1717 import { serve, type Servers } from "../src/http/server.ts";
1818 import { BOOTED } from "../src/release/gate.ts";
1919 import { gitAt } from "./helpers/plain-git.ts";
20 import { writeWave } from "../src/story/wave.ts";
2021 import { checkAtom } from "./helpers/atom.ts";
2122
2223 const entriesOf = (text: string): string[] => text.match(/<entry>[\s\S]*?<\/entry>/g) ?? [];
@@ -47,7 +48,18 @@ describe("GET /changelog.atom with one release tag and no landed pull", () => {
4748 const work = join(data, "work");
4849 await Bun.$`mkdir -p ${work}`.quiet();
4950 gitAt(work, ["init", "-q", "-b", "main"], "2026-11-20T10:00:00Z");
50 gitAt(work, ["commit", "-q", "--allow-empty", "-m", "cut 0.7.629"], "2026-11-20T10:00:00Z");
51 const w = writeWave({
52 version: "0.7.629",
53 date: "2026-11-20",
54 headline: "Releases speak by wave",
55 highlights: [1, 2, 3].map((n) => ({ title: `Thing ${n}`, why: "because" })),
56 pulls: [{ title: "#1 Fix", url: "http://x/trevato/forge/pulls/1" }],
57 });
58 if (!w.ok) throw w.error;
59 await Bun.$`mkdir -p ${work}/waves`.quiet();
60 await Bun.write(join(work, "waves/0.7.629.md"), w.value);
61 gitAt(work, ["add", "."], "2026-11-20T10:00:00Z");
62 gitAt(work, ["commit", "-q", "-m", "cut 0.7.629"], "2026-11-20T10:00:00Z");
5163 tagged = gitAt(work, ["rev-parse", "HEAD"], "2026-11-20T10:00:00Z");
5264 // As scripts/cut-release.ts cuts it: annotated, the message its JSON record.
5365 gitAt(work, ["tag", "-a", "-F", "-", "v0.7.629"], "2026-11-20T10:00:00Z", JSON.stringify({ version: "0.7.629" }));
@@ -69,7 +81,9 @@ describe("GET /changelog.atom with one release tag and no landed pull", () => {
6981 const entries = entriesOf(text);
7082 expect(entries.length).toBe(1);
7183 expect(entries[0]).toContain("<id>urn:forge:release:trevato/[email protected]</id>");
72 expect(entries[0]).toContain("<title>Released v0.7.629</title>");
84 expect(entries[0]).toContain("<title>Released v0.7.629: Releases speak by wave</title>");
85 expect(entries[0]).toContain('<category term="0.7.629" label="Wave 0.7.629"/>');
86 expect(entries[0]).toContain(`href="${servers.url}/trevato/forge/waves/0.7.629"`);
7387 expect(entries[0]).toContain(`commit ${tagged.slice(0, 7)}`);
7488 expect(entries[0]).toContain("<updated>2026-11-20T10:00:00.000Z</updated>");
7589 // The feed's updated is its newest entry's, and no running-build entry stands beside a release.
test/changelog-atom.test.ts +11
@@ -13,6 +13,7 @@ import { forgetLive, keepLive } from "../src/release/landings.ts";
1313 import { feedEpoch } from "../src/core/feed_epoch.ts";
1414 import { getRepo } from "../src/core/repos.ts";
1515 import { writeWave } from "../src/story/wave.ts";
16 import { releaseItem } from "../src/web/feeds.ts";
1617 import { checkAtom } from "./helpers/atom.ts";
1718 import { serve, type Servers } from "../src/http/server.ts";
1819
@@ -226,6 +227,8 @@ describe("GET /changelog.atom", () => {
226227 const { titles } = checkAtom(text, `${servers.url}/changelog.atom`);
227228 expect(titles).toEqual(["Faster <b>feeds</b> & more", "Went live: j/k, enter, esc and ? on pulls"]);
228229 expect(text).toContain(`href="${servers.url}/alice/forge/waves/1.2.3"`);
230 // The landing a wave covers carries the wave as its category.
231 expect(text).toContain('<category term="1.2.3" label="Wave 1.2.3"/>');
229232 expect(text).toContain("<summary>Thing 1 &lt;x&gt;: because &amp; so");
230233 expect(text).toContain("Faster &lt;b&gt;feeds&lt;/b&gt; &amp; more");
231234 expect(text).not.toContain("<b>");
@@ -238,6 +241,14 @@ describe("GET /changelog.atom", () => {
238241 expect((await fell.text())).toContain("Went live: Fix &lt;&amp;&gt; escaping");
239242 });
240243
244 test("a release with no wave keeps its plain title and links /changelog", () => {
245 const r = { repo: "alice/forge", version: "1.0.0", commit: "c".repeat(40), servedAt: "2026-10-01T00:00:00.000Z", subject: "Cut 1.0.0" } as Parameters<typeof releaseItem>[2];
246 const { body } = releaseItem("http://h", "alice/forge", r);
247 expect(body).toContain("<title>Released v1.0.0: Cut 1.0.0</title>");
248 expect(body).toContain('href="http://h/changelog"');
249 expect(body).not.toContain("<category");
250 });
251
241252 test("the page links it", async () => {
242253 const html = await (await fetch(`${servers.url}/changelog`)).text();
243254 expect(html).toMatch(/rel="alternate"\s+type="application\/atom\+xml"[^>]*href="\/changelog\.atom"/);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs