Repository navigation
fix: explain apply_patch workspace rejections - #136126
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: blocked before merge. Reviewed September 19, 2026, 11:12 PM ET / September 20, 2026, 03:12 UTC (Revision 16). ClawSweeper reviewWhat this changesAdds operator-log explanations for apply_patch workspace rejections across standard, Codex, and worker execution while preserving model-visible errors and filesystem restrictions. Merge readiness⛔ Blocked before merge - 1 item remains This remains useful work absent from current main. The previous conflict blocker is resolved, recorded runtime proof supports the diagnostics, and review found no actionable introduced defect. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s patch tool applies model-requested file changes under configuration, session, and workspace boundaries. Rejected operations pass through harness failure handlers that report errors to the model and diagnostics to operators. flowchart TD
A[Model patch request] --> B[Runtime containment policy]
B --> C[Host filesystem checks]
C -->|Allowed| D[File changes]
C -->|Rejected| E[Error with diagnostic metadata]
E --> F[Operator log with explanation]
E --> G[Unchanged model error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +394, Tests +423, Docs +10, Other 0. Total +827 across 24 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep containment decisions with their existing owners and expose their explanations only through shared operator diagnostics. Do we have a high-confidence way to reproduce the issue? Not applicable as a new diagnostic capability; current source establishes the missing explanation, and the supplied runtime traces demonstrate the added output. Is this the best way to solve the issue? Yes. Owner-supplied metadata and a shared reader provide accurate explanations without duplicating containment policy or changing model responses. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4bcc873e508f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
39eb497 to
b00d59a
Compare
|
Addressed the P3 explicit-mock finding in 23d4eea0b4e: both workspace-guard tests now mock the small predicate directly, without loading the production sandbox-path module. No production code changed in this follow-up. The PR body now records the 24 passing workspace-guard tests, passing hint/logging regressions and gateway test files, and the requested The current-main comparison also found a separate containment-policy integration conflict in @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
23d4eea to
70b46ae
Compare
|
Rebased onto 0d30dcb and pushed 70b46aea626. The conflict is resolved without changing main's containment decision. Required-root rejections now explain that neither full permission mode nor workspaceOnly configuration lifts that boundary. The PR body records the three failing-before/passing-after regressions, all 85 passing focused tests, and the full changed-file gate (exit 0). Independent Codex review found no code issues. Exact-head CI is still running. A maintainer still needs to route security-owner review for the existing sandbox-paths.ts delta. GitHub rejected my request for openclaw/openclaw-secops review because the contributor account lacks RequestReviewsByLogin permission. No merge-readiness claim is made. |
70b46ae to
c380ada
Compare
|
/allow-security-sensitive-change |
1c621d7 to
f924c01
Compare
|
/allow-security-sensitive-change |
f924c01 to
f18dee3
Compare
Operators reading a "Path escapes sandbox root" failure had no way to tell which setting caused it, and tools.exec.mode is the wrong guess: it opens exec and leaves the apply_patch file boundary alone. The runtime owner now declares whether configuration, a session mode, or a worker placement imposed containment, and the failure logger names that control. The hint is attached out of band and read only by the failure logger, so it never enters the model-visible tool result. Host rejections are tagged at their throw sites rather than matched by message text, so a sandbox bridge's own mount rejection never draws host-setting advice that cannot lift it. Related: openclaw#131434
…ource directly isSandboxRootEscapeError now lives in sandbox-paths.ts, so the nodes workspace-guard test's explicit vi.mock factory hid it from agent-tools.read.ts and the host rejection surfaced as a vitest mock error instead of the sandbox-root message. Spread the original module so only assertSandboxPath is replaced. The operator-hint test indexed containmentSource off an optional parameter type, which tsgo rejects; import the ApplyPatchContainmentSource type instead. Co-Authored-By: Claude Opus 5 <[email protected]>
f18dee3 to
caa441e
Compare
|
/allow-security-sensitive-change |
|
Improved: apply_patch rejection logs now identify the active workspace restriction across OpenClaw, Codex, and worker execution. With thanks to @Marvinthebored. |
Explain which workspace policy rejected apply_patch in operator logs across OpenClaw, Codex, and worker execution. Preserve containment decisions, outside files, and model-visible errors. Refs openclaw#93140. Reviewed-by: @shakkernerd Co-authored-by: Shakker <[email protected]>
What Problem This Solves
An
apply_patchworkspace rejection tells the model which path failed, but the operator log does not explain why that workspace boundary is active. The answer depends on the run: configuration, a session permission policy, worker placement, or a mandatory workspace root. Changingtools.exec.modedoes not change the patch boundary, and changing a configuration switch cannot lift a mandatory root.The standard tool adapter and Codex dynamic tools use different failure handlers. Both need the same attribution, including when the host rejects a patch during initial path admission or late filesystem revalidation.
User Impact
Operator logs identify the restriction that actually rejected the patch in both OpenClaw and Codex harnesses. Configuration advice names the two independent workspace settings; session and worker advice describe their own policy; required-root advice makes clear that full session permission does not lift the root.
The model receives its existing rejection, and the allowed writes, configuration defaults, file contents and permissions are unchanged. Sandbox bridges retain their own boundary explanations. This diagnostic change does not resolve the writable-bind-mount behavior in #93140.
Why This Change Was Made
The runtime that selects containment also supplies its source. Host rejection owners attach diagnostic metadata to the same error, and the two harness failure loggers consume the advice without placing it in model output, result callbacks or transcript content. A stateless reader in the existing agent-harness runtime SDK lets Codex use the same supported metadata contract. Plugin release tooling synchronizes Codex's required SDK version with its host release and checks that alignment before publication.
Configured patch availability, containment, and its diagnostic source are prepared together, while worker placement retains its own policy. The integration preserves current workspace-mapping admission and the final host checks after awaited file work. It also distinguishes the host validator's symlink-escape failures from in-root hardlink restrictions and unrelated filesystem failures. Errors originating in a sandbox bridge keep their own explanation.
The worker permission cases move into a Vitest-only helper and retain their existing temporary-workspace lifecycle. Production descriptors, stored configuration, and database schemas are unchanged.
Evidence
Current head
caa441e3ec460f224eb71fcffddbbdfd04fb721ais based on maind5eed044d23f135ed5368198f88925833d7b2bc8. Conflict resolution retains main's workspace Memory documentation and remote-attachment capability, including its optional image-workspace argument. The contribution remains 24 paths, with the same diagnostic runtime and test bytes. Against the precedingf18dee3aintegration, 22 result files and 23 paths' added/removed lines are identical; the SDK count adjustment remains exactly one export and one callable on main's new totals, 4,521 and 2,665. Integration with inspected main snapshot066a93fbdacis conflict-free, without a contribution overlap. Hosted validation of this public head passed: 151 successful jobs and 16 skipped.Fresh remote checks on
f18dee3apassed formatting, targeted script lint, the SDK surface gate and all 10 existing surface-report cases. The unchanged cleanup fixture also passed through the repaired normal isolated route. The exactcaa441e3correction passes script formatting, targeted lint, the surface gate at 4,521 exports and 2,665 callables, and all 10 surface-report cases. Its source tree remains unchanged after checks, using the same locked dependencies asf18dee3a. Earlier preflight onf924c017passed formatting, targeted Codex/script/SDK lint, SDK exports and surface limits, all 10 surface-report tests, a syntax compile check, 13 host containment cases on main'sfs-safe0.16.0, and all six Codex diagnostic cases. These executions retain their actual source identities; source comparisons qualify reuse of the unchanged diagnostic paths.The focused verification exercises real tool construction and execution through the standard adapter, Codex dynamic-tool bridge, and worker runtime. Cases cover configuration defaults and independent filesystem configuration, session overrides, required roots in full mode, unconstrained success, ordinary in-root patches, sandbox bridge rejection, and a directory rebound after patch admission. Rejections must preserve outside-file bytes and the original model-visible error while producing one operator diagnostic.
At 5aec2729e417b70c7bf419e34f2a14f03e96f2d7, isolated remote verification passes 95 focused policy and diagnostic cases, plus 707 broader affected cases across patching, path boundaries, standard tool adapters, Codex dynamic tools and the host attempt. The broader batch includes all 81 worker runtime cases. One existing Windows-only path case is skipped on the Linux runner. All 10 existing SDK surface-report cases also pass, including exact export counts and rejection of further growth.
The real pinned Codex 0.154.0 app-server also passes both configuration-default and guarded-session scenarios through the full harness attempt and production host tool capability. A controlled loopback Responses endpoint supplies deterministic tool calls, and the normal finite tool allowlist selects the OpenClaw
apply_patchfunction. Host tool construction uses the OpenAI model provider. Each scenario rejects an outside update, produces exactly one operator log record, then successfully adds an in-root file. Captured operator lines, with fixture paths normalized:In both runs, the native dynamic-tool response and the subsequent model request retain exactly
Path escapes sandbox root (<workspace>): <outside>, without the advice. The outside file keeps its SHA-256 and mode0640; the in-root file contains the expected bytes. Both app-server processes report clean closure with PID exit verified, the fixture server closes, and the temporary fixture state is removed. Required-root rows additionally cover the core factory and generic Codex bridge; maintained mandatory-root entrypoints select OpenClaw or the rooted CLI route.Before the correction, the new declared-mapping, symlink-escape, and late-delete cases failed at the missing operator hint, with 61 other core cases passing. The final focused proof also covers the late provenance-read rejection while preserving its existing unsafe-path message and outside-file contents.
Counterfactual checks remove each diagnostic at its owner: all four contained Codex rows then fail on the missing log while both unrestricted rows still pass; the provenance-read row and both worker rows fail on their missing hints. A plain-Node packaged consumer imports the public SDK entrypoints and verifies the same rejection, hint, unchanged outside file and successful inside write. That packaged check used the preceding integration's CI artifact from merge commit
f178135ccc78, with its producer and runtime, SDK, package, lockfile and build inputs qualified against1c621d7d366af. Its fixture state was removed after the check; it remains evidence from that source, not an execution of the rebased head.The original contribution passed changed-path hygiene, line-count and assertion-safety ratchets, core/Codex/script lint, extension import boundaries, and SDK checks. The rebased integrations pass the invalidated preflights described above, and independent source review found no rebase or integration defect. Broader proof retains its original execution identities, including successful full CI at
5aec2729e417. Hosted validation off924c017executes merge8a4acce37a9a, containing that head and main1083c3fd0253; all 24 feature result files match that published head. The subagent authority group passes all 17 files and 917 tests, including all six authority cases and the previously failing first case. The earlier integration run remains historical failure evidence; the cause of its cleanup-root assertion is unproven. The selected main includes the Gateway partition repair.That run also exposes a separate cleanup-fixture failure:
Shared-state admission requires the host brokerinopenclaw-agent-execution-cleanup.test.ts. An independent execution of the same 229-file group on unchanged main1083c3fd0253reproduces the identical sole failure and stack: 1 failed, 2,725 passed and 20 skipped tests. The tested main tree remains unchanged afterward. Both runs use Node 24.19, two workers, one plan and an 8 GiB Node heap; the baseline has fresh caches and a larger host memory limit. The nonisolated worker can retain a database owner created before this fixture's transport mock, so cleanup reaches the real transport. Landed repair #153286 routes the unchanged fixture through the isolated lane, and the single fixture passed through that normal route on integrationf18dee3a. This PR does not change that owner, fixture or routing. The author's earlier isolated Gateway observation remains historical evidence.