Skip to content

fix: reuse admitted worker transcript and cron stores - #190861

Merged
roboclaw-bot merged 1 commit into
mainfrom
fix/native-worker-cron-admitted-sources
Nov 2, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
fix/native-worker-cron-admitted-sources

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes worker turns failing at the PostgreSQL thread boundary and Cron session runs reading scratch from a different partition than the scheduler that admitted them.

User Impact

Worker launch and scheduled session execution retain their admitted transcript and Cron sources. There are no schema migrations, configuration changes, permission changes, or required operator actions.

Why This Change Was Made

Reuse the transcript source already held by the history worker instead of reopening the native database on the Gateway thread. Thread the admitting Cron service’s selected store path into session execution; direct callers still resolve their configured store, and explicitly prepared scratch retains precedence. Existing source-custody checks, revocation, and release behavior remain in place. This removes seven net production lines rather than adding another owner.

Integration adapted from Galin Iliev’s requested fixes; commits credit @galiniliev. This PR is independent of the database portability and scheduled-widget changes.

Evidence

  • Red on the base: the real worker-launcher fixture failed with “PostgreSQL connections must run in a worker” before reaching its launch boundary. The Cron regression selected changed-partition scratch instead of the admitted partition.
  • Green: 65 tests across the worker launcher (34), PostgreSQL thread-boundary regression (1), transcript source lifetime (5), Cron session execution (15), and Gateway Cron dispatch (10). Fresh and follow-up worker admissions both reach the expected worker-launch boundary without Gateway-thread SQL.
  • Core TypeScript plus the Cron, Gateway-server, and Gateway-other test typecheck leaves passed; all nine touched code/routing files passed targeted lint. Formatting and diff whitespace checks passed.
  • Independent canonical autoreview completed scoped-clean for P0–P2 with no actionable findings. Review covered the existing history-worker, session-accessor, launcher, and Cron-store contracts.
  • Exact 95-line regression allocation; no global baseline increase.

Actual PostgreSQL and native Gateway qualification (November 2, 2026)

Two additional product/owner-boundary cases passed on unchanged head cd23fc527a2e9da4bb4f6972c286cebf795e23ef. The existing built Gateway's three native identity files matched this head. The canonical database-conformance runner retained its PostgreSQL preload, pool-root admission, thread restrictions, artifact checks, and cleanup. A fresh synthetic PostgreSQL 17.11 container was loopback-only; no operator database or Gateway was touched.

  • Native worker launcher, actual PostgreSQL: an independent PostgreSQL query confirmed the durable session row. Real fresh and follow-up launcher admissions both reached the existing capacity-refusal boundary without the original PostgreSQL/Gateway-thread exception. This proves the changed transcript-source owner with actual PostgreSQL, not remote-worker execution.
  • Shipped Gateway Cron/model turn, actual PostgreSQL: a separate authenticated child Gateway created a durable session/job through public RPC, persisted a scratch marker, ran the scheduled turn, and emitted a successful finished event. The actual synthetic Responses request contained the persisted scratch; public chat history contained the completion marker; public scratch read retained revision 1. Agent storage was PostgreSQL; shared state remained SQLite.

Sanitized observed output:

PostgreSQL 17.11: launchAdmissions=2; independently verified sessionRows=1
native launcher case: passed 22,898 ms; remoteExecution=false
Gateway head=cd23fc527a2e9da4bb4f6972c286cebf795e23ef
Gateway ready=7964ms; authenticated=8660ms
Cron modelRequests=1; status=ok; transcriptPersisted=true; scratchPersisted=true
Gateway Cron case: passed 14,054 ms; externalModel=synthetic-loopback
Test Files: 2 passed; Tests: 2 passed; Vitest: 255.67s
[test] passed 1 Vitest shard in 264.51s; wrapper exit 0

Command: node scripts/test-database-conformance.mjs --engine postgres --connection <owned-synthetic-loopback-DSN> -- test/e2e/qa-lab/runtime/worker-postgres-owner.e2e.test.ts test/e2e/qa-lab/runtime/cron-postgres-product.e2e.test.ts --maxWorkers=1 --reporter=verbose --silent=false. Used the supported Node/prebuilt-dist route, one serial test worker and bounded native compiler pools; the one required native generation completed in 167.765s. No test timeout, assertion, conformance, cache or authority rule was weakened.

Earlier attempts stopped during missing compiled-worker preparation or host I/O-heavy setup. After reconciling all earlier processes and verifying existing runtime identity, the authorized controlled preparation completed and both actual cases passed. The proof-only Cron fixture explicitly enables its owned scheduler, correcting the generic helper's disabled default. Both fixture typechecks, formatting and diff checks passed; their additional lint attempt previously stopped in prerequisite compilation and is not counted passing. Original committed-source lint/type evidence above remains unchanged.

Limits: the Gateway proof uses the current selected partition and synthetic model transport; it is not an end-to-end partition-switch regression or live external inference. The committed red/green Cron regression independently proves admitted-versus-changed partition selection. No out-of-process writes to a serving Gateway database were used to manufacture drift. The launcher capacity boundary is deliberately not a full remote-worker turn. Owned Gateway/test processes joined, generated workers cleaned up, and PostgreSQL stopped with exact container absence verified. Current-head CI and requested overall-Platinum hosted review remain separate gates.

Reuse retained transcript custody without a Gateway-thread database reopen and keep Cron scratch on the admitting scheduler partition.

Co-authored-by: galiniliev <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 2, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 2, 2026 04:18
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 2, 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. 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 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Reuse the retained transcript worker source and pass the admitting scheduler’s Cron store into session scratch reads.

Example: A scheduled session turn retains an admitted Cron partition after configuration selects a different partition.

  • Before: The prompt can contain “Changed partition scratch” from the newly selected partition.
  • After: The prompt contains “Admitted partition scratch” from the scheduler’s original partition.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, complete repair with credible PostgreSQL and Gateway behavior evidence, focused regressions, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Exact-head supplied output exercises fresh and follow-up native launcher admission with PostgreSQL and completes a scheduled turn through an authenticated shipped Gateway, observing scratch in the model request and persisted completion. Launcher qualification stops at capacity refusal; the Gateway uses the current partition and synthetic model transport, while the committed regression distinguishes admitted from changed partitions.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: PostgreSQL-backed worker turns can fail before launch, and scheduled session prompts can read scratch from a different partition.
Reason: The maintainer-authored direction restores existing source ownership without adding configuration, storage formats, or a competing runtime owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes two source-ownership failures still present on main; no actionable patch defect was found, and the maintainer-authored keep-open guard applies.

Priority: P2
Reviewed head: cd23fc527a2e9da4bb4f6972c286cebf795e23ef

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway worker admission prepares transcript identity before launching a turn; Gateway Cron dispatch prepares scheduled session prompts from the scheduler’s selected scratch store.

flowchart TD
  A[Worker turn admission] --> B[Retained history worker source]
  B --> C[Live placement and transcript checks]
  C --> D[Worker launch]
  E[Cron scheduler selected store] --> F[Session event dispatch]
  F --> G[Scratch read and session prompt]
Loading

Technical review

Best possible solution:

Retain the existing worker-owned transcript custody and scheduler-selected Cron partition through session execution.

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

Current main still reopens the native transcript database and reselects the Cron scratch partition; committed regressions and supplied red/green evidence identify both failures, without a new execution during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete repair using existing owners: remove the unnecessary native reopen and carry the scheduler’s selected store through the existing dispatch call.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native transcript database lifetime changes intended behavior with a stated reason (b8b094b: Retain a worker-admitted native handle for synchronous compatibility guards through settlement; the later worker-read migration established retained worker custody and published predicates.)
  • Retained worker transcript authority keeps the original intent (cbc53ac: Move bundled reads and authority into existing workers while preserving committed facts, cancellation, and final-effect checks.)
  • Scheduled session dispatch keeps the original intent (3d2f7ca: Run conversation jobs through ordinary session admission and retain their source, workspace, delivery, and settlement ownership.)
  • Asynchronous Cron store fallback keeps the original intent (6630db1: Avoid PostgreSQL connections on the Gateway thread while preserving prepared scratch and explicit-path precedence.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source -7, Tests +96, Other +2. Total +91 across 10 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 7 14 -7
Tests 5 118 22 +96
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 10 127 36 +91

Review metrics

Metric Value Why it matters
Production versus regression code Production +7/-14; tests +117/-22; test routing +1 The production change removes a redundant owner path; the net 95 test lines cover thread-boundary admission and selected-partition behavior using existing fixtures.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Focused runtime repair for PostgreSQL-backed worker admission and scheduled-session scratch selection, with limited affected paths.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (1 earlier review cycle)
  • reviewed 2026-11-02T04:34:14.175Z sha cd23fc5 :: needs maintainer review before merge. :: none

Reviewed November 2, 2026, 1:32 AM ET / 06:32 UTC (Revision 2).

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. 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 2, 2026
@roboclaw-bot
roboclaw-bot merged commit b563b4f into main Nov 2, 2026
276 of 278 checks passed
@roboclaw-bot
roboclaw-bot deleted the fix/native-worker-cron-admitted-sources branch November 2, 2026 08:49
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…nclaw#190861)

Reuse the admitted transcript worker context instead of reopening the database on the Gateway thread. Carry the scheduler-selected Cron store into scratch reads while retaining existing custody, authority, and fallback behavior.

Verified red/green boundary regressions, real PostgreSQL launcher admissions, built Gateway Cron/scratch persistence, and required current-head CI.

Co-authored-by: galiniliev <[email protected]>
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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