Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(sync): a --timeout run is stopped by its own abort, not the watchdog (#7819)

garrytanf8463a76edd2
diff --git a/docs/architecture/key-files/runtime.md b/docs/architecture/key-files/runtime.md
index bbc3cd8fbf..52d7c5243e 100644
--- a/docs/architecture/key-files/runtime.md
+++ b/docs/architecture/key-files/runtime.md
@@ -31,7 +31,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `src/core/read-heartbeat.ts` + `src/cli/slow-read.ts` — slow whole-brain reads say what they are doing. A `CliCommandRecord.slowRead(args)` (`src/cli/command-table.ts`) names the read for doctor, sync status, sources status, orphans, anomalies, status and diag; `beginCommandRead` (skipped for `--help` and `--quiet`) wraps the CLI_ONLY dispatch in `src/cli/main.ts` and calls `beginSlowRead`, which prints one stderr start line and an unref'd `still reading` line every `READ_HEARTBEAT_EVERY_MS` (10 s); stdout is untouched. `withReadMeta(doc)` adds `elapsed_ms` and `complete` to a `--json` document and lists `incomplete` (`{field, reason}`) from the markers the documents already carry (`incompleteFields`: a `status: not_read` object, `complete: false` or a `*_complete: false` key, `budget_hit: true`, a doctor check unknown for its budget); an error envelope gets `elapsed_ms` only and an array stays bare. `writeStdoutFinal` (`cli-force-exit.ts`) applies it to a guarded document during a slow read, and orphans, sources status and status call it directly. `noteInterrupted` prints the interrupt line and, under `--json`, writes `{error: 'interrupted', signal, read, elapsed_ms, complete: false}` at once through the writer `cli-force-exit.ts` registers (`setInterruptedDocumentWriter`); a SIGINT handler is installed only when nothing else listens. The fallback document for exits 129, 130 and 143 is `code: 'interrupted'`. Pinned by `test/read-heartbeat-cli.test.ts` (real spawned CLI fixture `test/fixtures/slow-read-cli.ts`: SIGTERM, SIGINT, SIGHUP, SIGKILL after SIGTERM, no `--json`, a kill outside a read) and `test/read-meta-diag.test.ts`.
- `src/commands/diag.ts` (+ `src/cli/commands/diag.ts`, `src/cli/help/diag.ts`) — `gbrain diag [--json] [--budget-ms N] [--query TEXT]`, read-only and refused on a thin client: one bounded bundle an agent pastes whole. `collectDiag` runs six sections in turn, each through `diagSection` under min(its cap in `DIAG_SECTION_CAP_MS`, what is left of the budget, default 30 s): `gbrain` (version, engine, runtime), `skew` (doctor `runtime_build_skew` and `writer_version`), `sources` (per source `last_sync_at`, last commit, `behind_head` from `readGitBehind`, the managed pass row's state from `readLivePassRows`), `holds` (counts per source and code), `pool` (Postgres only: backends by state, lock waits, idle transactions over 60 s, `pg_stat_database` session endings on 14+) and `search` (one search's stage timings and result count, never its results). Each section carries `elapsed_ms` and `status` `ok`, `not_read` (reason `budget`), `not_applicable` or `error` (with its code); the bundle carries `elapsed_ms`, `complete` and `incomplete`, error sections included. It never reads a source's file level (`sync status --detail`). Pinned by `test/read-meta-diag.test.ts`.
-- `src/core/process-watchdog.ts` — out-of-band hard-deadline killer for `gbrain sync`. A spinning sync (synchronous catastrophic-regex / ReDoS in pack link-inference) STARVES the main event loop, so the existing SIGTERM handler (`process-cleanup.ts`), `--timeout` `setTimeout`, and abort-flag checks can't fire — the process becomes unkillable-by-SIGTERM and, under cron, orphans pile up for 24h+. `installProcessWatchdog({deadlineMs, graceMs?, label?, heartbeatMs?, onWarn?}): WatchdogHandle` spawns a Bun `worker_threads` Worker via `new Worker(code, {eval: true, workerData})` — its own OS thread + event loop fires even while main is in an unyielding sync loop. At `deadlineMs` it `process.kill(process.pid, 'SIGTERM')` (clean-shutdown chance if responsive); at `deadlineMs+graceMs` `process.kill(process.pid, 'SIGKILL')` (uncatchable — guaranteed death under starvation). Signaling SELF has NO PID-reuse footgun (current PID never reused while alive — the reason the detached-child-watches-parent design was rejected). `eval: true` bakes the worker body into the `bun build --compile` binary with no separate-file embedding. Empirically validated on Bun 1.3.13 (worker timer + SIGKILL killed a `while(true){}`-starved process). `handle.dispose()` (clean-exit `finally`) `worker.terminate()`s it; `unref()`'d so it never keeps the process alive. Pure `watchdogDecision(elapsedMs, deadlineMs, graceMs) → 'wait'|'sigterm'|'sigkill'` extracted for unit tests, and pure exported `clampWatchdogTimers(deadlineMs, graceMs)` + `MAX_WATCHDOG_TIMER_MS` clamp BOTH worker timers so the deadline AND the `deadline+grace` SUM stay ≤ 2^31−1 — `setTimeout` overflow-fires above that at ~1ms, which for the sum timer would be an instant SIGKILL of a healthy process (unit-tested as pure arithmetic only; never arm a real max-deadline worker in-suite — its firing SIGTERMs the test runner itself). Optional `heartbeatMs` emits periodic `[<label>] parent alive Ns, hard-kill in ~Ms` lines (visible in cron logs even under starvation — the diagnosis surface). Optional `progressWindowMs` makes the deadline progress-aware: the handle forwards `noteForwardProgress()` notes (`src/core/forward-progress.ts`, throttled to at most one `postMessage` per min(1 s, window/4)) to the worker, which past the deadline extends while the last note is younger than the window and sends SIGTERM only after a full window without progress (pure mirror `progressDeadlineDecision(elapsedMs, deadlineMs, sinceProgressMs, windowMs) → 'wait'|'extend'|'stop'`; the window starts at install). A starved loop sends no notes, so starvation is still killed. Optional `stopNotice` is written to stdout (fd 1) when the watchdog stops the run, so the agent sees why and how to resume. GBRA-133 PR 3a: `progressSignal: 'committed'` forwards only `noteCommittedProgress()` notes, and a run that reaches its deadline having committed nothing stops at once (the `progressed` argument of `progressDeadlineDecision` is false) and writes `stallNotice` instead of `stopNotice`; the sync watchdog uses it, so screening and legacy-sweep slices never extend the deadline. Fallback: if `new Worker` throws, degrades to an in-process timer with a loud warning that it can't fire under starvation. Two adopters: `gbrain sync` (below) and the opt-in PGLite disconnect watchdog (`pglite-engine.ts` entry above); autopilot/cycle are follow-up candidates. Pinned by `test/process-watchdog.test.ts` (pure decision matrices + clamp arithmetic + handle contract) + `test/process-watchdog-harness.test.ts` (Bun-pinned spawn integration: a starved harness process IS killed ~deadline+grace, a no-watchdog control does NOT self-exit, clean dispose never kills, a progressing run outlives its deadline, a run that stops progressing is stopped one window later with its stop notice on stdout). Wired into `src/cli.ts` sync dispatch BEFORE `connectEngine` (so a connect-phase hang is bounded too) through `syncWatchdogPlan` in `src/core/sync-reconcile.ts`; deadline resolved by `resolveSyncHardDeadline` (precedence: `--no-hard-deadline` > `--hard-deadline` > `--timeout`(non-`--all`) > `GBRAIN_SYNC_MAX_RUNTIME_SECONDS` env > non-TTY default 3600s > none). The env and default deadlines carry `progressWindowMs` = the sync stall window (`GBRAIN_SYNC_STALL_ABORT_SECONDS`, default 900 s; the default when that is disabled), so a large first sync that keeps importing is never stopped; the explicit flags stay strict. The stop notice (`syncDeadlineStopNotice`: `code=sync_deadline_stop`, cause, resume command; one JSON object under `--json`) is pinned by `test/sync-hard-deadline.test.ts`, and the real CLI journey by `test/large-brain-ceilings.test.ts`. The stall notice of a run that committed nothing (`syncDeadlineStallNotice`: `code=sync_deadline_stalled`, why, a read-only `gbrain sync status` fix) is pinned by `test/honest-stalls-gbra133.test.ts`.
+- `src/core/process-watchdog.ts` — out-of-band hard-deadline killer for `gbrain sync`. A spinning sync (synchronous catastrophic-regex / ReDoS in pack link-inference) STARVES the main event loop, so the existing SIGTERM handler (`process-cleanup.ts`), `--timeout` `setTimeout`, and abort-flag checks can't fire — the process becomes unkillable-by-SIGTERM and, under cron, orphans pile up for 24h+. `installProcessWatchdog({deadlineMs, graceMs?, label?, heartbeatMs?, onWarn?}): WatchdogHandle` spawns a Bun `worker_threads` Worker via `new Worker(code, {eval: true, workerData})` — its own OS thread + event loop fires even while main is in an unyielding sync loop. At `deadlineMs` it `process.kill(process.pid, 'SIGTERM')` (clean-shutdown chance if responsive); at `deadlineMs+graceMs` `process.kill(process.pid, 'SIGKILL')` (uncatchable — guaranteed death under starvation). Signaling SELF has NO PID-reuse footgun (current PID never reused while alive — the reason the detached-child-watches-parent design was rejected). `eval: true` bakes the worker body into the `bun build --compile` binary with no separate-file embedding. Empirically validated on Bun 1.3.13 (worker timer + SIGKILL killed a `while(true){}`-starved process). `handle.dispose()` (clean-exit `finally`) `worker.terminate()`s it; `unref()`'d so it never keeps the process alive. Pure `watchdogDecision(elapsedMs, deadlineMs, graceMs) → 'wait'|'sigterm'|'sigkill'` extracted for unit tests, and pure exported `clampWatchdogTimers(deadlineMs, graceMs)` + `MAX_WATCHDOG_TIMER_MS` clamp BOTH worker timers so the deadline AND the `deadline+grace` SUM stay ≤ 2^31−1 — `setTimeout` overflow-fires above that at ~1ms, which for the sum timer would be an instant SIGKILL of a healthy process (unit-tested as pure arithmetic only; never arm a real max-deadline worker in-suite — its firing SIGTERMs the test runner itself). Optional `heartbeatMs` emits periodic `[<label>] parent alive Ns, hard-kill in ~Ms` lines (visible in cron logs even under starvation — the diagnosis surface). Optional `progressWindowMs` makes the deadline progress-aware: the handle forwards `noteForwardProgress()` notes (`src/core/forward-progress.ts`, throttled to at most one `postMessage` per min(1 s, window/4)) to the worker, which past the deadline extends while the last note is younger than the window and sends SIGTERM only after a full window without progress (pure mirror `progressDeadlineDecision(elapsedMs, deadlineMs, sinceProgressMs, windowMs) → 'wait'|'extend'|'stop'`; the window starts at install). A starved loop sends no notes, so starvation is still killed. Optional `stopNotice` is written to stdout (fd 1) when the watchdog stops the run, so the agent sees why and how to resume. GBRA-133 PR 3a: `progressSignal: 'committed'` forwards only `noteCommittedProgress()` notes, and a run that reaches its deadline having committed nothing stops at once (the `progressed` argument of `progressDeadlineDecision` is false) and writes `stallNotice` instead of `stopNotice`; the sync watchdog uses it, so screening and legacy-sweep slices never extend the deadline. Fallback: if `new Worker` throws, degrades to an in-process timer with a loud warning that it can't fire under starvation. Two adopters: `gbrain sync` (below) and the opt-in PGLite disconnect watchdog (`pglite-engine.ts` entry above); autopilot/cycle are follow-up candidates. Pinned by `test/process-watchdog.test.ts` (pure decision matrices + clamp arithmetic + handle contract) + `test/process-watchdog-harness.test.ts` (Bun-pinned spawn integration: a starved harness process IS killed ~deadline+grace, a no-watchdog control does NOT self-exit, clean dispose never kills, a progressing run outlives its deadline, a run that stops progressing is stopped one window later with its stop notice on stdout). Wired into `src/cli.ts` sync dispatch BEFORE `connectEngine` (so a connect-phase hang is bounded too) through `syncWatchdogPlan` in `src/core/sync-reconcile.ts`; deadline resolved by `resolveSyncHardDeadline` (precedence: `--no-hard-deadline` > `--hard-deadline` > `--timeout`(non-`--all`, armed `HARD_DEADLINE_GRACE_SEC` after the timeout so the in-band stop lands first) > `GBRAIN_SYNC_MAX_RUNTIME_SECONDS` env > non-TTY default 3600s > none). The env and default deadlines carry `progressWindowMs` = the sync stall window (`GBRAIN_SYNC_STALL_ABORT_SECONDS`, default 900 s; the default when that is disabled), so a large first sync that keeps importing is never stopped; the explicit flags stay strict. The stop notice (`syncDeadlineStopNotice`: `code=sync_deadline_stop`, cause, resume command; one JSON object under `--json`) is pinned by `test/sync-hard-deadline.test.ts`, and the real CLI journey by `test/large-brain-ceilings.test.ts`. The stall notice of a run that committed nothing (`syncDeadlineStallNotice`: `code=sync_deadline_stalled`, why, a read-only `gbrain sync status` fix) is pinned by `test/honest-stalls-gbra133.test.ts`.
- `src/core/forward-progress.ts` — process-wide forward-progress signal, zero imports. `noteForwardProgress()` records that a unit of work completed (called by every `progress.ts` tick); `onForwardProgress(listener)` subscribes and returns the unsubscribe; `lastForwardProgressAt()` reads the last note. Consumers are deadlines that must never stop a run that is still progressing: the sync watchdog (`process-watchdog.ts`, `progressWindowMs`) and the `gbrain serve` boot deadline. Heartbeats are not progress. GBRA-133 PR 3a: `noteCommittedProgress()` records committed work (a page written, deleted or renamed, a cursor advanced; the sync import, delete and rename loops, the drain's page commits and checkpoint, and a followed drain holder whose committed count rose) and is also a forward note; `onCommittedProgress` / `lastCommittedProgressAt` read it. The sync watchdog listens to committed notes only.
- `src/core/spawn.ts` — the one module in `src/` that launches subprocesses with `windowsHide` defaulted (#4992, contributed by @rokas-tarasevicius in PR #6105). A `detached: true` child on Windows has no console, so every console program it launches without `windowsHide` opens a visible console window that takes focus; the Stop-hook push, the backup check, the job supervisor, its worker and every job child run that way. Wraps `spawn`, `spawnSync`, `exec`, `execSync`, `execFile`, `execFileSync` (Node's overloads and `util.promisify.custom` kept) plus `bunSpawn` / `bunSpawnSync`, each defaulting `windowsHide: true` and keeping an explicit `false` (only `openBrowser` in `creds/redirect.ts`). Calls go through `child_process` and `Bun` at call time, so `spyOn` in tests still intercepts them. Trade-off: with every stdio stream piped or ignored, libuv turns the flag into CREATE_NO_WINDOW and the child gets a windowless console of its own, so a program that prompts on the console directly prompts invisibly; gbrain's networked git calls set `GIT_TERMINAL_PROMPT=0` (git-remote.ts also `SSH_ASKPASS_REQUIRE=never`), and inherited-stdio launches still attach to the terminal. `scripts/check-windows-hide.ts` (`bun run check:windows-hide`, in `verify`) is a RATCHET: a new runtime `child_process` import or `Bun.spawn*` in `src/` fails unless the file is in its `NOT_YET_MIGRATED` list (the minions supervisor/worker/child/readiness/isolation/registry/shell handler, `workspace-push.ts`, `cli/main.ts`, `context/hook-heartbeat.ts`, the backup check, `cli-force-exit.ts`, `cli-preflight.ts`, `autopilot-lock.ts`, the autopilot commands and `bounded-child-exec.ts` are migrated; the rest, wave-13-claimed files included, are listed and lose the entry when they move), and a listed file that stops launching directly fails as stale. Pinned by `test/spawn-windows-hide.test.ts` (argument shapes; the detached supervisor, worker and push-git sites), `test/scripts/windows-hide-guard.test.ts` (forms, allowlist, ratchet, stale entries, the repository) and, natively on the test.yml `security-regressions` Windows row, `test/windows-hidden-console.test.ts` (a compiled console probe launched from a console-less detached process: the unhidden CONTROL launch must show a window or the run fails as `windows_console_gate_unsupported`; then the worker, the push's git and every seam launcher show none).
diff --git a/src/commands/sync-delegate.ts b/src/commands/sync-delegate.ts
index 86ef07dfd0..63fd07a0dc 100644
--- a/src/commands/sync-delegate.ts
+++ b/src/commands/sync-delegate.ts
@@ -147,20 +147,22 @@ export function parseDelegatedSyncArgs(args: string[]): ParsedDelegatedArgs {
* explicitly waived the bound (--no-hard-deadline) — the ONLY unbounded
* encoding; an interactive TTY default (null from resolveSyncHardDeadline)
* maps to the same 3600s the non-TTY default uses, so a job whose client
- * dies is always bounded.
+ * dies is always bounded. A single-source --timeout bounds the job itself,
+ * not the watchdog's later backstop.
*/
export async function deriveDelegatedTimeoutSeconds(
args: string[],
opts: { isTty?: boolean; env?: Record<string, string | undefined> } = {},
): Promise<number> {
if (args.includes('--no-hard-deadline')) return 0;
- const { resolveSyncHardDeadline } = await import('../core/sync-reconcile.ts');
+ const { resolveSyncHardDeadline, HARD_DEADLINE_GRACE_SEC } = await import('../core/sync-reconcile.ts');
const res = resolveSyncHardDeadline(args, {
isTty: opts.isTty ?? Boolean(process.stdout.isTTY),
env: opts.env ?? process.env,
});
if (!res) return 3600;
- return Math.max(1, Math.round(res.deadlineMs / 1000));
+ const hard = Math.max(1, Math.round(res.deadlineMs / 1000));
+ return res.reason === 'flag:--timeout' ? hard - HARD_DEADLINE_GRACE_SEC : hard;
}
async function setVerdict(code: number): Promise<void> {
diff --git a/src/core/sync-reconcile.ts b/src/core/sync-reconcile.ts
index ebb2caef9b..28d32ab4f5 100644
--- a/src/core/sync-reconcile.ts
+++ b/src/core/sync-reconcile.ts
@@ -262,13 +262,16 @@ export function resolveSyncHardDeadline(
return mk(sec ?? 0, 'flag:--hard-deadline');
}
- // --timeout auto-arms a hard backstop at timeout(+grace), but ONLY single-source.
+ // --timeout auto-arms a hard backstop one grace window after the timeout, but
+ // ONLY single-source. The watchdog arms before connect and the in-band
+ // --timeout abort after it, so a backstop at the timeout itself would always
+ // SIGTERM (exit 143) a run the abort stops as a partial (exit 0).
// For --all, per-source budgets don't collapse to one wall-clock; fall through.
const isAll = args.includes('--all');
const timeoutStr = args.find((a, i) => args[i - 1] === '--timeout');
if (timeoutStr !== undefined && !isAll) {
const sec = parseDurationSeconds(timeoutStr, '--timeout');
- if (sec && sec > 0) return mk(sec, 'flag:--timeout');
+ if (sec && sec > 0) return mk(sec + HARD_DEADLINE_GRACE_SEC, 'flag:--timeout');
}
// A large first sync legitimately outlives the default hour, so these two
diff --git a/test/sync-hard-deadline.test.ts b/test/sync-hard-deadline.test.ts
index 333308db33..48b99ae43a 100644
--- a/test/sync-hard-deadline.test.ts
+++ b/test/sync-hard-deadline.test.ts
@@ -54,9 +54,9 @@ describe('resolveSyncHardDeadline', () => {
expect(() => resolveSyncHardDeadline(['--hard-deadline', '0'], { isTty: true })).toThrow();
});
- test('--timeout (single-source) auto-arms the hard backstop', () => {
+ test('--timeout (single-source) auto-arms the hard backstop one grace window after the timeout', () => {
const r = resolveSyncHardDeadline(['--source', 'briefings', '--timeout', '480'], { isTty: false });
- expect(r).toEqual({ deadlineMs: 480_000, graceMs: GRACE_MS, reason: 'flag:--timeout' });
+ expect(r).toEqual({ deadlineMs: 480_000 + GRACE_MS, graceMs: GRACE_MS, reason: 'flag:--timeout' });
});
test('--timeout + --all does NOT auto-arm (per-source budgets); falls through', () => {
diff --git a/test/sync-timeout-cli-dispatch.test.ts b/test/sync-timeout-cli-dispatch.test.ts
index c279686c89..d1a98876dd 100644
--- a/test/sync-timeout-cli-dispatch.test.ts
+++ b/test/sync-timeout-cli-dispatch.test.ts
@@ -43,7 +43,8 @@ describe('CLI integration: sync --timeout reaches the sync handler (#3013)', ()
// argv BEFORE connectEngine, so its stderr banner proves (a) dispatch fell
// through to the sync branch instead of dispatchReadOnlyCommand, (b) the
// handed-back --timeout was parsed with sync's SECONDS semantics (60s, not
- // the 60ms the global parser used to produce for a bare "60").
+ // the 60ms the global parser used to produce for a bare "60"); the backstop
+ // arms one 30s grace window after it (#7819), so the banner reads 90s.
const run = (args: string[]) =>
spawnSync('bun', [CLI, ...args], {
encoding: 'utf-8',
@@ -59,7 +60,7 @@ describe('CLI integration: sync --timeout reaches the sync handler (#3013)', ()
const all = `${res.stdout}\n${res.stderr}`;
expect(all).not.toContain('dispatchReadOnlyCommand');
expect(all).not.toContain('connect timed out');
- expect(res.stderr).toContain('hard deadline armed: 60s');
+ expect(res.stderr).toContain('hard deadline armed: 90s');
expect(res.stderr).toContain('(flag:--timeout)');
});
@@ -68,7 +69,7 @@ describe('CLI integration: sync --timeout reaches the sync handler (#3013)', ()
const all = `${res.stdout}\n${res.stderr}`;
expect(all).not.toContain('dispatchReadOnlyCommand');
expect(all).not.toContain('connect timed out');
- expect(res.stderr).toContain('hard deadline armed: 60s');
+ expect(res.stderr).toContain('hard deadline armed: 90s');
expect(res.stderr).toContain('(flag:--timeout)');
});
});
diff --git a/test/sync-timeout-watchdog-order.test.ts b/test/sync-timeout-watchdog-order.test.ts
new file mode 100644
index 0000000000..5125cd8c59
--- /dev/null
+++ b/test/sync-timeout-watchdog-order.test.ts
@@ -0,0 +1,42 @@
+/**
+ * #7819: the sync watchdog never stops a single-source `--timeout N` run that
+ * the in-band `--timeout` abort stops on its own.
+ *
+ * Protects: the hard-deadline backstop for `--timeout N` sits one grace window
+ * after N. The watchdog arms before connectEngine and the in-band abort after
+ * it, so a backstop at exactly N always fires first and SIGTERMs the run
+ * (exit 143, `code=sync_deadline_stop`).
+ * Fails when: the `--timeout` backstop moves back to N.
+ * Seam: a plain-directory source large enough that its import outlasts the
+ * timeout, through the real CLI.
+ */
+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { runCli } from './helpers/cli-spawn.ts';
+import { writeLargeWorktree } from './helpers/large-worktree.ts';
+
+const KEYS = { OPENAI_API_KEY: undefined, ANTHROPIC_API_KEY: undefined, VOYAGE_API_KEY: undefined };
+
+let dir: string;
+beforeAll(() => { dir = mkdtempSync(join(tmpdir(), 'gbrain-sync-timeout-watchdog-')); });
+afterAll(() => rmSync(dir, { recursive: true, force: true }));
+
+describe('sync --timeout (CLI)', () => {
+ test('the in-band --timeout stop lands before the watchdog backstop', async () => {
+ const home = join(dir, 'home');
+ const notes = join(dir, 'notes');
+ writeLargeWorktree(notes, 3000);
+ const init = await runCli(['init', '--pglite', '--no-embedding'], { home, env: KEYS, timeoutMs: 120_000 });
+ expect(init.exitCode, init.stderr).toBe(0);
+ const add = await runCli(['sources', 'add', 'source-a', '--path', notes, '--force'], { home, env: KEYS, timeoutMs: 120_000 });
+ expect(add.exitCode, add.stderr).toBe(0);
+
+ const sync = await runCli(['sync', '--source', 'source-a', '--no-embed', '--timeout', '2'], { home, env: KEYS, timeoutMs: 120_000 });
+ expect(sync.stdout).not.toContain('sync_deadline_stop');
+ expect(sync.stderr).not.toContain('[sync-watchdog] deadline reached');
+ expect(sync.exitCode, `${sync.stdout.slice(-2000)}\n${sync.stderr.slice(-2000)}`).not.toBe(143);
+ expect(sync.stderr).toContain('hard deadline armed: 32s');
+ }, 300_000);
+});