Skip to content

fix(agents): failed apply_patch deletes earlier files when a later update hunk cannot apply - #160409

Merged
obviyus merged 6 commits into
openclaw:mainfrom
masatohoshino:fix/117742-apply-patch-preflight
Oct 15, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
masatohoshino:fix/117742-apply-patch-preflight

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #117742

What Problem This Solves

Fixes: a multi-file apply_patch call permanently deletes, creates, or rewrites earlier files when a later update hunk targets a missing file or its context lines do not match, while the tool only reports the later error.

User Impact

User impact: when an update hunk in a patch cannot apply, the whole patch now rejects before any file changes, so the workspace is left exactly as it was and the agent's retry starts from the state it expects.

Why This Change Was Made

The issue and #127496 leave one durability question open: after a failure that happens while files are being written (I/O error, a competing writer, cancellation mid-commit), should apply_patch compensate, or keep the earlier effects and report them? This PR does not make that choice. It implements only the part both options in the ClawSweeper review share, which is also the first step of the repair described in #127496: validate the ordered envelope before writing, while holding the file queues for the whole envelope.

  • All hunk targets resolve first, and the patch holds the file-mutation queue for every path it touches for the whole run, so the check reads the same state the writes act on.
  • Every update hunk is then computed in order before anything is written, with the same applyUpdateHunk the write pass uses. Earlier adds, updates, deletes and moves in the same patch are staged by physical file identity, so an update of a file added or changed earlier in the patch still works, and an update of a file an earlier hunk deletes or moves away rejects up front. A missing file, a context mismatch or invalid UTF-8 rejects with no mutation.
  • Links are staged apart from the files they name. Queue identity follows a final symlink, so a link and its target share one key, but deleting the link leaves the target in place. A delete or move of a final symlink therefore stages the link path by its spelling, and later hunks at or under that path (Add File: link, Update File: link, Move to: link, Add File: dir-link/x.txt) use that path stage, which starts out removed. The target keeps its own staged contents, so Delete File: link followed by a mismatched Update File: target now rejects before the link is deleted, and Delete File: link, Add File: link, Update File: target no longer checks the target against the new link contents. The write pass decides whether an update is a move from the same stages, so Update File: target with Move to: link after Delete File: link moves the file instead of rewriting it in place.
  • Names of one hardlinked file share staged contents in unrestricted host mode (workspaceOnly: false), where an update rewrites the file in place and every name sees it. Each name has its own queue identity, so an update hunk of a hardlinked file (more than one link at the snapshot) stages by the file's device and inode instead, until an earlier hunk in the patch deletes, re-creates or moves that name. Update File: a followed by Update File: b whose context matches the text written through a applies again, as it does on main. Moving one name away leaves the shared contents for the other names. Confined mode refuses hardlink aliases, and the sandbox helpers refuse hardlinked reads and replace files atomically, so neither shares contents across names.
  • Path admission for a later hunk runs against the initial snapshot. When an earlier removal changes what admission sees (a symlink or file replaced by a regular file or directory, or the last other name of a hardlink), that hunk repeats strict admission in the write pass right before it runs, after the earlier hunk has removed the path. The link target is never read or written. A later path matches an earlier host symlink removal by the link entry's own identity (lstat device and inode) as well as by spelling, so the filesystem decides which spellings name the removed link: on a case-insensitive volume, Delete File: link.txt then Add File: LINK.txt (or Add File: D/x.txt after Delete File: d) replaces the link as it does on main. A symlink with more than one hardlinked name matches by spelling only, because its identity also names the entries that stay. Any other admission failure still rejects the whole patch up front, even after an unrelated delete.

Deliberately left out: compensation or a partial-effect result for failures that only show up during the write pass (an add whose destination exists, a delete of a missing file, a move onto an existing file, removing a directory, I/O errors, cancellation between writes). Those still behave as on main and need the maintainer decision above. For the same reason this PR does not close the issue on its own; keeping #117742 open for that decision is fine.

Scope tradeoff for maintainers: landing this PR means accepting a bounded fix. A patch whose update hunk cannot apply now leaves the workspace untouched, but a patch that fails during the write pass can still leave the effects of earlier hunks in place without reporting them, exactly as on main. Closing that gap needs the compensation or partial-effect decision tracked in #127496.

Where the check cannot predict the state it leaves the hunk to the write pass, which stays authoritative, rather than reject a patch the write pass would accept: an update of the other name of a hardlink that an earlier delete frees, and an unreadable new path whose spelling differs only in case from a path an earlier hunk staged (case-insensitive filesystems keep the spelled case in the identity of a missing path).

Design note: I chose a read-only preflight in front of the unchanged write pass over a staged plan with an undo journal. The staged plan must model every backend precondition (entry kinds, parent topology, symlink handling in the sandbox bridges), and #122933 stalled on exactly that.

The branch is rebased onto current main. The patch parser moved unchanged to src/agents/apply-patch-parse.ts (main's current parser, which returns the hunk list directly), and the tests this PR adds live in src/agents/apply-patch.preflight.test.ts, so both files stay within the line-cap ratchet.

The existing permission-change fence test now expects the abort at the envelope checkpoint: the read that triggers it happens in the preflight, so the rejection is an AbortError that carries the permission-change reason as its cause, and the file still stays unchanged.

Evidence

Real behavior: an isolated Gateway built from each side (own state directory, loopback port, channels skipped) with a keyless local mock model that makes one agent turn call the real apply_patch tool with the envelope from the issue (Delete File: important.txt, then Update File: missing.txt). The workspace is seeded with important.txt.

Before (upstream main, no apply_patch changes since):

== workspace before: important.txt 
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after: 
== important.txt after: <MISSING>

After (this branch, same Gateway setup and turn):

== workspace before: important.txt 
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after: important.txt 
== important.txt after: irreplaceable-user-data

Control on this branch, a valid envelope (delete, add, then update of the just-added file) still applies in order:

== workspace before: important.txt 
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
== workspace after: notes.txt 
== important.txt after: <MISSING>

The Gateway proof above is still valid for this head: its envelope does not involve a link, a hardlink or a path an earlier hunk frees, so it takes the same path as before the link and hardlink staging changes.

Hardlink names in unrestricted mode, same Gateway setup with tools.exec.applyPatch.workspaceOnly: false. The workspace holds original.txt (one) and alias.txt, a second hardlink to the same file. The turn sends Update File: original.txt (one to two), then Update File: alias.txt (two to three).

Before (previous head of this branch, rebased onto current main without the hardlink change; main accepts this envelope):

== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to find expected lines in <workspace>/alias.txt:\ntwo"
}
== after: original.txt=one alias.txt=one links=2

After (this head):

== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
M original.txt
M alias.txt
== after: original.txt=three alias.txt=three links=2

Tests (src/agents/apply-patch.preflight.test.ts, through the real apply_patch tool or applyPatch):

  • Delete before an update of a missing file, and add plus update before a context mismatch: fail on main with the earlier effects committed, pass here. Updates of files added or changed earlier in the same patch, including a move, still apply.
  • Delete File: link.txt (a symlink to an in-workspace target.txt) followed by a mismatched Update File: target.txt, or by Update File: target.txt / Move to: link.txt and a later update of target.txt: fail on an earlier head of this branch (the link is deleted before the error) and pass here with the link and target unchanged.
  • Delete File: link.txt, Add File: link.txt, Update File: target.txt, Update File: link.txt, and Update File: target.txt / Move to: link.txt after the delete: fail on an earlier head of this branch (false context mismatch on the target, or an in-place rewrite instead of a move) and pass here.
  • Outside-link and directory-link replacement (Delete File: d, then Add File: d/x.txt, Add File: d/..cache, Delete File: d/x.txt), a regular file replaced by a directory, and both names of a hardlink (re-create the deleted name, or update the other name): sequences main accepts; they fail on earlier heads of this branch, where admission ran only against the snapshot, and pass here.
  • A moved symlink path updated again, and an outside-symlink update after an unrelated delete: reject before any mutation.
  • Unrestricted mode (workspaceOnly: false) with two hardlink names: an update of the second name using text written through the first, alone or after deleting the first name, applies as on main. These cases pass on main, fail on the previous head of this branch, and pass here. A third case (move the first name away, then update the second against the original text) guards that a move does not carry the new contents to the other name.
  • A removed outside symlink replaced under different casing (Delete File: link.txt, Add File: LINK.txt; Delete File: d, Add File: D/x.txt), gated on a case-insensitive temp volume. Run on macOS 15.7.9 (Intel, case-insensitive APFS) with this head's tests and each side's src/agents/apply-patch.ts: main passes both, the previous head of this branch (583baf2) fails both with Symlink escapes sandbox root, and this head passes both. The full apply-patch suites pass there on this head (162 passed, 1 Linux-only skip). Linux CI skips these two cases.
  • A hardlinked symlink (Linux link(2) on a symlink): Delete File: a then Update File: b for the other name still updates the target, as on main; it fails on an intermediate version of this fix that matched any symlink by identity.
  • Fail-to-pass run against main (merge base, Linux): the 7 regression tests above fail on main and pass here. The hardlink cases pass on main and here, and fail when the hardlink staging is removed from this head. The casing cases skip on Linux, so their before/after evidence is the macOS run above.
  • node scripts/run-vitest.mjs src/agents/apply-patch*.test.ts: 12 files, 161 tests pass on Linux (2 macOS-only skips).
  • pnpm check:changed: passes on the current head, apart from the dead export scan, which fails only on exports in files this PR does not touch (src/plugins/config-policy.ts, src/media-understanding/defaults.ts) and was skipped for the rerun.
  • Review: a fresh-context code review at high effort, repeated after each round of fixes; its confirmed findings (move detection after a link delete, hardlink and directory-link replacement, held queue keys for removed link paths, case-folded link detection on the host, ..-prefixed names under a removed link, abort checks during resolution) are fixed and covered above. A fresh-context review of the hardlink change found no correctness issue; it traced further hardlink, symlink and move sequences, which all matched the ordered writer, and the one wording note it raised is applied. A fresh-context review of the casing change found that a hardlinked symlink's identity also names its other entries (a delete of one name then made an update of the other reject); identity matching now requires a single link, with a regression test.
Test file pnpm test <file> --maxWorkers=1 wall CI seconds New cases
src/agents/apply-patch.preflight.test.ts 6.0 s (20 tests, 2 skip on Linux) pending for this head 20 cases, each under 15 ms of test time
src/agents/apply-patch.test.ts 6.3 s pending for this head none (one assertion changed)

Maintainer E2E verification

Verified on macOS arm64 through an isolated, built Gateway and the real openclaw agent CLI. The Gateway used fresh state, workspace and HOME, loopback-only ports, and a local OpenAI Responses fixture model following the repository's existing HTTP/SSE test contract. No production state, personal API credentials, or CLI-login credentials were used. The model request advertised the real apply_patch tool; the next model request contained its actual function_call_output from the filesystem operation.

Baseline: 372ff7cacef (fresh main). Candidate: contributor head merged with that main, then simplified; final head e8d17b1d604780c1e351f74ef7e221fde5ba1967. Runtime E2E ran at 6353875b56e and again at d908d9ea2d4; the final commit only restores the existing permission-fence test assertion, without changing production code.

Real Gateway scenario Main Candidate / simplified head
Delete important.txt, then update missing missing.txt Tool reports the missing-file error; important.txt is permanently missing Same tool error; important.txt retains irreplaceable-user-data\n
Add created.txt, rewrite important.txt, then fail a later context match Not rerun on main Simplified head rejects; only the unchanged original important.txt remains
Valid delete, add notes.txt, then update the newly added file Not rerun on main Simplified head succeeds; notes.txt contains final\n

Redacted model-visible failing result on both sides:

{
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}

The valid control returned:

Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt

All task-owned Gateways and fixture model servers were stopped. This is deterministic model-boundary proof, not a claim about live model behavior or commit-time rollback.

Checks:

  • Baseline full pnpm build, candidate and simplified pnpm build:runtime: passed.
  • All nine apply-patch*.test.ts suites were exercised. Initial result: 151 passed, one Linux-only skip, one outdated permission-error assertion failed. After restoring that assertion to main's existing contract, the affected suite passed all 51 tests. The other eight suites' passing results remain applicable.
  • node scripts/run-tsgo.mjs -p tsconfig.core.json --noEmit: passed.
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-root.json --noEmit: passed, including after the assertion repair.
  • Scoped Oxlint and Oxfmt: passed.
  • check:test-timeout-race-ratchet --base origin/main, check:test-mock-exports, and check:assertion-safety: passed.
  • UI was not changed; no UI typecheck was needed.

Maintainer simplification

Preserved the contributor's commits and merged current main without rebasing or force-pushing. The merge retains main's ToolInputError classification and its already-simplified parser in the extracted parser module. Replaced two temporary-array constructions in patch staging with direct iteration, including removal of the tuple assertion. Restored main's existing permission-change assertion because the current guarded read rejects before the envelope checkpoint; the test still proves the file remains unchanged.

The ordered staging, link/hardlink identity handling, and distinct filesystem regression cases are retained: they preserve accepted ordered patches while adding preflight, rather than pursuing a separate behavior change. No new rollback or partial-effect contract was introduced.

Final diff against the main merge base: production +725/-299 (net +426); tests +434/-0. Parser extraction accounts for +218 production lines; the required ordered preflight and filesystem-identity handling account for the remaining growth. The original apply-patch.test.ts has no net diff from main.

No overlap with Pash/Sarah changes in the touched files. Full diff security read found no new network access, credential reads, package/lockfile changes, or build-script changes. The contributor had 123 merged OpenClaw PRs at inspection.

The broader durability decision in #117742 / #127496 remains open: commit-time I/O failures, cancellation between writes, and other write-pass failures can still leave partial effects. This PR is the bounded update-preflight improvement and should not close those issues by itself.

@clawsweeper

clawsweeper Bot commented Sep 28, 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 agents Agent runtime and tooling size: M labels Sep 28, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The patch tool validates ordered update hunks before writing, holds file queues across the envelope, and preserves existing link and replacement behavior.

Example: Delete important.txt containing irreplaceable-user-data, then update nonexistent missing.txt.

  • Before: The tool rejects, but important.txt has already been deleted.
  • After: The tool rejects before writing, and important.txt retains its original contents.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong production-entry-point proof and no actionable introduced defect; the PR intentionally fixes only part of the linked issues' broader durability expectation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied macOS arm64 verification exercises an isolated built Gateway through the real openclaw agent CLI and real apply_patch filesystem operations. Main loses important.txt after a missing-file update; the candidate preserves its bytes, rejects a later context mismatch without earlier mutations, and accepts valid ordered edits. Production code is unchanged after the verified simplified head. Earlier supplied runs also exercise unrestricted hardlinks and case-insensitive symlink replacement. No persisted format or migration changes are introduced.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A failed multi-file patch can silently leave earlier workspace files deleted or rewritten.
Reason: The scoped improvement prevents a demonstrated destructive failure without adding configuration or changing successful patch contracts; the broader issues correctly remain open.

Merge readiness

✅ Ready for maintainer review

This PR addresses a demonstrated data-loss defect still present on current main, with convincing Gateway proof and no blocking introduced defect found.

Priority: P0
Reviewed head: e8d17b1d604780c1e351f74ef7e221fde5ba1967

Before merge

None.

Findings

None.

Agent review details

How this fits together

Agents submit patch envelopes to OpenClaw's coding tool; it resolves host or sandbox paths, performs guarded filesystem operations, and returns a summary or error.

flowchart TD
  A[Agent patch input] --> B[Parse operations]
  B --> C[Resolve paths and reserve queues]
  C --> D[Preflight ordered updates]
  D --> E[Reject invalid updates]
  D --> F[Guarded filesystem commit]
  F --> G[Summary or write error]
Loading

Technical review

Best possible solution:

Land the bounded update preflight while keeping commit-time recovery and truthful partial-effect reporting in the broader durability reports.

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

Current-main source establishes the delete-then-missing-update failure, and supplied Gateway before/after output demonstrates it; this read-only review did not execute the reproduction.

Is this the best way to solve the issue?

The existing patch owner can prevent predictable update failures before mutation while retaining guarded writes; compensation after commit-time failure is a separate unresolved contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 591db854a7a7.

Provenance checked

  • Immediate per-hunk mutation changes intended behavior with a stated reason (8b4bdaa: The initial patch tool applied parsed operations sequentially; no envelope-level preflight or rollback was implemented.)
  • Physical file queues and input-path interpretation keeps the original intent (fix(sandbox): queue reads behind in-flight writes to the same file #125091: Shared physical identities preserve same-file ordering across aliases; subsequent path-resolution work freezes literal versus shorthand interpretation before mutation.)
  • Exclusive add and move destinations keeps the original intent (fix(agents): apply_patch destroys an existing file when a patch creates that path #114911: Fail closed instead of silently overwriting existing destinations, while allowing explicit ordered replacement.)
  • Parser extraction keeps the original intent (395ad80: The existing parser consolidation preserved grammar and error behavior; extraction retains that implementation.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8b4bdaa adds src/agents/apply-patch.ts:87 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8b4bdaa8a473; files: src/agents/apply-patch.ts)
  • Mohit Malik: Raw commit b87f6d3 adds src/agents/apply-patch.ts:414 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b87f6d374c56; files: src/agents/apply-patch.ts)
  • Sally O'Malley: Raw commit 1c5b042 adds src/agents/apply-patch.ts:320 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1c5b042b2567; files: src/agents/apply-patch.ts)

PR surface

Source +426, Tests +434. Total +860 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 725 299 +426
Tests 1 434 0 +434
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 1159 299 +860

Review metrics

Metric Value Why it matters
Production versus test growth Production +725/-299, net +426; tests +434/-0. Parser relocation contributes to gross additions; remaining growth implements ordered preflight and preserves demonstrated filesystem identity contracts.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #117742
Summary: This PR fixes predictable update failures within the broader partial-commit defect, without resolving write-time recovery.

Members:

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P0: The existing default agent tool can permanently delete workspace data while reporting only a later patch failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-28T11:53:54.636Z sha c5349bfcb96020ca08c6e69be3b3f0e811cdd113 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T13:44:28.559Z sha c5349bfcb96020ca08c6e69be3b3f0e811cdd113 :: blocked before merge. :: [P1] Preserve delete-then-add replacement of a symlink
  • reviewed 2026-09-28T15:58:55.097Z sha 59c39297353a37cc75d15983a4aeff5091d83de4 :: blocked before merge. :: [P1] Keep symlink unlink state separate from target contents
  • reviewed 2026-09-28T18:36:38.518Z sha 47fbeba2ec8f94a140cb03c5d66c31010f509e50 :: blocked before merge. :: [P1] Preserve updates through both names of a hardlink
  • reviewed 2026-10-05T17:04:33.772Z sha 583baf2 :: blocked before merge. :: [P1] Match removed symlinks across equivalent filename casing
  • reviewed 2026-10-06T04:28:21.632Z sha d53f359 :: needs maintainer review before merge. :: none

Reviewed October 15, 2026, 4:04 PM ET / 20:04 UTC (Revision 7).

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 28, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 28, 2026
@masatohoshino
masatohoshino force-pushed the fix/117742-apply-patch-preflight branch from 47fbeba to 583baf2 Compare October 5, 2026 16:54
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 6, 2026
@obviyus

obviyus commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 15, 2026
@obviyus
obviyus merged commit 5348bbc into openclaw:main Oct 15, 2026
126 of 128 checks passed
@obviyus

obviyus commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Landed in 5348bbc. Thanks @masatohoshino! A failed apply_patch no longer deletes files from earlier hunks. Verified end to end: on main the earlier file was deleted before the later hunk failed; with this change it survives. Broader commit-time recovery stays tracked in #117742 / #127496.

RomneyDa pushed a commit that referenced this pull request Oct 16, 2026
Backport the merged predictable-failure data-loss fix, retaining its ordered patch and filesystem identity contracts. Resolve apply-patch.ts against the exact merged source, including its existing ToolInputError classification; the error owner is already present on this branch.

(cherry picked from commit 5348bbc)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…date hunk cannot apply (openclaw#160409)

Related: openclaw#117742

## What Problem This Solves

Fixes: a multi-file `apply_patch` call permanently deletes, creates, or rewrites earlier files when a later update hunk targets a missing file or its context lines do not match, while the tool only reports the later error.

## User Impact

User impact: when an update hunk in a patch cannot apply, the whole patch now rejects before any file changes, so the workspace is left exactly as it was and the agent's retry starts from the state it expects.

## Why This Change Was Made

The issue and openclaw#127496 leave one durability question open: after a failure that happens while files are being written (I/O error, a competing writer, cancellation mid-commit), should `apply_patch` compensate, or keep the earlier effects and report them? This PR does not make that choice. It implements only the part both options in the ClawSweeper review share, which is also the first step of the repair described in openclaw#127496: validate the ordered envelope before writing, while holding the file queues for the whole envelope.

- All hunk targets resolve first, and the patch holds the file-mutation queue for every path it touches for the whole run, so the check reads the same state the writes act on.
- Every update hunk is then computed in order before anything is written, with the same `applyUpdateHunk` the write pass uses. Earlier adds, updates, deletes and moves in the same patch are staged by physical file identity, so an update of a file added or changed earlier in the patch still works, and an update of a file an earlier hunk deletes or moves away rejects up front. A missing file, a context mismatch or invalid UTF-8 rejects with no mutation.
- Links are staged apart from the files they name. Queue identity follows a final symlink, so a link and its target share one key, but deleting the link leaves the target in place. A delete or move of a final symlink therefore stages the link path by its spelling, and later hunks at or under that path (`Add File: link`, `Update File: link`, `Move to: link`, `Add File: dir-link/x.txt`) use that path stage, which starts out removed. The target keeps its own staged contents, so `Delete File: link` followed by a mismatched `Update File: target` now rejects before the link is deleted, and `Delete File: link`, `Add File: link`, `Update File: target` no longer checks the target against the new link contents. The write pass decides whether an update is a move from the same stages, so `Update File: target` with `Move to: link` after `Delete File: link` moves the file instead of rewriting it in place.
- Names of one hardlinked file share staged contents in unrestricted host mode (`workspaceOnly: false`), where an update rewrites the file in place and every name sees it. Each name has its own queue identity, so an update hunk of a hardlinked file (more than one link at the snapshot) stages by the file's device and inode instead, until an earlier hunk in the patch deletes, re-creates or moves that name. `Update File: a` followed by `Update File: b` whose context matches the text written through `a` applies again, as it does on main. Moving one name away leaves the shared contents for the other names. Confined mode refuses hardlink aliases, and the sandbox helpers refuse hardlinked reads and replace files atomically, so neither shares contents across names.
- Path admission for a later hunk runs against the initial snapshot. When an earlier removal changes what admission sees (a symlink or file replaced by a regular file or directory, or the last other name of a hardlink), that hunk repeats strict admission in the write pass right before it runs, after the earlier hunk has removed the path. The link target is never read or written. A later path matches an earlier host symlink removal by the link entry's own identity (`lstat` device and inode) as well as by spelling, so the filesystem decides which spellings name the removed link: on a case-insensitive volume, `Delete File: link.txt` then `Add File: LINK.txt` (or `Add File: D/x.txt` after `Delete File: d`) replaces the link as it does on main. A symlink with more than one hardlinked name matches by spelling only, because its identity also names the entries that stay. Any other admission failure still rejects the whole patch up front, even after an unrelated delete.

Deliberately left out: compensation or a partial-effect result for failures that only show up during the write pass (an add whose destination exists, a delete of a missing file, a move onto an existing file, removing a directory, I/O errors, cancellation between writes). Those still behave as on main and need the maintainer decision above. For the same reason this PR does not close the issue on its own; keeping openclaw#117742 open for that decision is fine.

Scope tradeoff for maintainers: landing this PR means accepting a bounded fix. A patch whose update hunk cannot apply now leaves the workspace untouched, but a patch that fails during the write pass can still leave the effects of earlier hunks in place without reporting them, exactly as on main. Closing that gap needs the compensation or partial-effect decision tracked in openclaw#127496.

Where the check cannot predict the state it leaves the hunk to the write pass, which stays authoritative, rather than reject a patch the write pass would accept: an update of the other name of a hardlink that an earlier delete frees, and an unreadable new path whose spelling differs only in case from a path an earlier hunk staged (case-insensitive filesystems keep the spelled case in the identity of a missing path).

Design note: I chose a read-only preflight in front of the unchanged write pass over a staged plan with an undo journal. The staged plan must model every backend precondition (entry kinds, parent topology, symlink handling in the sandbox bridges), and openclaw#122933 stalled on exactly that.

The branch is rebased onto current main. The patch parser moved unchanged to `src/agents/apply-patch-parse.ts` (main's current parser, which returns the hunk list directly), and the tests this PR adds live in `src/agents/apply-patch.preflight.test.ts`, so both files stay within the line-cap ratchet.

The existing permission-change fence test now expects the abort at the envelope checkpoint: the read that triggers it happens in the preflight, so the rejection is an `AbortError` that carries the permission-change reason as its cause, and the file still stays unchanged.

## Evidence

Real behavior: an isolated Gateway built from each side (own state directory, loopback port, channels skipped) with a keyless local mock model that makes one agent turn call the real `apply_patch` tool with the envelope from the issue (`Delete File: important.txt`, then `Update File: missing.txt`). The workspace is seeded with `important.txt`.

Before (upstream main, no apply_patch changes since):

```
== workspace before: important.txt 
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after: 
== important.txt after: <MISSING>
```

After (this branch, same Gateway setup and turn):

```
== workspace before: important.txt 
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after: important.txt 
== important.txt after: irreplaceable-user-data
```

Control on this branch, a valid envelope (delete, add, then update of the just-added file) still applies in order:

```
== workspace before: important.txt 
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
== workspace after: notes.txt 
== important.txt after: <MISSING>
```

The Gateway proof above is still valid for this head: its envelope does not involve a link, a hardlink or a path an earlier hunk frees, so it takes the same path as before the link and hardlink staging changes.

Hardlink names in unrestricted mode, same Gateway setup with `tools.exec.applyPatch.workspaceOnly: false`. The workspace holds `original.txt` (`one`) and `alias.txt`, a second hardlink to the same file. The turn sends `Update File: original.txt` (`one` to `two`), then `Update File: alias.txt` (`two` to `three`).

Before (previous head of this branch, rebased onto current main without the hardlink change; main accepts this envelope):

```
== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to find expected lines in <workspace>/alias.txt:⏎two"
}
== after: original.txt=one alias.txt=one links=2
```

After (this head):

```
== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
M original.txt
M alias.txt
== after: original.txt=three alias.txt=three links=2
```

Tests (`src/agents/apply-patch.preflight.test.ts`, through the real `apply_patch` tool or `applyPatch`):

- Delete before an update of a missing file, and add plus update before a context mismatch: fail on main with the earlier effects committed, pass here. Updates of files added or changed earlier in the same patch, including a move, still apply.
- `Delete File: link.txt` (a symlink to an in-workspace `target.txt`) followed by a mismatched `Update File: target.txt`, or by `Update File: target.txt` / `Move to: link.txt` and a later update of `target.txt`: fail on an earlier head of this branch (the link is deleted before the error) and pass here with the link and target unchanged.
- `Delete File: link.txt`, `Add File: link.txt`, `Update File: target.txt`, `Update File: link.txt`, and `Update File: target.txt` / `Move to: link.txt` after the delete: fail on an earlier head of this branch (false context mismatch on the target, or an in-place rewrite instead of a move) and pass here.
- Outside-link and directory-link replacement (`Delete File: d`, then `Add File: d/x.txt`, `Add File: d/..cache`, `Delete File: d/x.txt`), a regular file replaced by a directory, and both names of a hardlink (re-create the deleted name, or update the other name): sequences main accepts; they fail on earlier heads of this branch, where admission ran only against the snapshot, and pass here.
- A moved symlink path updated again, and an outside-symlink update after an unrelated delete: reject before any mutation.
- Unrestricted mode (`workspaceOnly: false`) with two hardlink names: an update of the second name using text written through the first, alone or after deleting the first name, applies as on main. These cases pass on main, fail on the previous head of this branch, and pass here. A third case (move the first name away, then update the second against the original text) guards that a move does not carry the new contents to the other name.
- A removed outside symlink replaced under different casing (`Delete File: link.txt`, `Add File: LINK.txt`; `Delete File: d`, `Add File: D/x.txt`), gated on a case-insensitive temp volume. Run on macOS 15.7.9 (Intel, case-insensitive APFS) with this head's tests and each side's `src/agents/apply-patch.ts`: main passes both, the previous head of this branch (583baf2) fails both with `Symlink escapes sandbox root`, and this head passes both. The full apply-patch suites pass there on this head (162 passed, 1 Linux-only skip). Linux CI skips these two cases.
- A hardlinked symlink (Linux `link(2)` on a symlink): `Delete File: a` then `Update File: b` for the other name still updates the target, as on main; it fails on an intermediate version of this fix that matched any symlink by identity.
- Fail-to-pass run against main (merge base, Linux): the 7 regression tests above fail on main and pass here. The hardlink cases pass on main and here, and fail when the hardlink staging is removed from this head. The casing cases skip on Linux, so their before/after evidence is the macOS run above.
- `node scripts/run-vitest.mjs src/agents/apply-patch*.test.ts`: 12 files, 161 tests pass on Linux (2 macOS-only skips).
- `pnpm check:changed`: passes on the current head, apart from the dead export scan, which fails only on exports in files this PR does not touch (`src/plugins/config-policy.ts`, `src/media-understanding/defaults.ts`) and was skipped for the rerun.
- Review: a fresh-context code review at high effort, repeated after each round of fixes; its confirmed findings (move detection after a link delete, hardlink and directory-link replacement, held queue keys for removed link paths, case-folded link detection on the host, `..`-prefixed names under a removed link, abort checks during resolution) are fixed and covered above. A fresh-context review of the hardlink change found no correctness issue; it traced further hardlink, symlink and move sequences, which all matched the ordered writer, and the one wording note it raised is applied. A fresh-context review of the casing change found that a hardlinked symlink's identity also names its other entries (a delete of one name then made an update of the other reject); identity matching now requires a single link, with a regression test.

| Test file | `pnpm test <file> --maxWorkers=1` wall | CI seconds | New cases |
| --- | --- | --- | --- |
| `src/agents/apply-patch.preflight.test.ts` | 6.0 s (20 tests, 2 skip on Linux) | pending for this head | 20 cases, each under 15 ms of test time |
| `src/agents/apply-patch.test.ts` | 6.3 s | pending for this head | none (one assertion changed) |




## Maintainer E2E verification

Verified on macOS arm64 through an isolated, built Gateway and the real `openclaw agent` CLI. The Gateway used fresh state, workspace and HOME, loopback-only ports, and a local OpenAI Responses fixture model following the repository's existing HTTP/SSE test contract. No production state, personal API credentials, or CLI-login credentials were used. The model request advertised the real `apply_patch` tool; the next model request contained its actual `function_call_output` from the filesystem operation.

Baseline: `0af05d521e4` (fresh main). Candidate: contributor head merged with that main, then simplified; final head `e8d17b1d604780c1e351f74ef7e221fde5ba1967`. Runtime E2E ran at `6353875b56e` and again at `d908d9ea2d4`; the final commit only restores the existing permission-fence test assertion, without changing production code.

| Real Gateway scenario | Main | Candidate / simplified head |
| --- | --- | --- |
| Delete `important.txt`, then update missing `missing.txt` | Tool reports the missing-file error; `important.txt` is permanently missing | Same tool error; `important.txt` retains `irreplaceable-user-data⏎` |
| Add `created.txt`, rewrite `important.txt`, then fail a later context match | Not rerun on main | Simplified head rejects; only the unchanged original `important.txt` remains |
| Valid delete, add `notes.txt`, then update the newly added file | Not rerun on main | Simplified head succeeds; `notes.txt` contains `final⏎` |

Redacted model-visible failing result on both sides:

```json
{
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
```

The valid control returned:

```text
Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
```

All task-owned Gateways and fixture model servers were stopped. This is deterministic model-boundary proof, not a claim about live model behavior or commit-time rollback.

Checks:
- Baseline full `pnpm build`, candidate and simplified `pnpm build:runtime`: passed.
- All nine `apply-patch*.test.ts` suites were exercised. Initial result: 151 passed, one Linux-only skip, one outdated permission-error assertion failed. After restoring that assertion to main's existing contract, the affected suite passed all 51 tests. The other eight suites' passing results remain applicable.
- `node scripts/run-tsgo.mjs -p tsconfig.core.json --noEmit`: passed.
- `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-root.json --noEmit`: passed, including after the assertion repair.
- Scoped Oxlint and Oxfmt: passed.
- `check:test-timeout-race-ratchet --base origin/main`, `check:test-mock-exports`, and `check:assertion-safety`: passed.
- UI was not changed; no UI typecheck was needed.

## Maintainer simplification

Preserved the contributor's commits and merged current main without rebasing or force-pushing. The merge retains main's `ToolInputError` classification and its already-simplified parser in the extracted parser module. Replaced two temporary-array constructions in patch staging with direct iteration, including removal of the tuple assertion. Restored main's existing permission-change assertion because the current guarded read rejects before the envelope checkpoint; the test still proves the file remains unchanged.

The ordered staging, link/hardlink identity handling, and distinct filesystem regression cases are retained: they preserve accepted ordered patches while adding preflight, rather than pursuing a separate behavior change. No new rollback or partial-effect contract was introduced.

Final diff against the main merge base: production +725/-299 (net +426); tests +434/-0. Parser extraction accounts for +218 production lines; the required ordered preflight and filesystem-identity handling account for the remaining growth. The original `apply-patch.test.ts` has no net diff from main.

No overlap with Pash/Sarah changes in the touched files. Full diff security read found no new network access, credential reads, package/lockfile changes, or build-script changes. The contributor had 123 merged OpenClaw PRs at inspection.

The broader durability decision in openclaw#117742 / openclaw#127496 remains open: commit-time I/O failures, cancellation between writes, and other write-pass failures can still leave partial effects. This PR is the bounded update-preflight improvement and should not close those issues by itself.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 22, 2026
…date hunk cannot apply (#160409)

Related: #117742

Fixes: a multi-file `apply_patch` call permanently deletes, creates, or rewrites earlier files when a later update hunk targets a missing file or its context lines do not match, while the tool only reports the later error.

User impact: when an update hunk in a patch cannot apply, the whole patch now rejects before any file changes, so the workspace is left exactly as it was and the agent's retry starts from the state it expects.

The issue and #127496 leave one durability question open: after a failure that happens while files are being written (I/O error, a competing writer, cancellation mid-commit), should `apply_patch` compensate, or keep the earlier effects and report them? This PR does not make that choice. It implements only the part both options in the ClawSweeper review share, which is also the first step of the repair described in #127496: validate the ordered envelope before writing, while holding the file queues for the whole envelope.

- All hunk targets resolve first, and the patch holds the file-mutation queue for every path it touches for the whole run, so the check reads the same state the writes act on.
- Every update hunk is then computed in order before anything is written, with the same `applyUpdateHunk` the write pass uses. Earlier adds, updates, deletes and moves in the same patch are staged by physical file identity, so an update of a file added or changed earlier in the patch still works, and an update of a file an earlier hunk deletes or moves away rejects up front. A missing file, a context mismatch or invalid UTF-8 rejects with no mutation.
- Links are staged apart from the files they name. Queue identity follows a final symlink, so a link and its target share one key, but deleting the link leaves the target in place. A delete or move of a final symlink therefore stages the link path by its spelling, and later hunks at or under that path (`Add File: link`, `Update File: link`, `Move to: link`, `Add File: dir-link/x.txt`) use that path stage, which starts out removed. The target keeps its own staged contents, so `Delete File: link` followed by a mismatched `Update File: target` now rejects before the link is deleted, and `Delete File: link`, `Add File: link`, `Update File: target` no longer checks the target against the new link contents. The write pass decides whether an update is a move from the same stages, so `Update File: target` with `Move to: link` after `Delete File: link` moves the file instead of rewriting it in place.
- Names of one hardlinked file share staged contents in unrestricted host mode (`workspaceOnly: false`), where an update rewrites the file in place and every name sees it. Each name has its own queue identity, so an update hunk of a hardlinked file (more than one link at the snapshot) stages by the file's device and inode instead, until an earlier hunk in the patch deletes, re-creates or moves that name. `Update File: a` followed by `Update File: b` whose context matches the text written through `a` applies again, as it does on main. Moving one name away leaves the shared contents for the other names. Confined mode refuses hardlink aliases, and the sandbox helpers refuse hardlinked reads and replace files atomically, so neither shares contents across names.
- Path admission for a later hunk runs against the initial snapshot. When an earlier removal changes what admission sees (a symlink or file replaced by a regular file or directory, or the last other name of a hardlink), that hunk repeats strict admission in the write pass right before it runs, after the earlier hunk has removed the path. The link target is never read or written. A later path matches an earlier host symlink removal by the link entry's own identity (`lstat` device and inode) as well as by spelling, so the filesystem decides which spellings name the removed link: on a case-insensitive volume, `Delete File: link.txt` then `Add File: LINK.txt` (or `Add File: D/x.txt` after `Delete File: d`) replaces the link as it does on main. A symlink with more than one hardlinked name matches by spelling only, because its identity also names the entries that stay. Any other admission failure still rejects the whole patch up front, even after an unrelated delete.

Deliberately left out: compensation or a partial-effect result for failures that only show up during the write pass (an add whose destination exists, a delete of a missing file, a move onto an existing file, removing a directory, I/O errors, cancellation between writes). Those still behave as on main and need the maintainer decision above. For the same reason this PR does not close the issue on its own; keeping #117742 open for that decision is fine.

Scope tradeoff for maintainers: landing this PR means accepting a bounded fix. A patch whose update hunk cannot apply now leaves the workspace untouched, but a patch that fails during the write pass can still leave the effects of earlier hunks in place without reporting them, exactly as on main. Closing that gap needs the compensation or partial-effect decision tracked in #127496.

Where the check cannot predict the state it leaves the hunk to the write pass, which stays authoritative, rather than reject a patch the write pass would accept: an update of the other name of a hardlink that an earlier delete frees, and an unreadable new path whose spelling differs only in case from a path an earlier hunk staged (case-insensitive filesystems keep the spelled case in the identity of a missing path).

Design note: I chose a read-only preflight in front of the unchanged write pass over a staged plan with an undo journal. The staged plan must model every backend precondition (entry kinds, parent topology, symlink handling in the sandbox bridges), and #122933 stalled on exactly that.

The branch is rebased onto current main. The patch parser moved unchanged to `src/agents/apply-patch-parse.ts` (main's current parser, which returns the hunk list directly), and the tests this PR adds live in `src/agents/apply-patch.preflight.test.ts`, so both files stay within the line-cap ratchet.

The existing permission-change fence test now expects the abort at the envelope checkpoint: the read that triggers it happens in the preflight, so the rejection is an `AbortError` that carries the permission-change reason as its cause, and the file still stays unchanged.

Real behavior: an isolated Gateway built from each side (own state directory, loopback port, channels skipped) with a keyless local mock model that makes one agent turn call the real `apply_patch` tool with the envelope from the issue (`Delete File: important.txt`, then `Update File: missing.txt`). The workspace is seeded with `important.txt`.

Before (upstream main, no apply_patch changes since):

```
== workspace before: important.txt
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after:
== important.txt after: <MISSING>
```

After (this branch, same Gateway setup and turn):

```
== workspace before: important.txt
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after: important.txt
== important.txt after: irreplaceable-user-data
```

Control on this branch, a valid envelope (delete, add, then update of the just-added file) still applies in order:

```
== workspace before: important.txt
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
== workspace after: notes.txt
== important.txt after: <MISSING>
```

The Gateway proof above is still valid for this head: its envelope does not involve a link, a hardlink or a path an earlier hunk frees, so it takes the same path as before the link and hardlink staging changes.

Hardlink names in unrestricted mode, same Gateway setup with `tools.exec.applyPatch.workspaceOnly: false`. The workspace holds `original.txt` (`one`) and `alias.txt`, a second hardlink to the same file. The turn sends `Update File: original.txt` (`one` to `two`), then `Update File: alias.txt` (`two` to `three`).

Before (previous head of this branch, rebased onto current main without the hardlink change; main accepts this envelope):

```
== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to find expected lines in <workspace>/alias.txt:⏎two"
}
== after: original.txt=one alias.txt=one links=2
```

After (this head):

```
== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
M original.txt
M alias.txt
== after: original.txt=three alias.txt=three links=2
```

Tests (`src/agents/apply-patch.preflight.test.ts`, through the real `apply_patch` tool or `applyPatch`):

- Delete before an update of a missing file, and add plus update before a context mismatch: fail on main with the earlier effects committed, pass here. Updates of files added or changed earlier in the same patch, including a move, still apply.
- `Delete File: link.txt` (a symlink to an in-workspace `target.txt`) followed by a mismatched `Update File: target.txt`, or by `Update File: target.txt` / `Move to: link.txt` and a later update of `target.txt`: fail on an earlier head of this branch (the link is deleted before the error) and pass here with the link and target unchanged.
- `Delete File: link.txt`, `Add File: link.txt`, `Update File: target.txt`, `Update File: link.txt`, and `Update File: target.txt` / `Move to: link.txt` after the delete: fail on an earlier head of this branch (false context mismatch on the target, or an in-place rewrite instead of a move) and pass here.
- Outside-link and directory-link replacement (`Delete File: d`, then `Add File: d/x.txt`, `Add File: d/..cache`, `Delete File: d/x.txt`), a regular file replaced by a directory, and both names of a hardlink (re-create the deleted name, or update the other name): sequences main accepts; they fail on earlier heads of this branch, where admission ran only against the snapshot, and pass here.
- A moved symlink path updated again, and an outside-symlink update after an unrelated delete: reject before any mutation.
- Unrestricted mode (`workspaceOnly: false`) with two hardlink names: an update of the second name using text written through the first, alone or after deleting the first name, applies as on main. These cases pass on main, fail on the previous head of this branch, and pass here. A third case (move the first name away, then update the second against the original text) guards that a move does not carry the new contents to the other name.
- A removed outside symlink replaced under different casing (`Delete File: link.txt`, `Add File: LINK.txt`; `Delete File: d`, `Add File: D/x.txt`), gated on a case-insensitive temp volume. Run on macOS 15.7.9 (Intel, case-insensitive APFS) with this head's tests and each side's `src/agents/apply-patch.ts`: main passes both, the previous head of this branch (583baf2) fails both with `Symlink escapes sandbox root`, and this head passes both. The full apply-patch suites pass there on this head (162 passed, 1 Linux-only skip). Linux CI skips these two cases.
- A hardlinked symlink (Linux `link(2)` on a symlink): `Delete File: a` then `Update File: b` for the other name still updates the target, as on main; it fails on an intermediate version of this fix that matched any symlink by identity.
- Fail-to-pass run against main (merge base, Linux): the 7 regression tests above fail on main and pass here. The hardlink cases pass on main and here, and fail when the hardlink staging is removed from this head. The casing cases skip on Linux, so their before/after evidence is the macOS run above.
- `node scripts/run-vitest.mjs src/agents/apply-patch*.test.ts`: 12 files, 161 tests pass on Linux (2 macOS-only skips).
- `pnpm check:changed`: passes on the current head, apart from the dead export scan, which fails only on exports in files this PR does not touch (`src/plugins/config-policy.ts`, `src/media-understanding/defaults.ts`) and was skipped for the rerun.
- Review: a fresh-context code review at high effort, repeated after each round of fixes; its confirmed findings (move detection after a link delete, hardlink and directory-link replacement, held queue keys for removed link paths, case-folded link detection on the host, `..`-prefixed names under a removed link, abort checks during resolution) are fixed and covered above. A fresh-context review of the hardlink change found no correctness issue; it traced further hardlink, symlink and move sequences, which all matched the ordered writer, and the one wording note it raised is applied. A fresh-context review of the casing change found that a hardlinked symlink's identity also names its other entries (a delete of one name then made an update of the other reject); identity matching now requires a single link, with a regression test.

| Test file | `pnpm test <file> --maxWorkers=1` wall | CI seconds | New cases |
| --- | --- | --- | --- |
| `src/agents/apply-patch.preflight.test.ts` | 6.0 s (20 tests, 2 skip on Linux) | pending for this head | 20 cases, each under 15 ms of test time |
| `src/agents/apply-patch.test.ts` | 6.3 s | pending for this head | none (one assertion changed) |

Verified on macOS arm64 through an isolated, built Gateway and the real `openclaw agent` CLI. The Gateway used fresh state, workspace and HOME, loopback-only ports, and a local OpenAI Responses fixture model following the repository's existing HTTP/SSE test contract. No production state, personal API credentials, or CLI-login credentials were used. The model request advertised the real `apply_patch` tool; the next model request contained its actual `function_call_output` from the filesystem operation.

Baseline: `372ff7cacef` (fresh main). Candidate: contributor head merged with that main, then simplified; final head `e8d17b1d604780c1e351f74ef7e221fde5ba1967`. Runtime E2E ran at `6353875b56e` and again at `d908d9ea2d4`; the final commit only restores the existing permission-fence test assertion, without changing production code.

| Real Gateway scenario | Main | Candidate / simplified head |
| --- | --- | --- |
| Delete `important.txt`, then update missing `missing.txt` | Tool reports the missing-file error; `important.txt` is permanently missing | Same tool error; `important.txt` retains `irreplaceable-user-data⏎` |
| Add `created.txt`, rewrite `important.txt`, then fail a later context match | Not rerun on main | Simplified head rejects; only the unchanged original `important.txt` remains |
| Valid delete, add `notes.txt`, then update the newly added file | Not rerun on main | Simplified head succeeds; `notes.txt` contains `final⏎` |

Redacted model-visible failing result on both sides:

```json
{
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
```

The valid control returned:

```text
Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
```

All task-owned Gateways and fixture model servers were stopped. This is deterministic model-boundary proof, not a claim about live model behavior or commit-time rollback.

Checks:
- Baseline full `pnpm build`, candidate and simplified `pnpm build:runtime`: passed.
- All nine `apply-patch*.test.ts` suites were exercised. Initial result: 151 passed, one Linux-only skip, one outdated permission-error assertion failed. After restoring that assertion to main's existing contract, the affected suite passed all 51 tests. The other eight suites' passing results remain applicable.
- `node scripts/run-tsgo.mjs -p tsconfig.core.json --noEmit`: passed.
- `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-root.json --noEmit`: passed, including after the assertion repair.
- Scoped Oxlint and Oxfmt: passed.
- `check:test-timeout-race-ratchet --base origin/main`, `check:test-mock-exports`, and `check:assertion-safety`: passed.
- UI was not changed; no UI typecheck was needed.

Preserved the contributor's commits and merged current main without rebasing or force-pushing. The merge retains main's `ToolInputError` classification and its already-simplified parser in the extracted parser module. Replaced two temporary-array constructions in patch staging with direct iteration, including removal of the tuple assertion. Restored main's existing permission-change assertion because the current guarded read rejects before the envelope checkpoint; the test still proves the file remains unchanged.

The ordered staging, link/hardlink identity handling, and distinct filesystem regression cases are retained: they preserve accepted ordered patches while adding preflight, rather than pursuing a separate behavior change. No new rollback or partial-effect contract was introduced.

Final diff against the main merge base: production +725/-299 (net +426); tests +434/-0. Parser extraction accounts for +218 production lines; the required ordered preflight and filesystem-identity handling account for the remaining growth. The original `apply-patch.test.ts` has no net diff from main.

No overlap with Pash/Sarah changes in the touched files. Full diff security read found no new network access, credential reads, package/lockfile changes, or build-script changes. The contributor had 123 merged OpenClaw PRs at inspection.

The broader durability decision in #117742 / #127496 remains open: commit-time I/O failures, cancellation between writes, and other write-pass failures can still leave partial effects. This PR is the bounded update-preflight improvement and should not close those issues by itself.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 5348bbc)
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 22, 2026
…date hunk cannot apply (#160409)

Related: #117742

## What Problem This Solves

Fixes: a multi-file `apply_patch` call permanently deletes, creates, or rewrites earlier files when a later update hunk targets a missing file or its context lines do not match, while the tool only reports the later error.

## User Impact

User impact: when an update hunk in a patch cannot apply, the whole patch now rejects before any file changes, so the workspace is left exactly as it was and the agent's retry starts from the state it expects.

## Why This Change Was Made

The issue and #127496 leave one durability question open: after a failure that happens while files are being written (I/O error, a competing writer, cancellation mid-commit), should `apply_patch` compensate, or keep the earlier effects and report them? This PR does not make that choice. It implements only the part both options in the ClawSweeper review share, which is also the first step of the repair described in #127496: validate the ordered envelope before writing, while holding the file queues for the whole envelope.

- All hunk targets resolve first, and the patch holds the file-mutation queue for every path it touches for the whole run, so the check reads the same state the writes act on.
- Every update hunk is then computed in order before anything is written, with the same `applyUpdateHunk` the write pass uses. Earlier adds, updates, deletes and moves in the same patch are staged by physical file identity, so an update of a file added or changed earlier in the patch still works, and an update of a file an earlier hunk deletes or moves away rejects up front. A missing file, a context mismatch or invalid UTF-8 rejects with no mutation.
- Links are staged apart from the files they name. Queue identity follows a final symlink, so a link and its target share one key, but deleting the link leaves the target in place. A delete or move of a final symlink therefore stages the link path by its spelling, and later hunks at or under that path (`Add File: link`, `Update File: link`, `Move to: link`, `Add File: dir-link/x.txt`) use that path stage, which starts out removed. The target keeps its own staged contents, so `Delete File: link` followed by a mismatched `Update File: target` now rejects before the link is deleted, and `Delete File: link`, `Add File: link`, `Update File: target` no longer checks the target against the new link contents. The write pass decides whether an update is a move from the same stages, so `Update File: target` with `Move to: link` after `Delete File: link` moves the file instead of rewriting it in place.
- Names of one hardlinked file share staged contents in unrestricted host mode (`workspaceOnly: false`), where an update rewrites the file in place and every name sees it. Each name has its own queue identity, so an update hunk of a hardlinked file (more than one link at the snapshot) stages by the file's device and inode instead, until an earlier hunk in the patch deletes, re-creates or moves that name. `Update File: a` followed by `Update File: b` whose context matches the text written through `a` applies again, as it does on main. Moving one name away leaves the shared contents for the other names. Confined mode refuses hardlink aliases, and the sandbox helpers refuse hardlinked reads and replace files atomically, so neither shares contents across names.
- Path admission for a later hunk runs against the initial snapshot. When an earlier removal changes what admission sees (a symlink or file replaced by a regular file or directory, or the last other name of a hardlink), that hunk repeats strict admission in the write pass right before it runs, after the earlier hunk has removed the path. The link target is never read or written. A later path matches an earlier host symlink removal by the link entry's own identity (`lstat` device and inode) as well as by spelling, so the filesystem decides which spellings name the removed link: on a case-insensitive volume, `Delete File: link.txt` then `Add File: LINK.txt` (or `Add File: D/x.txt` after `Delete File: d`) replaces the link as it does on main. A symlink with more than one hardlinked name matches by spelling only, because its identity also names the entries that stay. Any other admission failure still rejects the whole patch up front, even after an unrelated delete.

Deliberately left out: compensation or a partial-effect result for failures that only show up during the write pass (an add whose destination exists, a delete of a missing file, a move onto an existing file, removing a directory, I/O errors, cancellation between writes). Those still behave as on main and need the maintainer decision above. For the same reason this PR does not close the issue on its own; keeping #117742 open for that decision is fine.

Scope tradeoff for maintainers: landing this PR means accepting a bounded fix. A patch whose update hunk cannot apply now leaves the workspace untouched, but a patch that fails during the write pass can still leave the effects of earlier hunks in place without reporting them, exactly as on main. Closing that gap needs the compensation or partial-effect decision tracked in #127496.

Where the check cannot predict the state it leaves the hunk to the write pass, which stays authoritative, rather than reject a patch the write pass would accept: an update of the other name of a hardlink that an earlier delete frees, and an unreadable new path whose spelling differs only in case from a path an earlier hunk staged (case-insensitive filesystems keep the spelled case in the identity of a missing path).

Design note: I chose a read-only preflight in front of the unchanged write pass over a staged plan with an undo journal. The staged plan must model every backend precondition (entry kinds, parent topology, symlink handling in the sandbox bridges), and #122933 stalled on exactly that.

The branch is rebased onto current main. The patch parser moved unchanged to `src/agents/apply-patch-parse.ts` (main's current parser, which returns the hunk list directly), and the tests this PR adds live in `src/agents/apply-patch.preflight.test.ts`, so both files stay within the line-cap ratchet.

The existing permission-change fence test now expects the abort at the envelope checkpoint: the read that triggers it happens in the preflight, so the rejection is an `AbortError` that carries the permission-change reason as its cause, and the file still stays unchanged.

## Evidence

Real behavior: an isolated Gateway built from each side (own state directory, loopback port, channels skipped) with a keyless local mock model that makes one agent turn call the real `apply_patch` tool with the envelope from the issue (`Delete File: important.txt`, then `Update File: missing.txt`). The workspace is seeded with `important.txt`.

Before (upstream main, no apply_patch changes since):

```
== workspace before: important.txt
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after:
== important.txt after: <MISSING>
```

After (this branch, same Gateway setup and turn):

```
== workspace before: important.txt
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
== workspace after: important.txt
== important.txt after: irreplaceable-user-data
```

Control on this branch, a valid envelope (delete, add, then update of the just-added file) still applies in order:

```
== workspace before: important.txt
== important.txt before: irreplaceable-user-data
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
== workspace after: notes.txt
== important.txt after: <MISSING>
```

The Gateway proof above is still valid for this head: its envelope does not involve a link, a hardlink or a path an earlier hunk frees, so it takes the same path as before the link and hardlink staging changes.

Hardlink names in unrestricted mode, same Gateway setup with `tools.exec.applyPatch.workspaceOnly: false`. The workspace holds `original.txt` (`one`) and `alias.txt`, a second hardlink to the same file. The turn sends `Update File: original.txt` (`one` to `two`), then `Update File: alias.txt` (`two` to `three`).

Before (previous head of this branch, rebased onto current main without the hardlink change; main accepts this envelope):

```
== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   {
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to find expected lines in <workspace>/alias.txt:⏎two"
}
== after: original.txt=one alias.txt=one links=2
```

After (this head):

```
== before: original.txt=one alias.txt=one links=2
== agent exit: 0
== tool result the model received:
   Success. Updated the following files:
M original.txt
M alias.txt
== after: original.txt=three alias.txt=three links=2
```

Tests (`src/agents/apply-patch.preflight.test.ts`, through the real `apply_patch` tool or `applyPatch`):

- Delete before an update of a missing file, and add plus update before a context mismatch: fail on main with the earlier effects committed, pass here. Updates of files added or changed earlier in the same patch, including a move, still apply.
- `Delete File: link.txt` (a symlink to an in-workspace `target.txt`) followed by a mismatched `Update File: target.txt`, or by `Update File: target.txt` / `Move to: link.txt` and a later update of `target.txt`: fail on an earlier head of this branch (the link is deleted before the error) and pass here with the link and target unchanged.
- `Delete File: link.txt`, `Add File: link.txt`, `Update File: target.txt`, `Update File: link.txt`, and `Update File: target.txt` / `Move to: link.txt` after the delete: fail on an earlier head of this branch (false context mismatch on the target, or an in-place rewrite instead of a move) and pass here.
- Outside-link and directory-link replacement (`Delete File: d`, then `Add File: d/x.txt`, `Add File: d/..cache`, `Delete File: d/x.txt`), a regular file replaced by a directory, and both names of a hardlink (re-create the deleted name, or update the other name): sequences main accepts; they fail on earlier heads of this branch, where admission ran only against the snapshot, and pass here.
- A moved symlink path updated again, and an outside-symlink update after an unrelated delete: reject before any mutation.
- Unrestricted mode (`workspaceOnly: false`) with two hardlink names: an update of the second name using text written through the first, alone or after deleting the first name, applies as on main. These cases pass on main, fail on the previous head of this branch, and pass here. A third case (move the first name away, then update the second against the original text) guards that a move does not carry the new contents to the other name.
- A removed outside symlink replaced under different casing (`Delete File: link.txt`, `Add File: LINK.txt`; `Delete File: d`, `Add File: D/x.txt`), gated on a case-insensitive temp volume. Run on macOS 15.7.9 (Intel, case-insensitive APFS) with this head's tests and each side's `src/agents/apply-patch.ts`: main passes both, the previous head of this branch (583baf2) fails both with `Symlink escapes sandbox root`, and this head passes both. The full apply-patch suites pass there on this head (162 passed, 1 Linux-only skip). Linux CI skips these two cases.
- A hardlinked symlink (Linux `link(2)` on a symlink): `Delete File: a` then `Update File: b` for the other name still updates the target, as on main; it fails on an intermediate version of this fix that matched any symlink by identity.
- Fail-to-pass run against main (merge base, Linux): the 7 regression tests above fail on main and pass here. The hardlink cases pass on main and here, and fail when the hardlink staging is removed from this head. The casing cases skip on Linux, so their before/after evidence is the macOS run above.
- `node scripts/run-vitest.mjs src/agents/apply-patch*.test.ts`: 12 files, 161 tests pass on Linux (2 macOS-only skips).
- `pnpm check:changed`: passes on the current head, apart from the dead export scan, which fails only on exports in files this PR does not touch (`src/plugins/config-policy.ts`, `src/media-understanding/defaults.ts`) and was skipped for the rerun.
- Review: a fresh-context code review at high effort, repeated after each round of fixes; its confirmed findings (move detection after a link delete, hardlink and directory-link replacement, held queue keys for removed link paths, case-folded link detection on the host, `..`-prefixed names under a removed link, abort checks during resolution) are fixed and covered above. A fresh-context review of the hardlink change found no correctness issue; it traced further hardlink, symlink and move sequences, which all matched the ordered writer, and the one wording note it raised is applied. A fresh-context review of the casing change found that a hardlinked symlink's identity also names its other entries (a delete of one name then made an update of the other reject); identity matching now requires a single link, with a regression test.

| Test file | `pnpm test <file> --maxWorkers=1` wall | CI seconds | New cases |
| --- | --- | --- | --- |
| `src/agents/apply-patch.preflight.test.ts` | 6.0 s (20 tests, 2 skip on Linux) | pending for this head | 20 cases, each under 15 ms of test time |
| `src/agents/apply-patch.test.ts` | 6.3 s | pending for this head | none (one assertion changed) |

## Maintainer E2E verification

Verified on macOS arm64 through an isolated, built Gateway and the real `openclaw agent` CLI. The Gateway used fresh state, workspace and HOME, loopback-only ports, and a local OpenAI Responses fixture model following the repository's existing HTTP/SSE test contract. No production state, personal API credentials, or CLI-login credentials were used. The model request advertised the real `apply_patch` tool; the next model request contained its actual `function_call_output` from the filesystem operation.

Baseline: `372ff7cacef` (fresh main). Candidate: contributor head merged with that main, then simplified; final head `e8d17b1d604780c1e351f74ef7e221fde5ba1967`. Runtime E2E ran at `6353875b56e` and again at `d908d9ea2d4`; the final commit only restores the existing permission-fence test assertion, without changing production code.

| Real Gateway scenario | Main | Candidate / simplified head |
| --- | --- | --- |
| Delete `important.txt`, then update missing `missing.txt` | Tool reports the missing-file error; `important.txt` is permanently missing | Same tool error; `important.txt` retains `irreplaceable-user-data⏎` |
| Add `created.txt`, rewrite `important.txt`, then fail a later context match | Not rerun on main | Simplified head rejects; only the unchanged original `important.txt` remains |
| Valid delete, add `notes.txt`, then update the newly added file | Not rerun on main | Simplified head succeeds; `notes.txt` contains `final⏎` |

Redacted model-visible failing result on both sides:

```json
{
  "status": "error",
  "tool": "apply_patch",
  "error": "Failed to read file to update <workspace>/missing.txt: Failed boundary read for <workspace>/missing.txt (path not found)"
}
```

The valid control returned:

```text
Success. Updated the following files:
A notes.txt
M notes.txt
D important.txt
```

All task-owned Gateways and fixture model servers were stopped. This is deterministic model-boundary proof, not a claim about live model behavior or commit-time rollback.

Checks:
- Baseline full `pnpm build`, candidate and simplified `pnpm build:runtime`: passed.
- All nine `apply-patch*.test.ts` suites were exercised. Initial result: 151 passed, one Linux-only skip, one outdated permission-error assertion failed. After restoring that assertion to main's existing contract, the affected suite passed all 51 tests. The other eight suites' passing results remain applicable.
- `node scripts/run-tsgo.mjs -p tsconfig.core.json --noEmit`: passed.
- `node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-root.json --noEmit`: passed, including after the assertion repair.
- Scoped Oxlint and Oxfmt: passed.
- `check:test-timeout-race-ratchet --base origin/main`, `check:test-mock-exports`, and `check:assertion-safety`: passed.
- UI was not changed; no UI typecheck was needed.

## Maintainer simplification

Preserved the contributor's commits and merged current main without rebasing or force-pushing. The merge retains main's `ToolInputError` classification and its already-simplified parser in the extracted parser module. Replaced two temporary-array constructions in patch staging with direct iteration, including removal of the tuple assertion. Restored main's existing permission-change assertion because the current guarded read rejects before the envelope checkpoint; the test still proves the file remains unchanged.

The ordered staging, link/hardlink identity handling, and distinct filesystem regression cases are retained: they preserve accepted ordered patches while adding preflight, rather than pursuing a separate behavior change. No new rollback or partial-effect contract was introduced.

Final diff against the main merge base: production +725/-299 (net +426); tests +434/-0. Parser extraction accounts for +218 production lines; the required ordered preflight and filesystem-identity handling account for the remaining growth. The original `apply-patch.test.ts` has no net diff from main.

No overlap with Pash/Sarah changes in the touched files. Full diff security read found no new network access, credential reads, package/lockfile changes, or build-script changes. The contributor had 123 merged OpenClaw PRs at inspection.

The broader durability decision in #117742 / #127496 remains open: commit-time I/O failures, cancellation between writes, and other write-pass failures can still leave partial effects. This PR is the bounded update-preflight improvement and should not close those issues by itself.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 5348bbc)
Co-authored-by: RomneyDa <[email protected]>
RomneyDa pushed a commit that referenced this pull request Oct 22, 2026
…later update hunk cannot apply (#160409)"

This reverts commit e57e6d3.
RomneyDa added a commit that referenced this pull request Oct 22, 2026
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Oct 25, 2026
…026.10.7) (#2447)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/openclaw/openclaw](https://openclaw.ai) ([source](https://github.com/openclaw/openclaw)) | patch | `2026.10.6` → `2026.10.7` |

---

### Release Notes

<details>
<summary>openclaw/openclaw (ghcr.io/openclaw/openclaw)</summary>

### [`v2026.10.7`](https://github.com/openclaw/openclaw/releases/tag/v2026.10.7): openclaw 2026.10.7

[Compare Source](openclaw/openclaw@v2026.10.6...v2026.10.7)

##### 2026.10.7

##### Highlights

- **Replay-safe session recovery:** interrupted sessions now retain recovery provenance and unfinished tool outcomes, stopped conversations retire terminal recovery residue before accepting the next message, rejected Claude CLI drafts stay out of final replies, large child-completion batches stay within requester context, and Codex previews no longer block replies after a context refresh. ([#&#8203;153728](openclaw/openclaw#153728), [#&#8203;168764](openclaw/openclaw#168764), [#&#8203;172068](openclaw/openclaw#172068), [#&#8203;177716](openclaw/openclaw#177716), [#&#8203;176682](openclaw/openclaw#176682), [#&#8203;176783](openclaw/openclaw#176783), [#&#8203;176675](openclaw/openclaw#176675), [#&#8203;159715](openclaw/openclaw#159715), [#&#8203;181801](openclaw/openclaw#181801)) Thanks [@&#8203;zhangguiping-xydt](https://github.com/zhangguiping-xydt), [@&#8203;ruel225](https://github.com/ruel225), [@&#8203;Oliver4Spot](https://github.com/Oliver4Spot), [@&#8203;jjjhenriksen](https://github.com/jjjhenriksen), [@&#8203;enki](https://github.com/enki), [@&#8203;PennyVibe](https://github.com/PennyVibe), [@&#8203;mbelinky](https://github.com/mbelinky), [@&#8203;RomneyDa](https://github.com/RomneyDa), and [@&#8203;krjcolby-svg](https://github.com/krjcolby-svg).
- **Safer update activation and recovery:** verified activations remain successful through later maintenance or ledger errors, interrupted package updates resume safely, post-activation Doctor waits are bounded, stale receipts cannot veto a valid repair, and Windows deep or 8.3 state paths no longer abort onboarding or migration. ([#&#8203;181166](openclaw/openclaw#181166), [#&#8203;181307](openclaw/openclaw#181307), [#&#8203;173862](openclaw/openclaw#173862), [#&#8203;167459](openclaw/openclaw#167459), [#&#8203;172768](openclaw/openclaw#172768), [#&#8203;172769](openclaw/openclaw#172769), [#&#8203;181389](openclaw/openclaw#181389)) Thanks [@&#8203;najef1979-code](https://github.com/najef1979-code), [@&#8203;agroman1993](https://github.com/agroman1993), [@&#8203;shanselman](https://github.com/shanselman), [@&#8203;RomneyDa](https://github.com/RomneyDa), [@&#8203;dor-sr](https://github.com/dor-sr), [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666), and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **Database and worker continuity:** maintenance refusals preserve peer readers and borrowers, incompatible retained agent databases stay isolated, empty transcript deletions skip unnecessary archive materialization, Bun admission deadlines remain thread-local, and worker shutdown completes after inventory retirement. ([#&#8203;175987](openclaw/openclaw#175987), [#&#8203;179320](openclaw/openclaw#179320), [#&#8203;170122](openclaw/openclaw#170122), [#&#8203;171372](openclaw/openclaw#171372), [#&#8203;172756](openclaw/openclaw#172756), [#&#8203;168862](openclaw/openclaw#168862)) Thanks [@&#8203;LifeViwer](https://github.com/LifeViwer), [@&#8203;Captain69G](https://github.com/Captain69G), [@&#8203;RomneyDa](https://github.com/RomneyDa), [@&#8203;shanselman](https://github.com/shanselman), [@&#8203;dor-sr](https://github.com/dor-sr), [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666), and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **Backup and state durability:** snapshots retain supported legacy exec-approval policies, interrupted R2 verification and restores resume safely, config observation keeps the last-known-good snapshot during truncated writes, failed multi-file patches preserve earlier files, and Memory Wiki re-imports preserve human-authored notes. ([#&#8203;164297](openclaw/openclaw#164297), [#&#8203;171292](openclaw/openclaw#171292), [#&#8203;152565](openclaw/openclaw#152565), [#&#8203;160409](openclaw/openclaw#160409), [#&#8203;175707](openclaw/openclaw#175707)) Thanks [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666), [@&#8203;davidcittadini](https://github.com/davidcittadini), [@&#8203;LiuwqGit](https://github.com/LiuwqGit), [@&#8203;yetval](https://github.com/yetval), [@&#8203;masatohoshino](https://github.com/masatohoshino), [@&#8203;YangManBOBO](https://github.com/YangManBOBO), [@&#8203;RomneyDa](https://github.com/RomneyDa), [@&#8203;shanselman](https://github.com/shanselman), [@&#8203;dor-sr](https://github.com/dor-sr), [@&#8203;cristianoc](https://github.com/cristianoc), and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **Operator control continuity:** native computer control recovers after session expiry, late-attached GitHub operators can publish PRs, synchronous node output is not duplicated as a completion wake, cron announcements preserve CLI chats, and history maintenance reads identities before payloads. ([#&#8203;169385](openclaw/openclaw#169385), [#&#8203;169400](openclaw/openclaw#169400), [#&#8203;164511](openclaw/openclaw#164511), [#&#8203;176218](openclaw/openclaw#176218), [#&#8203;174530](openclaw/openclaw#174530)) Thanks [@&#8203;stackingrockss](https://github.com/stackingrockss), [@&#8203;Gigaxel](https://github.com/Gigaxel), [@&#8203;holgergruenhagen](https://github.com/holgergruenhagen), [@&#8203;eliavb43](https://github.com/eliavb43), [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666), [@&#8203;asikorskiy](https://github.com/asikorskiy), and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **Provider and plugin continuity:** model refresh, configured-account readiness, GPT-5.6 tool turns, OpenRouter onboarding, incremental plugin loading, and faster external TypeScript plugin startup retain current state instead of rejecting valid setup or discarding providers. ([#&#8203;176709](openclaw/openclaw#176709), [#&#8203;178522](openclaw/openclaw#178522), [#&#8203;173366](openclaw/openclaw#173366), [#&#8203;173292](openclaw/openclaw#173292), [#&#8203;162226](openclaw/openclaw#162226), [#&#8203;161267](openclaw/openclaw#161267), [#&#8203;168391](openclaw/openclaw#168391)) Thanks [@&#8203;ericcaiwx-star](https://github.com/ericcaiwx-star), [@&#8203;eduardonunesfreire-rgb](https://github.com/eduardonunesfreire-rgb), [@&#8203;chandraveshchaudhari](https://github.com/chandraveshchaudhari), [@&#8203;netcrazed](https://github.com/netcrazed), [@&#8203;obviyus](https://github.com/obviyus), [@&#8203;jakeaadams](https://github.com/jakeaadams), and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **Managed integration reliability:** saved Linux Gateway dashboards preserve pairing across restarts, slow macOS Talk runs retain their replies, app upgrades converge official plugins, Copilot setup verifies SDK-backed agents correctly, Claude CLI cache prefixes stay stable after child completion and retain context when caller-only tools appear or disappear, and passkey prompts no longer block headless browser clicks. ([#&#8203;158908](openclaw/openclaw#158908), [#&#8203;164485](openclaw/openclaw#164485), [#&#8203;174257](openclaw/openclaw#174257), [#&#8203;163578](openclaw/openclaw#163578), [#&#8203;172026](openclaw/openclaw#172026), [#&#8203;178955](openclaw/openclaw#178955), [#&#8203;170857](openclaw/openclaw#170857)) Thanks [@&#8203;dor-sr](https://github.com/dor-sr), [@&#8203;PollyBot13](https://github.com/PollyBot13), [@&#8203;kazuyuki-eguchi](https://github.com/kazuyuki-eguchi), [@&#8203;lifuyue](https://github.com/lifuyue), [@&#8203;Marvinthebored](https://github.com/Marvinthebored), [@&#8203;VACInc](https://github.com/VACInc), [@&#8203;trukhinyuri](https://github.com/trukhinyuri), [@&#8203;Peetiegonzalez](https://github.com/Peetiegonzalez), [@&#8203;RomneyDa](https://github.com/RomneyDa), [@&#8203;shanselman](https://github.com/shanselman), [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666), [@&#8203;brucemccurdy](https://github.com/brucemccurdy), and [@&#8203;rsaeks](https://github.com/rsaeks).
- **Cross-platform app-managed upgrades:** native state repair, recovery snapshots, Gateway runtime admission, and post-upgrade service recovery now converge without losing agent access across macOS and Windows. ([#&#8203;171508](openclaw/openclaw#171508), [#&#8203;174297](openclaw/openclaw#174297), [#&#8203;175007](openclaw/openclaw#175007), [#&#8203;176174](openclaw/openclaw#176174), [#&#8203;178155](openclaw/openclaw#178155), [#&#8203;178779](openclaw/openclaw#178779), [#&#8203;180010](openclaw/openclaw#180010), [#&#8203;180576](openclaw/openclaw#180576), [#&#8203;180769](openclaw/openclaw#180769)) Thanks [@&#8203;tjarrau-dev](https://github.com/tjarrau-dev), [@&#8203;DonnieFi](https://github.com/DonnieFi), [@&#8203;jayzhou2309](https://github.com/jayzhou2309), [@&#8203;lostsock1](https://github.com/lostsock1), [@&#8203;sglion777](https://github.com/sglion777), [@&#8203;Almost-Certified-ops](https://github.com/Almost-Certified-ops), [@&#8203;billpang1-sketch](https://github.com/billpang1-sketch), and [@&#8203;RomneyDa](https://github.com/RomneyDa).

##### Changes

- **Google models:** add Gemini 4 Argon support. ([#&#8203;171852](openclaw/openclaw#171852)) Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).

##### Fixes

- **Update guidance:** avoid irrelevant database-repair advice when a package manager is missing, and remove superseded warnings after a successful update. ([#&#8203;173293](openclaw/openclaw#173293), [#&#8203;173395](openclaw/openclaw#173395)) Thanks [@&#8203;DonnieFi](https://github.com/DonnieFi), [@&#8203;RomneyDa](https://github.com/RomneyDa), [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666), [@&#8203;sunlit-deng](https://github.com/sunlit-deng), and [@&#8203;bhedanikhilkumar-code](https://github.com/bhedanikhilkumar-code).
- **macOS onboarding:** allow fresh profiles to start the Gateway and complete automatic setup. ([#&#8203;173246](openclaw/openclaw#173246)) Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **Gateway logging:** prevent a deleted or stale temporary log directory from wedging the Gateway at full CPU during date rollover. ([#&#8203;160433](openclaw/openclaw#160433)) Fixes [#&#8203;130807](openclaw/openclaw#130807) Thanks [@&#8203;masatohoshino](https://github.com/masatohoshino), [@&#8203;WadeOwenWatts](https://github.com/WadeOwenWatts), and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **Control UI queue state:** clear slash-steer chips after the queued command is consumed. ([#&#8203;180024](openclaw/openclaw#180024)) Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).

##### Complete contribution record

This audited record covers the complete v2026.10.6..[`5c4a797`](openclaw/openclaw@5c4a797) history: 49 in-range PRs + 21 retained seed-only PRs = 70 unique PRs. The generation manifest also supplies direct commits as editorial input; the grouped notes above prioritize user impact.

##### Pull requests

- **PR [#&#8203;181867](openclaw/openclaw#181867 Backports [#&#8203;181801](openclaw/openclaw#181801). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;181487](openclaw/openclaw#181487 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;181801](openclaw/openclaw#181801 Related [#&#8203;181770](openclaw/openclaw#181770). Thanks [@&#8203;najef1979-code](https://github.com/najef1979-code) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;173293](openclaw/openclaw#173293 Related [#&#8203;173084](openclaw/openclaw#173084). Thanks [@&#8203;DonnieFi](https://github.com/DonnieFi) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;sunlit-deng](https://github.com/sunlit-deng).
- **PR [#&#8203;173395](openclaw/openclaw#173395 Related [#&#8203;173089](openclaw/openclaw#173089). Thanks [@&#8203;DonnieFi](https://github.com/DonnieFi) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;bhedanikhilkumar-code](https://github.com/bhedanikhilkumar-code).
- **PR [#&#8203;178155](openclaw/openclaw#178155 Related [#&#8203;177697](openclaw/openclaw#177697). Thanks [@&#8203;DonnieFi](https://github.com/DonnieFi) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;175707](openclaw/openclaw#175707 Related [#&#8203;175700](openclaw/openclaw#175700). Thanks [@&#8203;YangManBOBO](https://github.com/YangManBOBO) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;180024](openclaw/openclaw#180024 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;180010](openclaw/openclaw#180010 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;178779](openclaw/openclaw#178779 Related [#&#8203;167385](openclaw/openclaw#167385). Thanks [@&#8203;jayzhou2309](https://github.com/jayzhou2309) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;lostsock1](https://github.com/lostsock1).
- **PR [#&#8203;180576](openclaw/openclaw#180576 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;176675](openclaw/openclaw#176675 Thanks [@&#8203;enki](https://github.com/enki) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;176682](openclaw/openclaw#176682 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;enki](https://github.com/enki).
- **PR [#&#8203;172026](openclaw/openclaw#172026 Thanks [@&#8203;Marvinthebored](https://github.com/Marvinthebored) and [@&#8203;VACInc](https://github.com/VACInc) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;Peetiegonzalez](https://github.com/Peetiegonzalez).
- **PR [#&#8203;170122](openclaw/openclaw#170122
- **PR [#&#8203;178955](openclaw/openclaw#178955 Thanks [@&#8203;Marvinthebored](https://github.com/Marvinthebored).
- **PR [#&#8203;179933](openclaw/openclaw#179933
- **PR [#&#8203;179951](openclaw/openclaw#179951
- **PR [#&#8203;182030](openclaw/openclaw#182030
- **PR [#&#8203;176892](openclaw/openclaw#176892 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;159715](openclaw/openclaw#159715 Thanks [@&#8203;mbelinky](https://github.com/mbelinky) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;162226](openclaw/openclaw#162226 Thanks [@&#8203;netcrazed](https://github.com/netcrazed) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;161267](openclaw/openclaw#161267 Thanks [@&#8203;obviyus](https://github.com/obviyus) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;171852](openclaw/openclaw#171852 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;176709](openclaw/openclaw#176709 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;180769](openclaw/openclaw#180769 Related [#&#8203;180636](openclaw/openclaw#180636), [#&#8203;180701](openclaw/openclaw#180701), [#&#8203;180707](openclaw/openclaw#180707). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;sglion777](https://github.com/sglion777) and [@&#8203;Almost-Certified-ops](https://github.com/Almost-Certified-ops) and [@&#8203;billpang1-sketch](https://github.com/billpang1-sketch).
- **PR [#&#8203;178522](openclaw/openclaw#178522 Related [#&#8203;178502](openclaw/openclaw#178502). Thanks [@&#8203;ericcaiwx-star](https://github.com/ericcaiwx-star) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;eduardonunesfreire-rgb](https://github.com/eduardonunesfreire-rgb).
- **PR [#&#8203;152565](openclaw/openclaw#152565 Related [#&#8203;152509](openclaw/openclaw#152509). Thanks [@&#8203;LiuwqGit](https://github.com/LiuwqGit) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;yetval](https://github.com/yetval).
- **PR [#&#8203;160409](openclaw/openclaw#160409 Thanks [@&#8203;masatohoshino](https://github.com/masatohoshino) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;163578](openclaw/openclaw#163578 Thanks [@&#8203;lifuyue](https://github.com/lifuyue) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;180482](openclaw/openclaw#180482 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;180989](openclaw/openclaw#180989 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;164297](openclaw/openclaw#164297 Related [#&#8203;164146](openclaw/openclaw#164146), [#&#8203;156945](openclaw/openclaw#156945). Thanks [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;shanselman](https://github.com/shanselman) and [@&#8203;dor-sr](https://github.com/dor-sr) and [@&#8203;cristianoc](https://github.com/cristianoc) and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **PR [#&#8203;158908](openclaw/openclaw#158908 Related [#&#8203;156945](openclaw/openclaw#156945). Thanks [@&#8203;dor-sr](https://github.com/dor-sr) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;shanselman](https://github.com/shanselman) and [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **PR [#&#8203;175987](openclaw/openclaw#175987 Related [#&#8203;156945](openclaw/openclaw#156945). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;shanselman](https://github.com/shanselman) and [@&#8203;dor-sr](https://github.com/dor-sr) and [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **PR [#&#8203;179320](openclaw/openclaw#179320 Related [#&#8203;156945](openclaw/openclaw#156945). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;shanselman](https://github.com/shanselman) and [@&#8203;dor-sr](https://github.com/dor-sr) and [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **PR [#&#8203;181389](openclaw/openclaw#181389 Related [#&#8203;156945](openclaw/openclaw#156945). Thanks [@&#8203;shanselman](https://github.com/shanselman) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;dor-sr](https://github.com/dor-sr) and [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **PR [#&#8203;167459](openclaw/openclaw#167459 Related [#&#8203;167441](openclaw/openclaw#167441), [#&#8203;156945](openclaw/openclaw#156945). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;shanselman](https://github.com/shanselman) and [@&#8203;dor-sr](https://github.com/dor-sr) and [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;brucemccurdy](https://github.com/brucemccurdy).
- **PR [#&#8203;153728](openclaw/openclaw#153728 Related [#&#8203;144842](openclaw/openclaw#144842). Thanks [@&#8203;zhangguiping-xydt](https://github.com/zhangguiping-xydt) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;krjcolby-svg](https://github.com/krjcolby-svg).
- **PR [#&#8203;164485](openclaw/openclaw#164485 Related [#&#8203;153145](openclaw/openclaw#153145). Thanks [@&#8203;PollyBot13](https://github.com/PollyBot13) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;rsaeks](https://github.com/rsaeks).
- **PR [#&#8203;168391](openclaw/openclaw#168391 Related [#&#8203;168130](openclaw/openclaw#168130). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;jakeaadams](https://github.com/jakeaadams).
- **PR [#&#8203;168629](openclaw/openclaw#168629 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;168764](openclaw/openclaw#168764 Related [#&#8203;168676](openclaw/openclaw#168676). Thanks [@&#8203;ruel225](https://github.com/ruel225) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;Oliver4Spot](https://github.com/Oliver4Spot).
- **PR [#&#8203;168862](openclaw/openclaw#168862 Related [#&#8203;158126](openclaw/openclaw#158126). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;Captain69G](https://github.com/Captain69G).
- **PR [#&#8203;169385](openclaw/openclaw#169385 Related [#&#8203;169353](openclaw/openclaw#169353). Thanks [@&#8203;stackingrockss](https://github.com/stackingrockss) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;169400](openclaw/openclaw#169400 Related [#&#8203;169377](openclaw/openclaw#169377). Thanks [@&#8203;Gigaxel](https://github.com/Gigaxel) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;171292](openclaw/openclaw#171292 Related [#&#8203;171165](openclaw/openclaw#171165). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;davidcittadini](https://github.com/davidcittadini).
- **PR [#&#8203;171372](openclaw/openclaw#171372 Related [#&#8203;171348](openclaw/openclaw#171348). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;LifeViwer](https://github.com/LifeViwer).
- **PR [#&#8203;172068](openclaw/openclaw#172068 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;164511](openclaw/openclaw#164511 Thanks [@&#8203;holgergruenhagen](https://github.com/holgergruenhagen) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;172756](openclaw/openclaw#172756 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;172768](openclaw/openclaw#172768 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;172769](openclaw/openclaw#172769 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;173862](openclaw/openclaw#173862 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;176218](openclaw/openclaw#176218 Related [#&#8203;176208](openclaw/openclaw#176208). Thanks [@&#8203;eliavb43](https://github.com/eliavb43) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;177716](openclaw/openclaw#177716 Thanks [@&#8203;jjjhenriksen](https://github.com/jjjhenriksen) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;174530](openclaw/openclaw#174530 Related [#&#8203;174078](openclaw/openclaw#174078). Thanks [@&#8203;wangmiao0668000666](https://github.com/wangmiao0668000666) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;asikorskiy](https://github.com/asikorskiy).
- **PR [#&#8203;181166](openclaw/openclaw#181166 Related [#&#8203;181020](https://github.com/openclaw/openclaw/issues/181020). Thanks [@&#8203;najef1979-code](https://github.com/najef1979-code).
- **PR [#&#8203;181307](openclaw/openclaw#181307 Related [#&#8203;181235](https://github.com/openclaw/openclaw/issues/181235). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;agroman1993](https://github.com/agroman1993).
- **PR [#&#8203;176783](openclaw/openclaw#176783 Related [#&#8203;176669](https://github.com/openclaw/openclaw/issues/176669). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;PennyVibe](https://github.com/PennyVibe).
- **PR [#&#8203;173366](openclaw/openclaw#173366 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;173292](openclaw/openclaw#173292 Thanks [@&#8203;chandraveshchaudhari](https://github.com/chandraveshchaudhari) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;174257](openclaw/openclaw#174257 Related [#&#8203;174120](https://github.com/openclaw/openclaw/issues/174120). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;kazuyuki-eguchi](https://github.com/kazuyuki-eguchi).
- **PR [#&#8203;170857](openclaw/openclaw#170857 Thanks [@&#8203;trukhinyuri](https://github.com/trukhinyuri) and [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;171508](openclaw/openclaw#171508 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;174297](openclaw/openclaw#174297 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;175007](openclaw/openclaw#175007 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;176174](openclaw/openclaw#176174 Related [#&#8203;176163](https://github.com/openclaw/openclaw/issues/176163). Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;tjarrau-dev](https://github.com/tjarrau-dev).
- **PR [#&#8203;173246](openclaw/openclaw#173246 Thanks [@&#8203;RomneyDa](https://github.com/RomneyDa).
- **PR [#&#8203;160433](openclaw/openclaw#160433 Related [#&#8203;130807](openclaw/openclaw#130807). Thanks [@&#8203;masatohoshino](https://github.com/masatohoshino) and [@&#8203;RomneyDa](https://github.com/RomneyDa) and [@&#8203;WadeOwenWatts](https://github.com/WadeOwenWatts).

##### Release verification

- npm package: <https://www.npmjs.com/package/openclaw/v/2026.10.7>
- registry tarball: <https://registry.npmjs.org/openclaw/-/openclaw-2026.10.7.tgz>
- integrity: `sha512-iiZO+kFFBgQvxm17wn3Sc/MSC/GQu01PubAFVNA2Nn736HOHUbR0ra7a9NeW9wpjq3kDkSJ1RB7dTP+qVJFXig==`
- release SHA: `157d8c2bc3ea2fa183afdc11088e69690bf8e64e`
- full release CI report: <https://github.com/openclaw/releases/blob/main/evidence/2026.10.7/release-evidence.md>
- release publish: <https://github.com/openclaw/openclaw/actions/runs/40081926023>
- npm preflight: <https://github.com/openclaw/openclaw/actions/runs/40055378381>
- full release validation: <https://github.com/openclaw/openclaw/actions/runs/40054950351>
- plugin npm publish: <https://github.com/openclaw/openclaw/actions/runs/40082487401>
- plugin ClawHub submission: <https://github.com/openclaw/openclaw/actions/runs/40082490562>; public finalization and exact artifact verification follow terminal release-parent completion
- plugin ClawHub bootstrap: not needed
- OpenClaw npm publish: <https://github.com/openclaw/openclaw/actions/runs/40073183916/attempts/1>
- npm Telegram beta E2E: not supplied
- Android APK: skipped — apps/android/version.json is 2026.8.2, release train is 2026.10.7; run pnpm android:version:pin -- --from-gateway before the next tag.

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNzUuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE3NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/2447
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

2 participants