Skip to content

fix(cron): capture Codex shell aliases under canonical tool identity with a restrict-only exec pin - #130579

Merged
jalehman merged 11 commits into
mainfrom
oc-979/cron-codex-exec-canonical-capture
Aug 28, 2026
Merged

jalehman merged 11 commits into
mainfrom
oc-979/cron-codex-exec-canonical-capture

Conversation

@jalehman

@jalehman jalehman commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Supersedes #126496. Related: #92238.

What Problem This Solves

Cron trigger scripts created from a Codex-backed turn fail with Unknown tool id: exec when they use the documented exec(...) contract. Codex sessions present OpenClaw's exec as a runtime-specific dynamic tool named gateway_exec; creator capture recorded that presentation name into the persisted toolsAllow cap, and the headless trigger runtime — which rebuilds canonical core tools — could not resolve it.

Why This Change Was Made

The violated invariant: the core-owned toolsAllow cap must be recorded in core's canonical tool vocabulary, not a runtime's presentation names. #126496 compensated downstream — persisting the alias name plus a sealed sidecar binding that authorized a trigger-time gateway_exec→exec projection — and the granting nature of that persisted artifact forced SHA-256 seals, downgrade recovery, and a schema change.

This PR fixes the capture instead:

  • Object-identity projection registry (in-memory only). The host capability marks the concrete exec/process tool objects it constructs; a host-private, ownerPluginId-gated factory is the only way to mint a Codex gateway alias from those exact objects. Capture consults the registry and records the alias under its canonical name. A foreign tool merely named gateway_exec has no registry entry, captures literally, and stays fail-closed. Nothing about the registry is persisted.
  • Durable fail-closed pin. A private requirement records the exact Gateway target and original exec grant position. Storage removes exec from the generic persisted cap and restores it only when the requirement and target validate; missing, malformed, or mismatched state stays without broad exec and fails before trigger, script, or agent execution. Detached-media continuation copies and revalidates the same requirement. Legacy unmarked jobs retain their existing baseline policy. No SQLite schema change.
  • One enforcement choke point. createOpenClawCodingTools pins the rebuilt exec tool (host default, argument rewrite, schema stripping, and the before-tool-call preparation/finalization lifecycle) when the scheduled context carries the pin — covering trigger scripts, script payloads, non-Codex isolated agent turns, and the cron run continuation path. Codex-runtime payload runs already rebuild pinned aliases via the landed scheduled-app-authority round trip.
  • Node (node_exec) and sandbox aliases stay unmapped (fail closed), matching fix(cron): preserve Codex trigger exec authority #126496's scoping. Existing jobs with persisted gateway_exec caps are not migrated (explicit maintainer decision): recreate them from a creator turn.

User Impact

Automations created from a Codex-backed session can call exec(...) in trigger and script payloads without widening toolsAllow. The persisted cap is the ordinary canonical shape (toolsAllow: ["exec", ...]), inspectable with standard tooling. The command stays pinned to the Gateway even when cron's configured default exec host differs, and the pin survives detached-media run continuations. Same-name non-Codex tools, literal alias-name caps, and node/sandbox aliases fail closed.

Evidence

Current exact-head follow-up: rebased onto 869cf47b8dafe7c372a788c615ee7e7acc5bd85d; exact head ddef1ff060da565f589291cdb623dc90bb6887e8. Full build, 6 focused Vitest shards / 195 tests, every check-changed lane, and fresh whole-branch autoreview passed. ClawSweeper dispositions, exact-head real-Gateway deny/no-side-effect plus allow-once proof, direct Codex contract links, managed scheduler evidence, and cleanup are recorded in the durable proof comment. Exact-head CI is attached as run 33183670282.

Original validation on head 713294f66ab (approval-floor repair plus the existing canonical-capture change):

  • pnpm check:changed over the full changed set passes every lane (format, ratchets, dead-export scan, core/extension typechecks, core/extension lint, import cycles, plugin boundaries, SDK surface budget).
  • Focused suites pass: cron store/normalize/ops/trigger-script/jobs-tool-policy, creator-cap, scheduled-tool-policy, host-capability, agent-tool metadata, run-session-state, agent-session-persist, plugin-sdk projection, and the Codex extension dynamic-tool-build suite (90 tests exercising the production host-capability + projection-factory path).
  • New regression coverage: capture canonicalization and alias-name cap matching; collision fail-closed (unregistered gateway_exec captured literally; trigger errors exec is not defined with no filesystem effect); pin persistence round-trip with tolerant normalization (foreign shapes dropped, future extra keys tolerated); pin enforcement across schema/arguments/preparation lifecycle; continuation-slot round-trip; trusted-context re-resolution.
  • Guarded approval-floor coverage: capture, signed caller identity, cron persistence, hidden continuation, generated-media continuation, runtime reconstruction, and the full preparation/finalization lifecycle retain ask: "always". A real Gateway E2E starts from tools.exec.ask: "off"; denial prevents the marker side effect, while a separate allow-once request completes.
  • Trigger-level final-effect regression: a canonically captured pinned cap executes exec(...) gateway-pinned while the configured default exec host is a nonexistent node, proving the pin (not config luck) carries execution; the same script with a literal gateway_exec cap fails closed.

Managed-Gateway proof was later completed on packaged substantive head 713294f66ab (patch-equivalent to the previous PR head except a lint-only refactor): guarded canonical capture persisted ask: "always", its natural trigger was denied with no marker effect, an unguarded comparison succeeded, trigger updates retained the floor, and a separate five-minute one-shot visibly delivered into WebChat. It is explicitly not exact-current-head proof. The ClawSweeper persistent-full-session repair is covered on exact current head by a real-Gateway deny/no-side-effect plus allow-once E2E; full evidence and cleanup are in the follow-up comment. The earlier canonical-capture run was:

  1. A real Codex-backed creator turn (openai/gpt-5.6-luna, agentRuntime: { id: "codex" }) called the automations tool once to add a trigger job without toolsAllow.
  2. Persisted row (SQLite cron_jobs.job_json): toolsAllow contains canonical exec and process (plus node_exec captured literally, unmapped by design), toolsAllowIsDefault: true, toolsAllowExecTarget: { version: 1, host: "gateway" }, toolsAllowProvenance: { source: "final-executable-surface", ... }, account-mode scheduledToolPolicy — no gateway_exec anywhere.
  3. The trigger fired on schedule and Gateway-pinned exec wrote the allowed marker file.
  4. Forbidden colliding-issuer case: an operator-created job with literal toolsAllow: ["gateway_exec"] and the same trigger script recorded cron trigger evaluation failed (internal_error): ReferenceError: exec is not defined in run history, and the forbidden marker check returned ENOENT — stopped before any filesystem I/O.

Direct Codex contract inspection used the exact pinned @openai/codex 0.150.1 source (sibling ../codex checkout, tag rust-v0.150.1, commit 90854393966b21e9ebfd21b122334eb09a20c93d), personally inspected by the acting agent:

  • codex-rs/protocol/src/dynamic_tools.rs — DynamicToolFunctionSpec carries name/description/input_schema/defer_loading; DynamicToolCallRequest carries call_id/turn_id/started_at_ms/namespace/tool/arguments. No producer identity crosses the protocol, which is why producer identity lives in OpenClaw's object-identity registry rather than anything round-tripped through Codex.
  • codex-rs/app-server/src/request_processors/thread_processor.rs:326-411 — validate_dynamic_tools rejects empty/whitespace/reserved names, duplicate names per namespace, and duplicate namespaces, so a colliding registration cannot shadow the harness alias within a namespace.
  • codex-rs/core/src/tools/handlers/dynamic.rs — dispatch reconstructs ToolName from namespace+name and round-trips arguments only.

Follow-up uncommitted-diff autoreview on the approval-floor repair (Codex gpt-5.6-sol) was clean at 0.98 confidence with no accepted/actionable findings. Earlier branch autoreview (Codex gpt-5.5, --mode branch --base origin/main): final run clean — "no actionable defects; the patch consistently carries the captured Gateway exec target from the Codex host projection through cron creation, persistence, and scheduled runtime reconstruction" (0.83). Three earlier accepted findings were fixed with regression tests (continuation-path pin propagation, whole-lifecycle pinning including exec preparation, trusted-context re-resolution); one finding (alias identity loss via bridge re-wrap) was rejected with direct evidence — the spread-carried symbol wrap marker makes the bridge skip re-wrapping (extensions/codex/src/app-server/dynamic-tools.ts:1075), confirmed by the live managed run.

Current production LOC: net +595 (+814/−219); tests/tooling net +648 (+896/−248). The growth funds the host-identity alias issuance, canonical capture, restrict-only pin across persistence/continuation, and lifecycle-complete enforcement; the follow-up approval-floor repair itself is one non-bypassable owner-boundary expression.

This PR is AI-assisted. I reviewed the implementation and validation results and understand the change.

@clawsweeper

clawsweeper Bot commented Aug 27, 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 gateway Gateway runtime agents Agent runtime and tooling extensions: codex labels Aug 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 27, 2026
@jalehman
jalehman marked this pull request as ready for review August 27, 2026 01:39
@jalehman
jalehman requested a review from a team as a code owner August 27, 2026 01:39
@jalehman
jalehman force-pushed the oc-979/cron-codex-exec-canonical-capture branch from 379f68d to 571e62c Compare August 27, 2026 01:50
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 3:42 PM ET / 19:42 UTC.

ClawSweeper review

What this changes

The PR translates Codex Gateway shell aliases to canonical cron tool names and persists a Gateway-only exec restriction that is restored only for a valid scheduled job.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for human security-boundary review. The checked code fixes the capture-time alias mismatch and fails closed when the persisted exec restriction is damaged, but this maintainer-labeled PR adds durable execution-policy state and the required local Codex checkout was unavailable for an independent protocol audit.

Priority: P1
Reviewed head: 1e5dbcd30475e50e0e64e5afb46555dbc83030d9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The owner-boundary implementation is coherent and covered, but independent Codex-contract validation and security acceptance remain material merge blockers.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies this as a MEMBER-authored PR, so the ordinary external-contributor proof gate does not apply; the supplied exact-head Gateway E2E evidence remains useful support for the changed deny/allow boundary.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies this as a MEMBER-authored PR, so the ordinary external-contributor proof gate does not apply; the supplied exact-head Gateway E2E evidence remains useful support for the changed deny/allow boundary.
Evidence reviewed 6 items Current-main behavior: Current main still captures creator tools by their presented names and builds the Gateway alias directly, while the PR adds projection-aware canonical capture and a host-owned projection factory.
Authority enforcement: The introduced runtime wrapper removes caller-controlled host, security, ask, and node parameters before prepare, finalize, and execute; damaged persisted requirements are preflight-stopped before trigger, script, or agent work.
Storage and continuation coverage: The introduced store codec strips the protected exec grant before persistence and restores it only after matching the requirement and target; continuation restoration performs the same validation.
Findings None None.
Security Needs attention Independently validate the authority premise: The persisted restriction is safe only if the Codex dynamic-tool protocol cannot preserve a trustworthy producer identity; the required sibling Codex source was unavailable to this reviewer.

How this fits together

Codex-backed turns capture the tools available when creating a cron job, while later trigger and isolated-agent runs rebuild core tools from that saved policy. The change maps a host-issued alias to canonical exec and carries its restrictive target through storage, continuation, and rebuilt execution.

flowchart LR
A[Codex creator turn] --> B[Gateway shell alias]
B --> C[Canonical cron capture]
C --> D[Stored cron job]
D --> E[Restriction validation]
E --> F[Rebuilt exec tool]
F --> G[Gateway command execution]
Loading

Decision needed

Question Recommendation
Does the security owner accept storing the Gateway-only exec restriction with legacy alias-only jobs requiring recreation or explicit reauthorization, after independently verifying the pinned Codex dynamic-tool protocol premise? Accept the restricted persistence design: Approve the fail-closed target-and-requirement envelope and its explicit recreation path for historical alias-only jobs.

Why: This changes how a scheduled job regains shell capability after persistence, so the remaining question is a security policy decision rather than a mechanical code correction.

Before merge

  • Resolve security concern: Independently validate the authority premise - The persisted restriction is safe only if the Codex dynamic-tool protocol cannot preserve a trustworthy producer identity; the required sibling Codex source was unavailable to this reviewer.
  • Resolve merge risk (P1) - The PR adds net production code and durable private exec-restriction fields to cron-job and continuation state; security ownership should accept the storage and legacy-job recovery policy before merge.
  • Resolve merge risk (P1) - The unavailable sibling Codex checkout prevents this reviewer from independently confirming that the external dynamic-tool protocol cannot carry the producer identity on which the design relies.

Findings

  • [medium] Independently validate the authority premise — src/agents/exec-tool-target-pinning.ts:47
Agent review details

Security

Needs attention: The code has concrete fail-closed checks, but durable scheduled shell authority and the unavailable direct Codex protocol audit require security-owner review before merge.

PR surface

Source +888, Tests +886, Other -1. Total +1773 across 58 files.

View PR surface stats
Area Files Added Removed Net
Source 40 1114 226 +888
Tests 17 1119 233 +886
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 58 2233 460 +1773

Review metrics

Metric Value Why it matters
Production and test delta production +1111/-223 (net +888); tests +1122/-236 (net +886); baseline -1 This is substantial production growth for a focused bug fix, although it spans capture, persistence, continuation, and enforcement rather than only an alias rename.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/cron/index.ts, migration/backfill/repair: src/commands/doctor/cron/repair-plan.ts, migration/backfill/repair: src/commands/doctor/cron/store-migration.ts, serialized state: src/config/sessions/types.ts, serialized state: src/cron/service/state.ts, unknown-data-model-change: src/commands/doctor/cron/store-migration.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Obtain security-owner acceptance (recommended)
    Verify the Codex protocol premise and approve the fail-closed persistence and explicit legacy-job reauthorization behavior before merging.
  2. Pause the persistence change
    Do not merge if scheduled shell restrictions should not be represented in cron state without a different approved upgrade policy.

Technical review

Best possible solution:

Retain capture-time canonicalization and the single restrictive exec wrapper, but merge only after a security owner accepts the persisted-pin and legacy-alias reauthorization policy with the Codex protocol premise independently checked.

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

Yes, at source level: current main captures the Codex-facing alias name, while scheduled execution rebuilds canonical core tools; the PR adds capture-time translation and focused trigger coverage. The cited live proof was not rerun in this read-only environment.

Is this the best way to solve the issue?

Unclear: capture-time canonicalization is the right owner boundary and the implementation consistently applies the restrictive target, but the durable authority representation and external Codex protocol premise still require security-owner acceptance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4395a0cc3e6a.

Labels

Label justifications:

  • P1: The PR repairs scheduled automations that otherwise lose an expected shell capability on the Codex path.
  • merge-risk: 🚨 compatibility: Existing cron jobs with the retired alias are intentionally not migrated and instead require recreation or explicit reauthorization.
  • merge-risk: 🚨 security-boundary: The change creates and consumes durable policy facts that decide whether a scheduled run may restore Gateway-pinned exec.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: Repository state identifies this as a MEMBER-authored PR, so the ordinary external-contributor proof gate does not apply; the supplied exact-head Gateway E2E evidence remains useful support for the changed deny/allow boundary.

Evidence

Security concerns:

  • [medium] Independently validate the authority premise — src/agents/exec-tool-target-pinning.ts:47
    The persisted restriction is safe only if the Codex dynamic-tool protocol cannot preserve a trustworthy producer identity; the required sibling Codex source was unavailable to this reviewer.
    Confidence: 0.78

What I checked:

  • Current-main behavior: Current main still captures creator tools by their presented names and builds the Gateway alias directly, while the PR adds projection-aware canonical capture and a host-owned projection factory. (src/agents/tools/cron-tool-creator-cap.ts:43, 9396ea20296b)
  • Authority enforcement: The introduced runtime wrapper removes caller-controlled host, security, ask, and node parameters before prepare, finalize, and execute; damaged persisted requirements are preflight-stopped before trigger, script, or agent work. (src/agents/exec-tool-target-pinning.ts:155, 1e5dbcd30475)
  • Storage and continuation coverage: The introduced store codec strips the protected exec grant before persistence and restores it only after matching the requirement and target; continuation restoration performs the same validation. (src/cron/store/row-codec.ts:131, 1e5dbcd30475)
  • Exact-head validation supplied in discussion: The latest contributor comment reports exact-head Gateway deny/no-side-effect and allow-once coverage, focused Vitest runs, and successful exact-head CI; this supports the PR’s stated runtime path but was not rerun in this read-only review. (src/agents/bash-tools.exec-gateway-approval.e2e.test.ts:68, 1e5dbcd30475)
  • Codex contract limitation: extensions/codex/package.json identifies the Codex dependency, but the required sibling ../codex checkout is absent and the promisor remote could not resolve github.com, so this review cannot independently validate the dependency protocol claim. (extensions/codex/package.json:11, 1e5dbcd30475)
  • History sampling: Available current-main blame attributes the pre-PR alias capture lines to the shallow-history boundary commit; deeper provenance was unavailable because missing promisor objects could not be fetched. (src/agents/tools/cron-tool-creator-cap.ts:43, 72ff36e97a93)

Likely related people:

  • jalehman: Authored the current 11-commit implementation and the prior related cron/Codex proposal, making them the best available routing contact for the changed owner boundary. (role: recent area contributor; confidence: medium; commits: c1dd233bc386, 1e5dbcd30475; files: src/agents/exec-tool-target-pinning.ts, src/cron/scheduled-tool-policy.ts)
  • Peter Steinberger: Available shallow-history blame attributes the existing creator-cap and Codex dynamic-alias lines to the current-main boundary commit; deeper ownership could not be resolved locally. (role: current-main history attribution; confidence: low; commits: 72ff36e97a93; files: src/agents/tools/cron-tool-creator-cap.ts, extensions/codex/src/app-server/dynamic-tool-build.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Have the security owner independently inspect the pinned Codex dynamic-tool protocol and accept the persistent restriction and legacy-job policy.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-27T09:33:45.734Z sha a186669 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-27T14:44:58.252Z sha e91faf5 :: needs real behavior proof before merge. :: [P1] Preserve guarded approval through scheduled exec reconstruction
  • reviewed 2026-08-27T18:12:50.402Z sha 2ec4233 :: needs real behavior proof before merge. :: [P1] Preserve guarded approval through scheduled exec reconstruction
  • reviewed 2026-08-27T20:51:35.631Z sha 713294f :: needs real behavior proof before merge. :: [P1] Keep the new exec helpers private or define their SDK contract
  • reviewed 2026-08-27T23:36:36.015Z sha e5ef3d0 :: needs real behavior proof before merge. :: [P1] Preserve the approval floor in persistent cron sessions | [P1] Keep the Codex projection helper private or publish its SDK contract
  • reviewed 2026-08-28T15:22:00.547Z sha ddef1ff :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T16:26:58.674Z sha 7a6d056 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T19:18:15.274Z sha 1e5dbcd :: needs maintainer review before merge. :: none

@jalehman

Copy link
Copy Markdown
Contributor Author

Known sibling, intentionally out of scope: the same capture invariant is still violated for CLI-backend (bundled-MCP/loopback) creator sessions, where a requested finite toolsAllow: ["exec"] intersects to [] because the loopback surface carries projected names and excludes gateway exec (#125192, #116059). Filed as #130753 with live evidence from current main and a proposed direction that extends this PR's canonicalization seam. Kept out of this PR because the owning boundary differs (loopback surface resolution vs. Codex in-process dynamic-tool projections) and this PR is under security-boundary review.

@jalehman

Copy link
Copy Markdown
Contributor Author

Exact-head live proof and direct Codex contract audit are complete.

Managed Gateway proof

The active OCM-managed Gateway was bound to installed runtime primary-pr130579-571e62c-clean1; its dist/build-info.json identifies exact PR head 571e62cba5d485540bbc7e0cff9170adcf1031b3.

A fresh Codex-created canary (1a6ec5b6-0db8-4ec6-b039-d7803cd9041f) was created through the default capture path, without an explicit toolsAllow. Its persisted job state recorded:

  • toolsAllowIsDefault: true
  • canonical exec present; gateway_exec absent
  • toolsAllowExecTarget: { version: 1, host: "gateway" }
  • toolsAllowProvenance.source: "final-executable-surface"
  • trigger script: documented exec(...) call
  • trigger.once: true

The naturally due run completed at 2026-08-27T07:21:01.146Z with lastRunStatus: "ok", no error, and duration 5820ms. The job then became disabled with no next run, proving the one-shot trigger evaluated and fired through the reconstructed canonical exec surface. Delivery was intentionally disabled (lastDeliveryStatus: "not-requested") so this evidence does not depend on channel routing.

A later WebChat ACK experiment is deliberately excluded from this proof: its exec call succeeded, but WebChat heartbeat delivery has no outbound route and produced no standalone message. That is a separate routing behavior, not evidence for or against this PR's cron capability repair.

Direct Codex 0.149.1 contract audit

I inspected sibling ../codex at tag rust-v0.149.1 (ff29a44391deccde0aba0f8390337d7f3c319ea4):

  • codex-rs/protocol/src/dynamic_tools.rs:21-26 defines a dynamic function by name, description, input schema, and deferral only.
  • codex-rs/protocol/src/dynamic_tools.rs:47-55 round-trips namespace, tool name, and JSON arguments; it carries no producer identity.
  • codex-rs/core/src/tools/handlers/dynamic.rs:50-60 reconstructs ToolName from the presented namespace/name and derives exposure from the presented spec.
  • codex-rs/app-server/src/request_processors/thread_processor.rs:326-415 validates names, reserved prefixes, namespace-local duplicates, and deferred-tool namespace requirements; no producer identity is introduced there.

This closes the two ClawSweeper rank-up requests for exact-head managed-Gateway behavior and the pinned Codex protocol premise. It is targeted real-behavior proof for canonical creator capture plus natural trigger execution; it does not replace review of the broader persistence/continuation/security-boundary tests already listed in the PR body.

@jalehman

Copy link
Copy Markdown
Contributor Author

Natural-run proof on exact PR head 571e62cba5d485540bbc7e0cff9170adcf1031b3:

  • OCM served the installed runtime primary-pr130579-571e62c-clean1; its dist/build-info.json records commit 571e62cba5d485540bbc7e0cff9170adcf1031b3.
  • A fresh Codex-created cron job omitted explicit toolsAllow, exercising default creator-surface capture.
  • The persisted job captured canonical exec/process, toolsAllowIsDefault: true, toolsAllowProvenance.source: "final-executable-surface", and toolsAllowExecTarget: { version: 1, host: "gateway" }.
  • Its naturally due trigger executed the documented exec(...) call successfully: lastRunStatus: "ok", no error, and lastDeliveryStatus: "not-requested".
  • trigger.once: true then disabled the job and cleared its next-run timestamp, proving trigger evaluation occurred rather than only forcing the payload path.
  • The corresponding pre-fix naturally due canary failed with ReferenceError: exec is not defined.

This is targeted real-behavior proof for canonical Codex capture plus scheduled trigger reconstruction. It does not claim coverage of unrelated WebChat delivery: a separate ACK experiment reached openclaw system event, but WebChat is intentionally not an outbound heartbeat route, so that second-hop delivery result is excluded from this PR evidence.

Direct pinned-Codex audit: tag rust-v0.149.1 (980a6d12110b110d29ec13bdcbe14011100b3566), codex-rs/protocol/src/dynamic_tools.rs confirms dynamic tool specs/calls carry presented name, optional namespace, and arguments—not OpenClaw producer identity; codex-rs/core/src/tools/handlers/dynamic.rs reconstructs dispatch identity from namespace + presented tool name.

@jalehman
jalehman force-pushed the oc-979/cron-codex-exec-canonical-capture branch from 571e62c to a186669 Compare August 27, 2026 09:26
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 27, 2026
@jalehman
jalehman force-pushed the oc-979/cron-codex-exec-canonical-capture branch from e91faf5 to 2ec4233 Compare August 27, 2026 18:05
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 27, 2026
@clawsweeper clawsweeper Bot added 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. and removed 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 Aug 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Aug 28, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Exact-head fail-closed security follow-up

Exact head: 1e5dbcd30475e50e0e64e5afb46555dbc83030d9.

The security follow-up is now implemented at the cron policy owner boundary:

  • newly pinned jobs persist the exact Gateway target plus the original canonical exec grant position;
  • storage removes exec from the generic persisted cap and restores it only when target and requirement match;
  • missing, malformed, or mismatched required state leaves no broad exec grant and fails before trigger, script, or agent execution;
  • detached generated-media continuations copy and revalidate the same requirement before restoring the tool cap;
  • Doctor reports historical literal gateway_exec jobs for recreation or explicit reauthorization instead of inferring authority;
  • legacy unmarked exec jobs retain their existing baseline behavior. No SQLite schema change was made.

Direct Codex contract inspection

The supported dependency is @openai/codex 0.150.1 (extensions/codex/package.json:11). I fetched and directly inspected sibling ../codex tag rust-v0.150.1, commit 90854393966b21e9ebfd21b122334eb09a20c93d:

  • ../codex/codex-rs/protocol/src/dynamic_tools.rs:21-55: function specs carry name, description, input schema, and deferral; calls carry call/turn IDs, optional namespace, tool name, and arguments. No host producer identity crosses this protocol.
  • ../codex/codex-rs/app-server/src/request_processors/thread_processor.rs:278-423: registration validates identifiers and rejects duplicate unnamespaced tools, duplicate names within a namespace, and duplicate namespaces.
  • ../codex/codex-rs/app-server/src/request_processors/thread_processor.rs:1387-1390: validation runs before thread startup consumes dynamic tools.
  • ../codex/codex-rs/core/src/tools/handlers/dynamic.rs:50-81,171-220: runtime dispatch reconstructs ToolName from namespace/name and forwards arguments; it does not recover host-side producer identity.

That confirms the producer binding must remain the pre-protocol OpenClaw object-identity check. Persisted reconstruction must rely on the server-authored target/requirement pair and fail closed when it is incomplete; a name-only gateway_exec binding would not be authoritative.

Exact-head proof

node scripts/run-vitest.mjs \
  src/cron/service.scheduler-regressions.test.ts \
  src/cron/service/timer-execution.tool-policy.test.ts \
  src/agents/bash-tools.exec-gateway-approval.e2e.test.ts
# 2 shards, 3 files, 12 tests passed

node scripts/run-vitest.mjs \
  src/cron/store.test.ts \
  src/cron/service/timer-execution.tool-policy.test.ts
# 1 shard, 2 files, 69 tests passed

env -u CODEX_HOME .agents/skills/autoreview/scripts/autoreview \
  --mode uncommitted --base origin/main --stream-engine-output
# clean; no accepted/actionable findings, correctness confidence 0.97

The new tests protect observable security behavior: damaged required pins cause no trigger/script/agent invocation or filesystem effect; storage cannot persist or restore broad exec from damaged state; continuation restoration rejects the same damage. They fail on the pre-fix path and require no test-only production seam.

Exact-head CI run 33202265563 completed successfully, including openclaw/ci-gate, build, security, lint, type, SQLite lifecycle, UI E2E, and changed test shards.

The retained product decision is explicit: historical literal alias jobs are not automatically granted canonical shell authority; operators recreate or explicitly reauthorize them. The requested @openclaw/openclaw-secops review remains the owner gate for the restricted cron path.

@jalehman jalehman self-assigned this Aug 28, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@openclaw/openclaw-secops Final owner decision requested before landing.

Please approve or reply accepting these security-boundary choices:

  • newly captured scheduled exec authority is stored as a Gateway target plus a grant-coupled requirement, with generic persisted exec removed;
  • missing, malformed, mismatched, or older-writer-lost restriction state fails closed before trigger, script, or agent execution;
  • historical literal gateway_exec jobs are not auto-promoted because their stored name proves neither producer identity nor approval restrictions; Doctor directs explicit recreation or trusted reauthorization;
  • downgrade may remove newly pinned exec capability, but cannot restore broad shell authority.

Pinned Codex 0.150.1 was directly checked: its dynamic-tool protocol carries name/namespace/schema/arguments and correlation, but no trustworthy OpenClaw producer identity or approval floor. Exact head 1e5dbcd is mergeable, openclaw/ci-gate is green, the real-Gateway deny/no-side-effect plus independent allow-once proof is recorded above, and fresh whole-branch autoreview is clean.

@jalehman
jalehman merged commit 151fbaa into main Aug 28, 2026
255 checks passed
@jalehman
jalehman deleted the oc-979/cron-codex-exec-canonical-capture branch August 28, 2026 21:23
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
…with a restrict-only exec pin (openclaw#130579)

* oc-18a,oc-e8d,oc-592,oc-660: canonical cron capture for scheduled tool aliases + restrict-only exec pin

Co-Authored-By: Claude Fable 5 <[email protected]>

* oc-db4: create Codex gateway shell aliases through the host-owned projection factory

Co-Authored-By: Claude Fable 5 <[email protected]>

* oc-729: regression coverage for canonical capture, pin persistence, and enforcement

Co-Authored-By: Claude Fable 5 <[email protected]>

* oc-729: consolidate cap-authority reconciliation into one seam; gate fixes

Co-Authored-By: Claude Fable 5 <[email protected]>

* oc-f0f: pin whole exec lifecycle, cover continuation path, harden context re-resolution

Autoreview findings: continuation slot now carries the restrict-only pin;
pinExecToolTarget pins preparation/finalize/execute; trusted contexts with
execTarget survive re-resolution.

Co-Authored-By: Claude Fable 5 <[email protected]>

* oc-979: read scheduled tool projections through a structural key

The creator-cap capture iterates tools typed only as { name: string }, and
reaching the projection registry required a chained `as unknown as`
assertion that the boundary-guard lint rejects. Key the registry WeakMap by
plain object identity and give the reader a structural parameter covering
exactly what it checks (name plus executable identity), so the caller passes
its tools directly. Tamper checks are unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(cron): preserve scheduled exec approval floor

* fix(cron): preserve scheduled approval above session mode

* test(ui): restore mock gateway event types

* test(agents): split scheduled projection coverage

* fix(cron): fail closed on lost exec pins

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui commands Command implementations extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant