Skip to content

fix: continue code mode with read-only recovery - #128071

Merged
shakkernerd merged 7 commits into
mainfrom
fix/code-mode-read-only-recovery
Aug 23, 2026
Merged

shakkernerd merged 7 commits into
mainfrom
fix/code-mode-read-only-recovery

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep failed Code Mode mutations terminal and non-replayable
  • start one fresh read-only reconciliation phase only when the original final prompt policy authorized a core-owned read tool
  • reject plugin-owned candidate signals and plugin/channel read shadows; reconstruct only the built-in core read tool

Root cause

After bridge dispatch starts, Code Mode correctly refuses to replay a failed mutation. The repair hook also terminates the outer tool loop, so a partially applied operation ends the run before the model can inspect and report the authoritative resulting state.

The fix records only the narrow unsafe-dispatch case, carries that fact to the embedded run owner, and permits one host-created reconciliation phase when all tool and side-effect lifecycles are settled. Candidate minting consumes the original turn’s final prompt-policy decision, after before_prompt_build intersects the concrete host surface. Explicit empty, deny, sandbox, sender, inherited, runtime, and prompt-specific policies remain authoritative. Plugin or channel tools named read do not qualify.

Verification

  • reproduced on current main with a real apply_patch bridge call: the first hunk applied, the second failed as ambiguous, and the run terminated without inspection
  • focused repair/reconciliation, concrete-ownership, and final prompt-policy tests passed
  • full-runner regression proves an authorized candidate becomes a subsequent attempt with the internal reconciliation prompt and forced read-only policy
  • final-policy coverage proves both baseline and prompt-time read denial prevent candidate minting; plugin-owned transports and plugin/channel read shadows are rejected
  • construction-plan proof confirms the follow-up excludes plugin, channel, OpenClaw, and shell families
  • Blacksmith Testbox focused policy lanes and full-runner regression passed; all leases cleaned up
  • pnpm tsgo:core
  • pnpm check:changed -- <changed files>
  • independent autoreview: no blocker
  • directly inspected current Codex runtime callback contract at openai/codex@8e649e3afa5cdddfb09a1b85a090b94775045d9b; it has no reusable read-only recovery contract

Fixes #128028

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 23, 2026
@shakkernerd
shakkernerd marked this pull request as ready for review August 23, 2026 00:58
@shakkernerd
shakkernerd force-pushed the fix/code-mode-read-only-recovery branch from cf61c31 to 2d09902 Compare August 23, 2026 01:01
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 10:54 PM ET / August 23, 2026, 02:54 UTC.

ClawSweeper review

What this changes

The branch adds one host-created, read-only reconciliation attempt after a settled Code Mode bridge failure that may have partially applied a mutation.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The PR remains necessary and appears to implement the linked Code Mode recovery bug without replaying the mutation. The new attempt is gated on the final prompt-policy decision and reconstructs only the core read surface; exact-head checks are still running.

Priority: P1
Reviewed head: 6ca440425797c25c878ae516ae9670160c5ecbc9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with coherent policy propagation and targeted regression coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the ordinary external-contributor proof gate; its focused source and harness coverage still supports the merge-risk review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the ordinary external-contributor proof gate; its focused source and harness coverage still supports the merge-risk review.
Evidence reviewed 7 items Final prompt-policy entitlement: The candidate is recorded only when the final prompt surface retained a core-owned read tool; plugin and channel read shadows are excluded.
Prompt-policy intersection: The prompt hook derives authorization from the already filtered host surface, so it cannot add read after host policy removed it.
Restricted reconstruction: The reconciliation attempt forces a read-only allowlist, disables Code Mode and tool-search controls, excludes client/MCP/LSP tools, and filters the constructed surface to read.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

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

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

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

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

[tsdown-build] invocation 2/2 finished in 14.8s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4419ms (slowest: built plugin control-plane loads 3643ms)

OpenClaw 2026.8.1 (6ca4404) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

The embedded agent runner executes Code Mode bridge calls inside an agent tool loop. After an unsafe mutation failure, this change can start one fresh attempt that inspects the resulting workspace state and returns an accurate recovery report.

flowchart LR
A[Code Mode mutation] --> B[Bridge dispatch]
B --> C{Partial failure}
C --> D[Settled-attempt gate]
D --> E{Core read was authorized}
E -->|yes| F[Read-only reconciliation]
E -->|no| G[Terminal response]
F --> H[Authoritative state report]
G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The fix adds a new tool-capable recovery mode after a terminal mutation failure; although the source has layered policy and side-effect gates, merge should retain the focused Testbox/full-runner evidence on the exact head.
  • Complete next step (P2) - This maintainer-authored PR needs normal exact-head validation rather than an automated replacement or repair job.
Agent review details

Security

None.

PR surface

Source +223, Tests +175. Total +398 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 18 240 17 +223
Tests 9 181 6 +175
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 27 421 23 +398

Review metrics

Metric Value Why it matters
Production versus test delta production +149 net, tests +249 net The bug fix introduces a bounded recovery owner and policy propagation across the embedded-runner lifecycle; the test growth covers its gate and integration path.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/agents/embedded-agent-runner/run/attempt-session.test.ts, migration/backfill/repair: src/agents/embedded-agent-runner/run/code-mode-repair.ts, vector/embedding metadata: src/agents/embedded-agent-runner/run/attempt-client-tools.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #128028
Summary: This PR is the explicit candidate fix for the reported partial-mutation reconciliation bug.

Members:

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

Merge-risk options

Maintainer options:

  1. Retain exact-head recovery proof (recommended)
    Let the focused policy and full-runner checks finish on this head, preserving evidence for both permitted core-read recovery and denied surfaces.
  2. Accept the source-coverage residual
    Merge after maintainer acceptance that the current focused source tests are sufficient despite the remaining exact-head check activity.

Technical review

Best possible solution:

Keep the one-shot recovery at the embedded-runner owner boundary, with only core read reconstructed after final prompt-policy authorization and exact-head validation complete.

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

Yes, at source level: a bridge-started Code Mode failure is terminal on current main, while this branch admits a second attempt only after the original final prompt policy authorizes core read.

Is this the best way to solve the issue?

Yes. The repair preserves the no-replay invariant at the Code Mode owner while offering a narrowly constructed, one-shot observation path rather than a downstream retry or broad fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 672ac118c34f.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the ordinary external-contributor proof gate; its focused source and harness coverage still supports the merge-risk review.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A potentially partial Code Mode mutation currently prevents same-turn authoritative recovery in affected agent workflows.
  • merge-risk: 🚨 compatibility: Existing bridge-failure terminal behavior changes to permit one bounded follow-up attempt.
  • merge-risk: 🚨 security-boundary: A final prompt-policy entitlement is carried into a newly constructed tool-capable recovery attempt.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the ordinary external-contributor proof gate; its focused source and harness coverage still supports the merge-risk review.

Evidence

What I checked:

Likely related people:

  • Shakker: Introduced the existing Code Mode repair hook and authored the current final-policy preservation work. (role: feature owner; confidence: high; commits: c3ec166cbcdd, 6ca440425797; files: src/agents/embedded-agent-runner/run/code-mode-repair.ts, src/agents/embedded-agent-runner/run/attempt-session-prepare.ts)
  • Onur Solmaz: Recent history attributes the shared embedded-runner recovery path to this contributor. (role: adjacent recovery-path contributor; confidence: medium; commits: 1f10ef8050a9; files: src/agents/embedded-agent-runner/run-loop.ts)

Rank-up moves

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

  • Allow the in-progress exact-head checks to complete before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-23T01:31:02.790Z sha aa5cf25 :: needs changes before merge. :: [P1] Preserve the original tool allowlist during reconciliation
  • reviewed 2026-08-23T02:23:35.401Z sha 820f15ec04780749162c17bf97ece12ff11ee500 :: needs real behavior proof before merge. :: [P1] Carry final prompt tool policy into reconciliation

@shakkernerd
shakkernerd force-pushed the fix/code-mode-read-only-recovery branch from aa5cf25 to 820f15e Compare August 23, 2026 02:16
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 23, 2026
@shakkernerd
shakkernerd force-pushed the fix/code-mode-read-only-recovery branch from 820f15e to 55e597f Compare August 23, 2026 02:33
@shakkernerd
shakkernerd force-pushed the fix/code-mode-read-only-recovery branch from 55e597f to 6ca4404 Compare August 23, 2026 02:48
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@shakkernerd shakkernerd self-assigned this Aug 23, 2026
@shakkernerd
shakkernerd merged commit 32bb08d into main Aug 23, 2026
240 of 241 checks passed
@shakkernerd
shakkernerd deleted the fix/code-mode-read-only-recovery branch August 23, 2026 03:05
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Code Mode can now report partial mutation state through a final-policy-authorized read-only reconciliation attempt without replaying the mutation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Code Mode bridge failures terminate read-only recovery after partial mutations

1 participant