Skip to content

fix: node turns bypass before_agent_run policies - #164270

Merged
steipete merged 2 commits into
mainfrom
codex/node-parity-r3-gate
Oct 3, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/node-parity-r3-gate

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes OpenClaw node-hosted turns bypassing plugin before_agent_run policies: input rejected locally could still reach a model on a node.

User Impact

The Gateway now gates node input before transcript persistence or worker launch. Blocks and hook failures return the redacted block message, and the placement remains available for the next turn.

Node admission sees the Gateway prompt and loaded history. It omits the system prompt assembled later on the node; policies requiring that final context must use a supported local runner. This does not establish parity for other lifecycle hooks or change pending-input retention.

Why This Change Was Made

Node admission now uses the same fail-closed decision and redacted-message owners as local and CLI runners, under the retained executable plugin generation. The standard hook context projection supplies the admitted identity. The Gateway rechecks run, placement, cancellation, and transcript authority after the hook, and releases a blocked turn's claim.

The security repair adds 120 net production lines (+292/-172), within the approved policy-bypass exception. Gateway admission and persistence fencing require new integration code; duplicated local/CLI policy decisions, message construction, and casts were removed. The cast baseline only shrinks.

Evidence

  • Five new admission regressions fail against original production code; 21 existing cases pass in that negative control (112.09 s wall). Coverage includes both persistence paths, thrown hooks, and authority loss during an awaited gate.
  • Owner and sibling proof: 148 tests across six whole files passed on the lease. The execution file passed all 26 tests standalone in 123.83 s wall (node scripts/run-vitest.mjs src/gateway/worker-environments/worker-turn-execution.test.ts --maxWorkers=1, the repository test wrapper). Core and every core-test type lane, changed-file formatting, typed lint, and the selected structural guards passed. Initial lint findings were fixed and the failed lint plus remaining planned guards rerun; passing type and guard evidence was retained. After rebasing and consolidating context preparation, all 71 Gateway owner/sibling tests passed again in 302.99 s wall. Exact-head CI run 37119128403 passed, including openclaw/ci-gate, selected Node suites, production/test types, and lint. The execution suite passed all 26 cases in 75.38 s in hosted shard agentic-gateway-server-isolated-hosted-20; its containing CI job completed in 175 s including setup and other shard work.
  • Live baseline: local policy blocked with zero deltas, while the node returned SHOULD_NOT_RUN. Candidate: both hosts returned the policy block with zero deltas/tools. The same node session then executed exec and returned CONTINUATION_OK; its transcript contains the redacted block rather than the original prompt.
  • Source hashes were verified on the isolated AWS lease before candidate execution. Two loopback nodes prove this composition, not WAN or physical-device behavior.
  • Indexed call-count/order fixtures were searched across the repository. No additional fixture repair was needed.
  • Independent Codex autoreview: no actionable P0–P2 findings.

Six local and six node pong turns on the same lease at base 47a026ea3fe6; medians exclude turn 0. Candidate is the final committed implementation. All values are milliseconds.

Revision Local first delta / final / tail Node first delta / final / tail
Baseline 1493 / 1784 / 176 1465 / 2115 / 594
Candidate 1548 / 1878 / 322 1644 / 2196 / 604

Node tail increased 10 ms and local tail increased 146 ms in this small sample. This is a policy repair, not evidence of a speed improvement.

The execution suite uses the existing placement fixture and real transcript storage to prove admission ordering and claim release; a helper-only test cannot detect this bypass.

Compatibility review: ClawSweeper completed its exact-head review with no code findings. Its serialized-state heuristic flagged cli-run-transcript.ts; the reviewed diff replaces only the inline blocked-message builder with the shared builder. Both emit the same role, text content, timestamp, hook-block:before_agent_run:user:<runId> idempotency key, and __openclaw.beforeAgentRunBlocked.{blockedBy,blockedAt} fields and values. The transcript writer, reader, schema, and schema version are unchanged. Existing CLI/local block regressions and real transcript readback pass; no stored-data migration is introduced or required.

Run before_agent_run under the retained plugin generation before node input
persistence or worker launch. Reuse the local/CLI fail-closed gate and redacted
message owner, fence blocked writes, and release the placement claim.

Lease proof: 148 owner/sibling tests; five regressions fail on original code;
core and core-test types, typed lint, and changed structural checks passed.
Live blocked input produced no node deltas/tools; a following tool turn passed.

Committed with --no-verify because the sparse worktree has no dependencies.
The full changed-file oxfmt check passed on the isolated AWS validation lease.
Keep policy admission and admitted transcript context at the user-message owner. Reuse the standard hook context projection and remove narration and one-use type aliases.

Rebased owner/sibling proof: 71 tests pass; core types, typed lint, line cap, and formatting pass on the AWS lease. The sparse local pre-commit hook was skipped only after that remote formatting proof. Independent review found no actionable P0-P2 findings.
@clawsweeper

clawsweeper Bot commented Oct 3, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 11:16
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 7:32 AM ET / 11:32 UTC (Revision 2).

ClawSweeper review

What this changes

The PR applies plugin input policies before node-hosted turns persist approved input or launch a worker, and shares fail-closed blocking behavior with local and CLI runners.

Merge readiness

✅ Ready for maintainer review

This repair remains necessary on current main. No actionable introduced defects were found, and source comparison resolves the previous transcript compatibility blocker.

Priority: P0
Reviewed head: 1d7c8c59f70e4d0f189f9f2309caf1a5807bc3df

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner consolidation, failing baseline regressions, real before/after node observations, and verified transcript equivalence provide strong review evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured AWS loopback-node observations exercise Gateway admission through real node turns: rejected input produces no model deltas/tools, redacted transcript readback succeeds, and the same session subsequently executes an allowed tool turn. Source and regressions support post-await revocation fencing. The CLI builder extraction preserves the existing serialized shape, resolving the prior upgrade concern without a migration.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured AWS loopback-node observations exercise Gateway admission through real node turns: rejected input produces no model deltas/tools, redacted transcript readback succeeds, and the same session subsequently executes an allowed tool turn. Source and regressions support post-await revocation fencing. The CLI builder extraction preserves the existing serialized shape, resolving the prior upgrade concern without a migration.
Evidence reviewed 8 items Introduced change and merge ownership: Reviewed the pinned merge-base-to-head changes. Raw test-merge parents are exactly the supplied base followed by the PR head; the transcript builder replacement also survives that three-way merge.
Policy boundary and authority fencing: Node admission invokes the shared gate under the retained plugin generation before approved persistence and credential acquisition. It revalidates run, cancellation, placement claim, and transcript identity after awaited policy execution; blocked writes inherit the synchronous transcript commit assertion.
Prior compatibility blocker resolved: Compared the original inline CLI message with the shared builder: role, text content, timestamp, idempotency key, blockedBy, and blockedAt retain the same values and shape. Only construction moves; transcript writers, readers, and schema remain unchanged. The captured body also reports passing existing block regressions and real transcript readback. No migration is required.
Findings None None.
Security None None.

How this fits together

The Gateway dispatches agent turns to node-hosted workers. Input admission sits between incoming prompts and conversation history, transcript persistence, and worker execution.

flowchart TD
  A[Incoming prompt and history] --> B[Gateway node admission]
  B --> C[Plugin input policy]
  C -->|Blocked or failed| D[Redacted transcript and blocked reply]
  C -->|Allowed| E[Recheck live authority]
  E --> F[Approved transcript and worker launch]
  D --> G[Release turn claim]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +121, Tests +144, Docs +11, Other -1. Total +275 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 292 171 +121
Tests 1 145 1 +144
Docs 3 22 11 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 13 459 184 +275

Review metrics

Metric Value Why it matters
Production versus test growth production +120 net lines; tests +144 net lines The body justifies production growth for Gateway admission and persistence fencing while consolidating existing local and CLI decisions.

Stored data model

Persistent data-model change detected: serialized state: src/agents/cli-runner/cli-run-transcript.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Use the shared fail-closed admission owner for node turns while preserving transcript compatibility and the documented Gateway-context boundary.

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

Yes: current main's node path lacks the existing input-policy gate, and the supplied baseline evidence demonstrates rejected input reaching the node model. This review inspected source without executing the runtime.

Is this the best way to solve the issue?

Yes: sharing the existing gate and redacted-message builder repairs the bypass at Gateway admission without adding configuration or changing stored transcript contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P0: The repaired defect allows node-hosted input to bypass plugin policies that reject the same input locally.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured AWS loopback-node observations exercise Gateway admission through real node turns: rejected input produces no model deltas/tools, redacted transcript readback succeeds, and the same session subsequently executes an allowed tool turn. Source and regressions support post-await revocation fencing. The CLI builder extraction preserves the existing serialized shape, resolving the prior upgrade concern without a migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured AWS loopback-node observations exercise Gateway admission through real node turns: rejected input produces no model deltas/tools, redacted transcript readback succeeds, and the same session subsequently executes an allowed tool turn. Source and regressions support post-await revocation fencing. The CLI builder extraction preserves the existing serialized shape, resolving the prior upgrade concern without a migration.

Evidence

What I checked:

  • Introduced change and merge ownership: Reviewed the pinned merge-base-to-head changes. Raw test-merge parents are exactly the supplied base followed by the PR head; the transcript builder replacement also survives that three-way merge. (src/agents/cli-runner/cli-run-transcript.ts:312, 8ec92074792b)
  • Policy boundary and authority fencing: Node admission invokes the shared gate under the retained plugin generation before approved persistence and credential acquisition. It revalidates run, cancellation, placement claim, and transcript identity after awaited policy execution; blocked writes inherit the synchronous transcript commit assertion. (src/gateway/worker-environments/worker-turn-user-message.ts:124, 1d7c8c59f70e)
  • Prior compatibility blocker resolved: Compared the original inline CLI message with the shared builder: role, text content, timestamp, idempotency key, blockedBy, and blockedAt retain the same values and shape. Only construction moves; transcript writers, readers, and schema remain unchanged. The captured body also reports passing existing block regressions and real transcript readback. No migration is required. (src/agents/harness/before-agent-run.ts:41, 1d7c8c59f70e)
  • Real boundary proof: The captured PR body, source revision 608ba1e917438f2d973e2529e9eceb1e003ed03bbc24e1d913d843f113a940c2, reports an isolated AWS setup with two loopback nodes: baseline node input reached the model, while the final candidate returned the policy block with zero deltas/tools. A subsequent exec turn in the same node session returned CONTINUATION_OK, and transcript readback contained the redacted block. Coverage establishes this composition rather than WAN or physical-device behavior. (1d7c8c59f70e)
  • Meaningful regression coverage: Four parameterized cases exercise explicit blocks and thrown hooks through both persistence paths, asserting redaction, no credential/tunnel acquisition, and claim release. A fifth case closes authority during an awaited passing hook and observes no transcript write or credential acquisition. The body reports all five failing against original production code, plus owner/sibling and exact-head CI passes; tests were inspected, not executed during this read-only review. (src/gateway/worker-environments/worker-turn-execution.test.ts:60, 1d7c8c59f70e)
  • Still necessary on current main: Fetched main retains approved persistence and worker credential acquisition without the newly introduced input gate. GitHub's read endpoint confirms the pinned PR remains open, unmerged, and cleanly mergeable; no verified merged fixing PR establishes redundancy. (src/gateway/worker-environments/worker-turn-execution.ts:134, e40ed06f23cb)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: 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 (1 earlier review cycle)
  • reviewed 2026-10-03T11:22:23.994Z sha 1d7c8c5 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 3, 2026
@steipete
steipete merged commit c81d86e into main Oct 3, 2026
225 of 228 checks passed
@steipete
steipete deleted the codex/node-parity-r3-gate branch October 3, 2026 11:37
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

RomneyDa pushed a commit that referenced this pull request Oct 3, 2026
* fix: enforce input policies before node worker turns

Run before_agent_run under the retained plugin generation before node input
persistence or worker launch. Reuse the local/CLI fail-closed gate and redacted
message owner, fence blocked writes, and release the placement claim.

Lease proof: 148 owner/sibling tests; five regressions fail on original code;
core and core-test types, typed lint, and changed structural checks passed.
Live blocked input produced no node deltas/tools; a following tool turn passed.

Committed with --no-verify because the sparse worktree has no dependencies.
The full changed-file oxfmt check passed on the isolated AWS validation lease.

* refactor: consolidate node input preparation

Keep policy admission and admitted transcript context at the user-message owner. Reuse the standard hook context projection and remove narration and one-use type aliases.

Rebased owner/sibling proof: 71 tests pass; core types, typed lint, line cap, and formatting pass on the AWS lease. The sparse local pre-commit hook was skipped only after that remote formatting proof. Independent review found no actionable P0-P2 findings.

(cherry picked from commit c81d86e)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
* fix: enforce input policies before node worker turns

Run before_agent_run under the retained plugin generation before node input
persistence or worker launch. Reuse the local/CLI fail-closed gate and redacted
message owner, fence blocked writes, and release the placement claim.

Lease proof: 148 owner/sibling tests; five regressions fail on original code;
core and core-test types, typed lint, and changed structural checks passed.
Live blocked input produced no node deltas/tools; a following tool turn passed.

Committed with --no-verify because the sparse worktree has no dependencies.
The full changed-file oxfmt check passed on the isolated AWS validation lease.

* refactor: consolidate node input preparation

Keep policy admission and admitted transcript context at the user-message owner. Reuse the standard hook context projection and remove narration and one-use type aliases.

Rebased owner/sibling proof: 71 tests pass; core types, typed lint, line cap, and formatting pass on the AWS lease. The sparse local pre-commit hook was skipped only after that remote formatting proof. Independent review found no actionable P0-P2 findings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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