Repository navigation
fix(update): return failure when dirty checkout blocks update - #117452
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:52 PM ET / 17:52 UTC. ClawSweeper reviewWhat this changesThe PR changes Merge readinessThe patch appears correct and addresses a real CLI contract defect: a blocked update currently prints an error but exits successfully. Keep this PR open for normal maintainer merge review because it has recent maintainer involvement, a clean three-way merge result, real behavior proof, and hosted checks still running. Priority: P2 Review scores
Verification
How this fits together
flowchart LR
A[Operator runs openclaw update] --> B[Update command]
B --> C[Git update runner]
C --> D[Clean working-tree check]
D -->|Local edits found| E[Skipped dirty result]
E --> F[Post-update handler]
F --> G[Diagnostic and shell exit status]
D -->|Clean checkout| H[Git update steps]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +39. Total +39 across 3 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow post-update exit-status change once the current merge result is green, retaining exit 0 for intentional informational skips and exit 1 only when local edits prevent the requested Git update. Do we have a high-confidence way to reproduce the issue? Yes—current source establishes the path: the Git runner returns a skipped Is this the best way to solve the issue? Yes—the conditional belongs at the post-update owner that translates a structured update outcome into the CLI process result, rather than changing the runner’s safety behavior or treating every skipped outcome as a failure. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 926afb66e9c4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
7823ae0 to
976161e
Compare
Maintainer real dirty-checkout process-contract verificationPreserved original contributor @IWhatsskill, original human Git author/email/first authored date, and the original PR. Refreshed exact head Created and committed a real temporary Git repository, modified its actual tracked README, invoked production Before: {"dirty":{"status":"skipped","reason":"dirty","steps":["clean check"],"exitCode":0,"beforeGitMutationCalls":0,"diagnostic":"Update blocked: local files are edited in this checkout.","repoHeadPreserved":true,"statusPreserved":true,"dirtyFilePreserved":true},"intentionalNonGit":{"reason":"not-git-install","exitCode":0}}After: {"dirty":{"status":"skipped","reason":"dirty","steps":["clean check"],"exitCode":1,"beforeGitMutationCalls":0,"diagnostic":"Update blocked: local files are edited in this checkout.","repoHeadPreserved":true,"statusPreserved":true,"dirtyFilePreserved":true},"intentionalNonGit":{"reason":"not-git-install","exitCode":0}}The real operator file, Git HEAD, and dirty status are preserved exactly; only node --import tsx --input-type=module -e 'import {mkdtemp,writeFile,readFile,rm,realpath} from "node:fs/promises";import {tmpdir} from "node:os";import {join} from "node:path";import {execFileSync} from "node:child_process";import {runGatewayUpdate} from "./src/infra/update-runner.ts";import {finishUpdate} from "./src/cli/update-cli/update-command-post-update.ts";import {defaultRuntime} from "./src/runtime.ts";const temporary=await mkdtemp(join(tmpdir(),"openclaw-dirty-update-"));const root=await realpath(temporary);const originals={exit:defaultRuntime.exit,log:defaultRuntime.log,error:defaultRuntime.error};try{await writeFile(join(root,"package.json"),JSON.stringify({name:"openclaw",version:"2026.7.1"}));await writeFile(join(root,"openclaw.mjs"),"export {};\n");await writeFile(join(root,"README.md"),"original\n");execFileSync("git",["init","--initial-branch=main","--quiet",root]);execFileSync("git",["-C",root,"add","package.json","openclaw.mjs","README.md"]);execFileSync("git",["-C",root,"-c","user.name=Proof","-c","[email protected]","commit","--quiet","-m","fixture"]);await writeFile(join(root,"README.md"),"operator local changes\n");const headBefore=execFileSync("git",["-C",root,"rev-parse","HEAD"],{encoding:"utf8"}).trim();const statusBefore=execFileSync("git",["-C",root,"status","--porcelain"],{encoding:"utf8"});let mutationCalls=0;const result=await runGatewayUpdate({cwd:root,argv1:join(root,"openclaw.mjs"),timeoutMs:5000,beforeGitMutation:async()=>{mutationCalls++}});const exitCodes=[];const logs=[];const errors=[];defaultRuntime.exit=(code)=>{exitCodes.push(code)};defaultRuntime.log=(...args)=>{logs.push(args.map(String).join(" "))};defaultRuntime.error=(...args)=>{errors.push(args.map(String).join(" "))};const finish=async(value)=>finishUpdate({result:value,opts:{},showProgress:false,controlPlaneUpdateSentinelMeta:undefined});await finish(result);await finish({status:"skipped",mode:"unknown",reason:"not-git-install",steps:[],durationMs:1});const headAfter=execFileSync("git",["-C",root,"rev-parse","HEAD"],{encoding:"utf8"}).trim();const statusAfter=execFileSync("git",["-C",root,"status","--porcelain"],{encoding:"utf8"});const contents=await readFile(join(root,"README.md"),"utf8");process.stdout.write(JSON.stringify({dirty:{status:result.status,reason:result.reason,steps:result.steps.map(step=>step.name),exitCode:exitCodes[0],beforeGitMutationCalls:mutationCalls,diagnostic:errors.find(line=>line.includes("Update blocked")),repoHeadPreserved:headAfter===headBefore,statusPreserved:statusAfter===statusBefore,dirtyFilePreserved:contents==="operator local changes\n"},intentionalNonGit:{reason:"not-git-install",exitCode:exitCodes[1]}})+"\n")}finally{Object.assign(defaultRuntime,originals);await rm(root,{recursive:true,force:true})}'
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-117452-update node scripts/run-vitest.mjs src/cli/update-cli/update-command-post-update.test.ts src/cli/update-cli.test.ts src/infra/update-runner.test.ts -t 'skipped update exit status|explains why git updates cannot run with edited files|skips git update when worktree is dirty'
.agents/skills/autoreview/scripts/autoreview --mode uncommitted --engine codex --thinking xhighAll 4 matching regressions across three owner/caller/runner files pass; targeted formatter and diff checks pass; fresh Codex Sol xhigh autoreview is clean. |
|
Merged via squash.
|
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (#117555) fix(cli): explain filtered plugin policy without unsafe recovery (#117556) fix(irc): strip markdown from outbound text (#112961) refactor(plugins): consolidate registry snapshots (#117561) fix(plugins): fail blocked enable commands (#117536) test(secrets): dedupe runtime state fixtures (#117563) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
…aw#117452) Co-authored-by: IWhatsskill <[email protected]>
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (openclaw#117555) fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556) fix(irc): strip markdown from outbound text (openclaw#112961) refactor(plugins): consolidate registry snapshots (openclaw#117561) fix(plugins): fail blocked enable commands (openclaw#117536) test(secrets): dedupe runtime state fixtures (openclaw#117563) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
[AI-assisted]
Original contributor: @IWhatsskill. The contributor's original human Git author, email, first authored timestamp, and existing PR are preserved.
What Problem This Solves
openclaw updatecorrectly refuses to mutate a dirty Git checkout, prints an actionableUpdate blockeddiagnostic, and then incorrectly exits with status 0. Shell automation therefore records an update that did not happen as successful.Why This Change Was Made
Keep dirty detection and the pre-mutation safety boundary in the existing Git update runner. At the post-update owner, map only skipped reason
dirtyto exit 1; intentional skips such asnot-git-installcontinue to exit 0. Preserve the contributor's original production change and focused owner tests, and correct the existing stale full-CLI dirty-checkout assertion that incorrectly expected success.The refreshed branch changes exactly three files: the original two contributor files plus the stale caller-level assertion. The production delta is net zero lines; there is no config, dependency, protocol, migration, service lifecycle, or Git mutation change.
User Impact
Automation receives a failing process status when operator changes prevent the requested update. Existing actionable recovery guidance stays visible. The real checkout, current commit, user-edited file, and dirty status are untouched, and intentional non-Git-install skips remain successful.
Evidence
Created a real temporary Git checkout with a real committed
package.json, entrypoint, and README; edited the actual tracked README; invoked productionrunGatewayUpdateusing actual Git subprocesses, then passed its real structured result into productionfinishUpdate. Also invoked the existing intentional non-Git skip sibling.Before, current main:
{ "dirty": { "status": "skipped", "reason": "dirty", "steps": [ "clean check" ], "exitCode": 0, "beforeGitMutationCalls": 0, "diagnostic": "Update blocked: local files are edited in this checkout.", "repoHeadPreserved": true, "statusPreserved": true, "dirtyFilePreserved": true }, "intentionalNonGit": { "reason": "not-git-install", "exitCode": 0 } }After, exact original contributor head
976161e7c015964701c661788ad9b56ffb3d59de:{ "dirty": { "status": "skipped", "reason": "dirty", "steps": [ "clean check" ], "exitCode": 1, "beforeGitMutationCalls": 0, "diagnostic": "Update blocked: local files are edited in this checkout.", "repoHeadPreserved": true, "statusPreserved": true, "dirtyFilePreserved": true }, "intentionalNonGit": { "reason": "not-git-install", "exitCode": 0 } }The only attempted Git update step is the real
clean check;beforeGitMutationis never called; repository HEAD, git status, and the operator-edited README are identical afterward.OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-117452-update node scripts/run-vitest.mjs src/cli/update-cli/update-command-post-update.test.ts src/cli/update-cli.test.ts src/infra/update-runner.test.ts -t 'skipped update exit status|explains why git updates cannot run with edited files|skips git update when worktree is dirty' .agents/skills/autoreview/scripts/autoreview --mode uncommitted --engine codex --thinking xhighAll four matching owner/caller/runner regressions pass across three files; targeted formatter and
git diff --checkpass; fresh Codex Sol xhigh structured autoreview is clean. The latest ClawSweeper rank-up move is addressed by refreshing current main, correcting the preexisting failing CLI expectation, and rerunning all directly relevant checks; exact-head hosted CI must still finish green before landing.