Skip to content

refactor(process): let Darwin helper cleanup errors read their owner's release - #10801

Merged
morluto merged 9 commits into
mainfrom
refactor/darwin-helper-release-claims
Nov 15, 2026
Merged

morluto merged 9 commits into
mainfrom
refactor/darwin-helper-release-claims

Conversation

@morluto

@morluto morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Summary

Moves the Darwin ownership-helper cache and run-token reader root cleanup onto the read-side cleanup model from #10744. Failures now report a shared AnalysisCleanupRelease that the owner confirms when a retry succeeds, instead of later failures depending on a first-failure "anchor" error that the owner resolved with resolveCleanup(). Third owner-family slice of #10763's baseline.

Problem and expected behavior

DarwinHelperCache.close() and the run-token reader's cleanupRoot() kept the first unresolved ProviderCleanupError as an anchor, bound each later failure to it with bindCleanupDependencies(), and called resolveCleanup() on the anchor after a successful retry. The anchor stood in for the owner's release. Expected behaviour is unchanged: every failure from one unreleased cleanup reports incomplete until a retry succeeds, then all report complete.

Change and scope

  • New src/domain/analysisCleanupRelease.ts: AnalysisCleanupRelease, an AnalysisCleanupReleaseClaim for owners that retry cleanup in place rather than through one close(); bind(error) and confirm(). It lives in the domain layer because src/process may not import src/artifacts.
  • DarwinHelperCache and DarwinProcessRunTokenReader keep one release per unreleased cleanup, bind each failure to it, and confirm it on success.
  • Removed two resolveCleanup() and two bindCleanupDependencies() calls; both counted baselines shrink.
  • Not included: other owner families; the pcap and worker records from refactor(pcap): let pcap cleanup errors read command and snapshot release #10792/refactor(process): let worker cleanup errors read their root epoch's release #10789 keep their own claim implementations because each record already owns its released flag.

Stacked on #10789 (which now carries #10792), itself on #10744.

Contribution scope: not applicable (internal refactor within existing boundaries).

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the helper cache and the reader root own release; AnalysisError.cleanupIncomplete reads it.
  • 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 (if applicable): retry order and resources unchanged.
  • Generated metadata, package, or installation impact: none.
  • Semantic owner and earliest changed stage:
  • Contribution scope fit and linked maintainer decision:
  • CLI and MCP/tool-catalog contract:
  • Provider, bridge, target-format, or platform compatibility:
  • Evidence, artifact, provenance, or reconstruction contract:
  • Target selection, authority, upstream behavior, and cleanup details (if applicable):
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs):

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/analysisCleanupRelease.test.ts binds two errors, confirms the release and requires both complete, plus an error bound after release. Existing Darwin cache and reader cleanup tests pin provider behaviour.
  • Base reproduction or other evidence: refactor; no behaviour change intended.
  • User-visible CLI/MCP output (if applicable): not applicable.
  • Remaining proof gaps: none known.
  • Tests added or updated:
  • Base reproduction or other evidence:
  • User-visible CLI/MCP output (if applicable):
  • Remaining proof gaps:

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

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

  • npm run check:fast — passed (after moving the class from src/artifacts to src/domain to satisfy module layering).
  • node scripts/verify/architecture-guards.mjs --shrink-baselines — passed (baselines lowered).
  • npm run test:local -- src/domain/analysisCleanupRelease.test.ts src/process/DarwinHelperCache.ownership.test.ts src/process/DarwinProcessRunTokenReader.finalization.test.ts src/process/DarwinProcessRunTokenReader.timeout.test.ts src/process/DarwinCompilationRetirement.test.ts — 14 passed.
  • npm run test:focused -- tests/boundary/process/darwinHelperCache.test.ts tests/boundary/process/darwinProcessRunTokenReader.test.ts tests/process-global/darwinCompilerCleanup.test.ts tests/process-global/darwinHelperCacheCleanup.test.ts — 68 passed.
  • Pre-push hook passed. macOS arm64.
  • command — result

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 (the Darwin helper's platform).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new effects.
  • Breaking changes or migration steps:
  • Real Hopper/Ghidra, browser, or OS coverage:
  • Package or release metadata impact:
  • Security, privacy, process, or containment review:

Author readiness

Human owner:

  • 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.

…f pushing it to dependents

AnalysisError.cleanupIncomplete becomes a getter over the error's own unresolved state and its bound dependencies. The WeakRef dependents graph and resolveCleanup's push propagation are removed, and subclasses mark their initial state through markCleanupIncomplete instead of overriding a public mutable field.
A composite whose dependencies had released but whose status was never read
stayed incomplete when a later dependency was bound.
…resolving them (#10759)

AnalysisCleanupLeaseGroup no longer calls resolveCleanup() on its error.
The error holds the group as a release claim and reads cleanupReleased when
asked, so completion follows the lease owner without a push.
… so they only shrink (#10763)

* refactor(errors): let errors read a lease group's release instead of resolving them

AnalysisCleanupLeaseGroup no longer calls resolveCleanup() on its error.
The error holds the group as a release claim and reads cleanupReleased when
asked, so completion follows the lease owner without a push.

* chore(verify): count resolveCleanup and bindCleanupDependencies calls so they only shrink
…release

OwnedWorkerRuntime's root epoch is now an AnalysisCleanupReleaseClaim. Errors bound to it read its release when asked instead of the epoch pushing resolveCleanup() through weak references, and a runtime without a retained root binds an already-released owner. Removes the OwnedWorkerCleanupFailure structural type and four resolveCleanup() pushes; the counted baseline shrinks accordingly.
…ease (#10792)

Retained pcap commands, retained snapshot failures and snapshot completion descriptors now own their release and errors read it: commands and snapshot failures implement AnalysisCleanupReleaseClaim, and a failed completion-descriptor close is retried through an AnalysisCleanupLease bound to its error. Removes four resolveCleanup() pushes; the counted baseline shrinks accordingly.
…s release

Darwin helper cache and run-token reader root cleanup now record an AnalysisCleanupRelease that every failure reports; a successful retry confirms it. Replaces the first-failure anchor that later failures depended on and the resolveCleanup() push. Removes two resolveCleanup() and two bindCleanupDependencies() calls; both counted baselines shrink.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T09:11:31.765663Z 1c3a5cb New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no new blocking issue was found.

Summary

Replaces retained cleanup errors with shared AnalysisCleanupRelease claims in the Darwin helper cache, run-token reader, Ghidra checkpoint and Ghidra client.

  • Cleanup errors now read the release confirmed by their owner.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Cleanup fails] --> B[Bind error to owner release]
  B --> C[Error reports incomplete]
  C --> D[Owner retries cleanup]
  D -->|Fails| B
  D -->|Succeeds| E[Confirm release]
  E --> F[Bound errors report complete]
  E --> G[Use a fresh release for later cleanup]
Loading

Reviews (4) · Last reviewed commit: "Merge origin/main into refactor/darwin-h..." · Reviewed by Greptile

…ckpoint's release (#10802)

GhidraClient and GhidraCheckpoint bind each cleanup failure to an AnalysisCleanupRelease and confirm it when a later close or retry releases everything, instead of keeping a set of failures and pushing resolveCleanup() to each. Removes two resolveCleanup() calls; the counted baseline shrinks.
@morluto
morluto changed the base branch from refactor/worker-runtime-release-claim to main November 15, 2026 09:02
@morluto
morluto merged commit df0bdd9 into main Nov 15, 2026
15 checks passed
@morluto
morluto deleted the refactor/darwin-helper-release-claims branch November 15, 2026 09:26
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant