Skip to content

fix(verifiers): retain WABT roots until MCP cleanup completes - #8698

Closed
wunianze666-netizen wants to merge 1 commit into
morluto:mainfrom
wunianze666-netizen:codex/wabt-verifier-root-ownership
Closed

wunianze666-netizen wants to merge 1 commit into
morluto:mainfrom
wunianze666-netizen:codex/wabt-verifier-root-ownership

Conversation

@wunianze666-netizen

@wunianze666-netizen wunianze666-netizen commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A failed WABT verifier handshake or MCP close could still release its input root and provider temporary directory. Retain both until their MCP owners complete, preserve the primary and cleanup errors, and expose the same cleanup owner for retry. Fixes #8564.

Problem and expected behavior

On frozen main 2cb29693c3d574c4898832047fe309ac1ad00e9d, an executed Windows subprocess importing the actual verifier reached an authored handshake refusal, observed both MCP closes reject, and still removed both directories. A directory must outlive the process or transport that may use it. Constructors and partial setup must also leave every acquired resource with a cleanup owner.

Change and scope

One verifier resource owner replaces the unconditional directory cleanup and the separate setup-error cleanup path. It attempts both MCP closes, retains the SDK's exact child before the SDK forgets it, and uses the existing process supervisor to establish exit and output closure. Only then can independent directory releases run; successful releases are not repeated on retry. The error lists only roots still held, and its retry capability is non-enumerable so logging the error does not dump the inherited child environment.

This is an ordinary correction to the existing verifier; no new provider, target execution, installation or protection capability. A maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner: WABT verifier resource acquisition and finalization, before either root is released; no generic cleanup policy changes.
  • Scope and authority: ordinary verifier repair; no new maintainer scope decision required.
  • CLI/MCP, providers and Evidence: production contracts and analysis behavior unchanged. The verifier still uses the actual SDK stdio transport.
  • Platform and cleanup: retained child handle, exit/output completion, exact primary errors, mixed close failures and same-owner retry. See the platform limits below.
  • Generated metadata, packaging and installation: unchanged.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Effects concern only the existing verifier's authored fixture files and MCP child; no WASM target is executed.

Evidence and regression coverage

The new subprocess cases import the actual verifier and resource helper. Authored WABT version probes and controlled client failures avoid requiring an engine; child lifecycle cases use the real pinned SDK transport and real Node children. The real-server control also connects the real SDK client to the compiled REA MCP server, then stops at fake compiler output rather than claiming a WABT analysis.

The original verifier failed 9 of the initial 11 scenarios, with 2 controls passing. The candidate covers client/transport close failures individually and together, constructor and spawn failure, delayed exit after the SDK's final kill, separate directory-release failures, retained residue, and idempotent same-owner retry. Additional setup cases cover provider-temp allocation failure and failure to release the input root at that stage. Assertions retain the exact primary/close error objects and prevent inherited-environment output.

No real WABT, selected target execution, natural failure frequency, or detached-descendant guarantee is claimed. The preserved original failures and current results are separate; repeated runs are not additional scenarios. Production Evidence is unchanged; the following Evidence-specific checklist is not applicable.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • node scripts/run-exact-tests.mjs run tests/boundary/process/wabtVerifierResources.test.ts tests/boundary/process/verifierCleanup.test.ts — 25 passed (13 new lifecycle cases, 12 existing cleanup cases), no skips; Windows x64, official Node 24.22.1.
  • Initial new regression subset against the byte-exact original main verifier — 9 failed, 2 controls passed; candidate restored byte-for-byte. The earlier minimal production-entry reproduction also failed at the intended root-retention assertion.
  • npm run check:fast — typecheck and lint successful, 2 tasks, no cache. An earlier lint run rejected one overlong test callback; the fixture source builder was factored out and the final check passed.
  • npm run docs:check — 6 tasks successful (3 cached), plus 9 README consistency tests passed.
  • node scripts/verify-test-discovery.mjs — 2,981 files discovered exactly once; npm run verify:architecture-guards — 2,369 source files passed. One earlier invocation used a nonexistent architecture script path and was corrected; it was not a product failure.
  • Focused-test artifact preparation — 3 successful cached tasks. Touched-file formatting and git diff --check passed.
  • Full local check, typed lint, a real WABT engine run, and local Linux/macOS execution were not run. CI run 41487270752, attempt 1, completed successfully for head b792e5d137c7cb3442a1d3c58c6627831364ab8c: all 40 jobs were enumerated, with 17 successful and 23 conditional skips, no failures or cancellations. The actual checkout was 2d21fb7bee436344323e3dfc31ec519b1e557580, parents 2cb29693c3d574c4898832047fe309ac1ad00e9d + b792e5d137c7cb3442a1d3c58c6627831364ab8c, tree 579d5108a571e54c39b0f8980ce85c14996db6ec. The selected Linux shard 2/8 actually executed all 13 new WABT cleanup cases successfully; that shard reported 2,243 passed and 32 skipped in total. The aggregate Portable job is not additional test execution. No skipped optional provider lane or unread raw report is claimed as verified.

Compatibility, safety, and release

No public tool, Evidence, package version, deadline or provider permission changes. The standalone verifier now fails and names retained directories when completion is unproven; an importing caller can retry cleanupOwner.close() on the same error owner. POSIX additionally requires positive run-lineage evidence; the new controlled lifecycle cases exercised it in Linux CI. No local Linux/macOS or real WABT run was performed. Windows verifies the exact SDK child and its output, and reports that it has no retained native Job Object lease for other descendants. Detached/reparented processes outside those pipes remain an explicit limit. Real WABT and Linux/macOS verification were not run.

Author readiness

Human owner: @wunianze666-netizen

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] No actionable defect was found in the reviewed changes.

Summary

The PR gives the WABT verifier one cleanup owner and retains its directories until MCP cleanup completes.

  • The WABT verifier keeps its temporary roots until MCP cleanup finishes.

No actionable defect was established from the reviewed source. Tests were not executed during this review. GitHub authentication was unavailable, so supersession and existing review threads could not be checked.

Acknowledged by wunianze666-netizen: Windows has no retained Job Object lease for descendants outside the SDK child's pipes. Detached or reparented descendants remain an explicit limit.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Acquire input root] --> B[Create cleanup owner]
  B --> C[Acquire temp root, client, and transport]
  C --> D[Run verifier]
  D --> E[Attempt both MCP closes]
  E --> F{Child completion established?}
  F -- No --> R[Retain roots and expose same owner]
  F -- Yes --> G[Check lineage and provider residue]
  G --> H{Checks pass?}
  H -- No --> R
  H -- Yes --> I[Release each directory independently]
  I --> J{Any release failed?}
  J -- Yes --> R
  J -- No --> K[Cleanup complete]
  R --> E
Loading

Reviews (1) · Last reviewed commit: "fix(verifiers): retain WABT roots until ..." · Reviewed by Greptile

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the one changed test file on three Node versions, and all 13 tests passed on each. The head is 379 commits behind main 9d0e87f, and I did not merge it. CI shows one cancelled check, Conventional PR title, and a pending PR readiness status.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
tests/boundary/process/wabtVerifierResources.test.ts pass, 1/1 files, 13/13 tests pass, 1/1 files, 13/13 tests pass, 1/1 files, 13/13 tests
  • I ran head b792e5d in a VM.
  • The PR changes 4 files against merge base 2cb2969.
  • The files are docs/testing-lanes.md, scripts/lib/wabt-verifier-resources.mjs, scripts/verify-wasm-artifact.mjs and tests/boundary/process/wabtVerifierResources.test.ts.
  • The PR is a draft. GitHub shows mergeable true and state unstable.
  • Workflow runs: CI is completed/success, and CodeQL production is completed/skipped.
  • PR readiness has 4 runs, all completed/success.
  • PR title has 3 runs completed/success and 1 run completed/cancelled.
  • Check runs: 25 success, 24 skipped, 1 cancelled.
  • The successes include Source tests, Portable tests, Static checks and CI required.
  • The successes also include Test shard (1/8) through Test shard (8/8).
  • The cancelled check run is Conventional PR title.
  • The commit status PR readiness is pending.

Not run

  • A run of tests/boundary/process/wabtVerifierResources.test.ts with cleanupOwner temporarily made enumerable. It would show whether the env-leak assertion still passes.
  • A probe that makes completeVerifierRun or assertVerifierCleanupComplete throw after a failed run, to check whether both roots stay on disk
  • A merge with current main, 9d0e87f
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: b792e5d / 2cb2969 (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/boundary/process/wabtVerifierResources.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thanks. These cleanup orderings were real. They landed in #10491, which fixes the shared rule once with a releaseAfter helper in scripts/lib/verifier-cleanup.mjs, so the fixture root is released only after its dependent cleanups succeed. Closing in favor of that merge.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added area: tests Test suite and verification bug Something isn't working provider: wabt Analysis provider / engine: wabt labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification bug Something isn't working provider: wabt Analysis provider / engine: wabt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] WABT artifact verifier releases both roots after MCP cleanup fails

4 participants