Skip to content

fix(cron): recover from local scope upgrades - #86272

Closed
matin wants to merge 5 commits into
openclaw:mainfrom
matin:codex/issue-154-local-cli-scope-upgrade
Closed

matin wants to merge 5 commits into
openclaw:mainfrom
matin:codex/issue-154-local-cli-scope-upgrade

Conversation

@matin

@matin matin commented May 25, 2026 •

Copy link
Copy Markdown

Summary

  • Request operator.write for cron.add, cron.update, cron.remove, and cron.run instead of operator.admin, so local cron mutations fit the normal write-scoped operator baseline.
  • Teach cron CLI error handling to recognize pairing and scope-upgrade transport failures, then print exact openclaw devices approve ... and openclaw devices list recovery commands.
  • Keep cron CLI JSON errors machine-readable and update the operator-scope docs/changelog.

Verification

  • node scripts/run-vitest.mjs src/cli/cron-cli.test.ts src/cli/cron-cli/shared.test.ts src/gateway/method-scopes.test.ts src/gateway/call.test.ts
  • OPENCLAW_LOCAL_CHECK_MODE=throttled npx --yes [email protected] check:changed
  • node scripts/format-docs.mjs --check
  • node scripts/check-docs-mdx.mjs docs/gateway/operator-scopes.md
  • git diff --check

Real behavior proof

  • Behavior or issue addressed: A local cron CLI command that reconnects with broader cron mutation scopes should ask for normal operator.write access and, when the Gateway requires a scope upgrade approval, should show the exact device approval command instead of a raw WebSocket close error.
  • Real environment tested: Local OpenClaw source checkout on macOS, running the actual openclaw cron add CLI entrypoint through npx --yes [email protected] openclaw, connected to a live local WebSocket listener that closes with the Gateway scope-upgrade close reason and requestId.
  • Exact steps or command run after this patch:
$ node tmp/proof-cron-scope-upgrade.mjs
  • Evidence after fix: Terminal output from the local source CLI:
$ npx --yes [email protected] openclaw cron add --url ws://127.0.0.1:19876 --token proof-token --name scope-upgrade-proof --every 1h --message prove cron scope upgrade guidance
$ node scripts/run-node.mjs cron add --url ws://127.0.0.1:19876 --token proof-token --name scope-upgrade-proof --every 1h --message 'prove cron scope upgrade guidance'
[openclaw] Syncing runtime artifacts (missing_runtime_postbuild_output - required runtime postbuild output missing).
runtime-postbuild: plugin SDK root alias completed in 0ms
runtime-postbuild: bundled plugin metadata completed in 84ms
runtime-postbuild: official channel catalog completed in 3ms
runtime-postbuild: bundled plugin runtime overlay completed in 200ms
runtime-postbuild: static extension assets completed in 38ms
runtime-postbuild: stable root runtime imports completed in 99ms
runtime-postbuild: stable root runtime aliases completed in 13ms
runtime-postbuild: legacy root runtime compat aliases completed in 0ms
runtime-postbuild: legacy CLI exit compat chunks completed in 0ms
No --agent specified; the job will run with the configured default agent. Specify --agent to choose a specific agent.
Gateway scope upgrade pending approval.
Approve it with: openclaw devices approve req-proof-154
Review pending requests with: openclaw devices list
[ELIFECYCLE] Command failed with exit code 1.
exit code: 1
  • Observed result after fix: The CLI prints Gateway scope upgrade pending approval., openclaw devices approve req-proof-154, and openclaw devices list; it no longer surfaces the raw Gateway transport close reason for this cron command path.
  • What was not tested: A full persisted Gateway device-pairing store upgrade was not exercised in this fork PR; the terminal capture uses the same Gateway scope-upgrade close reason over a live local WebSocket to prove the CLI recovery text.

Context: imperfect-co/tulgey#154

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR has been inactive for a while and still is not in a landable state.

The branch has had no head activity for 50 days, is conflict-blocked and waiting on the author, and still carries the unresolved security-boundary and unrelated-scope problems from the prior review; current main intentionally keeps cron mutations admin-scoped. citeturn7search0turn5search1.

So I’m closing this as inactive for now. If you pick the work back up, push a rebased branch with green checks and reopen (or open a fresh PR) and it will be reviewed again.

Review details

Best possible solution:

Close this stalled mixed branch and invite a fresh focused PR that preserves operator.admin, uses current structured Gateway errors, keeps the selected Gateway target and authentication in recovery commands, and excludes changelog, dead-code allowlist, and unrelated formatting changes.

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

Yes for the raw cron CLI scope-upgrade error path: the supplied live WebSocket transcript demonstrates it, but the full persisted Gateway device-upgrade flow was not reproduced.

Is this the best way to solve the issue?

No; actionable cron CLI recovery is useful, but lowering a persistent-control-plane authorization boundary and bundling unrelated automation churn is not the safest or narrowest fix.

Security review:

Security review needs attention: The patch lowers the authorization required for persistent cron scheduling and manual execution.

  • [high] Cron mutation authorization is broadened — src/gateway/methods/core-descriptors.ts:175
    Write-scoped operators would gain permission to create, update, remove, and run persistent cron jobs, increasing durable scheduling and execution authority beyond the current admin boundary.
    Confidence: 0.99

AGENTS.md: found and applied where relevant.

What I checked:

  • Abandoned branch state: The external PR was opened May 25, 2026; its current head is still the May 25 commit e153405e6871c1895e2ea38917226daf75ce7f55, while the live PR is dirty, labeled waiting on author, and had no new head commit or check activity for 50 days as of July 14, 2026. (e153405e6871)
  • Current authorization contract: Current main classifies cron.add, cron.update, cron.remove, and cron.run under operator.admin, so the PR's authorization downgrade remains contrary to the current implementation rather than being obsolete cleanup. citeturn7search0. (src/gateway/method-scopes.ts:131, efc12f2e3148)
  • Security significance: Current security documentation identifies cron as a persistent control-plane capability and recommends denying it on surfaces handling untrusted content, supporting explicit review of any scope broadening. citeturn5search1. Public docs: docs/gateway/security/index.md. (docs/gateway/security/index.md:58, efc12f2e3148)
  • Prior review continuity: The current head exactly matches the previously reviewed SHA, so the five prior findings remain unfixed: admin-scope approval, target-preserving recovery commands, current protocol import, removal of the Knip rollback, and removal of the release-owned changelog entry. (e153405e6871)
  • Useful proof retained: The PR body supplies terminal output from the real cron CLI entrypoint against a live WebSocket close reason, demonstrating the improved human recovery text while clearly noting that a full persisted pairing-store upgrade was not exercised. (src/cli/cron-cli/shared.ts:76, e153405e6871)
  • Existing main recovery work: Current main already has structured scope-upgrade request details, explicit device approval recovery, persisted approved scopes, and least-privilege classified CLI scope selection; this supports preserving the admin boundary and treating remaining cron-specific messaging as a narrow follow-up. citeturn11search0turn11search1. (src/gateway/call.ts:635, af10be59d8)

Likely related people:

  • steipete: Authored the current-main least-privilege CLI scope selection fix and documented the intended explicit scope-upgrade recovery model. (role: recent gateway scope contributor; confidence: high; commits: af10be59d8; files: src/gateway/call.ts, src/gateway/call.test.ts, src/gateway/method-scopes.ts)
  • vignesh07: Carried the operator-scope compatibility repair that made operator.admin satisfy other operator-scope checks in the same pairing and authorization area. (role: adjacent authorization contributor; confidence: medium; commits: 55d492b; files: src/gateway/method-scopes.ts, src/gateway/operator-scopes.ts)

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

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label May 25, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label May 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress.

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.
What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 2026
@matin

matin commented May 25, 2026

Copy link
Copy Markdown
Author

Context on the deadcode allowlist: I restored it after confirming current main is red on the same check-dependencies shard. ea3bb9282c removed those entries, but both current main and this branch report the same files from deadcode:unused-files; with the entries restored, the full dependency shard (deadcode:dependencies, deadcode:unused-files, deadcode:report:ci:ts-unused) passes locally and in CI. Happy to split that if maintainers want it as a separate scripts repair, but without it this PR inherits main's red dependency gate.

On the cron scope: agreed this is the real maintainer/security call. This PR intentionally classifies persistent cron mutations as operator.write so existing write-scoped local CLI pairings can recover through normal scope upgrade approval. If upstream wants cron scheduling to remain admin-scoped, the still-useful smaller piece is the CLI scope-upgrade recovery text/tests.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 25, 2026
@BingqingLyu

This comment was marked as spam.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jun 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M stale Marked as stale due to inactivity 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.

2 participants