Skip to content

fix(codex): scope app approvals to native threads - #137383

Merged
steipete merged 4 commits into
mainfrom
codex/codex-app-policy-refresh-continued
Sep 3, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/codex-app-policy-refresh-continued

Conversation

@steipete

@steipete steipete commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #137167.

What Problem This Solves

A warm Codex conversation in ask mode could keep a saved connected-app approval after OpenClaw cleared it. Native config readback describes the current configuration, while tool calls use the loaded thread's captured layers. The first proposed fix requested a reload, but Codex can acknowledge the write while an individual thread reload fails. Ordinary app-inventory timeouts also stopped conversations that could safely continue without apps.

Why This Change Was Made

App admission now projects the writable-tool and account-link approval settings into the native session configuration. The native merge gives these settings precedence over user/project configuration, and subsequent user-config reloads preserve them. This removes the durable config writes, readback requests, reload dependency, and obsolete failure paths. Saved native settings, read-only tool policy, disabled tools, and unrelated app policy stay intact.

Normal, resumed, and /btw fork paths share this projection. Existing binding fingerprints refresh cold configurations and rotate warm bindings when override keys change; a private fingerprint revision also invalidates bindings created before this repair. Scheduled authority applies the same link policy after intersecting current and captured approval modes, then keeps its stricter per-tool ceilings. Active legacy-managed app settings outrank session flags, so admission rejects those layers with migration guidance, using the same native precedence set as restricted turns.

Literal-key preservation also covers binding fingerprints: changes to native dynamic-tool schemas, app-link policy, and MCP settings now invalidate identity correctly. Authorization redaction and ordinary fingerprint bytes are preserved. The identical ordinary/scheduled policy serializer is shared, and the assertion baseline decreases for a removed cast.

Ordinary inventory timeouts use the existing features.apps=false recovery. Scheduled runs still stop when their captured authority cannot be verified. No new user configuration, schema, storage format, migration, or protocol version is introduced.

Production: +148/-235, net -87 lines, including shared config-layer and policy-serialization declarations. Guard metadata: +1/-1 (assertion allowance lowered). Tests: +760/-849, net -89, replacing obsolete write/readback fixtures with owner and lifecycle coverage. Docs: +13/-6.

User Impact

ask policy applies to the admitted native thread without modifying shared saved preferences. Existing warm conversations remain warm while their projected policy is unchanged. Ordinary conversations continue without app tools during inventory timeouts; scheduled automations retain their authorization ceiling.

Evidence

  • Nine regressions failed against the previous implementation: configured/account app projection, warm/cold continuation, side forks, and active non-overridable app layers. The scheduled intersection then exposed two additional failing cases: current ask/captured allow and current allow/captured ask. Both now preserve human link review and the scheduled tool ceiling.
  • A final review caught literal __proto__ tool-title/link keys being lost during object assignment. The native probe reproduced one synthetic write with zero approval requests. Approval projection now creates own data properties, and the shared configuration merge preserves them through JSON serialization; the same native probe then requested approval and denied execution.
  • 327 tests pass across plugin thread configuration, side questions, physical-process lifecycle, startup, scheduled app authority, managed requirements, shared fingerprints, and user-MCP lifecycle. Coverage includes tool name/title aliases, disabled/read-only/retired tools, unchanged saved settings, changed-key fingerprints, excluded apps, and ordinary versus scheduled timeout behavior.
  • Real @openai/[email protected] app-server, using the production approval projection helper and synthetic localhost provider/MCP: ordinary, same-thread-after-reload, forked, and scheduled-policy calls each requested one approval; declining each produced zero tool executions. Saved automatic overrides remained unchanged. A separate native probe completed with apps disabled and no exposed app namespace or app MCP server despite saved app enablement. The native model request also retained a literal __proto__ dynamic-schema property. Four fingerprint collision regressions failed before the shared-owner repair and passed afterward. No real credentials or external services were used; these are native-runtime tests with synthetic services.
{"nativeRuntime":"0.153.0","productionHelperUsed":true,"savedOverridesPreserved":true,"ordinary":{"approvalRequests":1,"toolExecutions":0},"afterUserReload":{"approvalRequests":1,"toolExecutions":0},"fork":{"approvalRequests":1,"toolExecutions":0},"scheduledPolicy":{"approvalRequests":1,"toolExecutions":0}}
  • Stored-data compatibility: the scheduled authority capture, parser, auth types, and payload construction are byte-identical to the base. Reopened 64 serialized version-1 payloads spanning both auth variants and every app/tool approval mode; old and new input fingerprints matched, including literal tool keys, and neither reader mutated the payload. Sharing the identical serializer changes no stored format or schema version; the changed intersection only projects effective runtime approval policy. No migration is needed.

Direct dependency evidence at openai/codex commit 41e22fee981a63b3698df7ed36bad393cda24715:

Review Follow-through

The reload-acknowledgment finding and rank-up request are resolved by removing reload from admission altogether. Unit, lifecycle, native-runtime, and scheduled-sibling evidence cover the replacement. The ordinary timeout and scheduled strictness findings from #137167 remain addressed.

Named follow-up: native administrative requirements can independently force automatic review or per-tool approval. This pre-existing policy precedence is outside saved user/project overrides, and 0.153.0 does not expose app requirements through configRequirements/read (native policy, exported requirements). The docs now make administrative authority explicit; exposing that upstream contract and surfacing conflicting effective policy is separate work.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 docs Improvements or additions to documentation extensions: codex labels Sep 3, 2026
@steipete
steipete marked this pull request as ready for review September 3, 2026 15:40
@steipete steipete self-assigned this Sep 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 3, 2026
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Ready to land at bf48c73.

Required CI run 33774038922 passed. Local proof passed all 273 tests across lifecycle inventory, plugin config, side questions, startup, and scheduled authority; the six-path changed gate passed typechecks, lint, policy guards, dead-export scans, and import cycles. Exact commands are in the PR body. Independent Codex autoreview is clean through P2.

Pre-fix lifecycle proof had four failures and 27 passes. The real Codex 0.153.0 app-server confirmed that durable-only cleanup left one synthetic write executable without approval in the same loaded thread; native reload caused an approval request, and declining prevented execution. A separate apps-disabled native thread completed without app tools or its app MCP server. Services were synthetic and local; external connector authentication was not exercised.

The fix stays in the native policy owner, removes the redundant ordinary-turn timeout predicate, and reduces production code by seven lines. All three rank-up moves from the final #137167 review are addressed. No configuration, schema, or stored-format changes are introduced. The latest ClawSweeper comment currently reports review started; no new findings are published.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 3, 2026, 1:06 PM ET / 17:06 UTC.

ClawSweeper review

What this changes

Moves Codex connected-app approval policy into each native thread’s session configuration and preserves literal dynamic-tool keys in policy projection and fingerprints.

Regression provenance

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

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open. No blocking defect was found: the branch replaces durable native-config writes and best-effort reload with a higher-precedence native thread-session overlay, preserving approval enforcement across reload, fork, and scheduled paths.

Priority: P1
Reviewed head: 1a1037c315a09837e517a72cc4f845cfc14b1a2b

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A well-scoped owner-boundary repair with direct dependency-contract support, lifecycle coverage, and real native-runtime after-fix evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied native Codex 0.153 app-server terminal evidence exercises the production policy helper through ordinary, reload, fork, and scheduled paths, observing approval requests and no tool execution after denial.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Supplied native Codex 0.153 app-server terminal evidence exercises the production policy helper through ordinary, reload, fork, and scheduled paths, observing approval requests and no tool execution after denial.
Evidence reviewed 8 items Current-main behavior remains the old implementation: Current main still clears persisted app-approval overrides during plugin thread configuration, so the branch’s central replacement has not already landed.
Thread-local projection owns the repair: The PR projects effective app approvals into the native thread patch for configured-plugin and account-wide app paths, without persisting native settings.
Literal dynamic-tool keys are preserved: The approval projection uses Object.fromEntries, preserving an own literal proto property instead of mutating an object prototype.
Findings None None.
Security None None.

How this fits together

The Codex plugin translates OpenClaw app policy into native Codex thread configuration before connected-app tools run. That configuration determines whether a tool is exposed and whether its action must request approval.

flowchart TD
  A[OpenClaw app policy] --> B[Approval projection]
  B --> C[Native thread session overlay]
  D[User config reload] --> C
  E[Scheduled policy ceiling] --> B
  C --> F[Codex approval decision]
  F --> G[Connected app tool execution]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -87, Tests -89, Docs +7, Other 0. Total -169 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 10 148 235 -87
Tests 5 760 849 -89
Docs 1 13 6 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 17 922 1091 -169

Review metrics

Metric Value Why it matters
Production-versus-test LOC production -87 net, tests -89 net, docs +7 net The durable write/reload owner is removed rather than expanded; the remaining session-policy implementation is smaller.

Stored data model

Persistent data-model change detected: serialized state: extensions/codex/src/app-server/scheduled-app-authority.ts, unknown-data-model-change: extensions/codex/src/app-server/scheduled-app-authority.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Land the owner-boundary repair after normal exact-head CI, retaining native session projection and tracking administrative-requirements handling separately upstream.

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

Yes. The supplied real Codex 0.153 app-server probes exercise ordinary, reloaded, forked, and scheduled-policy paths; direct source inspection identifies the same owner and approval decision path.

Is this the best way to solve the issue?

Yes. Codex’s native session-layer precedence and reload behavior make a thread-local overlay the correct owner-boundary fix; the removed durable-write/reload approach was explicitly best-effort.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 61c67cc8a686.

Labels

Label justifications:

  • P1: The repair addresses a connected-app approval-policy bypass path that could affect real tool actions, without evidence of an active broad compromise.
  • 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 (terminal): Supplied native Codex 0.153 app-server terminal evidence exercises the production policy helper through ordinary, reload, fork, and scheduled paths, observing approval requests and no tool execution after denial.
  • proof: sufficient: Contributor real behavior proof is sufficient. Supplied native Codex 0.153 app-server terminal evidence exercises the production policy helper through ordinary, reload, fork, and scheduled paths, observing approval requests and no tool execution after denial.

Evidence

What I checked:

Likely related people:

  • steipete: 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 (2 earlier review cycles)
  • reviewed 2026-09-03T15:51:31.002Z sha bf48c73 :: blocked before merge. :: [P1] Fail closed when warm-thread reload is not confirmed
  • reviewed 2026-09-03T16:48:31.348Z sha e3247d3 :: needs maintainer review before merge. :: none

Replace durable approval writes and best-effort reload with session overlays shared by normal, forked, and scheduled threads. Preserve native settings and literal configuration keys, invalidate old bindings, and keep ordinary apps-disabled timeout recovery. Native runtime probes and 282 focused tests cover the repaired policy boundary.
@steipete steipete changed the title fix(codex): refresh warm app approvals and preserve timeout recovery fix(codex): scope app approvals to native threads Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 3, 2026
Keep native schema, app-policy, and MCP configuration keys as own JSON properties through stabilization and authorization redaction. Share identical plugin policy serialization with scheduled authority, preserve ordinary fingerprint bytes, and reduce the assertion baseline after removing a cast. Four regressions failed before the fix; all 327 focused tests and independent review pass.
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head is 1a1037c315a09837e517a72cc4f845cfc14b1a2b. The earlier best-effort reload finding is resolved by removing durable writes and reload from app admission: writable-tool and link approval policy now lives in the native thread session overlay. Native user-config reload preserves that overlay. Current/captured scheduled policy applies the same link projection after intersection, while keeping stricter tool ceilings.

The completed repair also preserves literal JSON keys in approval projection, merged configuration, and binding fingerprints. A native __proto__ tool-title reproduction executed one synthetic write with no approval before the fix; afterward ordinary, reloaded, forked, and scheduled-policy probes each requested approval and executed nothing after denial. Native dynamic-tool schema transport retains the literal property, and four fingerprint-collision regressions fail before their owner repair and pass afterward.

Validation: 327 focused tests pass across eight files; the full changed-file checks pass, including production/test type checks, full extension lint, dead exports, and runtime import cycles. Whole-branch and follow-up independent Codex reviews are clean through P2. Real Codex 0.153.0 app-server tests used the production helper with synthetic localhost provider/MCP services; no real credentials or external connector authentication were used. An apps-disabled native turn exposed no app tools despite saved enablement.

The PR body contains the native source evidence, minimum-version proof, and the separate pre-existing administrative-requirements follow-up. Final production delta is -87 lines; tests -89; no new user option, schema, storage format, or protocol version. Exact-head hosted CI is running.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Follow-through for the latest data-model compatibility checklist: verified against the PR base that authority capture, parsing, auth types, and payload construction are byte-identical. The removed local serializer and the shared serializer produce identical authority fingerprints.

A direct old-module/new-module probe reopened 64 serialized version-1 authority payloads spanning both auth variants, all four app approval modes, all four tool modes, and ordinary/literal tool names. Every old/new fingerprint matched, and the readers left each payload unchanged. The no-authority case also matched.

{"payloadsReopened":64,"identicalFingerprints":true,"payloadMutation":false,"captureParserAuthAndPayloadSourceUnchanged":true,"schemaVersion":1}

This is a runtime policy projection repair and serializer deduplication, with no persistent data-model change or required migration. The native session layer outranks user/project settings, while legacy managed layers and administrative requirements retain their authority, as documented and tested.

The full exact-head CI run is green: https://github.com/openclaw/openclaw/actions/runs/33781795118 . GitHub rejected the first merge request because main changed during dispatch; the PR remains open with no merge event, and the native recovery workflow retains that rejected attempt before retrying.

@steipete
steipete merged commit d2829f3 into main Sep 3, 2026
156 checks passed
@steipete
steipete deleted the codex/codex-app-policy-refresh-continued branch September 3, 2026 17:14
@steipete

steipete commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 4, 2026
Apply connected-app ask policy through native thread session overrides, preserving saved native preferences across warm reuse, cold resume, user-config reload, side-question forks, and scheduled turns. Remove durable approval writes, readback, and the best-effort reload dependency. Keep scheduled tool ceilings and reject legacy-managed app layers that outrank session configuration.

Preserve literal JSON property names through approval projection, configuration merge, and binding fingerprints so changed dynamic schemas, app links, and MCP settings invalidate the correct binding. Share identical ordinary/scheduled policy serialization. Ordinary inventory timeouts continue with apps disabled; scheduled authority remains strict.

Validation: 327 focused tests; full changed-file type, lint, boundary, dead-export, and cycle checks; independent Codex review. Real Codex 0.153.0 app-server probes with synthetic localhost services verify approval before execution, denied calls executing nothing, unchanged saved settings, apps-disabled recovery, and literal schema transport.

Related: openclaw#137167. Production net -87 lines. No new user option, database schema, storage format, or protocol version. Native administrative requirements remain authoritative; exposing effective app requirements is recorded as a separate follow-up in the PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL 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