diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index dba94dcf..84c78cdc 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -1012,7 +1012,7 @@ deployment: # where a merge is confirmed live (BB-53); omi - Stewards are children of their parent steward, or of the project steward when they have none, with parent notifications off (§4), so bb's thread tree nests each under its parent. bb does not re-parent a live thread when its - parent ends: a child spawned under a goal that later ends stays under it + parent ends: a child spawned under an initiative that later ends stays under it visually, even though the binding's `parentBindingId` moved up (`endBinding`). The sidebar's own list (§21) derives the same nesting from each binding's `parentKey`, one level deep, so the two views agree. Who reports to whom is in diff --git a/plugins/stewards/config.test.ts b/plugins/stewards/config.test.ts index 75f85520..c0330d1d 100644 --- a/plugins/stewards/config.test.ts +++ b/plugins/stewards/config.test.ts @@ -368,16 +368,16 @@ describe("playbooks", () => { }); it("keys a phase on a label with `label:`, keeping it out of the states (BB-248)", () => { - const withLabel = parsePlaybook(LINEAR_TICKETS.replace(" In Progress: { stage: build, stuck: 2d }", ' In Progress: { stage: build, stuck: 2d }\n "label:goal:awaiting-outcome": { stage: build, stuck: 120d }'), "linear-tickets"); + const withLabel = parsePlaybook(LINEAR_TICKETS.replace(" In Progress: { stage: build, stuck: 2d }", ' In Progress: { stage: build, stuck: 2d }\n "label:initiative:awaiting-outcome": { stage: build, stuck: 120d }'), "linear-tickets"); if (!withLabel.ok) throw new Error(withLabel.error); const p = withLabel.value; - expect(labelPhaseName("label:goal:awaiting-outcome")).toBe("goal:awaiting-outcome"); + expect(labelPhaseName("label:initiative:awaiting-outcome")).toBe("initiative:awaiting-outcome"); expect(labelPhaseName("In Progress")).toBeNull(); - expect(playbookLabels(p)).toEqual(["goal:awaiting-outcome"]); - expect(playbookStates(p)).not.toContain("label:goal:awaiting-outcome"); + expect(playbookLabels(p)).toEqual(["initiative:awaiting-outcome"]); + expect(playbookStates(p)).not.toContain("label:initiative:awaiting-outcome"); expect(playbookStates(p)).toContain("In Progress"); // phaseOf still resolves the label key itself, for a binding's stored phase. - expect(phaseOf(p, "label:goal:awaiting-outcome")).toMatchObject({ name: "label:goal:awaiting-outcome", stage: "build" }); + expect(phaseOf(p, "label:initiative:awaiting-outcome")).toMatchObject({ name: "label:initiative:awaiting-outcome", stage: "build" }); // A `label:` key with no name is refused; a state-only playbook has no label keys. expect(parsePlaybook(LINEAR_TICKETS.replace(" In Progress: { stage: build, stuck: 2d }", ' In Progress: { stage: build, stuck: 2d }\n "label:": { stage: build }'), "linear-tickets")).toMatchObject({ ok: false }); const plain = parsePlaybook(LINEAR_TICKETS, "linear-tickets"); @@ -846,29 +846,29 @@ describe("project-level ticket watches (BB-246)", () => { const file = (tickets: unknown) => parseProjectFile(JSON.stringify({ version: 1, tickets })); const playbooks = () => { const tickets = parsePlaybook(LINEAR_TICKETS, "linear-tickets"); - const goals = parsePlaybook(LINEAR_TICKETS.replace("name: linear-tickets", "name: goals"), "goals"); + const initiative = parsePlaybook(LINEAR_TICKETS.replace("name: linear-tickets", "name: initiative"), "initiative"); const prs = parsePlaybook(GITHUB_PRS, "github-prs"); - if (!tickets.ok || !goals.ok || !prs.ok) throw new Error("playbook parse failed"); + if (!tickets.ok || !initiative.ok || !prs.ok) throw new Error("playbook parse failed"); return new Map([ ["linear-tickets", tickets.value], - ["goals", goals.value], + ["initiative", initiative.value], ["github-prs", prs.value], ]); }; it("parses a tickets list, defaulting match, and refuses a bad shape", () => { - const parsed = file([{ match: { labels: ["docs"], title: "Docs: *" }, playbook: "goals" }, { playbook: "linear-tickets" }]); + const parsed = file([{ match: { labels: ["docs"], title: "Docs: *" }, playbook: "initiative" }, { playbook: "linear-tickets" }]); if (!parsed.ok) throw new Error(parsed.error); expect(parsed.value.tickets).toEqual([ - { match: { labels: ["docs"], title: "Docs: *" }, playbook: "goals" }, + { match: { labels: ["docs"], title: "Docs: *" }, playbook: "initiative" }, { match: {}, playbook: "linear-tickets" }, ]); const empty = parseProjectFile(JSON.stringify({ version: 1 })); if (!empty.ok) throw new Error(empty.error); expect(empty.value.tickets).toEqual([]); - expect(file([{ match: { labels: [] }, playbook: "goals" }])).toMatchObject({ ok: false }); + expect(file([{ match: { labels: [] }, playbook: "initiative" }])).toMatchObject({ ok: false }); expect(file([{ match: { labels: ["docs"] } }])).toMatchObject({ ok: false }); - expect(file([{ match: { bogus: true }, playbook: "goals" }])).toMatchObject({ ok: false }); + expect(file([{ match: { bogus: true }, playbook: "initiative" }])).toMatchObject({ ok: false }); // A near-miss key is still refused by the strict project file. expect(parseProjectFile(JSON.stringify({ version: 1, ticket: [] }))).toMatchObject({ ok: false }); }); @@ -887,15 +887,15 @@ describe("project-level ticket watches (BB-246)", () => { }); it("reports a ticket watch playbook that did not parse from the loader's error, once", () => { - const parsed = file([{ playbook: "goals" }]); + const parsed = file([{ playbook: "initiative" }]); if (!parsed.ok) throw new Error(parsed.error); - const problems = ticketWatchProblems(parsed.value, new Map(), new Map([["goals", "stewards/playbooks/goals.md: the front matter is not YAML"]])); - expect(problems).toEqual([expect.stringMatching(/tickets\[0\].*"goals".*not YAML/u)]); + const problems = ticketWatchProblems(parsed.value, new Map(), new Map([["initiative", "stewards/playbooks/initiative.md: the front matter is not YAML"]])); + expect(problems).toEqual([expect.stringMatching(/tickets\[0\].*"initiative".*not YAML/u)]); }); it("names a ticket watch by its playbook", () => { - const parsed = file([{ playbook: "goals" }]); + const parsed = file([{ playbook: "initiative" }]); if (!parsed.ok) throw new Error(parsed.error); - expect(parsed.value.tickets.map((w) => ticketWatchId(w))).toEqual(["goals@ticket"]); + expect(parsed.value.tickets.map((w) => ticketWatchId(w))).toEqual(["initiative@ticket"]); }); }); diff --git a/plugins/stewards/config.ts b/plugins/stewards/config.ts index 47ce5c1f..efa3146d 100644 --- a/plugins/stewards/config.ts +++ b/plugins/stewards/config.ts @@ -20,14 +20,15 @@ export const playbookPath = (name: string) => `${STEWARDS_DIR}/playbooks/${name} export const DEFAULT_LABEL = "bb-managed"; /** - * The label a goal ticket carries besides the adoption label, and the playbook - * that stewards it (BB-243). A ticket is a goal when it carries the label or - * runs under the playbook: the project steward's wake and digest read a goal's - * progress from the `**Met:**` comments, and the playbook name is known even - * before the first snapshot, so an unread history reads `unknown`, never `0`. + * The label an initiative ticket carries besides the adoption label, and the + * playbook that stewards it (BB-243). A ticket is an initiative when it + * carries the label or runs under the playbook: the project steward's wake and + * digest read an initiative's progress from the `**Met:**` comments, and the + * playbook name is known even before the first snapshot, so an unread history + * reads `unknown`, never `0`. */ -export const GOAL_LABEL = "goal"; -export const GOAL_PLAYBOOK = "goal"; +export const INITIATIVE_LABEL = "initiative"; +export const INITIATIVE_PLAYBOOK = "initiative"; /** * Authors whose pull requests the dependency watch adopts under deps-prs diff --git a/plugins/stewards/reconcile.test.ts b/plugins/stewards/reconcile.test.ts index 20cd497c..196134b1 100644 --- a/plugins/stewards/reconcile.test.ts +++ b/plugins/stewards/reconcile.test.ts @@ -20,7 +20,7 @@ const reviews = (() => { const ctx = { own: new Set(["thr_s", "thr_w"]), stewardThreadId: "thr_s", approved: false, cursor: "2026-10-01T12:00:00Z", workerInFlight: false }; const actionable = (cs: Array<{ text: string; actionable: boolean }>) => cs.filter((c) => c.actionable).map((c) => c.text); -const LABEL_PHASE = '\n "label:goal:awaiting-outcome": { stage: build, stuck: 120d }'; +const LABEL_PHASE = '\n "label:initiative:awaiting-outcome": { stage: build, stuck: 120d }'; const labelledTickets = (() => { const p = parsePlaybook(LINEAR_TICKETS.replace(" In Progress: { stage: build, stuck: 2d }", ` In Progress: { stage: build, stuck: 2d }${LABEL_PHASE}`), "linear-tickets"); if (!p.ok) throw new Error(p.error); @@ -34,23 +34,23 @@ const labelledGithubIssues = (() => { describe("phaseAndStage keys a phase on a present label (BB-248)", () => { it("selects a matching label phase ahead of the state, on Linear", () => { - expect(phaseAndStage(labelledTickets, "In Progress", ["bb-managed", "goal:awaiting-outcome"])).toEqual({ phase: "label:goal:awaiting-outcome", stage: "build" }); + expect(phaseAndStage(labelledTickets, "In Progress", ["bb-managed", "initiative:awaiting-outcome"])).toEqual({ phase: "label:initiative:awaiting-outcome", stage: "build" }); // The label match ignores case. - expect(phaseAndStage(labelledTickets, "In Progress", ["Goal:Awaiting-Outcome"])).toEqual({ phase: "label:goal:awaiting-outcome", stage: "build" }); + expect(phaseAndStage(labelledTickets, "In Progress", ["Initiative:Awaiting-Outcome"])).toEqual({ phase: "label:initiative:awaiting-outcome", stage: "build" }); // No such label, or no labels at all: the state decides, as today. expect(phaseAndStage(labelledTickets, "In Progress", ["bb-managed"])).toEqual({ phase: "In Progress", stage: "build" }); expect(phaseAndStage(labelledTickets, "In Progress")).toEqual({ phase: "In Progress", stage: "build" }); }); it("selects it on a GitHub entity too, over the synthesised status state", () => { - expect(phaseAndStage(labelledGithubIssues, "status:in-progress", ["bb-managed", "goal:awaiting-outcome"])).toEqual({ phase: "label:goal:awaiting-outcome", stage: "build" }); + expect(phaseAndStage(labelledGithubIssues, "status:in-progress", ["bb-managed", "initiative:awaiting-outcome"])).toEqual({ phase: "label:initiative:awaiting-outcome", stage: "build" }); // A present status label is still a state, and decides when no label phase matches. expect(phaseAndStage(labelledGithubIssues, "status:in-progress", ["bb-managed", "status:in-progress"])).toEqual({ phase: "status:in-progress", stage: "build" }); }); it("resolves the stored label phase for stuckDue", () => { - expect(phaseAndStage(labelledTickets, "In Progress", ["goal:awaiting-outcome"]).phase).toBe("label:goal:awaiting-outcome"); - expect(stuckDue({ advancedAt: 1_000, createdAt: 0, phase: "label:goal:awaiting-outcome" }, labelledTickets, [], 1_000 + 120 * 86_400_000)).toBe(120 * 86_400_000); + expect(phaseAndStage(labelledTickets, "In Progress", ["initiative:awaiting-outcome"]).phase).toBe("label:initiative:awaiting-outcome"); + expect(stuckDue({ advancedAt: 1_000, createdAt: 0, phase: "label:initiative:awaiting-outcome" }, labelledTickets, [], 1_000 + 120 * 86_400_000)).toBe(120 * 86_400_000); }); }); @@ -503,29 +503,29 @@ describe("lifecycle", () => { }); }); -// BB-243: a goal is a ticket routed to the `goal` playbook. All three endings -// (reached, superseded, retired) are the goal closing; a child's merge is not -// one, so the binding carries on. The fixture is a fake goal, never the pilot's. -describe("goal endings (BB-243)", () => { - const goal = (() => { - const p = parsePlaybook(GITHUB_ISSUES.replace("name: github-issues", "name: goal").replace("approval: project", "approval: user"), "goal"); +// BB-243: an initiative is a ticket routed to the `initiative` playbook. All three endings +// (reached, superseded, retired) are the initiative closing; a child's merge is not +// one, so the binding carries on. The fixture is a fake initiative, never the pilot's. +describe("initiative endings (BB-243)", () => { + const initiative = (() => { + const p = parsePlaybook(GITHUB_ISSUES.replace("name: github-issues", "name: initiative").replace("approval: project", "approval: user"), "initiative"); if (!p.ok) throw new Error(p.error); return p.value; })(); const open = { kind: "ticket" as const, endedAt: null, endReason: null, manualDetach: false, ending: null }; - it("ends the binding when the goal is reached, superseded or retired, and never on a child merge", () => { + it("ends the binding when the initiative is reached, superseded or retired, and never on a child merge", () => { // Reached: every criterion met, the owner closes it as completed. - expect(lifecycle(open, goal, issue({ state: "closed (completed)" }), "bb-managed").kind).toBe("terminal"); + expect(lifecycle(open, initiative, issue({ state: "closed (completed)" }), "bb-managed").kind).toBe("terminal"); // Retired: the owner closes it as not planned. - expect(lifecycle(open, goal, issue({ state: "closed (not planned)" }), "bb-managed").kind).toBe("terminal"); - // Superseded: a successor is filed and this goal is closed with a Revision comment. - const superseded = issue({ state: "closed", comments: [comment({ id: "r1", author: "Jane", body: "**Revision:** superseded by Goal: file the 2027 claim." })] }); - expect(lifecycle(open, goal, superseded, "bb-managed").kind).toBe("terminal"); - // A child merging does not close the goal, so the binding carries on. - expect(lifecycle(open, goal, issue({ state: "status:in-progress" }), "bb-managed").kind).toBe("continue"); - // An ended goal stays ended while it is closed, whatever an earlier digest said. - expect(lifecycle({ ...open, endedAt: 1, endReason: "terminal" }, goal, issue({ state: "closed" }), "bb-managed").kind).toBe("stay-ended"); + expect(lifecycle(open, initiative, issue({ state: "closed (not planned)" }), "bb-managed").kind).toBe("terminal"); + // Superseded: a successor is filed and this initiative is closed with a Revision comment. + const superseded = issue({ state: "closed", comments: [comment({ id: "r1", author: "Jane", body: "**Revision:** superseded by Initiative: file the 2027 claim." })] }); + expect(lifecycle(open, initiative, superseded, "bb-managed").kind).toBe("terminal"); + // A child merging does not close the initiative, so the binding carries on. + expect(lifecycle(open, initiative, issue({ state: "status:in-progress" }), "bb-managed").kind).toBe("continue"); + // An ended initiative stays ended while it is closed, whatever an earlier digest said. + expect(lifecycle({ ...open, endedAt: 1, endReason: "terminal" }, initiative, issue({ state: "closed" }), "bb-managed").kind).toBe("stay-ended"); }); }); diff --git a/plugins/stewards/server.test.ts b/plugins/stewards/server.test.ts index 3ea20c48..80156138 100644 --- a/plugins/stewards/server.test.ts +++ b/plugins/stewards/server.test.ts @@ -888,21 +888,21 @@ describe("a Linear ticket steward", () => { const t = await setup(); t.files[playbookPath("linear-tickets")] = LINEAR_TICKETS.replace( " In Progress: { stage: build, stuck: 2d }", - ' In Progress: { stage: build, stuck: 2d }\n "label:goal:awaiting-outcome": { stage: spec, stuck: 120d }', - ).replace("## In Review", "## label:goal:awaiting-outcome\n\nWait for the outcome.\n\n## In Review"); + ' In Progress: { stage: build, stuck: 2d }\n "label:initiative:awaiting-outcome": { stage: spec, stuck: 120d }', + ).replace("## In Review", "## label:initiative:awaiting-outcome\n\nWait for the outcome.\n\n## In Review"); t.entities.set("uuid-12", issue()); await t.ring("linear", "uuid-12"); const steward = t.spawns[1]!.id; expect(t.hooks.store.find("ENG-12", "p1")!.phase).toBe("Todo"); t.sends.length = 0; // The label moves the phase; the state stays `Todo`. - t.entities.set("uuid-12", issue({ labels: ["bb-managed", "goal:awaiting-outcome"] })); + t.entities.set("uuid-12", issue({ labels: ["bb-managed", "initiative:awaiting-outcome"] })); await t.ring("linear", "uuid-12"); - expect(t.hooks.store.find("ENG-12", "p1")!.phase).toBe("label:goal:awaiting-outcome"); + expect(t.hooks.store.find("ENG-12", "p1")!.phase).toBe("label:initiative:awaiting-outcome"); const wakes = t.sends.filter((s) => s.threadId === steward); expect(wakes).toHaveLength(1); - expect(wakes[0]!.text).toMatch(/Phase: Todo → label:goal:awaiting-outcome/u); - expect(wakes[0]!.text).toContain("### label:goal:awaiting-outcome"); + expect(wakes[0]!.text).toMatch(/Phase: Todo → label:initiative:awaiting-outcome/u); + expect(wakes[0]!.text).toContain("### label:initiative:awaiting-outcome"); expect(wakes[0]!.text).toContain("Wait for the outcome."); }); @@ -2623,43 +2623,43 @@ describe("escalations delivered once, updates safe to retry", () => { }); }); -// BB-243: a goal is a ticket under the `goal` playbook. All three endings -// (reached, superseded, retired) are the goal closing; a child's merge is not -// one, so the binding carries on. The fixture is a fake goal, never the pilot's. -describe("goal endings end the binding (BB-243)", () => { - const GOAL = LINEAR_TICKETS.replace("name: linear-tickets", "name: goal"); - async function goalBinding() { +// BB-243: an initiative is a ticket under the `initiative` playbook. All three endings +// (reached, superseded, retired) are the initiative closing; a child's merge is not +// one, so the binding carries on. The fixture is a fake initiative, never the pilot's. +describe("initiative endings end the binding (BB-243)", () => { + const INITIATIVE = LINEAR_TICKETS.replace("name: linear-tickets", "name: initiative"); + async function initiativeBinding() { const t = await setup(); const file = JSON.parse(t.files[PROJECT_FILE]!) as { playbooks?: Record }; - file.playbooks = { ticket: "goal" }; + file.playbooks = { ticket: "initiative" }; t.files[PROJECT_FILE] = JSON.stringify(file); - t.files[playbookPath("goal")] = GOAL; - t.entities.set("uuid-12", issue({ labels: ["bb-managed", "goal"], state: "In Progress", stateType: "started" })); + t.files[playbookPath("initiative")] = INITIATIVE; + t.entities.set("uuid-12", issue({ labels: ["bb-managed", "initiative"], state: "In Progress", stateType: "started" })); await t.ring("linear", "uuid-12"); return { t, steward: t.spawns[1]!.id }; } - const closeGoal = async (t: Awaited>["t"], steward: string, state: string, stateType: string) => { - t.entities.set("uuid-12", issue({ labels: ["bb-managed", "goal"], state, stateType })); + const closeInitiative = async (t: Awaited>["t"], steward: string, state: string, stateType: string) => { + t.entities.set("uuid-12", issue({ labels: ["bb-managed", "initiative"], state, stateType })); await t.ring("linear", "uuid-12"); await t.tool("steward_report", { phase: state, summary: "Ending.", nextAction: "Nothing", actor: "steward" }, steward); await t.idle(steward); }; it("ends on reached (Done), and not on a child merge", async () => { - const { t, steward } = await goalBinding(); - expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "goal", endedAt: null }); - // A child merging does not close the goal, so the binding carries on. - t.entities.set("uuid-12", issue({ labels: ["bb-managed", "goal"], state: "In Progress", stateType: "started", linkedPulls: [{ url: "https://github.com/acme/web/pull/7", key: "acme/web#7" }] })); + const { t, steward } = await initiativeBinding(); + expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "initiative", endedAt: null }); + // A child merging does not close the initiative, so the binding carries on. + t.entities.set("uuid-12", issue({ labels: ["bb-managed", "initiative"], state: "In Progress", stateType: "started", linkedPulls: [{ url: "https://github.com/acme/web/pull/7", key: "acme/web#7" }] })); await t.ring("linear", "uuid-12"); expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ endedAt: null }); // Reached: Done ends the binding once the wrap-up turn is over. - await closeGoal(t, steward, "Done", "completed"); + await closeInitiative(t, steward, "Done", "completed"); expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ endedAt: expect.any(Number), endReason: "terminal" }); }); it("ends on retired (Canceled)", async () => { - const { t, steward } = await goalBinding(); - await closeGoal(t, steward, "Canceled", "canceled"); + const { t, steward } = await initiativeBinding(); + await closeInitiative(t, steward, "Canceled", "canceled"); expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ endedAt: expect.any(Number), endReason: "terminal" }); }); }); @@ -3544,29 +3544,29 @@ describe("check --create-labels (BB-236)", () => { // BB-248: a playbook phase keyed `label:` is checked as a label, not as // a missing workflow state, on Linear and GitHub alike. describe("check on a `label:` phase key (BB-248)", () => { - const withLabel = (text: string, stateLine: string) => text.replace(stateLine, `${stateLine}\n "label:goal:awaiting-outcome": { stage: build, stuck: 120d }`); + const withLabel = (text: string, stateLine: string) => text.replace(stateLine, `${stateLine}\n "label:initiative:awaiting-outcome": { stage: build, stuck: 120d }`); it("checks a Linear label phase key as a label, not a missing workflow state", async () => { const t = await setup(); t.files[playbookPath("linear-tickets")] = withLabel(LINEAR_TICKETS, " In Progress: { stage: build, stuck: 2d }"); - t.setMissingLabel("linear", "ENG", ["goal:awaiting-outcome"]); + t.setMissingLabel("linear", "ENG", ["initiative:awaiting-outcome"]); const check = await t.harness.behavior.runCli(["check", "--project", "p1"]); expect(check.exitCode).toBe(1); - expect(check.stdout).toMatch(/problem: linear: ENG has no label goal:awaiting-outcome/u); - expect(check.stdout).not.toMatch(/has no state (?:label:)?goal:awaiting-outcome/u); + expect(check.stdout).toMatch(/problem: linear: ENG has no label initiative:awaiting-outcome/u); + expect(check.stdout).not.toMatch(/has no state (?:label:)?initiative:awaiting-outcome/u); // The label is read through the source's single-label field, with no states. const calls = t.rpcCalls.filter((c) => c.method === "sourceValidate" && c.pluginId === "linear"); - expect(calls.some((c) => c.input.label === "goal:awaiting-outcome" && (c.input.states as string[]).length === 0)).toBe(true); + expect(calls.some((c) => c.input.label === "initiative:awaiting-outcome" && (c.input.states as string[]).length === 0)).toBe(true); }); it("checks a GitHub repo label phase key the same way", async () => { const t = await setup(); t.files[playbookPath("github-issues")] = withLabel(GITHUB_ISSUES, " status:in-progress: { stage: build, stuck: 2d }"); - t.setMissingLabel("github", "acme/web", ["goal:awaiting-outcome"]); + t.setMissingLabel("github", "acme/web", ["initiative:awaiting-outcome"]); const check = await t.harness.behavior.runCli(["check", "--project", "p1"]); expect(check.exitCode).toBe(1); - expect(check.stdout).toMatch(/problem: github: acme\/web has no label goal:awaiting-outcome/u); - expect(check.stdout).not.toMatch(/has no state (?:label:)?goal:awaiting-outcome/u); + expect(check.stdout).toMatch(/problem: github: acme\/web has no label initiative:awaiting-outcome/u); + expect(check.stdout).not.toMatch(/has no state (?:label:)?initiative:awaiting-outcome/u); }); it("is silent when the label exists, and existing playbooks are unchanged", async () => { @@ -3574,7 +3574,7 @@ describe("check on a `label:` phase key (BB-248)", () => { t.files[playbookPath("linear-tickets")] = withLabel(LINEAR_TICKETS, " In Progress: { stage: build, stuck: 2d }"); const check = await t.harness.behavior.runCli(["check", "--project", "p1"]); expect(check.exitCode).toBe(0); - expect(check.stdout).not.toMatch(/goal:awaiting-outcome/u); + expect(check.stdout).not.toMatch(/initiative:awaiting-outcome/u); }); }); @@ -4049,28 +4049,28 @@ describe("role-owned pull watches (BB-164)", () => { // issue's labels and title, before the kind's default. The first watch wins; // with none, adoption is unchanged. It is the mirror of the pull watches. describe("project-level ticket watches (BB-246)", () => { - const GOALS = LINEAR_TICKETS.replace("name: linear-tickets", "name: goals"); - const GITHUB_GOALS = GITHUB_ISSUES.replace("name: github-issues", "name: goals"); + const INITIATIVES = LINEAR_TICKETS.replace("name: linear-tickets", "name: initiatives"); + const GITHUB_INITIATIVES = GITHUB_ISSUES.replace("name: github-issues", "name: initiatives"); const project = (tickets: unknown) => JSON.stringify({ version: 1, linear: { teams: ["ENG"] }, tickets }); it("adopts a labelled, assigned Linear ticket matching a watch under its playbook, and records the watch", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); - t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"], title: "docs: *" }, playbook: "goals" }]); - t.files[playbookPath("goals")] = GOALS; + t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"], title: "docs: *" }, playbook: "initiatives" }]); + t.files[playbookPath("initiatives")] = INITIATIVES; t.entities.set("uuid-12", issue({ labels: ["bb-managed", "docs"], title: "Docs: rewrite" })); await t.ring("linear", "uuid-12"); const b = t.hooks.store.find("ENG-12", "p1")!; - expect(b).toMatchObject({ kind: "ticket", playbook: "goals", adoptedBy: "goals@ticket", endedAt: null }); + expect(b).toMatchObject({ kind: "ticket", playbook: "initiatives", adoptedBy: "initiatives@ticket", endedAt: null }); expect(b.threadId).not.toBeNull(); // The title glob matched ignoring case, and `list` names the watch. const list = await t.harness.behavior.runCli(["list", "--project", "p1"]); - expect(list.stdout).toMatch(/adopted by goals@ticket/u); + expect(list.stdout).toMatch(/adopted by initiatives@ticket/u); }); it("adopts a ticket matching no watch under the kind's default playbook, as before", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); - t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "goals" }]); - t.files[playbookPath("goals")] = GOALS; + t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "initiatives" }]); + t.files[playbookPath("initiatives")] = INITIATIVES; t.entities.set("uuid-12", issue({ labels: ["bb-managed"], title: "Fix login" })); await t.ring("linear", "uuid-12"); expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "linear-tickets", adoptedBy: null }); @@ -4079,19 +4079,19 @@ describe("project-level ticket watches (BB-246)", () => { it("takes the first matching watch, so order decides", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); t.files[PROJECT_FILE] = project([ - { match: { labels: ["docs"] }, playbook: "goals" }, + { match: { labels: ["docs"] }, playbook: "initiatives" }, { match: { title: "Docs: *" }, playbook: "linear-tickets" }, ]); - t.files[playbookPath("goals")] = GOALS; + t.files[playbookPath("initiatives")] = INITIATIVES; t.entities.set("uuid-12", issue({ labels: ["bb-managed", "docs"], title: "Docs: rewrite" })); await t.ring("linear", "uuid-12"); - expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "goals", adoptedBy: "goals@ticket" }); + expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "initiatives", adoptedBy: "initiatives@ticket" }); }); it("matches every named label ignoring case, and falls through when one is missing", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); - t.files[PROJECT_FILE] = project([{ match: { labels: ["Docs", "v2"] }, playbook: "goals" }]); - t.files[playbookPath("goals")] = GOALS; + t.files[PROJECT_FILE] = project([{ match: { labels: ["Docs", "v2"] }, playbook: "initiatives" }]); + t.files[playbookPath("initiatives")] = INITIATIVES; // Missing `v2`: no match, so the default. t.entities.set("uuid-12", issue({ labels: ["bb-managed", "DOCS"] })); await t.ring("linear", "uuid-12"); @@ -4099,17 +4099,17 @@ describe("project-level ticket watches (BB-246)", () => { // Both present, ignoring case: the watch. t.entities.set("uuid-13", issue({ id: "uuid-13", key: "ENG-13", labels: ["bb-managed", "docs", "V2"] })); await t.ring("linear", "uuid-13"); - expect(t.hooks.store.find("ENG-13", "p1")).toMatchObject({ playbook: "goals" }); + expect(t.hooks.store.find("ENG-13", "p1")).toMatchObject({ playbook: "initiatives" }); }); it("adopts a labelled, assigned GitHub issue matching a watch under its playbook", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); - t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "goals" }]); + t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "initiatives" }]); t.files[playbookPath("github-issues")] = GITHUB_ISSUES; - t.files[playbookPath("goals")] = GITHUB_GOALS; + t.files[playbookPath("initiatives")] = GITHUB_INITIATIVES; t.entities.set("acme/web#14", githubIssue({ id: "acme/web#14", key: "acme/web#14", labels: ["bb-managed", "status:todo", "docs"] })); await t.ring("github", "acme/web#14"); - expect(t.hooks.store.find("acme/web#14", "p1")).toMatchObject({ source: "github", playbook: "goals", adoptedBy: "goals@ticket" }); + expect(t.hooks.store.find("acme/web#14", "p1")).toMatchObject({ source: "github", playbook: "initiatives", adoptedBy: "initiatives@ticket" }); }); it("adopts nothing when the matched watch's playbook is missing or not a ticket playbook", async () => { @@ -4128,15 +4128,15 @@ describe("project-level ticket watches (BB-246)", () => { it("does not re-route an adopted binding when the watch's label changes", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); - t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "goals" }]); - t.files[playbookPath("goals")] = GOALS; + t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "initiatives" }]); + t.files[playbookPath("initiatives")] = INITIATIVES; t.entities.set("uuid-12", issue({ labels: ["bb-managed", "docs"] })); await t.ring("linear", "uuid-12"); - expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "goals" }); + expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "initiatives" }); // Removing the watch's label leaves the playbook alone; the label still holds it. t.entities.set("uuid-12", issue({ labels: ["bb-managed"] })); await t.ring("linear", "uuid-12"); - expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "goals", endedAt: null }); + expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "initiatives", endedAt: null }); // A ticket adopted under the default does not switch when the label arrives. t.entities.set("uuid-13", issue({ id: "uuid-13", key: "ENG-13", labels: ["bb-managed"] })); await t.ring("linear", "uuid-13"); @@ -4148,22 +4148,22 @@ describe("project-level ticket watches (BB-246)", () => { it("keeps an adopted ticket's playbook after its watch is removed, until the playbook file itself goes", async () => { const t = await setup({ timing: { debounceMs: 1, nightlyStaggerMs: 0, configTtlMs: 0 } }); - t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "goals" }]); - t.files[playbookPath("goals")] = GOALS; + t.files[PROJECT_FILE] = project([{ match: { labels: ["docs"] }, playbook: "initiatives" }]); + t.files[playbookPath("initiatives")] = INITIATIVES; t.entities.set("uuid-12", issue({ labels: ["bb-managed", "docs"] })); await t.ring("linear", "uuid-12"); - expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "goals", adoptedBy: "goals@ticket" }); - // The watch is removed, but `goals.md` remains: the binding keeps running + expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "initiatives", adoptedBy: "initiatives@ticket" }); + // The watch is removed, but `initiatives.md` remains: the binding keeps running // under it, and `check` reports no problem for the removed watch. t.files[PROJECT_FILE] = project([]); t.hooks.forgetConfigs(); await t.ring("linear", "uuid-12"); - expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "goals", endedAt: null }); + expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ playbook: "initiatives", endedAt: null }); const check = await t.harness.behavior.runCli(["check", "--project", "p1"]); - expect(check.stdout).not.toMatch(/goals/u); + expect(check.stdout).not.toMatch(/initiatives/u); // With the playbook file gone too, and no last-good copy, it ends. - delete t.files[playbookPath("goals")]; - await t.bb.storage.kv.delete("good/p1/playbook/goals"); + delete t.files[playbookPath("initiatives")]; + await t.bb.storage.kv.delete("good/p1/playbook/initiatives"); t.hooks.forgetConfigs(); await t.ring("linear", "uuid-12"); expect(t.hooks.store.find("ENG-12", "p1")).toMatchObject({ endedAt: expect.any(Number), endReason: "unconfigured" }); @@ -4177,12 +4177,12 @@ describe("project-level ticket watches (BB-246)", () => { expect(check.stdout).toMatch(/tickets\[0\].*"gone".*does not exist/); expect(check.stdout).toMatch(/tickets\[1\].*"github-prs" is a pr playbook, not a ticket playbook/); // A project with a valid ticket watch names it and passes. - t.files[PROJECT_FILE] = project([{ playbook: "goals" }]); - t.files[playbookPath("goals")] = GOALS; + t.files[PROJECT_FILE] = project([{ playbook: "initiatives" }]); + t.files[playbookPath("initiatives")] = INITIATIVES; t.hooks.forgetConfigs(); const good = await t.harness.behavior.runCli(["check", "--project", "p1"]); expect(good.exitCode).toBe(0); - expect(good.stdout).toMatch(/tickets: goals@ticket/u); + expect(good.stdout).toMatch(/tickets: initiatives@ticket/u); }); }); diff --git a/plugins/stewards/skills/stewards/SKILL.md b/plugins/stewards/skills/stewards/SKILL.md index 43b962c8..55f040ca 100644 --- a/plugins/stewards/skills/stewards/SKILL.md +++ b/plugins/stewards/skills/stewards/SKILL.md @@ -427,16 +427,17 @@ body by hand with `_— from bb thread _`. - **No logs** (the wake says so): diagnose from status and events, and say in the ticket that logs were not available. -## If you are a goal steward - -You own a **goal**: an outcome with acceptance criteria and no fixed set of -children. You file and sequence the children yourself, revise the outcome as -signals arrive, and stay open until the outcome is reached, the goal is -superseded, or the owner retires it. The goal is a ticket carrying the -adoption label and the `goal` label, assigned to this server's owner, and -routed to the `goal` playbook; its children are native sub-issues on both -sources. The project steward's wake and digest count your progress from the -`**Met:**` comments, so write them as you go. +## If you are an initiative steward + +You own an **initiative**: an outcome with acceptance criteria and no fixed +set of children. You file and sequence the children yourself, revise the +outcome as signals arrive, and stay open until the outcome is reached, the +initiative is superseded, or the owner retires it. The initiative is a ticket +carrying the adoption label and the `initiative` label, assigned to this +server's owner, and routed to the `initiative` playbook; its children are +native sub-issues on both sources. An initiative here is a labelled issue, +not a Linear Initiative. The project steward's wake and digest count your +progress from the `**Met:**` comments, so write them as you go. **The description holds only what the owner approves**, under fixed headings: `## Outcome` (one paragraph: what is true when this is done), @@ -448,8 +449,8 @@ who gives feedback and where, validators, the calendar, external events), and criterion in the description: progress is counted from `Met:` comments, not from ticked boxes. -**Comment prefixes.** Every comment you write on the goal starts with one of -these, so the history reads as a record: +**Comment prefixes.** Every comment you write on the initiative starts with +one of these, so the history reads as a record: - `**Revision:**` explains each description edit: what changed in the outcome or criteria, and which signal prompted it. @@ -458,7 +459,7 @@ these, so the history reads as a record: - `**Note:**` for anything else worth recording. **The outcome evolves, under approval.** The outcome paragraph and the -criteria are the spec, and the `goal` playbook's ready gate is +criteria are the spec, and the `initiative` playbook's ready gate is `approval: user`, so the owner approves them — not you and not the project steward. When a signal warrants a change — a stakeholder's feedback, a child's result, a validator, a date passing, an external event — edit the @@ -473,34 +474,35 @@ comment. Comments from anyone other than the owner are information until the owner confirms them: mention people to ask them, and fold their input into the next revision rather than acting on it. -**You drive.** On every wake, reread the goal, its signals and its children -(listed in the wake). File the next child for the first unmet, approved -criterion that has no open child: an ordinary labelled sub-issue, with a -`**Child:**` comment on the goal naming the criterion it serves. One child -per step, in dependency order, one layer ahead of what has merged; at most -two or three open at a time; never a child for an unapproved criterion. When -you cannot derive the next step, the ticket steward's rules apply: escalate -only what the guidance does not settle, one question per reply, record each +**You drive.** On every wake, reread the initiative, its signals and its +children (listed in the wake). File the next child for the first unmet, +approved criterion that has no open child: an ordinary labelled sub-issue, +with a `**Child:**` comment on the initiative naming the criterion it +serves. One child per step, in dependency order, one layer ahead of what has +merged; at most two or three open at a time; never a child for an unapproved +criterion. When you cannot derive the next step, the ticket steward's rules +apply: escalate only what the guidance does not settle, one question per +reply, record each ask, never repeat an open one. Where a wrong answer is reversible, record an assumption with `steward_update { assume: { text, context } }` and proceed, letting the next revision confirm it; ask only when the wrong answer is irreversible or blocks everything. A `(check: …)` criterion is judged by you from a child's output, not run by the plugin. Once the remaining criteria wait on an outcome (a -filed claim, a cycle run), add the `goal:awaiting-outcome` label and report -the wait; the label phase is what parks you, not a state change. +filed claim, a cycle run), add the `initiative:awaiting-outcome` label and +report the wait; the label phase is what parks you, not a state change. -**Three endings.** The binding ends when the goal closes, never on a merge -of a child. +**Three endings.** The binding ends when the initiative closes, never on a +merge of a child. -- **Reached:** every criterion is met. Ask the owner to close the goal, +- **Reached:** every criterion is met. Ask the owner to close the initiative, naming the `**Met:**` comments in one closing comment, and take the wrap-up turn. -- **Superseded:** a revision changes the outcome so far that a new goal is -filed. Close this goal with a `**Revision:**` comment pointing at the -successor, so the successor carries the outcome and this record says why it -ended. -- **Retired:** the owner closes the goal as not planned. Take the wrap-up -turn and end; do not reopen it yourself. +- **Superseded:** a revision changes the outcome so far that a new initiative +is filed. Close this initiative with a `**Revision:**` comment pointing at +the successor, so the successor carries the outcome and this record says why +it ended. +- **Retired:** the owner closes the initiative as not planned. Take the +wrap-up turn and end; do not reopen it yourself. ## If you are the project steward diff --git a/plugins/stewards/wake.test.ts b/plugins/stewards/wake.test.ts index 78ea158c..80b8091e 100644 --- a/plugins/stewards/wake.test.ts +++ b/plugins/stewards/wake.test.ts @@ -7,7 +7,7 @@ import { comment, issue, pull } from "./fixtures.js"; import { gateState } from "./reconcile.js"; import { MIGRATIONS, RESOLUTION_KINDS, createStore } from "./store.js"; import { DEPS_PRS, GITHUB_PRS, GITHUB_REVIEWS, LINEAR_TICKETS, OPS_WATCH, DEPS_ALERTS, PLAYBOOK_TEMPLATES } from "./templates.js"; -import { STANDING_RULES, BRIEF_PREFIX, formatBrief, formatDepsWake, formatOpsWake, formatProjectWake, formatRecords, formatWake, goalProgress, goalProgressFlag, spawnCommand, workerFinishNote, workerQuestion, type DigestRecords, type WakeInput } from "./wake.js"; +import { STANDING_RULES, BRIEF_PREFIX, formatBrief, formatDepsWake, formatOpsWake, formatProjectWake, formatRecords, formatWake, initiativeProgress, initiativeProgressFlag, spawnCommand, workerFinishNote, workerQuestion, type DigestRecords, type WakeInput } from "./wake.js"; import { BRIEF_MAX_CHARS } from "./server.js"; import type { OpsFinding } from "./ops.js"; import type { DepsFinding } from "./deps.js"; @@ -736,7 +736,7 @@ describe("the ops and deps wake classification lines (BB-136)", () => { }); }); -describe("goal progress (BB-243)", () => { +describe("initiative progress (BB-243)", () => { const description = [ "## Outcome", "", @@ -752,21 +752,21 @@ describe("goal progress (BB-243)", () => { "", "The progress file.", ].join("\n"); - const goal = (over: Partial = {}) => issue({ labels: ["bb-managed", "goal"], description, ...over }); + const initiative = (over: Partial = {}) => issue({ labels: ["bb-managed", "initiative"], description, ...over }); const met = (text: string, id = text) => comment({ id, body: `**Met:** ${text}` }); it("counts distinct Met: comments against the description's criteria", () => { const { s, bind } = world(); - const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: goal({ comments: [met("Scope memo approved (owner)"), met("Expenses gathered (check: npm run expenses)")] }), pulls: [] } }); - expect(goalProgress(b)).toEqual({ met: 2, criteria: 3, capped: false }); - expect(goalProgressFlag(b)).toBe("goal met 2/3"); + const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: initiative({ comments: [met("Scope memo approved (owner)"), met("Expenses gathered (check: npm run expenses)")] }), pulls: [] } }); + expect(initiativeProgress(b)).toEqual({ met: 2, criteria: 3, capped: false }); + expect(initiativeProgressFlag(b)).toBe("criteria 2/3"); }); it("counts a criterion once when its Met: comment repeats", () => { const { s, bind } = world(); - const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: goal({ comments: [met("Scope memo approved (owner)", "c1"), met("scope memo approved (owner)", "c2")] }), pulls: [] } }); - expect(goalProgress(b)).toEqual({ met: 1, criteria: 3, capped: false }); - expect(goalProgressFlag(b)).toBe("goal met 1/3"); + const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: initiative({ comments: [met("Scope memo approved (owner)", "c1"), met("scope memo approved (owner)", "c2")] }), pulls: [] } }); + expect(initiativeProgress(b)).toEqual({ met: 1, criteria: 3, capped: false }); + expect(initiativeProgressFlag(b)).toBe("criteria 1/3"); }); it("counts the criteria a signed, evidenced Met: comment names, never above the checklist", () => { @@ -774,62 +774,62 @@ describe("goal progress (BB-243)", () => { const signed = (id: string, text: string) => comment({ id, body: `**Met:** ${text}\n\n_— from bb thread thr_steward_` }); const b = s.patch(bind("ENG-12").id, { lastSnapshot: { - entity: goal({ + entity: initiative({ comments: [signed("c1", "Scope memo approved (owner)"), signed("c2", "Scope memo approved — see docs/memo.md"), signed("c3", "Expenses gathered (check: npm run expenses)"), signed("c4", "Claim filed (owner)")], }), pulls: [], }, }); - expect(goalProgress(b)).toEqual({ met: 3, criteria: 3, capped: false }); - expect(goalProgressFlag(b)).toBe("goal met 3/3"); + expect(initiativeProgress(b)).toEqual({ met: 3, criteria: 3, capped: false }); + expect(initiativeProgressFlag(b)).toBe("criteria 3/3"); }); it("shows unknown, never 0, when no Met: comment can be read", () => { const { s, bind } = world(); - const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: goal({ comments: [] }), pulls: [] } }); - expect(goalProgress(b)).toEqual({ met: null, criteria: 3, capped: false }); - expect(goalProgressFlag(b)).toBe("goal met unknown"); + const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: initiative({ comments: [] }), pulls: [] } }); + expect(initiativeProgress(b)).toEqual({ met: null, criteria: 3, capped: false }); + expect(initiativeProgressFlag(b)).toBe("criteria unknown"); }); it("shows a lower bound when the snapshot held a full page of comments", () => { const { s, bind } = world(); const comments = Array.from({ length: 50 }, (_, i) => (i < 2 ? comment({ id: `c${i}`, body: `**Met:** ${i === 0 ? "Scope memo approved" : "Expenses gathered"}` }) : comment({ id: `c${i}`, body: `**Note:** noise ${i}` }))); - const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: goal({ comments }), pulls: [] } }); - expect(goalProgress(b)).toEqual({ met: 2, criteria: 3, capped: true }); - expect(goalProgressFlag(b)).toBe("goal met ≥2/3"); + const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: initiative({ comments }), pulls: [] } }); + expect(initiativeProgress(b)).toEqual({ met: 2, criteria: 3, capped: true }); + expect(initiativeProgressFlag(b)).toBe("criteria ≥2/3"); }); it("shows met without a criteria count when the description has no criteria section", () => { const { s, bind } = world(); - const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: goal({ description: "## Outcome\n\nJust an outcome.", comments: [met("Something")] }), pulls: [] } }); - expect(goalProgress(b)).toEqual({ met: 1, criteria: null, capped: false }); - expect(goalProgressFlag(b)).toBe("goal met 1"); + const b = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: initiative({ description: "## Outcome\n\nJust an outcome.", comments: [met("Something")] }), pulls: [] } }); + expect(initiativeProgress(b)).toEqual({ met: 1, criteria: null, capped: false }); + expect(initiativeProgressFlag(b)).toBe("criteria 1"); }); - it("knows a goal by its playbook before the first snapshot, and shows unknown", () => { + it("knows an initiative by its playbook before the first snapshot, and shows unknown", () => { const { s, bind } = world(); - const b = s.patch(bind("ENG-12").id, { playbook: "goal" }); - expect(goalProgress(b)).toEqual({ met: null, criteria: null, capped: false }); - expect(goalProgressFlag(b)).toBe("goal met unknown"); + const b = s.patch(bind("ENG-12").id, { playbook: "initiative" }); + expect(initiativeProgress(b)).toEqual({ met: null, criteria: null, capped: false }); + expect(initiativeProgressFlag(b)).toBe("criteria unknown"); }); - it("is null for a ticket without the goal label, and for a non-ticket", () => { + it("is null for a ticket without the initiative label, and for a non-ticket", () => { const { s, bind } = world(); const plain = s.patch(bind("ENG-12").id, { lastSnapshot: { entity: issue({ comments: [met("Something")] }), pulls: [] } }); - expect(goalProgress(plain)).toBeNull(); - expect(goalProgressFlag(plain)).toBeNull(); - expect(goalProgress({ ...plain, kind: "pr" })).toBeNull(); + expect(initiativeProgress(plain)).toBeNull(); + expect(initiativeProgressFlag(plain)).toBeNull(); + expect(initiativeProgress({ ...plain, kind: "pr" })).toBeNull(); }); it("rides on the project steward's binding list and digest lines", () => { const { s, bind } = world(); - const b = s.patch(bind("ENG-12").id, { status: status("Driving the goal."), advancedAt: T - 3_600_000, lastSnapshot: { entity: goal({ comments: [met("Scope memo approved (owner)"), met("Claim filed (owner)")] }), pulls: [] } }); + const b = s.patch(bind("ENG-12").id, { status: status("Driving the initiative."), advancedAt: T - 3_600_000, lastSnapshot: { entity: initiative({ comments: [met("Scope memo approved (owner)"), met("Claim filed (owner)")] }), pulls: [] } }); const records: DigestRecords = { previous: null, since: T - DAY, moved: [b], ended: [], answered: [], withUser: [], stuck: [], noWakeSource: [b], stall: [], held: [b] }; const wake = formatProjectWake({ reason: "nightly", bindings: [{ binding: b, openEscalations: [] }], routed: [], problems: [], digestDue: true, notes: [], bigDecisions: [], questions: [], records }); - expect(wake).toContain("- ENG-12 (ticket, In Progress): Driving the goal. Next: Open the PR (steward) [goal met 2/3]"); - expect(wake).toMatch(/- ENG-12 \(ticket, In Progress\), moved .*\[goal met 2\/3\]/u); - expect(wake).toMatch(/- ENG-12: on hold: .*\[goal met 2\/3\]/u); - expect(wake).toMatch(/- ENG-12 \(ticket, In Progress\): waiting with no wake source.*\[goal met 2\/3\]/u); + expect(wake).toContain("- ENG-12 (ticket, In Progress): Driving the initiative. Next: Open the PR (steward) [criteria 2/3]"); + expect(wake).toMatch(/- ENG-12 \(ticket, In Progress\), moved .*\[criteria 2\/3\]/u); + expect(wake).toMatch(/- ENG-12: on hold: .*\[criteria 2\/3\]/u); + expect(wake).toMatch(/- ENG-12 \(ticket, In Progress\): waiting with no wake source.*\[criteria 2\/3\]/u); }); }); diff --git a/plugins/stewards/wake.ts b/plugins/stewards/wake.ts index f7c1e99b..051572af 100644 --- a/plugins/stewards/wake.ts +++ b/plugins/stewards/wake.ts @@ -5,7 +5,7 @@ // Each wake is self-contained. A steward that has compacted away everything // it ever saw can act correctly from one wake alone, which is what lets its // transcript stop being the source of truth. -import { formatDuration, GITHUB_TODO_LABEL, GOAL_LABEL, GOAL_PLAYBOOK, phaseInstructions, type FilingTarget, type LessonRules, type Playbook } from "./config.js"; +import { formatDuration, GITHUB_TODO_LABEL, INITIATIVE_LABEL, INITIATIVE_PLAYBOOK, phaseInstructions, type FilingTarget, type LessonRules, type Playbook } from "./config.js"; import type { BigDecision } from "./decisions.js"; import { anyPending, type Deployments, type DeploymentWatch } from "./deploy.js"; import { localParts } from "./nightly.js"; @@ -1276,10 +1276,11 @@ function criteriaKeys(description: string): string[] { } /** - * A goal's progress (BB-243): `met` is the number of the description's + * An initiative's progress (BB-243): `met` is the number of the description's * criteria a `**Met:**` comment names, `criteria` the number of checklist - * lines under its `Criteria` heading. Null when the ticket is not a goal — it - * carries neither the `goal` label nor the `goal` playbook. + * lines under its `Criteria` heading. Null when the ticket is not an + * initiative — it carries neither the `initiative` label nor the `initiative` + * playbook. * * A criterion is named when a `**Met:**` comment's first line, normalised, * equals it or either is a prefix of the other. Evidence and the signature on @@ -1289,16 +1290,17 @@ function criteriaKeys(description: string): string[] { * null. * * `met` is null rather than 0 when no `**Met:**` comment can be read (or the - * snapshot has not been read yet), so a goal that has not been driven reads - * `unknown`, never `0`: an empty count cannot be told from an unread history, - * and only one of them means no criterion is met. `capped` is true when the - * snapshot held a full page of comments, so the count is a lower bound. + * snapshot has not been read yet), so an initiative that has not been driven + * reads `unknown`, never `0`: an empty count cannot be told from an unread + * history, and only one of them means no criterion is met. `capped` is true + * when the snapshot held a full page of comments, so the count is a lower + * bound. */ -export function goalProgress(binding: Pick): { met: number | null; criteria: number | null; capped: boolean } | null { +export function initiativeProgress(binding: Pick): { met: number | null; criteria: number | null; capped: boolean } | null { if (binding.kind !== "ticket") return null; const entity = binding.lastSnapshot?.entity; - const byLabel = entity !== undefined && entity.labels.some((l) => l.toLowerCase() === GOAL_LABEL); - if (!byLabel && binding.playbook !== GOAL_PLAYBOOK) return null; + const byLabel = entity !== undefined && entity.labels.some((l) => l.toLowerCase() === INITIATIVE_LABEL); + if (!byLabel && binding.playbook !== INITIATIVE_PLAYBOOK) return null; if (entity === undefined) return { met: null, criteria: null, capped: false }; const criteria = criteriaKeys(entity.description ?? ""); const names = new Set(); @@ -1317,18 +1319,18 @@ export function goalProgress(binding: Pick): string | null { - const p = goalProgress(binding); +export function initiativeProgressFlag(binding: Pick): string | null { + const p = initiativeProgress(binding); if (p === null) return null; - if (p.met === null) return "goal met unknown"; + if (p.met === null) return "criteria unknown"; const met = `${p.capped ? "≥" : ""}${p.met}`; - return p.criteria === null ? `goal met ${met}` : `goal met ${met}/${p.criteria}`; + return p.criteria === null ? `criteria ${met}` : `criteria ${met}/${p.criteria}`; } /** @@ -1475,7 +1477,7 @@ export function formatProjectWake(input: { for (const { binding: b, openEscalations } of input.bindings.slice(0, 200)) { const s = b.status; const conflicts = conflictsOf(b, allOpen); - const flags = [goalProgressFlag(b), b.priority === null ? null : `priority ${b.priority}`, b.hold === null ? null : `HOLD: ${b.hold}${b.holdBehind.length === 0 ? "" : ` (behind ${b.holdBehind.join(", ")})`}${b.holdStack.length === 0 ? "" : ` (stacked on ${b.holdStack.join(", ")})`}`, b.touches.length === 0 ? null : `touches ${b.touches.join(", ")}`, conflicts.length === 0 ? null : `file-level overlap: ${conflicts.map((c) => { const open = c.with.lastSnapshot === null ? null : openPull(c.with, c.with.lastSnapshot); return `${c.with.entityKey} on ${c.on.join(", ")}${open === null || open.head === null || open.head === "" ? "" : ` (its pull request ${open.key} is open on ${open.head})`}`; }).join("; ")}`, openEscalations.length > 0 ? `${openEscalations.length} escalation(s): ${openEscalations.map((x) => `${x.kind}→${x.route}`).join(", ")}` : null, unheardWait(s, openEscalations)].filter((f): f is string => f !== null); + const flags = [initiativeProgressFlag(b), b.priority === null ? null : `priority ${b.priority}`, b.hold === null ? null : `HOLD: ${b.hold}${b.holdBehind.length === 0 ? "" : ` (behind ${b.holdBehind.join(", ")})`}${b.holdStack.length === 0 ? "" : ` (stacked on ${b.holdStack.join(", ")})`}`, b.touches.length === 0 ? null : `touches ${b.touches.join(", ")}`, conflicts.length === 0 ? null : `file-level overlap: ${conflicts.map((c) => { const open = c.with.lastSnapshot === null ? null : openPull(c.with, c.with.lastSnapshot); return `${c.with.entityKey} on ${c.on.join(", ")}${open === null || open.head === null || open.head === "" ? "" : ` (its pull request ${open.key} is open on ${open.head})`}`; }).join("; ")}`, openEscalations.length > 0 ? `${openEscalations.length} escalation(s): ${openEscalations.map((x) => `${x.kind}→${x.route}`).join(", ")}` : null, unheardWait(s, openEscalations)].filter((f): f is string => f !== null); out.push(`- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}): ${s === null ? "no report yet" : `${s.summary} Next: ${s.nextAction} (${s.actor})${s.waitingOn === null ? "" : `; waiting on ${s.waitingOn}${b.requeueUntil === null ? "" : ` until ${day(b.requeueUntil)}`}`}`}${flags.length > 0 ? ` [${flags.join("; ")}]` : ""}`); } const bindings = out.splice(0); @@ -1636,15 +1638,15 @@ export function formatRecords(r: DigestRecords, questions: Array<{ question: Que if (r.previous === null) out.push("### Your previous digest", "", "None yet.", ""); else out.push(`### Your previous digest (${iso(r.previous.at)})`, "", quote(clip(r.previous.text, PREVIOUS_DIGEST_CHARS)), ""); - // A goal's progress rides on its line, wherever the digest lists it (BB-243). - const goalFlag = (b: Binding): string => { - const flag = goalProgressFlag(b); + // An initiative's progress rides on its line, wherever the digest lists it (BB-243). + const initiativeFlag = (b: Binding): string => { + const flag = initiativeProgressFlag(b); return flag === null ? "" : ` [${flag}]`; }; const moved = [ ...r.moved.map((b) => { const s = b.status; - return `- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}), moved ${b.advancedAt === null ? "?" : iso(b.advancedAt)}: ${s === null ? "no report yet" : `${oneLine(s.summary)} Next: ${oneLine(s.nextAction)} (${s.actor})`}${goalFlag(b)}`; + return `- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}), moved ${b.advancedAt === null ? "?" : iso(b.advancedAt)}: ${s === null ? "no report yet" : `${oneLine(s.summary)} Next: ${oneLine(s.nextAction)} (${s.actor})`}${initiativeFlag(b)}`; }), ...r.ended.map((b) => `- Ended: ${b.entityKey} (${b.kind}${b.title === null ? "" : `, ${oneLine(b.title, 120)}`}), ${b.endReason ?? "ended"} at ${b.endedAt === null ? "?" : iso(b.endedAt)}`), ...r.answered.map((q) => `- Answered: ${q.id} "${oneLine(q.question, 200)}" → ${oneLine(q.answer ?? "", 300)} (${q.answeredBy === "user" ? "by the user, on the stewards page" : "recorded by you"})`), @@ -1678,14 +1680,14 @@ export function formatRecords(r: DigestRecords, questions: Array<{ question: Que const stuck = [ ...r.stuck.map(({ escalation: x, from }) => `- ${from.entityKey}: stuck escalation ${x.id} with ${x.route}, since ${day(x.createdAt)}: ${oneLine(x.question)}${choicesNote(x.choices)}`), - ...r.held.map((b) => `- ${b.entityKey}: on hold: ${oneLine(b.hold ?? "")}${b.holdBehind.length === 0 ? "" : ` (behind ${b.holdBehind.join(", ")})`}${b.holdStack.length === 0 ? "" : ` (stacked on ${b.holdStack.join(", ")})`}${goalFlag(b)}`), + ...r.held.map((b) => `- ${b.entityKey}: on hold: ${oneLine(b.hold ?? "")}${b.holdBehind.length === 0 ? "" : ` (behind ${b.holdBehind.join(", ")})`}${b.holdStack.length === 0 ? "" : ` (stacked on ${b.holdStack.join(", ")})`}${initiativeFlag(b)}`), ]; out.push("### Stuck or held", "", ...capped(stuck, "Nothing."), ""); // BB-247: a dated wait is not a quiet stall: the plugin will wake the steward // at the date, so it is listed in its own section rather than under "waiting // with no wake source". - const dated = (r.datedWaits ?? []).map((b) => `- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}): waiting on ${oneLine(b.status?.waitingOn ?? "")} until ${day(b.requeueUntil!)}${goalFlag(b)}`); + const dated = (r.datedWaits ?? []).map((b) => `- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}): waiting on ${oneLine(b.status?.waitingOn ?? "")} until ${day(b.requeueUntil!)}${initiativeFlag(b)}`); out.push("### Dated waits", "", ...capped(dated, "Nothing."), ""); // BB-154: the quiet stall, visible once a day even before the requeue @@ -1693,7 +1695,7 @@ export function formatRecords(r: DigestRecords, questions: Array<{ question: Que // a stall can be open with the mark already cleared (the stall is itself a // live source), so the two lists are separate. const noWake = [ - ...r.noWakeSource.map((b) => `- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}): waiting with no wake source${b.status?.waitingOn === null || b.status?.waitingOn === undefined ? "" : `: ${oneLine(b.status.waitingOn)}`}${b.requeueWakeCount > 0 ? ` (${b.requeueWakeCount} requeue-only wake${b.requeueWakeCount === 1 ? "" : "s"})` : ""}${goalFlag(b)}`), + ...r.noWakeSource.map((b) => `- ${b.entityKey} (${b.kind}, ${b.phase ?? "?"}): waiting with no wake source${b.status?.waitingOn === null || b.status?.waitingOn === undefined ? "" : `: ${oneLine(b.status.waitingOn)}`}${b.requeueWakeCount > 0 ? ` (${b.requeueWakeCount} requeue-only wake${b.requeueWakeCount === 1 ? "" : "s"})` : ""}${initiativeFlag(b)}`), ...r.stall.map(({ escalation: x, from }) => `- ${from.entityKey}: stall escalation ${x.id} with the project steward, since ${day(x.createdAt)}: ${oneLine(x.question)}`), ]; out.push("### Waiting with no wake source", "", ...capped(noWake, "Nothing."), ""); @@ -1708,7 +1710,7 @@ export const PROJECT_STEWARD_INTRO = `You are this project's steward. Every Line - Before you ask the user something in a reply, record it with steward_update { ask: { question, context } } (with binding when it concerns one); close it with steward_update { resolve: "", answer } when they answer. Every wake lists the questions still open, so list them from there, not from memory. - You are woken by escalations, at the end of each nightly pass to write the morning digest, and by the user. When the user says something like "hold everything touching billing", turn it into steward_update calls on the bindings it concerns, and say what you changed. - You schedule the work so that two tickets do not change the same files at once. Every binding reports what it touches; when a ready ticket overlaps work in flight at file level, the plugin asks you with a schedule escalation. Hold it behind that work (steward_update { binding, hold, behind: [keys] }: the hold lifts itself when the work lands), stack it on a pull request still being built (steward_update { binding, hold, stack: [keys] }: the hold lifts itself, with the branch, when that pull request opens), or let it start (guidance + resolve). Use the same holds to sequence any two tickets whose overlap you can see in the bindings list. -- A goal's binding line carries \`goal met /\`, counted from its \`**Met:**\` comments against the criteria in its description (BB-243). \`unknown\` means no \`**Met:**\` comment could be read — never that none is met — so a goal that has not been driven yet is not mistaken for one with nothing met. +- An initiative's binding line carries \`criteria /\`, counted from its \`**Met:**\` comments against the criteria in its description (BB-243). \`unknown\` means no \`**Met:**\` comment could be read — never that none is met — so an initiative that has not been driven yet is not mistaken for one with nothing met. - Budget is advisory: keep the total work sensible through priority and holds. Wait for the user or a wake; there is nothing to do right now.`;