Skip to content

fix: honor sandbox requirements for native forks - #155358

Merged
shakkernerd merged 10 commits into
mainfrom
fix/native-fork-sandbox-guard
Sep 22, 2026
Merged

shakkernerd merged 10 commits into
mainfrom
fix/native-fork-sandbox-guard

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a native session branch could begin materialization before OpenClaw applied the session's required runtime policy.

User Impact

User impact: sandbox-required sessions now return the existing native-runtime restriction before a fork is created. Existing unrestricted forks require no configuration or migration.

Why This Change Was Made

The authority-bearing sessionForkV2 capability can declare an operation-specific execution environment. The shipped legacy sessionFork parameter shape remains source-compatible through its deprecation window, including dual registration where current hosts prefer V2, while its existing harness-level host execution descriptor still applies to the pre-call restriction. The Gateway evaluates the prospective child through the existing runtime-restriction owner, retains the source's isolation floor, and carries current caller/source/harness authority to native write boundaries across imported and canonical forks. That forward authority closes when the fork call settles. Forward policy and rollback ownership are separate: policy or requester access changes stop initialization, while the captured initializer can still remove only its unchanged pending child and verified native fork.

Evidence

  • The registered-handler regression returns AGENT_RUNTIME_RESTRICTED before legacy, V2, or dual host-only invocation, and dual registration selects V2 when unrestricted.
  • The registered Codex fixture rejects a stored required source with no thread/fork request, while the unrestricted compatibility case still creates its child.
  • Successful and failed forks both pass through the registered production harness and real Codex client. Reusing the exact assertion captured from that client's accepted thread/fork after either settlement is rejected at its physical pre-write check and adds no native thread/fork output.
  • A policy change immediately after native fork creation stops forward initialization, archives the verified fork, and removes the pending session.
  • Post-fork requester/source revocation still cleans the captured child; child or registry ownership replacement still refuses cleanup.
  • Source-successor injection before, during, and after link persistence confirms rollback removes only the captured child, link, binding, and native fork while preserving the successor source.
  • The complete registered-handler suite passes 37 cases in 28.7 seconds. The exact lifecycle slice passes three Codex fork/rollback cases in 19.9 seconds; the two affected Codex fork suites pass 25 cases in 15.3 seconds; and the SDK facade suite passes 23 cases in 10.6 seconds. Core types, bounded Codex types, and the SDK surface budget also pass.
  • Blacksmith Testbox verified merged tree a85710edd2d1ebab2f1bc0e84b0fd39535340874 (cf5a04baaee9b6a76016e4631ec90e7e7406b3d9 target plus the reviewed production head): four registered Gateway and four real Codex authority/lifecycle cases passed in 1 minute 58 seconds.
  • The final test-only proof and obsolete source-successor expectation run through the same production code reviewed at 39f3663219025e897c31a2ba142847e82b9c6c7d; its two settlement cases pass locally in 14.6 seconds and its three source-successor rollback cases pass in 32.8 seconds.

@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@shakkernerd shakkernerd self-assigned this Sep 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: M maintainer Maintainer-authored PR labels Sep 22, 2026
@shakkernerd shakkernerd changed the title fix(gateway): honor sandbox requirements for native forks fix: honor sandbox requirements for native forks Sep 22, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 12:28 AM ET / 04:28 UTC (Revision 4).

ClawSweeper review

What this changes

The PR checks sandbox requirements before native session forks, expires fork authority after completion, and preserves guarded cleanup of unfinished children.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. The prior compatibility, rollback, and authority-lifetime findings are addressed, and the new production-client evidence satisfies the remaining scoped proof requirement. No blocking patch defect was found.

Priority: P2
Reviewed head: 87f43d6696d64cc57ed54ee2bd2ea0982142d03f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation and production-client authority evidence resolve the prior blockers without introducing a new correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Authority-chain proof required: satisfied by the reported registered-owner harness runs and inspected production-client cases showing an accepted fork, rejection of retained authority after both settlement outcomes, and no additional native writes. Revocation stops initialization while guarded rollback preserves successor ownership; the native peer is synthetic.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Authority-chain proof required: satisfied by the reported registered-owner harness runs and inspected production-client cases showing an accepted fork, rejection of retained authority after both settlement outcomes, and no additional native writes. Revocation stops initialization while guarded rollback preserves successor ownership; the native peer is synthetic.
Evidence reviewed 11 items Introduced patch and review continuity: Reviewed the pinned merge-base-to-head changes. GitHub's exact-head commit patch confirms the latest commit only adds production-client settlement coverage; the production diff from 39f3663 to the reviewed head is empty.
Current main still needs the repair: Fetched main invokes the legacy native fork after source-incarnation checks without evaluating the prospective child's native-runtime restriction or passing explicit final-write authority. No implemented-on-main conclusion is supported. Inspection of the latest release's harness blob failed because that historical object could not be retrieved; release inclusion is not claimed.
Shared policy and live authority: The guard rechecks caller authority, source incarnation, upstream identity, harness selection, and current configuration, then applies the existing native-runtime restriction owner before host-only forks.
Findings None None.
Security None None.

How this fits together

The Gateway receives session-fork requests and delegates native conversation creation to an agent plugin. Its runtime policy and initialization owners control whether the plugin may create a native thread and whether an unfinished child may be removed.

flowchart TD
  A[Session fork request] --> B[Current caller and source checks]
  B --> C{Runtime policy permits fork?}
  C -->|No| D[Runtime restriction response]
  C -->|Yes| E[Native plugin fork]
  E --> F[Authority check before write]
  F --> G[Publish child or guarded rollback]
  G --> H[Expire fork authority]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +209, Tests +140. Total +349 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 9 290 81 +209
Tests 7 272 132 +140
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 562 213 +349

Review metrics

Metric Value Why it matters
Production versus test growth production net +209 lines; tests and support net +140 lines Production growth centralizes current-policy checks and separates forward authority from rollback ownership.
SDK compatibility window 1 versioned fork capability; legacy support through 2026-10-12 Required authority is added without making the legacy fork parameter type source-incompatible.

Technical review

Best possible solution:

Keep native forks under the shared runtime-policy owner, with operation-scoped write authority and independently fenced rollback.

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

Yes, source establishes a required-sandbox session reaching native fork delegation on current main without the shared runtime-policy check; this read-only review did not execute the failing path.

Is this the best way to solve the issue?

Yes, the patch reuses existing policy and lifecycle owners, preserves the legacy SDK contract, and now checks retained authority through the production client.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 58e27e0fedc4.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Authority-chain proof required: satisfied by the reported registered-owner harness runs and inspected production-client cases showing an accepted fork, rejection of retained authority after both settlement outcomes, and no additional native writes. Revocation stops initialization while guarded rollback preserves successor ownership; the native peer is synthetic.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Authority-chain proof required: satisfied by the reported registered-owner harness runs and inspected production-client cases showing an accepted fork, rejection of retained authority after both settlement outcomes, and no additional native writes. Revocation stops initialization while guarded rollback preserves successor ownership; the native peer is synthetic.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded correction to native session-fork policy and lifecycle enforcement.
  • merge-risk: 🚨 compatibility: The SDK transition and intentional rejection of sandbox-required host forks are compatibility-sensitive; the maintainer-authored proposal explicitly preserves legacy typing and unrestricted behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Authority-chain proof required: satisfied by the reported registered-owner harness runs and inspected production-client cases showing an accepted fork, rejection of retained authority after both settlement outcomes, and no additional native writes. Revocation stops initialization while guarded rollback preserves successor ownership; the native peer is synthetic.
  • proof: sufficient: Contributor real behavior proof is sufficient. Authority-chain proof required: satisfied by the reported registered-owner harness runs and inspected production-client cases showing an accepted fork, rejection of retained authority after both settlement outcomes, and no additional native writes. Revocation stops initialization while guarded rollback preserves successor ownership; the native peer is synthetic.

Evidence

What I checked:

  • Introduced patch and review continuity: Reviewed the pinned merge-base-to-head changes. GitHub's exact-head commit patch confirms the latest commit only adds production-client settlement coverage; the production diff from 39f3663 to the reviewed head is empty. (test/canonical-descendant.integration.test.ts:117, 87f43d6696d6)
  • Current main still needs the repair: Fetched main invokes the legacy native fork after source-incarnation checks without evaluating the prospective child's native-runtime restriction or passing explicit final-write authority. No implemented-on-main conclusion is supported. Inspection of the latest release's harness blob failed because that historical object could not be retrieved; release inclusion is not claimed. (src/gateway/server-methods/sessions-rewind.ts:435, 58e27e0fedc4)
  • Shared policy and live authority: The guard rechecks caller authority, source incarnation, upstream identity, harness selection, and current configuration, then applies the existing native-runtime restriction owner before host-only forks. (src/gateway/server-methods/sessions-fork-runtime-guard.ts:109, 87f43d6696d6)
  • Prior lifecycle findings resolved: The exported assertion closes in finally after successful or failed settlement. Rollback separately checks the captured pending child, registry, binding, and native-thread ownership, allowing source or requester revocation to stop forward work without preventing cleanup of the unchanged child. (src/sessions/session-initialization.ts:59, 87f43d6696d6)
  • Compatibility direction is explicit: The MEMBER-authored captured PR body explicitly accepts rejection of sandbox-required host forks and states that unrestricted forks need no migration. The legacy parameter shape remains source-compatible through 2026-10-12; dual registration selects V2, and the bundled Codex caller uses V2. SDK type assertions protect the legacy shape. (src/agents/harness/types.ts:505, 87f43d6696d6)
  • Final-effect authority proof: The captured body reports both settlement cases passing in 14.6 seconds. The inspected helper captures the assertion from an accepted production-client thread/fork call, reuses it after success or policy-triggered failure, expects source-closed rejection, and verifies no additional native fork request. The registered Gateway, plugin, initialization, and client owners run against a synthetic native peer; the client request implementation is not replaced. (test/canonical-descendant.integration.test.ts:117, 87f43d6696d6)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-22T02:28:49.804Z sha 30ba678 :: blocked before merge. :: [P1] Version the required fork-authority parameter | [P2] Keep runtime-policy rejection out of rollback ownership
  • reviewed 2026-09-22T03:16:10.186Z sha dcdfec3 :: needs real behavior proof before merge. :: [P2] Expire the exported guard when the fork operation settles
  • reviewed 2026-09-22T03:59:21.152Z sha 5a4bb6d :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 22, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 22, 2026
@shakkernerd
shakkernerd merged commit a3b58db into main Sep 22, 2026
205 of 217 checks passed
@shakkernerd
shakkernerd deleted the fix/native-fork-sandbox-guard branch September 22, 2026 04:32
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Native session forks now honor required runtime policy before creating a child.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
Native session forks now apply OpenClaw's required runtime policy before native execution, while preserving shipped plugin compatibility and initializer-owned cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

1 participant