benignswarm 0.12.138 → 0.12.139

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/dist/args.js CHANGED
@@ -34,7 +34,7 @@ export const STRING_FLAGS = [
34
34
  "drain-timeout", "on-running-turn", "extend", "ssh-config", "poll-ms",
35
35
  "stage", "machines", "resolved-retention-days", "wont-fix-retention-days", "alert-cooldown-minutes", "alerts", "confirm-force",
36
36
  "machine-session-id", "harness-binary", "pool-sessions", "registry", "detail", "worktree", "turn-claude-runtime", "turn-antigravity-runtime",
37
- "purpose", "storage-mode", "hosts", "arn", "version-id",
37
+ "purpose", "storage-mode", "hosts", "arn", "version-id", "kms-key",
38
38
  "mode", "weights", "quality-target", "half-life", "min-samples", "build-explore", "review-explore", "pause-build", "pause-review", "class",
39
39
  "expires-at", "conflicts-with", "source-channel-id", "source-message-id", "plain-summary",
40
40
  "metadata-file", "confirm-agent", "confirm-parked", "step",
@@ -44,7 +44,7 @@ export const BOOL_FLAGS = [
44
44
  "read-account-status", "replace-key", "mentions-me", "no-skill", "replace", "template", "scope-only", "unread",
45
45
  "pending", "force", "no-hooks", "yes", "open", "bind-here", "peek", "once", "launchd", "full", "no-bind",
46
46
  "all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive",
47
- "approve", "turn", "service", "print-hooks", "create", "rotate", "codex-userns", "bwrap-userns", "agy-userns", "print-apparmor",
47
+ "approve", "turn", "service", "print-hooks", "create", "rotate", "drain", "codex-userns", "bwrap-userns", "agy-userns", "print-apparmor",
48
48
  "cancel", "rerun", "confirmed", "refuted", "no-source", "confirm-bypass-signal", "assessment-only",
49
49
  "no-wait-verify", "preview", "remove-empty", "dry-run", "quota-substitution",
50
50
  "in-container", "retrieve-ec2", "stdin", "context-confirmed", "confirm-compatible", "no-commits-beyond-target",
@@ -127,7 +127,7 @@ export async function admin(p, out) {
127
127
  case "notifier":
128
128
  return notifierAdmin(p, out);
129
129
  case "account":
130
- return accountAdmin(p, out);
130
+ return accountAdmin(p, out, action, rest);
131
131
  case "account-stores":
132
132
  return accountStoresAdmin(action, rest, p, out);
133
133
  case "turn-judgment":
@@ -72,7 +72,7 @@ function writeMachineState(s) {
72
72
  * 12: Claude Code workspace-write roots name only the checkout, active unit worktree, narrowed Git metadata, config and caches.
73
73
  */
74
74
  const START_REV = 12;
75
- export const sessionFingerprint = (s, writable = [], imageDigest = null) => JSON.stringify([s.id, s.harness, ...(s.provider && s.provider !== "anthropic" ? [s.provider] : []), s.dir, s.sandbox, s.model, s.effort, s.turn_timeout, s.turns_per_hour ?? DEFAULT_TURNS_PER_HOUR, s.unproductive_per_hour ?? DEFAULT_UNPRODUCTIVE_PER_HOUR, s.turn_coalesce_seconds ?? 180, ...(s.max_budget_usd != null ? [`budget:${s.max_budget_usd}`] : []), ...(s.harness_binary ? [`binary:${s.harness_binary}`] : []), s.thread, ...(writable.length ? [writable] : []), ...(imageDigest ? [imageDigest] : []), ...(START_REV > 1 ? [`rev${START_REV}`] : [])]);
75
+ export const sessionFingerprint = (s, writable = [], imageDigest = null) => JSON.stringify([s.id, s.harness, ...(s.provider && s.provider !== "anthropic" ? [s.provider] : []), s.dir, s.sandbox, s.model, s.effort, s.turn_timeout, s.turns_per_hour ?? DEFAULT_TURNS_PER_HOUR, s.unproductive_per_hour ?? DEFAULT_UNPRODUCTIVE_PER_HOUR, s.turn_coalesce_seconds ?? 180, ...(s.max_budget_usd != null ? [`budget:${s.max_budget_usd}`] : []), ...(s.harness_binary ? [`binary:${s.harness_binary}`] : []), s.thread, ...(writable.length ? [writable] : []), ...(imageDigest ? [`image:${imageDigest}`] : []), ...(s.secret_context_hash ? [`secrets:${s.secret_context_hash}`] : []), ...(START_REV > 1 ? [`rev${START_REV}`] : [])]);
76
76
  /** A server thread update must restart the watcher even if a stored fingerprint is unexpectedly stale. */
77
77
  export function sessionConfigChanged(s, local, fingerprint) {
78
78
  const serverThreadChanged = s.thread !== null && s.thread !== (local?.thread ?? null);
@@ -968,7 +968,12 @@ export async function launchDesiredSession(opts) {
968
968
  return runner(opts.bin, startArgs(opts.s, opts.thread, opts.sessionWritable, opts.startupJitterSeconds), {
969
969
  cwd: opts.s.dir,
970
970
  timeout: startWaitMs(opts.s),
971
- env: { ...process.env, ...opts.secretEnv, ...(opts.progressFile ? { BSCHAT_MACHINE_START_PROGRESS_FILE: opts.progressFile } : {}) },
971
+ env: {
972
+ ...process.env,
973
+ ...opts.secretEnv,
974
+ ...(opts.secretDeclaredHosts?.length ? { B9S_SECRET_DECLARED_HOSTS: JSON.stringify(opts.secretDeclaredHosts) } : {}),
975
+ ...(opts.progressFile ? { BSCHAT_MACHINE_START_PROGRESS_FILE: opts.progressFile } : {}),
976
+ },
972
977
  });
973
978
  }
974
979
  const { runtime, imageDigest } = resolveContainerLaunchPrereqs({
@@ -1034,14 +1039,16 @@ export async function launchDesiredSession(opts) {
1034
1039
  B9S_URL: opts.m.url,
1035
1040
  B9S_AGENT: opts.s.agent,
1036
1041
  B9S_HOME: "/home/agent/.b9s",
1042
+ ...(opts.secretDeclaredHosts?.length ? { B9S_SECRET_DECLARED_HOSTS: JSON.stringify(opts.secretDeclaredHosts) } : {}),
1037
1043
  ...(opts.containerProgressFile ? { BSCHAT_MACHINE_START_PROGRESS_FILE: opts.containerProgressFile } : {}),
1038
1044
  },
1045
+ secretEnvKeys: opts.projectSecretEnvKeys,
1039
1046
  command: ["b9s", ...startArgs({ ...opts.s, harness_binary: null }, opts.thread, opts.s.sandbox === "workspace-write" ? containerWritablePaths : [], opts.startupJitterSeconds), "--in-container"],
1040
1047
  });
1041
1048
  const launchRes = runner(runtime, runArgs, {
1042
1049
  cwd: opts.s.dir,
1043
1050
  timeout: 60_000,
1044
- env: isolatedSubprocessEnv(process.env),
1051
+ env: isolatedSubprocessEnv(process.env, opts.secretEnv, opts.projectSecretEnvKeys),
1045
1052
  });
1046
1053
  if (launchRes.status !== 0)
1047
1054
  return launchRes;
@@ -1481,68 +1488,112 @@ export async function reconcile(m, log, reportIntervalSeconds = 30, deps) {
1481
1488
  }
1482
1489
  delete state.unsettled_turns[s.dir];
1483
1490
  }
1484
- const secretDelivery = resolveSessionSecretDelivery({
1485
- session: s,
1486
- secrets: me.harness_secrets ?? [],
1487
- targetDir: join(configRoot(), "providers", "ephemeral"),
1488
- runner: deps?.runner,
1489
- });
1490
- const startId = createHash("sha256").update(s.id).digest("hex").slice(0, 24);
1491
- const progressDir = containerMode ? join(agentHomeDirOf(s), ".b9s", "logs") : join(configRoot(), "state", "machine-start");
1492
- mkdirSync(progressDir, { recursive: true, mode: 0o700 });
1493
- const progressFile = join(progressDir, `start-${startId}.json`);
1494
- // What the daemon trusts (the child's identity, the outcome) stays in host-private state:
1495
- // a containerised session can write its own home, and only the progress note lives there.
1496
- // The name is per attempt, so nothing an earlier child wrote is read as this one's.
1497
- const privateDir = join(configRoot(), "state", "machine-start");
1498
- mkdirSync(privateDir, { recursive: true, mode: 0o700 });
1499
- const resultFile = join(privateDir, `result-${startId}-${randomBytes(6).toString("hex")}.json`);
1500
- writeJsonAtomically(progressFile, { state: "starting", at: new Date().toISOString() });
1501
- const launchOptions = {
1502
- m, accountId, s, project: projectEntry, thread, sessionWritable, machineWritable: writable,
1503
- bin, secretEnv: secretDelivery.env, containerMode, pullImage: isPoolImageOptIn, workdir,
1504
- sandboxReport: hostContainerProbe ?? undefined, onEc2, containerImdsBlocked: containerImdsOk,
1505
- startupJitterSeconds: deps?.startupJitterSeconds,
1506
- progressFile: containerMode ? undefined : progressFile,
1507
- containerProgressFile: containerMode ? `/home/agent/.b9s/logs/start-${startId}.json` : undefined,
1508
- };
1509
- rmSync(startChildFile(resultFile), { force: true });
1510
- // The intent is on disk before anything is launched, so a daemon that stops at any point
1511
- // from here finds either this record, the child's own file, or the result: never nothing.
1512
- const pending = {
1513
- pid: 0, pid_started: null, started_at: new Date().toISOString(), progress_file: progressFile, result_file: resultFile,
1514
- child_file: startChildFile(resultFile),
1515
- secret_files: secretDelivery.files, fingerprint: fp, thread, desired: s,
1516
- writable: sessionWritable, image_digest: pinnedImageRef,
1517
- ...(containerMode && containerPrereqs && containerName
1518
- ? {
1519
- container_name: containerName,
1520
- container_runtime: containerPrereqs.runtime,
1521
- container_runtime_version: containerPrereqs.version,
1522
- image_digest: extractPinnedImageDigest(pinnedImageRef),
1523
- image_reference: pinnedImageRef,
1524
- }
1525
- : {}),
1526
- };
1527
- state.starting_sessions[s.id] = pending;
1491
+ let secretDelivery = null;
1492
+ let pending = null;
1493
+ let childLaunched = false;
1494
+ const projectSecretEnv = {};
1495
+ const mergedSecretEnv = {};
1496
+ let secretDeclaredHosts = [];
1528
1497
  try {
1498
+ secretDelivery = resolveSessionSecretDelivery({
1499
+ session: s,
1500
+ secrets: me.harness_secrets ?? [],
1501
+ targetDir: join(configRoot(), "providers", "ephemeral"),
1502
+ runner: deps?.runner,
1503
+ });
1504
+ if (s.secret_grant_required) {
1505
+ const grant = await client.call("POST", `/machines/me/sessions/${encodeURIComponent(s.id)}/secret-grant`, {});
1506
+ const redeemed = await Client.raw(m.url, grant.grant_token).call("POST", "/secret-broker/redeem", {});
1507
+ if (!redeemed.secrets || typeof redeemed.secrets !== "object" || Array.isArray(redeemed.secrets)) {
1508
+ throw new Error("secret broker returned no authorized secret values");
1509
+ }
1510
+ if (!Array.isArray(redeemed.declared_hosts) || redeemed.declared_hosts.some((host) => typeof host !== "string")) {
1511
+ throw new Error("secret broker returned an invalid declared host list");
1512
+ }
1513
+ secretDeclaredHosts = redeemed.declared_hosts;
1514
+ for (const [key, value] of Object.entries(redeemed.secrets)) {
1515
+ if (typeof value !== "string")
1516
+ throw new Error("secret broker returned a non-text secret value");
1517
+ if (Object.prototype.hasOwnProperty.call(secretDelivery.env, key)) {
1518
+ throw new Error(`secret name ${key} collides with a machine credential`);
1519
+ }
1520
+ projectSecretEnv[key] = value;
1521
+ }
1522
+ }
1523
+ Object.assign(mergedSecretEnv, secretDelivery.env, projectSecretEnv);
1524
+ const startId = createHash("sha256").update(s.id).digest("hex").slice(0, 24);
1525
+ const progressDir = containerMode ? join(agentHomeDirOf(s), ".b9s", "logs") : join(configRoot(), "state", "machine-start");
1526
+ mkdirSync(progressDir, { recursive: true, mode: 0o700 });
1527
+ const progressFile = join(progressDir, `start-${startId}.json`);
1528
+ // The child identity and result are private machine state; neither contains secret values.
1529
+ const privateDir = join(configRoot(), "state", "machine-start");
1530
+ mkdirSync(privateDir, { recursive: true, mode: 0o700 });
1531
+ const resultFile = join(privateDir, `result-${startId}-${randomBytes(6).toString("hex")}.json`);
1532
+ pending = {
1533
+ pid: 0, pid_started: null, started_at: new Date().toISOString(), progress_file: progressFile, result_file: resultFile,
1534
+ child_file: startChildFile(resultFile),
1535
+ secret_files: secretDelivery.files, fingerprint: fp, thread, desired: s,
1536
+ writable: sessionWritable, image_digest: pinnedImageRef,
1537
+ ...(containerMode && containerPrereqs && containerName
1538
+ ? {
1539
+ container_name: containerName,
1540
+ container_runtime: containerPrereqs.runtime,
1541
+ container_runtime_version: containerPrereqs.version,
1542
+ image_digest: extractPinnedImageDigest(pinnedImageRef),
1543
+ image_reference: pinnedImageRef,
1544
+ }
1545
+ : {}),
1546
+ };
1547
+ writeJsonAtomically(progressFile, { state: "starting", at: new Date().toISOString() });
1548
+ const launchOptions = {
1549
+ m, accountId, s, project: projectEntry, thread, sessionWritable, machineWritable: writable,
1550
+ bin, secretEnv: mergedSecretEnv, projectSecretEnvKeys: Object.keys(projectSecretEnv), secretDeclaredHosts,
1551
+ containerMode, pullImage: isPoolImageOptIn, workdir,
1552
+ sandboxReport: hostContainerProbe ?? undefined, onEc2, containerImdsBlocked: containerImdsOk,
1553
+ startupJitterSeconds: deps?.startupJitterSeconds,
1554
+ progressFile: containerMode ? undefined : progressFile,
1555
+ containerProgressFile: containerMode ? `/home/agent/.b9s/logs/start-${startId}.json` : undefined,
1556
+ };
1557
+ rmSync(startChildFile(resultFile), { force: true });
1558
+ // Persist the start intent before launch so a daemon restart can find the child/result.
1559
+ state.starting_sessions[s.id] = pending;
1529
1560
  writeMachineState(state);
1530
- }
1531
- catch (error) {
1532
- delete state.starting_sessions[s.id];
1533
- secretDelivery.cleanup();
1534
- throw error;
1535
- }
1536
- try {
1537
1561
  await scheduleRestartWork("session start/relaunch", s.agent);
1538
1562
  pending.pid = (deps?.startTrackedSession ?? ((childBin, options, result) => startSessionChild(childBin, s.dir, options, result)))(bin, launchOptions, resultFile);
1563
+ childLaunched = true;
1539
1564
  }
1540
1565
  catch (error) {
1541
- delete state.starting_sessions[s.id];
1542
- writeMachineState(state);
1543
- cleanupMachineStart(pending);
1566
+ if (pending) {
1567
+ delete state.starting_sessions[s.id];
1568
+ try {
1569
+ writeMachineState(state);
1570
+ }
1571
+ finally {
1572
+ cleanupMachineStart(pending);
1573
+ }
1574
+ }
1544
1575
  throw error;
1545
1576
  }
1577
+ finally {
1578
+ for (const k of Object.keys(projectSecretEnv)) {
1579
+ projectSecretEnv[k] = "";
1580
+ delete projectSecretEnv[k];
1581
+ }
1582
+ for (const k of Object.keys(mergedSecretEnv)) {
1583
+ mergedSecretEnv[k] = "";
1584
+ delete mergedSecretEnv[k];
1585
+ }
1586
+ if (secretDelivery) {
1587
+ for (const k of Object.keys(secretDelivery.env)) {
1588
+ secretDelivery.env[k] = "";
1589
+ delete secretDelivery.env[k];
1590
+ }
1591
+ if (!childLaunched)
1592
+ secretDelivery.cleanup();
1593
+ }
1594
+ }
1595
+ if (!pending)
1596
+ throw new Error("tracked machine start did not persist its intent");
1546
1597
  pending.pid_started = readStartStamp(pending.pid);
1547
1598
  try {
1548
1599
  writeMachineState(state);
@@ -2,7 +2,7 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { DEFAULT_URL, listSaved } from "../config.js";
5
- import { bool, str } from "../args.js";
5
+ import { bool, need, str } from "../args.js";
6
6
  import { Client } from "../client.js";
7
7
  import { loadAdmin, resolveAdminName } from "../config.js";
8
8
  import { CliError } from "../errors.js";
@@ -395,8 +395,29 @@ export async function notifierAdmin(p, out) {
395
395
  l ? `last report ${l.at.slice(0, 16).replace("T", " ")} UTC (${l.project}, ${l.items} item${l.items === 1 ? "" : "s"})${l.agent ? `\n ${l.agent.ok ? "ok " : "FAIL"} ${l.agent.name}: ${l.agent.detail}` : ""}${l.email ? `\n ${l.email.ok ? "ok " : "FAIL"} email ${l.email.to}: ${l.email.detail}` : ""}` : "nothing reported yet",
396
396
  ].join("\n"), r);
397
397
  }
398
- export async function accountAdmin(p, out) {
398
+ export async function accountAdmin(p, out, action, rest = []) {
399
399
  const c = adminClient(p);
400
+ if (action === "secrets-kms") {
401
+ const sub = rest[0] ?? "status";
402
+ if (sub === "status" && rest.length <= 1) {
403
+ const k = await c.call("GET", "/account/secrets-kms");
404
+ out.print(`Project secret envelope mode: ${k.mode} (available: ${k.value_storage_available ? "yes" : "no"}${k.value_storage_unavailable_reason ? `, reason: ${k.value_storage_unavailable_reason}` : ""})${k.kms_key_id ? `\nKMS key: ${k.kms_key_id} (${k.kms_region ?? "?"})` : ""}${k.deletion_scheduled_at ? `\nDeletion scheduled: ${k.deletion_scheduled_at}` : ""}\n${k.value_storage_unavailable_message ? `${k.value_storage_unavailable_message}\n` : ""}${k.disclosure ?? ""}`.trim(), k);
405
+ return;
406
+ }
407
+ if (sub === "enable" && rest.length === 1) {
408
+ const region = need(p.flags, "region");
409
+ const kmsKeyId = str(p.flags, "kms-key");
410
+ const k = await c.call("PUT", "/account/secrets-kms", {
411
+ region,
412
+ ...(kmsKeyId ? { kms_key_id: kmsKeyId } : {}),
413
+ });
414
+ out.print(`Enabled per-account AWS KMS wrapping in ${k.kms_region}: ${k.kms_key_id}.\n${k.disclosure ?? ""}`.trim(), k);
415
+ return;
416
+ }
417
+ throw new CliError("usage", "b9s-admin account secrets-kms [status | enable --region <aws-region> [--kms-key <arn-or-id>]]");
418
+ }
419
+ if (action)
420
+ throw new CliError("usage", "b9s-admin account [--summary-minutes <n>] | secrets-kms [status | enable --region <r> [--kms-key <id>]]");
400
421
  const m = intFlag(str(p.flags, "summary-minutes"), "summary-minutes");
401
422
  if (m !== undefined)
402
423
  await c.call("PATCH", "/account", { summary_minutes: m });
@@ -1,5 +1,15 @@
1
1
  import { bool, need, str } from "../args.js";
2
2
  import { CliError } from "../errors.js";
3
+ import { table } from "../output.js";
4
+ function limitFlag(p) {
5
+ const raw = str(p.flags, "limit");
6
+ if (raw === undefined)
7
+ return undefined;
8
+ const n = Number(raw);
9
+ if (!Number.isInteger(n) || n < 1)
10
+ throw new CliError("usage", "--limit must be a positive integer");
11
+ return n;
12
+ }
3
13
  function csv(value) {
4
14
  return value?.split(",").map((part) => part.trim()).filter(Boolean) ?? [];
5
15
  }
@@ -12,7 +22,7 @@ function purposeFlag(p) {
12
22
  export async function projectSecrets(rest, p, c, out) {
13
23
  const [project, action, secret, ...extra] = rest;
14
24
  if (!project || !action)
15
- throw new CliError("usage", "project secrets <project> list|show|create|rotate|revoke|delete|set ...");
25
+ throw new CliError("usage", "project secrets <project> list|show|create|update|rotate|revoke|delete|set|audit ...");
16
26
  const base = `/projects/${encodeURIComponent(project)}/secrets`;
17
27
  const resolve = async (name) => {
18
28
  const listed = await c.call("GET", base);
@@ -40,7 +50,12 @@ export async function projectSecrets(rest, p, c, out) {
40
50
  if (mode === "aws_secrets_manager")
41
51
  body.reference = { arn: need(p.flags, "arn"), version_id: need(p.flags, "version-id") };
42
52
  const result = await c.call("POST", base, body);
43
- out.print(`Created ${secret} for ${project}; values are unavailable until encrypted storage lands in WU #231. Console control: WU #230.`, result);
53
+ const nextHint = mode === "aws_secrets_manager"
54
+ ? "External AWS reference recorded."
55
+ : result.value_storage_available
56
+ ? `Set its encrypted value with: b9s-admin project secrets ${project} set ${secret} --stdin`
57
+ : `Encrypted storage is unavailable (${result.value_storage_unavailable_reason ?? "aws_kms_unconfigured"}); configure per-account AWS KMS before calling set.`;
58
+ out.print(`Created ${secret} for ${project}. ${nextHint} (Console control: WU #230.)`, result);
44
59
  return;
45
60
  }
46
61
  if (action === "show" && secret && !extra.length) {
@@ -49,9 +64,33 @@ export async function projectSecrets(rest, p, c, out) {
49
64
  return;
50
65
  }
51
66
  if (action === "rotate" && secret && !extra.length) {
52
- const result = await c.call("POST", `${base}/${encodeURIComponent(await resolve(secret))}/versions`, { reference: { arn: need(p.flags, "arn"), version_id: need(p.flags, "version-id") } });
53
- out.print(`Recorded a new external reference version for ${secret}.`, result);
54
- return;
67
+ const id = await resolve(secret);
68
+ const drain = bool(p.flags, "drain");
69
+ const arn = str(p.flags, "arn");
70
+ const versionId = str(p.flags, "version-id");
71
+ if (arn !== undefined || versionId !== undefined) {
72
+ const result = await c.call("POST", `${base}/${encodeURIComponent(id)}/versions`, {
73
+ reference: { arn: need(p.flags, "arn"), version_id: need(p.flags, "version-id") },
74
+ ...(drain ? { drain_sessions: true } : {}),
75
+ });
76
+ out.print(`Recorded a new external reference version v${result.secret?.current_version ?? "?"} for ${secret}.${drain ? ` Drained ${result.drained_sessions?.length ?? 0} running session(s).` : ""}`, result);
77
+ return;
78
+ }
79
+ if (bool(p.flags, "stdin") || process.stdin.isTTY) {
80
+ const meta = await c.call("GET", `${base}/${encodeURIComponent(id)}`);
81
+ if (!meta.value_storage_available) {
82
+ throw new CliError("secret_storage_unavailable", "Secret value rotation is unavailable because encrypted storage is not configured on this server; no value was read or sent.");
83
+ }
84
+ let value = await readSecretValue(bool(p.flags, "stdin"));
85
+ const result = await c.call("PUT", `${base}/${encodeURIComponent(id)}/value`, {
86
+ value,
87
+ ...(drain ? { drain_sessions: true } : {}),
88
+ });
89
+ value = "";
90
+ out.print(`Rotated ${secret} to encrypted v${result.version ?? "?"} (${result.storage?.backend ?? "encrypted"}). Notice: BenignSwarm decrypts hosted secrets in memory during broker delivery to authorized sessions.`, result);
91
+ return;
92
+ }
93
+ throw new CliError("usage", "project secrets <p> rotate <name> (--arn <exact ARN> --version-id <id> | --stdin) [--drain]");
55
94
  }
56
95
  if (action === "update" && secret && !extra.length) {
57
96
  const body = {};
@@ -77,27 +116,54 @@ export async function projectSecrets(rest, p, c, out) {
77
116
  }
78
117
  if (action === "revoke" && secret && !extra.length) {
79
118
  const result = await c.call("POST", `${base}/${encodeURIComponent(await resolve(secret))}/revoke`, {});
80
- out.print(`Revoked future access to ${secret}.`, result);
119
+ out.print(`Revoked access to ${secret}; stopped ${result.stopped_sessions?.length ?? 0} active session(s).`, result);
81
120
  return;
82
121
  }
83
122
  if (action === "delete" && secret && !extra.length) {
84
123
  const result = await c.call("DELETE", `${base}/${encodeURIComponent(await resolve(secret))}`);
85
- out.print(`Deleted definition ${secret}; customer-owned AWS resources are unchanged.`, result);
124
+ out.print(`Deleted ${secret} (${result.stopped_sessions?.length ?? 0} session(s) stopped); customer-owned AWS Secrets Manager secrets and IAM roles remain in your AWS account.`, result);
86
125
  return;
87
126
  }
88
127
  if (action === "set" && secret && !extra.length && (bool(p.flags, "stdin") || process.stdin.isTTY)) {
89
128
  const id = await resolve(secret);
90
129
  const result = await c.call("GET", `${base}/${encodeURIComponent(id)}`);
91
130
  if (!result.value_storage_available) {
92
- throw new CliError("secret_storage_unavailable", "Secret value entry is unavailable until encrypted storage lands in WU #231; no value was read or sent.");
131
+ throw new CliError("secret_storage_unavailable", "Secret value entry is unavailable because encrypted storage is not configured on this server; no value was read or sent.");
93
132
  }
94
- // The metadata capability gate above must precede any read/prompt. WU #231 enables this path.
95
- const value = await readSecretValue(bool(p.flags, "stdin"));
96
- await c.call("PUT", `${base}/${encodeURIComponent(id)}/value`, { value });
97
- out.print(`Saved a new value version for ${secret}.`, { ok: true });
133
+ // The metadata capability gate above must precede any read/prompt.
134
+ let value = await readSecretValue(bool(p.flags, "stdin"));
135
+ const drain = bool(p.flags, "drain");
136
+ const saved = await c.call("PUT", `${base}/${encodeURIComponent(id)}/value`, {
137
+ value,
138
+ ...(drain ? { drain_sessions: true } : {}),
139
+ });
140
+ value = "";
141
+ const kmsNote = saved.storage?.kms_key_id
142
+ ? `encrypted with per-account AWS KMS key (${saved.storage.kms_key_id})`
143
+ : "encrypted with per-account AWS KMS key";
144
+ out.print(`Saved encrypted v${saved.version ?? "?"} for ${secret} (${kmsNote}).${drain ? ` Drained ${saved.drained_sessions?.length ?? 0} running session(s).` : ""} Notice: BenignSwarm decrypts hosted secrets in memory during broker delivery to authorized sessions.`, saved);
145
+ return;
146
+ }
147
+ if (action === "audit" && !extra.length) {
148
+ const limit = limitFlag(p);
149
+ const qs = limit !== undefined ? `?limit=${limit}` : "";
150
+ const path = secret
151
+ ? `${base}/${encodeURIComponent(await resolve(secret))}/audit${qs}`
152
+ : `${base}/audit${qs}`;
153
+ const result = await c.call("GET", path);
154
+ const events = result.events ?? [];
155
+ out.print(events.length
156
+ ? table(events.map((e) => ({
157
+ at: e.created_at,
158
+ action: e.action,
159
+ actor: e.actor_id,
160
+ version: e.version ?? "—",
161
+ detail: typeof e.detail === "string" ? e.detail : JSON.stringify(e.detail ?? {}),
162
+ })), ["at", "action", "actor", "version", "detail"])
163
+ : "No secret audit events.", result);
98
164
  return;
99
165
  }
100
- throw new CliError("usage", "project secrets <project> list | show <name> | create <name> --purpose <text> --storage-mode hosted|aws_secrets_manager --units 1,2 --tags api --hosts db.example.com [--arn <exact ARN> --version-id <id>] | update <name> [--purpose <text>] [--units 1,2] [--tags api] [--hosts host[,host]] | rotate <name> --arn <exact ARN> --version-id <id> | revoke <name> | delete <name> | set <name> [--stdin]");
166
+ throw new CliError("usage", "project secrets <project> list | show <name> | audit [<name>] [--limit N] | create <name> --purpose <text> --storage-mode hosted|aws_secrets_manager --units 1,2 --tags api --hosts db.example.com [--arn <exact ARN> --version-id <id>] | update <name> [--purpose <text>] [--units 1,2] [--tags api] [--hosts host[,host]] | rotate <name> (--arn <exact ARN> --version-id <id> | --stdin) [--drain] | revoke <name> | delete <name> | set <name> [--stdin] [--drain]");
101
167
  }
102
168
  function decodeSecretValue(bytes) {
103
169
  try {
@@ -8,7 +8,8 @@ import { describeFinding, describeProbe, evaluateProbe, expectedFor, runSandboxP
8
8
  *
9
9
  * b9s sandbox probe [--checkout <dir>] [--unit-worktree <dir>] [--sibling-checkout <dir>] [--api <host>] [--out <file>] [--nonce <id>] [--harness <h> --sandbox <mode>]
10
10
  * measure, from inside the sandbox: where commands run, which tools are there, what git can
11
- * do, which hosts answer, and what is writable. Records facts and judges nothing.
11
+ * do, which hosts answer, and what is writable. Records facts and judges nothing. By default
12
+ * it prints to stdout; --out must name a writable file (for example inside the checkout).
12
13
  * b9s sandbox check <file> --harness <h> --sandbox <mode>
13
14
  * compare a probe's result with what is expected of that harness and mode; exits 1 on a
14
15
  * difference, naming each one.
package/dist/container.js CHANGED
@@ -975,12 +975,13 @@ export function agentContainerRunArgs(opts) {
975
975
  const hostCache = assertSafeMountPath(join(opts.cacheRootDir, cacheName), "cache", boundaryOpts);
976
976
  args.push("-v", `${hostCache}:/caches/${cacheName}:rw`);
977
977
  }
978
+ const secretEnvKeys = new Set(opts.secretEnvKeys ?? []);
978
979
  for (const [k, v] of Object.entries(opts.extraEnv ?? {})) {
979
980
  if (/^(AWS_|B9S_MACHINE|BSCHAT_MACHINE)/i.test(k))
980
981
  continue;
981
982
  if (SECRET_KEY_RE.test(k) && v.includes("machine.json"))
982
983
  continue;
983
- args.push("-e", `${k}=${v}`);
984
+ args.push("-e", secretEnvKeys.has(k) ? k : `${k}=${v}`);
984
985
  }
985
986
  args.push(opts.imageDigest, ...opts.command);
986
987
  return args;
@@ -989,7 +990,7 @@ export function agentContainerRunArgs(opts) {
989
990
  * Constructs a secret-free host subprocess environment for disposable image builds and
990
991
  * container-runtime client invocations, stripping AWS, harness, GitHub, and machine credentials.
991
992
  */
992
- export function isolatedSubprocessEnv(baseEnv = process.env, extraEnv = {}) {
993
+ export function isolatedSubprocessEnv(baseEnv = process.env, extraEnv = {}, passSecretKeys = []) {
993
994
  const out = {};
994
995
  const allowKeys = ["PATH", "LANG", "LC_ALL", "TERM", "TMPDIR", "XDG_RUNTIME_DIR", "CONTAINER_HOST", "DOCKER_HOST"];
995
996
  for (const key of allowKeys) {
@@ -998,7 +999,7 @@ export function isolatedSubprocessEnv(baseEnv = process.env, extraEnv = {}) {
998
999
  out[key] = v;
999
1000
  }
1000
1001
  for (const [k, v] of Object.entries(extraEnv)) {
1001
- if (!SECRET_KEY_RE.test(k))
1002
+ if (!SECRET_KEY_RE.test(k) || passSecretKeys.includes(k))
1002
1003
  out[k] = v;
1003
1004
  }
1004
1005
  return out;
package/dist/help.js CHANGED
@@ -234,6 +234,8 @@ Machine placement enforces configured session slots and reports machine pressure
234
234
  b9s sandbox probe [--checkout <dir>] [--unit-worktree <dir>] [--sibling-checkout <dir>] [--api <host>] [--out <file>] [--nonce <id>] [--harness <h> --sandbox <mode>]
235
235
  what the sandbox this runs in really allows: where commands run, which tools
236
236
  are there, what git can do, which hosts answer, what is writable; facts only.
237
+ Prints to stdout by default; --out must name a writable file, such as one inside
238
+ the checkout.
237
239
  The harness/mode pair is needed for watcher cleanup on Antigravity workspace-write
238
240
  b9s sandbox check <file> --harness <h> --sandbox <mode>
239
241
  compare a probe result with what is expected of that harness; exits 1 on a difference
@@ -352,13 +354,15 @@ Use --admin <nickname> to select one of this machine's saved operator identities
352
354
  enable only after exact ruleset verification in console and live bypass-change signal check; controls are also in console WU #196
353
355
  b9s-admin project secrets <project> list
354
356
  b9s-admin project secrets <project> show <name>
357
+ b9s-admin project secrets <project> audit [<name>] [--limit n]
355
358
  b9s-admin project secrets <project> create <name> --purpose <text> --storage-mode hosted|aws_secrets_manager --units 1,2 --tags api --hosts host[,host] [--arn <exact ARN> --version-id <id>]
356
359
  b9s-admin project secrets <project> update <name> [--purpose <text>] [--units 1,2] [--tags api] [--hosts host[,host]]
357
- b9s-admin project secrets <project> rotate <name> --arn <exact ARN> --version-id <id>
360
+ b9s-admin project secrets <project> rotate <name> (--arn <exact ARN> --version-id <id> | --stdin) [--drain]
358
361
  b9s-admin project secrets <project> revoke <name>
359
362
  b9s-admin project secrets <project> delete <name>
360
- b9s-admin project secrets <project> set <name> [--stdin]
361
- purpose is trimmed before send (1–200 characters); values remain unavailable until encrypted storage lands in WU #231; set checks before reading input; console control is WU #230
363
+ b9s-admin project secrets <project> set <name> [--stdin] [--drain]
364
+ --hosts stores declared hostnames only; all current machine adapters refuse secret grants until outer egress enforcement exists
365
+ purpose is trimmed before send (1–200 characters); set/rotate check AWS KMS availability before reading a value; no plaintext fallback; console control is WU #230
362
366
  b9s-admin project environment show <project>
363
367
  b9s-admin project environment setup <project> [--catalog family@version] [--assessment-only] [--context text]
364
368
  b9s-admin project environment set <project> --file declaration.json --source-commit <merged-sha>
@@ -446,6 +450,8 @@ Use --admin <nickname> to select one of this machine's saved operator identities
446
450
  b9s-admin explain <key> ask the agent to explain a decision in plain words (the console's Explain)
447
451
  b9s-admin notifier [--agent name|none] [--email yes|no] [--repeat m] [--flow-summary yes|no] [--flow-min-age m] [--flow-min-impact n] how you are reached away from the console, and the last report
448
452
  b9s-admin account [--summary-minutes m] plan, usage and the account summary period
453
+ b9s-admin account secrets-kms status | enable --region <aws-region> [--kms-key <arn-or-id>]
454
+ dedicated per-account KMS key; foreign, shared, or untagged keys are refused
449
455
  assistant stays opt-in: PATCH /account {"assistant_enabled":true|false}; GET /account/usage shows used, allowance, uncertain calls and reset date
450
456
  b9s-admin account-stores migrations show|run [--json] inspect or resume the per-account SQLite schema migration runner (platform admin only)
451
457
  session/admin clients use GET /assistant/conversations/:id/messages for paged history and GET/POST/DELETE /assistant/conversations; POST messages streams data and saves tool notices with assistant messages; old assistant messages have notices_available=false; operator must explicitly apply or discard (see operator skill)
@@ -1,8 +1,8 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import { createHash } from "node:crypto";
3
- import { closeSync, existsSync, mkdirSync, openSync, readdirSync, realpathSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
3
+ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
- import { basename, delimiter, dirname, join } from "node:path";
5
+ import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
6
6
  import { configRoot } from "./config.js";
7
7
  import { CliError } from "./errors.js";
8
8
  import { CLI_VERSION } from "./version.js";
@@ -86,6 +86,96 @@ function createAndRemove(dir, nonce) {
86
86
  unlinkSync(path);
87
87
  });
88
88
  }
89
+ function canonicalIfPresent(path) {
90
+ if (!path)
91
+ return null;
92
+ try {
93
+ return realpathSync(path);
94
+ }
95
+ catch (error) {
96
+ if (error.code === "ENOENT")
97
+ return null;
98
+ throw error;
99
+ }
100
+ }
101
+ /** Identity names written into agent home checkouts and unit worktrees. */
102
+ function identityIdsAt(checkout) {
103
+ for (const path of [join(checkout, ".b9s", "identity.json"), join(checkout, ".bschat", "identity.json")]) {
104
+ let raw;
105
+ try {
106
+ raw = readFileSync(path, "utf8");
107
+ }
108
+ catch (error) {
109
+ if (error.code === "ENOENT")
110
+ continue;
111
+ throw error;
112
+ }
113
+ const identity = JSON.parse(raw);
114
+ if (typeof identity.agent === "string" && identity.agent.trim())
115
+ return [identity.agent.trim()];
116
+ if (!identity.agents || typeof identity.agents !== "object" || Array.isArray(identity.agents))
117
+ return [];
118
+ return Object.values(identity.agents).flatMap((value) => {
119
+ if (!value || typeof value !== "object" || Array.isArray(value))
120
+ return [];
121
+ const entry = value;
122
+ if (typeof entry.name !== "string" || !entry.name.trim())
123
+ return [];
124
+ return [typeof entry.project === "string" && entry.project.trim() ? `${entry.project.trim()}/${entry.name.trim()}` : entry.name.trim()];
125
+ });
126
+ }
127
+ return [];
128
+ }
129
+ /** Resolve a linked-worktree admin entry back to the checkout whose metadata it represents. */
130
+ function linkedCheckout(adminDir) {
131
+ const record = readFileSync(join(adminDir, "gitdir"), "utf8").trim();
132
+ const match = /^(?:gitdir:\s*)?(.+)$/i.exec(record);
133
+ if (!match?.[1])
134
+ throw new Error(`invalid linked-worktree gitdir record at ${adminDir}`);
135
+ const gitFile = realpathSync(isAbsolute(match[1]) ? match[1] : resolve(adminDir, match[1]));
136
+ return realpathSync(dirname(gitFile));
137
+ }
138
+ function otherAgentWorktree(commonDir, currentGitDir, currentCheckout, options, env) {
139
+ const selfPaths = new Set([options.checkout, options.unitWorktree, currentCheckout]
140
+ .map((path) => canonicalIfPresent(path)).filter((path) => path !== null));
141
+ const currentIds = new Set([env.BSCHAT_AGENT, env.B9S_AGENT, ...identityIdsAt(options.checkout ?? currentCheckout)]
142
+ .filter((id) => typeof id === "string" && id.trim().length > 0).map((id) => id.trim()));
143
+ let entries;
144
+ try {
145
+ entries = readdirSync(join(commonDir, "worktrees"), { withFileTypes: true });
146
+ }
147
+ catch (error) {
148
+ if (error.code === "ENOENT")
149
+ return null;
150
+ throw error;
151
+ }
152
+ for (const entry of entries) {
153
+ if (!entry.isDirectory())
154
+ continue;
155
+ const adminDir = join(commonDir, "worktrees", entry.name);
156
+ let checkout;
157
+ try {
158
+ if (realpathSync(adminDir) === currentGitDir)
159
+ continue;
160
+ checkout = linkedCheckout(adminDir);
161
+ }
162
+ catch (error) {
163
+ if (error.code === "ENOENT")
164
+ continue;
165
+ throw error;
166
+ }
167
+ if (selfPaths.has(checkout))
168
+ continue;
169
+ const candidateIds = identityIdsAt(checkout);
170
+ const identityMayBeSame = (currentId, candidateId) => currentId === candidateId
171
+ || (!currentId.includes("/") && candidateId.endsWith(`/${currentId}`))
172
+ || (!candidateId.includes("/") && currentId.endsWith(`/${candidateId}`));
173
+ const isDifferentAgent = (id) => ![...currentIds].some((currentId) => identityMayBeSame(currentId, id));
174
+ if (candidateIds.length > 0 && currentIds.size > 0 && candidateIds.every(isDifferentAgent))
175
+ return { checkout, adminDir };
176
+ }
177
+ return null;
178
+ }
89
179
  async function reach(url, timeoutMs = 10_000) {
90
180
  try {
91
181
  const res = await fetch(url, { method: "GET", signal: AbortSignal.timeout(timeoutMs), redirect: "manual" });
@@ -182,17 +272,25 @@ export async function runSandboxProbe(options) {
182
272
  throw new Error(`added a worktree but could not remove it: ${gone.err}`);
183
273
  }
184
274
  });
185
- checks.git_other_worktree = observe(() => {
186
- const currentGitDir = realpathSync(gitDir);
187
- const entries = readdirSync(join(commonDir, "worktrees"), { withFileTypes: true })
188
- .filter((entry) => entry.isDirectory() && realpathSync(join(commonDir, "worktrees", entry.name)) !== currentGitDir);
189
- const other = entries[0];
190
- if (!other)
191
- throw new Error("no other linked-worktree entry is available to check");
192
- const result = createAndRemove(join(commonDir, "worktrees", other.name), nonce);
193
- if (!result.ok)
194
- throw new Error(result.detail ?? `another worktree entry was refused: ${other.name}`);
195
- });
275
+ let other;
276
+ try {
277
+ other = otherAgentWorktree(commonDir, realpathSync(gitDir), toplevel, options, env);
278
+ }
279
+ catch (error) {
280
+ checks.git_other_worktree = { ok: false, error: true, detail: clip(error.message) };
281
+ other = null;
282
+ }
283
+ if (checks.git_other_worktree === null) {
284
+ if (!other) {
285
+ checks.git_other_worktree = { ok: false, not_applicable: true, detail: "no linked worktree belonging to another agent was found" };
286
+ }
287
+ else {
288
+ const result = createAndRemove(other.adminDir, nonce);
289
+ checks.git_other_worktree = result.ok
290
+ ? { ...result, value: other.checkout }
291
+ : { ...result, detail: clip(`another agent's linked-worktree metadata at ${other.checkout}: ${result.detail ?? "write refused"}`) };
292
+ }
293
+ }
196
294
  const remote = git(["ls-remote", "origin", "HEAD"], 30_000);
197
295
  // Exit 0 is the remote answering; a remote whose HEAD names no branch yet answers with nothing.
198
296
  checks.git_remote_read = remote.status === 0
@@ -264,8 +362,13 @@ export async function runSandboxProbe(options) {
264
362
  };
265
363
  }
266
364
  export function writeProbeResult(path, result) {
267
- mkdirSync(dirname(path), { recursive: true });
268
- writeFileSync(path, `${JSON.stringify(result, null, 2)}\n`, { mode: 0o600 });
365
+ try {
366
+ mkdirSync(dirname(path), { recursive: true });
367
+ writeFileSync(path, `${JSON.stringify(result, null, 2)}\n`, { mode: 0o600 });
368
+ }
369
+ catch (error) {
370
+ throw new CliError("sandbox_probe_output_failed", `cannot write sandbox probe result to ${path}: ${error.message}`, "Choose a writable path inside the checkout, or omit --out to print the result to stdout.");
371
+ }
269
372
  }
270
373
  const ACCEPTED_GIT = "not measured for this harness yet";
271
374
  const UNMEASURED = "not measured for this harness yet";
@@ -277,10 +380,13 @@ const ANTIGRAVITY_GIT_SCOPE = "Antigravity workspace-write policy: Git objects,
277
380
  const ANTIGRAVITY_REF_CLEANUP = "measured 2026-11-20 on Linux Antigravity 1.5.13: branch creation and commit-object writes work, but deleting a ref requires .git/packed-refs.lock under the read-only common Git directory. The watcher removes refs in this probe namespace outside the sandbox after the check; the session does not delete branches";
278
381
  export function expectedFor(harness, sandbox, result) {
279
382
  const works = { expected: "works" };
383
+ const otherWorktree = result?.checks.git_other_worktree?.not_applicable
384
+ ? { expected: "not_applicable", note: result.checks.git_other_worktree.detail }
385
+ : { expected: "refused", note: ANTIGRAVITY_GIT_SCOPE };
280
386
  const base = {
281
387
  cwd_is_checkout: works, origin_is_https: { expected: "any", note: UNMEASURED },
282
388
  tool_node: works, tool_npm: works, tool_npx: works, tool_git: works, tool_b9s: works,
283
- git_branch: works, git_branch_delete: works, git_object: works, git_worktree: works, git_other_worktree: { expected: "any", note: UNMEASURED }, git_remote_read: works,
389
+ git_branch: works, git_branch_delete: works, git_object: works, git_worktree: works, git_other_worktree: result?.checks.git_other_worktree?.not_applicable ? otherWorktree : { expected: "any", note: UNMEASURED }, git_remote_read: works,
284
390
  net_api: works, net_other_host: { expected: "any", note: UNMEASURED },
285
391
  write_checkout: works, write_checkout_parent: works, write_unit_worktree: { expected: "any", note: "requires --unit-worktree" }, write_sibling_checkout: { expected: "any", note: "requires --sibling-checkout" }, git_commit: { expected: "any", note: "requires --unit-worktree" }, git_fetch: { expected: "any", note: "requires --unit-worktree" }, write_b9s_home: works,
286
392
  write_git_config: { expected: "any", note: ACCEPTED_GIT }, write_git_hooks: { expected: "any", note: ACCEPTED_GIT },
@@ -301,7 +407,7 @@ export function expectedFor(harness, sandbox, result) {
301
407
  git_branch_delete: { expected: "refused", note: ANTIGRAVITY_REF_CLEANUP },
302
408
  git_worktree: { expected: "refused", note: ANTIGRAVITY_GIT_SCOPE },
303
409
  write_checkout_parent: { expected: "refused", note: ANTIGRAVITY_GIT_SCOPE },
304
- git_other_worktree: { expected: "refused", note: ANTIGRAVITY_GIT_SCOPE },
410
+ git_other_worktree: otherWorktree,
305
411
  write_git_config: { expected: "refused", note: ANTIGRAVITY_GIT_SCOPE },
306
412
  write_git_hooks: { expected: "refused", note: ANTIGRAVITY_GIT_SCOPE },
307
413
  write_node_install: { expected: "refused" },
@@ -317,7 +423,7 @@ export function expectedFor(harness, sandbox, result) {
317
423
  origin_is_https: { expected: "any", note: CLAUDE_ORIGIN },
318
424
  write_checkout_parent: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
319
425
  git_worktree: { expected: "refused", note: CLAUDE_WORKTREE },
320
- git_other_worktree: { expected: "refused", note: "another agent's linked-worktree Git metadata is outside the active turn's allow-list" },
426
+ git_other_worktree: result?.checks.git_other_worktree?.not_applicable ? otherWorktree : { expected: "refused", note: "another agent's linked-worktree Git metadata is outside the active turn's allow-list" },
321
427
  write_git_config: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
322
428
  write_git_hooks: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
323
429
  write_home: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
@@ -348,14 +454,18 @@ export function evaluateProbe(result, expected) {
348
454
  const seen = result.checks[check];
349
455
  const want = expected[check];
350
456
  const observed = seen === null || seen === undefined ? "not run"
351
- : seen.ok ? "works"
352
- : check === "git_branch_delete" ? seen.refusal === "packed-refs-lock-read-only" ? "refused" : "error"
353
- : "refused";
457
+ : seen.not_applicable ? "not applicable"
458
+ : seen.error ? "error"
459
+ : seen.ok ? "works"
460
+ : check === "git_branch_delete" ? seen.refusal === "packed-refs-lock-read-only" ? "refused" : "error"
461
+ : "refused";
354
462
  const detail = seen?.detail ?? seen?.value;
355
463
  if (want.expected === "any") {
356
464
  unjudged.push({ check, expected: "any", observed, ...(detail ? { detail } : {}), ...(want.note ? { note: want.note } : {}) });
357
465
  continue;
358
466
  }
467
+ if (want.expected === "not_applicable" && observed === "not applicable")
468
+ continue;
359
469
  if (observed !== want.expected)
360
470
  failures.push({ check, expected: want.expected, observed, ...(detail ? { detail } : {}) });
361
471
  }
@@ -372,15 +482,15 @@ const LABEL = {
372
482
  write_home: "the home folder is writable", write_node_install: "the Node installation is writable",
373
483
  };
374
484
  export function describeFinding(f) {
375
- const want = f.expected === "works" ? "should work" : "should be refused";
376
- const got = f.observed === "works" ? "it works" : f.observed === "refused" ? "it is refused" : f.observed === "error" ? "the check failed" : "the check could not run";
485
+ const want = f.expected === "works" ? "should work" : f.expected === "refused" ? "should be refused" : f.expected === "not_applicable" ? "should not apply" : "has no expected outcome";
486
+ const got = f.observed === "works" ? "it works" : f.observed === "refused" ? "it is refused" : f.observed === "error" ? "the check failed" : f.observed === "not applicable" ? "it is not applicable" : "the check could not run";
377
487
  return `${LABEL[f.check]}: ${want}, but ${got}${f.detail ? ` (${f.detail})` : ""}`;
378
488
  }
379
489
  export function describeProbe(result) {
380
490
  const lines = [`sandbox probe ${result.nonce} at ${result.at} (b9s ${result.cli_version}, ${result.platform})`, ` ran in ${result.cwd}${result.checkout ? `; expected ${result.checkout}` : ""}`];
381
491
  for (const check of PROBE_CHECKS) {
382
492
  const seen = result.checks[check];
383
- const state = seen === null ? "not run" : seen.ok ? "yes" : seen.refusal ? "refused" : "no";
493
+ const state = seen === null ? "not run" : seen.not_applicable ? "not applicable" : seen.error ? "error" : seen.ok ? "yes" : seen.refusal ? "refused" : "no";
384
494
  lines.push(` ${state.padEnd(7)} ${LABEL[check]}${seen?.detail ? ` (${seen.detail})` : seen?.value ? ` (${seen.value})` : ""}`);
385
495
  }
386
496
  return lines.join("\n");
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.138";
1
+ export const CLI_VERSION = "0.12.139";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.138",
3
+ "version": "0.12.139",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {