benignswarm 0.12.151 → 0.12.152

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/git.js CHANGED
@@ -641,7 +641,22 @@ export function findRemoteCommitBranch(sha, localBranch, cwd = process.cwd(), re
641
641
  }
642
642
  // Check ancestry against the advertised object ID, not a mutable tracking ref. A concurrent
643
643
  // fetch can move that ref between checking its tip and asking Git about containment.
644
- const branches = [...advertisedTips].filter(([branch, tip]) => branch !== `${remote}/HEAD` && remoteTrackingRefContainsCommit(branch, tip, sha, cwd)).map(([branch]) => branch).sort();
644
+ // The unit's own branch first: it is nearly always the one, and checking it costs two git calls.
645
+ const ownTip = advertisedTips.get(checkedRef);
646
+ if (ownTip && remoteTrackingRefContainsCommit(checkedRef, ownTip, sha, cwd)) {
647
+ return { remoteBranch: checkedRef, advertisedTip: ownTip, checkedRef, checked: true, reason: null };
648
+ }
649
+ // Otherwise ask Git once which remote-tracking refs contain the commit, then verify only those
650
+ // against their advertised tips. Checking every advertised branch one by one ran 1,542 git
651
+ // processes for 771 branches (238 s on 2026-11-21), long enough for the API connection opened
652
+ // before it to go stale, so wu submit failed with "fetch failed".
653
+ const containing = spawnSync("git", ["for-each-ref", "--contains", sha, "--format=%(refname:short)", `refs/remotes/${remote}/`], { cwd, encoding: "utf8", timeout: 60_000 });
654
+ if (containing.status !== 0) {
655
+ const detail = (containing.stderr || containing.stdout || `git for-each-ref exited with status ${containing.status ?? "unknown"}`).trim();
656
+ return { remoteBranch: null, advertisedTip: null, checkedRef, checked: false, reason: `git for-each-ref --contains ${sha} failed: ${detail}` };
657
+ }
658
+ const candidates = new Set(containing.stdout.split("\n").map((line) => line.trim()).filter(Boolean));
659
+ const branches = [...advertisedTips].filter(([branch, tip]) => branch !== `${remote}/HEAD` && candidates.has(branch) && remoteTrackingRefContainsCommit(branch, tip, sha, cwd)).map(([branch]) => branch).sort();
645
660
  const remoteBranch = branches.includes(checkedRef) ? checkedRef : branches[0] ?? null;
646
661
  return remoteBranch
647
662
  ? { remoteBranch, advertisedTip: advertisedTips.get(remoteBranch), checkedRef, checked: true, reason: null }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.151";
1
+ export const CLI_VERSION = "0.12.152";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.151",
3
+ "version": "0.12.152",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {