@theholocron/cli 5.0.0-alpha.385 → 5.0.0-alpha.387

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.
package/README.md CHANGED
@@ -249,8 +249,8 @@ provider the config does not use is ignored. The org area is shared: a config in
249
249
  also reads the repository root's `.holocron/org.ts` (the nearest ancestor with a `.git`), and its own
250
250
  `.holocron/org.ts` wins for a key set in both, option by option; that is not an error, so an identifier written in the
251
251
  root file needs no copy in the app. The other areas (`repo`, `notifications`) describe the repository and are not
252
- shared. Anything CI needs (`CLOUDFLARE_ACCOUNT_ID`,
253
- `TURBO_TEAM`, `HOLOCRON_AXIOM_DATASET`) stays out: it lives in 1Password and syncs to a GitHub variable (`repo.variables.sync`),
252
+ shared. Anything CI needs (`HOLOCRON_CLOUDFLARE_ACCOUNT_ID`,
253
+ `HOLOCRON_TURBO_TEAM`, `HOLOCRON_AXIOM_DATASET`) stays out: it lives in 1Password and syncs to a GitHub variable (`repo.variables.sync`),
254
254
  and nothing else carries a copy. `.holocron/org.md` (the agent contract the CLI embeds) is not an area: only
255
255
  `.ts`, `.js`, `.mjs`, `.cjs` and `.json` are read.
256
256
 
@@ -630,6 +630,7 @@ commands and the config are provider-neutral; Discord is the first provider.
630
630
  | `holocron doctor variables` | Do the Actions variables `repo.variables` declares exist, with those values (and, for the organization's, that visibility)? One row for the repository and one for the organization, each only when declared. Read-only. A `repo.variables.sync` entry adds one row that checks its names exist (no value is read or shown). An undeclared variable counts only with `prune`; a scope that cannot be read (no provider, no org token) is a skip, not a failure |
631
631
  | `holocron doctor ci` | Has the repo moved to the flat task vocabulary? One row each for the `tasks:` entries (a deprecated alias, with the id that replaces it), the generated callers (file, workflow and job name equal the task id), the `ci` aggregate's `expected` list (no id missing or stale) and where the callers point (`theholocron/.github` or holocron `ci-v1`). Read-only, no provider needed; exits 1 on a failure. The ruleset's checks are `doctor repo`'s |
632
632
  | `holocron doctor github-app` | Does each GitHub App instance in `githubApps` (`{ name, manifest, environment }`) have what its manifest file (`default_permissions`, `default_events`) declares? Reads the App's id and key from the vault `environment` in memory (never printed), calls `GET /app` and `GET /app/installations` with the App's JWT. Rows per instance: `reachable`, `events` (all subscribed), `permissions` (each granted at least at the manifest's level, `read < write < admin`), `installations` (none lags the App, a pending update fails). Extras on the App are `info` in a row's detail, never a failure. A gap ends with the App's settings page (user- or organization-owned) and, for an installation, its own page. Credentials that cannot be read are a skip; an unreadable manifest or a rejected JWT fails. Read-only |
633
+ | `holocron doctor logs` | Does each Axiom dataset the setup ships logs to exist, and does the token reach it? Rows: `token is accepted` (a 401 fails), one `dataset for <service>` for the CLI (`HOLOCRON_AXIOM_DATASET`, resolved by the logger's own chain), Sentinel (`SENTINEL_AXIOM_DATASET`) and any other `dev.serve.logging.datasetVar` (a 404 fails and names the fix), `organization` (`HOLOCRON_AXIOM_ORG`, then `AXIOM_ORG`), and an `info` row per dataset with the `retentionDays` Axiom reports (or says it reported none). Reads through the optional `Logs.readDataset` / `Logs.checkToken`; never creates a dataset or prints a token. A name or token that cannot be read is a skip. Read-only |
633
634
  | `holocron doctor environments` | Do the deployment environments exist? The ones `repo setup` creates (`staging`, `production`, when an `environments` provider is configured) plus every environment `repo.secrets.environments` names. One row. A missing one fails; an extra one is never a problem; no provider with some named is a skip |
634
635
  | `holocron doctor project [--post [channel]]` | Does each board `providers.projects.boards` declares exist and match its template? One row per board, status list, field, view and automation rule; the board's extras and the items `project reconcile` would fix (no status, closed but not done, open blocker but not blocked, blocked without a blocker) are `info` rows, never a failure. A template file that does not read fails, naming the file. Read-only; `--post` shares the failing rows through the `notifications` bot. |
635
636
  | `holocron doctor credentials` | Does the credentials environment exist, and does it hold every variable the configured plugins take? One row per variable and provider (`ok`, `fail` when missing, `skip` for an optional one not set), listing names only: it never reads a value, and says which spelling of the environment's name matched. |
package/dist/cli.mjs CHANGED
@@ -759,6 +759,7 @@ const COMMAND_CONTEXTS = {
759
759
  "doctor environments": "workspace",
760
760
  "doctor credentials": "workspace",
761
761
  "doctor project": "workspace",
762
+ "doctor logs": "workspace",
762
763
  "doctor github-app": "workspace",
763
764
  "project move": "workspace",
764
765
  "repo properties apply": "workspace",
@@ -1516,12 +1517,12 @@ async function runDoctorTokens(input) {
1516
1517
  try {
1517
1518
  module = await importer(pkg);
1518
1519
  } catch (err) {
1519
- rows.push(row$8(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
1520
+ rows.push(row$9(pkg, "skip", `cannot load the plugin: ${errorMessage(err)}`));
1520
1521
  continue;
1521
1522
  }
1522
- for (const token of module.tokens ?? []) rows.push(await checkToken(token, module, env, readToken, now()));
1523
+ for (const token of module.tokens ?? []) rows.push(await checkToken$1(token, module, env, readToken, now()));
1523
1524
  }
1524
- if (rows.length === 0) rows.push(row$8("tokens", "skip", "no configured plugin lists the tokens it takes"));
1525
+ if (rows.length === 0) rows.push(row$9("tokens", "skip", "no configured plugin lists the tokens it takes"));
1525
1526
  printCheckRows(rows, print);
1526
1527
  const summary = summariseChecks(rows);
1527
1528
  printCheckSummary(summary, print);
@@ -1553,11 +1554,11 @@ async function loadCredentials(input) {
1553
1554
  try {
1554
1555
  await loader.load();
1555
1556
  } catch (err) {
1556
- return [row$8("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
1557
+ return [row$9("credentials", "skip", `could not load the credentials providers: ${errorMessage(err)}`)];
1557
1558
  }
1558
- return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$8(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
1559
+ return loader.loadFailures().filter((failure) => failure.key === "credentials").map((failure) => row$9(`credentials ${failure.provider}`, "fail", `could not be read: ${errorMessage(failure.error)}`));
1559
1560
  }
1560
- function row$8(id, status, detail) {
1561
+ function row$9(id, status, detail) {
1561
1562
  return {
1562
1563
  id,
1563
1564
  title: id,
@@ -1566,26 +1567,26 @@ function row$8(id, status, detail) {
1566
1567
  problems: []
1567
1568
  };
1568
1569
  }
1569
- async function checkToken(token, module, env, readToken, now) {
1570
+ async function checkToken$1(token, module, env, readToken, now) {
1570
1571
  const { keyringKey, envName, vendorEnvName } = token;
1571
1572
  const fromEnv = env.get(envName) ? envName : vendorEnvName && env.get(vendorEnvName) ? vendorEnvName : void 0;
1572
1573
  const stored = fromEnv ? void 0 : findCredential(...vendorEnvName ? [envName, vendorEnvName] : [envName]);
1573
1574
  const value = fromEnv ? env.get(fromEnv) : stored?.value ?? readToken(keyringKey);
1574
- if (!value) return row$8(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron auth set ${keyringKey}\`)`);
1575
+ if (!value) return row$9(keyringKey, "skip", `not set (${vendorEnvName ? `${envName} / ${vendorEnvName}` : envName}, or \`holocron auth set ${keyringKey}\`)`);
1575
1576
  const verify = token.verify ?? (token.verifiable === false ? void 0 : module.verifyToken);
1576
- if (!verify) return row$8(keyringKey, "skip", "set, but its plugin cannot verify it");
1577
+ if (!verify) return row$9(keyringKey, "skip", "set, but its plugin cannot verify it");
1577
1578
  const from = fromEnv ?? stored?.source ?? "keyring";
1578
1579
  try {
1579
1580
  const verified = await verify(value);
1580
- if (!verified.ok) return row$8(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
1581
+ if (!verified.ok) return row$9(keyringKey, "fail", `rejected (${from}): ${verified.message}`);
1581
1582
  const expiry = verified.expiresAt ? describeExpiry(verified.expiresAt, now) : void 0;
1582
- if (!expiry) return row$8(keyringKey, "ok", `${verified.subject} (${from})`);
1583
+ if (!expiry) return row$9(keyringKey, "ok", `${verified.subject} (${from})`);
1583
1584
  return expiry.soon ? {
1584
- ...row$8(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
1585
+ ...row$9(keyringKey, "fail", `${verified.subject} (${from}), ${expiry.text}`),
1585
1586
  problems: [`${expiry.text}: renew it`]
1586
- } : row$8(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
1587
+ } : row$9(keyringKey, "ok", `${verified.subject} (${from}), ${expiry.text}`);
1587
1588
  } catch (err) {
1588
- return row$8(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
1589
+ return row$9(keyringKey, "fail", `could not be verified (${from}): ${errorMessage(err)}`);
1589
1590
  }
1590
1591
  }
1591
1592
  // src/commands/doctor-tokens/doctor-tokens.command.ts
@@ -2055,6 +2056,13 @@ const doctorGitHubAppEntry = {
2055
2056
  positionals: [],
2056
2057
  supportsDryRun: false
2057
2058
  };
2059
+ // src/commands/doctor-logs/doctor-logs.entry.ts
2060
+ const doctorLogsEntry = {
2061
+ name: "doctor logs",
2062
+ description: "Check the Axiom datasets the setup ships logs to exist and the token reaches them (read-only)",
2063
+ positionals: [],
2064
+ supportsDryRun: false
2065
+ };
2058
2066
  // src/commands/doctor-monitoring/doctor-monitoring.entry.ts
2059
2067
  const doctorMonitoringEntry = {
2060
2068
  name: "doctor monitoring",
@@ -2599,6 +2607,7 @@ const registry = createCommandRegistry([
2599
2607
  doctorCredentialsEntry,
2600
2608
  doctorProjectEntry,
2601
2609
  doctorGitHubAppEntry,
2610
+ doctorLogsEntry,
2602
2611
  projectMoveEntry,
2603
2612
  {
2604
2613
  name: "repo properties apply",
@@ -4466,6 +4475,7 @@ async function runDev(input) {
4466
4475
  return finish("fail");
4467
4476
  }
4468
4477
  row(true, `vault ${input.environment}`, `${Object.keys(values).length} variables, passed to the application`);
4478
+ const appEnvironment = values[`${PREFIX}_ENVIRONMENT`] ?? values["ENVIRONMENT"] ?? APP_ENVIRONMENT;
4469
4479
  let token;
4470
4480
  try {
4471
4481
  token = await loader.get("tunnels").tunnelToken(tunnel.tunnelId);
@@ -4482,7 +4492,8 @@ async function runDev(input) {
4482
4492
  command: program,
4483
4493
  args,
4484
4494
  env: {
4485
- ENVIRONMENT: APP_ENVIRONMENT,
4495
+ ENVIRONMENT: appEnvironment,
4496
+ [`${PREFIX}_ENVIRONMENT`]: appEnvironment,
4486
4497
  ...values,
4487
4498
  PORT: String(input.port),
4488
4499
  [`${PREFIX}_PORT`]: String(input.port)
@@ -4876,7 +4887,7 @@ async function runDoctorCredentials(input) {
4876
4887
  };
4877
4888
  }
4878
4889
  /** A row for the provider as a whole, or for one of its variables when `name` is given. */
4879
- function row$7(provider, status, detail, name) {
4890
+ function row$8(provider, status, detail, name) {
4880
4891
  return name === void 0 ? {
4881
4892
  id: provider,
4882
4893
  title: provider,
@@ -4893,32 +4904,32 @@ function row$7(provider, status, detail, name) {
4893
4904
  }
4894
4905
  async function checkCredentials(input, loader) {
4895
4906
  const { resolved } = input.loaded;
4896
- if (!resolved.providers.credentials) return [row$7("credentials", "skip", "no `credentials` provider is configured")];
4897
- const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$7(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
4907
+ if (!resolved.providers.credentials) return [row$8("credentials", "skip", "no `credentials` provider is configured")];
4908
+ const rows = loader.loadFailures().filter((f) => f.key === "credentials").map((f) => row$8(f.provider, "fail", `failed to load: ${errorMessage(f.error)}`));
4898
4909
  if (!loader.has("credentials")) return rows;
4899
4910
  const expected = await expectedTokens(input);
4900
4911
  const { tuples } = resolved.providers.credentials;
4901
4912
  for (const impl of loader.get("credentials")) {
4902
4913
  const tuple = tuples.find((t) => t.provider === impl.providerName);
4903
4914
  const environment = tuple && credentialsEnvironment(tuple, resolved);
4904
- rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$7(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set")]);
4915
+ rows.push(...environment ? await checkProvider(impl, environment, expected) : [row$8(impl.providerName, "skip", "no `environment` option and `credentials.environment` is not set")]);
4905
4916
  }
4906
4917
  return rows;
4907
4918
  }
4908
4919
  async function checkProvider(impl, environment, expected) {
4909
4920
  const provider = impl.providerName;
4910
- if (!impl.inspect) return [row$7(provider, "skip", "cannot list the variables without reading their values")];
4911
- if (expected.length === 0) return [row$7(provider, "skip", "no configured plugin lists the tokens it takes")];
4921
+ if (!impl.inspect) return [row$8(provider, "skip", "cannot list the variables without reading their values")];
4922
+ if (expected.length === 0) return [row$8(provider, "skip", "no configured plugin lists the tokens it takes")];
4912
4923
  try {
4913
4924
  const found = await impl.inspect(environment);
4914
4925
  const held = new Set(found.names);
4915
4926
  const where = found.environment === environment ? `"${found.environment}"` : `"${found.environment}" (the config writes "${environment}")`;
4916
4927
  return expected.map(({ name, optional }) => {
4917
- if (held.has(name)) return row$7(provider, "ok", `present in ${where}`, name);
4918
- return optional ? row$7(provider, "skip", `optional, not set in ${where}`, name) : row$7(provider, "fail", `missing from ${where}`, name);
4928
+ if (held.has(name)) return row$8(provider, "ok", `present in ${where}`, name);
4929
+ return optional ? row$8(provider, "skip", `optional, not set in ${where}`, name) : row$8(provider, "fail", `missing from ${where}`, name);
4919
4930
  });
4920
4931
  } catch (err) {
4921
- return [row$7(provider, "fail", errorMessage(err))];
4932
+ return [row$8(provider, "fail", errorMessage(err))];
4922
4933
  }
4923
4934
  }
4924
4935
  /**
@@ -5749,7 +5760,7 @@ async function runDoctorDns(input) {
5749
5760
  });
5750
5761
  else if (!loader.has("dns")) {
5751
5762
  const why = whyMissing(loader, "dns", "no `dns` provider to check them with");
5752
- for (const zone of zones) rows.push(row$6(zone, "skip", why));
5763
+ for (const zone of zones) rows.push(row$7(zone, "skip", why));
5753
5764
  for (const { hostname } of domains) rows.push(domainRow(hostname, "skip", why));
5754
5765
  } else {
5755
5766
  const dns = loader.get("dns");
@@ -5771,7 +5782,7 @@ async function runDoctorDns(input) {
5771
5782
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
5772
5783
  };
5773
5784
  }
5774
- function row$6(zone, status, detail, problems = []) {
5785
+ function row$7(zone, status, detail, problems = []) {
5775
5786
  return {
5776
5787
  id: `dns-${zone}`,
5777
5788
  title: `${zone} records exist`,
@@ -5800,7 +5811,7 @@ async function checkDomain(dns, deploy, project, hostname) {
5800
5811
  return noToken !== void 0 ? domainRow(hostname, "skip", noToken) : domainRow(hostname, "fail", errorMessage(err));
5801
5812
  }
5802
5813
  }
5803
- async function checkZone(dns, zone, wanted, rowOf = (...args) => row$6(zone, ...args)) {
5814
+ async function checkZone(dns, zone, wanted, rowOf = (...args) => row$7(zone, ...args)) {
5804
5815
  try {
5805
5816
  const have = await dns.listRecords(zone);
5806
5817
  const problems = declaredVsActual(new Map(wanted.map((w) => [keyOf(w), w])), new Map(have.map((h) => [keyOf(h), h])), {
@@ -5935,7 +5946,7 @@ function installationSettingsUrl(account, id) {
5935
5946
  return `https://github.com/settings/installations/${id}`;
5936
5947
  }
5937
5948
  // src/commands/doctor-github-app/app-rows.ts
5938
- const row$5 = (name, what, problems, ok) => ({
5949
+ const row$6 = (name, what, problems, ok) => ({
5939
5950
  id: `${name}:${what}`,
5940
5951
  title: `${name}: ${what}`,
5941
5952
  status: problems.length > 0 ? "fail" : "ok",
@@ -5962,9 +5973,9 @@ function appRows(name, manifest, app, installations) {
5962
5973
  return [`${who} has not accepted the current App: ${gaps.join("; ")}`, `fix: ${who} accepts the update at ${url}`];
5963
5974
  });
5964
5975
  return [
5965
- row$5(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
5966
- row$5(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
5967
- row$5(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
5976
+ row$6(name, "events", eventProblems.length > 0 ? [...eventProblems, fix] : [], `all ${manifest.events.length} subscribed${extrasNote("extra event(s)", extraEvents)}`),
5977
+ row$6(name, "permissions", permissionProblems.length > 0 ? [...permissionProblems, fix] : [], `all ${Object.keys(manifest.permissions).length} granted${extrasNote("extra permission(s)", extraPermissions)}`),
5978
+ row$6(name, "installations", installationProblems, `${installations.length} installation(s) up to date`)
5968
5979
  ];
5969
5980
  }
5970
5981
  // src/commands/doctor-github-app/parse-manifest.ts
@@ -5992,7 +6003,8 @@ function parseManifest(text) {
5992
6003
  *
5993
6004
  * GitHub has no API that changes an existing App's permissions or event subscriptions, so each instance is changed by
5994
6005
  * hand in its settings page and a missed one fails quietly. Read-only: for every entry of `githubApps` it reads the
5995
- * manifest file, reads the instance's `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY` from its vault environment in
6006
+ * manifest file, reads the instance's `SENTINEL_GITHUB_APP_ID` and `SENTINEL_GITHUB_APP_PRIVATE_KEY` (else the bare `GITHUB_APP_ID` and
6007
+ * `GITHUB_APP_PRIVATE_KEY`) from its vault environment in
5996
6008
  * memory (never printed, never written), signs the App's own JWT and calls `GET /app` and `GET /app/installations`.
5997
6009
  * Rows per instance: reachable; events (every manifest event is subscribed); permissions (each manifest permission is
5998
6010
  * granted at least at its level, `read < write < admin`); installations (none lags the App, which is a pending
@@ -6000,8 +6012,13 @@ function parseManifest(text) {
6000
6012
  * that fails ends with the settings page that fixes it. An instance whose credentials cannot be read is a skip with
6001
6013
  * the reason; an unreadable manifest, a rejected JWT or a gap is a failure.
6002
6014
  */
6003
- const APP_ID = "GITHUB_APP_ID";
6004
- const PRIVATE_KEY = "GITHUB_APP_PRIVATE_KEY";
6015
+ /** The names the App's credentials are kept under, Sentinel's own first and the bare ones an older Environment has (#1864). */
6016
+ const APP_ID = ["SENTINEL_GITHUB_APP_ID", "GITHUB_APP_ID"];
6017
+ const PRIVATE_KEY = ["SENTINEL_GITHUB_APP_PRIVATE_KEY", "GITHUB_APP_PRIVATE_KEY"];
6018
+ /** The first of `names` the environment holds a value for. */
6019
+ function held(values, names) {
6020
+ return names.map((name) => values[name]).find((value) => value?.trim());
6021
+ }
6005
6022
  const defaultApi = {
6006
6023
  getApp,
6007
6024
  listAppInstallations
@@ -6016,7 +6033,7 @@ async function runDoctorGitHubApp(input) {
6016
6033
  assertPluginsResolvable$1(loader, "doctor github-app");
6017
6034
  }
6018
6035
  const rows = [];
6019
- if (instances.length === 0) rows.push(row$4("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
6036
+ if (instances.length === 0) rows.push(row$5("github-app", "reachable", "skip", "no `githubApps` are declared in holocron.config.ts"));
6020
6037
  for (const instance of instances) rows.push(...await checkInstance(instance, loader, input));
6021
6038
  printCheckRows(rows, print);
6022
6039
  const summary = summariseChecks(rows);
@@ -6033,7 +6050,7 @@ async function runDoctorGitHubApp(input) {
6033
6050
  ...status === "skip" ? { reason: [...new Set(rows.map((r) => r.detail))].join("; ") } : {}
6034
6051
  };
6035
6052
  }
6036
- function row$4(name, what, status, detail) {
6053
+ function row$5(name, what, status, detail) {
6037
6054
  return {
6038
6055
  id: `${name}:${what}`,
6039
6056
  title: `${name}: ${what}`,
@@ -6056,11 +6073,16 @@ async function readCredentials(instance, loader) {
6056
6073
  } catch (err) {
6057
6074
  return { reason: `cannot read the "${instance.environment}" environment: ${errorMessage(err)}` };
6058
6075
  }
6059
- const missing = [APP_ID, PRIVATE_KEY].filter((key) => !values[key]?.trim());
6060
- if (missing.length > 0) return { reason: `"${instance.environment}" does not hold ${missing.join(" or ")}` };
6061
- const privateKey = values[PRIVATE_KEY].includes("\n") ? values[PRIVATE_KEY] : values[PRIVATE_KEY].replace(/\\n/g, "\n");
6076
+ const appId = held(values, APP_ID);
6077
+ const key = held(values, PRIVATE_KEY);
6078
+ const missing = [appId ? void 0 : APP_ID, key ? void 0 : PRIVATE_KEY].filter((names) => names !== void 0);
6079
+ if (missing.length > 0) {
6080
+ const named = missing.map(([preferred, older]) => `${preferred} (or ${older})`).join(" or ");
6081
+ return { reason: `"${instance.environment}" does not hold ${named}` };
6082
+ }
6083
+ const privateKey = key.includes("\n") ? key : key.replace(/\\n/g, "\n");
6062
6084
  return { creds: {
6063
- appId: values[APP_ID].trim(),
6085
+ appId: appId.trim(),
6064
6086
  privateKey
6065
6087
  } };
6066
6088
  }
@@ -6071,19 +6093,19 @@ async function checkInstance(instance, loader, input) {
6071
6093
  try {
6072
6094
  manifest = parseManifest(readManifest(instance.manifest));
6073
6095
  } catch (err) {
6074
- return [row$4(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
6096
+ return [row$5(name, "manifest", "fail", `cannot read ${instance.manifest}: ${errorMessage(err)}`)];
6075
6097
  }
6076
6098
  const read = await readCredentials(instance, loader);
6077
- if ("reason" in read) return [row$4(name, "reachable", "skip", read.reason)];
6099
+ if ("reason" in read) return [row$5(name, "reachable", "skip", read.reason)];
6078
6100
  const api = input.api ?? defaultApi;
6079
6101
  const secrets = [read.creds.privateKey];
6080
6102
  try {
6081
6103
  const app = await api.getApp(read.creds);
6082
6104
  const installations = await api.listAppInstallations(read.creds);
6083
6105
  const owner = app.owner ? `, owned by ${app.owner.login}` : "";
6084
- return [row$4(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
6106
+ return [row$5(name, "reachable", "ok", `${app.slug}${owner}, settings: ${appSettingsUrl(app)}`), ...appRows(name, manifest, app, installations)];
6085
6107
  } catch (err) {
6086
- return [row$4(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed(err, secrets)}`)];
6108
+ return [row$5(name, "reachable", "fail", `cannot call GitHub as the App: ${scrubbed(err, secrets)}`)];
6087
6109
  }
6088
6110
  }
6089
6111
  // src/commands/doctor-github-app/doctor-github-app.command.ts
@@ -6105,6 +6127,161 @@ const doctorGitHubAppCommand = {
6105
6127
  })).status === "fail") process.exitCode = 1;
6106
6128
  }
6107
6129
  };
6130
+ // src/commands/doctor-logs/dataset-targets.ts
6131
+ const SENTINEL_VARIABLE = "SENTINEL_AXIOM_DATASET";
6132
+ /** `SENTINEL_AXIOM_DATASET` to `sentinel`: the part before `_AXIOM_DATASET`, lower case. */
6133
+ const idOf = (variable) => variable.replace(/_AXIOM_DATASET$/, "").toLowerCase();
6134
+ /**
6135
+ * The datasets this repo's setup ships logs to, each resolved the way its service resolves it (ADR-0019): the CLI's
6136
+ * through the logger's own chain (`HOLOCRON_AXIOM_DATASET`, then `AXIOM_DATASET`, then `log.axiom.dataset`, then the
6137
+ * `credentials` providers), Sentinel's and any other service's through the environment then the `credentials`
6138
+ * providers. Another service is the one `dev.serve.logging.datasetVar` names, when it is not one of those two.
6139
+ * Comlink does not log to Axiom yet, so it is not listed.
6140
+ */
6141
+ function datasetTargets(config) {
6142
+ const targets = [{
6143
+ id: "cli",
6144
+ label: "the CLI",
6145
+ variable: `${PREFIX}_AXIOM_DATASET`,
6146
+ name: resolveCliDataset({ configAxiomDataset: config.log?.axiom?.dataset }, false),
6147
+ fix: "run `holocron repo setup`, which provisions it"
6148
+ }, {
6149
+ id: "sentinel",
6150
+ label: "Sentinel",
6151
+ variable: SENTINEL_VARIABLE,
6152
+ name: resolveValue$2([SENTINEL_VARIABLE]),
6153
+ fix: "create it in Axiom (setup provisions only the CLI's dataset)"
6154
+ }];
6155
+ const other = config.dev?.serve?.logging?.datasetVar;
6156
+ if (other && !targets.some((t) => t.variable === other || other === "AXIOM_DATASET")) targets.push({
6157
+ id: idOf(other),
6158
+ label: `the service behind ${other}`,
6159
+ variable: other,
6160
+ name: resolveValue$2([other]),
6161
+ fix: "create it in Axiom (setup provisions only the CLI's dataset)"
6162
+ });
6163
+ return targets;
6164
+ }
6165
+ // src/commands/doctor-logs/doctor-logs.ts
6166
+ /**
6167
+ * `holocron doctor logs` — does each Axiom dataset the setup ships logs to exist, and does the token reach them?
6168
+ *
6169
+ * Read-only: it never creates a dataset, and prints names and numbers only, never a token or a secret value. One row for
6170
+ * the token (accepted by the provider), one per dataset (the CLI's, Sentinel's and any other `dev.serve.logging` names),
6171
+ * one for the organization, and an `info` row per existing dataset with its retention (ADR-0019: one setting for the whole
6172
+ * dataset, shared by every environment in it). Only a dataset the provider says is missing, or a token it refuses, fails;
6173
+ * a name, a token or a response that cannot be read is a skip with the reason.
6174
+ */
6175
+ const row$4 = (id, title, status, detail, problems = []) => ({
6176
+ id,
6177
+ title,
6178
+ status,
6179
+ detail,
6180
+ problems
6181
+ });
6182
+ async function runDoctorLogs(input) {
6183
+ const print = input.print ?? ((line) => console.log(line));
6184
+ const logger = input.logger ?? getLogger();
6185
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
6186
+ await loader.load();
6187
+ assertPluginsResolvable$1(loader, "doctor logs");
6188
+ const rows = [];
6189
+ if (!loader.has("logs")) {
6190
+ const failure = loader.loadFailures().find((f) => f.key === "logs");
6191
+ const why = failure ? `\`${failure.provider}\` failed to load: ${describeError(failure.error)}` : "no `logs` provider is configured in holocron.config.ts";
6192
+ rows.push(row$4("logs", "logs", "skip", why));
6193
+ } else rows.push(...await checkLogs(loader.get("logs"), datasetTargets(input.loaded.resolved)));
6194
+ printCheckRows(rows, print);
6195
+ const summary = summariseChecks(rows);
6196
+ printCheckSummary(summary, print);
6197
+ const status = summary.fail > 0 ? "fail" : summary.ok === 0 ? "skip" : "ok";
6198
+ logger.info({
6199
+ ...summary,
6200
+ status
6201
+ }, "doctor logs");
6202
+ return {
6203
+ status,
6204
+ rows,
6205
+ summary,
6206
+ ...status === "skip" ? { reason: rows.map((r) => r.detail).join("; ") } : {}
6207
+ };
6208
+ }
6209
+ async function checkLogs(logs, targets) {
6210
+ const rows = [];
6211
+ const token = await checkToken(logs);
6212
+ rows.push(token.row);
6213
+ for (const target of targets) {
6214
+ const id = `logs:dataset:${target.id}`;
6215
+ const title = `dataset for ${target.label}`;
6216
+ if (!target.name) rows.push(row$4(id, title, "skip", `${target.variable} is not set here, so there is no name to look for`));
6217
+ else if (!token.usable) rows.push(row$4(id, title, "skip", `${target.name}: not checked, the token is not usable`));
6218
+ else if (!logs.readDataset) rows.push(row$4(id, title, "skip", `${logs.providerName} cannot read a dataset`));
6219
+ else rows.push(...await checkDataset(logs, target, target.name, id, title));
6220
+ }
6221
+ const org = resolveValue$2(["AXIOM_ORG"], void 0, { prefix: PREFIX });
6222
+ rows.push(org ? row$4("logs:org", "organization", "ok", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is set`) : row$4("logs:org", "organization", "skip", `${PREFIX}_AXIOM_ORG (or AXIOM_ORG) is not set here; Sentinel's log links and check-dispatched need it`));
6223
+ return rows;
6224
+ }
6225
+ /** Whether the provider accepts the token. `usable` is false when it was refused or could not be tried. */
6226
+ async function checkToken(logs) {
6227
+ const title = "token is accepted";
6228
+ if (!logs.checkToken) return {
6229
+ row: row$4("logs:token", title, "skip", `${logs.providerName} cannot check a token`),
6230
+ usable: true
6231
+ };
6232
+ try {
6233
+ const result = await logs.checkToken();
6234
+ if (result.ok) return {
6235
+ row: row$4("logs:token", title, "ok", `${logs.providerName} accepts the token`),
6236
+ usable: true
6237
+ };
6238
+ const reason = result.reason ?? `${logs.providerName} refused the token`;
6239
+ return {
6240
+ row: row$4("logs:token", title, "fail", reason, [reason]),
6241
+ usable: false
6242
+ };
6243
+ } catch (err) {
6244
+ const noToken = missingTokenReason(err);
6245
+ const detail = noToken ?? `could not check the token: ${describeError(err)}`;
6246
+ return {
6247
+ row: row$4("logs:token", title, "skip", detail),
6248
+ usable: noToken === void 0
6249
+ };
6250
+ }
6251
+ }
6252
+ async function checkDataset(logs, target, name, id, title) {
6253
+ try {
6254
+ const found = await logs.readDataset(name);
6255
+ if (!found.exists) {
6256
+ const problem = `dataset ${name} does not exist (${target.variable}); ${target.fix}`;
6257
+ return [row$4(id, title, "fail", `${name} does not exist`, [problem])];
6258
+ }
6259
+ const retention = found.retentionDays === void 0 ? `retention: ${logs.providerName} did not report one for ${name}` : `retention: ${found.retentionDays} days for ${name}`;
6260
+ return [row$4(id, title, "ok", `${name} exists`), row$4(`logs:retention:${target.id}`, `retention of ${name}`, "skip", `info: ${retention}; one setting shared by every environment in the dataset (ADR-0019)`)];
6261
+ } catch (err) {
6262
+ const detail = missingTokenReason(err) ?? `could not read ${name}: ${describeError(err)}`;
6263
+ return [row$4(id, title, "skip", detail)];
6264
+ }
6265
+ }
6266
+ // src/commands/doctor-logs/doctor-logs.command.ts
6267
+ const doctorLogsCommand = {
6268
+ command: "logs",
6269
+ describe: "Check the Axiom datasets the setup ships logs to exist and the token reaches them (read-only)",
6270
+ handler: async (argv) => {
6271
+ const tokens = tokenContext$1(argv.token);
6272
+ if (!tokens) return;
6273
+ const loaded = await loadConfig(argv.cwd);
6274
+ applyResolvedConfig(argv, loaded.resolved);
6275
+ if ((await runDoctorLogs({
6276
+ loaded,
6277
+ context: {
6278
+ repoRoot: argv.cwd,
6279
+ ...tokens,
6280
+ org: resolveOrg(argv, loaded.resolved)
6281
+ }
6282
+ })).status === "fail") process.exitCode = 1;
6283
+ }
6284
+ };
6108
6285
  // src/commands/doctor-monitoring/doctor-monitoring.ts
6109
6286
  /**
6110
6287
  * `holocron doctor monitoring` — do the checks the `monitoring` provider declares exist in its account, as declared?
@@ -10646,6 +10823,19 @@ const DEEP_CHECKS = [
10646
10823
  };
10647
10824
  }
10648
10825
  },
10826
+ {
10827
+ name: "logs",
10828
+ capability: "logs",
10829
+ command: doctorLogsCommand,
10830
+ async run(input) {
10831
+ const report = await runDoctorLogs(input);
10832
+ return {
10833
+ status: report.status,
10834
+ summary: report.summary,
10835
+ ...report.reason ? { reason: report.reason } : {}
10836
+ };
10837
+ }
10838
+ },
10649
10839
  {
10650
10840
  name: "project",
10651
10841
  capability: "projects",
@@ -11064,8 +11254,8 @@ async function runGithubAppCreate(input) {
11064
11254
  let identity;
11065
11255
  try {
11066
11256
  const lines = [
11067
- dotenvLine("GITHUB_APP_ID", String(app.id)),
11068
- dotenvLine("GITHUB_APP_PRIVATE_KEY", app.pem),
11257
+ dotenvLine("SENTINEL_GITHUB_APP_ID", String(app.id)),
11258
+ dotenvLine("SENTINEL_GITHUB_APP_PRIVATE_KEY", app.pem),
11069
11259
  dotenvLine(input.webhookSecretVar || DEFAULT_WEBHOOK_SECRET_VAR, app.webhookSecret)
11070
11260
  ];
11071
11261
  if (lines.includes(null)) throw new Error("a value cannot be written as a dotenv line");
@@ -11091,7 +11281,7 @@ async function runGithubAppCreate(input) {
11091
11281
  identity,
11092
11282
  print,
11093
11283
  holds: "the App's credentials",
11094
- importHint: "import it in the 1Password app: Developer, View Environments, the Environment, Import .env file; it holds GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY and the webhook secret",
11284
+ importHint: "import it in the 1Password app: Developer, View Environments, the Environment, Import .env file; it holds SENTINEL_GITHUB_APP_ID, SENTINEL_GITHUB_APP_PRIVATE_KEY and the webhook secret",
11095
11285
  keep: input.keep,
11096
11286
  interactive: input.interactive,
11097
11287
  shred: input.shred,