Repository navigation
fix(agents): failed apply_patch deletes earlier files when a later update hunk cannot apply - #160409
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAgents 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +426, Tests +434. Total +860 across 3 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (6 earlier review cycles)
Reviewed October 15, 2026, 4:04 PM ET / 20:04 UTC (Revision 7). |
47fbeba to
583baf2
Compare
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Landed in 5348bbc. Thanks @masatohoshino! A failed |
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)
…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]>
…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]>
…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]>
Co-authored-by: RomneyDa <[email protected]>
…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. ([#​153728](openclaw/openclaw#153728), [#​168764](openclaw/openclaw#168764), [#​172068](openclaw/openclaw#172068), [#​177716](openclaw/openclaw#177716), [#​176682](openclaw/openclaw#176682), [#​176783](openclaw/openclaw#176783), [#​176675](openclaw/openclaw#176675), [#​159715](openclaw/openclaw#159715), [#​181801](openclaw/openclaw#181801)) Thanks [@​zhangguiping-xydt](https://github.com/zhangguiping-xydt), [@​ruel225](https://github.com/ruel225), [@​Oliver4Spot](https://github.com/Oliver4Spot), [@​jjjhenriksen](https://github.com/jjjhenriksen), [@​enki](https://github.com/enki), [@​PennyVibe](https://github.com/PennyVibe), [@​mbelinky](https://github.com/mbelinky), [@​RomneyDa](https://github.com/RomneyDa), and [@​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. ([#​181166](openclaw/openclaw#181166), [#​181307](openclaw/openclaw#181307), [#​173862](openclaw/openclaw#173862), [#​167459](openclaw/openclaw#167459), [#​172768](openclaw/openclaw#172768), [#​172769](openclaw/openclaw#172769), [#​181389](openclaw/openclaw#181389)) Thanks [@​najef1979-code](https://github.com/najef1979-code), [@​agroman1993](https://github.com/agroman1993), [@​shanselman](https://github.com/shanselman), [@​RomneyDa](https://github.com/RomneyDa), [@​dor-sr](https://github.com/dor-sr), [@​wangmiao0668000666](https://github.com/wangmiao0668000666), and [@​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. ([#​175987](openclaw/openclaw#175987), [#​179320](openclaw/openclaw#179320), [#​170122](openclaw/openclaw#170122), [#​171372](openclaw/openclaw#171372), [#​172756](openclaw/openclaw#172756), [#​168862](openclaw/openclaw#168862)) Thanks [@​LifeViwer](https://github.com/LifeViwer), [@​Captain69G](https://github.com/Captain69G), [@​RomneyDa](https://github.com/RomneyDa), [@​shanselman](https://github.com/shanselman), [@​dor-sr](https://github.com/dor-sr), [@​wangmiao0668000666](https://github.com/wangmiao0668000666), and [@​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. ([#​164297](openclaw/openclaw#164297), [#​171292](openclaw/openclaw#171292), [#​152565](openclaw/openclaw#152565), [#​160409](openclaw/openclaw#160409), [#​175707](openclaw/openclaw#175707)) Thanks [@​wangmiao0668000666](https://github.com/wangmiao0668000666), [@​davidcittadini](https://github.com/davidcittadini), [@​LiuwqGit](https://github.com/LiuwqGit), [@​yetval](https://github.com/yetval), [@​masatohoshino](https://github.com/masatohoshino), [@​YangManBOBO](https://github.com/YangManBOBO), [@​RomneyDa](https://github.com/RomneyDa), [@​shanselman](https://github.com/shanselman), [@​dor-sr](https://github.com/dor-sr), [@​cristianoc](https://github.com/cristianoc), and [@​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. ([#​169385](openclaw/openclaw#169385), [#​169400](openclaw/openclaw#169400), [#​164511](openclaw/openclaw#164511), [#​176218](openclaw/openclaw#176218), [#​174530](openclaw/openclaw#174530)) Thanks [@​stackingrockss](https://github.com/stackingrockss), [@​Gigaxel](https://github.com/Gigaxel), [@​holgergruenhagen](https://github.com/holgergruenhagen), [@​eliavb43](https://github.com/eliavb43), [@​wangmiao0668000666](https://github.com/wangmiao0668000666), [@​asikorskiy](https://github.com/asikorskiy), and [@​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. ([#​176709](openclaw/openclaw#176709), [#​178522](openclaw/openclaw#178522), [#​173366](openclaw/openclaw#173366), [#​173292](openclaw/openclaw#173292), [#​162226](openclaw/openclaw#162226), [#​161267](openclaw/openclaw#161267), [#​168391](openclaw/openclaw#168391)) Thanks [@​ericcaiwx-star](https://github.com/ericcaiwx-star), [@​eduardonunesfreire-rgb](https://github.com/eduardonunesfreire-rgb), [@​chandraveshchaudhari](https://github.com/chandraveshchaudhari), [@​netcrazed](https://github.com/netcrazed), [@​obviyus](https://github.com/obviyus), [@​jakeaadams](https://github.com/jakeaadams), and [@​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. ([#​158908](openclaw/openclaw#158908), [#​164485](openclaw/openclaw#164485), [#​174257](openclaw/openclaw#174257), [#​163578](openclaw/openclaw#163578), [#​172026](openclaw/openclaw#172026), [#​178955](openclaw/openclaw#178955), [#​170857](openclaw/openclaw#170857)) Thanks [@​dor-sr](https://github.com/dor-sr), [@​PollyBot13](https://github.com/PollyBot13), [@​kazuyuki-eguchi](https://github.com/kazuyuki-eguchi), [@​lifuyue](https://github.com/lifuyue), [@​Marvinthebored](https://github.com/Marvinthebored), [@​VACInc](https://github.com/VACInc), [@​trukhinyuri](https://github.com/trukhinyuri), [@​Peetiegonzalez](https://github.com/Peetiegonzalez), [@​RomneyDa](https://github.com/RomneyDa), [@​shanselman](https://github.com/shanselman), [@​wangmiao0668000666](https://github.com/wangmiao0668000666), [@​brucemccurdy](https://github.com/brucemccurdy), and [@​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. ([#​171508](openclaw/openclaw#171508), [#​174297](openclaw/openclaw#174297), [#​175007](openclaw/openclaw#175007), [#​176174](openclaw/openclaw#176174), [#​178155](openclaw/openclaw#178155), [#​178779](openclaw/openclaw#178779), [#​180010](openclaw/openclaw#180010), [#​180576](openclaw/openclaw#180576), [#​180769](openclaw/openclaw#180769)) Thanks [@​tjarrau-dev](https://github.com/tjarrau-dev), [@​DonnieFi](https://github.com/DonnieFi), [@​jayzhou2309](https://github.com/jayzhou2309), [@​lostsock1](https://github.com/lostsock1), [@​sglion777](https://github.com/sglion777), [@​Almost-Certified-ops](https://github.com/Almost-Certified-ops), [@​billpang1-sketch](https://github.com/billpang1-sketch), and [@​RomneyDa](https://github.com/RomneyDa). ##### Changes - **Google models:** add Gemini 4 Argon support. ([#​171852](openclaw/openclaw#171852)) Thanks [@​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. ([#​173293](openclaw/openclaw#173293), [#​173395](openclaw/openclaw#173395)) Thanks [@​DonnieFi](https://github.com/DonnieFi), [@​RomneyDa](https://github.com/RomneyDa), [@​wangmiao0668000666](https://github.com/wangmiao0668000666), [@​sunlit-deng](https://github.com/sunlit-deng), and [@​bhedanikhilkumar-code](https://github.com/bhedanikhilkumar-code). - **macOS onboarding:** allow fresh profiles to start the Gateway and complete automatic setup. ([#​173246](openclaw/openclaw#173246)) Thanks [@​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. ([#​160433](openclaw/openclaw#160433)) Fixes [#​130807](openclaw/openclaw#130807) Thanks [@​masatohoshino](https://github.com/masatohoshino), [@​WadeOwenWatts](https://github.com/WadeOwenWatts), and [@​RomneyDa](https://github.com/RomneyDa). - **Control UI queue state:** clear slash-steer chips after the queued command is consumed. ([#​180024](openclaw/openclaw#180024)) Thanks [@​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 [#​181867](openclaw/openclaw#181867 Backports [#​181801](openclaw/openclaw#181801). Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​181487](openclaw/openclaw#181487 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​181801](openclaw/openclaw#181801 Related [#​181770](openclaw/openclaw#181770). Thanks [@​najef1979-code](https://github.com/najef1979-code) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​173293](openclaw/openclaw#173293 Related [#​173084](openclaw/openclaw#173084). Thanks [@​DonnieFi](https://github.com/DonnieFi) and [@​RomneyDa](https://github.com/RomneyDa) and [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​sunlit-deng](https://github.com/sunlit-deng). - **PR [#​173395](openclaw/openclaw#173395 Related [#​173089](openclaw/openclaw#173089). Thanks [@​DonnieFi](https://github.com/DonnieFi) and [@​RomneyDa](https://github.com/RomneyDa) and [@​bhedanikhilkumar-code](https://github.com/bhedanikhilkumar-code). - **PR [#​178155](openclaw/openclaw#178155 Related [#​177697](openclaw/openclaw#177697). Thanks [@​DonnieFi](https://github.com/DonnieFi) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​175707](openclaw/openclaw#175707 Related [#​175700](openclaw/openclaw#175700). Thanks [@​YangManBOBO](https://github.com/YangManBOBO) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​180024](openclaw/openclaw#180024 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​180010](openclaw/openclaw#180010 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​178779](openclaw/openclaw#178779 Related [#​167385](openclaw/openclaw#167385). Thanks [@​jayzhou2309](https://github.com/jayzhou2309) and [@​RomneyDa](https://github.com/RomneyDa) and [@​lostsock1](https://github.com/lostsock1). - **PR [#​180576](openclaw/openclaw#180576 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​176675](openclaw/openclaw#176675 Thanks [@​enki](https://github.com/enki) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​176682](openclaw/openclaw#176682 Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​enki](https://github.com/enki). - **PR [#​172026](openclaw/openclaw#172026 Thanks [@​Marvinthebored](https://github.com/Marvinthebored) and [@​VACInc](https://github.com/VACInc) and [@​RomneyDa](https://github.com/RomneyDa) and [@​Peetiegonzalez](https://github.com/Peetiegonzalez). - **PR [#​170122](openclaw/openclaw#170122 - **PR [#​178955](openclaw/openclaw#178955 Thanks [@​Marvinthebored](https://github.com/Marvinthebored). - **PR [#​179933](openclaw/openclaw#179933 - **PR [#​179951](openclaw/openclaw#179951 - **PR [#​182030](openclaw/openclaw#182030 - **PR [#​176892](openclaw/openclaw#176892 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​159715](openclaw/openclaw#159715 Thanks [@​mbelinky](https://github.com/mbelinky) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​162226](openclaw/openclaw#162226 Thanks [@​netcrazed](https://github.com/netcrazed) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​161267](openclaw/openclaw#161267 Thanks [@​obviyus](https://github.com/obviyus) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​171852](openclaw/openclaw#171852 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​176709](openclaw/openclaw#176709 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​180769](openclaw/openclaw#180769 Related [#​180636](openclaw/openclaw#180636), [#​180701](openclaw/openclaw#180701), [#​180707](openclaw/openclaw#180707). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​sglion777](https://github.com/sglion777) and [@​Almost-Certified-ops](https://github.com/Almost-Certified-ops) and [@​billpang1-sketch](https://github.com/billpang1-sketch). - **PR [#​178522](openclaw/openclaw#178522 Related [#​178502](openclaw/openclaw#178502). Thanks [@​ericcaiwx-star](https://github.com/ericcaiwx-star) and [@​RomneyDa](https://github.com/RomneyDa) and [@​eduardonunesfreire-rgb](https://github.com/eduardonunesfreire-rgb). - **PR [#​152565](openclaw/openclaw#152565 Related [#​152509](openclaw/openclaw#152509). Thanks [@​LiuwqGit](https://github.com/LiuwqGit) and [@​RomneyDa](https://github.com/RomneyDa) and [@​yetval](https://github.com/yetval). - **PR [#​160409](openclaw/openclaw#160409 Thanks [@​masatohoshino](https://github.com/masatohoshino) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​163578](openclaw/openclaw#163578 Thanks [@​lifuyue](https://github.com/lifuyue) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​180482](openclaw/openclaw#180482 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​180989](openclaw/openclaw#180989 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​164297](openclaw/openclaw#164297 Related [#​164146](openclaw/openclaw#164146), [#​156945](openclaw/openclaw#156945). Thanks [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​RomneyDa](https://github.com/RomneyDa) and [@​shanselman](https://github.com/shanselman) and [@​dor-sr](https://github.com/dor-sr) and [@​cristianoc](https://github.com/cristianoc) and [@​brucemccurdy](https://github.com/brucemccurdy). - **PR [#​158908](openclaw/openclaw#158908 Related [#​156945](openclaw/openclaw#156945). Thanks [@​dor-sr](https://github.com/dor-sr) and [@​RomneyDa](https://github.com/RomneyDa) and [@​shanselman](https://github.com/shanselman) and [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​brucemccurdy](https://github.com/brucemccurdy). - **PR [#​175987](openclaw/openclaw#175987 Related [#​156945](openclaw/openclaw#156945). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​shanselman](https://github.com/shanselman) and [@​dor-sr](https://github.com/dor-sr) and [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​brucemccurdy](https://github.com/brucemccurdy). - **PR [#​179320](openclaw/openclaw#179320 Related [#​156945](openclaw/openclaw#156945). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​shanselman](https://github.com/shanselman) and [@​dor-sr](https://github.com/dor-sr) and [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​brucemccurdy](https://github.com/brucemccurdy). - **PR [#​181389](openclaw/openclaw#181389 Related [#​156945](openclaw/openclaw#156945). Thanks [@​shanselman](https://github.com/shanselman) and [@​RomneyDa](https://github.com/RomneyDa) and [@​dor-sr](https://github.com/dor-sr) and [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​brucemccurdy](https://github.com/brucemccurdy). - **PR [#​167459](openclaw/openclaw#167459 Related [#​167441](openclaw/openclaw#167441), [#​156945](openclaw/openclaw#156945). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​shanselman](https://github.com/shanselman) and [@​dor-sr](https://github.com/dor-sr) and [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​brucemccurdy](https://github.com/brucemccurdy). - **PR [#​153728](openclaw/openclaw#153728 Related [#​144842](openclaw/openclaw#144842). Thanks [@​zhangguiping-xydt](https://github.com/zhangguiping-xydt) and [@​RomneyDa](https://github.com/RomneyDa) and [@​krjcolby-svg](https://github.com/krjcolby-svg). - **PR [#​164485](openclaw/openclaw#164485 Related [#​153145](openclaw/openclaw#153145). Thanks [@​PollyBot13](https://github.com/PollyBot13) and [@​RomneyDa](https://github.com/RomneyDa) and [@​rsaeks](https://github.com/rsaeks). - **PR [#​168391](openclaw/openclaw#168391 Related [#​168130](openclaw/openclaw#168130). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​jakeaadams](https://github.com/jakeaadams). - **PR [#​168629](openclaw/openclaw#168629 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​168764](openclaw/openclaw#168764 Related [#​168676](openclaw/openclaw#168676). Thanks [@​ruel225](https://github.com/ruel225) and [@​RomneyDa](https://github.com/RomneyDa) and [@​Oliver4Spot](https://github.com/Oliver4Spot). - **PR [#​168862](openclaw/openclaw#168862 Related [#​158126](openclaw/openclaw#158126). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​Captain69G](https://github.com/Captain69G). - **PR [#​169385](openclaw/openclaw#169385 Related [#​169353](openclaw/openclaw#169353). Thanks [@​stackingrockss](https://github.com/stackingrockss) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​169400](openclaw/openclaw#169400 Related [#​169377](openclaw/openclaw#169377). Thanks [@​Gigaxel](https://github.com/Gigaxel) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​171292](openclaw/openclaw#171292 Related [#​171165](openclaw/openclaw#171165). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​davidcittadini](https://github.com/davidcittadini). - **PR [#​171372](openclaw/openclaw#171372 Related [#​171348](openclaw/openclaw#171348). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​LifeViwer](https://github.com/LifeViwer). - **PR [#​172068](openclaw/openclaw#172068 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​164511](openclaw/openclaw#164511 Thanks [@​holgergruenhagen](https://github.com/holgergruenhagen) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​172756](openclaw/openclaw#172756 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​172768](openclaw/openclaw#172768 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​172769](openclaw/openclaw#172769 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​173862](openclaw/openclaw#173862 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​176218](openclaw/openclaw#176218 Related [#​176208](openclaw/openclaw#176208). Thanks [@​eliavb43](https://github.com/eliavb43) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​177716](openclaw/openclaw#177716 Thanks [@​jjjhenriksen](https://github.com/jjjhenriksen) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​174530](openclaw/openclaw#174530 Related [#​174078](openclaw/openclaw#174078). Thanks [@​wangmiao0668000666](https://github.com/wangmiao0668000666) and [@​RomneyDa](https://github.com/RomneyDa) and [@​asikorskiy](https://github.com/asikorskiy). - **PR [#​181166](openclaw/openclaw#181166 Related [#​181020](https://github.com/openclaw/openclaw/issues/181020). Thanks [@​najef1979-code](https://github.com/najef1979-code). - **PR [#​181307](openclaw/openclaw#181307 Related [#​181235](https://github.com/openclaw/openclaw/issues/181235). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​agroman1993](https://github.com/agroman1993). - **PR [#​176783](openclaw/openclaw#176783 Related [#​176669](https://github.com/openclaw/openclaw/issues/176669). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​PennyVibe](https://github.com/PennyVibe). - **PR [#​173366](openclaw/openclaw#173366 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​173292](openclaw/openclaw#173292 Thanks [@​chandraveshchaudhari](https://github.com/chandraveshchaudhari) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​174257](openclaw/openclaw#174257 Related [#​174120](https://github.com/openclaw/openclaw/issues/174120). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​kazuyuki-eguchi](https://github.com/kazuyuki-eguchi). - **PR [#​170857](openclaw/openclaw#170857 Thanks [@​trukhinyuri](https://github.com/trukhinyuri) and [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​171508](openclaw/openclaw#171508 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​174297](openclaw/openclaw#174297 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​175007](openclaw/openclaw#175007 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​176174](openclaw/openclaw#176174 Related [#​176163](https://github.com/openclaw/openclaw/issues/176163). Thanks [@​RomneyDa](https://github.com/RomneyDa) and [@​tjarrau-dev](https://github.com/tjarrau-dev). - **PR [#​173246](openclaw/openclaw#173246 Thanks [@​RomneyDa](https://github.com/RomneyDa). - **PR [#​160433](openclaw/openclaw#160433 Related [#​130807](openclaw/openclaw#130807). Thanks [@​masatohoshino](https://github.com/masatohoshino) and [@​RomneyDa](https://github.com/RomneyDa) and [@​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
Related: #117742
What Problem This Solves
Fixes: a multi-file
apply_patchcall 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_patchcompensate, 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.applyUpdateHunkthe 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.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, soDelete File: linkfollowed by a mismatchedUpdate File: targetnow rejects before the link is deleted, andDelete File: link,Add File: link,Update File: targetno longer checks the target against the new link contents. The write pass decides whether an update is a move from the same stages, soUpdate File: targetwithMove to: linkafterDelete File: linkmoves the file instead of rewriting it in place.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: afollowed byUpdate File: bwhose context matches the text written throughaapplies 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.lstatdevice 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.txtthenAdd File: LINK.txt(orAdd File: D/x.txtafterDelete 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 insrc/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
AbortErrorthat 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_patchtool with the envelope from the issue (Delete File: important.txt, thenUpdate File: missing.txt). The workspace is seeded withimportant.txt.Before (upstream main, no apply_patch changes since):
After (this branch, same Gateway setup and turn):
Control on this branch, a valid envelope (delete, add, then update of the just-added file) still applies in order:
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 holdsoriginal.txt(one) andalias.txt, a second hardlink to the same file. The turn sendsUpdate File: original.txt(onetotwo), thenUpdate File: alias.txt(twotothree).Before (previous head of this branch, rebased onto current main without the hardlink change; main accepts this envelope):
After (this head):
Tests (
src/agents/apply-patch.preflight.test.ts, through the realapply_patchtool orapplyPatch):Delete File: link.txt(a symlink to an in-workspacetarget.txt) followed by a mismatchedUpdate File: target.txt, or byUpdate File: target.txt/Move to: link.txtand a later update oftarget.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, andUpdate File: target.txt/Move to: link.txtafter 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.Delete File: d, thenAdd 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.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.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'ssrc/agents/apply-patch.ts: main passes both, the previous head of this branch (583baf2) fails both withSymlink 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.link(2)on a symlink):Delete File: athenUpdate File: bfor 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.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...-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.pnpm test <file> --maxWorkers=1wallsrc/agents/apply-patch.preflight.test.tssrc/agents/apply-patch.test.tsMaintainer E2E verification
Verified on macOS arm64 through an isolated, built Gateway and the real
openclaw agentCLI. 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 realapply_patchtool; the next model request contained its actualfunction_call_outputfrom the filesystem operation.Baseline:
372ff7cacef(fresh main). Candidate: contributor head merged with that main, then simplified; final heade8d17b1d604780c1e351f74ef7e221fde5ba1967. Runtime E2E ran at6353875b56eand again atd908d9ea2d4; the final commit only restores the existing permission-fence test assertion, without changing production code.important.txt, then update missingmissing.txtimportant.txtis permanently missingimportant.txtretainsirreplaceable-user-data\ncreated.txt, rewriteimportant.txt, then fail a later context matchimportant.txtremainsnotes.txt, then update the newly added filenotes.txtcontainsfinal\nRedacted 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:
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:
pnpm build, candidate and simplifiedpnpm build:runtime: passed.apply-patch*.test.tssuites 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.check:test-timeout-race-ratchet --base origin/main,check:test-mock-exports, andcheck:assertion-safety: passed.Maintainer simplification
Preserved the contributor's commits and merged current main without rebasing or force-pushing. The merge retains main's
ToolInputErrorclassification 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.tshas 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.