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
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15977-changelog-advertises-its-atom-feed-for-a → main 0 commits fork 2 threads · 2 unresolved
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 | ||
| 38 | 38 | |
| 39 | 39 | ## As a feed (#8213) |
| 40 | 40 | |
| 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"`. | |
| 42 | 42 | |
| 43 | 43 | 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. |
| 44 | 44 |
src/web/feeds.ts +13 −6
| @@ -258,17 +258,23 @@ interface FeedItem { | ||
| 258 | 258 | * as `/api/v1/changelog` lists it under `releases`. Its id names the repository and version, so |
| 259 | 259 | * a tag read twice is one entry to a reader. |
| 260 | 260 | */ |
| 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; | |
| 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}`)}"/>`; | |
| 264 | 270 | return { |
| 265 | 271 | at: r.servedAt, |
| 266 | 272 | body: ` <entry> |
| 267 | 273 | <id>urn:forge:release:${xml(`${r.repo}@${r.version}`)}</id> |
| 268 | 274 | <title>${xml(`Released v${r.version}${said}`)}</title> |
| 269 | 275 | <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> | |
| 272 | 278 | </entry>`, |
| 273 | 279 | }; |
| 274 | 280 | } |
| @@ -337,6 +343,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> { | ||
| 337 | 343 | <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. |
||
| 338 | 344 | <updated>${xml(stamp(l.at))}</updated> |
| 339 | 345 | <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}`)}"/> | |
| 340 | 347 | <summary>${xml(summary)}</summary> |
| 341 | 348 | </entry>` }]; |
| 342 | 349 | } |
| @@ -352,7 +359,7 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> { | ||
| 352 | 359 | <summary>${xml(`Landed in ${l.repo} as pull #${l.number} on ${stamp(l.at).slice(0, 10)} and is live.`)}</summary> |
| 353 | 360 | </entry>` }]; |
| 354 | 361 | }); |
| 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))] | |
| 356 | 363 | .sort((a, b) => Date.parse(stamp(b.at)) - Date.parse(stamp(a.at))) |
| 357 | 364 | .slice(0, CHANGELOG_ENTRIES); |
| 358 | 365 | 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"; | ||
| 17 | 17 | import { serve, type Servers } from "../src/http/server.ts"; |
| 18 | 18 | import { BOOTED } from "../src/release/gate.ts"; |
| 19 | 19 | import { gitAt } from "./helpers/plain-git.ts"; |
| 20 | import { writeWave } from "../src/story/wave.ts"; | |
| 20 | 21 | import { checkAtom } from "./helpers/atom.ts"; |
| 21 | 22 | |
| 22 | 23 | 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", () => { | ||
| 47 | 48 | const work = join(data, "work"); |
| 48 | 49 | await Bun.$`mkdir -p ${work}`.quiet(); |
| 49 | 50 | 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"); | |
| 51 | 63 | tagged = gitAt(work, ["rev-parse", "HEAD"], "2026-11-20T10:00:00Z"); |
| 52 | 64 | // As scripts/cut-release.ts cuts it: annotated, the message its JSON record. |
| 53 | 65 | 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", () => { | ||
| 69 | 81 | const entries = entriesOf(text); |
| 70 | 82 | expect(entries.length).toBe(1); |
| 71 | 83 | 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"`); | |
| 73 | 87 | expect(entries[0]).toContain(`commit ${tagged.slice(0, 7)}`); |
| 74 | 88 | expect(entries[0]).toContain("<updated>2026-11-20T10:00:00.000Z</updated>"); |
| 75 | 89 | // 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"; | ||
| 13 | 13 | import { feedEpoch } from "../src/core/feed_epoch.ts"; |
| 14 | 14 | import { getRepo } from "../src/core/repos.ts"; |
| 15 | 15 | import { writeWave } from "../src/story/wave.ts"; |
| 16 | import { releaseItem } from "../src/web/feeds.ts"; | |
| 16 | 17 | import { checkAtom } from "./helpers/atom.ts"; |
| 17 | 18 | import { serve, type Servers } from "../src/http/server.ts"; |
| 18 | 19 | |
| @@ -226,6 +227,8 @@ describe("GET /changelog.atom", () => { | ||
| 226 | 227 | const { titles } = checkAtom(text, `${servers.url}/changelog.atom`); |
| 227 | 228 | expect(titles).toEqual(["Faster <b>feeds</b> & more", "Went live: j/k, enter, esc and ? on pulls"]); |
| 228 | 229 | 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"/>'); | |
| 229 | 232 | expect(text).toContain("<summary>Thing 1 <x>: because & so"); |
| 230 | 233 | expect(text).toContain("Faster <b>feeds</b> & more"); |
| 231 | 234 | expect(text).not.toContain("<b>"); |
| @@ -238,6 +241,14 @@ describe("GET /changelog.atom", () => { | ||
| 238 | 241 | expect((await fell.text())).toContain("Went live: Fix <&> escaping"); |
| 239 | 242 | }); |
| 240 | 243 | |
| 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 | ||
| 241 | 252 | test("the page links it", async () => { |
| 242 | 253 | const html = await (await fetch(`${servers.url}/changelog`)).text(); |
| 243 | 254 | expect(html).toMatch(/rel="alternate"\s+type="application\/atom\+xml"[^>]*href="\/changelog\.atom"/); |
new above
offline
Principle 8 and clean code: two nested ternaries on one long line each. Name the wave link and the wave title as consts.