Skip to content

fix(plugins): recover missing retained capture directories - #158769

Merged
steipete merged 1 commit into
mainfrom
upd/upd-windows-capture-root
Sep 26, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-windows-capture-root

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #158712

What Problem This Solves

Fixes repeated plugin capture ENOENT failures after the payload directory of a retained capture instance disappears.

User Impact

New plugin and model-catalog captures can proceed under the existing live lease without restarting the Gateway. Previously deleted captured files are not restored. A missing coordinator parent still reports failure rather than creating an unprotected replacement.

Why This Change Was Made

The capture-directory owner created captures only for the first allocation. Later allocations trusted the retained path forever. Recover that missing child once at the same owner, preserving native custody, reference counting, and existing failure cleanup. No configuration, dependency, schema, permission, or updater-driver changes are required. This operates on disposable candidate runtime scratch; existing update backup and rollback behavior is unchanged.

The regression reproduces the retained-directory failure, but does not identify what removed the directory on the reporter's Windows host. Initial allocation is synchronous. Existing cleanup guards live leases; the worker/custody suites verify that behavior. owner.sqlite is intentionally empty, and its lock is separate from state-lifecycle. Captures preserve installed package bytes; npm plugin upgrades use a separate owner. No claim is made that this patch resolves the reported npm upgrade or WAL contention symptoms.

Catalog failures already publish catalog-failed and refreshFailed; failed renewal clears its expiry, and #157459 removed self-scheduling catalog observation. Explicit requests can retry. This patch adds no retry manager or timer.

Thanks @yihan331313 for the report.

Evidence

  • Before fix: the new owner-boundary regression fails at mkdtemp with ENOENT; the other eight recovery tests pass.
  • After fix: four capture/custody suites passed three times (31 tests per pass). New regression: 25–35 ms. Capture inventory stayed at two trees / 2,112,586 bytes across refreshes, then zero on retirement.
  • Blacksmith Testbox: tbx_01m3edfxkgq8wfx2davgzxgsnp, lease run, Node 24.19.0. All direct test importers found by the cross-lane search are included. Three dispatcher wall times: 63.18 s (including cold runtime build), 29.55 s, 26.06 s; individual test time remained below 2 s.
  • Native Windows / Node 24.18.0: run 36230796142 passed both capture suites, 28 tests, at exact head a01ac0baf091dcd75bb91b4d5b81f161b7189dde. New regression: 86 ms; dispatcher wall 48.62 s, Vitest 43.96 s (83% transform, 14% tests). This is native Windows capture proof, not a full Scheduled Task installation reproduction.
  • Catalog failure/publication and generation-artifact suites: 79 tests passed.
  • node scripts/check-changed.mjs -- src/plugins/plugin-source-capture-directory.ts src/plugins/plugin-source-capture-recovery.test.ts docs/plugins/architecture.md: passed on the Testbox (core plus all 25 test typecheck graphs, lint, dead exports, and source guards). Full remote command including repeated tests completed with exit 0 in 26m57.581s. No extension-lint substitution was needed.
  • Validation is complete. The PR remains draft pending its ready-for-review transition; auto-merge is off.
  • Changed recovery file alone: node scripts/run-vitest.mjs src/plugins/plugin-source-capture-recovery.test.ts --maxWorkers=1 passed 9 tests; 25.70 s process wall, 22.87 s Vitest (97% transform, about 0.18 s tests). This is the direct test wrapper used to avoid reconciling a shared nested worktree install.
  • Fresh isolated Codex autoreview at P1: scoped-clean.
  • LOC: production +11/-1 (net +10), tests +29/-0, docs +3/-0. The added production branch is the bounded recovery at the existing lifetime owner.

Recreate a lost payload directory under its existing native custody lease, without recursively recreating the coordinator parent. Preserve reference counting and advisory cleanup. Refs #158712; thanks @yihan331313.
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 26, 2026, 4:56 AM ET / 08:56 UTC (Revision 2).

ClawSweeper review

What this changes

The branch lets retained plugin source captures recreate a missing payload directory and adds a regression test and plugin architecture documentation.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open. Current main still has the retained-capture ENOENT path, so this is a useful candidate repair for one symptom in the linked Windows report. The prior blocking custody finding remains on the unchanged PR head.

Priority: P1
Reviewed head: a01ac0baf091dcd75bb91b4d5b81f161b7189dde

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and native filesystem testing provide useful evidence, but the unresolved coordinator-loss path blocks merge.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports native Windows tests using the production capture owner and real filesystem after deleting captures, but the changed recovery path still creates a capture when that root's coordinator is missing or replaced. Show a redacted final-effect trace that rejects that case before allocation, alongside the successful payload-only case. The replay log could not be inspected here; that reviewer limitation does not negate the reported positive test result. No stored-data contract changes. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports native Windows tests using the production capture owner and real filesystem after deleting captures, but the changed recovery path still creates a capture when that root's coordinator is missing or replaced. Show a redacted final-effect trace that rejects that case before allocation, alongside the successful payload-only case. The replay log could not be inspected here; that reviewer limitation does not negate the reported positive test result. No stored-data contract changes. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Introduced recovery branch: The pinned PR delta adds mkdir and a second mkdtemp after ENOENT on a retained root; it does not verify that the coordinator at that path still belongs to the retained lease.
Coordinator custody and reclamation: Initial allocation acquires owner.sqlite before making payload; a separate process can reclaim an aged root when owner.sqlite is absent. The in-process owned-root set cannot protect that root in another process.
Positive regression scope: The added test removes captures while leaving the root and coordinator intact, then verifies another capture and later cleanup. It does not remove or replace owner.sqlite.
Findings 1 actionable finding [P2] Reject recovery when the retained coordinator is gone
Security None None.

How this fits together

OpenClaw captures installed plugin source for metadata and model-catalog workers. A retained capture owner allocates temporary directories under a SQLite coordinator lease, and cleanup later reclaims directories whose custody has ended.

flowchart LR
  A[Installed plugin source] --> B[Retained capture owner]
  B --> C[Capture root and coordinator]
  C --> D[Payload directory recovery]
  D --> E[Captured source]
  E --> F[Model catalog worker]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports native Windows tests using the production capture owner and real filesystem after deleting captures, but the changed recovery path still creates a capture when that root's coordinator is missing or replaced. Show a redacted final-effect trace that rejects that case before allocation, alongside the successful payload-only case. The replay log could not be inspected here; that reviewer limitation does not negate the reported positive test result. No stored-data contract changes. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Reject recovery when the retained coordinator is gone (P2) - If captures and owner.sqlite are removed while the root remains, the introduced mkdir succeeds and the retry creates a capture without a coordinator protecting that path. Another process can then reclaim live worker scratch as tokenless. Check the original root and coordinator identity before recreating the child; the new test removes only captures, so it does not cover this case.
  • Resolve merge risk (P1) - If the retained root remains but its coordinator is removed or replaced, recovery can create live worker scratch at a path no longer protected by the held lease; another process can reclaim it.
  • Complete next step (P2) - Reject recovery when the original coordinator or root identity is lost, add the negative regression, and provide redacted after-fix proof of rejection before capture allocation.

Findings

  • [P2] Reject recovery when the retained coordinator is gone — src/plugins/plugin-source-capture-directory.ts:263-264
Agent review details

Security

None.

PR surface

Source +10, Tests +29, Docs +3. Total +42 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 1 +10
Tests 1 29 0 +29
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 43 1 +42

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #158712
Summary: This PR is a candidate fix for the issue's retained-capture ENOENT symptom; the reported upgrade and WAL symptoms are not established as the same defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Guard retained custody (recommended)
    Check the original root and coordinator identity before recovery, and demonstrate that a missing or replaced coordinator is rejected before a new capture is created.
  2. Pause payload recovery
    Leave the PR open until the custody invariant can be preserved without creating reclaimable live worker scratch.

Technical review

Best possible solution:

Keep payload-only recovery in the capture owner, but verify that the root and coordinator still match its live native custody before recreating captures; fail visibly when custody is lost.

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

Yes for the narrow defect: current main calls mkdtemp under a retained captures directory, so removing that directory before another allocation yields ENOENT. The original cause of its disappearance on the reported Windows host remains unknown.

Is this the best way to solve the issue?

No, not yet. Recovery belongs in this owner, but the branch must reject a missing or replaced coordinator before making new scratch.

Full review comments:

  • [P2] Reject recovery when the retained coordinator is gone — src/plugins/plugin-source-capture-directory.ts:263-264
    If captures and owner.sqlite are removed while the root remains, the introduced mkdir succeeds and the retry creates a capture without a coordinator protecting that path. Another process can then reclaim live worker scratch as tokenless. Check the original root and coordinator identity before recreating the child; the new test removes only captures, so it does not cover this case.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 96e81e68add4.

Labels

Label changes:

  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports native Windows tests using the production capture owner and real filesystem after deleting captures, but the changed recovery path still creates a capture when that root's coordinator is missing or replaced. Show a redacted final-effect trace that rejects that case before allocation, alongside the successful payload-only case. The replay log could not be inspected here; that reviewer limitation does not negate the reported positive test result. No stored-data contract changes. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P1: The linked released Windows setup reports repeated catalog capture failures that disrupt a working provider workflow.
  • merge-risk: 🚨 availability: The new recovery branch can allocate worker scratch under a root whose native coordinator no longer protects it.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The PR reports native Windows tests using the production capture owner and real filesystem after deleting captures, but the changed recovery path still creates a capture when that root's coordinator is missing or replaced. Show a redacted final-effect trace that rejects that case before allocation, alongside the successful payload-only case. The replay log could not be inspected here; that reviewer limitation does not negate the reported positive test result. No stored-data contract changes. Updating the PR body should trigger a fresh review; otherwise ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vyctor H. Brzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Verify the retained root and coordinator still match the live lease before the recovery write, and add a regression for a removed or replaced coordinator.
  • Show final-effect proof for both the allowed payload-only recovery and rejection after coordinator loss, with private paths and other sensitive details redacted.

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-26T08:52:21.115Z sha a01ac0b :: blocked before merge. :: [P2] Reject recovery when the retained coordinator is gone

@steipete
steipete marked this pull request as ready for review September 26, 2026 09:09
@steipete
steipete enabled auto-merge (squash) September 26, 2026 09:13
@steipete
steipete merged commit 4543ce2 into main Sep 26, 2026
294 checks passed
@steipete
steipete deleted the upd/upd-windows-capture-root branch September 26, 2026 09:25
steipete added a commit that referenced this pull request Sep 26, 2026
…ort #158414 to 2026.9.7) (#158910)

* fix(plugins): recover missing retained capture directories (backport #158769)

Recreate a lost payload directory under its existing native custody lease,
without recreating the coordinator parent. Required by the native artifact
admission backport so captures and native payloads can share one live instance.

(cherry picked from commit 4543ce2)

Conflict resolution: release/2026.9.7 predates the recovery test file; port only
the missing-directory regression, without later main-only cleanup tests.
Proof: focused regression passed (1 test, 87 ms; wrapper 2.39 s). Fresh Codex
review found no actionable P0/P1 findings. Refs #158712; thanks @yihan331313.

* perf(plugins): stop reading native plugin artifacts at startup

Reuse installed native admission receipts and retained package payloads across
artifacts and generations while preserving companion namespaces, mutable
snapshots, worker publication, and install rollback ownership.

(cherry picked from commit 9faa93d)

Conflict resolution for release/2026.9.7: retain the release catalog-worker
protocol, installed-index and lease helpers, and token-bearing cleanup policy.
Adapt native footprint coverage to the existing catalog-capture integration
suite. Exclude main-only updater extraction and later catalog/cleanup refactors.
Reuse the release path-selection logic and extract the unchanged browser-asset
predicate. Keep admission preparation and dispatch in a plugin-owned worker
module to preserve the state-worker line cap.

Prerequisite: #158769, 4543ce2, is backported
separately so captures and native directories can share an existing custody lease.
Refs #158414 #157815 #158738.

Evidence: 18 touched files / 288 cases passed three times; 29 importer shards /
11,150 cases passed, plus 10 live cases. Build, release-base changed checks,
and independent P1 review passed on this exact tree.

Slow-test follow-up on release/2026.9.7: update-cli.test.ts, owner: CLI tooling;
main has #157018. No unrelated test-performance changes are included.
roboclaw-bot added a commit that referenced this pull request Sep 27, 2026
Merge the already-landed release/2026.9.7 history at 7bd08b5 into
the reviewed prepared branch without re-cherry-picking external sources.
Preserve canonical native admission, companion namespaces, exact-generation
fingerprints, worker publication and atomic index ownership alongside the
parent's legacy census, cleanup and live lease repairs.

Resolve four conflicts and retain both test inventories. A damaged native
instance is not tokenless legacy scratch: keep its published payload when
the coordinator disappears. Add the existing Doctor journal-history helper
to the extracted-wrapper manifest; no database source changes.

Canonical provenance remains in the merged history:
- #158770 / source #157565 (PollyBot13, landed by Peter Steinberger)
- #158808 / source #158323 (Peter Steinberger)
- #158910 / sources #158414 and #158769 (Peter Steinberger)

Verified 1,019 exact-parent, 82 exact-canonical and nine combined postimages.
Two composition regressions reproduced and corrected. 157 focused owner
cases and two wrapper closure checks pass, as do production/test types,
lint, formatting and all frozen eb377ac ratchets. Full build passed in
262 seconds. Independent P0-P2 review completed all three passes clean.

Compilation is not installed-driver qualification. Normal built integration
preflight still refused runtime-artifact-publication/systemd-competing-managers.
The separate coupled database backport and its bound fixture hunk remain
unapplied. Version and dependencies are unchanged; public size-policy hold
remains active.

Implementation and verification:
https://team.openclaw.ai/chat/roboclaw/subagent/69c28824-7ae8-4692-9037-6998b58bc7f4
Discussion, review and integration:
https://team.openclaw.ai/chat/roboclaw/dashboard/db4d78ac-b19b-4f64-adfb-0ca7973a62e4

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…158769)

Recreate a lost payload directory under its existing native custody lease, without recursively recreating the coordinator parent. Preserve reference counting and advisory cleanup. Refs openclaw#158712; thanks @yihan331313.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

1 participant