Skip to content

fix(nodes): preserve screen output on write failure - #117973

Merged
steipete merged 2 commits into
mainfrom
codex/autoqa-node-screen-atomic-20260802
Aug 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/autoqa-node-screen-atomic-20260802

Conversation

@steipete

@steipete steipete commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #117970

What Problem This Solves

Fixes an issue where users replacing an existing node screen recording or snapshot through CLI --out or agent-tool outPath could lose the original file when the final filesystem write failed. The command/tool reported failure after the destination had already been truncated or partially replaced.

Why This Change Was Made

The shared node-media base64 writer now publishes through the same sibling-temp atomic owner used by generated CLI media. The owner moved from the infer-capability subdirectory to the shared CLI media boundary so image, video, TTS, node CLI, and node agent-tool callers keep one mode, cleanup, and final-rename policy. Existing missing-parent behavior remains unchanged.

No Gateway RPC, node protocol, capture format, workspace guard, config, storage, or provider behavior changes.

User Impact

Failed nodes screen record --out and agent nodes-tool screen_record / screen_snapshot output writes leave an existing destination unchanged. Successful writes still return the requested path and complete media bytes while preserving an existing destination mode.

Evidence

  • Current-main built-artifact reproduction at 85e409452982c7a74589a86ef22115a39c456b6f: a deterministic zero-file-size write failure exited 1 and truncated existing-screen to zero bytes.
  • Blacksmith Testbox tbx_01kz138pxg81d1yyzb7hhe1hcr, run https://github.com/openclaw/openclaw/actions/runs/30745551646:
    • 134/134 final focused assertions passed across prompt snapshots, nodes-camera, the agent nodes tool, and the full CLI node-media command path.
    • Full unscoped check:changed passed, including production/test typechecks, all core and Control UI lint shards, media/database guards, dead-code scans, and zero runtime import cycles.
    • Full build passed and verified all 149 public Plugin SDK subpaths plus the production Control UI build.
    • Source-blind built-artifact contract passed: normal replacement wrote all 2,048 bytes at mode 0640; injected write failure exited 1 while preserving existing-screen, mode 0640, and no sibling temp.
  • Exact head 875e5611ec2587d1e87cf795d4b32e004e6f53e1 on Blacksmith Testbox tbx_01kz15mc6f6rb6rsqnnseefrm6, run https://github.com/openclaw/openclaw/actions/runs/30746971236: remote HEAD and clean tree verified before the full build passed, including all 149 public Plugin SDK subpaths and the production Control UI build.
  • The first hosted run exposed expected prompt-snapshot drift from optional schema prose plus an unrelated SQLite flip-proof model-call failure. The prose was removed to keep scope narrow; all 15 prompt snapshot tests and the 119 node-focused tests then passed on the final candidate.
  • Final autoreview: full candidate clean at 0.98 correctness confidence; schema-only correction clean at 0.99, with no accepted/actionable finding.
  • git diff --check passed.
  • Public model identifier gate: PASS; the diff adds no model identifier.

Production delta: +13/-6 (net +7). Tests: +57/-2. Docs: +1/-0. The production growth is the shared writer call; the prior atomic publisher was moved rather than duplicated.

AI-assisted: yes. No agent transcript attached by user preference.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 11:50
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 8:12 AM ET / 12:12 UTC.

ClawSweeper review

What this changes

The PR moves the CLI media-output helper to a shared CLI boundary and uses it for node screen base64 output so failed writes preserve an existing destination file.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still writes decoded node screen bytes directly to the chosen path, so a failed write can truncate an existing recording or snapshot. The proposed shared atomic publisher repairs that owner boundary, has focused failure/mode/cleanup coverage, and includes strong exact-head Testbox proof; it needs the explicit maintainer merge decision required by its protected maintainer label.

Priority: P0
Reviewed head: 875e5611ec2587d1e87cf795d4b32e004e6f53e1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with strong failure-path proof and no actionable patch defect found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies exact-head Testbox built-artifact evidence showing both successful replacement and a forced write failure that preserves prior bytes, mode, and temporary-file cleanup.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies exact-head Testbox built-artifact evidence showing both successful replacement and a forced write failure that preserves prior bytes, mode, and temporary-file cleanup.
Evidence reviewed 7 items Current-main defect remains: Current main decodes the payload and calls fs.writeFile(filePath, buf) directly, so the linked data-loss report is not already fixed on main.
Repair uses the shared publication boundary: The PR preserves missing-parent failure behavior with a parent stat, then stages the decoded bytes through the existing shared atomic output publisher rather than adding a second node-specific policy.
Shared helper contract and provenance: The publisher stages beside the destination, preserves an existing mode, and delegates final publication to the established sibling-temp primitive; its current CLI-media implementation appears to date to the atomic buffered-media change.
Findings None None.
Security None None.

How this fits together

Node screen capture returns base64 media from a paired node to either the CLI or the agent nodes tool. Both paths reach the shared screen-file writer, which publishes the requested output path for the operator or model to use next.

flowchart LR
  A[Paired node screen capture] --> B[Base64 media payload]
  B --> C[CLI or agent nodes tool]
  C --> D[Shared screen file writer]
  D --> E[Sibling temporary file]
  E --> F[Atomic destination replacement]
  F --> G[Saved recording or snapshot]
Loading

Decision needed

Question Recommendation
Should this protected, P0 data-loss repair be merged after the current-main merge-result refresh? Refresh and merge: Recheck the clean three-way merge against current main, then merge the focused shared-writer repair.

Why: The implementation and exact-head proof are strong, but the maintainer label requires an explicit human merge decision and the branch is behind current main.

Before merge

  • Resolve merge risk (P1) - The branch is 12 commits behind current main; GitHub reports it mergeable, but maintainers should refresh the merge-result review before landing rather than infer safety from the stale base.
Agent review details

Security

None.

PR surface

Source +7, Tests +55, Docs +1. Total +63 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 13 6 +7
Tests 1 57 2 +55
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 71 8 +63

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/cli/nodes-camera.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #117970
Summary: This PR is the focused candidate repair for the linked report's single shared node-screen publication failure.

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 shared atomic publication path after an exact-head/current-main merge refresh, retaining one mode-preserving sibling-temp owner for generated CLI media and node screen outputs.
  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 shared atomic publication path after an exact-head/current-main merge refresh, retaining one mode-preserving sibling-temp owner for generated CLI media and node screen outputs.

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

Yes. The linked report provides a deterministic built-artifact failure path, and current-main source confirms the direct final-path fs.writeFile that permits truncation before failure.

Is this the best way to solve the issue?

Yes. Moving the existing atomic publication owner to the shared CLI media boundary fixes both screen output callers without introducing a parallel node-specific publication policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P0: The pre-fix failure path can erase an existing operator-selected screen recording or snapshot even though the command reports failure.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head Testbox built-artifact evidence showing both successful replacement and a forced write failure that preserves prior bytes, mode, and temporary-file cleanup.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head Testbox built-artifact evidence showing both successful replacement and a forced write failure that preserves prior bytes, mode, and temporary-file cleanup.

Evidence

What I checked:

  • Current-main defect remains: Current main decodes the payload and calls fs.writeFile(filePath, buf) directly, so the linked data-loss report is not already fixed on main. (src/cli/nodes-camera.ts:257, 8206bf1f858c)
  • Repair uses the shared publication boundary: The PR preserves missing-parent failure behavior with a parent stat, then stages the decoded bytes through the existing shared atomic output publisher rather than adding a second node-specific policy. (src/cli/nodes-camera.ts:258, 875e5611ec25)
  • Shared helper contract and provenance: The publisher stages beside the destination, preserves an existing mode, and delegates final publication to the established sibling-temp primitive; its current CLI-media implementation appears to date to the atomic buffered-media change. (src/cli/media-output.ts:20, 610ca42ce3d2)
  • Regression coverage: The PR test injects a post-write failure and verifies that the original bytes, 0640 mode, and directory cleanup remain intact; adjacent coverage confirms successful replacement and no leftover sibling temporary file. (src/cli/nodes-camera.test.ts:296, 875e5611ec25)
  • Both public paths share the repaired writer: Screen recording and snapshot helpers both delegate to writeBase64ToFile; CLI registration and the agent nodes-media tool invoke those helpers for explicit output paths. (src/cli/nodes-screen.ts:42, 8206bf1f858c)
  • Exact-head real behavior proof: The PR body reports an exact-head Blacksmith Testbox built-artifact run that writes 2,048 bytes successfully and preserves an existing output, mode, and directory cleanup when an injected write failure occurs; the supplied checks report success for the same head. (src/cli/nodes-camera.test.ts:296, 875e5611ec25)

Likely related people:

  • steipete: Git blame attributes the direct node-media write to this recent area, and file history associates the shared atomic CLI media publisher with the same contributor. (role: introduced affected writer and recent CLI media contributor; confidence: high; commits: a5b8b7052b27, 610ca42ce3d2; files: src/cli/nodes-camera.ts, src/cli/capability-cli/media-output.ts)

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-08-02T11:55:41.886Z sha 43d5563 :: needs maintainer review before merge. :: none

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 875e5611ec2587d1e87cf795d4b32e004e6f53e1.

Root cause: the shared node-media base64 writer decoded a valid paired-node payload and called fs.writeFile(filePath, buf) on the final user-selected path. CLI nodes screen record --out and agent-tool screen_record / screen_snapshot outPath therefore truncated or partially replaced an existing recording before reporting a filesystem failure.

Provenance (clear): git history traces the raw final-path writer to a92eb1f33d0952f15a16f8b5ad2edaf32d359738 (feat(camera): add snap/clip capture), authored by @steipete on December 14, 2025. Later screen helpers reused that writer, and the CLI plus agent-tool explicit output callers inherited the failure mode.

Canonical repair: the existing atomic CLI media publisher moved from the infer-capability subdirectory to src/cli/media-output.ts, and the shared node writer now stages decoded bytes there. Image, video, TTS, CLI node screen, and agent nodes-tool callers use one mode-preserving sibling-temp owner. The parent-directory preflight retains the prior missing-parent failure behavior; Gateway RPC, node protocol, capture formats, workspace guards, and no-output temp artifacts are unchanged.

Proof:

Scope: 7 files; production +13/-6 (net +7), tests +57/-2, docs +1/-0. No config, protocol, storage, migration, dependency, provider, capture, or Gateway RPC change. Residual risk is low and confined to final local node-screen file publication. No known proof gaps.

@steipete
steipete merged commit 5739f42 into main Aug 2, 2026
128 of 132 checks passed
@steipete
steipete deleted the codex/autoqa-node-screen-atomic-20260802 branch August 2, 2026 12:22
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* fix(nodes): publish screen output atomically

Closes openclaw#117970

* fix(nodes): keep output schema unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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]: Node screen output can erase existing files on write failure

1 participant