Skip to content

fix(cron): finalize retained one-shot jobs on PostgreSQL - #181802

Merged
steipete merged 1 commit into
mainfrom
pgprep/pglive4-cron
Oct 23, 2026
Merged

steipete merged 1 commit into
mainfrom
pgprep/pglive4-cron

Conversation

@steipete

@steipete steipete commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes retained one-shot cron jobs remaining marked as running on PostgreSQL after the model finishes successfully.

User Impact

Scheduled one-shot jobs with deleteAfterRun: false now publish their terminal result and become disabled, while their authored configuration stays intact.

Why This Change Was Made

The enablement transition called SQLite's json_set directly. Reuse the existing engine-aware JSON mutation helper so PostgreSQL uses jsonb_set and both engines retain JSON booleans. This changes no schema, locking, transaction, or public configuration contract. Production delta: +5/-2; the regression adds 148 lines to cover durable finalization and reenabling on both engines.

Evidence

A real Gateway with a real model reproduced PostgreSQL error 42883 after successful model execution. The regression fails on unchanged main for that same reason while SQLite passes; it passes on both engines with this fix. Twelve existing cron tests also pass, as do the core and infra-test type checks. Independent Codex P0–P2 autoreview is clean.

On final head 14193c8663ce803eaa5a478624be6c90b8131a6f, real-model scheduled execution passes on both PostgreSQL and SQLite: terminal history is published, the retained job is disabled, history is readable, and removal succeeds. All three PostgreSQL conformance shards and the full required CI passed in run 39998434582. The additional local Homebrew PostgreSQL 17 conformance run also passed all three shards on the same head: 1,130 tests passed, 39 source-declared skips, and zero failures; pgvector, pg_trgm, and unaccent cases executed.

Use the engine-owned JSON mutation when cron completion disables a retained one-shot. Preserve boolean enablement and authored config while atomically publishing terminal history.
@clawsweeper

clawsweeper Bot commented Oct 23, 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 marked this pull request as ready for review October 23, 2026 17:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T17:53:22.105526Z 14193c8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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. 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 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR uses engine-aware JSON mutation when cron runtime updates enable or disable a job.

Example: A PostgreSQL-backed one-shot job named one-shot finishes successfully with deleteAfterRun: false.

  • Before: Finalization calls SQLite json_set, fails with PostgreSQL error 42883, and leaves the job marked as running.
  • After: Finalization records the successful result and stores enabled: false while retaining the job's authored configuration.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is correct on inspection and has meaningful cross-engine regression coverage; the supplied after-fix evidence remains at the in-process boundary.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence reports a real-Gateway failure and passing owner-level regressions, while final-head live scheduled execution remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A successfully executed retained one-shot remains marked as running because PostgreSQL rejects its finalization statement.
Reason: The maintainer-authored repair restores existing behavior through the established engine abstraction without adding settings or changing product policy.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete PostgreSQL failure still present on current main, preserves the existing cron storage contract, and introduces no actionable correctness findings.

Priority: P2
Reviewed head: 14193c8663ce803eaa5a478624be6c90b8131a6f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Final-head scheduled execution through a real PostgreSQL-backed Gateway is described as pending, with no after-fix runtime trace supplied.
Agent review details

How this fits together

Cron execution outcomes enter the existing transactional finalization worker, which updates job runtime state and run history through the shared row codec and database-engine SQL helpers.

flowchart TD
A[Cron execution outcome] --> B[Finalization worker]
B --> C[Runtime row mutation]
C --> D[Cron row codec]
D --> E[Engine JSON helper]
E --> F[SQLite or PostgreSQL]
B --> G[Run history]
Loading

Technical review

Best possible solution:

Retain the focused helper substitution and its cross-engine finalization regression.

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

Current-main source directly exposes the SQLite-only call during retained one-shot finalization, matching the reported PostgreSQL 42883 failure; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch is the smallest complete repair: reuse the existing dialect owner while preserving the transaction, enablement policy, and authored fields.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6cc605dfe204.

Provenance checked

  • Runtime enablement mutation keeps the original intent (d89da75: Preserve authored cron definitions during runtime changes and leave legacy normalization to backed-up Doctor repairs.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +3, Tests +148. Total +151 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 1 148 0 +148
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 153 2 +151

Labels

Label changes:

  • add P2: Retained one-shot jobs on PostgreSQL cannot durably finalize after execution; the failure is concrete and limited to the affected backend and runtime transition.
  • 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: Retained one-shot jobs on PostgreSQL cannot durably finalize after execution; the failure is concrete and limited to the affected backend and runtime transition.
  • 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.

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 23, 2026, 2:06 PM ET / 18:06 UTC.

@steipete
steipete merged commit e96c704 into main Oct 23, 2026
217 of 220 checks passed
@steipete
steipete deleted the pgprep/pglive4-cron branch October 23, 2026 18:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…1802)

Use the engine-owned JSON mutation when cron completion disables a retained one-shot. Preserve boolean enablement and authored config while atomically publishing terminal history.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Use the engine-owned JSON mutation when cron completion disables a retained one-shot. Preserve boolean enablement and authored config while atomically publishing terminal history.

Beta.5 adaptation: Apply the source behavior to the c11c9d3 baseline; preserve baseline-native producer/consumer seams and include focused regression and registration adaptations for this group. See expanded-implementation-0/receipts.json for closure and qualification.

(cherry picked from commit e96c704)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 820bb0a3d96397d6d71fec318137bd335939bb24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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