Skip to content

fix(codex): reject unrelated-thread follow-ups at the input hook - #167075

Merged
vincentkoc merged 2 commits into
mainfrom
fix/codex-child-native-tools-20261007
Oct 8, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/codex-child-native-tools-20261007

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Native Codex follow-up admission can mistake a resolvable thread ID and compatible model source for authority to address that thread.

User Impact

OpenClaw's input hook rejects unrelated native receivers and revalidates live authority after preparation, while preserving same-tree follow-ups, saved-child recovery, and lifecycle-qualified parent rotation. Restricted turns stop advertising unavailable native helpers.

This is bounded hook-side hardening, not full helper restoration. Default child restrictions remain enabled. No Codex dependency, native protocol selection, permission policy, or deployed runtime is changed.

Why This Change Was Made

The receiver lifecycle owner rejects known unrelated targets before metadata reads. Collected children require native parent lineage, requested without turn history. Native metadata and current lifecycle custody are checked again after asynchronous preparation.

Only four OpenClaw admin/status denials are added to the audited safe-deny set. Session/conversation denials, unknown denials, finite allowlists, and delegation-depth restrictions remain conservative. Optional hooks do not establish mandatory native isolation.

Related: #157684 by @roboclaw-bot retains distinct value. I inspected its full diff: the restricted-policy predicate overlaps; its broader V1/V2-native wording, discovery, and waiting guidance are not incorporated or superseded here. This patch additionally covers workspace-only restrictions and receiver admission. #153902 and #160700 concern different input-policy and CLI-tool boundaries.

Evidence

Current head: 2edb9bb6bd183d4da66e54a709f07ca057a1e0eb (14 files). Production code and the original 13-file candidate are identical to formally reviewed c90367669a1858b9dad3e308bed6f7ccc4cb51cc; the only subsequent change corrects one sibling test assertion for earlier foreign-root rejection.

  • Formal AutoReview on the unchanged production candidate: scoped-clean, exit 0, no actionable P0–P2 findings. Manual review covers the one-line test-only delta.
  • Target-scope, hook admission, assignment recovery and direct-authority suites: 79/79 passed; prompt and persisted-session-policy/configuration suites: 51/51 passed.
  • Focused production/package types, scoped test types, touched-file lint, formatting, line-cap ratchet and diff checks passed. Stale generated SDK declarations found by the first package-type check were rebuilt through the canonical workflow before its passing check.
  • Fresh actual Codex 0.160.0 native-dispatch proof exercises the production OpenClaw relay CLI, relay admission callback, and receiver monitor, forwarding metadata requests to the real app-server. Synthetic model responses drive real native tools. A fixture byte bridge replaces relay transport; Gateway fallback is unavailable, and outbound delivery is isolated. Parent-rotation controls use real admitted host capabilities and completion custody in isolated state.
  • Assertions inspect receiver task_started events and accepted user input in native persisted records, not model claims or request counters. Native wait joins work; saved-child proof additionally verifies successful native close_agent and resume_agent outputs before the accepted follow-up.
Actual native control New receiver turns Probe input persisted
Same-tree follow-up 1 yes
Unrelated root 0 no
Authority revoked during metadata preparation 0 no
Collected OpenClaw monitor / native-lineage recovery 1 yes
Native close then persisted resume 1 yes
Rotated parent, matching live lifecycle custody 1 yes
Rotated parent, different lifecycle 0 no

Native executable SHA-256: 12eb3e81114588aca3b7998f4f19e8997b056aca08e57a7ca7c8a3ec8c652aad.

Final native proof invocations passed in 26.59s (four controls), 27.56s (two rotation controls), and 26.72s (saved-child control), including import/transform overhead. The earlier focused target/recovery runners took 84.16s and 51.34s. Proof-fixture failures were investigated and corrected; they are not counted as passing evidence.

The first CI run (https://github.com/openclaw/openclaw/actions/runs/37813653535) exposed one obsolete sibling assertion: foreign-root admission now correctly rejects before receiver-turn binding. The signed test-only correction updates that expected denial. The complete native-hook relay retention suite passes 6/6 (86.55s Vitest / 89.95s runner).

Current-head CI: https://github.com/openclaw/openclaw/actions/runs/37815283027 (in progress when recorded). Required GitHub checks and native merge admission remain enforced.

Redacted actual-native receipt excerpts

The following fields are extracted from the successful fixture receipts; unrelated metadata, local paths and ephemeral thread identifiers are omitted. The denied relay path has no Gateway fallback, so the production CLI emits its generic explicit deny response, which the native dispatcher records as blocked. No claim of native hook-failure isolation is made.

[
  {
    "mode": "unrelated",
    "targetTurns": 0,
    "targetHasInput": false,
    "nativeHookStatuses": [
      "blocked"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"Native hook relay unavailable\"}}\n",
        "stderr": "native hook relay unavailable: isolated proof has no Gateway fallback\n"
      }
    ]
  },
  {
    "mode": "same-tree",
    "targetTurns": 1,
    "targetHasInput": true,
    "nativeHookStatuses": [
      "completed"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "",
        "stderr": ""
      }
    ]
  },
  {
    "mode": "revoked",
    "targetTurns": 0,
    "targetHasInput": false,
    "nativeHookStatuses": [
      "blocked"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"Native hook relay unavailable\"}}\n",
        "stderr": "native hook relay unavailable: isolated proof has no Gateway fallback\n"
      }
    ]
  },
  {
    "mode": "collected-child",
    "targetTurns": 1,
    "targetHasInput": true,
    "nativeHookStatuses": [
      "completed"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "",
        "stderr": ""
      }
    ]
  },
  {
    "mode": "rotated-parent",
    "targetTurns": 1,
    "targetHasInput": true,
    "nativeHookStatuses": [
      "completed"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "",
        "stderr": ""
      }
    ]
  },
  {
    "mode": "rotated-denied",
    "targetTurns": 0,
    "targetHasInput": false,
    "nativeHookStatuses": [
      "blocked"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"Native hook relay unavailable\"}}\n",
        "stderr": "native hook relay unavailable: isolated proof has no Gateway fallback\n"
      }
    ]
  },
  {
    "mode": "saved-child",
    "targetTurns": 1,
    "targetHasInput": true,
    "nativeHookStatuses": [
      "completed"
    ],
    "relayResponses": [
      {
        "exitCode": 0,
        "stdout": "",
        "stderr": ""
      }
    ]
  }
]

Limitations

This proves the bounded hook-to-native effect and recovery contract in isolated local state, not an authenticated or deployed Gateway flow. It does not qualify native isolation when the hook itself is absent or fails. Full helper restoration still needs mandatory native target authorization and a separately qualified official artifact; this PR deliberately retains session-send restrictions until then.

Bind hook-side follow-up admission to the sender tree while preserving current-lifecycle recovery. Keep session/conversation restrictions and stop advertising native helpers on restricted turns. Mandatory native target authorization remains a separate dependency blocker.
@clawsweeper

clawsweeper Bot commented Oct 8, 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 agents Agent runtime and tooling extensions: codex size: M labels Oct 8, 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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 1:23 PM ET / 17:23 UTC (Revision 3).

ClawSweeper review

What this changes

The branch restricts native Codex follow-ups to admitted conversation trees, preserves qualified recovery, and aligns restricted-turn guidance and admin-tool denials with available capabilities.

Example: An agent sends a follow-up to an unrelated native root

  • Before: A resolvable thread ID and compatible model source can pass input preparation without establishing conversation-tree authority.
  • After: The hook rejects the target, and the native proof records zero receiver turns and no persisted probe input.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, bounded repair with real native final-effect evidence and no blocking finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The new Codex 0.160.0 receipts exercise the production relay CLI, admission callback, and receiver monitor with a real app-server and native dispatch. Persisted input and receiver turns distinguish allowed same-tree, collected/saved-child, and matching-rotation recovery from unrelated, revoked, and mismatched-lifecycle rejection. This resolves the prior scoped authority-chain request; authenticated Gateway transport and hook-failure isolation remain outside the stated change. No stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes
User problem: A native agent can address an unrelated conversation when thread resolution and model compatibility are mistaken for permission.
Reason: The change repairs the existing admission boundary and preserves legitimate recovery. Its restriction guidance and narrow admin/status exemptions keep advertised capabilities consistent with effective policy.

Merge readiness

✅ Ready for maintainer review

The new native final-effect evidence resolves the earlier authority-chain proof blocker. This PR remains useful: current main lacks its receiver-scope checks, and no blocking introduced defect was found.

Priority: P2
Reviewed head: 2edb9bb6bd183d4da66e54a709f07ca057a1e0eb

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Codex plugin connects OpenClaw agents to Codex's native conversations and subagents. Its input hook checks follow-up authority before native tools submit input to another conversation.

flowchart TD
  A[Native follow-up request] --> B[OpenClaw input hook]
  B --> C[Sender authority and receiver scope]
  C --> D[Native conversation metadata]
  D --> E[Recheck live lifecycle custody]
  E --> F[Admit native input]
  C --> G[Reject unrelated target]
  E --> G
  F --> H[Receiver conversation turn]
Loading

Technical review

Best possible solution:

Keep receiver authorization in the existing lifecycle owner and retain conservative native restrictions until independent native target enforcement is qualified.

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

Yes, source establishes the missing receiver-tree check in current main; the new native controls demonstrate rejection and preserved allowed behavior after the fix. No reviewer-side runtime execution was performed.

Is this the best way to solve the issue?

Yes, the repair extends the existing admission and lifecycle owners while preserving recovery and conservative session restrictions, rather than claiming optional hooks provide complete native isolation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point. Added test files: 7.

Security

None.

Evidence

What I checked:

  • Introduced receiver authorization: Input preparation now checks admitted tree scope before known-target metadata reads, validates native lineage for collected children, and repeats current-authority checks after asynchronous preparation. (extensions/codex/src/app-server/native-subagent-model-input.ts:215, 2edb9bb6bd18)
  • Actual native final-effect proof: The fully inspected PR body reports production relay CLI, admission callback, and monitor execution against actual Codex 0.160.0. Same-tree, collected-child, saved-child, and matching rotated-parent controls each produce one receiver turn and persisted input; unrelated-root, preparation-time revocation, and different-lifecycle controls produce neither. Receipts show native blocked/completed outcomes. The fixture replaces relay transport and isolates delivery; it does not claim authenticated Gateway coverage or isolation when hooks fail. Captured body identity: 85d774999a76a9fd107d39219bce364364117fa4e757da77acaa13d7a5ae6298. (2edb9bb6bd18)
  • Pinned native dispatch contract: Personally inspected the sibling source: native dispatch returns a blocked result before executing the handler when PreToolUse rejects input; the send-input handler performs the receiver submission. GitHub's annotated rust-v0.160.0 tag resolves to the inspected checkout commit, verifying repository identity and version. (codex-rs/core/src/tools/registry.rs:613, a956835d0207)
  • Prior review continuity: The only change after the previously reviewed production candidate updates the retention test's expected denial to the earlier foreign-root rejection. The new real-native allowed, forbidden, revoked, and recovery controls address the prior rank-up request. (extensions/codex/src/app-server/run-attempt.native-hook-relay-retention.test.ts:322, 2edb9bb6bd18)
  • Current-main necessity and base context: Comparison with fetched main shows the receiver-scope checks remain unique to this branch. Main's changes in the inspected production paths affect separate harness support and monitor callback/refactor hunks. GitHub reports the exact head mergeable; the supplied stale test merge was not used to infer removals or regressions. (extensions/codex/src/app-server/native-subagent-model-input.ts:211, bd90c1bbe666)
  • Existing authority and recovery intent: Read the merged rationale at feat: enforce role model limits in native agents and Visitor Access #154893 and fix(codex): preserve native subagent results through recovery #149864: native work retains its accepted source authority, current revocation checks, original ancestry, and lifecycle-qualified recovery. Main-line blame and feature-history searches connect these owners to the changed path. A deeper historical search encountered an unavailable promisor blob and HTTP 403; accessible history and PR rationale still establish the relevant intent. (extensions/codex/src/app-server/native-subagent-model-input.ts:170, 17d2faf6b710)

Likely related people:

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

PR surface

Source +93, Tests +214, Docs +13. Total +320 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 145 52 +93
Tests 6 219 5 +214
Docs 1 16 3 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 380 60 +320

Review metrics

Metric Value Why it matters
Safe-deny policy expansion 4 admin/status tool denials added These existing denials can retain native capabilities while session/conversation denials remain restrictive.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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:

  • P2: This is bounded native follow-up hardening with recovery controls and no demonstrated urgent production outage.
  • merge-risk: 🚨 security-boundary: The patch changes receiver authorization and four native-policy exemptions; its explicitly bounded scope and final-effect controls resolve the reviewed concerns.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-08T09:01:37.047Z sha c903676 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-08T17:08:41.663Z sha c903676 :: needs real behavior proof before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review October 8, 2026 17:03
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 8, 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 8, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) October 8, 2026 17:27
@vincentkoc
vincentkoc merged commit 9ed1b9d into main Oct 8, 2026
139 checks passed
@vincentkoc
vincentkoc deleted the fix/codex-child-native-tools-20261007 branch October 8, 2026 17:29
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…nclaw#167075)

* fix(codex): reject unrelated-thread follow-ups at the input hook

Bind hook-side follow-up admission to the sender tree while preserving current-lifecycle recovery. Keep session/conversation restrictions and stop advertising native helpers on restricted turns. Mandatory native target authorization remains a separate dependency blocker.

* test(codex): expect early foreign-root rejection
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 extensions: codex merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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: 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.

1 participant