Skip to content

fix(cron): scope all-run job names - #80146

Closed
HemantSudarshan wants to merge 3 commits into
openclaw:mainfrom
HemantSudarshan:hemant/49175-cron-runs-scope
Closed

HemantSudarshan wants to merge 3 commits into
openclaw:mainfrom
HemantSudarshan:hemant/49175-cron-runs-scope

Conversation

@HemantSudarshan

@HemantSudarshan HemantSudarshan commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #49175.

cron.runs with scope: "all" still returns global run-log rows, but job-name enrichment now uses the same agent-scoped job visibility path as cron.list instead of reading every job through the unfiltered cron.list() shortcut.

Problem summary

cron.runs(scope=all) built jobNameById from context.cron.list({ includeDisabled: true }). That list is not caller/agent filtered, so run-history responses could attach another agent's cron job name to otherwise global run entries.

Root cause

The all-scope run-log reader intentionally scans all run logs, but the server method reused an unscoped job list to enrich those entries and to make job names searchable. The leak was in the enrichment map, not in scheduler execution or run-log storage.

Architectural reasoning

  • Reuses context.cron.listPage() for the job-name lookup because it already applies agentId filtering and effective default-agent handling.
  • Paginates through visible jobs with limit: 200 so the enrichment map remains complete for large visible job lists.
  • Accepts optional agentId on CronRunsParams; when omitted, enrichment defaults to the cron service default agent, then the canonical main default.
  • Leaves run-log scanning, job-specific cron.runs, scheduling, delivery, cleanup, retry, and background-task behavior unchanged.
  • Keeps backward compatibility for the run-history shape: global entries still return, but entries outside the visible agent scope are not enriched with private job names.

Testing performed

  • pnpm test src/gateway/server-methods/cron.runs.test.ts src/gateway/protocol/cron-validators.test.ts
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/gateway/protocol/schema/cron.ts src/gateway/protocol/cron-validators.test.ts src/gateway/server-methods/cron.ts src/gateway/server-methods/cron.runs.test.ts
  • pnpm tsgo:core
  • pnpm tsgo:core:test
  • pnpm lint:core
  • OPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changed
  • pnpm check:changelog-attributions
  • git diff --check upstream/main...HEAD

Real behavior proof

  • Behavior or issue addressed: cron.runs(scope=all) no longer builds its job-name enrichment map from every cron job across all agents.
  • Real environment tested: Local Windows source checkout, Node v22.15.0, pnpm 10.33.2. The repo warns that Node >=22.16.0 is preferred on this machine; the targeted proof below completed.
  • Exact steps or command run after this patch: Ran the patched cron.runs server handler from the source checkout with scope: "all" and agentId: "main"; the command throws if the old unscoped cron.list() path is used and records the actual listing call made by the handler.
  • Evidence after fix: Terminal output copied from the patched checkout:
{
  "unscopedListCalls": 0,
  "listPageCalls": [
    {
      "includeDisabled": true,
      "agentId": "main",
      "limit": 200,
      "offset": 0
    }
  ],
  "response": {
    "ok": true,
    "result": {
      "entries": [],
      "total": 0,
      "offset": 0,
      "limit": 1,
      "hasMore": false,
      "nextOffset": null
    }
  }
}
  • Observed result after fix: The patched handler did not call the old unscoped list path (unscopedListCalls: 0) and used the agent-scoped paginated list path with agentId: "main"; the call returned successfully.
  • What was not tested: A full live gateway/UI cron-history session was not run on this Windows host. The existing src/gateway/server.cron.test.ts -t "writes cron run history" integration test was attempted locally and still fails here because the pre-existing all-scope run-log directory listing path returns no entries under the local fs-safe/root implementation. That failure is independent of this privacy fix; the added regression directly tests the changed handler contract.

Risk analysis

Risk is low-to-medium. The changed runtime path is limited to all-scope cron.runs job-name enrichment. It does not alter run execution, scheduler concurrency, cleanup, delivery, retries, or job-specific run-history reads. The main compatibility change is intentionally privacy-preserving: callers still receive all-scope run entries, but job names are only attached for the requested/default agent scope.

Backward compatibility

Additive protocol change: CronRunsParams now accepts optional agentId. Existing cron.runs callers remain valid.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S proof: supplied External PR includes structured after-fix real behavior proof. labels May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main already has a same-or-better trusted caller-scope cron fix from the merged cron ownership PR, so this stale branch is no longer the right landing path.

Root-cause cluster
Relationship: superseded
Canonical: #96883
Summary: The merged trusted caller-scope cron PR is the canonical current-main fix; this PR is an older narrow candidate for the same job-name disclosure area.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the current-main trusted caller-scope cron implementation from #96883 and close this older narrower branch.

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

Yes, at source level: the latest release builds all-scope cron.runs names from the unfiltered cron list, while current main rejects all-scope history for caller-scoped agent clients. I did not run a live two-agent Gateway reproduction in this read-only cleanup review.

Is this the best way to solve the issue?

No for this branch; current main's trusted caller-scope implementation is the better fix because it derives scope from Gateway client identity instead of accepting caller-supplied agentId. The branch should close rather than be repaired on top of obsolete protocol files.

Security review:

Security review needs attention: The branch's proposed fix uses caller-supplied agentId for a security-sensitive visibility boundary, which is superseded by main's trusted caller identity path.

  • [high] Caller-selectable agentId is not the right boundary — src/gateway/server-methods/cron.ts:580
    The PR would let an RPC caller choose the agent id used for job-name enrichment; main now derives caller scope from Gateway client identity and rejects caller-scoped all-scope history instead.
    Confidence: 0.9

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

Codex review notes: model internal, reasoning high; reviewed against ff1e7e1305cc; fix evidence: commit cee2aca40912, main fix timestamp 2026-06-27T02:41:14Z.

@HemantSudarshan
HemantSudarshan force-pushed the hemant/49175-cron-runs-scope branch from 21de933 to bda1db1 Compare May 18, 2026 05:42
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label May 18, 2026

Copy link
Copy Markdown
Contributor Author

Updated this branch to current main at head bda1db1795c4f8811c26a10ba489e20622965817.

What changed after the ClawSweeper review:

  • Rebased the cron run-name scoping fix onto current main, preserving newer runId support alongside the new agentId parameter.
  • Refreshed the generated Swift protocol model conflict to include both runId and agentId.
  • Documented the new cron.runs agentId parameter in docs/gateway/protocol.md.

Validation run at the new head:

  • pnpm test src/gateway/server-methods/cron.runs.test.ts src/gateway/protocol/cron-validators.test.ts
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/gateway/protocol.md src/gateway/protocol/schema/cron.ts src/gateway/protocol/cron-validators.test.ts src/gateway/server-methods/cron.ts src/gateway/server-methods/cron.runs.test.ts apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift
  • pnpm check:changed
  • git diff --check upstream/main...HEAD

Remaining external gate from the prior review: contributor-supplied real gateway/UI or persisted cron run-history proof and maintainer/security confirmation of the all-scope run-log visibility boundary.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P1 High-priority user-facing bug, regression, or broken workflow. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 18, 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 Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. labels Jun 14, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 15, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jun 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

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

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime 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. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cron.runs with scope=all leaks job names across sessions

1 participant