Skip to content

refactor(cron): hold message authority for remaining transports and delete the native checker (cron 2b/3) - #165129

Merged
steipete merged 27 commits into
mainfrom
dbasync/cron2b
Oct 5, 2026
Merged

steipete merged 27 commits into
mainfrom
dbasync/cron2b

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Remaining bundled message transports could pass a synchronous cron check, await preparation or a queue, and call their provider outside held authority. The native current-job reader also kept receipt SQL on the Gateway thread. Chunked sends could lose evidence of earlier accepted messages when a later chunk failed or was refused, inviting duplicate delivery on retry.

User Impact

Scheduled message operations retain authority through their SDK, CLI, or native handoff. Twitch and IRC raw batches are admitted before their first send. Transports with required application waits keep live checks per request, and later refusals, transport errors, or delivery-observer failures preserve accepted receipts as partial delivery. The dedicated Zalouser tool exposes that outcome too.

Schemas, stored bytes, retention, durability, force-disabled eligibility, execution revisions, and released synchronous callback signatures are preserved. No migration or new configuration is required. The effect-scope helper is additive. This adds zero OPENCLAW_* names. Cron writes use the serving Gateway; direct concurrent SQLite mutation is outside the supported contract.

Required current-head behavior proof is complete, and GitHub CI is green. Native exact-head review and merge admission remain authoritative.

Why This Change Was Made

Complete the cron 2a held-use cutover across remaining transports. Capture the originating scope before queues, prepare authority after application preparation, invoke the SDK/CLI/native operation synchronously inside the held use, and release before awaiting its response. Twitch and IRC precompute their synchronous batch and admit it once; acquiring multiple retained uses upfront would deadlock the owner's FIFO. Required application waits and retries retain fresh per-request checks.

Delete createServiceCronRunMessageAuthorityChecker and readCronRunReceiptCurrentJob. Synchronous guards consume the receipt owner's published facts; preparation stays with the shared-state worker and physical-store/FIFO owner. Main's standing-grant authority binding is preserved. Refusals keep their original cause and no-dispatch metadata and stay outside provider retry paths. Matrix retains its required AbortError adapter because its SDK converts other fetch errors into retryable connection failures.

The initiation boundary remains the provider SDK/CLI handoff. The table in docs/plugins/sdk-channel-plugins.md records remaining library windows, including Baileys processing, iMessage's spawn broker/bridge, Twurple's limiter, relay connection promises, and Teams token/Axios work. No dependency patches are introduced by this PR.

Published head: 4741f40d6f47252ffda483a957679c50f6995f8e. Main integration: 5721d8eb0e6cae9b0818675be2b583acd8b81f91, merged without rebasing. Related overlap: #164906, #162433, and #135889. This does not adopt #112375 or expand Gateway skill-trust policy.

Production: +703 / −321 / net +382, 1,024 changed lines, within the 1,300-line limit. The 74-file diff contains 38 production files, 31 test files, two docs, and three tooling/baseline files. Mock and assertion baselines remove obsolete allowances; no exception was added.

Retained SQL contracts

At the original lane baseline, T1 decreased 895 → 893, with 2,540 inventoried SQL expressions. The host caller is deleted; two shared kernels remain necessary. readActiveCronRunReceiptsInDatabase remains worker-only for current receipt/recovery, admission, and maintenance. loadCronRows remains in worker kernels and Doctor legacy-repair, store-repair, and heartbeat-migration one-shots. Their classifications change from T1 to W/T3 with caller evidence; this is not a claim that the SQL expressions were physically deleted.

No other-owner host SQL was found inside the grant/checker path touched here: availability consumes worker-provided deletion facts and remaining local guards are in memory. Broader unchanged callbacks are not claimed SQL-free. The unrelated standing-grant generation read stays with its owning lane.

Evidence

Focused commands use node scripts/run-vitest.mjs <files> --maxWorkers=1, the repository entrypoint equivalent to pnpm test <files> --maxWorkers=1. Wall times include compiler/import preparation. The final-head CI run took 469 s wall time; its successful jobs total 9,740 s (the sum includes checks and builds, not only tests).

Proof Result
Current transport fixes and siblings 315 tests / 15 files passed, 728.08 s. After CI fixture repairs, IRC client 22 passed, 46.70 s, and Teams outbound 26 passed, 131.13 s. Includes Twitch client/send/outbound, IRC client/send, Synology client/loopback, Zalouser send/tool/handoff, LINE payload/handoff, Teams outbound/handoff, and WhatsApp socket timing.
Main-conflict integration 66 tests / 5 files passed, 249.45 s: receipt currentness/store/authority, runtime publication, and the real Gateway reservation boundary. Core integration bytes are unchanged by the transport fixes.
Regression negative controls The new admission and partial-delivery regressions fail on the original Twitch, IRC, Synology, Zalouser, LINE, and Teams implementations. Initial no-send refusals remain unchanged. Fixture-constructor mistakes were corrected and independently rerun; they are not product-failure evidence.
Fresh Codex autoreview through P2 Scoped-clean for the complete candidate with full Matrix adapter/test context and the inspected [email protected] error contract. Original refusal identity remains in the cause chain while AbortError prevents SDK retries. A fresh final-delta P2 review after the IRC/Teams CI fixes is also clean.
Released SDK surface audit Compared v2026.9.8 SDK exports, runtime surfaces, and bundled public barrels. Removed current-job reader and IRC client send method are internal; withEffectAuthority is additive. No released signature change requires a compatibility record. The generated final-head report is checked: 128 reachable export changes, zero direct declaration or kind changes, zero entrypoint additions/removals; the sole changed reachable declaration adds withEffectAuthority. Report digest: 108123b7b77d8327e6f6b2f660a9c1e72fc5c85d511750a4af15bcfab31f3490.
Worker-cutover routing audit No missing host-owner route found. Cron/Gateway and behavior-reaching indirect command/CLI consumers already use owning fork projects; other database consumers are explicitly routed. No test-routing exception added.
Full changed check Passed on 4741f40d6f47252ffda483a957679c50f6995f8e in isolated Linux arm64 / Node 24.21.0 against base 5721d8eb0e6cae9b0818675be2b583acd8b81f91. All selected guards, core/extension types, lint, dead-export scans and import-cycle checks completed; no skips or exceptions.
Final-head GitHub CI Passed, run 37252013244, exact head 4741f40d6f47252ffda483a957679c50f6995f8e; 89 jobs, no failures, CI gate succeeded.
Canonical build/package Passed on the final head. Full build: 1,022.2 s; package tarball integrity/import graph passed. Tarball SHA-256: e0f87934d33ca10697459d69b66c4b1c395a211f62917aaf894fd80adecf0b57. The build reported a non-fatal UI startup gzip warning (365.1 KiB vs 364.7 KiB); UI and build/dependency inputs are unchanged in this PR.
Cross-process case 7 10 cases passed in 72.276 s on the exact final candidate. Both Gateway lifetimes reached /startupz and /readyz; real owner authority admitted six loopback HTTP calls, while stale captured authority and the original occurrence after restart produced zero calls. Pending mutations did not acknowledge/replay across the crash; the successor receipt admitted real I/O.
Published-driver update/restart Passed on native Linux using published 2026.9.8 and exact candidate 4741f40d6f47252ffda483a957679c50f6995f8e: updater exit 0, durable finished/succeeded, managed PID replacement, exact build identity, health and /readyz=200, durable history retained, incognito history absent. Whole cell: 450.847 s; update command: 371.630 s. Native tarball SHA-256: cab67c3f40f3a7e57651032954342344d95af3c3757abc6159123dc3ed4ff1b7. Diagnostic copies added only update-process Node report options; every original assertion and the 1,125 s cell deadline stayed unchanged. No signals were sent and no Node reports were produced.

The earlier receipt-owner proofs cover publication-before-reply, commit-admission suspension, custody/ABA/store partitions, worker loss, exact occurrence identity, message/source separation, force-disabled behavior, direct/RPC preparation, retry/chunk boundaries, and real server close settlement. The separate killed-Gateway independent-client case now has current-head native I/O proof, described below.

ClawSweeper's stale synthetic Signal fixture qualification was repaired in openclaw/clawsweeper#1747, merged as 6e783d80e5177979744dbc72dd1f6a32c7f134d7. Only the exact table-row witness was added; scanning remains enabled. Native controls reject changed bytes and a foreign path, and the complete original PR source range passes scanning. ClawSweeper completed review of this exact head at 2026-10-05T01:41:24.773Z with no actionable code findings; it requested the runtime evidence now being completed.

Existing follow-up: Zalouser credential persistence can fail after transport acceptance but before returning the current receipt (extensions/zalouser/src/zalo-js.ts); this separate lifecycle path is unchanged. The repaired chunk owner preserves all receipts it has received.

CI repair history: runs 37242475529 and 37245129202 found PR-caused IRC test shadowing/unbound-method/type issues, a shrink-only assertion-baseline mismatch, and a Teams map-spread lint violation. The final candidate corrects those owners. The IRC regression binds the native socket write after connection because Node reconnect setup resets that method. No CI rerun or admin exception was used to hide these failures.

Cross-process authority proof and fixture qualifications

Candidate: 4741f40
Case 7 passed: 10 cases in 72.276s on Linux with a synthetic local provider.
Both Gateway lifetimes reached startup completion and readiness before execution.
Job, grant, parent-decision and secondary-partition mutations did not acknowledge while an earlier real authority use held the interval.
Native HTTP: 6 allowed loopback collector receipts; stale captured authority after disable/re-enable produced zero additional requests.
Crash/restart: pending routed mutation lost its connection without acknowledgment or replay; persisted target stayed unchanged; a new actual receipt and owner admitted native HTTP.
Old occurrence in the new Gateway: production authority capture refused at prepare-use; receiptCurrent=false, nativeInitiated=false, collector delta=0.
Cleanup: 9 spawned child processes and 13 recorded descendants verified non-running; detached broker retirement was observed. Final Gateway shutdown exited 0.
Boundary: stock mutation RPCs and real worker/authority owners; the stale-carrier check uses a synthetic probe around the production capture entry, not the public message RPC signing envelope.
Prior attempts: corrected fixture config and approval-policy drift; an early pre-startup run was durably recorded as a failed agent-admission attempt (14ms). Its event-stream visibility remains unqualified. No product fix or baseline runtime equivalence is claimed.

Published-driver qualification: the initial virtualized Linux arm64 cell recorded successful activation and a healthy candidate, but timed out while the released updater remained alive 193 s after its terminal JSON. The released first hop retains older worker/runtime settlement paths; the candidate cannot replace that already-running code. The same assertions completed on native Linux, including command exit and post-update history checks. No product fix or exact blocking-resource diagnosis is claimed for the first host’s timeout.

published driver: 2026.9.8
candidate: 4741f40d6f47252ffda483a957679c50f6995f8e
update: exit=0; durable run=finished/succeeded
managed service: PID replaced; exact candidate build; readyz=200
durable history: same session and synthetic content retained
incognito history: empty after restart; no retained content artifacts
service cleanup: exit=0; diagnostic observer joined

Bind prepared effects to exact receipt facts and the existing Gateway-owned
FIFO. Keep repeatable assertions separate from one-shot native initiation,
and release exclusion before awaiting the provider response.

Allow a use to borrow its own gate for consumption while preserving native
publication and settlement. Closing retires unused effects and joins accepted
borrowed persistence independently of scheduler cancellation.

This additive interface supports the message and standing-grant cutovers;
it does not activate either consumer or change schema, retention, or policy.
Recheck standing-grant expiry after receipt publication and retain the
caller's live approval scope while persistence settles independently.
Permit only guarded consumption of an already-recorded handoff during close.

Align fixtures with async database custody and the single Gateway writer,
preserve admission identity during receipt-loss injection, and keep generic
detached-exec tests from cold-loading an unrelated channel runtime.

Receipt semantics, eligibility, schema, ledger, retention, and released SDK
signatures remain unchanged. Final-head published-driver update proof is
still a merge precondition for #164805.
Merge main to resolve the Gateway close-prelude conflict while retaining
cron receipt admission sealing before scheduler cancellation and main's
model-account shutdown fence and settlement join.

Focused real-close proof: cron receipt publication/finalization and an
accepted personal model-account write both pass (2 tests, 521.35s wrapper
wall on the loaded local host). Receipt semantics, eligibility, and storage
schemas are unchanged.
Wait for the saved dashboard row publication before deliberately closing its database for the durability probe. Retain every close/reopen and live-authority assertion. Full owner file: 34 passed, 241.25s wrapper wall; fresh P2 review clean.
Merge main through 8cabfb2, including the
three read-admission fixture fixes proved while investigating this PR's CI.
The merge is conflict-free; only worker-access documentation overlaps the
cron-specific delta, preserving both sections. The cron receipt-authority
delta and package manifests remain unchanged by this integration.

The main repair reproduced all three failures five times each, then passed
89 tests, scoped checks, and P2 review. The earlier close-prelude resolution
passed both real-close regressions, and the dashboard drain passed its full
34-case owner file. Final-head package/update and standing-grant proof remain
required before merge.
…4906)

Keep unguarded Discord fetch callbacks on their existing two-argument path.
Cancel Telegram's deferred request through its AbortSignal when authority
refuses initiation, so unread uploads are cleaned up and the original
local-authority error survives retries without being wrapped twice.

The real HTTP regression fails before the repair on unread upload cleanup
and refusal identity. Focused Discord/Telegram proof passes 108 tests;
the suppression inventory passes 4 tests. Extension production/test types,
targeted lint, formatting and the raw-channel-fetch guard pass.
Complete the bundled message transport cutover and remove the native current-job checker. Preserve exact receipt authority, release at SDK or CLI initiation, and retain refusal identity. Shared SQL kernels remain worker or Doctor owned.
Keep the Nostr handoff fixture generic without a cast and document the WhatsApp SDK initiation window.
@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost labels Oct 4, 2026
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review head 4741f40d6f47252ffda483a957679c50f6995f8e. The obsolete native-checker documentation is corrected. The IRC fixture and Teams lint/type failures are fixed; the full Linux changed check and final-head SDK report pass, and fresh P2 autoreview is clean. Published-driver update/restart and cross-process case 7 proof are still running before landing.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 5, 2026
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

All requested behavior proof is complete for 4741f40d6f47252ffda483a957679c50f6995f8e. The body now includes case 7’s ten passing real-Gateway/client cases, zero stale native I/O after restart, and the passing published 2026.9.8 updater cell with normal exit, PID replacement, exact candidate build, readiness, and durable/incognito history checks. The full changed check, SDK report, package integrity checks, P2 autoreview, and exact-head GitHub CI also pass. Earlier fixture errors and the first host’s post-result timeout remain qualified in the evidence.

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Oct 5, 2026
@steipete
steipete merged commit 22bdff6 into main Oct 5, 2026
185 of 187 checks passed
@steipete
steipete deleted the dbasync/cron2b branch October 5, 2026 03:49
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…elete the native checker (cron 2b/3) (openclaw#165129)

* refactor(cron): publish receipt authority from the Gateway owner

* fix(cron): preserve SDK admission factory contracts

* fix(cron): settle receipt authority before releasing close custody

* refactor(cron): add held receipt authority uses

Bind prepared effects to exact receipt facts and the existing Gateway-owned
FIFO. Keep repeatable assertions separate from one-shot native initiation,
and release exclusion before awaiting the provider response.

Allow a use to borrow its own gate for consumption while preserving native
publication and settlement. Closing retires unused effects and joins accepted
borrowed persistence independently of scheduler cancellation.

This additive interface supports the message and standing-grant cutovers;
it does not activate either consumer or change schema, retention, or policy.

* fix(cron): retain approval authority through publication

Recheck standing-grant expiry after receipt publication and retain the
caller's live approval scope while persistence settles independently.
Permit only guarded consumption of an already-recorded handoff during close.

Align fixtures with async database custody and the single Gateway writer,
preserve admission identity during receipt-loss injection, and keep generic
detached-exec tests from cold-loading an unrelated channel runtime.

Receipt semantics, eligibility, schema, ledger, retention, and released SDK
signatures remain unchanged. Final-head published-driver update proof is
still a merge precondition for openclaw#164805.

* test(sessions): drain publication before durability close

Wait for the saved dashboard row publication before deliberately closing its database for the durability probe. Retain every close/reopen and live-authority assertion. Full owner file: 34 passed, 241.25s wrapper wall; fresh P2 review clean.

* refactor(cron): hold message authority through core transport initiation

* refactor(cron): define held-use refusal in a shared error leaf

* style(cron): disambiguate authority callback bindings

* fix(cron): preserve transport refusal and cancellation semantics (openclaw#164906)

Keep unguarded Discord fetch callbacks on their existing two-argument path.
Cancel Telegram's deferred request through its AbortSignal when authority
refuses initiation, so unread uploads are cleaned up and the original
local-authority error survives retries without being wrapped twice.

The real HTTP regression fails before the repair on unread upload cleanup
and refusal identity. Focused Discord/Telegram proof passes 108 tests;
the suppression inventory passes 4 tests. Extension production/test types,
targeted lint, formatting and the raw-channel-fetch guard pass.

* refactor(cron): hold authority across remaining transport handoffs

Complete the bundled message transport cutover and remove the native current-job checker. Preserve exact receipt authority, release at SDK or CLI initiation, and retain refusal identity. Shared SQL kernels remain worker or Doctor owned.

* test(cron): preserve generic authority fixtures

Keep the Nostr handoff fixture generic without a cast and document the WhatsApp SDK initiation window.

* test(cron): normalize transport authority regression fixtures

* test(clickclack): isolate authority handoff regressions

* test(nostr): observe the production relay handoff

* test(cron): keep Synology handoff cases lint-clean

* docs(cron): remove superseded native-checker migration note

* fix(cron): clear receipt cutover lint and documentation gates

Bind the loopback socket writer's call to the original method, retaining the
socket receiver, and remove shadowed bindings. Regenerate the assertion
baseline after the LINE cleanup removes one assertion. Remove the remaining
obsolete statement that final message SQL guards await migration.

The IRC owner tests pass (41 tests, 69.26 seconds overall), and the bounded
P2 review is clean. The assertion baseline shrinks by exactly one. Local
type-aware lint stopped at declaration preparation's 300-second timeout;
the Linux full changed check remains required before merge.

* test(cron): bind native write faults after socket connection

Scope the IRC fault to the real client socket, install it after Node's connect
restores write, and preserve the method's boolean return type. Synchronize
and restore Node's connection-factory exports around the fixture. Use the
canonical Teams channel-result helper when aggregating earlier receipts.

Validation: all 22 IRC client tests pass (46.70 seconds overall), all 26 Teams
outbound tests pass (131.13 seconds overall), and the bounded P2 review is
clean. The full Linux changed check remains required before publication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: buzz channel: feishu Channel integration: feishu channel: imessage Channel integration: imessage channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: qa-channel Channel integration: qa-channel channel: reef Channel integration: reef channel: signal Channel integration: signal channel: sms Channel integration: sms channel: synology-chat channel: twitch Channel integration: twitch channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser docs Improvements or additions to documentation extensions: clickclack gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts 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