Skip to content

fix(qa): settle Unix commands after PGID cleanup - #120010

Merged
RomneyDa merged 1 commit into
mainfrom
fix/qa-command-settlement-pgid-20260806
Aug 8, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/qa-command-settlement-pgid-20260806

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Related: #119396

Problem and root cause

The maturity run on main wrote the Docker scheduler result, but the QA parent did not settle before the workflow supervisor terminated it at 04:29:37 with exit 124 (run 31141527327). The 04:11:40 summary-write timestamp comes from the captured reproduction evidence; the job log independently confirms the later supervisor timeout.

The architectural owner was the QA command lifecycle. It listened only for Node's close event, while Node explicitly permits exit before inherited stdio closes and emits close only after the process ends and all stdio closes. A descendant retaining inherited pipes therefore prevented close, so original-PGID cleanup never began. The Docker batch intentionally has no per-command timeout because its scheduler/workflow owns the aggregate deadline, making this an unbounded parent wait.

Dependency contract: Node exit, Node close, and detached process groups.

Canonical fix

QA Lab now has one settlement owner shared by test-file scenarios, suite CLI execution, and Matrix scenario CLI execution:

  • freeze the primary terminal result on exit, timeout, manual cleanup, parent signal, spawn error, or stream error;
  • bound inherited-stdio draining for every terminal path, then clean the original PGID with TERM/grace/KILL/verification;
  • signal negative PGIDs only, with Linux /proc inspection treating zombie/dead-only groups as stopped;
  • settle only after cleanup and drain completion, preserving the leader result and tail output;
  • preserve a stdout/stderr failure that arrives after the frozen primary result as a secondary settlement failure;
  • turn any cleanup failure into a failing scenario result and retain both the command failure and cleanup failure;
  • reuse the gateway's existing zombie-aware inspection policy without changing gateway stop behavior.

This also implements both ClawSweeper review cycles: a nonzero suite CLI exit is no longer discarded when cleanup fails, and a post-exit stream failure is retained by the shared outcome and rejected by Matrix. Focused regressions cover both event orderings.

CI failure classification

The previous check-lint failure was PR-caused: five typescript(unbound-method) findings in posix-command-settlement.test.ts. The tests now retain and assert bound spies. openclaw/ci-gate was only the derived failure. Previous production and test typechecks passed; the related maturity timeout was on main, not PR CI.

Proof

  • Final head: 83a0756121d75a0b5c6120f6701e17461c59091f
  • Rebased base at push: 74500f334ed147bd9ac23abb7e3b0cd36f49d124
  • Linux changed gate: run 31160868189, Testbox tbx_01kzdmjzq74m9bxbvftxmpe0f7: formatting, production/test types, full 245-rule changed-file lint (0 warnings/errors), dependency/boundary/dead-code/import-cycle guards all passed.
  • Linux behavior: run 31161463491, Testbox tbx_01kzdn32gw5kym7gjepnsx220e: 53/53 focused tests passed. The maturity-signature case settled in 639 ms after the leader wrote Docker scheduling finished while a live descendant retained inherited stdio.
  • The same Linux run passed live descendant TERM-to-KILL cleanup, self-detached escape reporting, parent SIGTERM cleanup/re-raise, zombie-only PGID liveness, timeout-without-close drain bounding, and nonzero-exit-plus-cleanup aggregation.
  • Exact repair-tree Linux behavior before the final conflict-free main-only rebase: run 31162887569, Testbox tbx_01kzdp8c8eqzze32h1yvc67gsg: 57/57 tests passed. The maturity-signature case settled in 675 ms, and Matrix rejected the exact exit(0) then stdout-error-before-close ordering. The one-shot lease stopped successfully.
  • Exact-final-head hosted CI: run 31163942995 passed with 118 passed/skipped checks and zero failures, including check-lint, production/test types, build, QA smoke, all Node shards, and openclaw/ci-gate.
  • Subsequent rebases were conflict-free. Exact final-head proof: 57/57 focused tests passed, including exit(0) followed by a stdout error before close; full type-aware changed-file lint, formatting, and git diff --check passed locally.
  • Final-head autoreview and secret scan: clean, no actionable findings; patch-correct score 0.98.

LOC and simplification

  • Production: +618/-485, net +133.
  • Tests: +588/-9, net +579.

The positive production delta is the canonical lifecycle/liveness boundary used by three callers. The change deletes caller-specific cleanup policy, removes the write-only cleanupFailure result field, and keeps the suite caller below its max-lines limit. Further reduction would duplicate or weaken timeout, signal, inherited-stdio, and zombie semantics.

Remaining risks

A descendant that deliberately starts a new session/process group is outside the original PGID by design. This owner bounds and reports that case but does not use unsafe positive-PID fallback signaling; the scheduler that creates detached lane PGIDs remains responsible for those groups. Windows keeps its existing task-tree behavior through the shared settlement adapter.

Rerun instructions

node scripts/run-vitest.mjs \
  extensions/qa-lab/src/posix-command-settlement.test.ts \
  extensions/qa-lab/src/posix-process-group.test.ts \
  extensions/qa-lab/src/suite-runtime-agent-process.test.ts \
  extensions/qa-lab/src/test-file-scenario-command-lifecycle.test.ts \
  extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-cli-stream-error.test.ts

node scripts/check-changed.mjs -- \
  extensions/qa-lab/src/posix-command-settlement.test.ts \
  extensions/qa-lab/src/posix-command-settlement.ts \
  extensions/qa-lab/src/posix-process-group.test.ts \
  extensions/qa-lab/src/suite-runtime-agent-process.test.ts \
  extensions/qa-lab/src/suite-runtime-agent-process.ts \
  extensions/qa-lab/src/test-file-scenario-command-lifecycle.test.ts \
  extensions/qa-lab/src/test-file-scenario-command-lifecycle.ts \
  extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-cli-stream-error.test.ts \
  extensions/qa-lab/src/live-transports/matrix/scenarios/scenario-runtime-cli.ts

Do not increase the maturity workflow timeout; rerun PR CI and then the maturity profile on the merged candidate SHA.

@vincentkoc vincentkoc self-assigned this Aug 6, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 6, 2026 17:25
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 6, 2026
@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 5:39 AM ET / 09:39 UTC.

ClawSweeper review

What this changes

The PR centralizes Unix QA child-process settlement so test-file, suite, and Matrix commands bound inherited-stream draining and clean their original process group before returning results.

Regression provenance

Possible regression — probable (failure trace; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. The PR is not on current main or the latest release, both prior P2 findings are fixed, and no new actionable patch defect was found; its maintainer label and intentional process-group ownership boundary require QA-owner handling before merge.

Priority: P2
Reviewed head: 83a0756121d75a0b5c6120f6701e17461c59091f
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong targeted process-lifecycle evidence and green exact-head CI support a clean patch, with an intentional availability boundary awaiting owner acceptance.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its supplied exact-head Linux CI and descendant-process evidence nevertheless support the claimed behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its supplied exact-head Linux CI and descendant-process evidence nevertheless support the claimed behavior.
Evidence reviewed 5 items Current main still has the reported close-only lifecycle: Current main has separate callers that settle on child close, and lacks the shared settlement module; the central behavior is not already implemented.
Shared owner covers all affected callers: The PR head adds one settlement owner and wires it into test-file, suite, and Matrix command execution, including post-exit stream-error aggregation.
Prior review findings are addressed: A nonzero suite exit remains primary when cleanup fails, while a stream error arriving after exit becomes a settlement failure that Matrix rejects; focused regressions cover both orderings.
Findings None None.
Security None None.

How this fits together

QA Lab runs child commands for scenarios and suites, then reports their terminal outcomes to schedulers and CI. This settlement layer consumes process/stream events and emits a bounded result after cleanup.

flowchart LR
  A[QA command] --> B[Child process events]
  B --> C[Shared settlement owner]
  C --> D[Bounded stream drain]
  D --> E[Original process group cleanup]
  E --> F[Scenario or suite result]
  F --> G[QA scheduler and CI]
Loading

Decision needed

Question Recommendation
Should QA Lab retain the safe original-PGID-only cleanup boundary, with deliberately session-detached descendants reported to their scheduler rather than forcibly signaled? Accept bounded PGID ownership: Merge after current-main verification, keeping detached-group cleanup with the scheduler that created those groups.

Why: The code intentionally declines unsafe positive-PID fallback signaling; choosing that process-ownership boundary is an operational QA policy decision, not a mechanical review finding.

Before merge

  • Resolve merge risk (P1) - The deliberate negative-PGID-only cleanup boundary reports, but does not forcibly signal, descendants that create a new session or process group; a QA owner must accept that scheduler-owned boundary.
  • Resolve merge risk (P1) - The branch is behind current main. GitHub reports it cleanly mergeable, so this needs an exact merge-time refresh rather than a claim that it removes main behavior.
  • Complete next step (P2) - A maintainer-owned protected PR needs QA-owner acceptance of its intentional process-group boundary and an exact current-main merge refresh.
Agent review details

Security

None.

PR surface

Source +133, Tests +579. Total +712 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 618 485 +133
Tests 5 588 9 +579
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 1206 494 +712

Review metrics

Metric Value Why it matters
Production vs test LOC production +618/-485 (net +133), tests +588/-9 (net +579) The production growth creates one shared lifecycle owner for three callers, while the larger test increase covers terminal-event and process-group orderings.

Stored data model

Persistent data-model change detected: serialized state: extensions/qa-lab/src/posix-process-group.ts, serialized state: extensions/qa-lab/src/test-file-scenario-command-lifecycle.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #120010
Summary: This PR is the canonical open implementation for command settlement; the earlier merged gateway cleanup repair shares a liveness invariant but solves a distinct lifecycle boundary.

Members:

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

Merge-risk options

Maintainer options:

  1. Refresh exact merge proof (recommended)
    Verify the clean current-main merge result and rerun focused settlement coverage if integration changes the QA lifecycle paths.
  2. Accept scheduler-owned escaped groups
    Merge with the documented negative-PGID-only behavior, leaving intentionally detached groups to their creating scheduler.

Technical review

Best possible solution:

Keep the shared settlement owner and safe negative-PGID boundary, then refresh the exact current-main merge result and focused QA lifecycle proof before merging.

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

Yes. Current-main source exposes close-only settlement, and the PR’s focused Linux scenario covers a leader exit while a descendant retains inherited stdio.

Is this the best way to solve the issue?

Yes. One shared owner removes three duplicated lifecycle implementations while preserving caller-specific Windows behavior and the established zombie-aware liveness policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2dd0e9b95046.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its supplied exact-head Linux CI and descendant-process evidence nevertheless support the claimed behavior.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The repair addresses QA scenario and CI command settlement stalls with bounded, non-core blast radius.
  • merge-risk: 🚨 availability: Timeout, signal, stream-drain, and process-group cleanup changes can affect whether QA jobs settle or stall.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is not subject to the external-contributor proof gate; its supplied exact-head Linux CI and descendant-process evidence nevertheless support the claimed behavior.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the related merged zombie-PGID repair and the current command-settlement work, giving direct feature-history context. (role: recent QA process-lifecycle contributor; confidence: high; commits: 9f8270dedc48, 83a0756121d7; files: extensions/qa-lab/src/gateway-child.ts, extensions/qa-lab/src/posix-command-settlement.ts)
  • RomneyDa: The PR timeline records the final reviewed-head update under this account, making them a relevant routing contact for the current branch state. (role: recent PR committer; confidence: medium; commits: 83a0756121d7; files: extensions/qa-lab/src/posix-command-settlement.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the exact current-main merge result and focused lifecycle proof before landing.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-06T23:35:16.844Z sha a4ce933 :: needs changes before merge. :: [P2] Preserve the CLI failure when cleanup also fails
  • reviewed 2026-08-07T08:36:33.669Z sha 9cbbb2c930a2c0a53e244ff9266bc2ed250e2c40 :: found issues before merge. :: [P2] Preserve post-exit stream failures

@RomneyDa
RomneyDa force-pushed the fix/qa-command-settlement-pgid-20260806 branch from a4ce933 to 9cbbb2c Compare August 7, 2026 08:29
@RomneyDa
RomneyDa force-pushed the fix/qa-command-settlement-pgid-20260806 branch from 9cbbb2c to e4cda65 Compare August 7, 2026 08:42
@RomneyDa

RomneyDa commented Aug 7, 2026

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Punchcard-Session: cobalt-valley-meadow-mg
@RomneyDa
RomneyDa force-pushed the fix/qa-command-settlement-pgid-20260806 branch from e4cda65 to 83a0756 Compare August 7, 2026 08:58
@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 7, 2026
@RomneyDa
RomneyDa merged commit bf0aadb into main Aug 8, 2026
140 checks passed
@RomneyDa
RomneyDa deleted the fix/qa-command-settlement-pgid-20260806 branch August 8, 2026 07:16
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
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 merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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