Skip to content

refactor(runtime): share cleanup deadline waiting - #139953

Merged
steipete merged 1 commit into
mainfrom
steipete/s3-share-cleanup-deadlines
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/s3-share-cleanup-deadlines

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #135868, #139517, #139657

What Problem This Solves

MCP and owned stdio duplicated the same cleanup deadline implementation, while LSP kept a third grace timer alive after an early shutdown reply. This is the maintainer-requested production compression follow-up for concern C of the #135868 split.

Why This Change Was Made

Use one internal settlesWithin helper for all three waits. It returns false on timeout, propagates rejection, unrefs and clears its timer. It does not decide whether resources are closed: protocol owners and the process owner's extinction join retain those decisions. LSP keeps its 500 ms shutdown grace and subsequent owned-process cleanup.

User Impact

No change to shutdown budgets, escalation order, error propagation or cleanup evidence. The losing LSP grace timer is now cleared after an early reply. Production shrinks by 12 lines; tests, tooling and docs are unchanged. No public API, dependency or configuration changes.

Evidence

Existing boundary coverage is retained: src/agents/mcp-stdio-transport.test.ts:195,218 covers failed cleanup replay and confirmed/unconfirmed forced shutdown; src/agents/agent-bundle-lsp-runtime.test.ts:544,575,651 covers descendant joining, uncertainty, and shutdown ordering. src/process/owned-stdio.real.test.ts:4 uses a real process and drains 8,192 Unicode diagnostic lines before cleanup completes; src/process/owned-stdio.test.ts:11 covers startup cleanup outcomes. The full MCP runtime suite also covers hung shutdown and remote transports.

Validation: 163 focused tests passed across six suites; full node scripts/check-changed.mjs exited 0, including core and all core-test typechecks, lint, guards, and dead-export scans. Import-cycle check: zero runtime value cycles. Independent Codex autoreview against the pinned merge base: scoped-clean through P2. git diff --check passed. Windows launch paths used fixtures; real stdio ran on macOS.

ClawSweeper reviewed exact head 1739b1af99be13546e7ab63ae4ebd36861d6df80: no actionable correctness/security findings and no before-merge or rank-up requests.

@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 08:52
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:07 AM ET / 09:07 UTC.

ClawSweeper review

What this changes

Shares deadline waiting across tool-server and subprocess cleanup, clearing the language-server grace timer when shutdown replies early.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused follow-up: current main retains the duplicated waits, and the pinned patch has no actionable correctness or security findings. The prior review’s empty finding list remains appropriate.

Priority: P3
Reviewed head: 1739b1af99be13546e7ab63ae4ebd36861d6df80

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable refactor with retained boundary coverage and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts this internal refactor from contributor proof requirements, and no authority change triggers an exception; reported macOS stdio execution exercises the process owner, with existing MCP/LSP tests supplying supplemental coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER classification exempts this internal refactor from contributor proof requirements, and no authority change triggers an exception; reported macOS stdio execution exercises the process owner, with existing MCP/LSP tests supplying supplemental coverage.
Evidence reviewed 7 items Pinned introduction verified: The merge-base-to-head diff matches the supplied four-file introduction. It moves the existing stdio waiter into a shared helper, substitutes equivalent MCP calls, and replaces LSP’s uncleared grace timer. Base-only Windows changes are outside this introduction.
Cleanup certification remains with its owner: The process owner still joins process completion and descendant extinction, preserves rejected cleanup, and performs the same escalation. LSP still sends exit after its 500 ms grace and then joins owned-process cleanup. These changed waits use OpenClaw’s local Promise/timer implementation; the patch does not depend on a Codex runtime contract.
Current main still needs this consolidation: Fetched main retains the local MCP waiter and LSP delay; its owned-stdio source also retains a separate waiter. The related merged cleanup work therefore does not supersede this follow-up.
Findings None None.
Security None None.

How this fits together

OpenClaw shuts down MCP tool servers, LSP language servers, and owned subprocesses through their lifecycle owners. Deadline waits bound shutdown phases; the owners separately determine whether cleanup actually completed.

flowchart TD
  A[Tool server shutdown] --> B[Protocol lifecycle owner]
  C[Subprocess shutdown] --> D[Process lifecycle owner]
  B --> E[Shared deadline wait]
  D --> E
  E --> F[Completed or timed out]
  F --> G[Owner checks cleanup or escalates]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -12. Total -12 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 4 24 36 -12
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 24 36 -12

Review metrics

None.

Technical review

Best possible solution:

Keep one internal deadline helper while preserving protocol shutdown ordering and owner-confirmed cleanup outcomes.

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

Not applicable to this refactor; source inspection confirms the duplicate waits and the old LSP timer surviving an early reply.

Is this the best way to solve the issue?

Yes. Extracting the existing waiter is a narrow consolidation, and clearing its timer does not replace the callers’ cleanup checks.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is bounded internal cleanup that preserves shutdown budgets and resource-certification behavior.
  • 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: The supplied MEMBER classification exempts this internal refactor from contributor proof requirements, and no authority change triggers an exception; reported macOS stdio execution exercises the process owner, with existing MCP/LSP tests supplying supplemental coverage.

Evidence

What I checked:

  • Pinned introduction verified: The merge-base-to-head diff matches the supplied four-file introduction. It moves the existing stdio waiter into a shared helper, substitutes equivalent MCP calls, and replaces LSP’s uncleared grace timer. Base-only Windows changes are outside this introduction. (src/shared/settle-within.ts:2, 1739b1af99be)
  • Cleanup certification remains with its owner: The process owner still joins process completion and descendant extinction, preserves rejected cleanup, and performs the same escalation. LSP still sends exit after its 500 ms grace and then joins owned-process cleanup. These changed waits use OpenClaw’s local Promise/timer implementation; the patch does not depend on a Codex runtime contract. (src/process/owned-stdio.ts:54, 1739b1af99be)
  • Current main still needs this consolidation: Fetched main retains the local MCP waiter and LSP delay; its owned-stdio source also retains a separate waiter. The related merged cleanup work therefore does not supersede this follow-up. (src/agents/mcp-client-lifecycle.ts:88, 9f089d6527cc)
  • Retained boundary coverage: Inspected existing tests cover startup cleanup failure, repeated failed disposal, confirmed versus uncertain forced shutdown, LSP descendant joining, and shutdown ordering. The real stdio test uses an actual child and checks complete output plus 8,192 Unicode diagnostic lines. The captured PR body reports 163 passing tests and a passing changed-code gate; this review did not execute them. (src/process/owned-stdio.real.test.ts:4, 1739b1af99be)
  • Merged feature history and routing: The raw commit records parent b7fed47; comparison against that parent confirms the owned-stdio cleanup implementation was added in bcef3b3. Supplied GitHub metadata identifies fix(runtime): require cleanup evidence before releasing owned work #139657 as merged at that commit. (src/process/owned-stdio.ts:56, bcef3b3526dd)
  • Review continuity and scope: The supplied completed review covers the same head and contains no findings or published rank-up requests. The body identifies this as a requested follow-up to the cleanup split. Root and agents policies were fully read; no maintainer-notes directory or additional applicable ancestor policy was found. (AGENTS.md:1, 1739b1af99be)

Likely related people:

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

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 (1 earlier review cycle)
  • reviewed 2026-09-06T08:58:14.752Z sha 1739b1a :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 5067f46 into main Sep 6, 2026
255 checks passed
@steipete
steipete deleted the steipete/s3-share-cleanup-deadlines branch September 6, 2026 09:10
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

1 participant