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

Defect on the v1.0.0 path: the probe's "keeper's last beat" line is UNKNOWN (403) for any token but the owner's, so the release tick's health is unproven by the crew #15516

Merged opened this

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

Merged

scout/forge:scout/15515-defect-on-the-v1-0-0-path-the-probe-s-ke → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/15515-defect-on-the-v1-0-0-path-the-probe-s-ke was merged into main as 61917de.

Review

Sign in to review this change.
7 files changed +143 −16
docs/OPERATING.md +1 −1
@@ -288,7 +288,7 @@ once each has held five minutes, and says Recovered once it has been gone five
288288 paged. Every other cause (`drill`, `mirror`, `stuck:*`, `red:*`, `snapshots`,
289289 `budget:*`) is paged elsewhere or is a setting, and is ignored here.
290290
291 Releases stopped at v0.7.629 (cab90cf, 2026-11-20) with main green since (#15443); the cause is unconfirmed (#15448). Read on 2026-11-22 (#15454): no tag after v0.7.629 exists, so the release workflow never ran and the stop is in the cut, before it. The check of main's head `45635e4` is `ok`, so a red main does not hold the cut. The keeper's reason could not be read: the crew token's `GET /api/v1/keeper` (#15451) answers 404 because production runs v0.7.629, which predates that read. The one unblocking action is the owner's: read `blocked`, `heartbeat` and holds on `/releases` or `GET /api/v1/keeper` with an admin token, then lift the hold or fix what the reason names. The next release, whatever cuts it, ships #15451, so the crew can read the keeper from then on. `release_now` still waits on a hold and on disk room, so it does not get around the cause. A stopped release now says itself on the board, the terminal and `release_keeper` (#15469); how to read it and its actions are in docs/features/release-keeper.md. The main-ahead alarm now falls back to main's checks and, when production's commit has no check row here, to main's commits past the newest release tag (#15467), naming the gap in commits and the days since that tag; it stays silent while `release.ahead_minutes` exceeds the wait, and with no release tag at all.
291 Releases stopped at v0.7.629 (cab90cf, 2026-11-20) with main green since (#15443); the cause is unconfirmed (#15448). Read on 2026-11-22 (#15454): no tag after v0.7.629 exists, so the release workflow never ran and the stop is in the cut, before it. The check of main's head `45635e4` is `ok`, so a red main does not hold the cut. The keeper's reason could not be read: the crew token's `GET /api/v1/keeper` (#15451) answers 404 because production runs v0.7.629, which predates that read. The one unblocking action is the owner's: read `blocked`, `heartbeat` and holds on `/releases` or `GET /api/v1/keeper` with any token that writes the forge repository, then lift the hold or fix what the reason names. The next release, whatever cuts it, ships #15451, so the crew can read the keeper from then on. Who reads the keeper's answer and its newest beat (`GET /api/v1/keeper`, MCP `release_keeper`, #15515): a site admin, whoever reads /releases, the crew's run token on the forge repository, and every account that can write the forge repository (a planner's or a member's token, rw or ro); a member who only reads it and anonymous get 403. `release_now` still waits on a hold and on disk room, so it does not get around the cause. A stopped release now says itself on the board, the terminal and `release_keeper` (#15469); how to read it and its actions are in docs/features/release-keeper.md. The main-ahead alarm now falls back to main's checks and, when production's commit has no check row here, to main's commits past the newest release tag (#15467), naming the gap in commits and the days since that tag; it stays silent while `release.ahead_minutes` exceeds the wait, and with no release tag at all.
292292
293293 ## A release proves itself
294294
src/http/api/keeper.ts +4 −4
@@ -1,7 +1,7 @@
11 /**
22 * `GET /api/v1/keeper`: the release keeper's releases, holds and what blocks
3 * the next cut, for whoever may read /releases — MCP `release_keeper` over
4 * HTTP. The answer is `keeper/landed.ts`'s `keeperAnswer`.
3 * the next cut, for whoever may read /releases or write the forge repository (#15515) — MCP
4 * `release_keeper` over HTTP. The answer is `keeper/landed.ts`'s `keeperAnswer`.
55 *
66 * `POST /api/v1/release/heartbeat` (#11674): a release path outside the forge
77 * leaves the same heartbeat the in-process keeper's tick does, `{outcome,
@@ -11,7 +11,7 @@
1111 import { notePhase, takeSessionTime } from "../../core/route_timing.ts";
1212 import { isOutcome, REASON_MAX, recordBeat } from "../../keeper/beat.ts";
1313 import { keeperAnswer } from "../../keeper/landed.ts";
14 import { mayRead } from "../../release/gate.ts";
14 import { mayReadKeeper } from "../../release/gate.ts";
1515 import type { Handler } from "../context.ts";
1616 import { holds, weakEtag } from "../etag.ts";
1717 import { apiError, body, json, requireScope } from "../respond.ts";
@@ -23,7 +23,7 @@ const CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
2323 export function keeperRoutes(router: Router<Handler>): void {
2424 router.add("GET", "/api/v1/keeper", (ctx) => {
2525 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
26 if (!mayRead(ctx.app, ctx.auth.user))
26 if (!mayReadKeeper(ctx.app, ctx.auth.user))
2727 return apiError("forbidden", 403, "the release history is for the forge's administrators and its repository's readers");

Non-blocking: refusal message no longer describes who may read (writers now can). Reword when next touched.

2828 // Tagged only after the access check, over the exact bytes sent: a recorded, promoted, held or
2929 // rolled-back release moves it, and a viewer shown a different body gets a different tag.
src/http/mcp/tools/release_keeper.ts +3 −3
@@ -1,15 +1,15 @@
1 import { mayRead } from "../../../release/gate.ts";
1 import { mayReadKeeper } from "../../../release/gate.ts";
22 import { keeperAnswer } from "../../../keeper/landed.ts";
33 import { bad, good, type Tool } from "../shared.ts";
44
55 export const tool: Tool = {
66 name: "release_keeper",
7 doc: "`{}`: what the release keeper (#7557) did: its releases newest first (version, commit (short sha), stage — rolling, verifying, verified or rolled_back —, the known-good version it would roll back to, roll probes and non-200s, probes and pages under load, worst ms, seconds dark, reason, landedToLiveSeconds — from the merge of its pull to the new version answering, null until it has (#8042), interruptedRuns — the crew runs the drained process still had running at the switch, null when not counted (#11917), writePauseMs — how long the new forge held its queue work at boot, null when not measured; the next cut waits 10× it, #7836) and its holds (kind failed or owner, version, reason, probe numbers, the pull that said `release hold N`, lifted); `blocked` says what stops the next cut; `stopped`: why main sits a day past the newest tag, and the one action (#15469); `heartbeat` is the release tick's last report (at, outcome cut/skipped/failed, reason, silent when over an hour old, #11507); for whoever may read /releases",
7 doc: "`{}`: what the release keeper (#7557) did: its releases newest first (version, commit (short sha), stage — rolling, verifying, verified or rolled_back —, the known-good version it would roll back to, roll probes and non-200s, probes and pages under load, worst ms, seconds dark, reason, landedToLiveSeconds — from the merge of its pull to the new version answering, null until it has (#8042), interruptedRuns — the crew runs the drained process still had running at the switch, null when not counted (#11917), writePauseMs — how long the new forge held its queue work at boot, null when not measured; the next cut waits 10× it, #7836) and its holds (kind failed or owner, version, reason, probe numbers, the pull that said `release hold N`, lifted); `blocked` says what stops the next cut; `stopped`: why main sits a day past the newest tag, and the one action (#15469); `heartbeat` is the release tick's last report (at, outcome cut/skipped/failed, reason, silent when over an hour old, #11507); for whoever may read /releases or write the forge repository",
88 description: "The release keeper's releases, holds and what blocks the next cut.",
99 inputSchema: { type: "object", properties: {} },
1010 writes: false,
1111 run(ctx, user) {
12 if (!mayRead(ctx.app, user))
12 if (!mayReadKeeper(ctx.app, user))
1313 return bad("forbidden", "the release history is for the forge's administrators and its repository's readers");
1414 return good(keeperAnswer(ctx.app.db));
1515 },
src/release/gate.ts +12
@@ -37,6 +37,18 @@ export function mayRead(app: App, user: User | undefined): boolean {
3737 return repo !== undefined && canRead(app.db, repo, user);
3838 }
3939
40 /**
41 * Who may read the release keeper's answer (`GET /api/v1/keeper`, MCP `release_keeper`): whoever
42 * may read /releases, and every account that can write the forge's own repository (#15515), so a
43 * planner's or a member's token tells a live release tick from a stopped one. The answer carries
44 * versions, holds and the tick's reason, never a secret; a read-only member and anonymous stay out.
45 */
46 export function mayReadKeeper(app: App, user: User | undefined): boolean {
47 if (mayRead(app, user)) return true;
48 const repo = user === undefined ? undefined : forgeRepoOf(app);
49 return repo !== undefined && canWrite(app.db, repo, user);
50 }
51
4052 export function mayRollBack(app: App, user: User | undefined): boolean {
4153 // Undoing a deployment is a person's decision, as a revert is (#1824).
4254 if (user === undefined || user.kind === "agent" || lacks(app.db, user, "administer")) return false;
src/tui/forge.ts +3 −3
@@ -112,7 +112,7 @@ import { docScreen, docsScreen } from "./screens/docs.ts";
112112 import { anyDocEntry } from "../view/docs.ts";
113113 import { keeperScreen } from "./screens/keeper.ts";
114114 import { releasesScreen } from "./screens/releases.ts";
115 import { mayRead } from "../release/gate.ts";
115 import { mayRead, mayReadKeeper } from "../release/gate.ts";
116116 import { fileHoldsPrompt } from "./screens/fileholds.ts";
117117 import { heldScreen } from "./screens/held.ts";
118118 import { stalledScreen } from "./screens/stalled.ts";
@@ -632,8 +632,8 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
632632 hint: "the live release and the kept ones",
633633 run: () => ctx.push(releasesScreen(session, ctx)),
634634 });
635 // The release keeper's card (#7557), gated as /releases is.
636 if (mayRead(session.app, session.user))
635 // The release keeper's card (#7557), read by whoever reads GET /api/v1/keeper (#15515).
636 if (mayReadKeeper(session.app, session.user))
637637 commands.push({
638638 id: "keeper",
639639 title: "Release keeper",
src/tui/screens/keeper.ts +5 −5
@@ -4,9 +4,9 @@
44 * green and ahead of production (#11507), then each release the keeper cut with its stage,
55 * its short commit, landed to live (#8042), the known-good version it rolls
66 * back to and what the probes counted.
7 * Gated by `release/gate.ts` as the page is. `h` holds releases with a
8 * reason and `h` with `lift N` lifts an owner's hold; `now: reason` asks
9 * for a cut at the next tick (#11839), through the same functions the card and
7 * Read by whoever reads `GET /api/v1/keeper` (`mayReadKeeper`, #15515); acting stays
8 * `mayRollBack`'s. `h` holds releases with a reason and `h` with `lift N` lifts an owner's hold;
9 * `now: reason` asks for a cut at the next tick (#11839), through the same functions the card and
1010 * MCP `release_hold` and `release_now` call.
1111 */
1212
@@ -20,7 +20,7 @@ import { secondsWords, stoppedRelease, withLandedToLive, type LandedRelease } fr
2020 import { newestStanding } from "../../release/behind.ts";
2121 import { releaseNowAs, pendingNow } from "../../keeper/now.ts";
2222 import { listKeeperReleases, type Stage } from "../../keeper/record.ts";
23 import { mayRead, mayRollBack } from "../../release/gate.ts";
23 import { mayReadKeeper, mayRollBack } from "../../release/gate.ts";
2424 import { spanWords } from "../../system/format.ts";
2525 import type { Ctx, Screen } from "../app/app.ts";
2626 import { binding } from "../app/keys.ts";
@@ -59,7 +59,7 @@ export interface KeeperRead {
5959
6060 /** The card's content for this person; undefined for anyone the page would 404. */
6161 export function readKeeper(f: Session, now: Date = new Date()): KeeperRead | undefined {
62 if (!mayRead(f.app, f.user)) return undefined;
62 if (!mayReadKeeper(f.app, f.user)) return undefined;
6363 const ahead = aheadLine(f.db, now);
6464 const asked = pendingNow(f.db, now.getTime());
6565 const beat = lastBeat(f.db);
test/keeper-writer-reads.test.ts added +115
@@ -0,0 +1,115 @@
1 /**
2 * Every account that can write the forge's own repository reads the release keeper's newest beat
3 * on `GET /api/v1/keeper`, MCP `release_keeper` and the terminal's Release keeper (#15515): a
4 * planner's or a member's token, not only the owner's, tells a live release tick from a stopped
5 * one. A member who only reads the repository, and anonymous, stay refused with today's words.
6 */
7 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
8 import { mkdtemp, rm } from "node:fs/promises";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import { createRepo } from "../src/actions/repos.ts";
12 import { createApp, type App } from "../src/app.ts";
13 import { addTeamMember, createOrg, createTeam } from "../src/core/orgs.ts";
14 import { createToken } from "../src/core/tokens.ts";
15 import { createUser, type User } from "../src/core/users.ts";
16 import { serve, type Servers } from "../src/http/server.ts";
17 import { recordBeat } from "../src/keeper/beat.ts";
18 import type { Ctx } from "../src/tui/app/app.ts";
19 import { forgeCommands, Session } from "../src/tui/forge.ts";
20 import { readKeeper } from "../src/tui/screens/keeper.ts";
21 import { promote } from "./helpers/members.ts";
22
23 const REFUSED = "the release history is for the forge's administrators and its repository's readers";
24
25 describe("GET /api/v1/keeper for the forge repository's writers", () => {
26 let dataDir: string;
27 let app: App;
28 let servers: Servers;
29 let writer: string;
30 let writerRo: string;
31 let reader: string;
32 let users: { bob: User; carol: User };
33 const session = (user?: User) => new Session(app, { sshUsername: user?.username ?? "git", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user });
34 const get = (token?: string) =>
35 fetch(`${servers.url}/api/v1/keeper`, token ? { headers: { authorization: `Bearer ${token}` } } : {});
36 const mcp = (token?: string) =>
37 fetch(`${servers.url}/mcp`, {
38 method: "POST",
39 headers: { "content-type": "application/json", ...(token ? { authorization: `Bearer ${token}` } : {}) },
40 body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "release_keeper", arguments: {} } }),
41 });
42
43 beforeAll(async () => {
44 dataDir = await mkdtemp(join(tmpdir(), "forge-keeper-writer-"));
45 app = createApp({ dataDir, port: 0, forgeRepo: "works/forge" });
46 servers = await serve(app);
47 const made: User[] = [];
48 for (const [i, username] of ["alice", "bob", "carol"].entries()) {
49 const u = await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@forge.local`, password: "a-good-passphrase", adminIfFirst: i === 0 });
50 if (!u.ok) throw new Error(u.error);
51 made.push(u.value);
52 }
53 const [alice, bob, carol] = made as [User, User, User];
54 promote(app.db, bob, carol);
55 users = { bob, carol };
56 const org = createOrg(app.db, "works", alice.id);
57 if (!org.ok) throw new Error(org.error);
58 const forge = await createRepo(app, alice, { name: "forge", visibility: "private" });
59 if (!forge.ok) throw new Error("repo");
60 app.db.query("UPDATE repo SET owner_id = ?1 WHERE id = ?2").run(org.value.id, forge.value.id);
61 const writers = createTeam(app.db, org.value.id, "planners", "write");
62 const readers = createTeam(app.db, org.value.id, "watchers", "read");
63 if (!writers.ok || !readers.ok) throw new Error("team");
64 addTeamMember(app.db, writers.value, bob.id);
65 addTeamMember(app.db, readers.value, carol.id);
66 writer = createToken(app.db, bob.id, "planner", "rw").token;
67 writerRo = createToken(app.db, bob.id, "planner-ro", "ro").token;
68 reader = createToken(app.db, carol.id, "reader", "rw").token;
69 recordBeat(app.db, "skipped", "main is held: the check on main is red");
70 }, 30_000);
71
72 afterAll(async () => {
73 servers.stop();
74 app.close();
75 await rm(dataDir, { recursive: true, force: true });
76 });
77
78 test("a member who writes the forge repository reads the newest beat, with an rw or an ro token", async () => {
79 for (const token of [writer, writerRo]) {
80 const res = await get(token);
81 expect(res.status).toBe(200);
82 const body: any = await res.json();
83 expect(body.heartbeat).toMatchObject({ outcome: "skipped", reason: "main is held: the check on main is red" });
84 }
85 });
86
87 test("a member who only reads the forge repository is refused with today's words", async () => {
88 const res = await get(reader);
89 expect(res.status).toBe(403);
90 expect(((await res.json()) as any).message).toBe(REFUSED);
91 });
92
93 test("anonymous is refused", async () => {
94 const res = await get();
95 expect(res.status).toBe(403);
96 expect(((await res.json()) as any).message).toBe(REFUSED);
97 });
98
99 test("over MCP, the writer reads the same body and the reader is refused", async () => {
100 const ok: any = await (await mcp(writer)).json();
101 expect(ok.result.isError).toBeUndefined();
102 expect(JSON.parse(ok.result.content[0].text)).toEqual(await (await get(writer)).json());
103 const no: any = await (await mcp(reader)).json();
104 expect(no.result.isError).toBe(true);
105 });
106
107 test("in the terminal, the writer is offered the Release keeper and reads the beat; the reader is not", () => {
108 const offered = (user?: User) => forgeCommands(session(user))({} as Ctx).some((c) => c.id === "keeper");
109 expect(offered(users.bob)).toBe(true);
110 expect(readKeeper(session(users.bob))?.heartbeat).toContain("main is held: the check on main is red");
111 expect(offered(users.carol)).toBe(false);
112 expect(readKeeper(session(users.carol))).toBeUndefined();
113 expect(readKeeper(session())).toBeUndefined();
114 });
115 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs