Skip to content

fix(cron): keep one-shot finalization working on PostgreSQL 16 - #194384

Merged
vincentkoc merged 4 commits into
mainfrom
audit/postgres-store-conformance-20261107
Nov 7, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
audit/postgres-store-conformance-20261107

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes cron job finalization and enable/disable transitions failing on PostgreSQL 16 with function json(unknown) does not exist. Also repairs the existing PostgreSQL 18 cache conformance assertion for fractional EXPLAIN row counts.

User Impact

Retained one-shot jobs can finish, and cron jobs can change enabled state, while preserving authored configuration and unrelated JSON fields. No migration or operator action is required. Cache eviction behavior is unchanged.

Why This Change Was Made

The cron row writer passed bound JSON text through SQLite's json(...) syntax on every engine. The database expression owner now parses serialized JSON with an explicit PostgreSQL cast and retains SQLite's JSON subtype behavior. The JSON path mutation helper stays unchanged, preserving scalar extraction behavior in session callers.

The all-major baseline also exposed a test-only PG18 failure: the correct timestamp-index scan reports rows=11.00 instead of rows=11. Accept zero fractional digits while retaining exactly eleven rows, one loop, the canonical index and no sequential scan. The loop boundary now also rejects loops=10. PostgreSQL documents the fractional EXPLAIN output change.

Correct the PostgreSQL guide's existing CI cadence and the index checker's stale runtime-admission comment.

No SQLite schema version, DDL, migration, persisted format, public API, SDK, config/default, protocol, durability, recovery, or retention-policy changes.

Production delta: +14 lines, justified by the internal engine-owned JSON conversion boundary; net test growth: zero (one existing assertion changed); prose/comments: +4/-3. Replaces the cron writer's unconditional SQLite function expression; adds no fallback or parallel storage path. The existing store-level regression catches the runtime defect; no duplicate helper tests are added.

Evidence

  • Completed baseline Linux PG16/17/18 matrix at efb980423985b290f5c294ba7b13ad4c2bd074d8: seven of nine jobs passed. PG16: 1,511 passed, 1 failed, 40 skipped; its sole failure is the repaired cron regression. PG17: all three jobs passed, 1,512 tests passed, 40 skipped. PG18: 1,511 passed, 1 failed, 40 skipped; its sole failure is the repaired EXPLAIN assertion. Counts mix actual PostgreSQL, SQLite sibling and unit/mock cases; the baseline remains failed.
  • Repaired runtime source: existing cron-runtime-row.postgres.test.ts passed on PostgreSQL 16, 17 and 18, including its SQLite sibling each time: 2/2 tests per major. Covers retained one-shot finalization, true/false enablement, current scratch snapshots, queue reconciliation and opaque authored fields. Runtime file hashes remain unchanged in the final head.
  • Repaired manager-embedding-cache.postgres.test.ts: all six tests passed on each of PG16/17/18. End-to-end runner wall time: 28.18s / 28.10s / 32.08s respectively; most time is worker compilation, actual cache test cases below one second per major. Retains bounded canonical-index eviction, composite identities, batching, rollback and preferred eviction coverage.
  • Original json-values.test.ts: 3/3 passed, 1.61s runner wall; byte-for-byte unchanged from baseline. Retains scalar/opaque preservation, ordered projections and nested-array aggregation.
  • Each major's schema conformance preflight passed: shared-state and agent catalogs, indexes, constraints, existing task-index migration and trigger parity; zero unexplained differences.
  • Focused proof used Node 26.12.1 on macOS with isolated Docker PostgreSQL services and CI's digest-pinned images. Frozen dependency inputs and exact source hashes were verified. PG17 used its cached amd64 image under emulation. Testbox allocation queued and was stopped; no remote payload result is claimed. This is focused repaired-source proof, not a passing full Linux all-major matrix or shipped Gateway/model end-to-end proof.
  • Fresh final local autoreview against efb9804, P0-P2: complete, no actionable findings. Independent owner/dependency/sibling, test-value and PG18 planner-contract reviews also completed. Kysely 0.29.7 emits named functions verbatim; the PG16 repair belongs in the engine expression owner.
  • Pinned formatter, pnpm docs:list, git diff --check and the zero-growth test-line ratchet passed. The single assertion edit preserves test line count; no existing tests, baseline or allocation were removed.
  • Final-head PR CI passed at 98bfbca282cbe41fde4a72e0d91059c3dd65b44b, including all three full PG17 conformance shards. Exact-head build artifacts also passed. The final check rollup has 64 successes, 58 intentional skips, one neutral result and no failures. Earlier failed/cancelled runs remain recorded separately.
  • Final-head ClawSweeper review found no actionable correctness/security issues and no before-merge actions. The missing Gateway-level PG16 proof remains the named follow-up below; review scores do not replace execution evidence.
  • Squash-merged as 7ab0143fc228.

Follow-ups: add a Gateway-level retained one-shot cron smoke on PG16 in PR CI; separately reconcile inherited one-line test-budget accounting debt in its CI owner. Neither changes this repair's schema boundary.

@vincentkoc vincentkoc self-assigned this Nov 7, 2026
@clawsweeper

clawsweeper Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: XS labels Nov 7, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 7, 2026 00:48
@vincentkoc
vincentkoc marked this pull request as draft November 7, 2026 01:04
@vincentkoc vincentkoc changed the title docs: clarify PostgreSQL conformance coverage fix(cron): keep one-shot finalization working on PostgreSQL 16 Nov 7, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 7, 2026 01:15
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review — final head 606d784. Focus on PG16 bound JSON conversion, SQLite JSON subtype preservation, and the unchanged schema boundary. Focused PostgreSQL 16/17/18 cron tests and SQLite JSON tests pass; current proof and limitations are in the PR body.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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 Nov 7, 2026
@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes cron enablement JSON writes portable to PostgreSQL 16, accepts PostgreSQL 18 EXPLAIN formatting, and corrects conformance documentation.

Example: A retained one-shot job named one-shot finishes successfully on PostgreSQL 16 with deleteAfterRun=false.

  • Before: Finalization invokes json(unknown), fails, and cannot commit the disabled job and terminal history.
  • After: Finalization parses the boolean with an explicit JSON cast and commits enabled=false while preserving unrelated authored fields.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and has no actionable findings, but the required shipped-entry-point evidence is missing and exact-head CI is unfinished.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Retained one-shot cron jobs cannot finish their database transition on PostgreSQL 16.
Reason: The maintainer-authored direction restores documented engine support with a narrow internal repair and preserves existing configuration and storage contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current PostgreSQL 16 cron failure through the existing database-expression owner, with no introduced correctness or security findings.

Priority: P2
Reviewed head: 98bfbca282cbe41fde4a72e0d91059c3dd65b44b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A current repaired-source Gateway/model run on PostgreSQL 16 showing retained one-shot completion and persisted disablement is not supplied.
Agent review details

How this fits together

Cron finalization sends runtime state and enablement changes to the transactional row writer, which uses engine-owned JSON expressions to update SQLite or PostgreSQL.

flowchart LR
  A[Cron execution outcome] --> B[Finalization worker]
  B --> C[Runtime row mutation]
  C --> D[Cron row writer]
  D --> E[Engine JSON expressions]
  E --> F[SQLite or PostgreSQL]
Loading

Technical review

Best possible solution:

Keep JSON parsing in the existing engine-expression owner and retain the current transactional cron write and regression coverage.

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

Current-main source exposes the unconditional json(...) call, and the existing database regression reaches it during retained one-shot finalization; no target code was executed during this review.

Is this the best way to solve the issue?

The patch fixes the invalid expression at its existing engine boundary, preserves SQLite JSON subtype handling, and avoids changing shared scalar-extraction semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 638a1851e7e6.

Provenance checked

  • Cron enablement JSON writes keeps the original intent (e96c704: The earlier repair moved JSON mutation to the engine owner to publish terminal history and disable retained jobs atomically; the nested SQLite parser was carried forward.)
  • Engine JSON expressions keeps the original intent (93e8fe3: Shared engine helpers preserve JSON and scalar behavior while making PostgreSQL queries portable; the addition follows that ownership.)
  • Embedding-cache planner assertion keeps the original intent (fdad53b: The assertion protects bounded canonical-index eviction rather than full-table sorting; accepting zero fractional row digits preserves that invariant.)
  • PostgreSQL qualification documentation and index-checker comment keeps the original intent (63b8eec: Documentation distinguishes qualified PostgreSQL majors and evidence scope; the corrected cadence matches the current scheduled workflow.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e96c704 adds src/cron/store/row-codec.ts:660 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e96c7041019b; files: src/cron/store/row-codec.ts)
  • Mitchell Etzel: Raw commit 4928146 adds extensions/memory-core/src/memory/manager-embedding-cache.postgres.test.ts:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 492814665d81; files: extensions/memory-core/src/memory/manager-embedding-cache.postgres.test.ts)

PR surface

Source +14, Tests 0, Docs +1, Other 0. Total +15 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 16 2 +14
Tests 1 1 1 0
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 5 21 6 +15

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P2: The defect breaks cron finalization and runtime enablement transitions on supported PostgreSQL 16 installations.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-07T01:22:51.577Z sha 606d784 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-07T01:34:11.275Z sha e24ebd1 :: needs maintainer review before merge. :: none

Reviewed November 6, 2026, 8:57 PM ET / November 7, 2026, 01:57 UTC (Revision 3).

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review — final head e24ebd1. Runtime files are unchanged from the reviewed/tested patch. Final test-value review restores the original JSON unit file and relies on the existing actual cron regression, already passed on PostgreSQL 16/17/18 and SQLite; net test growth is zero. Final local autoreview is complete with no actionable P0-P2 findings. Updated evidence and remaining limits are in the PR body.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 7, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Nov 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added the extensions: memory-core Extension: memory-core label Nov 7, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review — final head 98bfbca. The completed baseline found only two failures: the repaired PG16 cron JSON expression and PG18 fractional EXPLAIN row formatting. The latter is now a one-line test-only repair retaining exact rows, loops, canonical-index and no-full-scan checks. Existing cache suite passed 6/6 on each PG16/17/18; cron passed 2/2 per major including SQLite. Fresh final local autoreview is complete with no actionable P0-P2 findings. Runtime files and schema embargo are unchanged; updated proof and limits are in the PR body.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 Nov 7, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 7, 2026 02:00
@vincentkoc
vincentkoc merged commit 7ab0143 into main Nov 7, 2026
151 checks passed
@vincentkoc
vincentkoc deleted the audit/postgres-store-conformance-20261107 branch November 7, 2026 02:19
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 7, 2026
…law#194384)

* docs: clarify PostgreSQL conformance coverage

* fix(cron): keep one-shot finalization working on PostgreSQL 16

* test(database): reuse cron conformance for JSON conversion regression

* test(postgres): accept fractional explain row counts
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…law#194384)

* docs: clarify PostgreSQL conformance coverage

* fix(cron): keep one-shot finalization working on PostgreSQL 16

* test(database): reuse cron conformance for JSON conversion regression

* test(postgres): accept fractional explain row counts

(cherry picked from commit 7ab0143)

Release adaptation: Only engine-owned jsonValue and retained cron enabled JSON replacement; preserve native boolean type with PG16 explicit ::json and SQLite json(). Omit unrelated PG docs/EXPLAIN test edits; retained one-shot enabled-transition caller present on baseline.

Follow-up dispositions: e029e18 docs: document isolated PostgreSQL restore drills (openclaw#202704); 49f0740 fix(database): report disabled memory after a port (openclaw#202630); a80b564 fix: keep database workers healthy after silent connection loss (openclaw#201856); 3d91af2 fix(config): reject reserved PostgreSQL schema prefixes (openclaw#202097); 835d722 fix: catch incompatible ownership before porting to SQLite (openclaw#202101); 67796a6 fix: keep scheduled Git backups current on PostgreSQL (openclaw#201870); cc849dd fix: recover lease heartbeats after a PostgreSQL connection loss (openclaw#201858); 6594caf fix: prepare macOS runtime pins without the PostgreSQL secret (openclaw#202102); 6ca56cd docs: clarify PostgreSQL storage and backup coverage (openclaw#202086); a079190 fix(postgres): chat history slows under concurrent reads (openclaw#190129); 2ff4256 feat(database): keep PostgreSQL rollback captures in PostgreSQL (openclaw#196236); 96c685b feat(backup): restore PostgreSQL stores into a staging database for restore drills (openclaw#194808); fb83d65 fix: reduce transcript allocation when preparing native context seeds; 71ec4d2 fix(config): keep Workboard PostgreSQL upgrades readable (openclaw#194648); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682)

Validation: Baseline cron generated json(bound text) on PostgreSQL where json(text) is unavailable; helper and focused boolean regression retained. Exact PostgreSQL16 server proof unavailable; focused SQLite/helper tests queued. diff check passed.

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

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XS 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