@astrofoundry/pi-astro 0.40.46 → 0.40.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,13 +94,20 @@ function entry(r: ArcaneReport, stack: string): StackEntry {
94
94
  }
95
95
 
96
96
  describe("Arcane Daily Report layout", () => {
97
+ it("marks the images our own CI builds", () => {
98
+ const own = { stack: "bigcapital", service: "server", ref: "ghcr.io/astrofoundry/bigcapital-server:astrofoundry", running: "?", latest: "new build", status: "update", action: "pull", note: "versions unavailable: private image" };
99
+ const built = buildStacks({ ...updateReport, rows: [rows[0], own] });
100
+ expect(built?.stacks.find((s) => s.stack === "bigcapital")?.lines[0].own).toBe(true);
101
+ expect(built?.stacks.find((s) => s.stack === "vpn")?.lines[0].own).toBeUndefined();
102
+ });
103
+
97
104
  it("draws one section per stack with its services and the kind of change", () => {
98
105
  const r = report();
99
106
  entry(r, "stirling-pdf").lines[0].review = { verdict: "check", reason: "the config key changed" };
100
107
  const [page] = layoutMessages(r);
101
108
  expect(page).toEqual({ head: true, stacks: ["arcane", "bigcapital", "media", "postgres", "stirling-pdf", "supabase", "vpn", "x"] });
102
109
  const components = messageComponents(r, page);
103
- expect(components[0]).toEqual({ type: 10, content: `**${REPORT_PREFIX}** 6 stacks with updates (44 images, 2 private excluded, checked 06:00 CEST).` });
110
+ expect(components[0]).toEqual({ type: 10, content: `**${REPORT_PREFIX}** 6 stacks with updates (44 images, 2 pinned private excluded, checked 06:00 CEST).` });
104
111
  const text = (c: (typeof components)[number]) => (c.type === 9 ? c.components?.[0].content : c.content);
105
112
  expect(components.slice(1).map(text)).toEqual([
106
113
  "**arcane**\n• arcane: v2.16.1 → v2.17.0 · new version (digest pin)",
@@ -142,7 +149,7 @@ describe("Arcane Daily Report layout", () => {
142
149
  it("says so when nothing needs updating, warns about an unreadable holds file, and refuses a bad answer", () => {
143
150
  const empty = buildStacks({ ...updateReport, rows: [], holds: {}, holdsError: "update-holds.json is not JSON" });
144
151
  if (!empty) throw new Error("no report");
145
- expect(headText({ ...empty, timeZone: "Europe/Madrid" }).content).toBe(`**${REPORT_PREFIX}** no updates (44 images, 2 private excluded, checked 06:00 CEST).\n-# ⚠️ update-holds.json is not JSON; Update still refuses held stacks`);
152
+ expect(headText({ ...empty, timeZone: "Europe/Madrid" }).content).toBe(`**${REPORT_PREFIX}** no updates (44 images, 2 pinned private excluded, checked 06:00 CEST).\n-# ⚠️ update-holds.json is not JSON; Update still refuses held stacks`);
146
153
  expect(buildStacks({ nonsense: true })).toBeNull();
147
154
  expect(failureMessage().startsWith(REPORT_PREFIX)).toBe(true);
148
155
  });
@@ -4,6 +4,7 @@ import { parseImageRef } from "../../specialists/lib/registry.ts";
4
4
  import { configDir } from "./config.ts";
5
5
  import { escapeDiscord } from "./media.ts";
6
6
  import type { MessageComponent } from "./rest.ts";
7
+ import { isOwnImage } from "./security.ts";
7
8
  import type { ReleaseNote } from "../../specialists/lib/releases.ts";
8
9
  import type { Review, Verdict } from "./tools-report.ts";
9
10
  import type { Plan } from "./update-policy.ts";
@@ -79,6 +80,8 @@ export interface ServiceLine {
79
80
  major: boolean;
80
81
  note: string;
81
82
  review?: Review;
83
+ /** The image is one our own CI builds, so its update goes through Upgrade carefully. */
84
+ own?: boolean;
82
85
  }
83
86
 
84
87
  export type StackState = "offered" | "running" | "updated" | "rolled back" | "failed" | "current" | "planning";
@@ -160,7 +163,8 @@ export function buildStacks(report: unknown): ReportStacks | null {
160
163
  .map((r): ServiceLine => {
161
164
  const running = releaseTag(r.running);
162
165
  const latest = releaseTag(r.latest);
163
- return { service: r.service, status: r.status, action: r.action ?? "", running, latest, tag: tagOf(r.ref ?? ""), ...(r.ref ? { ref: r.ref } : {}), major: PENDING.has(r.status) && crossesMajor(running, latest), note: r.note ?? "" };
166
+ const own = r.ref ? isOwnImage(r.ref) : false;
167
+ return { service: r.service, status: r.status, action: r.action ?? "", running, latest, tag: tagOf(r.ref ?? ""), ...(r.ref ? { ref: r.ref } : {}), major: PENDING.has(r.status) && crossesMajor(running, latest), note: r.note ?? "", ...(own ? { own } : {}) };
164
168
  });
165
169
  const pending = lines.some((l) => PENDING.has(l.status));
166
170
  const held = holds[stack];
@@ -287,7 +291,7 @@ type ReportView = Omit<ArcaneReport, "messages" | "date" | "channelId">;
287
291
 
288
292
  export function headText(report: ReportView): MessageComponent {
289
293
  const withUpdates = report.stacks.filter((s) => s.lines.some((l) => PENDING.has(l.status))).length;
290
- const scope = `${report.images} images${report.privateCount > 0 ? `, ${report.privateCount} private excluded` : ""}, checked ${clock(report.checkedAt, report.timeZone)}`;
294
+ const scope = `${report.images} images${report.privateCount > 0 ? `, ${report.privateCount} pinned private excluded` : ""}, checked ${clock(report.checkedAt, report.timeZone)}`;
291
295
  const head =
292
296
  report.stacks.length === 0
293
297
  ? `**${REPORT_PREFIX}** no updates (${scope}).`
@@ -300,7 +300,8 @@ describe("security monitor", () => {
300
300
  const summary = await h.monitor.dailyReport(SCHEDULE, "2026-10-21");
301
301
  expect(h.rest.messages).toEqual([]);
302
302
  const text = JSON.stringify(h.rest.components[0].components);
303
- expect(text).toContain("🐳 **Arcane images** · 1 critical CVE whose package has a fix, in 1 image\\n- waiting on the publisher: nginx 1");
303
+ expect(text).toContain("🐳 **Arcane images** · 1 critical CVE whose package has a fix, in 1 image\"");
304
+ expect(text).not.toContain("waiting on the publisher");
304
305
  expect(h.calls).toContainEqual(["arcane", "images", "list", "--all"]);
305
306
  expect(h.calls).toContainEqual(["arcane", "images", "vulnerabilities", "list", "--severity", "critical", "--all"]);
306
307
  expect(summary).toEqual({ headline: "quiet day (24 h to 06:05 CEST)", tagged: false, messageId: "100" });
@@ -433,7 +433,10 @@ describe("Arcane image scans", () => {
433
433
  expect(offeredImages(null, offers)).toEqual([]);
434
434
  expect(imageVulnLine(null, offers)).toBe("Arcane images · the check failed");
435
435
  expect(imageVulnLine({ scanned: 0, total: 57, critical: [] }, offers)).toBe("Arcane images · no Trivy scan yet (57 images)");
436
- expect(imageVulnLine({ ...facts, critical: facts.critical.slice(4) }, new Map(), undefined, 0)).toBe("Arcane images · 1 critical CVE whose package has a fix, in 1 image · waiting on the publisher: +1 more");
436
+ expect(imageVulnLine({ ...facts, critical: facts.critical.slice(4) }, new Map(), undefined, 1)).toBe("Arcane images · 1 critical CVE whose package has a fix, in 1 image · waiting on the publisher: nginx 1");
437
+ expect(imageVulnLine(facts, offers, undefined, 0)).toBe(
438
+ "Arcane images · 5 critical CVEs whose package has a fix, in 3 images · update offered in the Arcane Daily Report: mealie 3 (mealie) · held: postgres:15.8.1.085 1 (supabase: coordinated release: review first)",
439
+ );
437
440
  });
438
441
 
439
442
  it("names our own images with their build date and a newer build waiting in the registry", () => {
@@ -661,7 +661,7 @@ export function offeredImages(facts: ImageVulnFacts | null, offers: ReadonlyMap<
661
661
  return [...stacks].sort();
662
662
  }
663
663
 
664
- function isOwnImage(image: string): boolean {
664
+ export function isOwnImage(image: string): boolean {
665
665
  const repo = repositoryOf(image);
666
666
  return repo !== null && OWN_IMAGE_PREFIXES.some((p) => repo.startsWith(p));
667
667
  }
@@ -686,6 +686,7 @@ function buildText(build: ImageBuild | undefined): string {
686
686
  * Critical CVEs whose package has a fixed version, grouped by who can act:
687
687
  * our own images (with their build date), images an update in the Arcane
688
688
  * Daily Report replaces, held stacks, and images waiting on their publisher.
689
+ * A `maxWaiting` of 0 leaves the publisher group out: nobody here can act on it.
689
690
  */
690
691
  export function imageVulnLine(facts: ImageVulnFacts | null, offers: ReadonlyMap<string, ImageOffer>, arcaneChannelId?: string, maxWaiting = 5): string {
691
692
  if (!facts) return "Arcane images · the check failed";
@@ -712,7 +713,7 @@ export function imageVulnLine(facts: ImageVulnFacts | null, offers: ReadonlyMap<
712
713
  if (offered.length > 0) parts.push(`update offered${arcaneChannelId ? ` in <#${arcaneChannelId}>` : " in the Arcane Daily Report"}: ${offered.join(", ")}`);
713
714
  if (held.length > 0) parts.push(`held: ${held.join(", ")}`);
714
715
  const rest = waiting.length - Math.min(waiting.length, maxWaiting);
715
- if (waiting.length > 0) parts.push(`waiting on the publisher: ${[...waiting.slice(0, maxWaiting), ...(rest > 0 ? [`+${rest} more`] : [])].join(", ")}`);
716
+ if (waiting.length > 0 && maxWaiting > 0) parts.push(`waiting on the publisher: ${[...waiting.slice(0, maxWaiting), ...(rest > 0 ? [`+${rest} more`] : [])].join(", ")}`);
716
717
  return parts.join(" · ");
717
718
  }
718
719
 
@@ -783,7 +784,7 @@ export function dailyCard(d: DailyData, owners: readonly string[]): ReportCard {
783
784
  section("👁️", d.wazuh.line),
784
785
  section("📦", vulnLine(d.found)),
785
786
  section("🩹", patchLine(d.closed)),
786
- section("🐳", imageVulnLine(d.images, d.offers, d.arcaneChannelId)),
787
+ section("🐳", imageVulnLine(d.images, d.offers, d.arcaneChannelId, 0)),
787
788
  section("🩺", healthLine(d.attention)),
788
789
  ];
789
790
  return {
@@ -13,6 +13,7 @@ describe("update policy", () => {
13
13
 
14
14
  it("plans carefully when notes need attention, even for a minor update", () => {
15
15
  expect(stackPlan([{ major: false, review: check }])).toBe("careful");
16
+ expect(stackPlan([{ major: false, review: none }, { major: false, own: true }])).toBe("careful");
16
17
  expect(stackPlan([{ major: true, review: none }, { major: false, review: { verdict: "breaking", reason: "x" } }])).toBe("careful");
17
18
  });
18
19
 
@@ -4,7 +4,7 @@ import type { Review } from "./tools-report.ts";
4
4
  * What the morning run does with an offered update (approved 2026-10-23):
5
5
  * - `auto`: applied without anyone and checked again minutes later;
6
6
  * - `update`: the owners are tagged, and Update runs it on its own (a major whose notes raise nothing);
7
- * - `careful`: the owners are tagged, and Upgrade carefully plans it in a thread first (the notes need attention, or there are none for a major);
7
+ * - `careful`: the owners are tagged, and Upgrade carefully plans it in a thread first (the notes need attention, there are none for a major, or the image is one we build);
8
8
  * - `button`: offered without a tag (Pi, the bridge's own runtime, never updates itself).
9
9
  */
10
10
  export type Plan = "auto" | "update" | "careful" | "button";
@@ -16,12 +16,14 @@ export function needsAttention(review: Review | undefined): boolean {
16
16
  interface PlannedLine {
17
17
  major: boolean;
18
18
  review?: Review;
19
+ /** An image our own CI builds: it has no release notes, and its stack's README sets the rollout (a queue drain, a database backup). */
20
+ own?: boolean;
19
21
  }
20
22
 
21
- /** One stack's pending updates: any line whose notes need attention makes it careful; a major is careful unless its notes say nothing relevant. */
23
+ /** One stack's pending updates: an image of ours or a line whose notes need attention makes it careful; a major is careful unless its notes say nothing relevant. */
22
24
  export function stackPlan(pending: readonly PlannedLine[]): Plan | null {
23
25
  if (pending.length === 0) return null;
24
- if (pending.some((l) => needsAttention(l.review))) return "careful";
26
+ if (pending.some((l) => l.own || needsAttention(l.review))) return "careful";
25
27
  const majors = pending.filter((l) => l.major);
26
28
  if (majors.length === 0) return "auto";
27
29
  return majors.every((l) => l.review?.verdict === "none") ? "update" : "careful";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.40.46",
3
+ "version": "0.40.47",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -36,9 +36,9 @@ The output is JSON with `counts`, `rows`, and `table`. Answer with the `table` f
36
36
  - `Running` and `Latest` are release tags. `older build`: the running build carries no tag any more. `new build`: no release tag names the newer build. `17 (older build)`: the running build of that major series is no longer tagged.
37
37
  - `Update`: `pull` means redeploying the stack with an image pull applies it; `edit tag` means changing the tag in the GitOps repository; `edit digest` means changing the pinned digest in the repository (`latestDigest` in the row holds it); `unknown` has its reason in the notes under the table.
38
38
  - A note "major version change" or "newer major ... available" means the update crosses a major version. Read its release notes yourself before asking anything (next section).
39
- - Private images (the registry refuses anonymous access, such as our own Grimoire builds) are left out of the table and the counts; the summary line counts them and `privateImages` lists them. Mention them only when the caller asks.
39
+ - Private images (the registry refuses anonymous access, such as graphile-worker) come from Arcane's own check, which uses its registry login: their rows show `new build` without version names. Digest-pinned private images (the Grimoire builds, moved only by their release workflow) are left out of the table and the counts; the summary line counts them and `privateImages` lists them. Mention them only when the caller asks.
40
40
 
41
- Messages that start with "Arcane Daily Report:" are the bridge's scheduled report, built from `update-report` in the morning run without you: one section per stack with updates and a release-notes verdict on every pending update. Stacks without a major version and without notes that need attention (including an Arcane manager release) are updated by the bridge right after the post, without you, and checked again five minutes later; a stack that fails then is rolled back where possible and handed to `astro.foreman`. A major whose notes say nothing relevant gets an Update button that owners press, which runs `stack-update` without you; anything else gets Upgrade carefully (next sections). When the caller replies to one, its list is the context ("update these", "why is this a new build"); run `update-report` again only when the caller wants fresh data.
41
+ Messages that start with "Arcane Daily Report:" are the bridge's scheduled report, built from `update-report` in the morning run without you: one section per stack with updates and a release-notes verdict on every pending update. Stacks without a major version and without notes that need attention (including an Arcane manager release) are updated by the bridge right after the post, without you, and checked again five minutes later; a stack that fails then is rolled back where possible and handed to `astro.foreman`. A major whose notes say nothing relevant gets an Update button that owners press, which runs `stack-update` without you; anything else, and every update of an image our own CI builds (ghcr.io astronaute77, astrofoundry, monadeo: the stack README sets its rollout), gets Upgrade carefully (next sections). When the caller replies to one, its list is the context ("update these", "why is this a new build"); run `update-report` again only when the caller wants fresh data.
42
42
 
43
43
  ## Applying updates
44
44
 
@@ -69,6 +69,7 @@ describe("resolveRef", () => {
69
69
  "library/nginx": { tags: ["1.31.4-alpine"], digests: {} },
70
70
  "getarcaneapp/manager": { tags: ["v1.2.0", "v1.3.0", "latest"], digests: { "v1.3.0": "sha256:new", "v1.2.0": "sha256:old" } },
71
71
  "astrofoundry/app": "private",
72
+ "monadeo/server": "private",
72
73
  });
73
74
 
74
75
  it("resolves a floating tag to the release versions behind both digests", async () => {
@@ -99,8 +100,11 @@ describe("resolveRef", () => {
99
100
  expect(await resolveRef("ghcr.io/getarcaneapp/manager@sha256:new", undefined, registry, NOW)).toMatchObject({ running: "v1.3.0", status: "up-to-date" });
100
101
  });
101
102
 
102
- it("falls back to the digest result for private images and marks bad checks unknown", async () => {
103
- expect(await resolveRef("ghcr.io/astrofoundry/app:main", entry("A1", "A2"), registry, NOW)).toMatchObject({ status: "update", latest: "new build", private: true });
103
+ it("falls back to Arcane's digest check for private images, leaves out private digest pins, and marks bad checks unknown", async () => {
104
+ const own = await resolveRef("ghcr.io/astrofoundry/app:main", entry("A1", "A2"), registry, NOW);
105
+ expect(own).toMatchObject({ status: "update", latest: "new build", action: "pull", note: "versions unavailable: private image" });
106
+ expect(own.private).toBeUndefined();
107
+ expect(await resolveRef("ghcr.io/monadeo/server:v1.0.0@sha256:abc", undefined, registry, NOW)).toMatchObject({ status: "unknown", private: true });
104
108
  expect(await resolveRef("nginx:1.31.4-alpine", undefined, registry, NOW)).toMatchObject({ status: "unknown", note: "not in the fresh check" });
105
109
  expect(await resolveRef("nginx:1.31.4-alpine", entry("N", "N", { checkTime: "2026-09-24T00:00:00Z" }), registry, NOW)).toMatchObject({ status: "unknown", note: expect.stringContaining("stale") });
106
110
  expect(await resolveRef("nginx:1.31.4-alpine", entry("N", "N", { error: "timeout" }), registry, NOW)).toMatchObject({ status: "unknown", note: "check failed: timeout" });
@@ -121,6 +125,7 @@ describe("buildUpdateReport", () => {
121
125
  { name: "canary", status: "stopped", updateInfo: { serviceUpdates: { canary: { imageRef: "busybox:latest" } } } },
122
126
  { name: "empty", status: "running" },
123
127
  { name: "ours", status: "running", updateInfo: { serviceUpdates: { api: { imageRef: "ghcr.io/astrofoundry/app:main" }, worker: { imageRef: "ghcr.io/astrofoundry/app:main" } } } },
128
+ { name: "pinned", status: "running", updateInfo: { serviceUpdates: { server: { imageRef: "ghcr.io/monadeo/server:v1.0.0@sha256:abc" } } } },
124
129
  ],
125
130
  };
126
131
  const check = {
@@ -130,15 +135,15 @@ describe("buildUpdateReport", () => {
130
135
  "ghcr.io/astrofoundry/app:main": entry("A1", "A2"),
131
136
  };
132
137
  const report = await buildUpdateReport({ check, projects, registry, startedAt: NOW, all: false });
133
- expect(report.counts).toEqual({ update: 1, release: 0, rebuild: 0, unknown: 1, "up-to-date": 2 });
134
- expect(report.rows.map((r) => `${r.stack}/${r.service}:${r.status}`)).toEqual(["media/prowlarr:update", "empty/empty:unknown"]);
135
- expect(report.table).toMatch(/^Fresh check 2026-09-25T18:30:00Z: 4 services in 5 stacks, 3 images\. 1 private images \(2 services\) excluded\./);
136
- expect(report.privateImages).toEqual(["ghcr.io/astrofoundry/app:main"]);
137
- expect(report.rows.some((r) => r.stack === "ours")).toBe(false);
138
+ expect(report.counts).toEqual({ update: 3, release: 0, rebuild: 0, unknown: 1, "up-to-date": 2 });
139
+ expect(report.rows.map((r) => `${r.stack}/${r.service}:${r.status}`)).toEqual(["media/prowlarr:update", "ours/api:update", "ours/worker:update", "empty/empty:unknown"]);
140
+ expect(report.table).toMatch(/^Fresh check 2026-09-25T18:30:00Z: 6 services in 6 stacks, 4 images\. 1 pinned private images \(1 services\) excluded\./);
141
+ expect(report.privateImages).toEqual(["ghcr.io/monadeo/server:v1.0.0@sha256:abc"]);
142
+ expect(report.rows.some((r) => r.stack === "pinned")).toBe(false);
138
143
  expect(report.table).toContain("media/prowlarr prowlarr 2.0.5.5160-ls123 2.1.0.5190-ls124 pull");
139
144
  expect(report.table).toContain("* empty: Arcane lists no images for this stack");
140
145
  const all = await buildUpdateReport({ check, projects, registry, startedAt: NOW, all: true });
141
- expect(all.rows).toHaveLength(4);
146
+ expect(all.rows).toHaveLength(6);
142
147
  expect(all.table).toContain("* canary: stack is stopped");
143
148
  });
144
149
 
@@ -34,7 +34,7 @@ export interface UpdateReport {
34
34
  checkedAt: string;
35
35
  stacks: number;
36
36
  images: number;
37
- /** Private image references, excluded from `rows`, `counts`, and the table. */
37
+ /** Digest-pinned private image references, excluded from `rows`, `counts`, and the table: only their own release workflow moves them. */
38
38
  privateImages: string[];
39
39
  counts: Record<UpdateStatus, number>;
40
40
  rows: UpdateRow[];
@@ -152,7 +152,7 @@ interface Resolution {
152
152
  action: string;
153
153
  note: string;
154
154
  latestDigest?: string;
155
- /** The registry refused anonymous access: an image of our own, left out of the report. */
155
+ /** The registry refused anonymous access to a digest pin: an image of our own that only its release workflow moves, left out of the report. */
156
156
  private?: boolean;
157
157
  }
158
158
 
@@ -179,7 +179,8 @@ export async function resolveRef(refText: string, entry: CheckEntry | undefined,
179
179
  tags = (await registry.tags(ref)).map(parseTag).filter((t): t is TagVersion => t !== null);
180
180
  } catch (err) {
181
181
  const status = err instanceof RegistryError ? err.status : 0;
182
- if (status === 401 || status === 403) return { ...digestOnly("private image, the registry needs credentials"), private: true };
182
+ // Arcane checks a private image with its own registry login, so only the version names are missing.
183
+ if (status === 401 || status === 403) return kind === "pinned" ? { ...unknown("pinned private image"), private: true } : digestOnly("private image");
183
184
  return digestOnly(err instanceof Error ? err.message : String(err));
184
185
  }
185
186
 
@@ -377,7 +378,7 @@ export async function buildUpdateReport(input: { check: unknown; projects: unkno
377
378
  const shown = input.all ? rows : rows.filter((r) => r.status !== "up-to-date" || r.note.includes("newer major"));
378
379
  const checkedAt = new Date(input.startedAt).toISOString().replace(/\.\d+Z$/, "Z");
379
380
  const stacks = new Set(services.map((s) => s.stack)).size;
380
- const excluded = privateImages.length === 0 ? "" : ` ${privateImages.length} private images (${services.length - listed.length} services) excluded.`;
381
+ const excluded = privateImages.length === 0 ? "" : ` ${privateImages.length} pinned private images (${services.length - listed.length} services) excluded.`;
381
382
  const summary =
382
383
  `Fresh check ${checkedAt}: ${listed.length} services in ${stacks} stacks, ${refs.length - privateImages.length} images.${excluded} ` +
383
384
  `${counts.update} new builds, ${counts.release} new releases, ${counts.rebuild} rebuilds, ${counts.unknown} unknown, ${counts["up-to-date"]} up to date` +