Skip to content

fix(process): use monotonic clock for orphaned process-tree reap grace deadline - #181335

Merged
steipete merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/orphaned-process-reap-grace-deadline-monotonic-213
Oct 23, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/orphaned-process-reap-grace-deadline-monotonic-213

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a worker/sandbox environment exits, reapOrphanedProcesses clears its orphaned process tree. A child that ignores SIGTERM is escalated to SIGKILL after a 5-second grace window — but that window is measured on the wall clock. If the wall clock steps backward during teardown (NTP correction, VM or laptop resume), the escalation is delayed by the length of the step, so the stuck child stays alive for 5s + step instead of 5s. This change keeps the reap grace deadline on the monotonic clock.

  • Problem: waitForExit seeds and compares its 5s grace deadline with Date.now() (wall clock), while sleepWithAbort consumes the remaining budget through setTimeout (monotonic). A backward wall-clock step during teardown inflates the grace window, delaying the SIGKILL escalation of a child that ignores SIGTERM; a forward step escalates early.
  • Solution: use performance.now() for the deadline seed, the exit-condition comparison, and the remaining-budget calculation. performance.now() is monotonic and unaffected by wall-clock adjustments.
  • What changed: src/process/orphaned-process.ts — the waitForExit grace deadline now lives entirely on the monotonic clock (3 lines). src/process/orphaned-process.test.ts — a regression test that rewinds the wall clock mid-teardown and asserts the SIGKILL escalation stays bounded at 5s.
  • What did NOT change: no parser, policy branch, or configuration surface; no behavior change on a normal clock. The sleepWithAbort consumer is untouched — resolveSleepDelayMs already floors internally, so no Math.floor is needed here.

Why This Change Was Made

reapOrphanedProcesses is the canonical owner of the orphaned-process-tree reap grace deadline, so the fix lives there rather than at call sites. This is the same cross-clock-domain pattern already fixed for command process-group teardown in #174151 (exec-spawn.ts / exec-termination.ts); orphaned-process.ts waitForExit is the sibling site in the same module that was left on the wall clock. Node 16+ exposes a global performance, so no import is required.

User Impact

Environment exit and resource reclamation are no longer delayed or spuriously accelerated by wall-clock adjustments. An orphaned child that ignores SIGTERM is always force-killed after a bounded 5s monotonic grace window, regardless of NTP corrections or machine resume.

Evidence

Pre-fix RED — source reverted to Date.now(), regression test kept: the 60s wall rewind inflates the grace window, tree never reaped in 5s monotonic, test times out at 120s.

$ npx vitest run src/process/orphaned-process.test.ts
 × keeps SIGKILL escalation bounded when the wall clock rewinds  120079ms  (timed out 120000ms)
 Test Files  1 failed | Tests  1 failed | 21 passed (22)

Post-fix GREEN — with performance.now(), same test completes in 56ms, suite 22/22.

$ npx vitest run src/process/orphaned-process.test.ts
 ✓ keeps SIGKILL escalation bounded when the wall clock rewinds  56ms
 Test Files  1 passed | Tests  22 passed (22)

Behavior matrix (wall rewound 60s during teardown, child ignores SIGTERM):

clock during teardown      => SIGKILL escalation      => result
normal (no step)            => after 5s grace          => bounded
wall rewind 60s (pre-fix)   => after 5s + 60s (hangs)  => delayed by step
wall rewind 60s (post-fix)  => after 5s grace          => bounded

Regression test uses #174151's two-clock separation: vi.setSystemTime(Date.now() - 60_000) rewinds only wall clock; performance.now() keeps advancing on the fake-timer clock.

macOS real-behavior proof (single continuous capture) — GHA macos-14 arm64, through the shipped recoverManagedLlamaServer (extensions/llama-cpp) entry: real managed llama-server asset at its pinned install path (root PPID=1), TERM-resistant descendant, real native inspection + real process.kill. 60s wall-clock rollback injected at the remaining-budget read (CI pins clock via NTP; monotonic clock + transport stay real). Full run: oc-macos-proof run 39908934594.

===== CASE: FIXED (wall jump -60000ms) =====
[DIAG] platform=darwin arch=arm64 state_dir=/tmp/llama-state
[DIAG] findManagedLlamaServerAsset(command) => llama-b10809-bin-macos-arm64.tar.gz
[FIXED] before recovery: 4964  1 /tmp/llama-state/tools/llama.cpp/b10809/darwin-arm64/llama-server
[llama-cpp] reaping orphaned managed llama-server: pid=4964 port=19321
[FIXED] recoverManagedLlamaServer returned elapsed_monotonic=5634ms root_alive_after=false
VERDICT[FIXED] wall_jump=-60000ms elapsed_monotonic=5634ms reaped_root=4964 root_alive_after=false
PROOF PASS: FIXED escalated to SIGKILL in ~5s monotonic under wall-clock rollback

===== CASE: OLD (wall jump -60000ms) =====
[DIAG] platform=darwin arch=arm64 state_dir=/tmp/llama-state
[DIAG] findManagedLlamaServerAsset(command) => llama-b10809-bin-macos-arm64.tar.gz
[OLD] before recovery: 5509  1 /tmp/llama-state/tools/llama.cpp/b10809/darwin-arm64/llama-server
[llama-cpp] reaping orphaned managed llama-server: pid=5509 port=19321
[OLD] recoverManagedLlamaServer returned elapsed_monotonic=65290ms root_alive_after=false
VERDICT[OLD] wall_jump=-60000ms elapsed_monotonic=65290ms reaped_root=5509 root_alive_after=false
PROOF EXPECTED-OLD: OLD delayed SIGKILL by ~|rollback| (bug reproduced on real tree)
variant deadline clock SIGKILL escalation (rollback −60s)
OLD (pre-fix) Date.now() 65.29s = 5s grace + 60s rollback
FIXED (this PR) performance.now() 5.63s = bounded grace

Real managed-service recovery on a real macOS orphan tree, matching already-landed sibling #174151.

Open PR collision check: no open/merged PR touches orphaned-process.ts clock domain; sibling #174151 landed for exec-spawn.ts/exec-termination.ts, no overlap.

…e deadline

Ref: BUG-213-orphaned-process-reap-grace-deadline-wall-clock (local finding)
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR measures orphaned-process cleanup grace periods with a monotonic clock.

Example: A managed macOS process ignores SIGTERM while the wall clock moves backward by 60 seconds.

  • Before: SIGKILL escalation takes about 65 seconds.
  • After: SIGKILL escalation remains near the intended 5-second grace period.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair supported by real native-process proof through a production-owner harness.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied macOS output and inspected successful workflow exercise recoverManagedLlamaServer and the real orphan reaper against a native launchd-adopted process fixture, showing roughly 5.6-second fixed cleanup versus 65.3 seconds with rollback-sensitive reads; raw hosted logs were inaccessible from this review environment.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Managed llama.cpp recovery can wait an extra wall-clock offset before killing a stuck orphan, delaying resource reclamation.
Reason: The change restores the existing bounded-grace contract without adding configuration, APIs, or policy.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it fixes a current process-cleanup timing defect with a focused change and no actionable findings.

Priority: P2
Reviewed head: 5b2d5acbd4ebe05f80cfb70f2bdf81462d4ab170

Before merge

None.

Findings

None.

Agent review details

How this fits together

Managed llama.cpp recovery passes executable and argument identity into the shared orphan reaper, which captures matching processes, validates their identities, and sends termination signals.

flowchart TD
 A[Managed llama.cpp acquisition] --> B[Managed server recovery]
 B --> C[Capture matching orphan tree]
 C --> D[Validate identity and send SIGTERM]
 D --> E[Monotonic grace deadline]
 E --> F[Revalidate survivors and send SIGKILL]
Loading

Technical review

Best possible solution:

Land the focused clock replacement in the existing orphan-recovery owner with its regression coverage.

Do we have a high-confidence way to reproduce the issue?

The current-main deadline arithmetic establishes the failure path, supported by contributor-supplied red/green tests and real macOS process-recovery output; no target code was executed during this review.

Is this the best way to solve the issue?

This is the smallest complete fix: keep deadline creation, comparison, and remaining-budget calculation on one monotonic clock without changing recovery ownership or signaling safeguards.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e78d8fcab266.

Provenance checked

  • Orphan-tree shutdown grace deadline keeps the original intent (a0197f4: Recover matching managed macOS orphans safely, with five-second TERM and exit-confirmation waits.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a0197f4 adds src/process/orphaned-process.ts:193 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a0197f4921be; files: src/process/orphaned-process.ts)

PR surface

Source 0, Tests +27. Total +27 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 3 0
Tests 1 27 0 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 30 3 +27

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Clock adjustments can delay or prematurely escalate managed-process cleanup, with limited scope to this recovery path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-23T05:02:56.882Z sha 5b2d5ac :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-23T05:44:06.305Z sha 5b2d5ac :: needs maintainer review before merge. :: none

Reviewed October 23, 2026, 2:12 AM ET / 06:12 UTC (Revision 3).

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 23, 2026
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review.

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 23, 2026
@steipete
steipete merged commit f9a17a7 into openclaw:main Oct 23, 2026
192 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@steipete Thanks!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…e deadline (openclaw#181335)

## What Problem This Solves

When a worker/sandbox environment exits, `reapOrphanedProcesses` clears its orphaned process tree. A child that ignores `SIGTERM` is escalated to `SIGKILL` after a 5-second grace window — but that window is measured on the wall clock. If the wall clock steps backward during teardown (NTP correction, VM or laptop resume), the escalation is delayed by the length of the step, so the stuck child stays alive for `5s + step` instead of `5s`. This change keeps the reap grace deadline on the monotonic clock.

- **Problem**: `waitForExit` seeds and compares its 5s grace deadline with `Date.now()` (wall clock), while `sleepWithAbort` consumes the remaining budget through `setTimeout` (monotonic). A backward wall-clock step during teardown inflates the grace window, delaying the `SIGKILL` escalation of a child that ignores `SIGTERM`; a forward step escalates early.
- **Solution**: use `performance.now()` for the deadline seed, the exit-condition comparison, and the remaining-budget calculation. `performance.now()` is monotonic and unaffected by wall-clock adjustments.
- **What changed**: `src/process/orphaned-process.ts` — the `waitForExit` grace deadline now lives entirely on the monotonic clock (3 lines). `src/process/orphaned-process.test.ts` — a regression test that rewinds the wall clock mid-teardown and asserts the `SIGKILL` escalation stays bounded at 5s.
- **What did NOT change**: no parser, policy branch, or configuration surface; no behavior change on a normal clock. The `sleepWithAbort` consumer is untouched — `resolveSleepDelayMs` already floors internally, so no `Math.floor` is needed here.

## Why This Change Was Made

`reapOrphanedProcesses` is the canonical owner of the orphaned-process-tree reap grace deadline, so the fix lives there rather than at call sites. This is the same cross-clock-domain pattern already fixed for command process-group teardown in openclaw#174151 (`exec-spawn.ts` / `exec-termination.ts`); `orphaned-process.ts` `waitForExit` is the sibling site in the same module that was left on the wall clock. Node 16+ exposes a global `performance`, so no import is required.

## User Impact

Environment exit and resource reclamation are no longer delayed or spuriously accelerated by wall-clock adjustments. An orphaned child that ignores `SIGTERM` is always force-killed after a bounded 5s monotonic grace window, regardless of NTP corrections or machine resume.

## Evidence

**Pre-fix RED** — source reverted to `Date.now()`, regression test kept: the 60s wall rewind inflates the grace window, tree never reaped in 5s monotonic, test times out at 120s.

```console
$ npx vitest run src/process/orphaned-process.test.ts
 × keeps SIGKILL escalation bounded when the wall clock rewinds  120079ms  (timed out 120000ms)
 Test Files  1 failed | Tests  1 failed | 21 passed (22)
```

**Post-fix GREEN** — with `performance.now()`, same test completes in 56ms, suite 22/22.

```console
$ npx vitest run src/process/orphaned-process.test.ts
 ✓ keeps SIGKILL escalation bounded when the wall clock rewinds  56ms
 Test Files  1 passed | Tests  22 passed (22)
```

**Behavior matrix** (wall rewound 60s during teardown, child ignores `SIGTERM`):

```text
clock during teardown      => SIGKILL escalation      => result
normal (no step)            => after 5s grace          => bounded
wall rewind 60s (pre-fix)   => after 5s + 60s (hangs)  => delayed by step
wall rewind 60s (post-fix)  => after 5s grace          => bounded
```

**Regression test** uses openclaw#174151's two-clock separation: `vi.setSystemTime(Date.now() - 60_000)` rewinds only wall clock; `performance.now()` keeps advancing on the fake-timer clock.

**macOS real-behavior proof (single continuous capture)** — GHA `macos-14` arm64, through the shipped `recoverManagedLlamaServer` (`extensions/llama-cpp`) entry: real managed llama-server asset at its pinned install path (root PPID=1), TERM-resistant descendant, real native inspection + real `process.kill`. 60s wall-clock rollback injected at the remaining-budget read (CI pins clock via NTP; monotonic clock + transport stay real). Full run: [oc-macos-proof run 39908934594](https://github.com/SunnyShu0925/oc-macos-proof/actions/runs/39908934594).

```console
===== CASE: FIXED (wall jump -60000ms) =====
[DIAG] platform=darwin arch=arm64 state_dir=/tmp/llama-state
[DIAG] findManagedLlamaServerAsset(command) => llama-b10809-bin-macos-arm64.tar.gz
[FIXED] before recovery: 4964  1 /tmp/llama-state/tools/llama.cpp/b10809/darwin-arm64/llama-server
[llama-cpp] reaping orphaned managed llama-server: pid=4964 port=19321
[FIXED] recoverManagedLlamaServer returned elapsed_monotonic=5634ms root_alive_after=false
VERDICT[FIXED] wall_jump=-60000ms elapsed_monotonic=5634ms reaped_root=4964 root_alive_after=false
PROOF PASS: FIXED escalated to SIGKILL in ~5s monotonic under wall-clock rollback

===== CASE: OLD (wall jump -60000ms) =====
[DIAG] platform=darwin arch=arm64 state_dir=/tmp/llama-state
[DIAG] findManagedLlamaServerAsset(command) => llama-b10809-bin-macos-arm64.tar.gz
[OLD] before recovery: 5509  1 /tmp/llama-state/tools/llama.cpp/b10809/darwin-arm64/llama-server
[llama-cpp] reaping orphaned managed llama-server: pid=5509 port=19321
[OLD] recoverManagedLlamaServer returned elapsed_monotonic=65290ms root_alive_after=false
VERDICT[OLD] wall_jump=-60000ms elapsed_monotonic=65290ms reaped_root=5509 root_alive_after=false
PROOF EXPECTED-OLD: OLD delayed SIGKILL by ~|rollback| (bug reproduced on real tree)
```

| variant | deadline clock | SIGKILL escalation (rollback −60s) |
|---|---|---|
| OLD (pre-fix) | `Date.now()` | **65.29s** = 5s grace + 60s rollback |
| FIXED (this PR) | `performance.now()` | **5.63s** = bounded grace |

Real managed-service recovery on a real macOS orphan tree, matching already-landed sibling openclaw#174151.

**Open PR collision check**: no open/merged PR touches `orphaned-process.ts` clock domain; sibling openclaw#174151 landed for `exec-spawn.ts`/`exec-termination.ts`, no overlap.

Co-authored-by: SunnyShu <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…e deadline (#181335)

## What Problem This Solves

When a worker/sandbox environment exits, `reapOrphanedProcesses` clears its orphaned process tree. A child that ignores `SIGTERM` is escalated to `SIGKILL` after a 5-second grace window — but that window is measured on the wall clock. If the wall clock steps backward during teardown (NTP correction, VM or laptop resume), the escalation is delayed by the length of the step, so the stuck child stays alive for `5s + step` instead of `5s`. This change keeps the reap grace deadline on the monotonic clock.

- **Problem**: `waitForExit` seeds and compares its 5s grace deadline with `Date.now()` (wall clock), while `sleepWithAbort` consumes the remaining budget through `setTimeout` (monotonic). A backward wall-clock step during teardown inflates the grace window, delaying the `SIGKILL` escalation of a child that ignores `SIGTERM`; a forward step escalates early.
- **Solution**: use `performance.now()` for the deadline seed, the exit-condition comparison, and the remaining-budget calculation. `performance.now()` is monotonic and unaffected by wall-clock adjustments.
- **What changed**: `src/process/orphaned-process.ts` — the `waitForExit` grace deadline now lives entirely on the monotonic clock (3 lines). `src/process/orphaned-process.test.ts` — a regression test that rewinds the wall clock mid-teardown and asserts the `SIGKILL` escalation stays bounded at 5s.
- **What did NOT change**: no parser, policy branch, or configuration surface; no behavior change on a normal clock. The `sleepWithAbort` consumer is untouched — `resolveSleepDelayMs` already floors internally, so no `Math.floor` is needed here.

## Why This Change Was Made

`reapOrphanedProcesses` is the canonical owner of the orphaned-process-tree reap grace deadline, so the fix lives there rather than at call sites. This is the same cross-clock-domain pattern already fixed for command process-group teardown in #174151 (`exec-spawn.ts` / `exec-termination.ts`); `orphaned-process.ts` `waitForExit` is the sibling site in the same module that was left on the wall clock. Node 16+ exposes a global `performance`, so no import is required.

## User Impact

Environment exit and resource reclamation are no longer delayed or spuriously accelerated by wall-clock adjustments. An orphaned child that ignores `SIGTERM` is always force-killed after a bounded 5s monotonic grace window, regardless of NTP corrections or machine resume.

## Evidence

**Pre-fix RED** — source reverted to `Date.now()`, regression test kept: the 60s wall rewind inflates the grace window, tree never reaped in 5s monotonic, test times out at 120s.

```console
$ npx vitest run src/process/orphaned-process.test.ts
 × keeps SIGKILL escalation bounded when the wall clock rewinds  120079ms  (timed out 120000ms)
 Test Files  1 failed | Tests  1 failed | 21 passed (22)
```

**Post-fix GREEN** — with `performance.now()`, same test completes in 56ms, suite 22/22.

```console
$ npx vitest run src/process/orphaned-process.test.ts
 ✓ keeps SIGKILL escalation bounded when the wall clock rewinds  56ms
 Test Files  1 passed | Tests  22 passed (22)
```

**Behavior matrix** (wall rewound 60s during teardown, child ignores `SIGTERM`):

```text
clock during teardown      => SIGKILL escalation      => result
normal (no step)            => after 5s grace          => bounded
wall rewind 60s (pre-fix)   => after 5s + 60s (hangs)  => delayed by step
wall rewind 60s (post-fix)  => after 5s grace          => bounded
```

**Regression test** uses #174151's two-clock separation: `vi.setSystemTime(Date.now() - 60_000)` rewinds only wall clock; `performance.now()` keeps advancing on the fake-timer clock.

**macOS real-behavior proof (single continuous capture)** — GHA `macos-14` arm64, through the shipped `recoverManagedLlamaServer` (`extensions/llama-cpp`) entry: real managed llama-server asset at its pinned install path (root PPID=1), TERM-resistant descendant, real native inspection + real `process.kill`. 60s wall-clock rollback injected at the remaining-budget read (CI pins clock via NTP; monotonic clock + transport stay real). Full run: [oc-macos-proof run 39908934594](https://github.com/SunnyShu0925/oc-macos-proof/actions/runs/39908934594).

```console
===== CASE: FIXED (wall jump -60000ms) =====
[DIAG] platform=darwin arch=arm64 state_dir=/tmp/llama-state
[DIAG] findManagedLlamaServerAsset(command) => llama-b10809-bin-macos-arm64.tar.gz
[FIXED] before recovery: 4964  1 /tmp/llama-state/tools/llama.cpp/b10809/darwin-arm64/llama-server
[llama-cpp] reaping orphaned managed llama-server: pid=4964 port=19321
[FIXED] recoverManagedLlamaServer returned elapsed_monotonic=5634ms root_alive_after=false
VERDICT[FIXED] wall_jump=-60000ms elapsed_monotonic=5634ms reaped_root=4964 root_alive_after=false
PROOF PASS: FIXED escalated to SIGKILL in ~5s monotonic under wall-clock rollback

===== CASE: OLD (wall jump -60000ms) =====
[DIAG] platform=darwin arch=arm64 state_dir=/tmp/llama-state
[DIAG] findManagedLlamaServerAsset(command) => llama-b10809-bin-macos-arm64.tar.gz
[OLD] before recovery: 5509  1 /tmp/llama-state/tools/llama.cpp/b10809/darwin-arm64/llama-server
[llama-cpp] reaping orphaned managed llama-server: pid=5509 port=19321
[OLD] recoverManagedLlamaServer returned elapsed_monotonic=65290ms root_alive_after=false
VERDICT[OLD] wall_jump=-60000ms elapsed_monotonic=65290ms reaped_root=5509 root_alive_after=false
PROOF EXPECTED-OLD: OLD delayed SIGKILL by ~|rollback| (bug reproduced on real tree)
```

| variant | deadline clock | SIGKILL escalation (rollback −60s) |
|---|---|---|
| OLD (pre-fix) | `Date.now()` | **65.29s** = 5s grace + 60s rollback |
| FIXED (this PR) | `performance.now()` | **5.63s** = bounded grace |

Real managed-service recovery on a real macOS orphan tree, matching already-landed sibling #174151.

**Open PR collision check**: no open/merged PR touches `orphaned-process.ts` clock domain; sibling #174151 landed for `exec-spawn.ts`/`exec-termination.ts`, no overlap.

Co-authored-by: SunnyShu <[email protected]>

(cherry picked from commit f9a17a7)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants