@catalyst-cloud/cli 0.16.7 → 0.16.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.9
4
+
5
+ Setup on macOS now accepts Docker’s initial folder ownership mapping during the local storage check. Updating this computer keeps its verified file-access enrollment and can resume an interrupted update to a newer version.
6
+
7
+ ## 0.16.8
8
+
9
+ Setup can resume an update stopped by a local storage check. Failed access checks keep the earlier settings and report which check stopped setup.
10
+
3
11
  ## 0.16.7
4
12
 
5
13
  Setup can update an existing installation that still runs its saved, older image version. Headless setup names which key input Catalyst rejected and shows how to try a saved personal login when one is available. Installer checks leave existing skill files in place until the installer updates them.
@@ -7,7 +7,34 @@ import { fileURLToPath } from "node:url";
7
7
  import { canonicalDarwinThoughtsJson, parseDarwinThoughtsAuthority, parseDarwinThoughtsRequest, verifyDarwinThoughtsCustodyResponse, } from "../vendor/self-host/darwin-thoughts-custody/verifier.mjs";
8
8
  const LABEL = "dev.catalystcloud.runner.darwin-thoughts-custody";
9
9
  const vendor = resolve(dirname(fileURLToPath(import.meta.url)), "../vendor/self-host/darwin-thoughts-custody");
10
- function fail(reason) { throw Error("darwin_thoughts_custody_install:" + reason); }
10
+ class CustodyInstallError extends Error {
11
+ reason;
12
+ constructor(reason) {
13
+ super("darwin_thoughts_custody_install:" + reason);
14
+ this.reason = reason;
15
+ this.name = "CustodyInstallError";
16
+ }
17
+ }
18
+ /** Only our fixed installer errors may reach output; never forward command stderr or causes. */
19
+ export function darwinThoughtsInstallRefusal(error) {
20
+ return error instanceof CustodyInstallError ? error.reason : undefined;
21
+ }
22
+ /** Unknown exception text can contain credentials. Keep its class, and explicitly redact it. */
23
+ export function darwinThoughtsInstallException(error) {
24
+ const known = error instanceof CustodyInstallError;
25
+ const classes = new Set(["Error", "TypeError", "RangeError", "SyntaxError", "AbortError", "CustodyInstallError"]);
26
+ return { custodyErrorClass: error instanceof Error && classes.has(error.name) ? error.name : "Error",
27
+ custodyErrorMessage: known ? error.message : "Unclassified local storage exception; message withheld to protect credentials.",
28
+ custodyErrorMessageRedacted: !known };
29
+ }
30
+ function fail(reason) { throw new CustodyInstallError(reason); }
31
+ const VERIFIER_REFUSALS = new Set([
32
+ "ancestor", "ancestor_identity", "bootstrap_directory", "bootstrap_owner", "bootstrap_path",
33
+ "channel_identity", "cleanup", "deadline", "directory", "engine_identity", "exchange",
34
+ "file_owner", "git_descriptor", "git_path", "invalid", "noncanonical_json", "nonce_collision",
35
+ "path", "producer_refused", "signature", "size", "substituted_file", "substituted_request",
36
+ "unsafe_directory", "unsafe_file",
37
+ ]);
11
38
  function path(value) {
12
39
  if (!isAbsolute(value) || normalize(value) !== value || value.includes("\0") ||
13
40
  value.endsWith("/") || value === "/")
@@ -217,6 +244,7 @@ function factory(ports) {
217
244
  const nodeHash = executable(executables.nodeExecutable, principal, roots);
218
245
  const dockerHash = executable(executables.dockerExecutable, principal, roots);
219
246
  let authority;
247
+ let producerSupervisorImage = input.supervisorImage;
220
248
  if (existing) {
221
249
  custody.walk(state, false, 0o700, true);
222
250
  const runtime = record(parse(custody.read(join(state, "runtime.json"), 4096)), ["version", "nodeExecutable", "nodeExecutableSha256"]);
@@ -229,9 +257,14 @@ function factory(ports) {
229
257
  authority.nativeHome !== principal.home || authority.thoughtsRoot !== thoughtsRoot ||
230
258
  authority.locksRoot !== locksRoot || authority.requestsRoot !== requestsRoot ||
231
259
  authority.responsesRoot !== responsesRoot || row.privateKeyFile !== privateKeyFile ||
232
- row.supervisorImage !== input.supervisorImage || row.dockerExecutable !== executables.dockerExecutable ||
260
+ row.dockerExecutable !== executables.dockerExecutable ||
233
261
  row.dockerExecutableSha256 !== dockerHash)
234
262
  fail("existing_authority_mismatch");
263
+ if (typeof row.supervisorImage !== "string")
264
+ fail("existing_authority_mismatch");
265
+ image(row.supervisorImage);
266
+ if (row.supervisorImage.split("@sha256:")[0] !== input.supervisorImage.split("@sha256:")[0])
267
+ fail("existing_authority_mismatch");
235
268
  let key;
236
269
  try {
237
270
  key = createPrivateKey({ key: custody.read(privateKeyFile, 4096), type: "pkcs8", format: "der" });
@@ -241,15 +274,20 @@ function factory(ports) {
241
274
  }
242
275
  if (key.asymmetricKeyType !== "ed25519" || createPublicKey(key).export({ type: "spki", format: "der" }).toString("base64") !== authority.publicKey)
243
276
  fail("private_key_authority_mismatch");
277
+ // The enrolled producer attests its helper image. A runtime update does not re-enroll it.
278
+ producerSupervisorImage = row.supervisorImage;
244
279
  }
245
280
  custody.recheck();
246
281
  alive();
247
282
  const engine = await ports.engineIdentity({ ...executables, principal,
248
- supervisorImage: input.supervisorImage, runnerImage: input.runnerImage, deadlineMs: input.deadlineMs, signal });
283
+ supervisorImage: input.supervisorImage, producerSupervisorImage,
284
+ runnerImage: input.runnerImage, deadlineMs: input.deadlineMs, signal });
249
285
  alive();
250
286
  if (!/^unix:\/\/\/[^,\0]+$/.test(engine.endpoint) || normalize(engine.endpoint.slice(7)) !== engine.endpoint.slice(7) ||
251
287
  !engine.cachedSupervisor || !engine.cachedRunner || !/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,255}$/.test(engine.daemonId))
252
288
  fail("engine_endpoint_or_cache_invalid");
289
+ if (engine.cachedProducerSupervisor !== true)
290
+ fail("producer_helper_cache_unavailable");
253
291
  if (engine.runnerCustodyVersion !== "v1")
254
292
  fail("runner_custody_label_unqualified");
255
293
  if (authority && (authority.endpoint !== engine.endpoint || authority.daemonId !== engine.daemonId))
@@ -306,7 +344,7 @@ function factory(ports) {
306
344
  await ports.service({ ...executables, uid: principal.uid, serviceLabel: LABEL, plistPath, deadlineMs: input.deadlineMs, signal });
307
345
  alive();
308
346
  const receipt = await ports.receiveBootstrap({ ...executables, authority, configPath,
309
- supervisorImage: input.supervisorImage, deadlineMs: input.deadlineMs, signal });
347
+ supervisorImage: producerSupervisorImage, deadlineMs: input.deadlineMs, signal });
310
348
  alive();
311
349
  if (ports.now() >= input.deadlineMs)
312
350
  fail("startup_proof_expired");
@@ -432,6 +470,9 @@ async function actualEngine(input) {
432
470
  const run = (args) => command(input.dockerExecutable, ["--config", config, "--host", selected, ...args], input.deadlineMs, 16384, input.signal);
433
471
  const daemon = await run(["info", "--format", "{{.ID}}"]);
434
472
  const supervisor = await run(["image", "inspect", "--format", "{{.Id}}", input.supervisorImage]);
473
+ const producerSupervisorImage = input.producerSupervisorImage ?? input.supervisorImage;
474
+ const producerSupervisor = producerSupervisorImage === input.supervisorImage ? supervisor :
475
+ await run(["image", "inspect", "--format", "{{.Id}}", producerSupervisorImage]);
435
476
  const runner = await run(["image", "inspect", "--format", "{{json .}}", input.runnerImage]);
436
477
  if (daemon.code !== 0)
437
478
  fail("engine_identity_unavailable");
@@ -465,6 +506,7 @@ async function actualEngine(input) {
465
506
  }
466
507
  return { endpoint: selected, daemonId: daemon.stdout,
467
508
  cachedSupervisor: supervisor.code === 0 && /^sha256:[a-f0-9]{64}$/.test(supervisor.stdout),
509
+ cachedProducerSupervisor: producerSupervisor.code === 0 && /^sha256:[a-f0-9]{64}$/.test(producerSupervisor.stdout),
468
510
  cachedRunner: runnerId !== undefined,
469
511
  ...(runnerCustodyVersion === undefined ? {} : { runnerCustodyVersion }) };
470
512
  }
@@ -594,8 +636,10 @@ async function actualBootstrap(input) {
594
636
  fail("bootstrap_cleanup_unproved");
595
637
  id = receiveIdentity(await docker(["inspect", name]), id);
596
638
  const started = await docker(["start", "--attach", id]);
597
- if (started.code !== 0)
598
- fail("bootstrap_proof_refused");
639
+ if (started.code !== 0) {
640
+ const reported = /darwin_thoughts_custody:([a-z_]+)(?![a-z_])/.exec(started.stderr)?.[1];
641
+ fail("bootstrap_proof_refused" + (reported && VERIFIER_REFUSALS.has(reported) ? ":" + reported : ""));
642
+ }
599
643
  const value = JSON.parse(started.stdout);
600
644
  if (typeof value.bytes !== "string" || value.bytes.length > 21848 ||
601
645
  Buffer.from(value.bytes, "base64").toString("base64") !== value.bytes)
@@ -0,0 +1,80 @@
1
+ import { hostname } from "node:os";
2
+ import { loadConfig, normalizeBaseUrl } from "./config.js";
3
+ import { ownedFetch } from "./owned-fetch.js";
4
+ /** One failure event, using the existing personal login and the tenant-stamping ingest route.
5
+ * The short-lived export token stays in memory. Export failure never erases the setup refusal. */
6
+ export async function emitCustodyFailure(ctx, journal, details, parent) {
7
+ const cfg = loadConfig(ctx.home);
8
+ if (!cfg?.user || cfg.account !== (journal.account ?? journal.tenant) ||
9
+ cfg.user.id !== journal.membershipId || !journal.baseUrl ||
10
+ normalizeBaseUrl(cfg.baseUrl) !== normalizeBaseUrl(journal.baseUrl))
11
+ return false;
12
+ const expiry = cfg.auth ? Date.parse(cfg.auth.expiresAt) - ctx.now().getTime() : 0;
13
+ const bearer = cfg.key || (cfg.auth && expiry > 30_000 ? cfg.auth.accessToken : undefined);
14
+ if (!bearer || parent?.aborted)
15
+ return false;
16
+ const deadline = new AbortController();
17
+ const timer = setTimeout(() => deadline.abort(), 5000);
18
+ const signal = parent ? AbortSignal.any([parent, deadline.signal]) : deadline.signal;
19
+ const owner = ownedFetch(ctx.fetch, signal, { maxBodyBytes: 4096 });
20
+ let delivered = false;
21
+ try {
22
+ const origin = normalizeBaseUrl(cfg.baseUrl);
23
+ const minted = await owner.fetch(`${origin}/api/v1/telemetry/token`, {
24
+ method: "POST", redirect: "error", signal,
25
+ headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json" },
26
+ body: JSON.stringify({ ttlSeconds: 60 }),
27
+ });
28
+ if (minted.status !== 200)
29
+ return false;
30
+ const token = await minted.json();
31
+ if (!token || typeof token !== "object" || !("token" in token) ||
32
+ typeof token.token !== "string" || !/^ctc_tel_[A-Za-z0-9._~-]{1,2048}$/.test(token.token) ||
33
+ !("account" in token) || token.account !== cfg.account ||
34
+ !("scope" in token) || token.scope !== "telemetry:write" ||
35
+ !("endpoint" in token) || token.endpoint !== `${origin}/api/v1/telemetry`)
36
+ return false;
37
+ const current = loadConfig(ctx.home);
38
+ if (!current?.user || current.account !== cfg.account || current.user.id !== cfg.user.id ||
39
+ normalizeBaseUrl(current.baseUrl) !== origin)
40
+ return false;
41
+ const attribute = (key, value) => ({ key,
42
+ value: typeof value === "boolean" ? { boolValue: value } : { stringValue: value } });
43
+ const attributes = [
44
+ attribute("catalyst.onboarding.run_id", journal.runId),
45
+ attribute("catalyst.onboarding.step", "runner"),
46
+ attribute("catalyst.onboarding.custody.failure_case", details.custodyFailureCase),
47
+ ...Object.entries(details).filter(([key]) => key !== "custodyFailureCase").map(([key, value]) => attribute(key, value)),
48
+ ];
49
+ const response = await owner.fetch(`${origin}/api/v1/telemetry/v1/logs`, {
50
+ method: "POST", redirect: "error", signal,
51
+ headers: { authorization: `Bearer ${token.token}`, "content-type": "application/json" },
52
+ body: JSON.stringify({ resourceLogs: [{ resource: { attributes: [
53
+ attribute("service.name", "catalyst-cloud.cli"), attribute("host.name", hostname()),
54
+ ] }, scopeLogs: [{ scope: { name: "catalyst-cloud.cli.onboarding", version: journal.cli },
55
+ logRecords: [{ timeUnixNano: String(BigInt(ctx.now().getTime()) * 1000000n),
56
+ severityNumber: 17, severityText: "ERROR", eventName: "onboarding.runner.custody.refused",
57
+ body: { stringValue: "Setup could not verify local storage." }, attributes }] }] }] }),
58
+ });
59
+ const text = await response.text();
60
+ const acknowledgement = text ? JSON.parse(text) : {};
61
+ if (response.ok && acknowledgement && typeof acknowledgement === "object" && !Array.isArray(acknowledgement)) {
62
+ const partial = "partialSuccess" in acknowledgement ? acknowledgement.partialSuccess : undefined;
63
+ delivered = partial === undefined || !!partial && typeof partial === "object" && !Array.isArray(partial) &&
64
+ (!("rejectedLogRecords" in partial) || partial.rejectedLogRecords === 0 || partial.rejectedLogRecords === "0");
65
+ }
66
+ }
67
+ catch {
68
+ delivered = false;
69
+ }
70
+ finally {
71
+ clearTimeout(timer);
72
+ try {
73
+ await owner.settle();
74
+ }
75
+ catch {
76
+ delivered = false;
77
+ }
78
+ }
79
+ return delivered;
80
+ }
@@ -8,7 +8,8 @@ import { runnerAdmission, issueRunnerOrgKey, verifyRunnerRoutes } from "./onboar
8
8
  import { verifyOnboardRoutes } from "./onboard-capabilities.js";
9
9
  import { liveTeamKey, onboardTeamAdmission } from "./onboard-capacity.js";
10
10
  import { runnerVmCapabilities } from "./onboard-runner-probes.js";
11
- import { installDarwinThoughtsCustody } from "./onboard-runner-custody.js";
11
+ import { darwinThoughtsInstallException, darwinThoughtsInstallRefusal, installDarwinThoughtsCustody } from "./onboard-runner-custody.js";
12
+ import { emitCustodyFailure } from "./onboard-runner-telemetry.js";
12
13
  import { canonicalDarwinThoughtsJson, parseDarwinThoughtsAuthority } from "../vendor/self-host/darwin-thoughts-custody/verifier.mjs";
13
14
  import { readExistingOnboardJson, readOnboardTeamInventory, selectedOnboardTeam, } from "./onboard-existing.js";
14
15
  import { onboardStateRoot, } from "./onboard.js";
@@ -19,13 +20,13 @@ import { onboardStateRoot, } from "./onboard.js";
19
20
  /** The Compose project name the vendored file declares. */
20
21
  export const RUNNER_PROJECT = "catalyst-host";
21
22
  export const RUNNER_SESSION_NETWORK = "catalyst-session-v1";
22
- /** Public multi-architecture images from main 3d657787e8: host run 38043266620,
23
- * runner run 38042751509. Explicit environment image values override
24
- * these pins; the runner also preserves a saved image before choosing its default. */
23
+ /** Qualified public images from main 72e4e20f86: host run 38073557244 and
24
+ * runner run 38073557245; the unchanged watchdog retains its earlier reviewed pin.
25
+ * Explicit environment values override these pins; a saved runner image is preserved. */
25
26
  export const RUNNER_HOST_IMAGES = {
26
- supervisor: "ghcr.io/coalesce-labs/catalyst-supervisor@sha256:a0a8f383b5869eddc8346b7d07fd98d92fe1cd4cfc57956cbbe9dc42d79a4727",
27
+ supervisor: "ghcr.io/coalesce-labs/catalyst-supervisor@sha256:c175a4176ffdca4ec6689217a2a1c4bcc83cc8e0e93443e3e1d6d449433068f5",
27
28
  watchdog: "ghcr.io/coalesce-labs/catalyst-deadline-watchdog@sha256:a5999dbf229ac432b83c2ed3fe43fa251366baceb73af2f57590890a6a758f0d",
28
- runner: "ghcr.io/coalesce-labs/catalyst-runner@sha256:88c6143f6c95f92fca9ca385f3c5145389e6d6d0532398c52d225d0edfcf2ea8",
29
+ runner: "ghcr.io/coalesce-labs/catalyst-runner@sha256:29603376bfd88559f8aa13cccbec31f578be61e99eb8f65f1dcea9ea757c1391",
29
30
  };
30
31
  const IMAGE_REF = /^[a-z0-9][a-z0-9._:/-]{0,255}@sha256:[0-9a-f]{64}$/;
31
32
  const HOST_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
@@ -242,16 +243,30 @@ export function dockerRunnerEngine(deps = {}) {
242
243
  const baseUrl = origins[0].slice("CATALYST_MIRROR_URL=".length);
243
244
  if (!HOST_NAME.test(hostName))
244
245
  return "unverified";
245
- // A running older pin is still ours only when the self-owned Compose environment
246
- // names that exact pinned image and the same runtime identity. Setup can then move it
247
- // to the desired pin after the normal enrollment and custody checks.
248
- if (config.Image !== supervisorImage &&
249
- (!saved || !IMAGE_REF.test(saved.CATALYST_SUPERVISOR_IMAGE ?? "") ||
250
- config.Image !== saved.CATALYST_SUPERVISOR_IMAGE ||
246
+ // An interrupted update can leave saved intent ahead of the actual runtime.
247
+ // A later requested pin still requires the same publisher and installation identity.
248
+ if (config.Image !== supervisorImage) {
249
+ if (!saved || !IMAGE_REF.test(saved.CATALYST_SUPERVISOR_IMAGE ?? "") ||
250
+ typeof config.Image !== "string" || !IMAGE_REF.test(config.Image) ||
251
+ config.Image.split("@sha256:")[0] !== supervisorImage.split("@sha256:")[0] ||
251
252
  saved.CATALYST_SUPERVISOR_IMAGE.split("@sha256:")[0] !== supervisorImage.split("@sha256:")[0] ||
252
253
  saved.CATALYST_HOST_NAME !== hostName ||
253
- normalizeBaseUrl(saved.CATALYST_MIRROR_URL ?? "") !== normalizeBaseUrl(baseUrl)))
254
- return "unverified";
254
+ normalizeBaseUrl(saved.CATALYST_MIRROR_URL ?? "") !== normalizeBaseUrl(baseUrl))
255
+ return "unverified";
256
+ if (config.Image !== saved.CATALYST_SUPERVISOR_IMAGE && saved.CATALYST_SUPERVISOR_IMAGE !== supervisorImage) {
257
+ // Prove the configured old digest names this exact cached runtime, without a pull.
258
+ const imageRead = await docker(["image", "inspect", config.Image], { signal });
259
+ if (imageRead.code !== 0 || signal?.aborted)
260
+ return "unverified";
261
+ const cached = JSON.parse(imageRead.stdout);
262
+ const runtimeImage = rows[0]?.Image;
263
+ if (!Array.isArray(cached) || cached.length !== 1 ||
264
+ typeof runtimeImage !== "string" || !/^sha256:[a-f0-9]{64}$/.test(runtimeImage) ||
265
+ cached[0]?.Id !== runtimeImage || !Array.isArray(cached[0]?.RepoDigests) ||
266
+ !cached[0].RepoDigests.includes(config.Image))
267
+ return "unverified";
268
+ }
269
+ }
255
270
  return { dir, hostName, baseUrl: normalizeBaseUrl(baseUrl) };
256
271
  }
257
272
  catch {
@@ -708,6 +723,15 @@ export function onboardRunnerAdapter(input = {}) {
708
723
  ...want,
709
724
  ...Object.fromEntries(Object.entries(saved ?? {}).filter(([key]) => !(key in want))),
710
725
  });
726
+ async function refuseCustody(ctx, journal, failureCase, message, details = {}, signal) {
727
+ if (signal?.aborted)
728
+ return waiting("interrupted", selected);
729
+ input.message?.(message);
730
+ const evidence = { custodyFailureCase: failureCase, ...details };
731
+ const delivered = await emitCustodyFailure(ctx, journal, evidence, signal);
732
+ return waiting("runner_thoughts_custody_unavailable", { ...selected, ...evidence,
733
+ custodyTelemetry: delivered ? "sent" : "unavailable" });
734
+ }
711
735
  async function listHosts(ctx, p, signal) {
712
736
  const read = await readExistingOnboardJson(ctx, `${ENROLLMENTS}?account=${encodeURIComponent(p.account)}`, signal);
713
737
  return "reason" in read ? null : parseHosts(read.body);
@@ -934,8 +958,6 @@ export function onboardRunnerAdapter(input = {}) {
934
958
  return false;
935
959
  }
936
960
  };
937
- if (!writeEnv(want))
938
- return { state: "failed", reason: "runner_directory_unavailable", evidence: selected };
939
961
  for (const ref of Object.values(p.images)) {
940
962
  if (!(await engine.imageArch(ref, signal)) && !p.info.vm) {
941
963
  await engine.pull(ref, signal);
@@ -950,11 +972,13 @@ export function onboardRunnerAdapter(input = {}) {
950
972
  const capability = await engine.vmCapabilities(p.dir, p.images.supervisor, p.baseUrl, signal);
951
973
  if (capability !== "ready")
952
974
  return waiting(capability, selected);
975
+ if (!engine.nativeThoughtsCustody)
976
+ return refuseCustody(ctx, journal, "capability_missing", "Setup could not verify local storage: this engine has no native storage-check capability.", {}, signal);
977
+ let custodyReturned = false;
953
978
  try {
954
- if (!engine.nativeThoughtsCustody)
955
- return waiting("runner_thoughts_custody_unavailable", selected);
956
979
  const result = await engine.nativeThoughtsCustody({ dir: p.dir,
957
980
  supervisorImage: p.images.supervisor, runnerImage: p.images.runner }, signal);
981
+ custodyReturned = true;
958
982
  if (signal?.aborted)
959
983
  return waiting("interrupted", selected);
960
984
  const values = {
@@ -962,19 +986,23 @@ export function onboardRunnerAdapter(input = {}) {
962
986
  CATALYST_THOUGHTS_CUSTODY_REQUESTS_DIR: result.requestsRoot,
963
987
  CATALYST_THOUGHTS_CUSTODY_RESPONSES_DIR: result.responsesRoot,
964
988
  };
965
- if (persistedCustody(p.dir, values) !== "installed" ||
966
- canonicalDarwinThoughtsJson(result.authority) !== result.envAuthority)
967
- return waiting("runner_thoughts_custody_unavailable", selected);
989
+ const custodyResultInstalled = persistedCustody(p.dir, values) === "installed";
990
+ const custodyAuthorityMatched = canonicalDarwinThoughtsJson(result.authority) === result.envAuthority;
991
+ if (!custodyResultInstalled || !custodyAuthorityMatched)
992
+ return refuseCustody(ctx, journal, "result_unverified", "Setup could not verify local storage: the returned installation or authority did not match.", { custodyResultInstalled, custodyAuthorityMatched }, signal);
968
993
  writePrivate(join(p.dir, "compose.darwin-thoughts.yaml"), readFileSync(join(packageRoot(), "vendor", "self-host", "compose.darwin-thoughts.yaml"), "utf8"));
969
994
  receivedCustody = { dir: p.dir, result };
970
995
  want = (await desiredEnv(p, ctx));
971
- if (!writeEnv(want))
972
- return { state: "failed", reason: "runner_directory_unavailable", evidence: selected };
973
996
  }
974
- catch {
975
- return waiting(signal?.aborted ? "interrupted" : "runner_thoughts_custody_unavailable", selected);
997
+ catch (error) {
998
+ const custodyReason = darwinThoughtsInstallRefusal(error);
999
+ const failureCase = custodyReturned ? "result_unverified" : "call_threw";
1000
+ const details = { ...darwinThoughtsInstallException(error), ...(custodyReason ? { custodyReason } : {}) };
1001
+ return refuseCustody(ctx, journal, failureCase, `Setup could not verify local storage: ${custodyReturned ? "recording the result failed" : "the native check threw"} (${details.custodyErrorClass}: ${details.custodyErrorMessage}).`, details, signal);
976
1002
  }
977
1003
  }
1004
+ if (!writeEnv(want))
1005
+ return { state: "failed", reason: "runner_directory_unavailable", evidence: selected };
978
1006
  const network = await engine.network(RUNNER_SESSION_NETWORK, signal);
979
1007
  if (network === "misshaped")
980
1008
  return waiting("runner_session_network_misshaped", selected);
package/dist/onboard.js CHANGED
@@ -315,6 +315,14 @@ function normalizeStep(value, fallbackAt) {
315
315
  "actor",
316
316
  // CTC-4716: which AI accounts the workspace may add, so the step's text offers only those.
317
317
  "aiAccountKinds",
318
+ "custodyFailureCase",
319
+ "custodyErrorClass",
320
+ "custodyErrorMessage",
321
+ "custodyErrorMessageRedacted",
322
+ "custodyReason",
323
+ "custodyResultInstalled",
324
+ "custodyAuthorityMatched",
325
+ "custodyTelemetry",
318
326
  ]) {
319
327
  const item = evidence?.[key];
320
328
  if (item === null ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catalyst-cloud/cli",
3
- "version": "0.16.7",
3
+ "version": "0.16.9",
4
4
  "description": "Set up Catalyst Cloud, check your tickets and manage your account from the command line.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -4,7 +4,7 @@ description: >-
4
4
  Catalyst's GitHub: show a ticket's pull request with its checks, reviews and review threads, say whether it is mergeable under this repository's policy, and explain what a PR accumulates as the ticket moves (the branch, the draft, the rewrite, the force-pushes, the labels, the queue). Use when someone asks "show me the PR", "what are the checks saying", "why hasn't it merged", "what does the queue need", "what does that label mean", or wants the branch and merge conventions Catalyst follows.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # Catalyst's GitHub
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Catalyst's view of Linear on the customer's own cloud account. Reads a ticket with its comments, relations, labels, linked pull requests and agent sessions inline, from the cloud API by default, with local replica reads available as an explicit opt-in, always naming the source; searches tickets, PRs, projects and initiatives; writes comments, card moves, labels and new tickets through the account's agent proxy as the app actor, with every route, stage id, label id and marker read from the account's contract. Knows what a ticket accumulates as Catalyst works it (phase-outcome comments, the document per phase, the agent session, the labels, the single blocks relation, the bookkeeping marker, the eyes acknowledgement). Use when a person says "show me the ticket", "what did Catalyst write on it", "comment on it", "move it", "label it" or "file a ticket". Not for raising a decision for a human (what-needs-me) and not for pull requests (catalyst-github).
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # Catalyst Linear
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Set up Catalyst Cloud and say whether setup is working. Walks a person from nothing to their first ticket running, one step at a time: the coding account, the project, the integrations and connected accounts, each repository's settings file, then one real ticket moving. Also logs this machine in, reads the readiness verdict with who can fix each failure, and checks the optional local replica. Use when someone says "set me up", "onboard me", "I just signed up", "get me started", "what do I do first", "log me in", "which account is this machine on", "am I set up", "what is missing", "why does nothing happen" or "is the replica running", when a login expired, or when a skill script exits 2 saying this machine is not connected. Does every step a key can do through the catalyst CLI, hands over the exact page for the steps only a browser can do, and never claims a step it did not watch succeed.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # Onboard me
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Own one Catalyst Cloud project end to end until it closes. Use when the person says "run this project for me", "own this until it ships", "keep this moving", or hands you a project id or a set of tickets to drive. Subscribes to the account's event stream for the scope through the catalyst CLI, reacts to each change in the same turn, makes tickets ready and moves them to dispatch, parks what should stop, chases stalls, escalates inward, and keeps one status summary current. Writes to Linear as the app actor; never polls.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # Run this project
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Get a stuck Catalyst Cloud ticket moving again. Use when the person asks "why is this parked and can you release it?", "unpark this", "get things flowing again", "the outage is over, retry what failed", or hands you a ticket that is not moving. Reads why nothing runs and what holds the ticket through the catalyst CLI, decides whether the recorded cause is fixed, previews the release, releases every governor holding the ticket the right way (or one failure class across a team), and raises an ask only for what a person has to do. Never releases a cause it cannot show changed without saying so.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # Unstick
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  The human's decision inbox on Catalyst Cloud, and the one way an agent raises a decision on their behalf. Use when the person asks "what needs me?", "what am I blocking?", or when active work is gated on a choice only they can make. Lists open asks ranked by how much open work each one holds, files an ask through the cloud's ask route with the account's own template, and records the answer so the held work releases. Never answers as the human, never duplicates an open ask.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # What needs me
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  What environment variable names does this repository need, and where does each one come from? Scans the repository offline (no login, no network) and lists the names in three groups (build/test, deploy-only, bindings), each with where it was found, what uses it, and where a local value would come from. Never reads a value or prints one. Also checks the environment variable table in `.catalyst/catalyst.toml` offline. Use when someone asks "what does catalyst.env.json mean", "what env vars does this repo need", "why does the container need this", or before reviewing or writing the declaration.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # What this repository needs
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Use for "what's happening?", "what machines do we have?", "how much capacity do we have?", "where are we?", "why is that stuck?", "what closed?", "what's next?", "how does this work?", "why did it do that?", "how does it prioritise?" and "what does this setting do, where is it set?" in Catalyst Cloud, or asks for something to be done rather than known. Reads the contract via catalyst CLI. Read-only: route work/decisions, never answer as the human.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.7 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.9 — written in this repository for customer accounts -->
8
8
 
9
9
  # What's happening
10
10
 
@@ -4,7 +4,7 @@
4
4
  "inputs": {
5
5
  "packages/host-isolation/src/darwin-thoughts-producer.ts": "038fb63d8121fb1665ec31869f45604aedd96dd7d9b15a415d578fea9a0ad507",
6
6
  "packages/protocol/src/darwin-thoughts-custody.ts": "3515efc22b0a3cfb512ff1acaf649c6eafb978b894c724fabb01c325aea51075",
7
- "packages/host-isolation/src/darwin-thoughts-custody.ts": "5d65d59d71205e2ce5551e99b4ad33364d53cbdd29993cf2f164fc214b83baf8",
7
+ "packages/host-isolation/src/darwin-thoughts-custody.ts": "d75c21a5a64a3200f882f14d15c80eb365637e91d2d101cc6c20568f689ffe8d",
8
8
  "deploy/self-host/darwin-thoughts-custody/producer-entry.ts": "27c8ff591c8dc4d1a4c65dd154157df5191ead1fb0af673bfd7099d5226d37bc",
9
9
  "deploy/self-host/darwin-thoughts-custody/verifier-entry.ts": "80bc1e72943e43bc33d76ba205bd79751f58ca34d622e35f7e50e3b661f65464",
10
10
  "deploy/self-host/darwin-thoughts-custody/generate.ts": "bfe1bef175fa8243be0558e1ddee6ddbcfbd622922e3a5df850e8621f18e7b26",
@@ -13,6 +13,6 @@
13
13
  "deploy/self-host/darwin-thoughts-custody/service.plist.in": "66e9a2c175d2500b1f7130e7c04a5ed07f22bc7425661777f514fa3f2a816496"
14
14
  },
15
15
  "artifactSha256": "0e0f1bbdac23813e8ee57b6eb4ae3dfd24c3f1c51ebe0c3d119a1448734ea05e",
16
- "verifierSha256": "2d8c9b5c35e38a25a45098b7606a216109557fb0466113098f503e9d6c8f6b4c",
16
+ "verifierSha256": "64bc6251fbd7033067fab74d855293b901e05d3280a3f5fcb76811440dcbeb5d",
17
17
  "verifierDeclarationsSha256": "624428ced2eb18b045b761b49e20b7f52c0fc6c3132689571103ece7b4a1083f"
18
18
  }
@@ -522,6 +522,19 @@ function checkAncestors(expected) {
522
522
  }
523
523
  }
524
524
  }
525
+ function receiveStagingChannel(path, before, stagedFile, observedAncestors) {
526
+ const current = directory(path, true);
527
+ if (sameDirectoryAuthority(before, current))
528
+ return current;
529
+ if (before.dev !== current.dev || before.ino !== current.ino || before.mode !== current.mode || before.uid !== 0n || before.gid !== 0n || current.uid !== 10001n || current.gid !== 10001n || process.getuid?.() !== 10001 || process.geteuid?.() !== 10001 || process.getgid?.() !== 10001 || stagedFile.uid !== 10001n || stagedFile.gid !== 10001n)
530
+ throw failure("ancestor_identity");
531
+ const channel = observedAncestors.find((ancestor) => ancestor.path === path);
532
+ if (!channel || !sameDirectoryAuthority(channel.stat, before))
533
+ throw failure("ancestor_identity");
534
+ checkAncestors(observedAncestors.filter((ancestor) => ancestor.path !== path));
535
+ channel.stat = current;
536
+ return current;
537
+ }
525
538
  function isMissing(error) {
526
539
  return error instanceof Error && "code" in error && error.code === "ENOENT";
527
540
  }
@@ -607,7 +620,7 @@ async function exchange(options, bootstrap) {
607
620
  issuedAtMs,
608
621
  expiresAtMs: options.deadlineMs
609
622
  }));
610
- const requests = directory(options.requestDir, true);
623
+ let requests = directory(options.requestDir, true);
611
624
  const responses = directory(options.responseDir, true);
612
625
  const creationPaths = bootstrap ? bootstrapPaths(authority, options.tenant, options.repository) : [];
613
626
  if (bootstrap)
@@ -651,6 +664,7 @@ async function exchange(options, bootstrap) {
651
664
  } finally {
652
665
  fs.closeSync(fd);
653
666
  }
667
+ requests = receiveStagingChannel(options.requestDir, requests, owned, aliasAncestors);
654
668
  checkAncestors(aliasAncestors);
655
669
  if (!sameDirectoryAuthority(requests, directory(options.requestDir, true)))
656
670
  throw failure("channel_identity");
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "repository": "coalesce-labs/catalyst-cloud",
3
- "commit": "3d657787e8d4a0295068d0ea67ea3e7a1f4707a2",
3
+ "commit": "72e4e20f866e0c0885d1b40fc0e1a1026a2487a6",
4
4
  "sha256": {
5
5
  "deploy/self-host/compose.yaml": "0ffb7671c7ea49d8490d6e97093ada0afcb31da3b00092a8768150b090cca0bc",
6
6
  "deploy/self-host/compose.darwin-thoughts.yaml": "6269d66d6f487175ab8560d0648e65c8a0eccb86f69a8dc24daf41d8ae1dcf02",
7
7
  "deploy/self-host/darwin-thoughts-custody/producer.mjs": "0e0f1bbdac23813e8ee57b6eb4ae3dfd24c3f1c51ebe0c3d119a1448734ea05e",
8
- "deploy/self-host/darwin-thoughts-custody/verifier.mjs": "2d8c9b5c35e38a25a45098b7606a216109557fb0466113098f503e9d6c8f6b4c",
8
+ "deploy/self-host/darwin-thoughts-custody/verifier.mjs": "64bc6251fbd7033067fab74d855293b901e05d3280a3f5fcb76811440dcbeb5d",
9
9
  "deploy/self-host/darwin-thoughts-custody/verifier.d.mts": "624428ced2eb18b045b761b49e20b7f52c0fc6c3132689571103ece7b4a1083f",
10
10
  "deploy/self-host/darwin-thoughts-custody/watchdog.mjs": "6b5c7204aacd296c85a216d4f1b3adbe2084024fe37200ec1d24dfc2dec2e12d",
11
11
  "deploy/self-host/darwin-thoughts-custody/watchdog-deadline.mjs": "a642e6d8968f56f635056d3b258e5c4ad186c638a273c26b4528e85b7d2a6346",
12
12
  "deploy/self-host/darwin-thoughts-custody/service.plist.in": "66e9a2c175d2500b1f7130e7c04a5ed07f22bc7425661777f514fa3f2a816496",
13
- "deploy/self-host/darwin-thoughts-custody/manifest.json": "ee575635e8135bc2d9e735bb69795d011371e234af1139e30dfee6d4785f4fa4",
13
+ "deploy/self-host/darwin-thoughts-custody/manifest.json": "c7816e0ffa4ae46b6d19f79359bbddbc889bd88f948c7e3e1ab36cccaaf45382",
14
14
  "deploy/self-host/linux-session-egress/session-egress.py": "a20cedfa1e883127ec461e4b7f9588d379fe1633b8244ecd703c81f589d3f142",
15
15
  "deploy/self-host/linux-session-egress/catalyst-session-egress.service": "703c150ab23ec87aea47cfc394f63e061b66c4b8c1454a88a9be879c161ce2a5",
16
16
  "deploy/self-host/linux-session-egress/catalyst-session-egress-attest.service": "94fa75ea0616f6a1172fc20ca637a5727c36456357e4a977d5bdd65f2fad2e8d",