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

A pull's Next line says a person lands it where autonomy is off, not the queue #17719

opened this

Merged 19h 21m ago, live in production

mason/forge:mason/17570-a-pull-s-next-line-says-a-person-lands-i → main 0 commits fork 1 thread · 1 unresolved

  • Merged. mason/17570-a-pull-s-next-line-says-a-person-lands-i was merged into main as 7015bd2.

Review

Sign in to review this change.
13 files changed +88 −14
docs/features/pull-pane.md +1 −1
@@ -8,7 +8,7 @@ A pull says where it stands in one sentence, with what shows it and at most thre
88
99 - **One reader:** `src/flow/pull_pane.ts` (`pullPane`, `paneOf`) reads the facts the flow already trusts: who acts next (`nextOfPull`, which carries a hold), the head's check and its place in the queue, the crew's unfinished run on the pull, and whether production has served since a merge.
1010 - **Three doors, one sentence:** the pull page (both tabs, under the title, `src/web/studio/pane.ts`), the terminal's pull screen, and the peek card that a link to a pull shows on hover. Each prints the same sentence.
11 - **States:** draft, held, conflict, building, checking, red, changes asked, a person decides, waits for a review, ready, merged, closed. `test/pull-pane.test.ts` holds each one's sentence, verbs and evidence.
11 - **States:** draft, held, conflict, building, checking, red, changes asked, a person decides, waits for a review, ready, merged, closed. Ready also shows, with Merge and Close, when a green pull has no queue to land it (the repository's autonomy is off, #16452): the Next line reads "a person lands it". `test/pull-pane.test.ts` holds each one's sentence, verbs and evidence.
1212 - **Verbs** go through the doors the acts already have:
1313 - a run's stop and queue again post to the run's routes;
1414 - update and close post to the pull's routes;
docs/features/reviews-off-lands-on-green.md +2 −2
@@ -4,7 +4,7 @@ row: Reviews are something an owner turns on
44 ---
55 # Reviews are something an owner turns on (#11666)
66
7 A green pull in an app whose owner has **not** asked for reviews, and where no reviewer is seated, lands by itself. No review is sent and nothing waits for one.
7 A green pull in an app whose owner has **not** asked for reviews, and where no reviewer is seated, lands by itself where the app's autonomy is on. No review is sent and nothing waits for one. Where autonomy is off no queue lands anything: the pull reads "green, reviews are off: a person lands it" and a person merges it.
88
99 **This changes the default.** Before, a green agent pull with no reviewer seated waited for a person forever. Now, with **Require review** off (the default) and no reviewer on the crew, it lands once its check passes. A new forge's first app has reviews off, so its first change goes live on green. An owner who wants a second look before anything lands turns reviews on, as below.
1010
@@ -17,7 +17,7 @@ Either one keeps every agent pull waiting for an approving review:
1717
1818 ## What still stops a pull with reviews off
1919
20 A conflict, a red check, a hold, the access wall, and a `changes requested` verdict on the head. Only the wait for a review is gone. The pull's page, the terminal and the MCP `pull` tool read "Next: queue, green, reviews are off: it lands".
20 A conflict, a red check, a hold, the access wall, and a `changes requested` verdict on the head. Only the wait for a review is gone. The pull's page, the terminal and the MCP `pull` tool read "Next: queue, green, reviews are off: it lands" where autonomy is on, and "Next: person, green, reviews are off: a person lands it" where it is off (#16452).
2121
2222 ## One rule
2323
src/flow/landing_line.ts +9 −1
@@ -9,6 +9,7 @@
99
1010 import type { Database } from "bun:sqlite";
1111 import { etaSays, landingEta } from "./landing_eta.ts";
12 import { noQueueLands } from "./next_actor.ts";
1213 import { median } from "./pipeline.ts";
1314
1415 const HOUR_MS = 3_600_000;
@@ -19,7 +20,10 @@ export interface LandingLine {
1920 readonly says: string;
2021 }
2122
22 /** The pull's estimate, or null when it is not an open, approved, unlanded pull. */
23 /**
24 * The pull's estimate, or null when it is not an open, approved, unlanded pull or no queue lands
25 * here.
26 */
2327 export function landingLine(
2428 db: Database,
2529 pull: { readonly id: string; readonly number: number; readonly state: string; readonly mergedAt: string | null },
@@ -28,6 +32,10 @@ export function landingLine(
2832 ): LandingLine | null {
2933 if (pull.state !== "open" || pull.mergedAt !== null) return null;
3034 // Open approved pulls, each by its latest approval with no changes-requested after it.
35 // No queue lands here, so there is no place in one to say: the pull's Next line says a person
36 // does (#16452).
37 const repo = db.query<{ autonomy: string; autonomyBy: string | null }, [string]>("SELECT autonomy, autonomy_by AS autonomyBy FROM repo WHERE id = ?1").get(repoId);
38 if (repo === null || noQueueLands(repo)) return null;
3139 const approved = db
3240 .query<{ id: string; number: number; at: string }, [string]>(
3341 `SELECT i.id AS id, i.number AS number, a.at AS at
src/flow/next_actor.ts +31 −5
@@ -25,6 +25,11 @@ export interface Next {
2525 * Set when a reviewer's asked-for changes on this head are the reason (the pane's own state too).
2626 */
2727 readonly changes?: true;
28 /**
29 * Set when it is ready and only a person's merge lands it (`personLands`): the pane still offers
30 * Merge.
31 */
32 readonly lands?: true;
2833 }
2934
3035 export interface NextInput {
@@ -45,6 +50,17 @@ export interface NextInput {
4550 readonly firstChange?: boolean;
4651 /** Who asked for changes on this head, and which review (`blockingReviewWords`). */
4752 readonly askedBy?: string | null;
53 /**
54 * No merge queue lands here: the repository's autonomy is not `autonomous` (or no one
55 * turned it on), so `land_admit.ts` answers `off` and a green pull waits for a person to
56 * land it (#16452). Unset reads as a queue that lands.
57 */
58 readonly personLands?: boolean;
59 }
60
61 /** No merge queue lands in this repository: `land_admit.ts` answers `off` (#16452). */
62 export function noQueueLands(repo: { readonly autonomy: string; readonly autonomyBy: string | null }): boolean {
63 return repo.autonomy !== "autonomous" || repo.autonomyBy === null;
4864 }
4965
5066 const WAITING = {
@@ -60,7 +76,10 @@ export function nextActor(i: NextInput): Next {
6076 if (i.conflicted) return { who: "builder", why: "it conflicts with its base" };
6177 if (i.changesRequested > 0 && i.firstChange === true && i.check !== "failed") {
6278 if (i.wall != null && i.wall.length > 0) return { who: "person", why: wallAsk(i.wall) };
63 if (i.check === "ok") return { who: "queue", why: "green, the app's first change: it lands" };
79 if (i.check === "ok")
80 return i.personLands === true
81 ? { who: "person", why: "green, the app's first change: a person lands it", lands: true }
82 : { who: "queue", why: "green, the app's first change: it lands" };
6483 return { who: "queue", why: WAITING[i.check] };
outdated

Split this long line. The first-change branch above (line 74) needs the same personLands switch.

6584 }
6685 if (i.changesRequested > 0)
@@ -68,11 +87,17 @@ export function nextActor(i: NextInput): Next {
6887 if (i.check === "failed") return { who: "builder", why: "its check is red" };
6988 if (i.wall != null && i.wall.length > 0) return { who: "person", why: wallAsk(i.wall) };
7089 if (i.approvals > 0) {
71 if (i.check === "ok") return { who: "queue", why: "approved and green" };
90 if (i.check === "ok")
91 return i.personLands === true
92 ? { who: "person", why: "approved and green: a person lands it", lands: true }
93 : { who: "queue", why: "approved and green" };
7294 return { who: "queue", why: `approved, ${WAITING[i.check]}` };
7395 }
7496 if (i.reviewOff === true) {
75 if (i.check === "ok") return { who: "queue", why: "green, reviews are off: it lands" };
97 if (i.check === "ok")
98 return i.personLands === true
99 ? { who: "person", why: "green, reviews are off: a person lands it", lands: true }
100 : { who: "queue", why: "green, reviews are off: it lands" };
76101 return { who: "queue", why: i.check === "none" ? "no check yet" : WAITING[i.check] };
77102 }
78103 return {
@@ -96,8 +121,8 @@ export function nextOfPull(
96121 db: Database,
97122 pull: Pull,
98123 live: { readonly headOid: string; readonly conflicts: number },
99 /** The pull's repository; without one, reviews count as asked for. */
100 repo: Pick<Repo, "id" | "requireReview"> | undefined,
124 /** The pull's repository; without one, reviews count as asked for and a queue as landing. */
125 repo: Pick<Repo, "id" | "requireReview" | "autonomy" | "autonomyBy"> | undefined,
101126 /** The head's check, when the caller already read it for `live.headOid`. */
102127 known?: CheckSummary,
103128 ): Next | null {
@@ -115,6 +140,7 @@ export function nextOfPull(
115140 wall: wallWords(db, pull.id, live.headOid),
116141 askedBy: reviews.changesRequested > 0 ? blockingReviewWords(db, pull.id, live.headOid) : null,
117142 firstChange: reviews.changesRequested > 0 && repo !== undefined && isFirstChange(db, repo, pull),
143 personLands: repo !== undefined && noQueueLands(repo),
118144 },
119145 () => repo !== undefined && reviewsOff(db, repo),
120146 );
src/flow/pull_pane.ts +3 −1
@@ -132,6 +132,8 @@ export function paneOf(f: PaneFacts): Pane {
132132 };
133133 if (n === null) return { state: "waits", tone: undefined, sentence: "Waiting", verbs: [], evidence: [] };
134134 const green = c.state === "ok" ? "Green" : c.state === "cancelled" ? "Its check was cancelled" : "No check yet";
135 // Ready, and no queue lands it here (autonomy is off, #16452): the person merges.
136 if (n.lands === true) return { state: "ready", tone: "success", sentence: cap(n.why), verbs: ["merge", "close"], evidence: [] };
135137 if (n.who === "person") return { state: "decide", tone: "attn", sentence: cap(n.why), verbs: [], evidence: [] };
136138 if (n.who === "queue")
137139 return {
@@ -154,7 +156,7 @@ export function paneOf(f: PaneFacts): Pane {
154156 */
155157 export function pullPane(
156158 db: Database,
157 repo: Pick<Repo, "id" | "requireReview" | "defaultBranch">,
159 repo: Pick<Repo, "id" | "requireReview" | "defaultBranch" | "autonomy" | "autonomyBy">,
158160 pull: Pull,
159161 live: { readonly headOid: string; readonly conflicts: readonly string[] },
160162 now: Date = new Date(),
src/flow/waits_for.ts +1 −1
@@ -22,7 +22,7 @@ import { nextOfPull, type Next } from "./next_actor.ts";
2222 */
2323 export function pullWaitsFor(
2424 db: Database,
25 repo: Pick<Repo, "id" | "requireReview">,
25 repo: Pick<Repo, "id" | "requireReview" | "autonomy" | "autonomyBy">,
2626 pull: Pull,
2727 live: { readonly headOid: string; readonly conflicts: number },
2828 now: Date = new Date(),
test/landing-line.test.ts +1
@@ -52,6 +52,7 @@ beforeAll(async () => {
5252 const made = await createRepo(app, alice, { name: "site", visibility: "public" });
5353 if (!made.ok) throw new Error(String(made.error));
5454 repo = made.value;
55 app.db.query("UPDATE repo SET autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1").run(repo.id, alice.id); // a queue that lands (#16452)
5556 await commitToBranch(app, alice, repo, { message: "seed", files: [{ path: "README.md", content: "# site\n" }] });
5657 addToCrew(app, alice, repo, "bot");
5758 await commitToBranch(app, alice, repo, {
test/mcp-flow-why.test.ts +7 −2
@@ -294,8 +294,13 @@ describe("MCP flow about a pull", () => {
294294 "INSERT INTO review (id, issue_id, author_id, state, commit_oid, created_at) VALUES ('rvw', ?1, ?2, 'approved', ?3, ?4)",
295295 [p.id, bot.id, live, new Date().toISOString()],
296296 );
297 // Before the wall speaks it reads as the queue's, as it always did.
298 expect(await call({ repo: "alice/lib", pull: n })).toMatchObject({ next: { who: "queue" } });
297 // Before the wall speaks it waits for a person's merge: autonomy is off here, so no queue lands
298 // it (#16452).
299 expect(await call({ repo: "alice/lib", pull: n })).toMatchObject({ next: { who: "person", why: "approved and green: a person lands it", lands: true } });
300 // Where autonomy is on, the queue lands it.
301 app.db.query("UPDATE repo SET autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1").run(repo.id, alice.id);
302 expect(await call({ repo: "alice/lib", pull: n })).toMatchObject({ next: { who: "queue", why: "approved and green" } });
303 app.db.query("UPDATE repo SET autonomy = 'off', autonomy_by = NULL WHERE id = ?1").run(repo.id);
299304 app.db.run(
300305 "INSERT INTO decision (id, kind, repo_id, issue_id, state, answer, p, by, ms) VALUES ('dw', 'land', ?1, ?2, ?3, 'wall', 1, 'wall', 0)",
301306 [repo.id, p.id, JSON.stringify({ head: live, cells: ["pack.read as anon: new, and yes"], plain: ["anyone signed out could read pack records"] })],
test/next_actor.test.ts +23
@@ -31,6 +31,9 @@ const cases: [string, Partial<NextInput>, Actor, string][] = [
3131 ["reviews off, running", { check: "running", reviewOff: true }, "queue", "its check is running"],
3232 ["reviews off, changes asked", { changesRequested: 1, check: "ok", reviewOff: true }, "builder", "changes were asked on this head"],
3333 ["reviews off, red", { check: "failed", reviewOff: true }, "builder", "its check is red"],
34 // No queue lands where autonomy is off (#16452): a ready pull waits for a person's merge.
35 ["person lands, approved, running", { approvals: 1, check: "running", personLands: true }, "queue", "approved, its check is running"],
36 ["person lands, red", { approvals: 1, check: "failed", personLands: true }, "builder", "its check is red"],
3437 ];
3538
3639 describe("nextActor", () => {
@@ -57,3 +60,23 @@ describe("nextAsking (#11666)", () => {
5760 expect(nextAsking({ ...base, check: "ok" }, () => false)).toEqual({ who: "reviewer", why: "no review yet" });
5861 });
5962 });
63
64 describe("nextActor where no queue lands (#16452)", () => {
65 test("approved and green: a person lands it", () => {
66 expect(nextActor({ ...base, approvals: 1, check: "ok", personLands: true })).toEqual({ who: "person", why: "approved and green: a person lands it", lands: true });
67 });
68 test("the app's first change, green: a person lands it", () => {
69 expect(nextActor({ ...base, changesRequested: 1, firstChange: true, check: "ok", personLands: true })).toEqual({
70 who: "person",
71 why: "green, the app's first change: a person lands it",
72 lands: true,
73 });
74 });
75 test("reviews off and green: a person lands it", () => {
76 expect(nextActor({ ...base, check: "ok", reviewOff: true, personLands: true })).toEqual({
77 who: "person",
78 why: "green, reviews are off: a person lands it",
79 lands: true,
80 });
81 });
82 });
test/pull-next-tui.test.ts +4
@@ -99,6 +99,10 @@ test("with reviews off, a green pull's screen says it lands by itself, as the pa
9999 const run = createRun(app.db, { repoId: topic.repo.id, kind: "check", issueId: topic.pull.id, commitOid: topic.pull.headOid });
100100 claimRun(app.db, run.id);
101101 finishRun(app.db, run.id, { state: "ok", summary: "green" });
102 // Autonomy is off: no queue lands it, a person does (#16452).
103 const off = await screenSaying(topic, "Green, reviews are off: a person lands it");
104 if (off.includes("waits for a review")) throw new Error(off);
105 app.db.query("UPDATE repo SET autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1").run(topic.repo.id, alice.id);
102106 const text = await screenSaying(topic, "Green, reviews are off: it lands");
103107 if (text.includes("waits for a review")) throw new Error(text);
104108 });
test/pull-waits-for.test.ts +3 −1
@@ -109,7 +109,9 @@ describe("read from the rows", () => {
109109 alice = made.value;
110110 const r = await createRepo(app, alice, { name: "app", visibility: "public" });
111111 if (!r.ok) throw new Error("no repo");
112 app.db.query("UPDATE repo SET require_review = 1 WHERE id = ?1").run(r.value.id);
112 // Autonomous, so an approved green pull is the queue's to land (off, a person lands it:
113 // #16452).
114 app.db.query("UPDATE repo SET require_review = 1, autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1").run(r.value.id, alice.id);
113115 repo = getRepoById(app.db, r.value.id)!;
114116 review = greenPull(8).number;
115117 const q = greenPull(9);
test/repo-bound-reads.test.ts +2
@@ -104,6 +104,8 @@ test("an issue's spend is its own, read from the usage index", () => {
104104 });
105105
106106 test("the landing line reads one repository's approvals, by index", () => {
107 expect(landingLine(app.db, pull, "a")).toBeNull(); // autonomy off: no queue to be first in (#16452)
108 app.db.run("UPDATE repo SET autonomy = 'autonomous', autonomy_by = 'ua' WHERE id = 'a'");
107109 expect(landingLine(app.db, pull, "a")?.says).toStartWith("first in the queue");
108110 expect(landingLine(app.db, { ...pull, id: "b2" }, "a")).toBeNull();
109111 const lines = plans(() => void landingLine(app.db, pull, "a"), "state = 'approved'");
test/tui-pull-landing.test.ts +1
@@ -37,6 +37,7 @@ beforeAll(async () => {
3737 const r = await createRepo(forge, alice, { name: "site", visibility: "public" });
3838 if (!r.ok) throw new Error("repo creation failed");
3939 repo = r.value;
40 forge.db.query("UPDATE repo SET autonomy = 'autonomous', autonomy_by = ?2 WHERE id = ?1").run(repo.id, alice.id); // a queue that lands (#16452)
4041 await commitToBranch(forge, alice, repo, { message: "seed", files: [{ path: "README.md", content: "# s\n" }] });
4142 addToCrew(forge, alice, repo, "bot");
4243 await commitToBranch(forge, alice, repo, {

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs