Skip to content

fix(nodes): validate capture batches before publishing files - #130371

Merged
steipete merged 1 commit into
mainfrom
codex/loc-sweep-camera-batch-atomicity-20260826
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-sweep-camera-batch-atomicity-20260826

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The agent camera tool and nodes camera snap --facing both published the front image before checking the back response. A malformed second native payload could leave a private photo on disk even though the command failed. The photo-library path already preflighted its native batch but duplicated result construction.

Why This Change Was Made

Gather and validate native responses before publishing any capture file. Reuse one artifact/result owner for agent camera and photo-library responses; the CLI gathers safe output paths before writing. Invalid first responses still stop before the second camera is invoked. Existing safe CLI format extensions remain accepted.

Production LOC: +98/-101 (net -3). Tests: +97/-0. No config, schema, protocol, dependency, or model tool-result contract changes. This follows the parser hardening in #116927; the older per-capture publishing loop remained in place after that repair.

User Impact

A malformed later native response no longer leaves an earlier private camera image published. This is native-payload/path preflight, not batch rollback for later network or filesystem errors. All requested captures now precede downloads; a later download or write failure can still leave a valid earlier file. Per-file atomic publication remains unchanged.

Evidence

  • Exact candidate: 1807f208710b09ddefc906a54aa51dbaa70a03ea, rebased onto landed CLI fix(cli): validate node options before contacting the Gateway #130352 at 52beb5e113ead4730b7488c42e97d19feaeaeb9b. Original reviewed camera head was 14d88d0a2d91c5ddbb82b9cc51b6d08ba29b6c3a.
  • Four new agent/CLI regressions fail on the original code, observing a real fs.rename of the first JPG before rejection of malformed base64 or format. They pass with this change; actual published files are read back/cleaned up.
  • 168 owner and sibling tests pass with matching dependencies. Native node responses are controlled fixtures; this is real filesystem publication proof, not physical-camera testing.
  • Fresh structured Codex P1 and separate independent review passed on the final candidate; the independent reviewer also ran 47 camera tests.
  • All selected changed-gate components passed. The aggregate run first stopped on a missing task UI dependency link; after repairing only that environment link, the exact remaining type/lint/guard commands passed. The original aggregate exit was not green; required clean hosted CI remains mandatory.
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs src/agents/openclaw-tools.camera.test.ts src/agents/tools/nodes-tool.test.ts src/cli/nodes-cli/register.camera.test.ts src/cli/nodes-camera.test.ts src/cli/nodes-media-utils.test.ts

The coordinated CLI preflight refactor #130352 is now landed. Its one actual camera-registration merge conflict was resolved by retaining early pure input/timeout validation and the capture preflight array, removing only the duplicated old timeout declaration. The exact combined tree 5867ed2101a8bb1417693684146ee249ca96d9ed passed 260 tests across ten files, all eleven runtime/declaration build phases, formatting, lint, core and core-test TypeScript. Twenty actual rebuilt CLI invalid-input subprocesses produced the expected local diagnostic with zero Gateway TCP connections; a valid canary made one connection. Both independent source/proof reviewers approved the exact tree.

Fresh integration review initially asked for broader URL-download/filesystem rollback. The finding was checked against complete parser/writer source and the pre-existing explicit scope above: native-payload/path preflight is repaired; later network/filesystem rollback is not promised. The raw findings and source-based disposition are retained. A fresh review with the full contracts passed without accepted/actionable findings. No production changes were made to obtain that result. Current-head hosted CI must pass before landing.

Named pre-existing follow-ups: the human-duration clip E2E case lacks its neighboring artifact-readback/cleanup assertion; camera docs still mention --duration-ms although registration exposes --duration. Neither is claimed fixed here. Maintainer-requested, AI-assisted.

@clawsweeper

clawsweeper Bot commented Aug 26, 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 cli CLI command changes agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 20:21
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 5:08 PM ET / 21:08 UTC.

ClawSweeper review

What this changes

The PR gathers and validates all requested node-camera responses before writing image artifacts, and consolidates agent camera and photo-library result construction.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer merge handling: current main still publishes each camera capture inside its request loop, while this PR establishes the intended validate-all-before-publish boundary without an actionable correctness finding.

Priority: P1
Reviewed head: 1807f208710b09ddefc906a54aa51dbaa70a03ea
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-boundary repair and focused regressions are solid; exact-head hosted checks remain the final merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state classifies the author as a MEMBER; the external-contributor proof gate does not apply, while the PR body supplies filesystem-focused after-fix evidence for maintainer review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state classifies the author as a MEMBER; the external-contributor proof gate does not apply, while the PR body supplies filesystem-focused after-fix evidence for maintainer review.
Evidence reviewed 6 items Current-main failure boundary: Current main invokes a capture, parses it, and writes its artifact within the same loop; with two targets, the first artifact can be published before the later native response is read.
Agent owner repair: The PR first accumulates parsed and format-validated snapshots, then sends that complete collection to the single artifact/result owner, so no writer is reached after a malformed later response.
CLI sibling repair: The CLI now builds its capture collection before its separate writing loop, covering the same facing=both ordering invariant as the agent tool.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw nodes camera snap --help

Result: PASS (completed)

$ node scripts/run-node.mjs nodes camera snap --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 84.92 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.6s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 12.9s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 3578ms (slowest: built plugin control-plane loads 2922ms)
│
◇

OpenClaw 2026.8.1 (1807f20) — All your chats, one OpenClaw.

Usage: openclaw nodes camera snap [options]

Capture a photo from a node camera (prints the saved path)

Options:
  --delay-ms ‹ms›             Delay before capture in ms (optional; platform-specific default)
  --device-id ‹id›            Camera device id (from nodes camera list)
  --facing ‹front|back|both›  Camera facing
  -h, --help                  Display help for command
  --invoke-timeout ‹ms›       Node invoke timeout in ms (default 20000) (default: "20000")
  --json                      Output JSON (default: false)
  --max-w
… output truncated …

Assertions:

  • PASS expect_output: Capture a photo from a node camera

How this fits together

Node camera commands request media from paired devices, validate native payloads, then publish temporary image files for CLI output or agent tool results. The changed boundary is the handoff from native response handling to filesystem publication.

flowchart LR
A[CLI or agent camera request] --> B[Paired node captures]
B --> C[Payload and format validation]
C --> D[Temporary image publication]
D --> E[CLI paths or agent results]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned PR land with its explicit native-payload/path-preflight scope, retaining existing per-file behavior for later download or filesystem failures? Land the scoped privacy repair: Merge after exact-head checks pass, preserving the documented behavior that only malformed native payloads prevent all publication.

Why: The patch intentionally changes when requested captures occur relative to publication, and the protected maintainer workflow requires a human merge decision even though the source-level repair is sound.

Before merge

  • Resolve merge risk (P1) - Exact-head hosted checks were still running in the supplied PR state; normal merge gates should complete before landing.
Agent review details

Security

None.

PR surface

Source -3, Tests +97. Total +94 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 98 101 -3
Tests 2 97 0 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 195 101 +94

Review metrics

Metric Value Why it matters
Production versus regression-test LOC production +98/-101 (net -3); tests +97/-0 The bug fix removes duplicate result construction while adding focused ordering regressions for both agent and CLI publication paths.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared gather-then-validate-then-publish flow after exact-head checks pass, while keeping later download or filesystem rollback out of this narrowly defined repair.
  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 gather-then-validate-then-publish flow after exact-head checks pass, while keeping later download or filesystem rollback out of this narrowly defined repair.

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

Yes—source-reproducible with high confidence: current main writes the first facing=both capture before requesting and validating the second response. The review did not execute the fixture because the target checkout is read-only.

Is this the best way to solve the issue?

Yes—the shared artifact owner validates all native responses before publication and is narrower than adding rollback logic for independent later network or filesystem failures.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P1: The PR addresses a current path where a malformed later node response can leave an earlier private camera artifact published.
  • 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 repository state classifies the author as a MEMBER; the external-contributor proof gate does not apply, while the PR body supplies filesystem-focused after-fix evidence for maintainer review.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the central media-result path to Peter Steinberger, and the same contributor authored the related merged photo-payload and CLI-preflight repairs. (role: recent node-camera preflight contributor; confidence: high; commits: 6f2409b68024, 52beb5e113ea; files: src/agents/tools/nodes-tool-media.ts, src/cli/nodes-cli/register.camera.ts, src/cli/nodes-camera.ts)

Rank-up moves

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

  • Allow the exact-head hosted checks to complete successfully before merge.

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-26T20:29:38.223Z sha 14d88d0 :: needs maintainer review before merge. :: none

Gather and validate each requested camera response before publishing any capture, so a malformed second reply cannot leave the first photo on disk. Reuse photo artifact and result construction for camera snapshots and library photos.

Preserve first-payload validation before requesting another camera. Downloads and filesystem failures retain per-file semantics rather than promising batch rollback.
@steipete
steipete force-pushed the codex/loc-sweep-camera-batch-atomicity-20260826 branch from 14d88d0 to 1807f20 Compare August 26, 2026 21:01
@steipete

Copy link
Copy Markdown
Contributor Author

Addressing the latest ClawSweeper review and rank-up move: the documented patch scope remains native-payload/path preflight, not a new transactional download feature. An explicit request for both cameras authorizes both captures; each returned native payload and generated path is validated before requesting the next capture. After all replies validate, downloads and writes begin. Later network/filesystem failure retains per-file semantics and is not rolled back. This is the reviewed scope of the repair, not a claim of a new product-policy decision.

#130352 is now landed. Its actual merge conflict was resolved and independently reviewed at camera head 1807f208710b09ddefc906a54aa51dbaa70a03ea, tree 5867ed2101a8bb1417693684146ee249ca96d9ed: early CLI argument validation remains before Gateway lookup; native payload/path validation remains before any file publication.

The exact combined source passes 260 tests across ten files, all eleven runtime/declaration build phases, formatting, lint, core and core-test TypeScript. Twenty actual rebuilt CLI invalid-input subprocesses produced the expected diagnostic and zero Gateway TCP connections; a valid canary made one connection. These supersede the review helper's 30-second build/help timeout. Native camera replies are controlled fixtures; publication uses the real filesystem, not physical cameras.

The first integration review's two broader rollback findings were retained and checked against complete parser/writer source. A subsequent review with those full contracts found no accepted/actionable issue within the stated scope; both independent final-source/proof reviews pass. Fresh exact-head CI is running and must pass before native landing.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Aug 26, 2026
@steipete
steipete merged commit e0a4915 into main Aug 26, 2026
202 of 204 checks passed
@steipete
steipete deleted the codex/loc-sweep-camera-batch-atomicity-20260826 branch August 26, 2026 21:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…w#130371)

Gather and validate each requested camera response before publishing any capture, so a malformed second reply cannot leave the first photo on disk. Reuse photo artifact and result construction for camera snapshots and library photos.

Preserve first-payload validation before requesting another camera. Downloads and filesystem failures retain per-file semantics rather than promising batch rollback.
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 maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. 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