Skip to content

fix(cli): release workspace resources after success - #1241

Merged
chubes4 merged 1 commit into
mainfrom
fix/1234-finalize-exit
Aug 25, 2026
Merged

fix(cli): release workspace resources after success#1241
chubes4 merged 1 commit into
mainfrom
fix/1234-finalize-exit

Conversation

@chubes4

@chubes4 chubes4 commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • finalize synchronous workspace WP-CLI requests at the command-owning after_invoke boundary
  • flush terminal streams, clear deferred WordPress shutdown work, and close the request-owned database connection only after successful command return
  • replace synthetic list-only exit coverage with process-level worktree finalize coverage using a merged-PR-shaped receipt and owner-terminal-outcome=success

Root Cause

The existing boundary deferred resource release until WordPress shutdown. A successful finalizer could commit metadata and render its receipt while the request-owned database connection remained open; a later shutdown participant could then retain the process and its SQLite lock. The regression fixture verifies current-main behavior deterministically by making that later participant wait only while the DB remains open.

The shared workspace after_invoke callback is the smallest generic owning layer: it runs after successful command output and before PHP shutdown, while failures before after_invoke retain the normal shutdown lifecycle and nonzero status.

Closes #1234.

Verification

Passed:

  • php tests/workspace-cli-bounded-exit.php
  • php tests/workspace-command-startup-bounds.php
  • php tests/workspace-help-cli-lifecycle.php
  • php tests/workspace-list-cli-format-contract.php
  • php tests/workspace-show-cli-format-contract.php
  • changed-file php -l checks
  • git diff origin/main...HEAD --check
  • every standalone tests/*.php test except the unchanged baseline failure below

The full standalone loop stops at tests/worktree-add-lifecycle.php with partial success omitted its exact read-only continuation. The same environment-sensitive failure is documented on current main in PR #1198, and this PR does not modify that test or the implicated handoff lifecycle. Rerunning all standalone tests while skipping only that baseline test passes. worktree-command-wp-cli-synopsis.php reports its existing skip because WP_CLI_ROOT is unavailable.

AI Assistance

OpenAI GPT-5.6 Sol via OpenCode read the issue and history, traced the removed process-boundary coverage, implemented the owning-layer resource finalizer and process fixture, and ran the verification above. Chris Huber directed the work and remains responsible for the change.

@chubes4
chubes4 merged commit 58431c6 into main Aug 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: successful worktree finalization mutates then never exits

1 participant