Public: anyone can read this; the crew can change it.
A half-sure stop parks a red pull and closes it as done: the decider's stop takes the same 0.7 bar as its cause; a parked pull closes as parked #1469
mason/forge:mason/1354-a-half-sure-stop-parks-a-red-pull-and-cl → main 9 commits fork 2 threads · 2 unresolved
11 files
changed +267
−26
README.md +11
| @@ -346,6 +346,17 @@ changes, a line comment — and the agent picks it up in the background, | ||
| 346 | 346 | resuming its session. A failed check re-engages it too, a bounded number of |
| 347 | 347 | times before a person must speak. |
| 348 | 348 | |
| 349 | A red check is weighed by the decider: the builder reworks the pull unless | |
| 350 | the decider is sure (p ≥ 0.7) another try is pointless. Then, on an | |
| 351 | autonomous repository, the crew **parks** the pull: it says why on the pull, | |
| 352 | closes it unmerged, and hands its issues back to the map unassigned. A parked | |
| 353 | pull is not delivered. Its `closeReason` is `parked` in the API and on the | |
| 354 | `pull.closed` event, the change page says the crew parked it and the timeline | |
| 355 | "parked this", and the terminal's fleet plans read it as `closed (parked)`. | |
| 356 | Parked differs from dropped: a person drops an *issue* they will not do, | |
| 357 | while only the crew parks, and only a *pull* — nobody can choose it when | |
| 358 | closing. Reopening a parked pull clears it. | |
| 359 | ||
| 349 | 360 | **Already done.** A builder that finds its issue already built on the base |
| 350 | 361 | branch declines with `DECLINED: already done on main in <commit>`, naming the |
| 351 | 362 | full or abbreviated id of each commit that did it (at most five). The forge |
src/actions/issues.ts +10 −2
| @@ -407,7 +407,12 @@ export function setIssueState( | ||
| 407 | 407 | return err("already_merged"); |
| 408 | 408 | const reason = state === "closed" ? (closing.reason ?? "done") : undefined; |
| 409 | 409 | const children: Issue[] = []; |
| 410 | if (closing.reason !== undefined || closing.into !== undefined) { | |
| 410 | if (closing.reason === "parked") { | |
| 411 | // Parked is how the crew closes a pull it could not land (`parkPull`), | |
| 412 | // and nothing else: an issue is dropped or split, never parked. | |
| 413 | if (state !== "closed" || issue.kind !== "pull" || closing.into !== undefined) | |
| 414 | return err("invalid_reason"); | |
| 415 | } else if (closing.reason !== undefined || closing.into !== undefined) { | |
| 411 | 416 | // A reason is how an issue closes; a pull or a reopen has none. |
| 412 | 417 | if (state !== "closed" || issue.kind !== "issue") |
| 413 | 418 | return err("invalid_reason"); |
| @@ -449,7 +454,10 @@ export function setIssueState( | ||
| 449 | 454 | actorId: user.value.id, |
| 450 | 455 | payload: { |
| 451 | 456 | number: issue.number, |
| 452 | ...(issue.kind === "issue" && reason !== undefined ? { reason } : {}), | |
| 457 | ...((issue.kind === "issue" || reason === "parked") && | |
| 458 | reason !== undefined | |
| 459 | ? { reason } | |
| 460 | : {}), | |
| 453 | 461 | ...(children.length > 0 ? { into: children.map((c) => c.number) } : {}), |
| 454 | 462 | }, |
| 455 | 463 | }); |
src/core/issues.ts +16 −7
| @@ -12,8 +12,13 @@ import { repoVisible } from "./visibility.ts"; | ||
| 12 | 12 | |
| 13 | 13 | export type IssueKind = "issue" | "pull"; |
| 14 | 14 | export type IssueState = "open" | "closed"; |
| 15 | /** Why an issue closed: done frees what waited on it; the others hold it. */ | |
| 16 | export type CloseReason = "done" | "dropped" | "split"; | |
| 15 | /** | |
| 16 | * Why an issue closed: done frees what waited on it; the others hold it. | |
| 17 | * `parked` is the crew's own, for a pull it closed without landing | |
| 18 | * (`parkPull`); nobody chooses it, so it is not in `CLOSE_REASONS`. | |
| 19 | */ | |
| 20 | export type CloseReason = "done" | "dropped" | "split" | "parked"; | |
| 21 | /** The reasons a person may close an issue with. */ | |
| 17 | 22 | export const CLOSE_REASONS: readonly CloseReason[] = [ |
| 18 | 23 | "done", |
| 19 | 24 | "dropped", |
| @@ -77,7 +82,8 @@ interface IssueRow { | ||
| 77 | 82 | created_at: string; |
| 78 | 83 | updated_at: string; |
| 79 | 84 | closed_at: string | null; |
| 80 | close_reason: CloseReason | null; | |
| 85 | close_reason: Exclude<CloseReason, "parked"> | null; | |
| 86 | parked: number; | |
| 81 | 87 | origin_author: string | null; |
| 82 | 88 | origin_html_url: string | null; |
| 83 | 89 | assignee_id: string | null; |
| @@ -107,7 +113,8 @@ function toIssue(row: IssueRow): Issue { | ||
| 107 | 113 | createdAt: row.created_at, |
| 108 | 114 | updatedAt: row.updated_at, |
| 109 | 115 | closedAt: row.closed_at, |
| 110 | closeReason: row.close_reason, | |
| 116 | closeReason: | |
| 117 | row.state === "closed" && row.parked === 1 ? "parked" : row.close_reason, | |
| 111 | 118 | originAuthor: row.origin_author, |
| 112 | 119 | originUrl: row.origin_html_url, |
| 113 | 120 | assigneeId: row.assignee_id, |
| @@ -469,12 +476,14 @@ export function setIssueState( | ||
| 469 | 476 | ): Issue | undefined { |
| 470 | 477 | const now = new Date().toISOString(); |
| 471 | 478 | const closedAt = state === "closed" ? now : null; |
| 472 | const why = state === "closed" ? reason : null; | |
| 479 | const parked = state === "closed" && reason === "parked"; | |
| 480 | // Parked is stored as dropped plus the flag (migration 77). | |
| 481 | const why = state !== "closed" ? null : parked ? "dropped" : reason; | |
| 473 | 482 | const changed = db |
| 474 | 483 | .query( |
| 475 | "UPDATE issue SET state = ?1, closed_at = ?2, updated_at = ?3, close_reason = ?5 WHERE id = ?4 AND state != ?1", | |
| 484 | "UPDATE issue SET state = ?1, closed_at = ?2, updated_at = ?3, close_reason = ?5, parked = ?6 WHERE id = ?4 AND state != ?1", | |
| 476 | 485 | ) |
| 477 | .run(state, closedAt, now, issueId, why).changes; | |
| 486 | .run(state, closedAt, now, issueId, why, parked ? 1 : 0).changes; | |
| 478 | 487 | return changed > 0 ? getIssueById(db, issueId) : undefined; |
| 479 | 488 | } |
| 480 | 489 |
src/core/schema.ts +8
| @@ -1614,6 +1614,14 @@ export const migrations: readonly string[] = [ | ||
| 1614 | 1614 | PRIMARY KEY (key, issue_id) |
| 1615 | 1615 | ); |
| 1616 | 1616 | `, |
| 1617 | // 77 — a pull the crew parked (#1354): closed without landing. Its | |
| 1618 | // `close_reason` is stored as 'dropped', which the CHECK of 44 already | |
| 1619 | // allows and an older process reads as not delivered; `toIssue` reads | |
| 1620 | // the pair as `parked`. A column, not a widened CHECK: that would mean a | |
| 1621 | // table rebuild. | |
| 1622 | ` | |
| 1623 | ALTER TABLE issue ADD COLUMN parked INTEGER NOT NULL DEFAULT 0; | |
| 1624 | `, | |
| 1617 | 1625 | ]; |
| 1618 | 1626 | |
| 1619 | 1627 | /** |
src/crew/autonomy.ts +4 −1
| @@ -956,7 +956,10 @@ export function parkPull( | ||
| 956 | 956 | const issue = getIssueById(app.db, pull.id); |
| 957 | 957 | if (!issue || issue.state !== "open") return false; |
| 958 | 958 | addComment(app, by, repo, issue, `${PARK_NOTE}${why}`); |
| 959 | const closed = setIssueState(app, by, repo, issue, "closed"); | |
| 959 | // Parked, not done: the record of a pull that never landed says so. | |
| 960 | const closed = setIssueState(app, by, repo, issue, "closed", { | |
| 961 | reason: "parked", | |
| 962 | }); | |
| 960 | 963 | if (!closed.ok) return false; |
| 961 | 964 | for (const number of closesFromBody(pull.body)) { |
| 962 | 965 | const about = getIssue(app.db, repo.id, number); |
src/crew/dispatch.ts +16 −6
| @@ -758,6 +758,9 @@ export interface CheckJudgement { | ||
| 758 | 758 | readonly failingTest: string | undefined; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | /** How sure the decider must be for its answer to stand over the rule's. */ | |
| 762 | const SURE = 0.7; | |
| 763 | ||
| 761 | 764 | const RETRY_OPTIONS = ["again", "stop"]; |
| 762 | 765 | const CAUSE_OPTIONS = ["change", "environment", "base"]; |
| 763 | 766 | |
| @@ -835,18 +838,25 @@ export async function judgeFailedCheck( | ||
| 835 | 838 | cause: certain(CAUSE_OPTIONS, "change"), |
| 836 | 839 | }), |
| 837 | 840 | ); |
| 838 | const retry = decided.answers.retry.choice === "stop" ? "stop" : "again"; | |
| 839 | // The change is what a half-sure answer means: an environment called | |
| 841 | // A half-sure answer means the cheap path, for both questions. A stop | |
| 842 | // throws the pull away, so it takes the bar: below it the builder reworks. | |
| 843 | const stopP = decided.answers.retry.p; | |
| 844 | const stopChosen = decided.answers.retry.choice === "stop"; | |
| 845 | const retry = stopChosen && stopP >= SURE ? "stop" : "again"; | |
| 846 | // The change is what a half-sure cause means: an environment called | |
| 840 | 847 | // that way on a hunch is how a broken change escapes a rework. |
| 841 | 848 | const cause = |
| 842 | decided.answers.cause.p >= 0.7 | |
| 849 | decided.answers.cause.p >= SURE | |
| 843 | 850 | ? (decided.answers.cause.choice as CheckJudgement["cause"]) |
| 844 | 851 | : "change"; |
| 845 | if (retry === "stop") | |
| 846 | log.info("check failed; the decider stopped here for a person", { | |
| 852 | if (stopChosen) | |
| 853 | log.info("check failed; the decider's answer", { | |
| 847 | 854 | issue: issue.number, |
| 848 | 855 | by: decided.by, |
| 849 | p: decided.answers.retry.p.toFixed(2), | |
| 856 | retry: | |
| 857 | retry === "stop" | |
| 858 | ? `stop (p=${stopP.toFixed(2)})` | |
| 859 | : `again: a half-sure stop reworks (p=${stopP.toFixed(2)})`, | |
| 850 | 860 | cause, |
| 851 | 861 | }); |
| 852 | 862 | return { retry, cause, failingTest }; |
src/web/pages/pull.ts +5 −1
| @@ -347,7 +347,11 @@ function mergeBox( | ||
| 347 | 347 | return card( |
| 348 | 348 | html`${icon("x")} |
| 349 | 349 | <div class="grow"> |
| 350 | <div class="merge-headline">Closed without merging.</div> | |
| 350 | <div class="merge-headline"> | |
| 351 | ${pull.closeReason === "parked" | |
| 352 | ? "Parked by the crew: closed without merging." | |
| 353 | : "Closed without merging."} | |
| 354 | </div> | |
| 351 | 355 | <p class="merge-sub"> |
| 352 | 356 | Nothing was applied to |
| 353 | 357 | <span class="mono">${pull.baseBranch}</span>. |
src/web/pages/thread.ts +4 −1
| @@ -174,7 +174,10 @@ function stateEvents(ctx: Ctx, repo: Repo, issue: Issue): Entry[] { | ||
| 174 | 174 | ); |
| 175 | 175 | const entries: Entry[] = []; |
| 176 | 176 | for (const event of events) { |
| 177 | const look = EVENT_LOOK[event.kind]!; | |
| 177 | const look = | |
| 178 | event.kind === "pull.closed" && event.payload.reason === "parked" | |
| 179 | ? { ...EVENT_LOOK[event.kind]!, verb: "parked this" } | |
| 180 | : EVENT_LOOK[event.kind]!; | |
| 178 | 181 | const actor = |
| 179 | 182 | event.actorId !== null ? actors.get(event.actorId) : undefined; |
| 180 | 183 | entries.push({ |
src/web/studio/words.ts +8 −2
| @@ -180,7 +180,7 @@ function checkRunWord(check: CheckSummary): { word: Word; note: string } { | ||
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | 182 | * A pull's word: open goes by its own check, closed without a merge is |
| 183 | * simply stopped, and merged is *shipped* only once production is at or | |
| 183 | * simply stopped (a parked one says the crew parked it), and merged is *shipped* only once production is at or | |
| 184 | 184 | * past the commit that merge carried — the one place that fact is asked, |
| 185 | 185 | * so the app page, the change page, the home and the board never invent |
| 186 | 186 | * their own answer to it. |
| @@ -209,7 +209,13 @@ export async function pullWord( | ||
| 209 | 209 | return mergedPullWord(production, commitOid); |
| 210 | 210 | } |
| 211 | 211 | if (pull.state === "closed") |
| 212 | return { word: "stopped", note: "closed without shipping" }; | |
| 212 | return { | |
| 213 | word: "stopped", | |
| 214 | note: | |
| 215 | pull.closeReason === "parked" | |
| 216 | ? "parked by the crew, never landed" | |
| 217 | : "closed without shipping", | |
| 218 | }; | |
| 213 | 219 | const check = checkSummary(ctx.db, pull.id, pull.headOid); |
| 214 | 220 | // A repository that is not an app never deploys a head, so it never gets |
| 215 | 221 | // a look: an open change there waits on a person, and says so. |
test/ledger.test.ts +142 −5
| @@ -36,8 +36,14 @@ import { answerFailedCheck, judgeFailedCheck } from "../src/crew/dispatch.ts"; | ||
| 36 | 36 | import { startChecks } from "../src/checks/service.ts"; |
| 37 | 37 | import { serve, type Servers } from "../src/http/server.ts"; |
| 38 | 38 | |
| 39 | /** A decider that answers from a script: question name → choice. */ | |
| 40 | function scripted(answers: Record<string, string>): Decider & { | |
| 39 | /** | |
| 40 | * A decider that answers from a script: question name → choice, sure to | |
| 41 | * p = 0.8 unless `sure` names another for that question. | |
| 42 | */ | |
| 43 | function scripted( | |
| 44 | answers: Record<string, string>, | |
| 45 | sure: Record<string, number> = {}, | |
| 46 | ): Decider & { | |
| 41 | 47 | seen: unknown[]; |
| 42 | 48 | } { |
| 43 | 49 | const seen: unknown[] = []; |
| @@ -50,8 +56,10 @@ function scripted(answers: Record<string, string>): Decider & { | ||
| 50 | 56 | for (const [key, q] of Object.entries(questions)) { |
| 51 | 57 | const choice = answers[key] ?? q.options[0]!; |
| 52 | 58 | const probabilities: Record<string, number> = {}; |
| 53 | for (const o of q.options) probabilities[o] = o === choice ? 0.8 : 0.2; | |
| 54 | out[key] = { choice, p: 0.8, probabilities }; | |
| 59 | const p = sure[key] ?? 0.8; | |
| 60 | for (const o of q.options) | |
| 61 | probabilities[o] = o === choice ? p : (1 - p) / (q.options.length - 1); | |
| 62 | out[key] = { choice, p, probabilities }; | |
| 55 | 63 | } |
| 56 | 64 | return out as { [K in keyof Q]: Answer }; |
| 57 | 65 | }, |
| @@ -66,7 +74,8 @@ describe("the decision ledger", () => { | ||
| 66 | 74 | let scout: User; |
| 67 | 75 | let repo: Repo; |
| 68 | 76 | const script: Record<string, string> = {}; |
| 69 | const decider = scripted(script); | |
| 77 | const sure: Record<string, number> = {}; | |
| 78 | const decider = scripted(script, sure); | |
| 70 | 79 | const fresh = () => getRepoById(app.db, repo.id)!; |
| 71 | 80 | |
| 72 | 81 | beforeAll(async () => { |
| @@ -422,6 +431,134 @@ describe("the decision ledger", () => { | ||
| 422 | 431 | } |
| 423 | 432 | }); |
| 424 | 433 | |
| 434 | test("a half-sure stop reworks; a sure one parks, and the pull closes as parked, not done (#1354)", async () => { | |
| 435 | const { getAgentByName } = await import("../src/core/agents.ts"); | |
| 436 | const { listEvents } = await import("../src/core/events.ts"); | |
| 437 | const { setIssueState } = await import("../src/actions/issues.ts"); | |
| 438 | const scoutAgent = getAgentByName(app.db, "scout")!; | |
| 439 | const branch = await commitToBranch(app, alice, repo, { | |
| 440 | branch: "feature/unsure", | |
| 441 | base: "main", | |
| 442 | message: "Unsure", | |
| 443 | files: [{ path: "unsure.ts", content: "export const unsure = 1;\n" }], | |
| 444 | }); | |
| 445 | if (!branch.ok) throw new Error(JSON.stringify(branch.error)); | |
| 446 | const opened = await openPull(app, scout, repo, { | |
| 447 | title: "Unsure", | |
| 448 | baseBranch: "main", | |
| 449 | headBranch: "feature/unsure", | |
| 450 | }); | |
| 451 | if (!opened.ok) throw new Error(String(opened.error)); | |
| 452 | const pull = opened.value; | |
| 453 | const red = (): string => { | |
| 454 | const run = createRun(app.db, { | |
| 455 | repoId: repo.id, | |
| 456 | kind: "check", | |
| 457 | issueId: pull.id, | |
| 458 | env: `pull-${pull.number}`, | |
| 459 | commitOid: pull.headOid, | |
| 460 | reason: "pull", | |
| 461 | }); | |
| 462 | claimRun(app.db, run.id); | |
| 463 | finishRun(app.db, run.id, { | |
| 464 | state: "failed", | |
| 465 | summary: "check failed: 1 of 18 tests", | |
| 466 | }); | |
| 467 | return run.id; | |
| 468 | }; | |
| 469 | const failure = { | |
| 470 | kind: "check", | |
| 471 | commitOid: pull.headOid, | |
| 472 | env: `pull-${pull.number}`, | |
| 473 | since: pull.createdAt, | |
| 474 | }; | |
| 475 | const reworks = () => | |
| 476 | listRuns(app.db, repo.id, { kind: "agent" }).filter( | |
| 477 | (r) => r.issueId === pull.id && r.reason === "check_failed", | |
| 478 | ).length; | |
| 479 | script["retry"] = "stop"; | |
| 480 | script["cause"] = "change"; | |
| 481 | try { | |
| 482 | // p = 0.6: unsure means the cheap path. The builder reworks it and | |
| 483 | // the pull stays open. | |
| 484 | sure["retry"] = 0.6; | |
| 485 | expect( | |
| 486 | await answerFailedCheck(app, fresh(), pull, scoutAgent, { | |
| 487 | runId: red(), | |
| 488 | ...failure, | |
| 489 | }), | |
| 490 | ).toBe("reworked"); | |
| 491 | expect(reworks()).toBe(1); | |
| 492 | expect(getPull(app.db, repo.id, pull.number)?.state).toBe("open"); | |
| 493 | ||
| 494 | // p = 0.8: a sure stop parks it, and the record says parked. | |
| 495 | sure["retry"] = 0.8; | |
| 496 | expect( | |
| 497 | await answerFailedCheck(app, fresh(), pull, scoutAgent, { | |
| 498 | runId: red(), | |
| 499 | ...failure, | |
| 500 | }), | |
| 501 | ).toBe("parked"); | |
| 502 | expect(reworks()).toBe(1); | |
| 503 | const parked = getPull(app.db, repo.id, pull.number)!; | |
| 504 | expect(parked.state).toBe("closed"); | |
| 505 | expect(parked.closeReason).toBe("parked"); | |
| 506 | const closed = listEvents(app.db, { repoId: repo.id, limit: 50 }).find( | |
| 507 | (e) => e.kind === "pull.closed" && e.payload["number"] === pull.number, | |
| 508 | ); | |
| 509 | expect(closed?.payload["reason"]).toBe("parked"); | |
| 510 | ||
| 511 | // The pages say parked: the timeline's verb, the change's word, the | |
| 512 | // merge box on its files step, and the changes list. | |
| 513 | const cookie = ( | |
| 514 | ( | |
| 515 | await fetch(`${servers.url}/signin`, { | |
| 516 | method: "POST", | |
| 517 | body: new URLSearchParams({ | |
| 518 | username: "alice", | |
| 519 | password: "a-good-passphrase", | |
| 520 | }), | |
| 521 | redirect: "manual", | |
| 522 | }) | |
| 523 | ).headers.get("set-cookie") ?? "" | |
| 524 | ).split(";")[0]!; | |
| 525 | const read = async (path: string) => | |
| 526 | (await fetch(`${servers.url}${path}`, { headers: { cookie } })).text(); | |
| 527 | const page = await read(`/alice/shop/pulls/${pull.number}`); | |
| 528 | expect(page).toContain("parked this"); | |
| 529 | expect(page).toContain("parked by the crew, never landed"); | |
| 530 | expect(await read(`/alice/shop/pulls/${pull.number}/files`)).toContain( | |
| 531 | "Parked by the crew: closed without merging.", | |
| 532 | ); | |
| 533 | expect(await read("/alice/shop/pulls?state=closed")).toContain( | |
| 534 | "parked by the crew, never landed", | |
| 535 | ); | |
| 536 | // The terminal's plans read it the same way. | |
| 537 | const { VERBS } = await import("../src/fleet/verbs.ts"); | |
| 538 | expect(VERBS["drop"]!.read({ issue: parked } as never)).toBe( | |
| 539 | "closed (parked)", | |
| 540 | ); | |
| 541 | ||
| 542 | // Reopened, it is no longer parked; nobody may close as parked but | |
| 543 | // the crew, and never an issue. | |
| 544 | expect( | |
| 545 | setIssueState(app, alice, fresh(), parked, "open").ok, | |
| 546 | ).toBe(true); | |
| 547 | expect(getPull(app.db, repo.id, pull.number)?.closeReason).toBeNull(); | |
| 548 | const ask = await openIssue(app, alice, fresh(), { title: "An ask" }); | |
| 549 | if (!ask.ok) throw new Error(String(ask.error)); | |
| 550 | expect( | |
| 551 | setIssueState(app, alice, fresh(), ask.value, "closed", { | |
| 552 | reason: "parked", | |
| 553 | }), | |
| 554 | ).toEqual({ ok: false, error: "invalid_reason" }); | |
| 555 | } finally { | |
| 556 | delete script["retry"]; | |
| 557 | delete script["cause"]; | |
| 558 | delete sure["retry"]; | |
| 559 | } | |
| 560 | }); | |
| 561 | ||
| 425 | 562 | test("conflicts come first: a green pull that no longer merges gets a conflict run before anyone decides", async () => { |
| 426 | 563 | const branch = await commitToBranch(app, alice, repo, { |
| 427 | 564 | branch: "feature/readme", |
test/milestones.test.ts +43 −1
| @@ -14,7 +14,7 @@ import { join } from "node:path"; | ||
| 14 | 14 | import { createApp, type App } from "../src/app.ts"; |
| 15 | 15 | import { addToCrew, createAgent } from "../src/actions/crew.ts"; |
| 16 | 16 | import { linkIssue } from "../src/actions/dependencies.ts"; |
| 17 | import { openIssue } from "../src/actions/issues.ts"; | |
| 17 | import { openIssue, setIssueState } from "../src/actions/issues.ts"; | |
| 18 | 18 | import { mergePull, openPull } from "../src/actions/pulls.ts"; |
| 19 | 19 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 20 | 20 | import { createApp as insertApp } from "../src/core/apps.ts"; |
| @@ -515,4 +515,46 @@ describe("milestones", () => { | ||
| 515 | 515 | expect(page).toMatch(/<b>0<\/b> of 2 done/); |
| 516 | 516 | expect(page).toContain("A profit slider"); |
| 517 | 517 | }); |
| 518 | test("a parked pull is not delivered: its issue stays open work and nothing merged (#1354)", async () => { | |
| 519 | const before = readPlan(app.db, fresh(engine), { spend: false }); | |
| 520 | const p0 = before.limbs.find((l) => l.issue.number === trust.number)!; | |
| 521 | const branch = await commitToBranch(app, alice, fresh(engine), { | |
| 522 | branch: "feature/names", | |
| 523 | base: "main", | |
| 524 | message: "names", | |
| 525 | files: [{ path: "names.md", content: "names\n" }], | |
| 526 | }); | |
| 527 | if (!branch.ok) throw new Error(JSON.stringify(branch.error)); | |
| 528 | const opened = await openPull(app, mason, fresh(engine), { | |
| 529 | title: "Reserve the names", | |
| 530 | body: `Closes #${names.number}`, | |
| 531 | baseBranch: "main", | |
| 532 | headBranch: "feature/names", | |
| 533 | }); | |
| 534 | if (!opened.ok) throw new Error(String(opened.error)); | |
| 535 | const parked = setIssueState( | |
| 536 | app, | |
| 537 | alice, | |
| 538 | fresh(engine), | |
| 539 | opened.value, | |
| 540 | "closed", | |
| 541 | { reason: "parked" }, | |
| 542 | ); | |
| 543 | if (!parked.ok) throw new Error(String(parked.error)); | |
| 544 | expect(parked.value.closeReason).toBe("parked"); | |
| 545 | ||
| 546 | const plan = readPlan(app.db, fresh(engine), { spend: false }); | |
| 547 | const after = plan.limbs.find((l) => l.issue.number === trust.number)!; | |
| 548 | expect(after.weight).toMatchObject({ | |
| 549 | total: p0.weight.total, | |
| 550 | done: p0.weight.done, | |
| 551 | open: p0.weight.open, | |
| 552 | merged: p0.weight.merged, | |
| 553 | }); | |
| 554 | const m = plan.milestone(trust.number)!; | |
| 555 | expect(m.merged.map((p) => p.number)).not.toContain(opened.value.number); | |
| 556 | expect( | |
| 557 | m.leaves.find((l) => l.issue.number === names.number)?.state, | |
| 558 | ).toBe("ready"); | |
| 559 | }); | |
| 518 | 560 | }); |
new above
offline
The "parked this" verb has no test; render a parked thread and assert it.