Skip to content

fix: declaration steps succeed with lingering subprocesses - #132070

Merged
steipete merged 1 commit into
mainfrom
steipete/strange-volhard-5ec0b5
Aug 28, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/strange-volhard-5ec0b5

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #132053.
Related: the earlier SDK timeout cleanup repair.

What Problem This Solves

Resolves a problem where declaration preparation could report success after a zero-exit leader left owned subprocesses running with ignored stdio. Preparation uses success as an artifact barrier before freshness stamps, dependent readers, and writer-lock release, so accepting unfinished work is the wrong ownership contract.

This is a confirmed process fixture, not a recurrence of the original compiler timeout leak or evidence of real declaration corruption. The installed native-preview launcher execves or synchronously joins the compiler. Zero-exit acceptance without group verification predates the timeout repair and is present in the inspected v2026.7.1 preparation code.

Why This Change Was Made

Both preparation and run-tsgo now opt into the existing strict POSIX completion verifier. They own different process groups: a controlled prep-only patch passed the prep regression but still failed the real compiler-wrapper regression. Reusing the verifier at both owners is the narrow fix; changing the shared default would affect unrelated commands and unconditionally enabling it would reject Windows before spawn.

The verifier drains leftover same-group processes and rejects with EPROCESSGROUP_CLEANUP_FAILED, rather than converting forced cleanup into success. Windows keeps its existing joined-launcher behavior. This is group verification, not recursive containment of arbitrary detached descendants.

The existing lingering-child test is reused for prep, its failure cleanup now recovers the recorded PID even when an assertion fails, and strict clean-completion coverage is correctly POSIX-only. A portable real compiler-version case protects normal wrapper execution. The completion contract and platform limits are documented in the testing reference.

Production/tooling: +4/-0 (net +4), consisting of two executable opt-ins and two ownership comments. Tests: +117/-28 (net +89). Docs: +7/-0. No new lifecycle implementation, removed runtime path, global default, configuration, dependency, timeout, grace, or resource-policy change. AI-assisted implementation and independent review.

User Impact

On POSIX, declaration/typecheck commands cannot report clean completion while their own managed group remains active. Normal compiler completion continues to work. There is no gateway runtime or channel behavior change, and no new operator setting.

The separate declaration resource-policy work, nested-timeout race investigation, and WhatsApp patch are not included or declared resolved here.

Evidence

Failing before the fix: new real-child caller regressions produced 2 failures / 2 passes with unchanged production on Node 26.7.0. Prep resolved with a descendant alive; the real run-tsgo.mjs wrapper returned zero with its compiler descendant alive. Exact fixture PIDs were recovered and cleaned after observation. With only the prep opt-in, the compiler regression still failed (1 failure / 3 passes). With both opt-ins, all four selected cases passed.

Fixed candidate: 15 focused tests across 3 files passed independently on both Node 24.20.0 and Node 26.7.0/macOS 27, covering both callers, strict helper cleanup, clean completion, disappearing-group handling, Windows pre-spawn refusal, serial preparation, timer saturation, and unchanged watchdog opt-in:

node scripts/run-vitest.mjs test/scripts/managed-child-process.test.ts test/scripts/run-tsgo.test.ts test/scripts/prepare-extension-package-boundary-artifacts.test.ts -t 'rejects and drains.*successful leader exit|runs the installed compiler version|allows bounded retry output|allows strict normal long-running|accepts a process group that vanishes|refuses strict Windows commands|leaves a completing tsgo alone|clamps oversized prep step timers|runs boundary prep steps serially|passes step-specific environment overrides|keeps the watchdog opt-in'

Standalone real-process proof on Node 24: the original fixture was copied unchanged into an isolated directory. Hardened prep rejected, reported the owned group terminated, and had zero survivors at return; its independent control stayed alive. The generic default runner still returned zero with two survivors, proving that the shared default was not changed. All exact fixture PIDs were removed afterward; that manual cleanup is not counted as baseline production cleanup.

Real compiler proof: a small declaration compile through runNodeStep -> run-tsgo.mjs -> run-tsgo.mts -> installed native-preview completed with the expected declaration bytes and nonempty build-info file present at return. No profiler or policy override was used. The installed launcher and exact Node child-process exit/close implementation were inspected directly.

Scoped gates passed, including both script and root-test typechecks through the now-strict real compiler owner, script lint, formatting, erasability, and repository guards:

node scripts/check-changed.mjs -- docs/reference/test.md scripts/prepare-extension-package-boundary-artifacts.mts scripts/run-tsgo.mts test/scripts/managed-child-process.test.ts test/scripts/run-tsgo.test.ts

Fresh isolated Codex autoreview returned scoped-clean with no accepted/actionable P0 findings. git diff --check passed.

Limits: native Windows execution and a full local SDK declaration build were not run. Windows's existing non-strict branch is preserved and its strict-refusal unit contract passed; the new real-version test is portable, not claimed as native Windows proof here. The seven nested-timeout matrix rows were deliberately excluded from the focused local run to avoid conflating the independently active race investigation with this completion-only repair. Hosted exact-head CI remains the required landing gate; no checks will be bypassed.

Fixes #132053. Verify POSIX process completion at each declaration owner before accepting success. Preserve Windows behavior without changing timeouts or shared defaults.
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: S maintainer Maintainer-authored PR labels Aug 28, 2026
@steipete
steipete marked this pull request as ready for review August 28, 2026 19:54
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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 Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 4:09 PM ET / 20:09 UTC.

ClawSweeper review

What this changes

The PR makes declaration preparation and the TypeScript compiler wrapper reject POSIX commands whose managed process group remains alive after the leader exits successfully.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No introduced correctness or security defect was found. Keep this maintainer-authored, maintainer-labeled PR open for explicit acceptance of its intentional stricter POSIX completion contract and completion of exact-head CI.

Priority: P2
Reviewed head: 6b5c4358debd0abfb204914376ae65ec5ee1e16e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned repair with credible owner-boundary coverage; the remaining requirement is maintainer acceptance of the intentional compatibility change and normal exact-head CI completion.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to the external-contributor proof gate because repository state identifies this as maintainer-authored; nevertheless, the supplied body records after-fix real process and compiler-wrapper runs, while the checked-in tests exercise both changed owner boundaries.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to the external-contributor proof gate because repository state identifies this as maintainer-authored; nevertheless, the supplied body records after-fix real process and compiler-wrapper runs, while the checked-in tests exercise both changed owner boundaries.
Evidence reviewed 6 items Introduced owner-boundary change: The PR opts the declaration-step owner into existing strict process-group verification before it can report success.
Nested compiler owner: The TypeScript wrapper separately opts in because it owns the compiler process group nested beneath preparation.
Existing strict lifecycle contract: The shared launcher rejects strict verification on Windows before spawn, then checks process-group exit after successful child completion and reports cleanup failure when it cannot verify termination.
Findings None None.
Security None None.

How this fits together

Declaration preparation launches subprocesses to build plugin boundary artifacts, including TypeScript compiler work. Its successful completion releases artifact stamps, downstream readers, and locks, so it must reflect whether owned work has finished.

flowchart LR
A[Declaration preparation] --> B[Managed child launcher]
B --> C[POSIX process-group check]
C -->|group exited| D[Artifact stamps and readers]
C -->|children remain| E[Terminate managed group]
E --> F[Report completion failure]
Loading

Decision needed

Question Recommendation
Should declaration preparation and the nested TypeScript wrapper intentionally fail on POSIX when their managed group remains alive after a zero-exit leader? Accept strict artifact completion: Accept the POSIX failure behavior because artifact stamps and dependent readers must not proceed before the owner’s managed work ends.

Why: This is an upgrade-sensitive, fail-closed behavior change for existing developer tooling, even though the implementation is narrow and the linked issue documents the intended invariant.

Before merge

  • Resolve merge risk (P1) - On POSIX, a declaration or compiler launch that previously returned success despite leaving its own managed group alive will now fail after cleanup; this intentional fail-closed tooling change needs maintainer acceptance for existing development workflows.
  • Complete next step (P2) - A maintainer must explicitly accept the intentional stricter POSIX completion behavior before normal PR landing gates decide the exact head.
Agent review details

Security

None.

PR surface

Tests +89, Docs +7, Other +4. Total +100 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 117 28 +89
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 2 4 0 +4
Total 5 128 28 +100

Review metrics

Metric Value Why it matters
Production versus test delta production/tooling +4, tests +89 net, docs +7 The small tooling increase enables an existing strict lifecycle mode at two owners; most of the change is boundary regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #132053
Summary: This PR is the linked candidate repair for the tracked declaration-completion defect.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept the stricter POSIX completion contract (recommended)
    Merge after exact-head CI if maintainers agree that lingering owned subprocesses must turn apparent declaration success into an explicit failure.
  2. Pause for compatibility direction
    Hold the PR if existing POSIX workflows must continue accepting a zero-exit leader with unfinished same-group work.

Technical review

Best possible solution:

Retain the existing shared default and apply strict verification only at these two artifact-producing owners once maintainers accept the POSIX success-to-failure behavior and exact-head checks finish.

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

Yes. The checked-in regressions encode a real Node leader-and-descendant scenario at both affected owners; the supplied PR evidence also records before/after process observations, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Reusing the existing strict verifier at the two process-group owners is narrower than changing the shared default, and the Windows guard preserves the existing unsupported-platform behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded developer-tooling correctness repair with no demonstrated gateway or channel runtime outage.
  • add merge-risk: 🚨 compatibility: The new POSIX opt-ins intentionally convert formerly accepted lingering-child completion into a command failure for existing declaration workflows.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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: Not applicable to the external-contributor proof gate because repository state identifies this as maintainer-authored; nevertheless, the supplied body records after-fix real process and compiler-wrapper runs, while the checked-in tests exercise both changed owner boundaries.

Label justifications:

  • P2: This is a bounded developer-tooling correctness repair with no demonstrated gateway or channel runtime outage.
  • merge-risk: 🚨 compatibility: The new POSIX opt-ins intentionally convert formerly accepted lingering-child completion into a command failure for existing declaration workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the external-contributor proof gate because repository state identifies this as maintainer-authored; nevertheless, the supplied body records after-fix real process and compiler-wrapper runs, while the checked-in tests exercise both changed owner boundaries.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the recent merged shared-lifecycle repair and this follow-up touches its declaration and compiler callers. (role: recent lifecycle and declaration-tooling contributor; confidence: high; commits: dd81c6aa1d1a, 6b5c4358debd; files: scripts/lib/managed-child-process.mts, scripts/prepare-extension-package-boundary-artifacts.mts, scripts/run-tsgo.mts)

Rank-up moves

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

  • Confirm the intended POSIX success-to-failure compatibility contract and let exact-head CI complete.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer decision: accept the stricter POSIX artifact-completion contract. A declaration/typecheck leader exiting zero while its own managed group remains active must fail after cleanup, rather than release artifact stamps, dependent readers, or the writer lock. Applying the existing verifier at both the preparation and nested compiler owners is intentional; Windows behavior and the shared default remain unchanged.

This addresses the acceptance/compatibility decision and sole rank-up move in the current ClawSweeper review, which found no introduced correctness or security defects. No code changed after that review, and no re-review is needed.

Exact-head CI is green: run 33205915259 completed successfully on 6b5c4358debd0abfb204914376ae65ec5ee1e16e, including the required CI gate. The bounded native watcher returned GREEN; no failed test job was rerun or bypassed.

Local proof on the candidate:

  • The two caller regressions fail with unchanged production; the compiler regression remains red with a prep-only opt-in; both pass with the two-owner fix.
  • 15 focused completion/platform cases across 3 files pass on Node 24.20.0 and Node 26.7.0/macOS 27.
  • A real Node 24 prep fixture rejects with no survivors at return while its independent control remains alive. The generic-default control is unchanged, and every exact fixture PID was cleaned afterward.
  • A small real native declaration compile emits the expected declaration bytes and build-info file.
  • Scoped script/root-test typechecks, lint, formatting, erasability and repository guards pass; fresh isolated autoreview is scoped-clean with no accepted/actionable P0 findings.

Exact local test command:

node scripts/run-vitest.mjs test/scripts/managed-child-process.test.ts test/scripts/run-tsgo.test.ts test/scripts/prepare-extension-package-boundary-artifacts.test.ts -t 'rejects and drains.*successful leader exit|runs the installed compiler version|allows bounded retry output|allows strict normal long-running|accepts a process group that vanishes|refuses strict Windows commands|leaves a completing tsgo alone|clamps oversized prep step timers|runs boundary prep steps serially|passes step-specific environment overrides|keeps the watchdog opt-in'

Exact local changed gate:

node scripts/check-changed.mjs -- docs/reference/test.md scripts/prepare-extension-package-boundary-artifacts.mts scripts/run-tsgo.mts test/scripts/managed-child-process.test.ts test/scripts/run-tsgo.test.ts

Known limits remain explicit: no native Windows or full local SDK declaration build claim; the independently investigated nested-timeout race was not altered or declared resolved. This verifier covers owned POSIX groups, not arbitrary descendants that deliberately escape them. Native review artifacts validate on the exact head; proceeding through the required scripts/pr prepare/merge workflow with hosted CI reuse.

@steipete
steipete merged commit 4c6ed51 into main Aug 28, 2026
218 checks passed
@steipete
steipete deleted the steipete/strange-volhard-5ec0b5 branch August 28, 2026 20:27
@steipete

steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged through the repo-native prepare/merge workflow.

Landing anomaly recorded for follow-up: the native workflow reported HTTP 502 on the first merge request, after the patch reached main. A subsequent read reported the PR open; native lock recovery and retry finalized the PR with the empty second commit. Direct Git inspection confirms the first commit contains the five-file change and the final commit has no tree delta. All five landed files are byte-identical to the reviewed head. Main history was left intact; no code rewrite, rebase, test rerun, or gate bypass was used.

pull Bot pushed a commit to RealShocky/openclaw that referenced this pull request Aug 28, 2026
…132070)

Fixes openclaw#132053. Verify POSIX process completion at each declaration owner before accepting success. Preserve Windows behavior without changing timeouts or shared defaults.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…132070)

Fixes openclaw#132053. Verify POSIX process completion at each declaration owner before accepting success. Preserve Windows behavior without changing timeouts or shared defaults.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…132070)

Fixes openclaw#132053. Verify POSIX process completion at each declaration owner before accepting success. Preserve Windows behavior without changing timeouts or shared defaults.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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]: declaration steps accept leaders that leave owned subprocesses running

1 participant