Skip to content

fix(qa): stop live threads after their process leader exits - #147386

Merged
vincentkoc merged 2 commits into
mainfrom
fix/qa-leader-thread-liveness
Sep 13, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/qa-leader-thread-liveness

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Closes #147385

What Problem This Solves

Fixes: QA teardown can report a threaded process as stopped after its main thread exits, while another thread in the owned process group is still running.

User Impact

QA cleanup now retains responsibility for surviving worker threads and terminates the actual group before reporting success. Existing signal targets, timeout allowances, and non-Linux behavior are unchanged.

Why This Change Was Made

A Linux zombie leader does not by itself prove that its entire process has exited. Group inspection now uses the existing conservative SDK PID-death check, including its thread-count and unknown-status handling, instead of duplicating a weaker state-only rule.

Production: +10/-6 (net +4); tests: +55/-15. The added parameter connects the group owner to the canonical liveness contract. No SDK surface, new process tracker, or timeout increase is introduced.

Evidence

The corrected test mock additionally passed all 17 process-group tests and the repository extension test-type lane on Linux/Node 24.19.0. Fresh scoped autoreview and independent review found no actionable issue. Production source blobs and the independently verified real-process GREEN proof are unchanged.

  • The three focused process-group, command-settlement, and Gateway-lifecycle files passed on Linux/Node 24.19.0, using the repository wrapper and a frozen pnpm installation.
  • The original real-entrypoint repro used a detached C child with a live worker holding a touched 4 MiB allocation after the main thread called pthread_exit. Before the fix, liveness returned false and cleanup returned confirmed-stopped while an independent group pidfd still showed the worker alive.
  • With the fix, the same bounded scenario reports liveness true; production cleanup terminates the group with SIGTERM, and the immediate independent pidfd witness confirms completion before fixture fallback cleanup. The named case passes, child close is recorded, and the temporary test overlay is restored.
  • The original repro and repaired run use different source freezes. The four affected owner/SDK files before the patch are byte-identical between them. Repaired checks executed the candidate bytes on base b9a099e0a5fdaa8c14914da1c5c0d2797b223912; those bytes match signed commit eb96738d5c2a0138f595af4fcc73225a0c9329e5.
  • Independent source review and scoped P0–P2 autoreview found no actionable issue. Targeted formatting and git diff --check pass. Hosted exact-head CI and native maintainer qualification are pending.

The separately observed stateless RSS=0 reporting defect remains outside this PR. This proof does not establish ordinary incidence or a released-version boundary.

Use the canonical PID-death check so a zombie Linux leader with surviving threads retains the process-group cleanup obligation. Preserve unknown-status and existing signal behavior.

Closes #147385
@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The test-only correction removes an invalid TypeScript namespace access; the 17 focused group tests and extension test-type lane passed. Production source and real process cleanup proof are unchanged. Please review current head 45262f69fe5cdb15735bd4b050dc4f0bef6b3bd1.

@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 5:02 PM ET / 21:02 UTC.

ClawSweeper review

What this changes

QA cleanup now uses the shared PID-death check to retain responsibility for Linux worker threads that survive their process leader.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main and the latest release retain the weaker liveness check. The corrected mock resolves the reported TypeScript issue without changing production behavior, and no actionable patch defect was found.

Priority: P2
Reviewed head: 45262f69fe5cdb15735bd4b050dc4f0bef6b3bd1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair reuses the established owner contract, with relevant real-process evidence and no remaining actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied Linux real-process observations exercise group inspection and Gateway child cleanup with a surviving worker, then show SIGTERM and independent pidfd completion before fixture cleanup; the verified follow-up changes only the test mock.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied Linux real-process observations exercise group inspection and Gateway child cleanup with a surviving worker, then show SIGTERM and independent pidfd completion before fixture cleanup; the verified follow-up changes only the test mock.
Evidence reviewed 8 items Production owner and shared contract: Group inspection delegates member death decisions to the existing process-runtime SDK export. The underlying helper requires zombie state plus exactly one remaining thread, and preserves liveness when status is unavailable. No SDK API is added or changed.
Cleanup reaches the repaired decision: Gateway child cleanup consults group liveness before SIGTERM and during termination confirmation; command settlement consumes the same group helper. Existing signal targets and timeout budgets remain unchanged.
Follow-up correction verified: GitHub's exact-head commit patch contains only the test mock change from spreading actual.default to spreading actual. This preserves named and default fs mocks while avoiding the invalid namespace property access; production files are unchanged by this follow-up.
Findings None None.
Security None None.

How this fits together

QA Lab starts and stops isolated Gateway and command processes. Its process-group inspection determines whether cleanup must continue before reporting completion.

flowchart TD
  A[QA child process group] --> B[Linux process snapshot]
  B --> C[Filter group members]
  C --> D[Shared PID and thread check]
  D --> E{Any member still alive?}
  E -->|Yes or uncertain| F[Continue group cleanup]
  E -->|No| G[Report stopped]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +40. Total +44 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 6 +4
Tests 1 55 15 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 65 21 +44

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #147385
Summary: This PR is the cleanup fix candidate; the related RSS work has a separate measurement owner.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep Linux process-group cleanup tied to the shared conservative PID-death contract, with RSS availability handled separately.

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

Yes. A Linux child whose leader calls pthread_exit while a worker survives exposes the state-only check on current main; the supplied report exercises the actual cleanup entrypoint. This read-only review did not rerun it.

Is this the best way to solve the issue?

Yes. Reusing the existing thread-aware PID check removes the weaker duplicate rule without expanding the SDK, changing signal targets, or increasing timeouts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a demonstrated Linux QA cleanup edge case with limited scope and no established ordinary-user or released-version incidence.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied Linux real-process observations exercise group inspection and Gateway child cleanup with a surviving worker, then show SIGTERM and independent pidfd completion before fixture cleanup; the verified follow-up changes only the test mock.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Linux real-process observations exercise group inspection and Gateway child cleanup with a surviving worker, then show SIGTERM and independent pidfd completion before fixture cleanup; the verified follow-up changes only the test mock.

Label justifications:

  • P2: This repairs a demonstrated Linux QA cleanup edge case with limited scope and no established ordinary-user or released-version incidence.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Linux real-process observations exercise group inspection and Gateway child cleanup with a surviving worker, then show SIGTERM and independent pidfd completion before fixture cleanup; the verified follow-up changes only the test mock.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Linux real-process observations exercise group inspection and Gateway child cleanup with a surviving worker, then show SIGTERM and independent pidfd completion before fixture cleanup; the verified follow-up changes only the test mock.

Evidence

What I checked:

  • Production owner and shared contract: Group inspection delegates member death decisions to the existing process-runtime SDK export. The underlying helper requires zombie state plus exactly one remaining thread, and preserves liveness when status is unavailable. No SDK API is added or changed. (extensions/qa-lab/src/posix-process-group.ts:37, 45262f69fe5c)
  • Cleanup reaches the repaired decision: Gateway child cleanup consults group liveness before SIGTERM and during termination confirmation; command settlement consumes the same group helper. Existing signal targets and timeout budgets remain unchanged. (extensions/qa-lab/src/gateway-child-process.ts:229, 45262f69fe5c)
  • Follow-up correction verified: GitHub's exact-head commit patch contains only the test mock change from spreading actual.default to spreading actual. This preserves named and default fs mocks while avoiding the invalid namespace property access; production files are unchanged by this follow-up. (extensions/qa-lab/src/posix-process-group.test.ts:19, 45262f69fe5c)
  • Still needed on current main: Fetched main still classifies every Z or X group member as stopped based solely on the stat snapshot. It does not consult the shared thread-aware death check. (extensions/qa-lab/src/posix-process-stat.ts:59, edde862d16b2)
  • Latest release comparison: The supplied latest release, v2026.9.4, also contains the state-only group check, so this repair is not already present there. (extensions/qa-lab/src/posix-process-stat.ts:59, 3a9d69db306c)
  • Real-process proof and re-review context: The captured PR body reports a Linux/Node 24.19.0 detached C child whose leader calls pthread_exit while a worker survives. Before the repair, production cleanup reported confirmed-stopped while an independent group pidfd remained pending; afterward, liveness was true, SIGTERM stopped the group, and pidfd completion preceded fixture cleanup. The maintainer's follow-up reports 17 passing group tests and the extension test-type lane. These are supplied observations, not executions performed during this review. (eb96738d5c2a)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@vincentkoc
vincentkoc merged commit dedbaa0 into main Sep 13, 2026
112 checks passed
@vincentkoc
vincentkoc deleted the fix/qa-leader-thread-liveness branch September 13, 2026 21:11
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Sep 13, 2026
…1-prep

* commit '912ae8d96e5964dfdcdf419b79613fb941cdf0a8': (350 commits)
  fix: keep workspace preparation responsive during cleanup (openclaw#147358)
  docs: alphabetize donors and sponsors and add Red Hat logo (openclaw#147302)
  fix(plugins): retain update authority through doctor effects (openclaw#144316)
  refactor(qa): share Multipass mount retry lifecycle (openclaw#147084)
  fix(memory): emit one JSON result for command failures (openclaw#147366)
  improve(plugins): speed up cold metadata loading (openclaw#147411)
  fix(sessions): avoid duplicate work after waited child replies (openclaw#147394)
  fix(agents): retain outstanding child results in parent context (openclaw#112623)
  test: preserve native workflow loader selection (openclaw#147403)
  fix: reduce repeated work while polling session pull requests (openclaw#147373)
  test(qa): preserve task cancellation across process replacement (openclaw#147382)
  fix: prevent sidebar refresh storms during session activity (openclaw#147400)
  refactor: simplify skills CLI formatting (openclaw#147368)
  fix: prevent Git checkout certificate failures behind egress proxy (openclaw#147410)
  fix(qa): stop live threads after their process leader exits (openclaw#147386)
  refactor(release): share agent turn retry lifecycle (openclaw#147076)
  fix(ui): keep uploaded images aligned with their prompts (openclaw#147389)
  fix(fs): guard skill reads and bound worker bundle staging (openclaw#147336)
  fix(ci): restore Linux service ownership fixtures (openclaw#147398)
  fix(plugins): preserve manifest permissions when building plugins (openclaw#147393)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…#147386)

* fix(qa): stop live threads after their process leader exits

Use the canonical PID-death check so a zombie Linux leader with surviving threads retains the process-group cleanup obligation. Preserve unknown-status and existing signal behavior.

Closes openclaw#147385

* test(qa): preserve typed fs namespace in default mock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: qa-lab maintainer Maintainer-authored PR 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: S 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.

Bug: QA cleanup reports live worker threads as stopped after leader exit

1 participant