@astrofoundry/pi-astro 0.40.18 → 0.40.20

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.
@@ -36,7 +36,7 @@ export const RISKY: Readonly<Record<string, readonly RegExp[]>> = {
36
36
  network: [/^unifi\s+\S+\s+write\b/],
37
37
  dns: [
38
38
  /^technitium\s+primary\s+(zone-create|zone-catalog|zone-delete|record-add|record-update|record-delete|cluster-init|cluster-delete|cluster-remove|server-domain)\b/,
39
- /^technitium\s+node\s+\S+\s+server-domain\b/,
39
+ /^technitium\s+node\s+\S+\s+(server-domain|stale-zone-delete)\b/,
40
40
  /^technitium\s+join\b/,
41
41
  /^cloudflare\s+record-(add|update|delete)\b/,
42
42
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrofoundry/pi-astro",
3
- "version": "0.40.18",
3
+ "version": "0.40.20",
4
4
  "description": "Personal pi customizations (extensions, subagents, skills, prompts, themes) for the pi coding agent.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -28,6 +28,8 @@ The internal resolvers form one Technitium cluster, `dns.home.arpa`: the Primary
28
28
  | `cluster-delete` (primary) | remove the cluster from the primary; refused while Secondary nodes exist |
29
29
  | `cluster-remove <secondaryNodeId>` (primary) | ask a Secondary node (id from `cluster-state`) to leave |
30
30
  | `server-domain <name>` (primary or node) | set that node's DNS Server Domain |
31
+ | `zone-resync <zone>` (primary or node) | re-fetch a Secondary or catalog zone; on a node's cluster catalog it recreates missing member zones |
32
+ | `stale-zone-delete <zone>` (node only) | delete a Secondary zone no catalog manages (checked first), so the cluster catalog recreates it |
31
33
 
32
34
  Record parameters by type (the API's names): `A`/`AAAA` `ipAddress` (update: `newIpAddress`); `CNAME` `cname`; `TXT` `text`; `MX` `exchange`, `preference`; `SRV` `priority`, `weight`, `port`, `target`; `NS` `nameServer`; `PTR` `ptrName`. `ttl=<seconds>` and `comments=<text>` apply to all; `overwrite=true` replaces the record set on add.
33
35
 
@@ -58,6 +58,8 @@ export const TECHNITIUM_WRITES: Readonly<Record<string, { args: [number, number]
58
58
  "cluster-delete": { args: [0, 0], help: "cluster-delete remove the cluster from the primary (only without Secondary nodes)" },
59
59
  "cluster-remove": { args: [1, 1], help: "cluster-remove <secondaryNodeId> ask a Secondary node to leave the cluster" },
60
60
  "server-domain": { args: [1, 1], help: "server-domain <name> DNS Server Domain of the target node (also with node)" },
61
+ "zone-resync": { args: [1, 1], help: "zone-resync <zone> re-fetch a Secondary or catalog zone from its primary (also with node)" },
62
+ "stale-zone-delete": { args: [1, 1], help: "stale-zone-delete <zone> (node only) delete a Secondary zone that no catalog manages, so the cluster catalog recreates it" },
61
63
  };
62
64
 
63
65
  const HELP = `dns specialist
@@ -168,6 +170,10 @@ export function technitiumRequest(catalog: string, args: string[]): TechnitiumRe
168
170
  case "cluster-remove":
169
171
  if (!NODE_ID.test(rest[0])) throw new UsageError("cluster-remove needs the numeric Secondary node id from cluster-state");
170
172
  return { path: "/api/admin/cluster/primary/removeSecondary", params: { secondaryNodeId: rest[0] }, primaryOnly: true };
173
+ case "zone-resync":
174
+ return { path: "/api/zones/resync", params: { zone: assertName(rest[0], "zone") }, primaryOnly: false };
175
+ case "stale-zone-delete":
176
+ return { path: "/api/zones/delete", params: { zone: assertName(rest[0], "zone") }, primaryOnly: false };
171
177
  case "server-domain":
172
178
  return { path: "/api/settings/set", params: { dnsServerDomain: assertName(rest[0], "server domain") }, primaryOnly: false };
173
179
  default:
@@ -286,7 +292,16 @@ async function technitium(config: DnsConfig, args: string[]): Promise<number> {
286
292
  if (node !== undefined && request.primaryOnly) throw new UsageError("zone and cluster writes go to the primary; the other nodes follow through the catalog zone and the cluster");
287
293
  const params = node === undefined ? request.params : { ...request.params, node };
288
294
  const target = node ?? "primary";
289
- const parsed = await technitiumCall(config.technitiumPrimaryUrl, request.path, params, readSecret(SERVICE, "TECHNITIUM_TOKEN"), target);
295
+ const token = readSecret(SERVICE, "TECHNITIUM_TOKEN");
296
+ if (rest[0] === "stale-zone-delete") {
297
+ if (node === undefined) throw new UsageError("stale-zone-delete needs node <fqdn>; delete a primary zone with zone-delete");
298
+ const options = await technitiumCall(config.technitiumPrimaryUrl, "/api/zones/options/get", { zone: params.zone, node }, token, target);
299
+ const zone = options.response as { type?: string; catalog?: string | null } | undefined;
300
+ if (!["Secondary", "SecondaryCatalog"].includes(zone?.type ?? "") || (zone?.catalog ?? null) !== null) {
301
+ throw new UsageError(`${params.zone} on ${node} is ${zone?.type ?? "unknown"} in catalog ${zone?.catalog ?? "none"}; only a Secondary zone outside any catalog is stale`);
302
+ }
303
+ }
304
+ const parsed = await technitiumCall(config.technitiumPrimaryUrl, request.path, params, token, target);
290
305
  printJson({ node: target, status: parsed.status, response: redactSecrets(parsed.response ?? null) });
291
306
  return 0;
292
307
  }
@@ -195,6 +195,8 @@ describe("dns wrapper", () => {
195
195
  primaryOnly: true,
196
196
  });
197
197
  expect(technitiumRequest("c", ["cluster-delete"]).params).toEqual({ forceDelete: "false" });
198
+ expect(technitiumRequest("c", ["zone-resync", "cluster-catalog.dns.home.arpa"]).path).toBe("/api/zones/resync");
199
+ expect(technitiumRequest("c", ["stale-zone-delete", "pdf.37pla.net"])).toEqual({ path: "/api/zones/delete", params: { zone: "pdf.37pla.net" }, primaryOnly: false });
198
200
  expect(technitiumRequest("cluster-catalog.dns.home.arpa", ["zone-catalog", "pdf.37pla.net"])).toEqual({
199
201
  path: "/api/zones/options/set",
200
202
  params: { zone: "pdf.37pla.net", catalog: "cluster-catalog.dns.home.arpa" },