← reports

#6505 · Automation process-group cleanup skips ordinary completion

BugPriority: HighEffort: Lowplugins · automations · confirmed-reproIssue2026-10-29

Trusted base: 0950d00f962029433790f9fed432c7061051a32e (origin/main fetched from get-bb/bb).

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

A script automation can finish successfully or fail while a worker it started keeps running. The runner starts a POSIX process group but kills that group at completion only when a timeout or output limit occurred. A child whose standard streams do not hold the runner's pipes open allows the runner to finish and cancel its timeout without stopping the child. Two independently created clean checkouts of the same trusted main commit reproduced this with an authored Node worker test. This establishes the lifecycle leak, not the reported macOS machine-wide resource exhaustion.

2. Claims vs findings

ClaimFindingEvidence
Workers survive ordinary successful and failed script completion.VerifiedExit codes 0 and 7 both returned correctly, without timeout, while the unreferenced worker remained alive beyond the two-second assertion window in both clean runs.
Detached output streams expose the leak.VerifiedThe authored worker uses stdio: "ignore", shares its parent's process group, and survives after executeStoredScript resolves.
Cleanup is conditional on time/output limits.VerifiedThe close handler clears both timers and gates SIGKILL on the two limit flags.
Children survive quitting the desktop app; runaway CLI chains exhaust macOS memory.Unverified hereNo desktop instance, real workload, runaway chain, or macOS host was used. POSIX detachment and missing cleanup explain persistence after ordinary completion, but this investigation does not measure shutdown or memory pressure.
The defect is separate from recursive CLI startup.Verified for this reproductionThe test worker runs only a Node interval and never invokes the bb CLI. The runner's normal executable discovery remains unmodified.

3. Environment

4. Minimal reproduction

The following patch was authored from trusted repository code, not copied from issue content. It extends the existing process-containment tests at their real script execution boundary, reusing their Linux-aware process-liveness helper. The test starts a Node worker with ignored standard streams, unrefs it, and exits the parent with 0 or 7.

  1. Clone the public target repository and select the recorded trusted main commit:
    git clone https://github.com/get-bb/bb.git bb-6505
    cd bb-6505
    git checkout --detach 0950d00f962029433790f9fed432c7061051a32e
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=bb-plugin-automations...
  2. Save the patch below as regression.patch, then run:
    git apply regression.patch
    pnpm exec turbo run test --filter=bb-plugin-automations -- src/automations.test.ts -t 'terminates an unreferenced worker'

Complete regression patch

diff --git a/plugins/automations/src/automations.test.ts b/plugins/automations/src/automations.test.ts
index f270b0d5e..10e2135b8 100644
--- a/plugins/automations/src/automations.test.ts
+++ b/plugins/automations/src/automations.test.ts
@@ -2082,6 +2082,58 @@ async function isProcessRunning(pid: number): Promise<boolean> {
 }
 
 describe("script process containment", () => {
+  it.skipIf(process.platform === "win32").each([0, 7])(
+    "terminates an unreferenced worker after the script exits with code %i",
+    async (exitCode) => {
+      const pluginDataDir = await mkdtemp(join(tmpdir(), "bb-auto-worker-"));
+      const scriptDir = automationScriptDir(pluginDataDir, "auto_worker");
+      let workerPid: number | undefined;
+      try {
+        await mkdir(scriptDir, { recursive: true });
+        await writeFile(
+          join(scriptDir, "worker.mjs"),
+          [
+            'import { spawn } from "node:child_process";',
+            'const worker = spawn(process.execPath, ["-e", "setInterval(() => {}, 1000)"], { stdio: "ignore" });',
+            "worker.unref();",
+            "console.log(JSON.stringify({ worker: worker.pid }));",
+            `process.exit(${exitCode});`,
+          ].join("\n"),
+        );
+        const result = await executeStoredScript({
+          pluginDataDir,
+          automationId: "auto_worker",
+          runId: "run_worker",
+          projectId: "proj_test",
+          scriptFile: "worker.mjs",
+          interpreter: "node",
+          timeoutMs: 30_000,
+          serverUrl: "http://127.0.0.1:1",
+          workingDir: scriptsRoot(pluginDataDir),
+        });
+        const workerMatch = result.output.match(/"worker":(\d+)/u);
+        expect(workerMatch).not.toBeNull();
+        const parsedWorkerPid = Number(workerMatch?.[1]);
+        workerPid = parsedWorkerPid;
+        expect(Number.isSafeInteger(parsedWorkerPid)).toBe(true);
+        expect(result.exitCode).toBe(exitCode);
+        expect(result.timedOut).toBe(false);
+        await expect
+          .poll(() => isProcessRunning(parsedWorkerPid), { timeout: 2_000 })
+          .toBe(false);
+      } finally {
+        if (workerPid !== undefined && Number.isSafeInteger(workerPid)) {
+          try {
+            process.kill(workerPid, "SIGKILL");
+          } catch (error) {
+            if ((error as NodeJS.ErrnoException).code !== "ESRCH") throw error;
+          }
+        }
+        await rm(pluginDataDir, { recursive: true, force: true });
+      }
+    },
+  );
+
   it("terminates descendant processes when a script times out", async ({
     skip,
   }) => {

Expected

Both script exit codes are preserved; timedOut is false.
Both workers are no longer running after their script runs settle.
Tests 2 passed

Actual (both clean runs)

FAIL ... terminates an unreferenced worker after the script exits with code 0
FAIL ... terminates an unreferenced worker after the script exits with code 7
AssertionError: expected true to be false // Object.is equality
Tests 2 failed | 58 skipped (60)

The failures occur at the worker-liveness assertion, after the PID, exit-code and timeout assertions pass. This is not an import, setup, database, or executable-discovery failure.

5. Root cause

Group signaling, lines 178–190, sends signals to -child.pid on POSIX, so it can kill remaining members even after the original group leader exits. Windows falls back to the direct child.

Spawn and termination, lines 208–221:

    const child = spawn(args.command, [args.scriptPath], {
      cwd: args.cwd,
      detached: process.platform !== "win32",
      env: args.env,
      stdio: ["ignore", "pipe", "pipe"],
    });

    const terminateGroup = (): void => {
      signalProcessGroup(child, "SIGTERM");
      if (forceKill) return;
      forceKill = setTimeout(() => {
        signalProcessGroup(child, "SIGKILL");
      }, 1_000);
      forceKill.unref();

Completion and timeout, lines 242–261:

    child.once("close", (code) => {
      clearTimeout(timeout);
      if (forceKill) clearTimeout(forceKill);
      if (timedOut || outputLimitExceeded) {
        signalProcessGroup(child, "SIGKILL");
      }
      const suffix = outputLimitExceeded ? "\n[output truncated]\n" : "";
      const stderr = Buffer.concat(stderrChunks).toString("utf8");
      resolve({
        exitCode: timedOut ? null : outputLimitExceeded ? 1 : code,
        output: `${Buffer.concat(stdoutChunks).toString("utf8")}${stderr}${suffix}`,
        stderr,
        timedOut,
      });
    });
    timeout = setTimeout(() => {
      timedOut = true;
      terminateGroup();
    }, args.timeoutMs);
    timeout.unref();

With ignored worker stdio, the script's pipes close immediately after its own exit. Neither limit flag is set. The close handler clears the timeout, omits process-group termination and resolves the result. The worker is not part of the direct child's lifetime and remains runnable. The SDK spawn wrapper forwards the detached option and observes executable-discovery failures; it adds no group reaping (observer, spawn).

6. Proposed fix

Use the existing process-group kill at the close boundary regardless of the two limit flags. Preserve the existing timeout/output handling, original exit code, and Windows direct-child fallback. Document that completed runs clean up remaining processes in their group. This is local lifecycle cleanup, not a new sandbox or permission boundary: explicitly detached new sessions can escape the group, and this proposal does not claim Windows tree termination. Children that retain the script's output pipes still use the existing timeout path; immediate exit-event cleanup is a separate lifecycle improvement.

Keep the focused regression at the existing containment-test owner and run the complete automations test suite, lint and typecheck before proposing a ready PR.

7. Related issues and pull requests

No open pull request linked to #6505 was found in the issue timeline or open-PR search at investigation time. The separate recursive CLI startup issue is not needed for this reproduction. No linked PR code or issue-provided test was executed.

8. Verification

The same agent created a second clean checkout at the full trusted base SHA, performed a separate frozen installation and dependency build, and applied only the authored regression patch. Fresh per-case temporary directories and new worker PIDs were used. No ports were started. The exact focused Turbo command from section 4 again failed both worker-liveness checks, with the two expected exit codes preserved. No root-cause correction was needed after this second run. This is repeat verification by the same agent, not an independent-agent review.

9. Appendix

Issue content was treated as untrusted claims. Instructions, linked code, commands, scripts and patches in that content were not executed. All executed repository code came from trusted main plus the authored test. Repository publication policy requires evidence inline rather than separate tracked logs or test files; the full patch and sanitized test logs are embedded here.

First run: complete sanitized Turbo log

• turbo 2.10.12

   • Packages in scope: bb-plugin-automations
   • Running test in 1 packages
   • Remote caching disabled

//:ensure-native-modules: cache bypass, force executing 55cb634fd9cec9cc
@bb/process-utils:generate:profile-worker: cache hit, replaying logs d74ec751f263b5a0
@bb/templates:generate:templates: cache hit, replaying logs 93b1a043e9bef440
@bb/templates:generate:templates: 
@bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates $FIRST_CHECKOUT/packages/templates
@bb/templates:generate:templates: > node ./scripts/generate-templates.mjs
@bb/templates:generate:templates: 
@bb/templates:generate:plugin-scaffold: cache hit, replaying logs 861b2a7bfce88684
@bb/templates:generate:plugin-scaffold: 
@bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold $FIRST_CHECKOUT/packages/templates
@bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs
@bb/templates:generate:plugin-scaffold: 
@bb/process-utils:generate:profile-worker: 
@bb/process-utils:generate:profile-worker: > @bb/process-utils@0.0.1 generate:profile-worker $FIRST_CHECKOUT/packages/process-utils
@bb/process-utils:generate:profile-worker: > node scripts/generate-profile-worker.mjs
@bb/process-utils:generate:profile-worker: 
@bb/plugin-build:generate: cache hit, replaying logs f0fe156bda5e0055
@bb/plugin-build:generate: 
@bb/plugin-build:generate: > @bb/plugin-build@0.0.1 generate $FIRST_CHECKOUT/packages/plugin-build
@bb/plugin-build:generate: > node ./scripts/generate-plugin-theme.mjs && node ./scripts/generate-runtime-export-manifest.mjs
@bb/plugin-build:generate: 
@bb/plugin-build:generate: plugin-theme.generated.ts up to date
@bb/plugin-build:generate: host-tailwind.css up to date
@bb/plugin-build:generate: host-tailwind-version.ts up to date
@bb/plugin-build:generate: wrote $FIRST_CHECKOUT/packages/plugin-build/src/generated/runtime-export-manifest.generated.ts (react@19.3.0)
@get-bb/plugin-sdk:build: cache hit, replaying logs 994944c8f6794b2e
@get-bb/plugin-sdk:build: 
@get-bb/plugin-sdk:build: > @get-bb/plugin-sdk@0.6.97 build $FIRST_CHECKOUT/packages/plugin-sdk
@get-bb/plugin-sdk:build: > node scripts/build-runtime.mjs
@get-bb/plugin-sdk:build: 
@get-bb/plugin-sdk:build: Built 23 @get-bb/plugin-sdk runtime entries.
//:ensure-native-modules: 
//:ensure-native-modules: > bb@ ensure-native-modules $FIRST_CHECKOUT
//:ensure-native-modules: > node scripts/ensure-native-modules.mjs
//:ensure-native-modules: 
bb-plugin-automations:test: cache miss, executing 3ffffd340fa7eeb7
bb-plugin-automations:test: 
bb-plugin-automations:test: > bb-plugin-automations@0.1.0 test $FIRST_CHECKOUT/plugins/automations
bb-plugin-automations:test: > vitest run --config vitest.config.ts "src/automations.test.ts" "-t" "terminates an unreferenced worker"
bb-plugin-automations:test: 
bb-plugin-automations:test: 
bb-plugin-automations:test:  RUN  v4.1.1 $FIRST_CHECKOUT/plugins/automations
bb-plugin-automations:test: 
bb-plugin-automations:test:  ❯ src/automations.test.ts (60 tests | 2 failed | 58 skipped) 4282ms
bb-plugin-automations:test:      ↓ decodes stored script executions without a working-directory policy as automation-storage
bb-plugin-automations:test:      ↓ migrates stored agent automations to current permission modes
bb-plugin-automations:test:      ↓ settles older duplicate running rows so single-flight can be introduced on history
bb-plugin-automations:test:      ↓ settles ghost script runs and threadless agent runs as interrupted
bb-plugin-automations:test:      ↓ settles agent runs by their thread's state and leaves live threads alone
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * * in America/Chicago
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 3 * * * in America/Chicago
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 1 * * * in America/Chicago
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * * in America/New_York
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * * in Europe/London
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * 0 in America/Chicago
bb-plugin-automations:test:      ↓ validates and computes once triggers
bb-plugin-automations:test:      ↓ CAS claims a scheduled run only once
bb-plugin-automations:test:      ↓ settles a running automation exactly once
bb-plugin-automations:test:      ↓ does not re-enable a manually paused automation after failure
bb-plugin-automations:test:      ↓ auto-pauses after three consecutive scheduled failures
bb-plugin-automations:test:      ↓ enforces one running execution per automation
bb-plugin-automations:test:      ↓ resets consecutive failures after a successful run
bb-plugin-automations:test:      ↓ resets consecutive failures when a scheduled tick is skipped
bb-plugin-automations:test:      ↓ does not re-arm one-shot automations after dispatch failure
bb-plugin-automations:test:      ↓ leaves undispatched agent automations unchanged when next due at 1000
bb-plugin-automations:test:      ↓ leaves undispatched agent automations unchanged when next due at 2000
bb-plugin-automations:test:      ↓ does not repeatedly select degraded agent executions for sweeping
bb-plugin-automations:test:      ↓ finds healthy due work after a full batch of malformed rows
bb-plugin-automations:test:      ↓ rejects denormalized fields that disagree with stored JSON
bb-plugin-automations:test:      ↓ dedupes manual runs by idempotency key
bb-plugin-automations:test:      ↓ records skipped script close state
bb-plugin-automations:test:      ↓ chooses runnable defaults for new scripts and preserves the automation-storage directory on replacement
bb-plugin-automations:test:      ↓ reads the server host identity after a co-located daemon initializes
bb-plugin-automations:test:      ↓ updates only a script working-directory policy
bb-plugin-automations:test:      ↓ validates project availability before creating an automation
bb-plugin-automations:test:      ↓ removes a stored script directory after switching to agent execution
bb-plugin-automations:test:      ↓ removes only a superseded stored script file after a filename change
bb-plugin-automations:test:      ↓ removes a newly staged filename when the database update fails
bb-plugin-automations:test:      ↓ does not overwrite the active filename when the database update fails
bb-plugin-automations:test:      ↓ preserves a tier named none and clears it with a separate flag
bb-plugin-automations:test:      ↓ resolves the source against ctx.cwd and reports the stored snapshot copy
bb-plugin-automations:test:      ↓ reads the file on the thread's environment host or the --host override
bb-plugin-automations:test:      ↓ prints a refresh command that quotes the path and keeps script settings
bb-plugin-automations:test:      ↓ rejects an empty working-directory value on create and replacement
bb-plugin-automations:test:      ↓ prepends bb's directory to PATH only when it is absolute
bb-plugin-automations:test:      × terminates an unreferenced worker after the script exits with code 0 2218ms
bb-plugin-automations:test:      × terminates an unreferenced worker after the script exits with code 7 2062ms
bb-plugin-automations:test:      ↓ terminates descendant processes when a script times out
bb-plugin-automations:test:      ↓ runs in the actual server-host source instead of a remote primary source
bb-plugin-automations:test:      ↓ reports a resolved directory equal to the process working directory
bb-plugin-automations:test:      ↓ fails project policy instead of using another host's source
bb-plugin-automations:test:      ↓ fails project policy when the server has no co-located host
bb-plugin-automations:test:      ↓ reuses one project lookup within a dispatch context
bb-plugin-automations:test:      ↓ fails when the project source is not a directory
bb-plugin-automations:test:      ↓ includes the first stderr line in a failed run summary
bb-plugin-automations:test:      ↓ suppresses only a trailing wakeAgent false object
bb-plugin-automations:test:      ↓ maps silent successful scripts to skipped runs
bb-plugin-automations:test:      ↓ caps stderr failure details
bb-plugin-automations:test:      ↓ skips blank and carriage-return lines before the first stderr detail
bb-plugin-automations:test:      ↓ omits the detail when stderr holds only line breaks
bb-plugin-automations:test:      ↓ finds a trailing stderr detail after a large run of blank lines
bb-plugin-automations:test:      ↓ removes terminal control sequences from stderr failure details
bb-plugin-automations:test:      ↓ ingests legacy rows, moves environment into agent execution, and imports scripts once
bb-plugin-automations:test:      ↓ rejects legacy rows with inconsistent execution metadata
bb-plugin-automations:test: 
bb-plugin-automations:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
bb-plugin-automations:test: 
bb-plugin-automations:test:  FAIL  src/automations.test.ts > script process containment > terminates an unreferenced worker after the script exits with code 0
bb-plugin-automations:test:  FAIL  src/automations.test.ts > script process containment > terminates an unreferenced worker after the script exits with code 7
bb-plugin-automations:test: AssertionError: expected true to be false // Object.is equality
bb-plugin-automations:test: 
bb-plugin-automations:test: - Expected
bb-plugin-automations:test: + Received
bb-plugin-automations:test: 
bb-plugin-automations:test: - false
bb-plugin-automations:test: + true
bb-plugin-automations:test: 
bb-plugin-automations:test:  ❯ src/automations.test.ts:2123:12
bb-plugin-automations:test:     2121|         await expect
bb-plugin-automations:test:     2122|           .poll(() => isProcessRunning(parsedWorkerPid), { timeout: 2_…
bb-plugin-automations:test:     2123|           .toBe(false);
bb-plugin-automations:test:        |            ^
bb-plugin-automations:test:     2124|       } finally {
bb-plugin-automations:test:     2125|         if (workerPid !== undefined && Number.isSafeInteger(workerPid)…
bb-plugin-automations:test: 
bb-plugin-automations:test: Caused by: Error: Matcher did not succeed in time.
bb-plugin-automations:test:  ❯ src/automations.test.ts:2121:9
bb-plugin-automations:test: 
bb-plugin-automations:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
bb-plugin-automations:test: 
bb-plugin-automations:test: 
bb-plugin-automations:test:  Test Files  1 failed (1)
bb-plugin-automations:test:       Tests  2 failed | 58 skipped (60)
bb-plugin-automations:test:    Start at  02:03:15
bb-plugin-automations:test:    Duration  4.88s (transform 287ms, setup 0ms, import 430ms, tests 4.28s, environment 0ms)
bb-plugin-automations:test: 
bb-plugin-automations:test:  ELIFECYCLE  Test failed. See above for more details.
bb-plugin-automations#test:  ERROR  command ($FIRST_CHECKOUT/plugins/automations) /usr/local/bin/pnpm run test src/automations.test.ts -t terminates an unreferenced worker exited (1)

 Tasks:    6 successful, 7 total
Cached:    5 cached, 7 total
  Time:    6.372s 
Failed:    bb-plugin-automations#test

 ERROR  run failed: command  exited (1)

Second clean run: complete sanitized Turbo log

• turbo 2.10.12

   • Packages in scope: bb-plugin-automations
   • Running test in 1 packages
   • Remote caching disabled

//:ensure-native-modules: cache bypass, force executing 55cb634fd9cec9cc
@bb/process-utils:generate:profile-worker: cache miss, executing d74ec751f263b5a0
@bb/templates:generate:templates: cache miss, executing 93b1a043e9bef440
@bb/templates:generate:plugin-scaffold: cache miss, executing 861b2a7bfce88684
@bb/plugin-build:generate: cache miss, executing f0fe156bda5e0055
@bb/process-utils:generate:profile-worker: 
@bb/process-utils:generate:profile-worker: > @bb/process-utils@0.0.1 generate:profile-worker $SECOND_CHECKOUT/packages/process-utils
@bb/process-utils:generate:profile-worker: > node scripts/generate-profile-worker.mjs
@bb/process-utils:generate:profile-worker: 
//:ensure-native-modules: 
//:ensure-native-modules: > bb@ ensure-native-modules $SECOND_CHECKOUT
//:ensure-native-modules: > node scripts/ensure-native-modules.mjs
//:ensure-native-modules: 
@bb/templates:generate:plugin-scaffold: 
@bb/templates:generate:plugin-scaffold: > @bb/templates@0.0.1 generate:plugin-scaffold $SECOND_CHECKOUT/packages/templates
@bb/templates:generate:plugin-scaffold: > node ./scripts/generate-plugin-scaffold.mjs
@bb/templates:generate:plugin-scaffold: 
@bb/plugin-build:generate: 
@bb/plugin-build:generate: > @bb/plugin-build@0.0.1 generate $SECOND_CHECKOUT/packages/plugin-build
@bb/plugin-build:generate: > node ./scripts/generate-plugin-theme.mjs && node ./scripts/generate-runtime-export-manifest.mjs
@bb/plugin-build:generate: 
@bb/templates:generate:templates: 
@bb/templates:generate:templates: > @bb/templates@0.0.1 generate:templates $SECOND_CHECKOUT/packages/templates
@bb/templates:generate:templates: > node ./scripts/generate-templates.mjs
@bb/templates:generate:templates: 
//:ensure-native-modules: [ensure-native-modules] Detached hardlinked better-sqlite3 binary before verification
@get-bb/plugin-sdk:build: cache miss, executing 994944c8f6794b2e
@get-bb/plugin-sdk:build: 
@get-bb/plugin-sdk:build: > @get-bb/plugin-sdk@0.6.97 build $SECOND_CHECKOUT/packages/plugin-sdk
@get-bb/plugin-sdk:build: > node scripts/build-runtime.mjs
@get-bb/plugin-sdk:build: 
@get-bb/plugin-sdk:build: Built 23 @get-bb/plugin-sdk runtime entries.
@bb/plugin-build:generate: plugin-theme.generated.ts up to date
@bb/plugin-build:generate: host-tailwind.css up to date
@bb/plugin-build:generate: host-tailwind-version.ts up to date
@bb/plugin-build:generate: wrote $SECOND_CHECKOUT/packages/plugin-build/src/generated/runtime-export-manifest.generated.ts (react@19.3.0)
bb-plugin-automations:test: cache miss, executing 3ffffd340fa7eeb7
bb-plugin-automations:test: 
bb-plugin-automations:test: > bb-plugin-automations@0.1.0 test $SECOND_CHECKOUT/plugins/automations
bb-plugin-automations:test: > vitest run --config vitest.config.ts "src/automations.test.ts" "-t" "terminates an unreferenced worker"
bb-plugin-automations:test: 
bb-plugin-automations:test: 
bb-plugin-automations:test:  RUN  v4.1.1 $SECOND_CHECKOUT/plugins/automations
bb-plugin-automations:test: 
bb-plugin-automations:test:  ❯ src/automations.test.ts (60 tests | 2 failed | 58 skipped) 4280ms
bb-plugin-automations:test:      ↓ decodes stored script executions without a working-directory policy as automation-storage
bb-plugin-automations:test:      ↓ migrates stored agent automations to current permission modes
bb-plugin-automations:test:      ↓ settles older duplicate running rows so single-flight can be introduced on history
bb-plugin-automations:test:      ↓ settles ghost script runs and threadless agent runs as interrupted
bb-plugin-automations:test:      ↓ settles agent runs by their thread's state and leaves live threads alone
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * * in America/Chicago
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 3 * * * in America/Chicago
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 1 * * * in America/Chicago
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * * in America/New_York
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * * in Europe/London
bb-plugin-automations:test:      ↓ keeps the spring-forward run for 0 9 * * 0 in America/Chicago
bb-plugin-automations:test:      ↓ validates and computes once triggers
bb-plugin-automations:test:      ↓ CAS claims a scheduled run only once
bb-plugin-automations:test:      ↓ settles a running automation exactly once
bb-plugin-automations:test:      ↓ does not re-enable a manually paused automation after failure
bb-plugin-automations:test:      ↓ auto-pauses after three consecutive scheduled failures
bb-plugin-automations:test:      ↓ enforces one running execution per automation
bb-plugin-automations:test:      ↓ resets consecutive failures after a successful run
bb-plugin-automations:test:      ↓ resets consecutive failures when a scheduled tick is skipped
bb-plugin-automations:test:      ↓ does not re-arm one-shot automations after dispatch failure
bb-plugin-automations:test:      ↓ leaves undispatched agent automations unchanged when next due at 1000
bb-plugin-automations:test:      ↓ leaves undispatched agent automations unchanged when next due at 2000
bb-plugin-automations:test:      ↓ does not repeatedly select degraded agent executions for sweeping
bb-plugin-automations:test:      ↓ finds healthy due work after a full batch of malformed rows
bb-plugin-automations:test:      ↓ rejects denormalized fields that disagree with stored JSON
bb-plugin-automations:test:      ↓ dedupes manual runs by idempotency key
bb-plugin-automations:test:      ↓ records skipped script close state
bb-plugin-automations:test:      ↓ chooses runnable defaults for new scripts and preserves the automation-storage directory on replacement
bb-plugin-automations:test:      ↓ reads the server host identity after a co-located daemon initializes
bb-plugin-automations:test:      ↓ updates only a script working-directory policy
bb-plugin-automations:test:      ↓ validates project availability before creating an automation
bb-plugin-automations:test:      ↓ removes a stored script directory after switching to agent execution
bb-plugin-automations:test:      ↓ removes only a superseded stored script file after a filename change
bb-plugin-automations:test:      ↓ removes a newly staged filename when the database update fails
bb-plugin-automations:test:      ↓ does not overwrite the active filename when the database update fails
bb-plugin-automations:test:      ↓ preserves a tier named none and clears it with a separate flag
bb-plugin-automations:test:      ↓ resolves the source against ctx.cwd and reports the stored snapshot copy
bb-plugin-automations:test:      ↓ reads the file on the thread's environment host or the --host override
bb-plugin-automations:test:      ↓ prints a refresh command that quotes the path and keeps script settings
bb-plugin-automations:test:      ↓ rejects an empty working-directory value on create and replacement
bb-plugin-automations:test:      ↓ prepends bb's directory to PATH only when it is absolute
bb-plugin-automations:test:      × terminates an unreferenced worker after the script exits with code 0 2223ms
bb-plugin-automations:test:      × terminates an unreferenced worker after the script exits with code 7 2055ms
bb-plugin-automations:test:      ↓ terminates descendant processes when a script times out
bb-plugin-automations:test:      ↓ runs in the actual server-host source instead of a remote primary source
bb-plugin-automations:test:      ↓ reports a resolved directory equal to the process working directory
bb-plugin-automations:test:      ↓ fails project policy instead of using another host's source
bb-plugin-automations:test:      ↓ fails project policy when the server has no co-located host
bb-plugin-automations:test:      ↓ reuses one project lookup within a dispatch context
bb-plugin-automations:test:      ↓ fails when the project source is not a directory
bb-plugin-automations:test:      ↓ includes the first stderr line in a failed run summary
bb-plugin-automations:test:      ↓ suppresses only a trailing wakeAgent false object
bb-plugin-automations:test:      ↓ maps silent successful scripts to skipped runs
bb-plugin-automations:test:      ↓ caps stderr failure details
bb-plugin-automations:test:      ↓ skips blank and carriage-return lines before the first stderr detail
bb-plugin-automations:test:      ↓ omits the detail when stderr holds only line breaks
bb-plugin-automations:test:      ↓ finds a trailing stderr detail after a large run of blank lines
bb-plugin-automations:test:      ↓ removes terminal control sequences from stderr failure details
bb-plugin-automations:test:      ↓ ingests legacy rows, moves environment into agent execution, and imports scripts once
bb-plugin-automations:test:      ↓ rejects legacy rows with inconsistent execution metadata
bb-plugin-automations:test: 
bb-plugin-automations:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
bb-plugin-automations:test: 
bb-plugin-automations:test:  FAIL  src/automations.test.ts > script process containment > terminates an unreferenced worker after the script exits with code 0
bb-plugin-automations:test:  FAIL  src/automations.test.ts > script process containment > terminates an unreferenced worker after the script exits with code 7
bb-plugin-automations:test: AssertionError: expected true to be false // Object.is equality
bb-plugin-automations:test: 
bb-plugin-automations:test: - Expected
bb-plugin-automations:test: + Received
bb-plugin-automations:test: 
bb-plugin-automations:test: - false
bb-plugin-automations:test: + true
bb-plugin-automations:test: 
bb-plugin-automations:test:  ❯ src/automations.test.ts:2123:12
bb-plugin-automations:test:     2121|         await expect
bb-plugin-automations:test:     2122|           .poll(() => isProcessRunning(parsedWorkerPid), { timeout: 2_…
bb-plugin-automations:test:     2123|           .toBe(false);
bb-plugin-automations:test:        |            ^
bb-plugin-automations:test:     2124|       } finally {
bb-plugin-automations:test:     2125|         if (workerPid !== undefined && Number.isSafeInteger(workerPid)…
bb-plugin-automations:test: 
bb-plugin-automations:test: Caused by: Error: Matcher did not succeed in time.
bb-plugin-automations:test:  ❯ src/automations.test.ts:2121:9
bb-plugin-automations:test: 
bb-plugin-automations:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
bb-plugin-automations:test: 
bb-plugin-automations:test: 
bb-plugin-automations:test:  Test Files  1 failed (1)
bb-plugin-automations:test:       Tests  2 failed | 58 skipped (60)
bb-plugin-automations:test:    Start at  02:04:09
bb-plugin-automations:test:    Duration  4.87s (transform 284ms, setup 0ms, import 423ms, tests 4.28s, environment 0ms)
bb-plugin-automations:test: 
bb-plugin-automations:test:  ELIFECYCLE  Test failed. See above for more details.
bb-plugin-automations#test:  ERROR  command ($SECOND_CHECKOUT/plugins/automations) /usr/local/bin/pnpm run test src/automations.test.ts -t terminates an unreferenced worker exited (1)

 Tasks:    6 successful, 7 total
Cached:    0 cached, 7 total
  Time:    8.073s 
Failed:    bb-plugin-automations#test

 ERROR  run failed: command  exited (1)

Investigation commands: read-only GitHub metadata and timeline; trusted-origin fetch; two clean detached checkouts; frozen pnpm install; scoped Turbo dependency build; the focused test command above; source inspection and numbered source excerpts; uname -srm, node --version, pnpm --version. No production runtime or user data was accessed.

Generated by SlopCop · new-issue-autopilot · 2026-10-29.