Public: anyone can read this; the crew can change it.
Production's /api/v1/changelog reports the live version 1.0.0 and lists its releases #15598
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15585-production-s-api-v1-changelog-reports-th → main 0 commits fork 3 threads · 3 unresolved
src/http/api/forge_origin.ts +1 −3
| @@ -14,14 +14,12 @@ | ||
| 14 | 14 | import { listReposByOwner, visibleReposMarker, type Repo } from "../../core/repos.ts"; |
| 15 | 15 | import type { Ctx, Handler } from "../context.ts"; |
| 16 | 16 | import { limitRefusal, limitSays, pageRefusal, parseLimit, parsePage } from "../../contract/page_query.ts"; |
| 17 | import { FORGE_API_VERSION } from "../../kernel/version.ts"; | |
| 17 | 18 | import { holds, weakEtag } from "../etag.ts"; |
| 18 | 19 | import { json, unauthorized } from "../respond.ts"; |
| 19 | 20 | import type { Router } from "../router.ts"; |
| 20 | 21 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; |
| 21 | 22 | |
| 22 | /** The Gitea API generation this answers: the calls above, and no more. */ | |
| 23 | export const FORGE_API_VERSION = "1.0.0"; | |
| 24 | ||
| 25 | 23 | const PAGE_MAX = 100; |
| 26 | 24 | const OWNED_MAX = 1000; |
| 27 | 25 |
src/kernel/version.ts +16
| @@ -89,3 +89,19 @@ export function announcedVersion(r: Running = running()): string | null { | ||
| 89 | 89 | * known. |
| 90 | 90 | */ |
| 91 | 91 | export const announcedOr = (r: Running = running()): string => announcedVersion(r) ?? "unreleased"; |
| 92 | ||
| 93 | /** | |
| 94 | * The version `GET /api/v1/version` answers, and what the changelog says when the build names no | |
| 95 | * release. | |
| 96 | */ | |
| 97 | export const FORGE_API_VERSION = "1.0.0"; | |
| 98 | ||
| 99 | /** | |
| 100 | * The release a build names (`release`, null when none) and the version a probe is told | |
| 101 | * (`version`, never null: the API generation when the build names none), so the changelog's two | |
| 102 | * fields come from one place and cannot drift apart (#15585). | |
| 103 | */ | |
| 104 | export function releaseNamed(r: Running = running()): { release: string | null; version: string } { | |
| 105 | const release = releaseOf({ version: r.version, commit: r.commit }); | |
| 106 | return { release, version: releaseOf(r) ?? FORGE_API_VERSION }; | |
| 107 | } |
src/release/answer.ts +4 −3
| @@ -9,7 +9,7 @@ import { listPublicReleases } from "../core/app_releases.ts"; | ||
| 9 | 9 | import { getRepoById } from "../core/repos.ts"; |
| 10 | 10 | import { publicForgeRepo } from "../core/forge_repo.ts"; |
| 11 | 11 | import type { User } from "../core/users.ts"; |
| 12 | import { releaseOf, running, shortOf } from "../kernel/version.ts"; | |
| 12 | import { releaseNamed, running, shortOf } from "../kernel/version.ts"; | |
| 13 | 13 | import { BOOTED, mayRead } from "./gate.ts"; |
| 14 | 14 | import { withWaves } from "./chapter_waves.ts"; |
| 15 | 15 | import { chapterEntries, groupByChapter, wavesOf } from "./chapter_groups.ts"; |
| @@ -73,8 +73,9 @@ export async function shippedAnswer(app: App, asked: string | null = null) { | ||
| 73 | 73 | const tags = tagged === undefined ? [] : await publicTagReleases(app, tagged); |
| 74 | 74 | const waves = wavesOf(groupByChapter(live, await withWaves(app, chapterEntries(app.db, live, undefined)))); |
| 75 | 75 | return { |
| 76 | // The release number, or null for a build that is not one: never the word "dev". | |
| 77 | version: releaseOf({ version: read.version, commit: read.commit }), | |
| 76 | // `release` is what the build itself names, or null (the feeds name such a build by its | |
| 77 | // commit); `version` is never null, so it says what /api/v1/version says (#15585). | |
| 78 | ...releaseNamed({ ...running(), version: read.version, commit: read.commit }), | |
outdated
This line calls |
||
| 78 | 79 | commit: read.commit, |
| 79 | 80 | short: read.commit === null ? null : shortOf(read.commit), |
| 80 | 81 | liveSince: BOOTED, |
src/web/feeds.ts +2 −2
| @@ -309,9 +309,9 @@ export async function changelogAtom(ctx: Ctx): Promise<Response> { | ||
| 309 | 309 | const own = `${ownerName}/${repoName}`; |
| 310 | 310 | // A build with no version stamp is named by its commit, as /changelog names it (#15482): the |
| 311 | 311 | // generator carries it, and the tag changes with it so a cached feed never outlives a release. |
| 312 | const named = answer.version ?? answer.short; | |
| 312 | const named = answer.release ?? answer.short; | |
| 313 | 313 | const alone = live.length === 0 && releases.length === 0 && answer.commit !== null; |
| 314 | const etag = changelogTag(answer.version ?? answer.commit ?? "dev", live, [ | |
| 314 | const etag = changelogTag(answer.release ?? answer.commit ?? "dev", live, [ | |
| 315 | 315 | tip, |
| 316 | 316 | releases.map((r) => [r.repo, r.version, r.commit, r.servedAt, r.subject]), |
| 317 | 317 | alone ? answer.liveSince : "", |
test/changelog-api.test.ts +23 −1
| @@ -73,7 +73,9 @@ describe("GET /api/v1/changelog", () => { | ||
| 73 | 73 | expect(res.status).toBe(200); |
| 74 | 74 | const b: any = await res.json(); |
| 75 | 75 | expect(b.commit).toBe("a".repeat(40)); |
| 76 | expect(b.version).toBeNull(); | |
| 76 | expect(b.version).toBe("1.0.0"); | |
| 77 | const v: any = await (await fetch(`${servers.url}/api/v1/version`)).json(); | |
| 78 | expect(b.version).toBe(v.version); | |
| 77 | 79 | expect(b.short).toBe("aaaaaaa"); |
| 78 | 80 | expect(new Date(b.liveSince).toISOString()).toBe(b.liveSince); |
| 79 | 81 | const row = [...b.live, ...b.onItsWay][0]; |
| @@ -125,6 +127,26 @@ describe("GET /api/v1/changelog", () => { | ||
| 125 | 127 | } |
| 126 | 128 | }); |
| 127 | 129 | |
| 130 | test("a 500-entry release record lists its newest 50, 1.0.0 among them with its date", async () => { | |
| 131 | const repo: any = app.db.query("SELECT id FROM repo WHERE name = 'forge'").get(); | |
| 132 | const ins = app.db.query( | |
| 133 | `INSERT INTO app_release (id, repo_id, version, commit_oid, subject, note, tests, serving_ms, served_at) VALUES (?1, ?2, ?3, ?4, 's', '', 'none', NULL, ?5)`, | |
| 134 | ); | |
| 135 | try { | |
| 136 | for (let n = 0; n < 500; n++) { | |
| 137 | const version = n === 0 ? "1.0.0" : `0.${n}.0`; | |
| 138 | // 1.0.0 is dated 2026-11-20, later than every other row (all in 2026-01..09). | |
| 139 | ins.run(`r${n}`, repo.id, version, "c".repeat(40), n === 0 ? "2026-11-20T10:00:00.000Z" : `2026-0${1 + (n % 9)}-01T00:00:00.000Z`); | |
| 140 | } | |
| 141 | const b: any = await (await get("")).json(); | |
| 142 | expect(b.version).not.toBeNull(); | |
| 143 | expect(b.releases.length).toBe(50); | |
outdated
This comment is stale: nothing makes 1.0.0 the newest here beyond the dates. Also |
||
| 144 | expect(b.releases.find((r: any) => r.version === "1.0.0")?.servedAt).toBe("2026-11-20T10:00:00.000Z"); | |
| 145 | } finally { | |
| 146 | app.db.query("DELETE FROM app_release").run(); | |
| 147 | } | |
| 148 | }); | |
| 149 | ||
| 128 | 150 | test("MCP releases returns the same rows", async () => { |
| 129 | 151 | for (const repo of ["all", "alice/notes"]) { |
| 130 | 152 | const viaMcp = await mcp({ shipped: true, repo }, admin); |
test/version-etag.test.ts +1 −1
| @@ -6,7 +6,7 @@ import { join } from "node:path"; | ||
| 6 | 6 | import { createApp, type App } from "../src/app.ts"; |
| 7 | 7 | import { createToken } from "../src/core/tokens.ts"; |
| 8 | 8 | import { createUser } from "../src/core/users.ts"; |
| 9 | import { FORGE_API_VERSION } from "../src/http/api/forge_origin.ts"; | |
| 9 | import { FORGE_API_VERSION } from "../src/kernel/version.ts"; | |
| 10 | 10 | import { weakEtag } from "../src/http/etag.ts"; |
| 11 | 11 | import { serve, type Servers } from "../src/http/server.ts"; |
| 12 | 12 |
Importing a name and then re-exporting it keeps an alias that is not needed. Point the remaining importers at kernel/version.ts and drop the re-export, or keep a single
export ... from.