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
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
13 files
changed +88
−14
- docs/features/pull-pane.md
- docs/features/reviews-off-lands-on-green.md
- src/flow/landing_line.ts
- src/flow/next_actor.ts
- src/flow/pull_pane.ts
- src/flow/waits_for.ts
- test/landing-line.test.ts
- test/mcp-flow-why.test.ts
- test/next_actor.test.ts
- test/pull-next-tui.test.ts
- test/pull-waits-for.test.ts
- test/repo-bound-reads.test.ts
- test/tui-pull-landing.test.ts
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 | ||
| 8 | 8 | |
| 9 | 9 | - **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. |
| 10 | 10 | - **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. | |
| 12 | 12 | - **Verbs** go through the doors the acts already have: |
| 13 | 13 | - a run's stop and queue again post to the run's routes; |
| 14 | 14 | - 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 | ||
| 4 | 4 | --- |
| 5 | 5 | # Reviews are something an owner turns on (#11666) |
| 6 | 6 | |
| 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. | |
| 8 | 8 | |
| 9 | 9 | **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. |
| 10 | 10 | |
| @@ -17,7 +17,7 @@ Either one keeps every agent pull waiting for an approving review: | ||
| 17 | 17 | |
| 18 | 18 | ## What still stops a pull with reviews off |
| 19 | 19 | |
| 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). | |
| 21 | 21 | |
| 22 | 22 | ## One rule |
| 23 | 23 |
src/flow/landing_line.ts +9 −1
| @@ -9,6 +9,7 @@ | ||
| 9 | 9 | |
| 10 | 10 | import type { Database } from "bun:sqlite"; |
| 11 | 11 | import { etaSays, landingEta } from "./landing_eta.ts"; |
| 12 | import { noQueueLands } from "./next_actor.ts"; | |
| 12 | 13 | import { median } from "./pipeline.ts"; |
| 13 | 14 | |
| 14 | 15 | const HOUR_MS = 3_600_000; |
| @@ -19,7 +20,10 @@ export interface LandingLine { | ||
| 19 | 20 | readonly says: string; |
| 20 | 21 | } |
| 21 | 22 | |
| 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 | */ | |
| 23 | 27 | export function landingLine( |
| 24 | 28 | db: Database, |
| 25 | 29 | pull: { readonly id: string; readonly number: number; readonly state: string; readonly mergedAt: string | null }, |
| @@ -28,6 +32,10 @@ export function landingLine( | ||
| 28 | 32 | ): LandingLine | null { |
| 29 | 33 | if (pull.state !== "open" || pull.mergedAt !== null) return null; |
| 30 | 34 | // 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; | |
| 31 | 39 | const approved = db |
| 32 | 40 | .query<{ id: string; number: number; at: string }, [string]>( |
| 33 | 41 | `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 { | ||
| 25 | 25 | * Set when a reviewer's asked-for changes on this head are the reason (the pane's own state too). |
| 26 | 26 | */ |
| 27 | 27 | 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; | |
| 28 | 33 | } |
| 29 | 34 | |
| 30 | 35 | export interface NextInput { |
| @@ -45,6 +50,17 @@ export interface NextInput { | ||
| 45 | 50 | readonly firstChange?: boolean; |
| 46 | 51 | /** Who asked for changes on this head, and which review (`blockingReviewWords`). */ |
| 47 | 52 | 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; | |
| 48 | 64 | } |
| 49 | 65 | |
| 50 | 66 | const WAITING = { |
| @@ -60,7 +76,10 @@ export function nextActor(i: NextInput): Next { | ||
| 60 | 76 | if (i.conflicted) return { who: "builder", why: "it conflicts with its base" }; |
| 61 | 77 | if (i.changesRequested > 0 && i.firstChange === true && i.check !== "failed") { |
| 62 | 78 | 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" }; | |
| 64 | 83 | return { who: "queue", why: WAITING[i.check] }; |
| 65 | 84 | } |
| 66 | 85 | if (i.changesRequested > 0) |
| @@ -68,11 +87,17 @@ export function nextActor(i: NextInput): Next { | ||
| 68 | 87 | if (i.check === "failed") return { who: "builder", why: "its check is red" }; |
| 69 | 88 | if (i.wall != null && i.wall.length > 0) return { who: "person", why: wallAsk(i.wall) }; |
| 70 | 89 | 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" }; | |
| 72 | 94 | return { who: "queue", why: `approved, ${WAITING[i.check]}` }; |
| 73 | 95 | } |
| 74 | 96 | 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" }; | |
| 76 | 101 | return { who: "queue", why: i.check === "none" ? "no check yet" : WAITING[i.check] }; |
| 77 | 102 | } |
| 78 | 103 | return { |
| @@ -96,8 +121,8 @@ export function nextOfPull( | ||
| 96 | 121 | db: Database, |
| 97 | 122 | pull: Pull, |
| 98 | 123 | 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, | |
| 101 | 126 | /** The head's check, when the caller already read it for `live.headOid`. */ |
| 102 | 127 | known?: CheckSummary, |
| 103 | 128 | ): Next | null { |
| @@ -115,6 +140,7 @@ export function nextOfPull( | ||
| 115 | 140 | wall: wallWords(db, pull.id, live.headOid), |
| 116 | 141 | askedBy: reviews.changesRequested > 0 ? blockingReviewWords(db, pull.id, live.headOid) : null, |
| 117 | 142 | firstChange: reviews.changesRequested > 0 && repo !== undefined && isFirstChange(db, repo, pull), |
| 143 | personLands: repo !== undefined && noQueueLands(repo), | |
| 118 | 144 | }, |
| 119 | 145 | () => repo !== undefined && reviewsOff(db, repo), |
| 120 | 146 | ); |
src/flow/pull_pane.ts +3 −1
| @@ -132,6 +132,8 @@ export function paneOf(f: PaneFacts): Pane { | ||
| 132 | 132 | }; |
| 133 | 133 | if (n === null) return { state: "waits", tone: undefined, sentence: "Waiting", verbs: [], evidence: [] }; |
| 134 | 134 | 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: [] }; | |
| 135 | 137 | if (n.who === "person") return { state: "decide", tone: "attn", sentence: cap(n.why), verbs: [], evidence: [] }; |
| 136 | 138 | if (n.who === "queue") |
| 137 | 139 | return { |
| @@ -154,7 +156,7 @@ export function paneOf(f: PaneFacts): Pane { | ||
| 154 | 156 | */ |
| 155 | 157 | export function pullPane( |
| 156 | 158 | db: Database, |
| 157 | repo: Pick<Repo, "id" | "requireReview" | "defaultBranch">, | |
| 159 | repo: Pick<Repo, "id" | "requireReview" | "defaultBranch" | "autonomy" | "autonomyBy">, | |
| 158 | 160 | pull: Pull, |
| 159 | 161 | live: { readonly headOid: string; readonly conflicts: readonly string[] }, |
| 160 | 162 | now: Date = new Date(), |
src/flow/waits_for.ts +1 −1
| @@ -22,7 +22,7 @@ import { nextOfPull, type Next } from "./next_actor.ts"; | ||
| 22 | 22 | */ |
| 23 | 23 | export function pullWaitsFor( |
| 24 | 24 | db: Database, |
| 25 | repo: Pick<Repo, "id" | "requireReview">, | |
| 25 | repo: Pick<Repo, "id" | "requireReview" | "autonomy" | "autonomyBy">, | |
| 26 | 26 | pull: Pull, |
| 27 | 27 | live: { readonly headOid: string; readonly conflicts: number }, |
| 28 | 28 | now: Date = new Date(), |
test/landing-line.test.ts +1
| @@ -52,6 +52,7 @@ beforeAll(async () => { | ||
| 52 | 52 | const made = await createRepo(app, alice, { name: "site", visibility: "public" }); |
| 53 | 53 | if (!made.ok) throw new Error(String(made.error)); |
| 54 | 54 | 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) | |
| 55 | 56 | await commitToBranch(app, alice, repo, { message: "seed", files: [{ path: "README.md", content: "# site\n" }] }); |
| 56 | 57 | addToCrew(app, alice, repo, "bot"); |
| 57 | 58 | await commitToBranch(app, alice, repo, { |
test/mcp-flow-why.test.ts +7 −2
| @@ -294,8 +294,13 @@ describe("MCP flow about a pull", () => { | ||
| 294 | 294 | "INSERT INTO review (id, issue_id, author_id, state, commit_oid, created_at) VALUES ('rvw', ?1, ?2, 'approved', ?3, ?4)", |
| 295 | 295 | [p.id, bot.id, live, new Date().toISOString()], |
| 296 | 296 | ); |
| 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); | |
| 299 | 304 | app.db.run( |
| 300 | 305 | "INSERT INTO decision (id, kind, repo_id, issue_id, state, answer, p, by, ms) VALUES ('dw', 'land', ?1, ?2, ?3, 'wall', 1, 'wall', 0)", |
| 301 | 306 | [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][] = [ | ||
| 31 | 31 | ["reviews off, running", { check: "running", reviewOff: true }, "queue", "its check is running"], |
| 32 | 32 | ["reviews off, changes asked", { changesRequested: 1, check: "ok", reviewOff: true }, "builder", "changes were asked on this head"], |
| 33 | 33 | ["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"], | |
| 34 | 37 | ]; |
| 35 | 38 | |
| 36 | 39 | describe("nextActor", () => { |
| @@ -57,3 +60,23 @@ describe("nextAsking (#11666)", () => { | ||
| 57 | 60 | expect(nextAsking({ ...base, check: "ok" }, () => false)).toEqual({ who: "reviewer", why: "no review yet" }); |
| 58 | 61 | }); |
| 59 | 62 | }); |
| 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 | ||
| 99 | 99 | const run = createRun(app.db, { repoId: topic.repo.id, kind: "check", issueId: topic.pull.id, commitOid: topic.pull.headOid }); |
| 100 | 100 | claimRun(app.db, run.id); |
| 101 | 101 | 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); | |
| 102 | 106 | const text = await screenSaying(topic, "Green, reviews are off: it lands"); |
| 103 | 107 | if (text.includes("waits for a review")) throw new Error(text); |
| 104 | 108 | }); |
test/pull-waits-for.test.ts +3 −1
| @@ -109,7 +109,9 @@ describe("read from the rows", () => { | ||
| 109 | 109 | alice = made.value; |
| 110 | 110 | const r = await createRepo(app, alice, { name: "app", visibility: "public" }); |
| 111 | 111 | 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); | |
| 113 | 115 | repo = getRepoById(app.db, r.value.id)!; |
| 114 | 116 | review = greenPull(8).number; |
| 115 | 117 | 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", () => { | ||
| 104 | 104 | }); |
| 105 | 105 | |
| 106 | 106 | 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'"); | |
| 107 | 109 | expect(landingLine(app.db, pull, "a")?.says).toStartWith("first in the queue"); |
| 108 | 110 | expect(landingLine(app.db, { ...pull, id: "b2" }, "a")).toBeNull(); |
| 109 | 111 | const lines = plans(() => void landingLine(app.db, pull, "a"), "state = 'approved'"); |
test/tui-pull-landing.test.ts +1
| @@ -37,6 +37,7 @@ beforeAll(async () => { | ||
| 37 | 37 | const r = await createRepo(forge, alice, { name: "site", visibility: "public" }); |
| 38 | 38 | if (!r.ok) throw new Error("repo creation failed"); |
| 39 | 39 | 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) | |
| 40 | 41 | await commitToBranch(forge, alice, repo, { message: "seed", files: [{ path: "README.md", content: "# s\n" }] }); |
| 41 | 42 | addToCrew(forge, alice, repo, "bot"); |
| 42 | 43 | await commitToBranch(forge, alice, repo, { |
new above
offline
Split this long line. The first-change branch above (line 74) needs the same personLands switch.