Skip to content

fix(worker): preserve turn outcomes when skill cleanup fails - #136958

Merged
steipete merged 2 commits into
mainfrom
steipete/xenodochial-diffie-137454
Sep 3, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/xenodochial-diffie-137454

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136957

Additional instructions

This is a maintainer-owned upstream branch; maintainers can update it.

What Problem This Solves

Fixes an issue where users running worker turns with materialized skills could receive a failed result after their answer was committed and finishing was acknowledged when temporary skill-file deletion failed. Setup rollback could also lose its original cancellation or timeout error behind a secondary deletion error.

Why This Change Was Made

Copied skill inputs now own a private per-turn artifact directory, independent of worker state. Failed deletion is advisory: report a bounded/redacted warning and retained-directory guidance, then preserve the existing result or original error. The node CLI receives exactly that artifact directory as its additional read root; temporary Workshop configuration stays in a separate private directory allocated only when needed.

This isolation matters after #136583 introduced per-turn GitHub profiles inside worker state. The original version of this PR made enclosing state-directory deletion advisory; integration testing caught that this would weaken the new credential-bearing lifecycle. Worker state and GitHub credential cleanup are now byte-for-byte unchanged from the reviewed main baseline and still reject on deletion failure. A denied skill-file deletion cannot obstruct removal of credential-bearing state because the trees are independent.

Process draining, database/transport or MCP closure, authority revocation, privileged desktop cleanup, worker finishing/ACK, interruption precedence, and retry/fallback classification retain their existing behavior. No wire result field, configuration, dependency, store, retry, or timeout was added. The internal materializer directory result serves a real CLI read-permission caller; it is not a protocol change.

User Impact

Completed worker work remains completed when disposable skill-file cleanup is denied, and failed or interrupted work retains its original reason. Operators receive a warning identifying potentially retained skill files. Wait until the worker/session and its owned processes stop before manually checking permissions and removing the reported artifact directory. Integrity and resource-delivery validation still fail closed.

The maintainer explicitly selected advisory cleanup for these disposable skill inputs, not for credential state or privileged resources.

Evidence

The original reproduction used real filesystem EACCES and showed a committed answer plus successful finishing ACK followed by failed worker status. Portable partial-write rollback cases showed the exact frozen primary error being replaced by deletion failure.

After rebasing onto main df4628e68f13dc10a159e7beabf32a14c454db42, six integration regressions failed before the isolation repair: four standalone/managed success, provider-failure and cancellation cases retained worker state when skill deletion was denied; two standalone/managed credential-deletion cases incorrectly resolved. All six now pass: skill deletion warns while credential-bearing state disappears, and denied credential deletion still rejects.

These cases use the actual worker command, embedded loop, WebSocket/RPC owners, transcript store, finishing receiver/result fence, real materializer, actual GitHub-profile writer with synthetic credentials, and real POSIX deletion. Permissions remain blocked through command settlement. They also assert one provider execution and no extra inference or terminal replay. No production test seam was introduced.

220 tests passed across 12 files, in the following focused runs, with no skipped tests on the non-root macOS proof host:

node scripts/run-vitest.mjs src/worker/worker.fault-injection.test.ts src/skills/runtime/resources.test.ts src/node-host/claude-skill-session.test.ts
node scripts/run-vitest.mjs src/skills/library/service.test.ts src/worker/worker-command.runtime.test.ts src/worker/worker-runtime-environment.test.ts src/worker/worker.runtime.test.ts src/worker/embedded-agent-live.runtime.test.ts src/node-host/invoke-agent-cli-claude.test.ts src/node-host/worker-runtime.test.ts src/node-host/runtime.test.ts
node scripts/run-vitest.mjs src/gateway/node-claude-skill-runtime.test.ts --maxWorkers=1

Coverage includes exact frozen cancellation/timeout identity; private artifact and file modes; the exact node read root excluding Workshop config; independent artifact cleanup; actual synthetic CLI execution of supporting files; current-main GitHub identity binding and retained-process isolation; stale-transcript no-replay; background-process/finalizer ordering; desktop cleanup; and MCP close failures. POSIX permission cases explicitly skip Windows/root. There is no additional combined command-timeout/EACCES or typed transcript-error/EACCES case.

Targeted formatting, core/test types, typed lint, dead-export scans, import-cycle and applicable boundary guards passed through the scoped changed gate:

node scripts/check-changed.mjs -- docs/cli/worker.md src/infra/temp-artifact-cleanup.ts src/node-host/claude-skill-session.ts src/node-host/claude-skill-session.test.ts src/skills/library/service.test.ts src/skills/runtime/resources.ts src/skills/runtime/resources.test.ts src/worker/embedded-agent.runtime.ts src/worker/worker.fault-injection.test.ts src/worker/worker.runtime.ts

git diff --check passed. Fresh isolated Codex autoreview covered the complete candidate against the pinned main baseline and is clean at its default P0-only threshold. No full local build, live-model or UI run was performed: this repair is exercised at actual filesystem, command/RPC and synthetic CLI boundaries, without changing an external provider/API, package entrypoint or lazy boundary. Live-model/UI proof was outside the original task's authorization.

Production LOC: +40/-24 (net +16). Tests: +470/-9 (net +461). Docs: +14. Growth supplies the shared bounded/redacted artifact-deletion boundary and exact internal read-root ownership, while removing nested staging and unnecessary Workshop-directory allocation. The ClawSweeper merge-risk item about broadening cleanup policy is addressed: the helper is used only for materialized skill inputs and temporary node Workshop configuration, never worker credential state or privileged cleanup.

Guidance is updated in the worker documentation. Original defect provenance was verified at 1842ab774cd60155803b55248aaf0417b6e2bbd1, with the implicated owners unchanged from b394488146f52b5bc807855ebb64057d7d3c1d3f; the exact introducing commit and shipped-release reachability remain unverified. Generic node CLI prompt-file deletion and non-filesystem close-error precedence remain separate-policy follow-ups. The separate paired-node computer/provider repair is not included.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Sep 3, 2026
@steipete steipete self-assigned this Sep 3, 2026
@steipete
steipete marked this pull request as ready for review September 3, 2026 03:57
@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 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 12:42 AM ET / 04:42 UTC.

ClawSweeper review

What this changes

The PR puts materialized skill files in independent private temporary directories and logs deletion failures without replacing completed, failed, cancelled, or timed-out worker outcomes.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this maintainer-owned, protected PR open for its normal landing path. The repair cleanly separates disposable skill artifacts from credential-bearing worker state and preserves outcomes on artifact deletion failure; no blocking correctness or security defect was found.

Priority: P2
Reviewed head: fb761790e517b12f8b4618d2b2a439ae43ac35ca

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-covered repair with no blocking review findings; ordinary exact-head CI and maintainer handling remain.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-owned internal reliability repair is exempt from the external-contributor proof gate; its supplied source evidence nevertheless exercises the real worker command, composed Gateway owners, and POSIX deletion fault boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-owned internal reliability repair is exempt from the external-contributor proof gate; its supplied source evidence nevertheless exercises the real worker command, composed Gateway owners, and POSIX deletion fault boundary.
Evidence reviewed 8 items Artifact owner: The materializer creates a private OS temporary directory, writes immutable resource files there, and routes cleanup through the bounded best-effort artifact helper so a cleanup error cannot replace the primary result.
Worker outcome boundary: The embedded worker materializes resources before executing the turn and invokes advisory artifact cleanup only in its finalizer after the primary turn path has settled.
Credential cleanup remains strict: The worker runtime still waits for owned processes, closes its state database, restores ambient state, then directly awaits removal of the worker state directory; this PR does not alter that owner.
Findings None None.
Security None None.

How this fits together

Worker turns materialize approved skill bundles before the embedded agent or paired-node Claude session runs. Those temporary files are cleaned up after the turn, while worker state holds lifecycle data and may hold a per-turn GitHub credential profile that must still be deleted strictly.

flowchart LR
  A[Prepared skill bundle] --> B[Private turn artifact directory]
  B --> C[Embedded worker or Node Claude session]
  C --> D[Committed turn outcome]
  B --> E[Artifact cleanup]
  E --> F[Bounded warning if deletion fails]
  D --> G[Final worker result]
  H[Credential-bearing worker state] --> I[Strict state cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - Current-main source blobs could not be fetched from the partial clone because DNS access to GitHub failed; the base-to-main tree comparison found no changes in the reviewed production paths.
  • Resolve merge risk (P1) - This bug fix adds net 16 production lines; the shared helper is justified because it centralizes bounded, redacted advisory cleanup for two disposable-artifact owners rather than duplicating that policy.
  • Complete next step (P2) - An organization maintainer should review this protected member-owned PR after exact-head CI completes successfully.
Agent review details

Security

None.

PR surface

Source +16, Tests +461, Docs +14. Total +491 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 40 24 +16
Tests 4 470 9 +461
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 524 33 +491

Review metrics

Metric Value Why it matters
Production versus test delta production +40/-24 (net +16); tests +470/-9 (net +461); docs +14 The positive production delta is limited to the reusable bounded/redacted artifact-cleanup boundary and isolation of disposable files from credential state.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #136957
Summary: This PR is the linked candidate repair for the worker skill-artifact cleanup 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. Decide the mitigation before merge
    Land the isolated artifact-cleanup policy after exact-head CI and maintainer review, retaining direct rejecting cleanup for worker state and GitHub credential profiles.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the isolated artifact-cleanup policy after exact-head CI and maintainer review, retaining direct rejecting cleanup for worker state and GitHub credential profiles.

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

Yes, source-reproducible with high confidence: the added composed-worker harness creates an actual POSIX EACCES after materialization and checks the final worker result, acknowledged finishing event, and strict credential-state deletion path.

Is this the best way to solve the issue?

Yes. Isolating disposable skill artifacts from credential-bearing worker state fixes the failure at the cleanup owner instead of weakening privileged state cleanup or adding a downstream outcome guard.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a bounded but meaningful worker-turn outcome regression without evidence of emergency availability, data-loss, or security impact.
  • 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: This member-owned internal reliability repair is exempt from the external-contributor proof gate; its supplied source evidence nevertheless exercises the real worker command, composed Gateway owners, and POSIX deletion fault boundary.

Evidence

What I checked:

  • Artifact owner: The materializer creates a private OS temporary directory, writes immutable resource files there, and routes cleanup through the bounded best-effort artifact helper so a cleanup error cannot replace the primary result. (src/skills/runtime/resources.ts:143, fb761790e517)
  • Worker outcome boundary: The embedded worker materializes resources before executing the turn and invokes advisory artifact cleanup only in its finalizer after the primary turn path has settled. (src/worker/embedded-agent.runtime.ts:112, fb761790e517)
  • Credential cleanup remains strict: The worker runtime still waits for owned processes, closes its state database, restores ambient state, then directly awaits removal of the worker state directory; this PR does not alter that owner. (src/worker/worker.runtime.ts:77, fb761790e517)
  • Boundary regression coverage: The added composed-worker cases use real POSIX permission denial and assert both preserved terminal outcomes for artifact deletion and rejection for credential-profile deletion. (src/worker/worker.fault-injection.test.ts:95, fb761790e517)
  • Paired-node caller and sibling contract: The Node Claude caller closes transport before invoking skill cleanup, and the bundled Anthropic runtime already recognizes --add-dir as a value-bearing CLI argument. (src/node-host/invoke-agent-cli-claude.ts:263, fb761790e517)
  • Current-main path check: No reviewed production path differs between the PR base and fetched current main, so the checked base behavior remains the relevant current-main comparison for this patch. (529070704174)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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-03T04:05:34.601Z sha 59242ea :: blocked before merge. :: none

Make temporary skill artifact deletion advisory across materializer, worker environment, and node skill-session cleanup. Warn on retained files while preserving completed results and original errors.

Closes #136957
@steipete

steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready review for fb761790e517b12f8b4618d2b2a439ae43ac35ca: exact-head CI 33715676324 completed successfully, and the required openclaw/ci-gate is independently verified SUCCESS. The earlier head's green run is not being reused.

The latest ClawSweeper review has no correctness or security finding. Its three remaining conditions are addressed:

  • Current-main source availability: fetched d4bc84d7fd8a1f8d902972a5a19c68f39abba1ea, verified the complete worker/GitHub source blobs locally, and confirmed the reviewed production owners are unchanged from the pinned integration baseline. The review worker's DNS/partial-clone limitation is not an evidence gap in this maintainer review.
  • Production growth: the net +16 lines are accepted for a single bounded/redacted policy used only by materialized skill inputs and temporary node Workshop configuration. Worker state, credential deletion and privileged cleanup remain unchanged and rejecting.
  • Maintainer review and CI: source/owner/sibling inspection and fresh isolated Codex autoreview are complete; 220 local tests and current exact-head hosted CI pass. Live effective branch rules require the Actions-owned CI gate and linear history, with no separate independent-approval rule. No server gate is bypassed.

The repaired ownership boundary is physical separation: copied skill files live in a private turn-artifact directory outside worker state. Real EACCES cases prove denied skill deletion preserves the original result while credentials are removed, and denied credential deletion still rejects. The node CLI gets only the exact skill read root; Workshop configuration remains separate. No new wire result field, state store, retry, or timeout.

Local proof, 220 passed across 12 files:

node scripts/run-vitest.mjs src/worker/worker.fault-injection.test.ts src/skills/runtime/resources.test.ts src/node-host/claude-skill-session.test.ts
node scripts/run-vitest.mjs src/skills/library/service.test.ts src/worker/worker-command.runtime.test.ts src/worker/worker-runtime-environment.test.ts src/worker/worker.runtime.test.ts src/worker/embedded-agent-live.runtime.test.ts src/node-host/invoke-agent-cli-claude.test.ts src/node-host/worker-runtime.test.ts src/node-host/runtime.test.ts
node scripts/run-vitest.mjs src/gateway/node-claude-skill-runtime.test.ts --maxWorkers=1
node scripts/check-changed.mjs -- docs/cli/worker.md src/infra/temp-artifact-cleanup.ts src/node-host/claude-skill-session.ts src/node-host/claude-skill-session.test.ts src/skills/library/service.test.ts src/skills/runtime/resources.ts src/skills/runtime/resources.test.ts src/worker/embedded-agent.runtime.ts src/worker/worker.fault-injection.test.ts src/worker/worker.runtime.ts

Scoped checks and git diff --check passed. Six integrated fault cases were observed failing before the isolation repair. POSIX permission tests ran as non-root on macOS; Windows/root skip those cases. No live-model/UI or full local-build proof is claimed; actual filesystem, command/RPC and synthetic CLI owners were exercised, and hosted CI supplies its normal build gates. Exact timeout identity and existing no-replay behavior are covered separately rather than claiming a new combined timeout/typed-transcript-error plus EACCES case.

Proceeding only through the repository-native hosted preparation and merge workflow.

Keep disposable skill inputs in a private per-turn artifact directory while preserving rejecting worker-state and GitHub credential cleanup after #136583.

Refs #136957.
@steipete
steipete force-pushed the steipete/xenodochial-diffie-137454 branch from 59242ea to fb76179 Compare September 3, 2026 04:36
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated the repair to keep materialized skill inputs in an independent private turn-artifact directory. Worker state and GitHub credential deletion are unchanged from main and still reject on failure; node Workshop configuration stays outside the skill read root. This resolves the earlier cleanup-policy merge-risk item without weakening privileged owners, and reduces production growth from +23 to +16 lines.

Six real EACCES integration cases failed before this isolation repair and now pass. The complete local evidence is 220 passing tests across 12 files, scoped checks, and a fresh clean isolated Codex autoreview of the full candidate at the default P0 threshold. The PR body contains exact commands and proof limitations. New exact-head CI must complete before native preparation and merge.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 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
steipete merged commit 204431b into main Sep 3, 2026
210 of 212 checks passed
@steipete
steipete deleted the steipete/xenodochial-diffie-137454 branch September 3, 2026 05:15
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
…w#136958)

* fix(worker): preserve turn outcomes when skill cleanup fails

Make temporary skill artifact deletion advisory across materializer, worker environment, and node skill-session cleanup. Warn on retained files while preserving completed results and original errors.

Closes openclaw#136957

* fix(skills): isolate turn artifacts from worker credential state

Keep disposable skill inputs in a private per-turn artifact directory while preserving rejecting worker-state and GitHub credential cleanup after openclaw#136583.

Refs openclaw#136957.
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 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.

[Bug]: Worker turns fail when temporary skill cleanup is denied

1 participant