Repository navigation
refactor(errors): compose multi-part provider cleanup failures through one owner - #12002
Conversation
…h one owner CdpBrowserProvider, CdpElectronProvider, FridaInstrumentationManager and PlaywrightBrowserScenarioProvider each built the same composite by hand: a ProviderCleanupError listing the parts' resources, an AggregateError cause, and bindCleanupDependencies over the parts. providerCleanupErrorFromFailures in src/domain/analysisErrorCleanup.ts now owns that composition. `causes` keeps non-AnalysisError failures in the aggregate cause without making them own completion, as the CDP providers did; `message` keeps the aggregate messages Frida and Playwright used. Tests: helper unit tests, new close-composition tests for both CDP providers, and a Playwright test with two failed cleanup retries. They pass on the base revision and on this change, and fail when the helper drops the dependency binding, the extra causes or the message. Lowers the cleanup-dependency-binding baseline to 43 files / 73 sites. Refs morluto#11859 Co-Authored-By: Claude Opus 5.5 <[email protected]>
[Medium impact] The PR appears safe to merge. SummaryThis refactor moves repeated cleanup-error composition into one shared helper without changing the four providers’ behavior.
No actionable correctness or security issues found. Tests were not rerun during this review. Reviews (4) · Last reviewed commit: "Merge main into contributor cleanup aggr..." · Reviewed by Greptile |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Follows docs/development/testing.md: the close-composition tests now check provider, operation, resources, aggregate causes and completion, not the explanatory reason or aggregate message. A harmless wording change passes; a lost binding, lost cause or wrong operation still fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I merged main into this branch at |
Summary
Next batch for #11859 (Refs #11859; the issue stays open for the remaining sites). Four providers built the same multi-part cleanup composite by hand. This adds one shared owner for it and moves those four sites onto it. Independent of #12000 (no file overlap; the two branches merge cleanly).
Problem and expected behavior
CdpBrowserProvider,CdpElectronProvider,FridaInstrumentationManagerandPlaywrightBrowserScenarioProvidereach wrote:Expected contract: the composite lists the parts' resources, keeps every failure in its aggregate cause, and completes only after every typed part reports release.
Change and scope
providerCleanupErrorFromFailures(providerId, failures, reason, { operation, causes?, message? })tosrc/domain/analysisErrorCleanup.ts(an existing owner exempt from the guard).causeskeeps non-AnalysisErrorfailures in the aggregate cause without making them own completion, as both CDP providers did (AggregateError(failures)while binding onlytyped).messagekeeps the aggregate messages Frida and Playwright used. When omitted,new AggregateError(x, undefined)has the same empty message asnew AggregateError(x).bindCleanupDependencies, even with an empty list, as the old code did.cleanup-dependency-bindingbaseline: 46 files / 77 sites → 43 files / 73 sites.Not included: sites that bind a resource owner, bind different errors than the ones they compose (
PcapProvider.ts:1007,NativeMacOSProvider.ts:1897), or build custom diagnostics (Kuna, SQLite, Firmware, ArtifactAnalysisResources, ScreenJudge). Those need their own decisions.Contribution scope: not applicable (internal refactor within existing boundaries).
Contract and boundary impact
Semantic owner and earliest changed stage:
providerCleanupErrorFromFailuresnow owns multi-part provider cleanup composition; close/shutdown paths of the four providers.Contribution scope fit and linked maintainer decision: not applicable.
CLI and MCP/tool-catalog contract: none.
Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: same composite error, resources, cause and completion dependencies.
Generated metadata, package, or installation impact: none.
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.
Evidence and regression coverage
Before the change, I checked which of these sites existing tests protect: removing
bindCleanupDependenciesfrom each site on base only failed Frida's tests. The CDP browser, Electron and Playwright multi-failure paths had no test that noticed.Tests added or updated:
src/domain/analysisErrorCleanup.test.ts: helper resources, provider/operation/reason, aggregate cause with an untyped failure, message, default cause, and completion only after both parts release.tests/boundary/browser/cdpProviderCloseComposition.test.ts: for both CDP providers,close()with both close steps failing returns the composite (provider, operation, resources, aggregate causes) that completes only after both parts release; with one untyped failure, the cause keeps it but completion follows the typed part only. Usesvi.spyOnon prototypes, no module mocks.src/browser/PlaywrightBrowserScenarioProvider.test.ts: two retained cleanups whose retries fail compose into one failure that stays incomplete after one releases and completes after both.Base reproduction or other evidence (executed), on the 6 related test files (234 tests):
bindCleanupDependenciescausesmessagecausesDropping a part from the composite's constructor resource list is not detected, and cannot be: while dependencies are bound,
AnalysisError.cleanupResourcesreports the pending dependencies' resources, not the constructor list (src/domain/analysisErrorBase.ts).User-visible CLI/MCP output: none.
Remaining proof gaps: Frida's aggregate message is covered only through the helper test; existing Frida tests cover its dependency binding. The full test suite was not run locally.
Validation performed
npx vitest run src/domain/analysisErrorCleanup.test.ts tests/boundary/browser/cdpProviderCloseComposition.test.ts src/browser/PlaywrightBrowserScenarioProvider.test.ts src/frida/FridaInstrumentationManager.test.ts tests/boundary/browser/cdpProviderCleanupOwnership.test.ts tests/boundary/browser/cdpElectronProvider.test.ts— 234 passed (plus the matrix above).npx vitest run tests/boundary/filesystem/ciTestProjects.test.ts— 23 passed.node scripts/verify/architecture-guards.mjs— passed across 2871 source files.npm run typecheck— exit 0.npm run verify:module-boundaries— passed.npm run check— exit 0 (typecheck, lint,oxfmtformat check, knip, metadata, guards, typed lint).npm run check:fast— exit 0.npx oxfmt --checkon changed files — clean.npx oxlinton changed files — no errors; 22 warnings before and after (pre-existing).Compatibility, safety, and release
Author readiness
Human owner: @anant8140
Before merge
type(scope): outcome.🤖 Generated with Claude Code