Skip to content

refactor(cron): split service operations - #113830

Merged
steipete merged 2 commits into
mainfrom
codex/j1-cronops
Jul 25, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/j1-cronops

Conversation

@steipete

@steipete steipete commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves an oversized core cron service module that mixed scheduler lifecycle, reads, persistence mutations, stream state, and manual-run admission/completion in one 2,045-line file. The file remained on the max-lines baseline and made ownership and review boundaries unnecessarily difficult to follow.

Why This Change Was Made

Keeps src/cron/service/ops.ts as the stable public facade while moving the existing implementation into six cohesive modules, all below the repository's approximate 700-line guideline. Shared cron invariants live in one small internal helper module so the split remains acyclic and behavior-neutral.

The required audit found pre-existing defects, including a live-probe expectation mismatch. They were deliberately not fixed in this PR so the structural change stays reviewable, and they are tracked separately for dedicated follow-ups.

User Impact

No user-visible behavior changes. This reduces core maintenance risk and removes src/cron/service/ops.ts from the max-lines baseline without changing the cron service API, persisted job shape, scheduling behavior, or execution semantics.

Evidence

  • Focused cron operations proof: 7 files, 116 tests passed after rebasing onto current origin/main.
  • Real packaged cron lifecycle proof: a real Gateway persisted and executed cron job 216e24c2-0596-47d2-b672-c2fcd62185ce, recorded run manual:216e24c2-0596-47d2-b672-c2fcd62185ce:1785010228236:1 with status: "ok", and confirmed cleanup (run).
  • Blacksmith Testbox changed gate: passed after the final current-main refresh, including max-lines ratchet, formatting, production/test typechecks, full core/script lint, import-cycle checks, and architecture guards (run).
  • Fresh Codex autoreview after the final refresh: clean, no accepted/actionable findings; overall correctness 0.97.
  • Every resulting production module is below 600 lines; ops.ts is a 22-line facade.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Jul 25, 2026
@steipete steipete self-assigned this Jul 25, 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 4:02 PM ET / 20:02 UTC.

ClawSweeper review

What this changes

This PR replaces the 2,045-line cron service operations implementation with focused lifecycle, read, mutation, and manual-run modules while preserving ops.ts as the public operations facade.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep open. The protected maintainer label and active author assignment require explicit maintainer handling; the branch is a focused cron refactor with no concrete correctness defect identified, but its supplied evidence is test/CI-based rather than an after-fix runtime demonstration of the scheduler path.

Priority: P3
Reviewed head: 0c90e46eefd409df474a20c0038838e2a4c55894
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation appears focused and well-covered by automated checks, but real cron runtime proof is still required before merge.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR reports focused tests and a passing changed gate, but does not provide direct after-fix runtime evidence of scheduler startup, persisted-job execution, and completion; add redacted terminal output, logs, or a recording and redact private endpoints, keys, IP addresses, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports focused tests and a passing changed gate, but does not provide direct after-fix runtime evidence of scheduler startup, persisted-job execution, and completion; add redacted terminal output, logs, or a recording and redact private endpoints, keys, IP addresses, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Stable facade retained: The proposed facade is reduced to a 22-line ops.ts module while the prior public cron-operation implementation is moved into focused service modules, preserving the established entry point for cron callers.
Lifecycle and run paths are separated: The branch places startup recovery and timer lifecycle in ops-lifecycle.ts, and manual-run preparation/execution in dedicated modules; these are high-value scheduler paths that warrant a real after-fix run in addition to unit and gate coverage.
Refactor provenance: The split was introduced by the cron-service refactor commit and followed by a focused type-privacy correction, indicating the current branch is intentionally scoped to internal module boundaries.
Findings None None.
Security None None.

How this fits together

The cron service is OpenClaw’s scheduler layer: callers manage jobs through its public operations facade, which loads persisted jobs, controls the scheduler lifecycle, and admits manual or timed runs. The split moves those internal responsibilities into separate modules while retaining the facade used by the rest of the product.

flowchart LR
  Clients[Cron callers] --> Facade[Public operations facade]
  Facade --> Lifecycle[Lifecycle operations]
  Facade --> Reads[Read and list operations]
  Facade --> Mutations[Job mutation operations]
  Facade --> Runs[Manual run operations]
  Lifecycle --> Store[SQLite cron store]
  Mutations --> Store
  Runs --> Scheduler[Timer and execution]
  Reads --> Store
Loading

Decision needed

Question Recommendation
Should this protected core-scheduler refactor merge after a current-head runtime cron lifecycle proof is added and the remaining checks finish? Request runtime cron proof: Ask for a redacted current-head run covering scheduler start, a persisted job execution, and completion or reload confirmation before approving the refactor.

Why: The patch changes no stated product contract, but it reorganizes lifecycle and run-admission logic in a protected maintainer-reviewed area; test and CI output alone do not establish the requested after-fix real behavior proof.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports focused tests and a passing changed gate, but does not provide direct after-fix runtime evidence of scheduler startup, persisted-job execution, and completion; add redacted terminal output, logs, or a recording and redact private endpoints, keys, IP addresses, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This broad internal move covers scheduler startup recovery, persistence mutations, and manual-run admission; CI is encouraging, but the supplied evidence does not directly demonstrate an after-fix cron lifecycle run against persisted state.
  • Resolve merge risk (P1) - The PR is behind the current base, so its final merge result should be refreshed after the remaining checks complete.
  • Complete next step (P2) - A protected scheduler refactor needs maintainer review and contributor-origin runtime evidence; automated repair cannot supply proof from the contributor’s setup.
Agent review details

Security

None.

PR surface

Source +72, Other -1. Total +71 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 7 2117 2045 +72
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 8 2117 2046 +71

Review metrics

Metric Value Why it matters
Cron operation split 1 facade retained; 6 focused implementation modules added The refactor moves lifecycle, reads, mutations, and execution across scheduler-critical boundaries while preserving the caller-facing entry point.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cron/service/ops-lifecycle.ts, migration/backfill/repair: src/cron/service/ops-run.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Capture a scheduler lifecycle run before merge (recommended)
    Add redacted evidence from the current head showing cron startup, persisted-job execution, and terminal completion so the moved lifecycle and admission paths are exercised outside mocks.
  2. Accept the automated-only proof
    Merge based on the focused cron tests and changed gate while explicitly accepting residual scheduler-availability risk from the large internal move.

Technical review

Best possible solution:

Keep the facade-only design, then provide a redacted real runtime transcript that starts the scheduler, runs a persisted job manually or on schedule, and confirms completion after reload before normal maintainer merge review.

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

Not applicable: this PR is a structural refactor, not a reported user-facing failure. Its relevant validation is an after-fix cron lifecycle run rather than reproducing a pre-fix bug.

Is this the best way to solve the issue?

Yes, preserving the existing facade while separating cohesive lifecycle, read, mutation, and run responsibilities is the maintainable direction; the remaining gap is runtime proof that the moved scheduler paths preserve behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a behavior-neutral maintainability refactor with no demonstrated user-facing regression.
  • add merge-risk: 🚨 availability: The moved code includes scheduler lifecycle, startup recovery, timer control, and manual-run admission, so an integration mistake could stop or stall cron work despite passing unit and CI gates.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports focused tests and a passing changed gate, but does not provide direct after-fix runtime evidence of scheduler startup, persisted-job execution, and completion; add redacted terminal output, logs, or a recording and redact private endpoints, keys, IP addresses, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a behavior-neutral maintainability refactor with no demonstrated user-facing regression.
  • merge-risk: 🚨 availability: The moved code includes scheduler lifecycle, startup recovery, timer control, and manual-run admission, so an integration mistake could stop or stall cron work despite passing unit and CI gates.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports focused tests and a passing changed gate, but does not provide direct after-fix runtime evidence of scheduler startup, persisted-job execution, and completion; add redacted terminal output, logs, or a recording and redact private endpoints, keys, IP addresses, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Stable facade retained: The proposed facade is reduced to a 22-line ops.ts module while the prior public cron-operation implementation is moved into focused service modules, preserving the established entry point for cron callers. (src/cron/service/ops.ts:1, 0c90e46eefd4)
  • Lifecycle and run paths are separated: The branch places startup recovery and timer lifecycle in ops-lifecycle.ts, and manual-run preparation/execution in dedicated modules; these are high-value scheduler paths that warrant a real after-fix run in addition to unit and gate coverage. (src/cron/service/ops-lifecycle.ts:1, 0c90e46eefd4)
  • Refactor provenance: The split was introduced by the cron-service refactor commit and followed by a focused type-privacy correction, indicating the current branch is intentionally scoped to internal module boundaries. (src/cron/service/ops.ts:1, 2178e0a7b9d0)
  • Validation reported by the PR: The PR body reports 116 focused cron-operation tests and a passing Blacksmith changed gate, but these are supplemental test/CI evidence rather than direct after-fix runtime proof of cron startup, persistence, and execution. (0c90e46eefd4)
  • Protected maintainer handling: The supplied GitHub context shows the maintainer label and an active assignment, so this PR should remain open for explicit maintainer review rather than automated cleanup.

Likely related people:

  • steipete: Authored both commits on the current PR head, including the cron-operations split and its follow-up type-surface correction; current-main feature-history ownership could not be independently inspected in this read-only environment. (role: recent area contributor; confidence: medium; commits: 2178e0a7b9d0, 0c90e46eefd4; files: src/cron/service/ops.ts, src/cron/service/ops-lifecycle.ts, src/cron/service/ops-mutations.ts)

Rank-up moves

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

  • Add a redacted current-head cron lifecycle transcript showing startup, persisted-job execution, and completion or reload confirmation.
  • Refresh the branch against current main after the remaining required checks complete.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 25, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Applied the ClawSweeper rank-up moves on current PR head 1b0cae2a206592d88722c1bf777257f0cca702cc:

main continued moving after the refresh; per the repo-native landing policy, that later behind-main drift is advisory because the current PR merge result has passed exact-head hosted CI. No audit bug or placement finding was folded into this behavior-neutral split.

@steipete
steipete merged commit 731a5d1 into main Jul 25, 2026
121 of 125 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/j1-cronops branch July 25, 2026 20:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 26, 2026
* refactor(cron): split service operations

* fix(ci): keep cron preparation type private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL 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.

1 participant