@futurelastic/colab-handbook 1.13.0-rc.54 → 1.13.0-rc.55

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/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=18"
35
35
  },
36
- "version": "1.13.0-rc.54"
36
+ "version": "1.13.0-rc.55"
37
37
  }
package/tools/colab CHANGED
@@ -15435,6 +15435,9 @@ function batchStatsSince(v, nowMs) {
15435
15435
  return Number.isFinite(t) ? t : null;
15436
15436
  }
15437
15437
 
15438
+ /** The trunk log read's buffer (#585); COLAB_BATCH_STATS_MAX_BUFFER overrides it, for a test. */
15439
+ const BATCH_STATS_LOG_MAX_BUFFER = Number(process.env.COLAB_BATCH_STATS_MAX_BUFFER) || 256 * 1024 * 1024;
15440
+
15438
15441
  function cmdBatchStats(argv) {
15439
15442
  const opts = parseArgs(argv, {
15440
15443
  values: { '--repo': 'repo', '--since': 'since' },
@@ -15455,7 +15458,11 @@ function cmdBatchStats(argv) {
15455
15458
  const remote = git.remoteFor(repoAbs);
15456
15459
  const f = git.git(['fetch', remote, trunk], repoAbs);
15457
15460
  if (!f.ok) notes.push(`could not fetch ${remote}/${trunk} (${git.gitFailureLine(f.stderr)}) — read from the local copy, which may be behind`);
15458
- const log = git.git(['log', `${remote}/${trunk}`, '--first-parent', `--since=${sinceIso}`, '--format=%H%x1f%cI%x1f%B%x1e'], repoAbs);
15461
+ // Full squash bodies over a long window pass spawnSync's 1 MiB default (measured 2026-10-10:
15462
+ // 60 days of one repo's trunk came to 1,061,950 bytes), and ENOBUFS then read as a failed
15463
+ // fetch (#585). The buffer is sized for the read; a spawn error is reported as itself.
15464
+ const log = git.git(['log', `${remote}/${trunk}`, '--first-parent', `--since=${sinceIso}`, '--format=%H%x1f%cI%x1f%B%x1e'], repoAbs, { maxBuffer: BATCH_STATS_LOG_MAX_BUFFER });
15465
+ if (!log.ok && log.error) throw new UserError(`could not read ${remote}/${trunk}: ${git.gitFailureLine(log.stderr)} — pass a shorter --since, then run \`colab batch-stats\` again`);
15459
15466
  if (!log.ok) throw new UserError(`could not read ${remote}/${trunk}: ${git.gitFailureLine(log.stderr)} — run \`git fetch ${remote} ${trunk}\`, then run this again`);
15460
15467
  const commits = log.stdout.split('\x1e').map((r) => r.replace(/^\n/, '')).filter((r) => r.trim()).map((r) => {
15461
15468
  const [sha, iso, body] = r.split('\x1f');
package/tools/lib/git.js CHANGED
@@ -19,16 +19,32 @@ function run(cmd, args, opts = {}) {
19
19
  const { timeoutMs, ...spawnOpts } = opts;
20
20
  const res = spawnSync(cmd, args, { encoding: 'utf8', ...(timeoutMs ? { timeout: timeoutMs } : {}), ...spawnOpts });
21
21
  const timedOut = !!(res.error && res.error.code === 'ETIMEDOUT');
22
+ const stderr = (res.stderr || '').trim();
22
23
  return {
23
- ok: res.status === 0 && !timedOut,
24
+ ok: res.status === 0 && !timedOut && !res.error,
24
25
  code: res.status,
25
26
  stdout: (res.stdout || '').trim(),
26
- stderr: timedOut ? `timed out after ${timeoutMs}ms with no output` : (res.stderr || '').trim(),
27
+ // A spawn error (#585) leaves stderr empty: ENOBUFS kills the child once stdout passes
28
+ // `maxBuffer` (1 MiB by default), ENOENT means the binary is missing. An empty detail then
29
+ // reads as "git said nothing" and a caller's remedy guesses at the wrong cause, so the error
30
+ // itself becomes the detail whenever the child wrote none.
31
+ stderr: timedOut ? `timed out after ${timeoutMs}ms with no output` : (stderr || spawnErrorLine(res.error, spawnOpts)),
27
32
  error: res.error || null,
28
33
  timedOut,
29
34
  };
30
35
  }
31
36
 
37
+ /** One line naming a spawn error, or '' for none. ENOBUFS names the buffer it overran (#585). */
38
+ function spawnErrorLine(error, spawnOpts = {}) {
39
+ if (!error) return '';
40
+ const code = error.code || 'error';
41
+ if (code === 'ENOBUFS') {
42
+ const max = spawnOpts.maxBuffer || 1024 * 1024;
43
+ return `ENOBUFS: output passed the ${Math.round(max / 1024)} KiB read buffer and the child was killed`;
44
+ }
45
+ return `${code}: ${error.message || 'spawn failed'}`;
46
+ }
47
+
32
48
  /**
33
49
  * Every `gh` spawn in this module goes through the tracker adapter (#500) — the one place the CLI
34
50
  * talks to GitHub. Lazy require, deliberately: `module.exports = {…}` below REPLACES the exports
@@ -1415,7 +1431,7 @@ function ghAssignedIssues(repo) {
1415
1431
 
1416
1432
  module.exports = {
1417
1433
  ghCommitCheckRuns, ghCheckRunAnnotations,
1418
- run, git, repoRoot, mainRepoRoot, originUrl, remoteInfo, remoteName, remoteFor, remoteUrl, remoteProblem, _resetRemoteCache,
1434
+ run, spawnErrorLine, git, repoRoot, mainRepoRoot, originUrl, remoteInfo, remoteName, remoteFor, remoteUrl, remoteProblem, _resetRemoteCache,
1419
1435
  detectTrunk, branchExists, branchRefs, existingBranchRef,
1420
1436
  claimRemote, remoteHeads, parseRemoteHeads, CLAIM_REF_PREFIX, claimRef, pushClaimRef, deleteClaimRef,
1421
1437
  worktreeList, worktreeListDetailed, resolveWorktreePathForBranch, gitFailureLine,