Skip to content

refactor(cron): deslop cron service, core, store and isolated agent - #160788

Merged
steipete merged 8 commits into
mainfrom
steipete/cron-deslop
Sep 29, 2026
Merged

steipete merged 8 commits into
mainfrom
steipete/cron-deslop

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/cron (about 41k production lines) had never had a dedicated deslop pass; it only picked up incidental edits from the agent-tools passes. It carried forwarding wrappers, duplicated local types, repeated result projections, re-normalization of already-normalized values, and dead exports across the service, the isolated cron agent, and the core/store modules.

User Impact

None intended. This is a behavior-preserving refactor. Scheduling, timing, run admission, delivery text, error and log messages, persisted SQLite rows and JSON shapes, quarantine keys, transaction boundaries, the config schema, CLI output, and gateway results are unchanged. No migration or operator action.

Why This Change Was Made

The pass removes 1,076 net production lines (565 added, 1,641 removed) across 59 production files, all inside src/cron. Test lines are unchanged (+4/-4, import renames only). It also removes 17 grandfathered unsafe assertions, so config/assertion-safety-baseline.txt shrinks for seven cron files (shrink-only; no other entries touched).

Commit Production net
refactor(cron): deslop cron service -287
refactor(cron): deslop cron core and store -369
refactor(cron): deslop isolated cron agent -457
refactor(cron): keep cap authority reconciliation steps named +38
refactor(cron): drop exports orphaned by the deslop pass -1
fix(cron): type copied session fields by their key set 0 (type-aware lint fix)
chore(cron): shrink assertion-safety baseline for the deslop pass (baseline only)

What was removed:

  • Service: forwarding wrappers (receipt claim/supersession, sync timeout helpers), three copies of the timeout-plus-last-phase message formatting, a dead resolveJobPayloadTextForMain export, single-implementation callback injection in job validation, duplicated validation-context and mutation-option types, and repeated filter whitelists.
  • Core and store: payload, patch, and failure types now derive from their protocol owners; normalization branches in normalize.ts and normalize-payload.ts are consolidated; saveCronJobsStoreWithMetadata reuses saveCronStoreInDatabase inside the same metadata transaction instead of repeating its quarantine and row-replacement steps; and history, diagnostics, and stream-schedule projections are shared.
  • Isolated agent: single-caller adapters in delivery dispatch, awareness, and policy, and in run prepare, config, finalize, and follow-up; prepared-run types now derive from their producer; repeated scans and guards in the delivery and session helpers; and a redundant runtime re-export.

Two decisions worth reviewing:

  • The isolated-agent changes were rebased onto fix(cron): named-session jobs run in the wrong workspace #159444 (named-session jobs run in the wrong workspace). Its workspace resolution, admission, and lease handling were kept exactly. Only simplifications that still applied cleanly to the new code were re-applied.
  • A candidate change that folded the cron cap-authority reconciliation (policy stamp, capture provenance, exec pin) into one nested function was reverted. It was behavior-equivalent, but the three documented steps are easier to review in security-relevant code.

Equivalence notes for the input normalization changes:

  • The nullable string-array helper lost an allowNull option that its only caller always set.
  • The argv truthiness check matches the old non-empty-array check, because normalizeCronCommandArgv returns only a non-empty array or undefined.
  • Per-kind field deletions moved into one grouped cleanup with identical field sets.
  • cronStoreKey is path.resolve, so the store save keeps the same quarantine key.

Evidence

Base a980ef32a98f, head a84b5a6ec2b2. All checks ran locally on macOS with Node 26.

Command Tree Result
oxfmt --check on all changed files; type-aware node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json on all 60 changed cron files final pass
pnpm tsgo:core final pass
pnpm tsgo:core:test three slice commits (35cfe24d2a19) pass, 27 shards
node scripts/run-vitest.mjs <325 explicit files>: every non-E2E test under src/cron plus every outside test importing a changed module three slice commits 5,117 passed, 1 skipped (323 files, 900 s)
run-vitest for the cron tool-policy, scheduled-policy, job, and validation suites after the cap-authority revert final 177 passed (10 files)
pnpm check:import-cycles, pnpm check:madge-import-cycles final 0 cycles
pnpm deadcode:exports, pnpm deadcode:unused-files final 0 entries (after dropping the three exports this pass orphaned)
Codex autoreview, P2 threshold, branch against the merge base final scoped-clean
check-assertion-safety-ratchet, check:max-lines-ratchet, config:docs:check, plugins:inventory:check final pass
Published-driver × candidate upgrade cell: OPENCLAW_UPGRADE_SURVIVOR_SCENARIOS=legacy-operator-state pnpm test:docker:published-upgrade-survivor, published openclaw@latest (2026.9.6) updated to candidate 89ff68620cab candidate pass (636 s). The baseline seeds two CLI-authored cron jobs with legacy run history; the first-hop cron and cron-owner assertions pass after update and Doctor (survivor-default-owner=main, survivor-ops-owner=ops). No scenario seeds quarantine entries; the store writer keeps the same path.resolve key and transaction, and the store.test.ts quarantine cases pass.

No tests were added or removed; the only test edits are four import renames, so per-PR test cost is unchanged. E2E cron suites were not run locally; hosted CI covers them.

Simplify helper indirection, repeated branches, and unused parameters.
Reuse existing types and constants; trim redundant comments.
Consolidate normalization branches, schema types, and delivery coercion.
Reuse store persistence and stream helpers; remove redundant wrappers.
Inline one-use helpers, consolidate delivery branches, and infer duplicate types.
Remove redundant casts and comments while preserving named-session workspace
resolution, admission, worktree leases, and persistent session restrictions.
The policy stamp, capture provenance, and exec pin reconciliation stay separate documented helpers; folding them into one nested function saved a few lines at the cost of reviewability in security-relevant code.
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete steipete self-assigned this Sep 28, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 8:21 PM ET / September 29, 2026, 00:21 UTC (Revision 3).

ClawSweeper review

What this changes

The branch simplifies cron scheduling, SQLite persistence, isolated-agent delivery, and related types while shrinking the unsafe-assertion baseline.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open. Current main still uses the older cron store path, and the merged named-session workspace repair addresses different work. The reported published-updater exercise and the unchanged SQLite save sequence address the prior review concern; this review found no concrete introduced defect.

Priority: P3
Reviewed head: a84b5a6ec2b205fc81f5ec75d0dbd20693257e91

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The broad cleanup has substantial reported validation and a source-supported upgrade path, with no concrete blocking finding in this review.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: Repository State classifies the author as a member, so the external-contributor proof gate does not apply. The changed Doctor writer uses the existing SQLite save owner; the PR body reports a published v2026.9.6 updater and Doctor exercise on legacy jobs with preserved run history, and the cron tree is unchanged at the reviewed head. Quarantine was not seeded in that exercise, but its canonical key, writer, and transaction sequence are unchanged. No stored-data format or schema contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State classifies the author as a member, so the external-contributor proof gate does not apply. The changed Doctor writer uses the existing SQLite save owner; the PR body reports a published v2026.9.6 updater and Doctor exercise on legacy jobs with preserved run history, and the cron tree is unchanged at the reviewed head. Quarantine was not seeded in that exercise, but its canonical key, writer, and transaction sequence are unchanged. No stored-data format or schema contract changes.
Evidence reviewed 8 items Introduced Doctor writer change: The PR calls the existing SQLite save routine after acquiring migration metadata, within the same transaction.
Persistence equivalence: The reused save routine handles quarantine writes and deletions before full row replacement; the store key resolves the path as the old writer did.
Current main comparison: Current main retains the earlier inline Doctor quarantine and row-replacement sequence, so this refactor is not implemented there.
Findings None None.
Security None None.

How this fits together

OpenClaw automations feed saved jobs into the Gateway cron scheduler, which admits runs and records their state in SQLite. Isolated runs then route their output to chat or webhook destinations.

flowchart LR
  A[Saved automation jobs] --> B[Cron scheduler]
  B --> C[Run admission]
  C --> D[Agent execution]
  D --> E[Delivery routing]
  E --> F[Chat or webhook]
  C --> G[SQLite jobs and receipts]
Loading

Before merge

  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
Agent review details

Security

None.

PR surface

Source -1076, Tests 0, Other -5. Total -1081 across 61 files.

View PR surface stats
Area Files Added Removed Net
Source 59 566 1642 -1076
Tests 1 4 4 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 7 -5
Total 61 572 1653 -1081

Review metrics

None.

Technical review

Best possible solution:

Keep Doctor and regular cron writes on one SQLite save path while preserving existing quarantine, receipt, runtime-state, and delivery behavior.

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

Not applicable: this PR proposes behavior-preserving cleanup, not a reported defect. The contributor reports focused tests and an existing-state upgrade exercise.

Is this the best way to solve the issue?

Yes: reusing the existing SQLite writer and removing forwarding helpers fits the current owner boundaries; the reviewed paths show no distinct replacement implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P3: This is an internal cleanup with no intended user-facing behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State classifies the author as a member, so the external-contributor proof gate does not apply. The changed Doctor writer uses the existing SQLite save owner; the PR body reports a published v2026.9.6 updater and Doctor exercise on legacy jobs with preserved run history, and the cron tree is unchanged at the reviewed head. Quarantine was not seeded in that exercise, but its canonical key, writer, and transaction sequence are unchanged. No stored-data format or schema contract changes.

Evidence

What I checked:

  • Introduced Doctor writer change: The PR calls the existing SQLite save routine after acquiring migration metadata, within the same transaction. (src/cron/store.ts:344, a84b5a6ec2b2)
  • Persistence equivalence: The reused save routine handles quarantine writes and deletions before full row replacement; the store key resolves the path as the old writer did. (src/cron/store/save.kernel.ts:196, a84b5a6ec2b2)
  • Current main comparison: Current main retains the earlier inline Doctor quarantine and row-replacement sequence, so this refactor is not implemented there. (src/cron/store.ts:344, 27de2f87db28)
  • Prior review and upgrade evidence: The previous completed review requested a published-driver upgrade check. The current PR body reports a v2026.9.6-to-candidate Doctor run preserving two legacy jobs and run history; it expressly says the scenario did not seed quarantine entries. The same canonical quarantine writer and key remain in use, and existing store tests cover quarantine rollback. (a84b5a6ec2b2)
  • Proof revision continuity: The cron tree is identical between the reported upgrade-test revision and the reviewed head, which merges main. (src/cron, a84b5a6ec2b2)
  • Related merged repair: The named-session workspace checks came from the merged fix(cron): named-session jobs run in the wrong workspace #159444 and remain in this checkout; that repair addresses workspace selection rather than this cleanup. (src/cron/isolated-agent/run-workspace.ts:164, 300ef3991158)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Raw commit 300ef39 adds src/cron/isolated-agent/run-workspace.ts:164 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 300ef3991158; files: src/cron/isolated-agent/run-workspace.ts)
  • Ayaan Zaidi: 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-28T23:34:10.711Z sha a16d4a3 :: blocked before merge. :: none
  • reviewed 2026-09-29T00:00:27.914Z sha 89ff686 :: blocked before merge. :: none

The pass removed 17 grandfathered assertions across seven cron files.
The helper's key parameter now types both the source and target, satisfying no-unnecessary-type-parameters without restoring a cast.
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 29, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 29, 2026
@steipete
steipete merged commit 63b38c7 into main Sep 29, 2026
212 of 214 checks passed
@steipete
steipete deleted the steipete/cron-deslop branch September 29, 2026 00:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#160788)

* refactor(cron): deslop cron service

Simplify helper indirection, repeated branches, and unused parameters.
Reuse existing types and constants; trim redundant comments.

* refactor(cron): deslop cron core and store

Consolidate normalization branches, schema types, and delivery coercion.
Reuse store persistence and stream helpers; remove redundant wrappers.

* refactor(cron): deslop isolated cron agent

Inline one-use helpers, consolidate delivery branches, and infer duplicate types.
Remove redundant casts and comments while preserving named-session workspace
resolution, admission, worktree leases, and persistent session restrictions.

* refactor(cron): keep cap authority reconciliation steps named

The policy stamp, capture provenance, and exec pin reconciliation stay separate documented helpers; folding them into one nested function saved a few lines at the cost of reviewability in security-relevant code.

* refactor(cron): drop exports orphaned by the deslop pass

* chore(cron): shrink assertion-safety baseline for the deslop pass

The pass removed 17 grandfathered assertions across seven cron files.

* fix(cron): type copied session fields by their key set

The helper's key parameter now types both the source and target, satisfying no-unnecessary-type-parameters without restoring a cast.

* Merge remote-tracking branch 'origin/main' into steipete/cron-deslop

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

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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