Skip to content

refactor(errors): inherit live cleanup ownership through shared domain helper - #12077

Merged
morluto merged 1 commit into
morluto:mainfrom
4yuying:refactor/cleanup-dependency-binding
Nov 19, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
4yuying:refactor/cleanup-dependency-binding

Conversation

@4yuying

@4yuying 4yuying commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses one slice of #11859. Introduces withInheritedCleanupOwnership in src/domain/analysisErrorCleanup.ts for wrapper errors that conditionally inherit live cleanup ownership from a source AnalysisError, and migrates 4 independent files (5 baseline sites) onto it.

Note: Open PRs #12000 (desktopCaptureCommands.ts) and #12002 (browser/Frida providers) cover other baseline files; this PR deliberately avoids those files.

Problem and expected behavior

Several wrapper sites (DirectAnalysisCleanup.ts, EvidenceBundleCommands.ts, HopperClient.ts, CdpTargetSessionOwner.ts) inline owner.cleanupIncomplete ? failure.bindCleanupDependencies([owner]) : failure directly, duplicating cleanup-ownership inheritance rules and keeping 4 files in scripts/verify/baselines/cleanup-dependency-binding.json. Moving the rule into src/domain/analysisErrorCleanup.ts preserves the exact invariant—including keeping cleanup unset when !owner.cleanupIncomplete so unowned close-rejection semantics remain unknown—while shrinking the baseline.

Change and scope

  • src/domain/analysisErrorCleanup.ts & src/domain/analysisErrorCleanup.test.ts: Add withInheritedCleanupOwnership and unit coverage for live owner inheritance, unowned cleanup retention, and clean owner cases.
  • src/application/DirectAnalysisCleanup.ts (1 site): Use withInheritedCleanupOwnership(failure, error).
  • src/application/EvidenceBundleCommands.ts (1 site): Conditionally pass cleanup only when original.cleanupIncomplete and bind via withInheritedCleanupOwnership.
  • src/hopper/HopperClient.ts (1 site): Use withInheritedCleanupOwnership(failure, source).
  • src/browser/CdpTargetSessionOwner.ts (2 sites): Use withInheritedCleanupOwnership.
  • scripts/verify/baselines/cleanup-dependency-binding.json: Shrunk via node scripts/verify/architecture-guards.mjs --shrink-baselines, removing those 4 files.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/analysisErrorCleanup.ts (withInheritedCleanupOwnership), consumed across application/provider/browser wrappers.
  • Contribution scope fit and linked maintainer decision: Internal domain-ownership cleanup under refactor(errors): migrate remaining cleanup-dependency-binding sites onto shared owners #11859; not applicable.
  • CLI and MCP/tool-catalog contract: Unchanged.
  • Provider, bridge, target-format, or platform compatibility: Preserves tests/composition/directAnalysisCleanup.test.ts unowned close-rejection semantics (!owner.cleanupIncomplete).
  • Evidence, artifact, provenance, or reconstruction contract: Unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Preserves live cleanup tracking and released-resource ownership without claiming cleanup succeeded for unowned wrappers.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: None.

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.

Evidence and regression coverage

  • Tests added or updated: src/domain/analysisErrorCleanup.test.ts (+41 lines) tests withInheritedCleanupOwnership across live cleanup owners, released owners, unowned cleanup wrappers, and clean owners.
  • Base reproduction or other evidence: verify:architecture-guards (cleanup-dependency-binding) counted 4 files / 5 direct bindCleanupDependencies sites prior to migration and removed all 4 files after --shrink-baselines.
  • User-visible CLI/MCP output (if applicable): None changed.
  • Remaining proof gaps: Live Hopper GUI and live browser CDP sessions were not launched; coverage relies on unit and boundary cleanup/socket test suites.

Validation performed

  • npm run test:local -- src/domain/analysisErrorCleanup.test.ts — 25/25 passed.
  • npm run test:focused -- tests/composition/directAnalysisCleanup.test.ts tests/boundary/filesystem/evidenceBundleFiles.test.ts tests/boundary/providers/hopper/hopperClient.cleanup.test.ts — 83/83 passed (5 + 42 + 36).
  • npm run test:focused -- tests/boundary/browser/cdpTargetSessionOwner.test.ts tests/boundary/browser/cdpBrowserProvider.browserSocket.test.ts — 31/31 passed.
  • npm run check:fast — passed (typecheck, lint, verify:architecture-guards across 2873 source files).

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Hopper and browser boundary test doubles executed locally on macOS arm64; live Hopper/Chromium binaries not invoked.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Retains fail-closed cleanup ownership semantics on close failures.

Author readiness

Human owner: @clark970417-eng

  • 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 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed code appears safe to merge.

Summary

This refactor moves repeated cleanup-owner checks into withInheritedCleanupOwnership and updates five wrapper sites across four files.

  • Wrapped errors follow their source only while cleanup is still live.

No actionable correctness or security issues found. Tests were not run during this review. Live PR history was unavailable, so supersession could not be confirmed.

Reviews (1) · Last reviewed commit: "refactor(errors): inherit live cleanup o..." · Reviewed by Greptile

@4yuying
4yuying marked this pull request as ready for review November 18, 2026 17:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T17:45:24.494245Z 6b1d430 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto
morluto merged commit 7bc8a62 into morluto:main Nov 19, 2026
47 of 49 checks passed
@morluto morluto added the area: domain Domain logic, errors, and pure functions label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants