benignswarm 0.12.137 → 0.12.138

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
@@ -22,7 +22,7 @@ export const STRING_FLAGS = [
22
22
  "require-evidence", "default-approver", "merged-by", "integrator-role", "require-rebased", "require-merge-commit",
23
23
  "require-pushed", "require-gate-receipt", "quiet", "summary", "meaning", "expert-role", "reviews", "works", "trials", "email",
24
24
  "repeat", "summary-minutes", "churn", "unmet", "require-cited-changes", "checks-every", "propose", "waits-on",
25
- "flow-summary", "flow-min-age", "flow-min-impact", "checkout", "api", "nonce",
25
+ "flow-summary", "flow-min-age", "flow-min-impact", "checkout", "unit-worktree", "sibling-checkout", "api", "nonce",
26
26
  "sandbox", "thread", "turn-timeout", "turns-per-hour", "unproductive-per-hour", "turn-coalesce-seconds", "session", "operation",
27
27
  "plain", "if-yes", "if-no", "ssh", "variant", "count", "min", "max", "needs", "min-ram", "exclude", "carry", "from",
28
28
  "to-ssh", "ssh-from", "wait", "writable", "writable-root", "dsh", "agy", "for", "until", "reason", "at", "requires",
@@ -370,7 +370,7 @@ export async function machineAdmin(action, rest, p, out) {
370
370
  if (action === "label" || action === "slots") {
371
371
  const name = rest[0];
372
372
  if (!name)
373
- throw new CliError("usage", "machine label <name> <label...> [--remove a,b] | machine slots <name> <n | auto>");
373
+ throw new CliError("usage", "machine label <name> <label...> [--remove a,b] [--preview | --impact-revision <revision>] | machine slots <name> <n | auto> [--preview | --impact-revision <revision>]");
374
374
  const cur = (await c.call("GET", `/machines/${name}`)).machine;
375
375
  let body;
376
376
  if (action === "label") {
@@ -382,9 +382,26 @@ export async function machineAdmin(action, rest, p, out) {
382
382
  throw new CliError("usage", "machine slots <name> <n | auto> (auto: one per 4 GB of RAM)");
383
383
  body = { slots: rest[1] === "auto" ? null : Number(rest[1]) };
384
384
  }
385
+ const suppliedRevision = str(p.flags, "impact-revision");
386
+ if (bool(p.flags, "preview") && suppliedRevision !== undefined)
387
+ throw new CliError("usage", "use either --preview or --impact-revision, not both");
388
+ const { impact } = await c.call("POST", `/machines/${encodeURIComponent(name)}/settings-impact`, body);
389
+ if (!impact || typeof impact.source_revision !== "string")
390
+ throw new CliError("invalid_response", "machine settings preview did not include a source revision");
391
+ const impactText = [
392
+ `${name}: ${action} placement preview (${impact.source_revision})`,
393
+ ` labels: ${impact.after.labels.join(", ") || "(none)"}; slots: ${impact.after.slots ?? "automatic"}`,
394
+ ...impact.placements.map((move) => ` ${move.project}/${move.pool}/${move.slot}: ${move.from ?? "unplaced"} → ${move.to ?? `unplaced (${move.reason ?? "no eligible machine"})`}`),
395
+ `Review this impact, then repeat the command with --impact-revision ${impact.source_revision}.`,
396
+ ].join("\n");
397
+ if (bool(p.flags, "preview") || suppliedRevision === undefined)
398
+ return out.print(impactText, { impact });
399
+ if (suppliedRevision !== impact.source_revision)
400
+ throw new CliError("stale_preview", `machine settings impact changed since revision ${suppliedRevision}; nothing was changed; review the new preview with --preview`);
401
+ body.source_revision = impact.source_revision;
385
402
  const r = await c.call("PATCH", `/machines/${name}`, body);
386
403
  const kept = keptInPlace(((await c.call("GET", "/pools")).pools ?? []));
387
- return out.print([`${name}: labels ${r.machine.labels.join(", ") || "(none)"}; slots ${r.machine.slots ?? "auto"}. Pools were re-placed: b9s-admin pool list`, ...keptWarningLines(kept)].join("\n"), { ...r, kept_in_place: kept });
404
+ return out.print([`${name}: labels ${r.machine.labels.join(", ") || "(none)"}; slots ${r.machine.slots ?? "auto"}. Pools were re-placed: b9s-admin pool list`, ...keptWarningLines(kept)].join("\n"), { ...r, impact, kept_in_place: kept });
388
405
  }
389
406
  if (action === "readiness") {
390
407
  const name = rest[0];
@@ -69,8 +69,9 @@ function writeMachineState(s) {
69
69
  * again once with them. 2: the agent's own worktree git folder is writable under workspace-write.
70
70
  * 3: turns get TMPDIR beside the checkout instead of the system's /tmp.
71
71
  * 11: Antigravity's linked-worktree Git permissions are narrowed to required data paths.
72
+ * 12: Claude Code workspace-write roots name only the checkout, active unit worktree, narrowed Git metadata, config and caches.
72
73
  */
73
- const START_REV = 11;
74
+ const START_REV = 12;
74
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
76
  /** A server thread update must restart the watcher even if a stored fingerprint is unexpectedly stale. */
76
77
  export function sessionConfigChanged(s, local, fingerprint) {
@@ -6,7 +6,7 @@ import { describeFinding, describeProbe, evaluateProbe, expectedFor, runSandboxP
6
6
  /**
7
7
  * What the sandbox this command runs in really allows.
8
8
  *
9
- * b9s sandbox probe [--checkout <dir>] [--api <host>] [--out <file>] [--nonce <id>] [--harness <h> --sandbox <mode>]
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
11
  * do, which hosts answer, and what is writable. Records facts and judges nothing.
12
12
  * b9s sandbox check <file> --harness <h> --sandbox <mode>
@@ -24,7 +24,7 @@ export async function sandbox(p, out) {
24
24
  const mode = str(p.flags, "sandbox");
25
25
  if ((harness === undefined) !== (mode === undefined) || harness === "" || mode === "")
26
26
  throw new CliError("usage", "sandbox probe --harness and --sandbox must be provided together");
27
- const result = await runSandboxProbe({ nonce, checkout: str(p.flags, "checkout"), apiHost: str(p.flags, "api"), ...(harness !== undefined && mode !== undefined ? { harness, sandbox: mode } : {}) });
27
+ const result = await runSandboxProbe({ nonce, checkout: str(p.flags, "checkout"), unitWorktree: str(p.flags, "unit-worktree"), siblingCheckout: str(p.flags, "sibling-checkout"), apiHost: str(p.flags, "api"), ...(harness !== undefined && mode !== undefined ? { harness, sandbox: mode } : {}) });
28
28
  const file = str(p.flags, "out");
29
29
  if (file)
30
30
  writeProbeResult(file, result);
@@ -46,7 +46,7 @@ export async function sandbox(p, out) {
46
46
  }
47
47
  if (result?.schema !== 1 || !result.checks)
48
48
  throw new CliError("probe_unreadable", `${file} is not a sandbox probe result`);
49
- const verdict = evaluateProbe(result, expectedFor(harness, mode));
49
+ const verdict = evaluateProbe(result, expectedFor(harness, mode, result));
50
50
  const lines = verdict.ok
51
51
  ? [`sandbox as expected for ${harness} ${mode} (${verdict.unjudged.length} recorded without a verdict)`]
52
52
  : [`sandbox differs from what is expected for ${harness} ${mode}:`, ...verdict.failures.map((f) => ` - ${describeFinding(f)}`)];
@@ -55,5 +55,5 @@ export async function sandbox(p, out) {
55
55
  throw new CliError("sandbox_differs", `${verdict.failures.length} sandbox check${verdict.failures.length === 1 ? "" : "s"} differ from what is expected`);
56
56
  return;
57
57
  }
58
- throw new CliError("usage", "sandbox probe [--checkout <dir>] [--api <host>] [--out <file>] [--nonce <id>] [--harness <h> --sandbox <mode>] | sandbox check <file> --harness <h> --sandbox <mode>");
58
+ throw new CliError("usage", "sandbox probe [--checkout <dir>] [--unit-worktree <dir>] [--sibling-checkout <dir>] [--api <host>] [--out <file>] [--nonce <id>] [--harness <h> --sandbox <mode>] | sandbox check <file> --harness <h> --sandbox <mode>");
59
59
  }
@@ -759,6 +759,9 @@ export async function wakeOnce(name, exec, unackedAfter, followDelay, log, model
759
759
  let preparedWorktree = null;
760
760
  if (turnSink && bindingToPrepare) {
761
761
  preparedWorktree = await (dependencies.prepareWorktree ?? prepareTurnWorktree)(name, bindingToPrepare);
762
+ if (!preparedWorktree && dependencies.claudeRuntime?.sandbox === "workspace-write") {
763
+ throw new CliError("unit_worktree_missing", `Claude Code workspace-write cannot start WU #${bindingToPrepare.work_unit_number}: the watcher did not prepare its unit worktree`);
764
+ }
762
765
  if (preparedWorktree) {
763
766
  wakePrefix.push(preparedWorktree.status === "assigned"
764
767
  ? `The watcher prepared WU #${preparedWorktree.number}'s worktree at ${preparedWorktree.path}. Run b9s wu start ${preparedWorktree.number} from this checkout to record the start, then work in that path.`
@@ -780,8 +783,7 @@ export async function wakeOnce(name, exec, unackedAfter, followDelay, log, model
780
783
  turnCwd = preparedWorktree?.path ?? process.cwd();
781
784
  if (turnSink && dependencies.claudeRuntime && turnExec?.includes(CLAUDE_SETTINGS_PLACEHOLDER)) {
782
785
  const runtime = dependencies.claudeRuntime;
783
- const cwd = turnCwd ?? process.cwd();
784
- const args = claudeSettings(runtime.sandbox, model, runtime.effort, cwd, configRoot(), runtime.writableRoots);
786
+ const args = claudeSettings(runtime.sandbox, model, runtime.effort, process.cwd(), configRoot(), runtime.writableRoots, preparedWorktree ?? undefined);
785
787
  turnExec = turnExec.replace(CLAUDE_SETTINGS_PLACEHOLDER, args.map(shellQuote).join(" "));
786
788
  }
787
789
  if (turnSink && dependencies.antigravityRuntime && turnExec?.includes(ANTIGRAVITY_SETTINGS_PLACEHOLDER)) {
package/dist/harnesses.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { accessSync, constants, existsSync, readFileSync, readdirSync, statSync } from "node:fs";
2
+ import { accessSync, constants, existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
- import { dirname, join } from "node:path";
4
+ import { basename, dirname, join, resolve } from "node:path";
5
5
  import { CliError } from "./errors.js";
6
6
  import { configRoot } from "./config.js";
7
+ import { gitSandboxWritablePaths } from "./git-sandbox-paths.js";
7
8
  import { readState, updateState } from "./state.js";
8
9
  import { codexArchivedRollout, codexRollout } from "./sessions.js";
9
10
  import { readTurnPhase, usageLimitUntil } from "./turn.js";
@@ -579,19 +580,54 @@ function claudeProbe(session, ref) {
579
580
  * The Claude Code flags a headless turn runs with. Claude Code's sandbox always lets the agent write
580
581
  * its working folder, so read-only cannot be honoured and is refused. workspace-write is its sandbox
581
582
  * (refusing to start when the sandbox is unavailable, never running a command outside it), every
582
- * domain reachable as with Codex, edits allowed in the checkout and the folders `wu start` and bschat
583
- * write (the checkout's parent, ~/.b9s) plus the machine's writable folders; anything that would
584
- * need a prompt is denied, since nobody can answer one. danger-full-access skips permissions.
583
+ * domain reachable as with Codex, edits allowed in the agent's checkout, its active unit worktree,
584
+ * the Git metadata those checkouts need, b9s's config root, and the machine's writable folders;
585
+ * anything that would need a prompt is denied, since nobody can answer one. danger-full-access skips
586
+ * permissions.
585
587
  */
586
- export function claudeSettings(sandbox, model, effort, cwd, bschatHome, extraWritable = []) {
588
+ export function claudeSettings(sandbox, model, effort, checkoutRoot, bschatHome, extraWritable = [], unitWorktree) {
587
589
  const common = [...(model ? ["--model", model] : []), ...(effort ? ["--effort", effort] : [])];
588
590
  if (sandbox === "danger-full-access")
589
591
  return [...common, "--permission-mode", "bypassPermissions"];
590
592
  if (sandbox === "read-only")
591
- throw new CliError("unsupported", "Claude Code has no read-only sandbox: its sandbox always lets the agent write its working folder. Use workspace-write (sandboxed; writes limited to the checkout, its unit worktrees, ~/.b9s and the machine's writable folders) or danger-full-access");
593
+ throw new CliError("unsupported", "Claude Code has no read-only sandbox: its sandbox always lets the agent write its working folder. Use workspace-write (sandboxed; writes limited to the checkout, the active unit worktree, required Git metadata, b9s config and machine writable folders) or danger-full-access");
592
594
  if (sandbox !== "workspace-write")
593
595
  throw new CliError("usage", `unknown sandbox ${sandbox}`);
594
- const dirs = [dirname(cwd), bschatHome, ...extraWritable];
596
+ const requiredDirectory = (label, value) => {
597
+ let resolved;
598
+ try {
599
+ resolved = realpathSync(resolve(value));
600
+ if (!statSync(resolved).isDirectory())
601
+ throw new Error("not a directory");
602
+ }
603
+ catch {
604
+ throw new CliError("sandbox_path_missing", `Claude Code workspace-write cannot start: ${label} directory ${value} is missing or is not a directory`);
605
+ }
606
+ return resolved;
607
+ };
608
+ const checkout = requiredDirectory("agent checkout", checkoutRoot);
609
+ const directories = [checkout];
610
+ const files = [];
611
+ if (unitWorktree)
612
+ directories.push(requiredDirectory(`WU #${unitWorktree.number} worktree`, unitWorktree.path));
613
+ // Shared Git path discovery is also used by Antigravity. Add directories as roots and files
614
+ // only to allowWrite; the common .git root, hooks/config and unassigned worktree metadata stay out.
615
+ const exactGitFiles = new Set(["FETCH_HEAD", "FETCH_HEAD.lock", "packed-refs", "packed-refs.lock", "HEAD", "HEAD.lock", "index", "index.lock", "COMMIT_EDITMSG"]);
616
+ // The checkout and prepared worktree can be separate clones on a machine. Compute each Git
617
+ // metadata allowlist independently, then deduplicate; neither is allowed to widen the other.
618
+ const gitPaths = [
619
+ ...gitSandboxWritablePaths(checkout),
620
+ ...(unitWorktree ? gitSandboxWritablePaths(unitWorktree.path) : []),
621
+ ];
622
+ const gitFiles = gitPaths.filter((path) => exactGitFiles.has(basename(path)));
623
+ directories.push(...gitPaths.filter((path) => !exactGitFiles.has(basename(path))));
624
+ files.push(...gitFiles);
625
+ // A first-time `b9s start --token` computes settings before enrollment creates this exact folder.
626
+ // It is safe to allow the path before creation; never replace it with its parent.
627
+ directories.push(existsSync(bschatHome) ? requiredDirectory("b9s config", bschatHome) : resolve(bschatHome));
628
+ directories.push(...extraWritable.map((path) => resolve(path)));
629
+ const dirs = [...new Set(directories)];
630
+ const writable = [...new Set([...dirs, ...files])];
595
631
  const settings = {
596
632
  env: claudeSandboxEnv(sandbox),
597
633
  sandbox: {
@@ -599,7 +635,7 @@ export function claudeSettings(sandbox, model, effort, cwd, bschatHome, extraWri
599
635
  failIfUnavailable: true,
600
636
  autoAllowBashIfSandboxed: true,
601
637
  allowUnsandboxedCommands: false,
602
- filesystem: { allowWrite: dirs },
638
+ filesystem: { allowWrite: writable },
603
639
  network: { allowedDomains: ["*", "api.benignswarm.org"] },
604
640
  },
605
641
  };
package/dist/help.js CHANGED
@@ -231,7 +231,7 @@ Machine placement enforces configured session slots and reports machine pressure
231
231
  restart the machine daemon first, then watchers in batches of 5 with 5 s between batches
232
232
  b9s install [<version> | --latest] [--no-restart] make or upgrade this machine's one b9s (join does it once), repair PATH aliases,
233
233
  restart the machine daemon first, then watchers in batches of 5 with 5 s between batches
234
- b9s sandbox probe [--checkout <dir>] [--api <host>] [--out <file>] [--nonce <id>] [--harness <h> --sandbox <mode>]
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
237
  The harness/mode pair is needed for watcher cleanup on Antigravity workspace-write
@@ -491,9 +491,9 @@ Machines (provisioned over your own ssh; a daemon on each runs the agent session
491
491
  transfers thread/note plus local agent state over SSH,
492
492
  refuses newer destination state and avoids duplicate Codex hooks under managed policy,
493
493
  then commits the session only after handoff succeeds; work left on the source requires both flags
494
- b9s-admin machine label <name> <label...> [--remove a,b] what cannot be measured (lab-lan, builds); pools' --needs match it
494
+ b9s-admin machine label <name> <label...> [--remove a,b] [--preview | --impact-revision <revision>] preview affected pool placement, then confirm with its revision
495
495
  b9s-admin machine headroom [name] latest resource headroom, freshness, session ceiling and reservations (console WU #118)
496
- b9s-admin machine slots <name> <n | auto> how many sessions it takes (auto: one per 4 GB of RAM)
496
+ b9s-admin machine slots <name> <n | auto> [--preview | --impact-revision <revision>] preview affected pool placement, then confirm with its revision
497
497
  b9s-admin machine writable <name> <path...> | none folders workspace-write agents there may also write (~/.cargo, ~/.ester)
498
498
  b9s-admin machine workdir <name> <path | default> where its daemon clones projects for pool sessions (default ~/bschat)
499
499
  b9s-admin machine cache-budget <name> [<GB> | default] [--floor <pct | default>] per-cache budget (default 40 GB) and volume free-space floor (default 15%)
@@ -12,7 +12,7 @@ export const PROBE_CHECKS = [
12
12
  "tool_node", "tool_npm", "tool_npx", "tool_git", "tool_b9s",
13
13
  "git_branch", "git_branch_delete", "git_object", "git_worktree", "git_other_worktree", "git_remote_read",
14
14
  "net_api", "net_other_host",
15
- "write_checkout", "write_checkout_parent", "write_b9s_home",
15
+ "write_checkout", "write_checkout_parent", "write_unit_worktree", "write_sibling_checkout", "git_commit", "git_fetch", "write_b9s_home",
16
16
  "write_git_config", "write_git_hooks", "write_home", "write_node_install",
17
17
  ];
18
18
  const clip = (text) => text.trim().replace(/\s+/g, " ").slice(0, 300);
@@ -110,10 +110,11 @@ export async function runSandboxProbe(options) {
110
110
  const originConfigured = read(["config", "--get", "remote.origin.url"]);
111
111
  const originEffective = read(["remote", "get-url", "origin"]);
112
112
  const checks = Object.fromEntries(PROBE_CHECKS.map((id) => [id, null]));
113
- checks.cwd_is_checkout = options.checkout
114
- ? cwd === options.checkout && toplevel === options.checkout
113
+ const expectedWorkingTree = options.unitWorktree ?? options.checkout;
114
+ checks.cwd_is_checkout = expectedWorkingTree
115
+ ? cwd === expectedWorkingTree && toplevel === expectedWorkingTree
115
116
  ? { ok: true, value: cwd }
116
- : { ok: false, value: cwd, detail: clip(`expected ${options.checkout}; the repository here is ${toplevel ?? "none"}`) }
117
+ : { ok: false, value: cwd, detail: clip(`expected ${expectedWorkingTree}; the repository here is ${toplevel ?? "none"}`) }
117
118
  : null;
118
119
  checks.origin_is_https = originEffective === null
119
120
  ? { ok: false, detail: "no origin remote is readable here" }
@@ -197,9 +198,52 @@ export async function runSandboxProbe(options) {
197
198
  checks.git_remote_read = remote.status === 0
198
199
  ? { ok: true }
199
200
  : { ok: false, detail: clip(remote.err || `git ls-remote origin exited ${remote.status ?? "without a status"}`) };
200
- checks.write_checkout = createAndRemove(toplevel, nonce);
201
- checks.write_checkout_parent = createAndRemove(dirname(toplevel), nonce);
201
+ checks.write_checkout = createAndRemove(options.checkout ?? toplevel, nonce);
202
+ checks.write_checkout_parent = createAndRemove(dirname(options.checkout ?? toplevel), nonce);
202
203
  }
204
+ if (options.unitWorktree) {
205
+ const unitWorktree = options.unitWorktree;
206
+ checks.write_unit_worktree = createAndRemove(unitWorktree, nonce);
207
+ const commitFile = join(unitWorktree, `.b9s-probe-commit-${nonce}`);
208
+ const indexFile = join(unitWorktree, `.b9s-probe-index-${nonce}`);
209
+ checks.git_commit = observe(() => {
210
+ const original = run("git", ["rev-parse", "HEAD"], unitWorktree, env);
211
+ if (original.status !== 0 || !original.out)
212
+ throw new Error(original.err || "cannot read unit worktree HEAD");
213
+ const oldHead = original.out;
214
+ writeFileSync(commitFile, `b9s sandbox probe ${nonce}\n`, { flag: "wx" });
215
+ const gitEnv = { ...env, GIT_INDEX_FILE: indexFile };
216
+ const readTree = run("git", ["read-tree", "HEAD"], unitWorktree, gitEnv);
217
+ if (readTree.status !== 0)
218
+ throw new Error(readTree.err || "git read-tree failed");
219
+ const add = run("git", ["add", "--", `.b9s-probe-commit-${nonce}`], unitWorktree, gitEnv);
220
+ if (add.status !== 0)
221
+ throw new Error(add.err || "git add failed");
222
+ const commit = run("git", ["-c", "user.name=b9s sandbox probe", "-c", "user.email=probe@invalid", "commit", "--no-verify", "-m", `b9s sandbox probe ${nonce}`], unitWorktree, gitEnv);
223
+ if (commit.status !== 0)
224
+ throw new Error(commit.err || "git commit failed");
225
+ const committedHead = run("git", ["rev-parse", "HEAD"], unitWorktree, env);
226
+ if (committedHead.status !== 0 || !committedHead.out || committedHead.out === oldHead)
227
+ throw new Error("git commit returned without advancing HEAD");
228
+ const restore = run("git", ["update-ref", "HEAD", oldHead, committedHead.out], unitWorktree, env);
229
+ if (restore.status !== 0)
230
+ throw new Error(`probe commit ${committedHead.out} was created but HEAD could not be restored: ${restore.err}`);
231
+ return `created and removed probe commit ${committedHead.out.slice(0, 12)}`;
232
+ });
233
+ // The alternate index leaves the agent's staged and unstaged work untouched; HEAD is
234
+ // compare-and-swap restored after the successful temporary commit.
235
+ rmSync(commitFile, { force: true });
236
+ rmSync(indexFile, { force: true });
237
+ rmSync(`${indexFile}.lock`, { force: true });
238
+ const fetched = run("git", ["fetch", "--no-tags", "origin", "HEAD"], unitWorktree, env, 60_000);
239
+ checks.git_fetch = fetched.status === 0 ? { ok: true } : { ok: false, detail: clip(fetched.err || `git fetch exited ${fetched.status ?? "without a status"}`) };
240
+ }
241
+ else {
242
+ checks.write_unit_worktree = null;
243
+ checks.git_commit = null;
244
+ checks.git_fetch = null;
245
+ }
246
+ checks.write_sibling_checkout = options.siblingCheckout ? createAndRemove(options.siblingCheckout, nonce) : null;
203
247
  if (commonDir) {
204
248
  // Opened for appending and closed: shows whether it could be changed without changing it.
205
249
  checks.write_git_config = observe(() => { closeSync(openSync(join(commonDir, "config"), "a")); });
@@ -214,7 +258,7 @@ export async function runSandboxProbe(options) {
214
258
  checks.net_other_host = await reach(`https://${options.otherHost ?? "example.com"}/`);
215
259
  return {
216
260
  schema: 1, nonce, at: new Date().toISOString(), cli_version: CLI_VERSION, platform: process.platform,
217
- cwd, checkout: options.checkout ?? null,
261
+ cwd, checkout: options.checkout ?? null, unit_worktree: options.unitWorktree ?? null, sibling_checkout: options.siblingCheckout ?? null,
218
262
  git: { toplevel, git_dir: gitDir, common_dir: commonDir, origin_configured: originConfigured?.replace(/\/\/[^@/]*@/, "//") ?? null, origin_effective: originEffective?.replace(/\/\/[^@/]*@/, "//") ?? null },
219
263
  checks,
220
264
  };
@@ -223,21 +267,22 @@ export function writeProbeResult(path, result) {
223
267
  mkdirSync(dirname(path), { recursive: true });
224
268
  writeFileSync(path, `${JSON.stringify(result, null, 2)}\n`, { mode: 0o600 });
225
269
  }
226
- const ACCEPTED_GIT = "accepted limit (2026-11-19): the clone's shared git folder is writable under the checkout's parent; see docs/REMOTE-MACHINES.md";
270
+ const ACCEPTED_GIT = "not measured for this harness yet";
227
271
  const UNMEASURED = "not measured for this harness yet";
228
272
  const CODEX_WORKSPACE_WRITE = "measured 2026-11-19 in Codex workspace-write: writes to the user's home and the Node installation are refused";
229
273
  const CLAUDE_WORKTREE = "measured 2026-11-19 in Claude Code workspace-write: git worktree add is refused because the clone's shared .git/worktrees folder is read-only; the watcher must prepare unit worktrees outside the sandbox";
230
- const CLAUDE_WORKSPACE_WRITE = "measured 2026-11-19 in Claude Code workspace-write: writes to the user's home, Node installation, shared git config and hooks are refused";
274
+ const CLAUDE_WORKSPACE_WRITE = "measured 2026-11-19 in Claude Code workspace-write: writes to the user's home, Node installation, checkout parent, shared git config and hooks are refused";
275
+ const CLAUDE_ORIGIN = "origin transport is machine-specific; git remote read and active-worktree fetch are measured independently";
231
276
  const ANTIGRAVITY_GIT_SCOPE = "Antigravity workspace-write policy: Git objects, refs and logs plus exact active/prepared worktree metadata are writable; arbitrary git worktree add is refused because only exact paths or recursive directories are supported, and recursive registry access would expose siblings. The watcher prepares the unit worktree before the turn; config, hooks, sibling worktrees and the checkout parent stay refused";
232
277
  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";
233
- export function expectedFor(harness, sandbox) {
278
+ export function expectedFor(harness, sandbox, result) {
234
279
  const works = { expected: "works" };
235
280
  const base = {
236
281
  cwd_is_checkout: works, origin_is_https: { expected: "any", note: UNMEASURED },
237
282
  tool_node: works, tool_npm: works, tool_npx: works, tool_git: works, tool_b9s: works,
238
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,
239
284
  net_api: works, net_other_host: { expected: "any", note: UNMEASURED },
240
- write_checkout: works, write_checkout_parent: works, write_b9s_home: works,
285
+ 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,
241
286
  write_git_config: { expected: "any", note: ACCEPTED_GIT }, write_git_hooks: { expected: "any", note: ACCEPTED_GIT },
242
287
  write_home: { expected: "any", note: UNMEASURED }, write_node_install: { expected: "any", note: UNMEASURED },
243
288
  };
@@ -263,18 +308,26 @@ export function expectedFor(harness, sandbox) {
263
308
  };
264
309
  }
265
310
  if (harness === "claude-code") {
266
- // Its sandbox proxies HTTP(S) only, so an SSH origin cannot be reached (the reason b9s start
267
- // rewrites it per worktree). On 2026-11-19 workspace-write also refused writes to home, the
311
+ // Origin transport is machine-specific; require the actual remote read below rather than
312
+ // requiring HTTPS. On 2026-11-20, ronald's real SSH origin was readable and fetchable in the
313
+ // live Claude Code workspace-write turn. Workspace-write also refuses writes to home, the
268
314
  // Node installation, shared git config/hooks, and git worktree registration.
269
315
  return {
270
316
  ...base,
271
- origin_is_https: works,
317
+ origin_is_https: { expected: "any", note: CLAUDE_ORIGIN },
318
+ write_checkout_parent: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
272
319
  git_worktree: { expected: "refused", note: CLAUDE_WORKTREE },
273
- git_other_worktree: { expected: "any", 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" },
274
321
  write_git_config: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
275
322
  write_git_hooks: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
276
323
  write_home: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
277
324
  write_node_install: { expected: "refused", note: CLAUDE_WORKSPACE_WRITE },
325
+ ...(result?.unit_worktree ? {
326
+ write_unit_worktree: { expected: "works", note: "the prepared active unit worktree is explicitly allow-listed" },
327
+ git_commit: { expected: "works", note: "the probe creates a temporary commit and restores HEAD" },
328
+ git_fetch: { expected: "works", note: "fetch writes shared Git objects, refs/logs, and FETCH_HEAD" },
329
+ } : {}),
330
+ ...(result?.sibling_checkout ? { write_sibling_checkout: { expected: "refused", note: "sibling checkouts are outside the active turn's allow-list" } } : {}),
278
331
  };
279
332
  }
280
333
  if (harness === "codex")
@@ -309,12 +362,12 @@ export function evaluateProbe(result, expected) {
309
362
  return { ok: failures.length === 0, failures, unjudged };
310
363
  }
311
364
  const LABEL = {
312
- cwd_is_checkout: "commands run in the agent's checkout",
365
+ cwd_is_checkout: "commands run in the checkout or active unit worktree",
313
366
  origin_is_https: "origin is reached over HTTPS",
314
367
  tool_node: "node runs", tool_npm: "npm runs", tool_npx: "npx runs", tool_git: "git runs", tool_b9s: "b9s is on PATH",
315
368
  git_branch: "git can create a probe branch", git_branch_delete: "git can delete a branch from inside the session", git_object: "git can write a commit object", git_worktree: "git can add its reserved sandbox probe worktree", git_other_worktree: "another agent's Git worktree metadata is writable", git_remote_read: "git can read origin",
316
369
  net_api: "the BenignSwarm API is reachable", net_other_host: "a host outside the allow-list is reachable",
317
- write_checkout: "the checkout is writable", write_checkout_parent: "the checkout's parent is writable", write_b9s_home: "b9s's own folder is writable",
370
+ write_checkout: "the checkout is writable", write_checkout_parent: "the checkout's parent is writable", write_unit_worktree: "the active unit worktree is writable", write_sibling_checkout: "a sibling checkout is writable", git_commit: "git commit works in the active unit worktree", git_fetch: "git fetch works in the active unit worktree", write_b9s_home: "b9s's own folder is writable",
318
371
  write_git_config: "the clone's git config is writable", write_git_hooks: "the clone's git hooks are writable",
319
372
  write_home: "the home folder is writable", write_node_install: "the Node installation is writable",
320
373
  };
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.137";
1
+ export const CLI_VERSION = "0.12.138";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.137",
3
+ "version": "0.12.138",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {