Public: anyone can read this; the crew can change it.
The sentinel never files a builder issue for a need only a person can settle; it goes to the owner's inbox with the one action #12617
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/12613-the-sentinel-never-files-a-builder-issue → main 19 commits fork 1 thread · 1 unresolved
4 files
changed +60
−1
src/actions/needs.ts +14
| @@ -194,6 +194,20 @@ export function forgeRecommended(cause: string, sentence: string): Recommended { | ||
| 194 | 194 | }; |
| 195 | 195 | if (cause.startsWith("drill:")) |
| 196 | 196 | return needsDecision(sentence, "a standby drill causes a real fault and needs an operator at the keyboard; the forge cannot run it for you", ["Run it with the command", "Leave it"]); |
| 197 | // Person-only (#12613): the sentinel files no issue for these, so this card is the one place | |
| 198 | // the action is named. A builder's token does not reach the repository. | |
| 199 | if (cause.startsWith("backup-refs:")) | |
| 200 | return needsDecision( | |
| 201 | `${sentence} Re-push each branch from a clone that still has its commits (check with \`git cat-file -e <oid>\` there first), or delete the branch if its work is gone.`, | |
| 202 | "only a person with access to that repository can restore or delete its branches; deleting a branch cannot be undone", | |
| 203 | ["Re-push the branches", "Delete the branches"], | |
| 204 | ); | |
| 205 | if (cause.startsWith("backup-repo:")) | |
| 206 | return needsDecision( | |
| 207 | `${sentence} Repair the repository so the next snapshot can read it, or delete it if it is no longer wanted.`, | |
| 208 | "only a person with access to that repository can repair or delete it; deleting it cannot be undone", | |
| 209 | ["Repair the repository", "Delete the repository"], | |
| 210 | ); | |
| 197 | 211 | if (cause.startsWith("db-")) |
| 198 | 212 | return needsDecision(`${sentence} Make room, or leave it?`, "the database's size has no safe default: clearing it loses data, leaving it keeps growing", ["Make room", "Leave it"]); |
| 199 | 213 | if (cause.startsWith("queue:")) |
src/crew/sentinel.ts +10
| @@ -463,6 +463,12 @@ export function degradedCauses(db: Database, now: number, forgeRepoId?: string, | ||
| 463 | 463 | */ |
| 464 | 464 | const BREACH_CAUSE = /^(queue:check|stuck:|budget:|red:|shared:)/; |
| 465 | 465 | |
| 466 | /** | |
| 467 | * Causes only a person can settle (#12613): never filed as an issue a builder could be given. | |
| 468 | * Each stays a vitals card in the owner's needs, with its one action (`forgeRecommended`). | |
| 469 | */ | |
| 470 | export const PERSON_ONLY: readonly string[] = ["backup-refs:", "backup-repo:"]; | |
| 471 | ||
| 466 | 472 | /** |
| 467 | 473 | * A red main in another repository is its owner's to fix, not the forge's |
| 468 | 474 | * (#3992): the crew cannot see that repository, so no issue is filed here. |
| @@ -475,6 +481,10 @@ export function ownCause(cause: string, forgeRepoId: string | undefined): boolea | ||
| 475 | 481 | // The forges' sizes against the machine's memory are the owner's to change (a bigger machine, |
| 476 | 482 | // smaller forges): no builder can, so no issue. The line stays where the owner reads it. |
| 477 | 483 | if (cause === "forges-memory") return false; |
| 484 | // What a snapshot could not hold of a repository (#12613): re-pushing a branch from a clone | |
| 485 | // that has its commits, or deleting it, is a person's with access to that repository; no | |
| 486 | // builder's token reaches it (#12608 was declined three times). The owner's card names it. | |
| 487 | if (PERSON_ONLY.some((p) => cause.startsWith(p))) return false; | |
| 478 | 488 | if (forgeRepoId === undefined) return true; |
| 479 | 489 | if (cause.startsWith("red:")) return cause === `red:${forgeRepoId}`; |
| 480 | 490 | if (cause.startsWith("shared:")) return cause.split(":")[1] === forgeRepoId; |
test/forge-needs-defaults.test.ts +24 −1
| @@ -23,7 +23,7 @@ import { recordVerdict } from "../src/snapshot/verdict.ts"; | ||
| 23 | 23 | import type { DrillResult } from "../src/snapshot/drill.ts"; |
| 24 | 24 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 25 | 25 | import { dirStore } from "../src/snapshot/store.ts"; |
| 26 | import { needsScreen } from "../src/tui/screens/needs.ts"; | |
| 26 | import { needsScreen, whyNot } from "../src/tui/screens/needs.ts"; | |
| 27 | 27 | import type { Ctx as TuiCtx } from "../src/tui/app/app.ts"; |
| 28 | 28 | import type { Session } from "../src/tui/session.ts"; |
| 29 | 29 | import type { ForgeEvent } from "../src/core/events.ts"; |
| @@ -78,6 +78,29 @@ test("forge needs: the restore drill is a default; a database, a queue and a sta | ||
| 78 | 78 | } |
| 79 | 79 | }); |
| 80 | 80 | |
| 81 | test("forge needs: a backup-refs card is the owner's ask and names its action, re-push or delete (#12613)", () => { | |
| 82 | const sentence = "2 branches of scout/forge cannot be backed up: their commits are missing (a, b)."; | |
| 83 | const r = forgeRecommended("backup-refs:scout/forge", sentence); | |
| 84 | expect(r).toMatchObject({ choice: "Needs your decision", safe: false }); | |
| 85 | expect(r.ask).toStartWith(sentence); | |
| 86 | expect(r.ask).toContain("Re-push each branch from a clone that still has its commits"); | |
| 87 | expect(r.ask).toContain("git cat-file -e"); | |
| 88 | expect(r.options).toEqual(["Re-push the branches", "Delete the branches"]); | |
| 89 | const repo = forgeRecommended("backup-repo:scout/gone", "scout/gone is not in the snapshot: unreadable."); | |
| 90 | expect(repo.ask).toContain("Repair the repository"); | |
| 91 | expect(repo.options).toEqual(["Repair the repository", "Delete the repository"]); | |
| 92 | }); | |
| 93 | ||
| 94 | test("the terminal shows a backup-refs card's ask on a, the same words as the page (#12613)", () => { | |
| 95 | const sentence = "1 branch of scout/forge cannot be backed up: its commit is missing (a)."; | |
| 96 | const recommended = forgeRecommended("backup-refs:scout/forge", sentence); | |
| 97 | // The shape needsStack gives a forge card: the page and the terminal both read `recommended`. | |
| 98 | const need = { id: "forge:backup-refs:scout/forge", sentence, why: "", waits: "", choices: ["Open it"], recommended, link: "/system", items: [] }; | |
| 99 | const said = whyNot({ user: alice, db: app.db, app } as unknown as Session, need); | |
| 100 | expect(said).toBe(recommended.ask!); | |
| 101 | expect(said).toContain("Re-push each branch from a clone that still has its commits"); | |
| 102 | }); | |
| 103 | ||
| 81 | 104 | let branchN = 0; |
| 82 | 105 | /** |
| 83 | 106 | * An open pull by `author`, its check failed; `stopped` adds the crew's stop, so it is a stopped |
test/sentinel.test.ts +12
| @@ -634,6 +634,18 @@ describe("degraded causes", () => { | ||
| 634 | 634 | plantSpan(`shared:${drepo.id}:abc`, day - 2 * 3_600_000, 30); |
| 635 | 635 | expect(degradedCauses(dapp.db, day, drepo.id).map((f) => f.key).length).toBe(1); |
| 636 | 636 | }); |
| 637 | ||
| 638 | test("a backup-refs or backup-repo cause is a person's: the hunt opens no issue a builder could pick (#12613)", () => { | |
| 639 | const day = D_NIGHT + 20 * D_DAY; | |
| 640 | plantSpan("backup-refs:scout/forge", day - 5 * 3_600_000, 30); | |
| 641 | plantSpan("backup-repo:scout/gone", day - 4 * 3_600_000, 30); | |
| 642 | expect(degradedCauses(dapp.db, day, drepo.id)).toEqual([]); | |
| 643 | expect(degradedCauses(dapp.db, day)).toEqual([]); | |
| 644 | const before = openIssues().length; | |
| 645 | expect(hunt(dapp, "alice/forge", day).filed).toBe(0); | |
| 646 | expect(openIssues().length).toBe(before); | |
| 647 | expect(openIssues().some((i) => i.title.includes("backup-"))).toBe(false); | |
| 648 | }); | |
| 637 | 649 | }); |
| 638 | 650 | |
| 639 | 651 | // ---- budget breaches (#1270) ---- |
new above
offline