Skip to content

fix: retain copied plugin resources through media cleanup - #143530

Merged
steipete merged 1 commit into
mainfrom
codex/prepared-donor-dependencies
Sep 10, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/prepared-donor-dependencies

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Related: #140674

What Problem This Solves

Detached media tasks could retain their primary prepared registrations while losing the managed donor behind copied callbacks. The last prepared-manager release closed the donor even though an accepted media task or the primary registration's disposer could still use it.

Why This Change Was Made

Move the existing donor claim into the primary inspection's physical resource owner. Final release joins the primary's disposers and tracked work, including cleanup already started by rollback, before releasing the donor. Cleanup failures remain awaited and reported. Retirement still refuses new media admission immediately; this does not extend authority or change raw host ownership. The separate prepared-manager donor release path is removed.

User Impact

Accepted media tasks and their cleanup can finish using copied plugin callbacks after the original prepared view retires. Resources close after their last physical user finishes.

Evidence

Validation: 71 focused tests cover the actual detached image task, construction/publication-manager retirement, primary and donor cleanup failures, started rollback, raw donors, and Image/Music/Video sibling behavior. Regression checks reproduce the original premature SQLite close and the rollback ordering defect. The complete changed gate, documentation check, independent Codex review, and normal build passed (233.23 seconds).

The compiled synthetic proof exercised genuine managed acquisition, non-read-only workspace preparation through the existing inbound-loader seam, and the actual image tool. It verified admission refusal after retirement, donor access during accepted work and primary cleanup, awaited cleanup failure, saved PNG readability, single disposal, and SQLite reopen. The compiled process joined in 2.039 seconds with build artifacts unchanged and no TypeScript source fallback. Actual manager retirement and detached scheduling are composed separately in the maintained native test; no external provider or live account was used.

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 9, 2026
@steipete
steipete marked this pull request as ready for review September 10, 2026 00:00
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The previous review job ended without publishing a review. Please retry this unchanged head; the required CI checks have passed.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The review checkout metadata fix has landed in openclaw/clawsweeper#1519. Please review the current head using the updated preparation path; the source and validation evidence in this PR are current.

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 9:46 PM ET / September 10, 2026, 01:46 UTC (Revision 2).

ClawSweeper review

What this changes

The PR keeps resources behind copied plugin callbacks alive through accepted media tasks and final cleanup, propagates disposal failures, and adds regression coverage and lifecycle documentation.

Merge readiness

✅ Ready for maintainer review

This remains a necessary, focused repair: current main still releases copied-callback resources before their final users finish. No actionable correctness or security findings remain, and the related aggregate is explicitly not a landing candidate.

Priority: P2
Reviewed head: fc10c0d01576e4cb6bdbc117a36e735316465f4c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful lifecycle coverage, reported compiled validation, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal repair is exempt from the external-contributor proof gate. Its body reports compiled image-tool behavior through managed acquisition and donor cleanup; inspected native coverage separately composes retirement and detached scheduling.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal repair is exempt from the external-contributor proof gate. Its body reports compiled image-tool behavior through managed acquisition and donor cleanup; inspected native coverage separately composes retirement and detached scheduling.
Evidence reviewed 8 items Current-main lifetime gap: The fetched main still releases borrowed sources when prepared-manager claims reach zero. Media acquisitions retain the underlying inspection directly, so accepted work can outlive those manager claims.
Dependency ownership and cleanup ordering: The primary inspection acquires the donor claim before publication. Its final physical release joins successful disposals and already-started rollback disposal before releasing dependencies; dependency failures are returned through the existing aggregate-error path.
Admission remains separate from physical retention: Media acquisition checks captured registry authority before retaining resources, and image preflight checks admission again before scheduling. The patch changes resource custody without changing these authority checks or adding a public plugin API.
Findings None None.
Security None None.

How this fits together

Prepared model runtimes collect plugin callbacks used by image, music, and video tools. Their resource owners must keep those callbacks usable through accepted work and cleanup while independently rejecting new work after retirement.

flowchart TD
  A[Managed source registry] --> B[Prepared plugin view]
  B --> C{New work admitted?}
  C -->|Retired| D[Reject new task]
  C -->|Accepted| E[Media generation and saving]
  E --> F[Primary and rollback cleanup]
  F --> G[Release borrowed source]
  G --> H[Completion or disposal error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +44, Tests +361, Docs +5. Total +410 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 49 5 +44
Tests 1 361 0 +361
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 415 5 +410

Review metrics

Metric Value Why it matters
Production versus test growth Production net +44 lines; tests +361 lines Production growth implements final-disposal dependency ownership, while the larger test fixture protects five distinct lifecycle outcomes.

Technical review

Best possible solution:

Keep borrowed resources under the primary registration's physical lifetime, with retirement fencing new work and final cleanup preserving error reporting.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: retire construction/publication owners while an accepted media callback retains its inspection, then resume donor access or primary cleanup. Current main can release the donor first; this review did not execute the regression.

Is this the best way to solve the issue?

Yes. Moving the existing donor claim into the physical resource owner repairs the lifetime boundary and removes the competing manager-level release path without changing configuration or public APIs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 04b265be7fd8.

Labels

Label justifications:

  • P2: This fixes a bounded resource-lifetime failure affecting accepted media work during prepared-runtime retirement.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored internal repair is exempt from the external-contributor proof gate. Its body reports compiled image-tool behavior through managed acquisition and donor cleanup; inspected native coverage separately composes retirement and detached scheduling.

Evidence

What I checked:

  • Current-main lifetime gap: The fetched main still releases borrowed sources when prepared-manager claims reach zero. Media acquisitions retain the underlying inspection directly, so accepted work can outlive those manager claims. (src/agents/prepared-model-runtime.resources.ts:84, 04b265be7fd8)
  • Dependency ownership and cleanup ordering: The primary inspection acquires the donor claim before publication. Its final physical release joins successful disposals and already-started rollback disposal before releasing dependencies; dependency failures are returned through the existing aggregate-error path. (src/plugins/registry-registration-resources.ts:41, fc10c0d01576)
  • Admission remains separate from physical retention: Media acquisition checks captured registry authority before retaining resources, and image preflight checks admission again before scheduling. The patch changes resource custody without changing these authority checks or adding a public plugin API. (src/agents/prepared-model-runtime.plugin-generation.ts:16, fc10c0d01576)
  • Regression coverage inspected: The complete added test covers managed donors, donor failure, primary failure, pending rollback, and raw donors using actual preparation, image-tool execution, and SQLite connections. Task bookkeeping and completion delivery are mocked; these tests were inspected, not executed during this review. (src/agents/tools/media-generate-tool.donor-resources.test.ts:41, fc10c0d01576)
  • Reported compiled behavior evidence: The captured PR body reports compiled managed acquisition and actual image-tool execution, observing donor access during work and cleanup, retired-admission refusal, awaited disposal failure, readable PNG output, and SQLite reopen. It explicitly distinguishes that scenario from the native test's manager-retirement and detached-scheduling composition and reports no external provider or live account. (fc10c0d01576)
  • Prior merged ownership work: GitHub verifies fix: close plugin resources after read-only model checks #143109 as merged. Its commit added the prepared-resource owner; the raw commit records parent 895bdee, where this file is absent. This establishes relevant prior area work, not that the earlier PR already fixes donor cleanup. (src/agents/prepared-model-runtime.resources.ts:78, 73b4086ff658)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-10T01:40:09.524Z sha fc10c0d :: needs maintainer review before merge. :: none

@steipete
steipete merged commit fb9addf into main Sep 10, 2026
250 checks passed
@steipete
steipete deleted the codex/prepared-donor-dependencies branch September 10, 2026 01:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant