Skip to content

fix(cron): avoid loading provider runtimes in state workers - #184598

Merged
vincentkoc merged 2 commits into
mainfrom
fix/cron-writer-classification-imports-20261026
Oct 26, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/cron-writer-classification-imports-20261026

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Resolves a problem where cron recovery makes the shared SQLite writer load provider and agent runtime code that it does not need, increasing memory pressure on smaller devices.

User Impact

Cron persistence and startup recovery use the classification already prepared by the execution owner. No configuration, database schema, retry policy, or operator action changes. End-to-end RSS savings are not yet quantified.

Why This Change Was Made

Classify the canonical finished event on the host, before dispatch to the writer. Make the result an explicit worker input, including an authoritative undefined, and use that same fact for job state and run history. Startup recovery reuses the persisted reason.

This removes the worker import path through provider-aware failover classification. It retains the separate permanent-error and aborted-run policies. Production changes are +10 net lines; the extra field establishes the host/worker ownership boundary.

Evidence

  • Red/green boundary regression: restoring the old classifier causes the worker to recompute an explicitly undefined reason as timeout; the candidate preserves the host result.
  • Linux/Bun: 209 tests passed across 17 focused files before a test-only counter correction; all 16 outcome-finalization tests pass on the final head.
  • Production head 7e1b0c6eae371965fcc3f1a1358e721b5f26d341: core, cron test, and Gateway test type-check lanes passed; pnpm build completed.
  • Linux proof run: the command completed; the wrapper then failed GitHub cleanup reconciliation. The allocation was subsequently stopped successfully. This is command proof, not a green hosted CI claim.
  • Hosted CI on that head found one missed PostgreSQL test fixture missing the required errorReason. Commit 081a461db09c0103cec9f173aee8ae13d8556286 adds explicit undefined to its successful outcome; production code is unchanged. Formatting and diff checks pass. Exact-head CI is now green, including the corrected test-type lane and all PostgreSQL conformance shards.
  • Independent review found no actionable production defect.
  • The import path is verified; current packaged-process RSS savings remain unmeasured.

Review follow-up

Exact-head ClawSweeper review found no actionable defect or pre-merge action. Its optional rank-up move asks for a packaged baseline/candidate worker-import or RSS comparison. That measurement is deferred to the continuing RSS campaign: this PR lands the independently verified ownership repair and makes no quantified process-memory or latency claim.

@clawsweeper

clawsweeper Bot commented Oct 26, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review October 26, 2026 12:10
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Oct 26, 2026
@vincentkoc vincentkoc self-assigned this Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR prepares cron error classification on the host and passes it explicitly to persistence and recovery workers.

Example: Cron recovers a failed run with a stored errorReason of undefined.

  • Before: Recovery loads the provider-aware classifier while applying the recorded outcome.
  • After: Recovery consumes the stored classification without that classifier dependency.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with useful boundary coverage; available evidence does not establish the packaged memory benefit.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers production-owner regressions and reported Linux/Bun validation, while packaged memory effects remain unmeasured and linked detailed logs are inaccessible from this reviewer environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Cron persistence and restart recovery unnecessarily pull provider-aware runtime code into shared-state workers, potentially increasing memory pressure on smaller devices.
Reason: The maintainer-authored direction removes unnecessary dependency edges through existing owners, preserves policy, and makes no quantified memory-saving claim.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused ownership repair, and source review found no actionable production defect.

Priority: P2
Reviewed head: 081a461db09c0103cec9f173aee8ae13d8556286

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No inspectable packaged-Gateway comparison demonstrates worker import reduction or RSS savings; the body reports red/green boundary coverage.
Agent review details

How this fits together

The cron host executes jobs and prepares terminal outcomes; the shared-state worker atomically records receipts, job state, and history, then returns committed facts for publication.

flowchart LR
  A[Cron execution host] --> B[Prepare error classification]
  B --> C[Shared state worker]
  C --> D[Job state and receipts]
  C --> E[Run history]
  E --> F[Startup recovery]
  F --> D
Loading

Technical review

Best possible solution:

Keep classification with the host and let the existing worker persist and recover that prepared fact.

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

Source inspection establishes the worker-to-provider-runtime dependency path on current main; no runtime reproduction or RSS measurement was performed during this read-only review.

Is this the best way to solve the issue?

The patch follows the smallest complete repair: prepare classification at the existing host boundary, require its explicit result, and remove worker-side recomputation without introducing another owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2988b14f22e6.

Provenance checked

  • Cron write-side history codec keeps the original intent (bb27303: The codec was separated to keep history readers free of the agents failover and sandbox graph; later worker-owned writes exposed the same dependency on the persistence side.)
  • Worker-owned completion and startup recovery keeps the original intent (64400ff: The worker became the sole terminal-accounting and recovery owner, preserving committed results without replaying uncertain execution or delivery.)
  • Permanent and aborted error policies keeps the original intent (0baf049: Producer classifications prevent permanent local failures from being reclassified as transient provider failures; the patch retains those classifications alongside the prepared reason.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current main: The introduced diff moves classification out of the persistence codec and outcome policy; fetched main still contains both classifier imports, so the central repair remains necessary. (src/cron/run-event-codec.ts:1, 081a461db09c)
  • Explicit host-owned classification: The host classifies the canonical finished-event error before dispatch; worker consumers use the required errorReason field, including authoritative undefined, while retaining permanent and aborted classifications for their separate policies. (src/cron/service/timer-outcome-finalization.ts:88, 081a461db09c)
  • Provider dependency path: run-error-reason imports agents/failover-error, whose classifier reaches provider-patterns, provider-failover, and provider-hook-runtime; removing the worker-facing classifier imports eliminates these concrete edges. (src/cron/run-error-reason.ts:1, 081a461db09c)
  • Recovery and historical intent: Recovery passes the existing stored reason into outcome application; this preserves the worker-owned accounting and no-replay design documented in refactor(cron): finish worker-owned results and recovery #169946. (src/cron/service/startup-run-repair.ts:157, 081a461db09c)
  • Proof and validation limits: The body reports focused regression, build, and type-check results and explicitly leaves packaged RSS savings unmeasured. The linked Testbox run is cancelled and has no artifacts; detailed logs redirect to a blocked storage host. Exact-head production and test type checks passed, while the aggregate CI gate remained pending. (081a461db09c)
  • History and policy inspection: Feature history spans the worker-accounting redesign, earlier timer and codec ownership, and recent restart repairs; an extended pickaxe search reached an unavailable historical blob. Root and Gateway AGENTS.md policies were applied, no maintainer-notes directory exists, and the checkout remains clean. (AGENTS.md, 081a461db09c)

Likely related people:

  • Vincent Koc: Raw commit 393a1ea adds src/cron/service/timer-outcomes.ts:184 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 393a1ea66b4d; files: src/cron/service/timer-outcomes.ts)

PR surface

Source +10, Tests +175. Total +185 across 22 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 25 15 +10
Tests 13 190 15 +175
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 215 30 +185

Review metrics

Metric Value Why it matters
Production versus test/support changes Production +25/-15; tests/support +190/-15 Production growth establishes the explicit host/worker contract; test changes adapt consumers and cover host classification, worker persistence, and restart recovery.

Labels

Label changes:

  • add P2: Removing unnecessary provider-runtime dependencies from cron state workers is a bounded resource-use improvement without demonstrated urgent user impact.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Removing unnecessary provider-runtime dependencies from cron state workers is a bounded resource-use improvement without demonstrated urgent user impact.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Record a baseline/candidate packaged-Gateway worker import or RSS comparison to quantify the resource benefit.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 8:33 AM ET / 12:33 UTC.

@vincentkoc
vincentkoc merged commit 16e4b17 into main Oct 26, 2026
154 checks passed
@vincentkoc
vincentkoc deleted the fix/cron-writer-classification-imports-20261026 branch October 26, 2026 12:48
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…#184598)

* fix(cron): avoid loading provider runtimes in state workers

* test(cron): prepare the database conformance outcome reason
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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