Skip to content

fix(cron): prevent duplicate one-shot delivery after restart - #159873

Merged
joshavant merged 5 commits into
mainfrom
codex/qa-p04-restart-duplicate
Oct 1, 2026
Merged

joshavant merged 5 commits into
mainfrom
codex/qa-p04-restart-duplicate

Conversation

@joshavant

@joshavant joshavant commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Prevents duplicate one-shot cron announcements/webhooks after recipient acceptance, a lost acknowledgment, and Gateway restart. Attempted or ambiguous interrupted deliveries remain disabled with Unknown, including delete-after-run jobs. Proven never-started runs recover.

Why This Change Was Made

The existing SQLite cron receipt owns a monotonic attempt fact committed through the worker before delivery. Recovery replays only the exact not-started receipt. Current-session completion carries cron authority explicitly into the background-result commit guard, preserving ordinary child-session admission.

This refresh rebased once because GitHub reported CONFLICTING / DIRTY at 875c597535f5acb47ffdc4370fbe358e85ed04a5. Frozen base: 3d3a11c401f9817c61531ad0781e7c14c08dd80c; rebased head: 8ddd02e038bee1d2e345fa8186ade5c855a2adff; final head: 65862a058521a48eb2195e341e0a7cf89e434b68.

Conflict provenance, verified against each introducing commit's parent:

  • run-receipts.ts and timer-job-runner.ts: 4a6d9aa0eae0 / #161935 moved current receipt checks to the read worker. Preserve that async owner, retained context, and post-await cancellation/liveness checks; compose the delivery-attempt fence before webhook dispatch.
  • timer.test.ts: 0c0faf026cfa / #161661 intentionally retired the command-routing assertion that the prior branch updated. Preserve the retirement; the final file matches this base exactly.
  • server-cron.ts: fb2052a33fd6 / #161007 moved the adjacent reconciler while this branch extracted completion helpers. Preserve main's subsequent watcher simplification from 3044ac325126 / #162010 and orphan-import removal d5e602f0bcf8; neither local helper is restored.

Separate repair commit 65862a058521 removes the now-async receipt-check fallback from the synchronous webhook final-authority callback. Receipt runs already have the synchronous delivery fence. Main's strict no-send/redirect uncertainty classification remains intact. No later-main drift was incorporated.

User Impact

The approved persistence decision adds state schema 19 → 20, migrating legacy receipts to unknown. Admission before transport can hold an unsent job after a crash; inspect the recipient before retrying. Retention, backup/rollback and older-reader refusal retain their owners. Older backups cannot reconcile later external deliveries. Arbitrary command/file/network effects and heartbeat/system-event handoffs remain outside this guarantee. Agent schema 24 and admission protocol 1 remain unchanged.

Evidence

  • Current focused proof: 216 cases / 12 files, one worker, 189.24 s wall, pass. Includes main's native receipt-snapshot/removal and foreign-commit races, timer cancellation, restart/catch-up, delivery receipts, schema migration, current-session/background transcript authority, Gateway watcher lifecycle and strict webhook outcomes. Both after-acceptance restart cases and all three controls pass. Recipients/process death are simulated; persistence, worker admission and repeated startup are real.
  • Public Gateway flow: all three server.chat-command-context.test.ts cases pass, including explicit non-main sessions.create → chat.send → final event → chat.history plus model-context verification. Gateway, websocket and storage are real; the agent reply is mocked.
  • Current checks: 31 conflict-scoped changed-check stages pass, including production core types, all 27 selected test-type graphs, lint, dead exports, native schema parity, import cycles and owner guards; 2,075.33 s wall. git diff --check passes. The prior unrelated max-lines baseline failure no longer occurs on this base.
  • Fresh ordinary autoreview: complete base-to-candidate review, including the separate repair, reports scoped-clean at P0/P1. Unchanged dependency internals were outside the isolated review bundle; the lead separately inspected the composed receipt/transport owners and ran their boundary tests.
  • Exact-range TruffleHog 3.97.8: base 3d3a11c401f9817c61531ad0781e7c14c08dd80c through head 65862a058521a48eb2195e341e0a7cf89e434b68: 239 chunks / 107,420 bytes, zero verified or unverified findings, credential verification disabled. The initial all-ref clone hit an unrelated missing promisor object; the supported trusted-local scan completed on the same exact range.
  • Independent iOS dead-code report: run 36789475837 completed successfully on exact head 65862a058521a48eb2195e341e0a7cf89e434b68. This terminal pass does not replace the cancelled CI lanes below.
  • Current exact-head CI and automatic ClawSweeper successor: CI run 36789475808 finished cancelled after the PR fail-fast monitor observed an Android test failure: 147 successful, 11 skipped, 12 cancelled jobs, plus the failed Android job and failed aggregate openclaw/ci-gate. security-fast passed. This is not a green CI result; cancelled lanes remain unproven. Automatic ClawSweeper revision 22, run 36791215232, published its review on 65862a058521a48eb2195e341e0a7cf89e434b68 with no code/security findings. That recorded review required a schema-19 upgrade-evidence decision. All three separately authorized attempts are recorded below; attempt 3 now supplies a passing bounded installed-updater survivor cell for automatic exact-head review to reconcile. The Telegram-proof label remains: live recipient/provider proof remains absent, and this conflict-only refresh makes no Telegram-specific or live-delivery claim. No manual ClawSweeper review was requested.

Non-attributable hosted failure and remaining CI limitation: Android test-third-party job 110139046107 ran 3,664 tests and failed only ChatComposerLayoutTest.branchRowsRespectCanonicalOutboxScope: ComposeTimeoutException after 1,000 ms at apps/android/app/src/test/java/ai/openclaw/app/ui/chat/ChatComposerLayoutTest.kt:2736. This PR changes no apps/android files. openclaw/ci-gate is only the downstream cascade of this Android failure. The test report artifact records that sessions.branches.switch and chat.history had returned while switching remained active. This uses NodeRuntimeMode.ScreenshotFixture and does not execute the cron/Gateway TypeScript path. The tested merge 9fa1edc3dda91755d8cea3e1e345c3fe780dfa1b has main parent 6f91eda9c72d6b4c2640cb76b5a753e64089f6f2; its entire Android tree (24ccd43d160b9e755f8a6e174ea146ac126b01f0), CI workflow, actions and Android scripts match that parent. The failed test blob also matches this branch. The timeout's underlying cause remains unresolved; local same-order/standalone reproduction is unavailable because this host has no Java runtime. No Testbox/updater cell, CI rerun, re-push or timeout/assertion change was used to investigate the Android failure. The fail-fast monitor recorded failure-cancelled; seven Node shards and five native/screenshot jobs were cancelled. No failure was attributed to the conflict repair. Current GitHub state at this exact head is open, ready for review and conflict-free (mergeable: true, mergeable_state: blocked); automerge is disabled. The blocked status is retained without changing the branch or claiming cancelled coverage passed.

The previous exact head 875c597535f5acb47ffdc4370fbe358e85ed04a5 passed CI run 36693460647 in 25m41s. Its ClawSweeper revision 20 history found no confirmed introduced code defect and retained the upgrade-evidence decision. These are prior-head evidence, not current-head passes. The prior branch's repaired spawn/heartbeat/requester-yield failures, historical negative control, broader focused cases and prior type checks remain recorded below.

Attempt 1 — scratch-harness failure before product execution (retained): One authorized Testbox lease and one remote proof invocation were used; exit 1, with no retry or second cell. The task-owned remote.sh incorrectly required git rev-parse HEAD to equal the candidate SHA. The maintained receiver intentionally uses carrier commit 749a259fb59d2ee69a09499ba98b30e80028a9c7 as HEAD and separately verified source 65862a058521a48eb2195e341e0a7cf89e434b68, tree 558c8f94238de33c9e4d30aae43365f7503c1d33, before handing off. The wrapper's incompatible guard caused the failure; this is not a product failure or evidence of incorrect synchronized source.

  • Identity: provider blacksmith-testbox, profile openclaw-check, Linux; lease tbx_01m3tcnn4m749w794706yepe0a; run 36794676517. Managed Crabbox 0.67.0 / Blacksmith 0.4.62. Hydration workflow SHA 33ae32bfc1d533d1cdcd6b3dc7cbd2605c423e0a; selected maintained tooling SHA 7db2084787edbc63b585badc8fe41beaa0d03d89.
  • Package inputs: candidate source 65862a058521a48eb2195e341e0a7cf89e434b68, manifest version 2026.9.7; no candidate tarball was built. Published baseline registry metadata: [email protected], tarball, integrity sha512-/8N2LnfTFQPvnZizi8qKSFfnLQaPvSG3Cb4xo1YV7b4JhYiUc43ZNRpXJ01bWghLK0Ezk3HVeo/DGHcIRQwRWA==. The published package was not installed during this attempt.
  • Command and timing: OPENCLAW_CRABBOX_WRAPPER_IGNORE_REPO_BINARY=1 node scripts/crabbox-wrapper.mjs run --id tbx_01m3tcnn4m749w794706yepe0a --keep --timing-json -- bash -c <hash-bound scratch transport>. Warmup 7.799 s; source preparation 32.913 s; delegated command 60.874 s, delegated total 61.197 s, wrapper elapsed 66.614 s. These are preparation/command timings, not updater-cell timings.
  • Auditable evidence: sanitized source/result archive, downloaded and hash-verified; archive SHA-256 5ffe45a47184c2f932ee8073cf054153e87be7f959d1a2d71c1605b4abeccec6. It contains the command wrappers, receipt helper, maintained runner prefix/source hash, result, and observed receiver/timing lines. remote.sh SHA-256 668e74bc266b2ee4295e95ebd1aa931059ffc98c7c2e11eb2301ffa066a4c1e9; cell.sh SHA-256 823bf8a00c8418549bca9f82bc7cfa379f08b843f827a3c1cf0ae5a6d987a9c1. The broker download link expires October 8, 2026 at 00:17 UTC.
  • Cleanup and limitation: the lease received one stop call and is verified completed, with no active runner IP. Task-owned temporary scenario/source scratch and this attempt’s local capture were removed after the sanitized archive was published and downloaded/hash-verified; existing campaign evidence remains preserved. No product bytes or protected Mainframe Gateway state changed. No published install, schema-19 fixture, updater, Doctor, isolated Gateway start, or receipt control executed. Product execution and schema-19 survivor proof remain unrun.

Attempt 2 — authorized corrected rerun; partial product proof, terminal harness failure (retained): Exactly one new configured-provider lease and one cell ran. Exit 1 at preserved-after-doctor; no retry. The published updater successfully installed the exact candidate, schema 19 → 20 and installed payload identity passed, and standalone Doctor completed. The scratch helper then used strict deep equality on a fresh node:sqlite null-prototype column row versus its JSON-restored ordinary-object snapshot (receipts.mjs:213). The retained assertion reports identical schema, job and receipt values; only the column object's prototype differs. This is a task-owned harness assertion defect, not a demonstrated product or infrastructure failure. The cell remains failed.

  • Scope and identity: blacksmith-testbox / openclaw-check, Linux; lease tbx_01m3tdvafnxc9am2gm0qmn1r92; run 36796432375. Crabbox 0.67.0 / Blacksmith 0.4.62. Hydration workflow SHA 588b5d7d50b78250148110f070d9deb55f4ace1d; maintained tooling SHA 7db2084787edbc63b585badc8fe41beaa0d03d89. Receiver and corrected guard agreed on candidate 65862a058521a48eb2195e341e0a7cf89e434b68, tree 558c8f94238de33c9e4d30aae43365f7503c1d33, carrier c26746ea3813c165296da6f74737f1dbc9cc6872.
  • Exact restoration and preflight: restored and hash-verified attempt 1's published archive. Only remote.sh's invalid HEAD guard and its checksum changed; local syntax and carrier/wrong-tree/wrong-ref probes passed before allocation. Corrected remote.sh SHA-256 5a96badd56f8e7390345a4a0261d413024b2c74462d6fe7588b21da9a3fa5ae7; unchanged cell SHA-256 823bf8a00c8418549bca9f82bc7cfa379f08b843f827a3c1cf0ae5a6d987a9c1. The launch environment supplies the maintained packer's supported GIT_COMMIT=65862a058521a48eb2195e341e0a7cf89e434b68 input; package and installed-file identity checks confirm that candidate. The restored collector's historical lease constant is explicitly distinguished from this execution in the outer evidence envelope.
  • Package and state proof: the unchanged published [email protected] tarball/integrity listed above was downloaded, verified and installed; baseline build commit c074824a27c96d3983043f9eeb33823cd1772d8c, tarball SHA-256 1b4746d9dfe1768e73da849e824172140f1a71b6edde3f7625f70477a73f83f7. Its Doctor created genuine schema 19 without delivery_attempt_state; two legacy announce/webhook receipts were seeded. Its shipped updater used the maintained local registry to install candidate version 2026.9.7, tarball SHA-256 e78739f73bed593920f6b7a155b344cfe1ab789a5571b6ef00d0a05af541a2fa, integrity sha512-mVZ54IfgHwboPfwi3v7Pz8LAGASuGTcGEpJce0/7279SFTBYwXhZLPDl1yNY/8vexgz040msuhCjhq9CF3KVsg==. Both original receipts survived with delivery_attempt_state=unknown; schema metadata/column checks passed. Post-Doctor assertion data still show those same two receipts/jobs; jobs remain enabled/running at this pre-recovery stage.
  • Command and timing: OPENCLAW_CRABBOX_WRAPPER_IGNORE_REPO_BINARY=1 node scripts/crabbox-wrapper.mjs run --id tbx_01m3tdvafnxc9am2gm0qmn1r92 --keep --timing-json -- bash -c <hash-bound transport.sh>. Warmup 7.582 s, package 466 s, cell 201 s, installed updater 167.332 s, standalone Doctor 8.327 s, wrapper 785.666 s, launch wall 796.969 s (2026-10-01 00:29:37–00:42:54 UTC).
  • Evidence and cleanup: sanitized source/result archive downloaded and SHA-256 verified: 7a1b19f174b62b300b6c70e26c56aa48c6c331c423de94215b00c849ac5e00ad; link expires 2026-10-08T00:45:27Z. It includes both attempts, exact source delta/hashes, preflight, phases, package identities, sanitized updater result, full synthetic assertion, and read-only prototype diagnosis. All evidence downloads completed; one native stop call completed and lease status is completed, with no runner IP. Task-owned local scenario/tooling scratch, downloaded raw logs, and this attempt’s local capture were removed after publication and download/hash verification; prior campaign evidence remains preserved. Product checkout and protected Mainframe Gateway remain unchanged.
  • Unrun in attempt 2: execution stopped before candidate-native started announce/webhook fixtures, the eligible not-started control, and both requested isolated Gateway starts. Any updater-owned canary process is not one of those two recovery starts. This attempt does not prove four held survivors stay disabled Unknown, no replacement/duplicate delivery after restart, or the eligible control's behavior. No retry, second new lease, manual ClawSweeper request, push, merge, queue or automerge action followed.

Attempt 3 — full bounded schema-19 installed-updater survivor cell PASS: Exit 0, exactly one newly authorized lease and one full cell, with no retry. The unchanged published [email protected] updater installed exact candidate 65862a058521a48eb2195e341e0a7cf89e434b68; genuine schema 19 → 20, standalone Doctor, both isolated Gateway starts, and all receipt/job assertions passed.

  • Only authorized helper correction: restored attempt 2's archive and verified SHA-256 7a1b19f174b62b300b6c70e26c56aa48c6c331c423de94215b00c849ac5e00ad. The observed SQLite column row is spread into ordinary value data before strict comparison, retaining schema-19 null and every field/value. Only receipts.mjs and its owned checksum changed; all other scenario files and the launcher are byte-identical to attempt 2. Helper SHA-256 fd156031b7e25ca139ca315dca896f5316fd839a0ebac307ebafbdc57970da3d. Before allocation, the original prototype-only comparison failed as expected, normalized equality passed, and changed receipt state, delivery-attempt state, job value, schema value, and column value all failed. Independent inspection confirmed no weakened assertions or production seam.
  • Provider and source binding: blacksmith-testbox / openclaw-check, Linux; lease tbx_01m3tf0qrzb6s5bzdh2nqmsfa4; run 36798116956. Crabbox 0.67.0 / Blacksmith 0.4.62. Hydration workflow SHA 0338bb3adbafa24f8887e169634169ae60d690af; maintained tooling SHA 7db2084787edbc63b585badc8fe41beaa0d03d89. Receiver and unchanged carrier-aware guard independently agreed on candidate 65862a058521a48eb2195e341e0a7cf89e434b68, tree 558c8f94238de33c9e4d30aae43365f7503c1d33, carrier 91caaf581013aef25afb5b5a3af1725d3220256d. The unchanged launch environment retains the maintained GIT_COMMIT candidate binding; candidate and installed application payload identities match.
  • Package identities: published baseline [email protected], tarball, integrity sha512-/8N2LnfTFQPvnZizi8qKSFfnLQaPvSG3Cb4xo1YV7b4JhYiUc43ZNRpXJ01bWghLK0Ezk3HVeo/DGHcIRQwRWA==, SHA-256 1b4746d9dfe1768e73da849e824172140f1a71b6edde3f7625f70477a73f83f7, build commit c074824a27c96d3983043f9eeb33823cd1772d8c. Exact-candidate package version 2026.9.7, SHA-256 44f03343b9b239856516e26052a095810201fb1f033a5a50ac2f31080991dfac, integrity sha512-2HFLGLtsmmQ9Vn1L5Tf5YO32Ooodl0n+VXftuMTwpeA8EhHbcMPBd1ICpN3b3WRCxygPNH7s6HTEwRLsZmu3Zw==, build ID 2026.9.7-65862a058521-2026-10-01T00-52-24.413Z.
  • Observed recovery: the published baseline Doctor created schema 19 without the delivery-attempt column. Two legacy announce/webhook receipts survived the shipped updater as unknown; standalone Doctor preserved the migrated snapshot exactly. Two candidate-native started announce/webhook fixtures and one eligible not-started system-event control were then added under schema 20. Across two distinct Gateway start/probe/recovery/stop sequences, all four held jobs stayed disabled with Unknown, lastDelivered=false, and exactly their original interrupted receipts—no replacement receipt or duplicate recovery delivery. The eligible control produced exactly one successful replacement receipt and became disabled with not-requested delivery. Final state: 5 jobs / 6 receipts; the first and second settled snapshots are exactly equal.
  • Command and timings: OPENCLAW_CRABBOX_WRAPPER_IGNORE_REPO_BINARY=1 node scripts/crabbox-wrapper.mjs run --id tbx_01m3tf0qrzb6s5bzdh2nqmsfa4 --keep --timing-json -- bash -c <hash-bound transport.sh>. Warmup 7.161 s, package 489 s, full cell 223 s, installed updater 174.152 s, standalone Doctor 8.978 s; first/second Gateway start phases 4.673 / 4.679 s. Wrapper 851.671 s, launch wall 862.784 s (2026-10-01 00:50:14–01:04:36 UTC).
  • Evidence, cleanup, and limits: sanitized attempt-3 source/result archive downloaded and SHA-256 verified: 6b4b6aa766937d714c0c59fd7ebe4cb729b253c943be1cb4e00ce80a269c73c2; link expires 2026-10-08T01:06:05Z. It contains all three attempts, exact source delta/hashes, pre-allocation positive/negative probes, phase records, package identities, final receipt/job snapshots, and sanitized updater output. The restored collector's historical lease constant is explicitly distinguished from this run in the outer envelope. One native stop call completed; lease status is completed, with no runner IP. Task-owned scenario, transport, downloaded raw evidence, and publication scratch were removed after download/hash verification; this successful invocation left no local wrapper capture. Prior campaign evidence remains preserved. Product checkout and protected Mainframe Gateway remain unchanged. These are synthetic destinations: no live recipient/provider delivery is claimed. The started/not-started controls were deliberately added after migration because schema 19 lacks their new column.

Historical upgrade witness: Package Acceptance run 36367832126, survivor lane 249 s (workflow 20m11s), product 818dd85ae1892e4d63cd431ee00d3baff8e66be2, harness 6615bbd751b238de2a4bdc1b9f2662244f372987. Published [email protected] created schema 18; its unchanged installed updater migrated preserved announce/webhook receipts to 20/unknown. Doctor and two isolated Gateway starts retained disabled Unknown jobs without replacement receipts. Sanitized artifact.

The migration, recovery kernel, receipt-delivery and delivery-fence source files remain byte-identical to that tested product. This is historical compatibility evidence, not current-head whole-product/process or live recipient/provider qualification. Current evidence status: the requested published v2026.9.7/schema-19 installed-updater → exact-candidate/schema-20, Doctor, and two-start survivor cell now passes. Attempts 1 and 2 retain their actual harness failures above; neither is relabeled a pass. Automatic exact-head review can reconcile the new immutable evidence without a manual ClawSweeper request. Live recipient/provider evidence remains absent; the non-attributable Android failure and cancelled CI coverage retain their stated limits. No branch push, merge, queue, or automerge action was taken.

Retained prior-head validation details
  • Prior-head focused proof: 205 cases / 23 files pass with one worker, 317.42 s wall. Covers restart controls, receipts, migration, current-session completion, webhook outcomes, MCP/message dispatch, thinking hydration and retained lifecycle owners.
  • CI regression replay: original 14-file subgroup passes 74 cases, one platform skip, 418.64 s wall; requester-yield/health pair passes 17 cases, 76.34 s with one worker. Tool-policy cases pass 27/27, 27.16 s; wrapper inventory passes 6.08 s. The earlier 12 spawn/heartbeat and two requester-yield failures were branch-attributable, reproduced before repair, and fixed by removing an ambient parent-writer assertion from general transcript persistence. No retries, timeouts or assertions were weakened.
  • Both after-acceptance restart cases and all three controls pass. The historical negative control, substituting frozen main’s recovery owner, produced exactly two duplicate-delivery failures with the controls passing (72.21 s wall). Recipients/process death are simulated; receipt persistence, admission and repeated startup are real.
  • Public Gateway flow: the existing ordinary-reply socket test passed on the prior head (1 case, 34.64 s wall): explicit non-main sessions.create → chat.send → final event → chat.history verifies the persisted exchange. Gateway, websocket and storage are real; the agent reply is mocked.
  • Checks: 27 affected-input guards, production core types, and all 27 selected test-type graphs pass (graphs 743.31 s, concurrency 3). Kysely/native schema parity pass. Fresh full-branch ordinary review found no actionable P0/P1 findings. Final TruffleHog 3.97.8 scanned 235 chunks / 107,211 bytes with zero findings, credential verification disabled.
  • Unrelated local check failure: max-lines rejects a stale Teams test baseline after main 0a0a2e048902 / test(core,plugins): remove low-value tests (batch d108) #161689 shortened the test and removed its suppression. Checker/helper/baseline/test blobs exactly match this pinned base (20.22 s). The earlier vision-test baseline was fixed upstream by 1087139f5fb.

@clawsweeper

clawsweeper Bot commented Sep 27, 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.

@joshavant
joshavant marked this pull request as ready for review September 27, 2026 20:06
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XL labels Sep 27, 2026
@joshavant
joshavant marked this pull request as draft September 27, 2026 20:06
@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 65862a058521a48eb2195e341e0a7cf89e434b68
  • Maintainer: @joshavant
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/tools/message-tool-turn-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 30, 2026, 9:15 PM ET / October 1, 2026, 01:15 UTC (Revision 27).

ClawSweeper review

What this changes

The branch records delivery attempts in Cron's SQLite run receipts and carries that fence through message and webhook delivery so restart recovery replays only one-shot runs proven not to have started delivery.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/state/openclaw-state-schema.sql. Prefer a design that avoids changing persisted SQLite tables. Migration or upgrade compatibility proof is recorded, but maintainers should still confirm that the schema change is necessary.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open. Current main still permits startup replay of an interrupted one-shot without a delivery-attempt check, so this PR remains useful. The previously missing schema-19 upgrade witness is now recorded for the reviewed head, and this review found no definite introduced defect. The exact-head CI gate remains failed after an Android test failure outside the changed paths.

Priority: P2
Reviewed head: 65862a058521a48eb2195e341e0a7cf89e434b68

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The receipt-owned implementation and upgrade/restart evidence are solid, with final recipient acceptance still simulated and exact-head CI incomplete.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The collaborator proof gate does not apply. For the reviewed head, the matching PR body records a published-updater schema-19→20 run, Doctor, and two Gateway starts with four ambiguous jobs held and one never-started control recovered; recipient transports were synthetic. The migrated receipt observations and focused downgrade/rollback tests support existing-state compatibility, although this review did not independently open the linked archive.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The collaborator proof gate does not apply. For the reviewed head, the matching PR body records a published-updater schema-19→20 run, Doctor, and two Gateway starts with four ambiguous jobs held and one never-started control recovered; recipient transports were synthetic. The migrated receipt observations and focused downgrade/rollback tests support existing-state compatibility, although this review did not independently open the linked archive.
Evidence reviewed 10 items Current main still needs the fix: The fetched main revision passes startup mode directly as recoverInterruptedOneShot, without consulting a delivery-attempt state.
Durable recovery rule: The introduced recovery code requires the exact receipt to read not-started; missing and legacy evidence resolves to unknown. New receipt claims explicitly start as not-started.
Stored-state migration: Schema 20 adds one checked receipt column defaulting to unknown, while the worker commits started before delivery. This is a stored-data change, independently assessed for upgrade compatibility.
Findings None None.
Security None None.

How this fits together

Cron schedules jobs and stores run receipts in OpenClaw's shared SQLite state. On restart, those receipts guide whether the Gateway may retry a one-shot job; during execution, the Gateway and outbound dispatch use them before handing off messages or webhooks.

flowchart LR
  A[Scheduled one-shot] --> B[SQLite run receipt]
  B --> C[Delivery-attempt fence]
  C --> D[Message or webhook handoff]
  B --> E[Restart recovery]
  E --> F{Attempt state}
  F -->|Not started| G[Recover job]
  F -->|Started or unknown| H[Hold for inspection]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test growth production +626 net lines; tests and test support +976 net lines The production growth spans receipt migration, run authority, and final delivery handoff; the PR explains those boundaries as necessary for durable fencing.
Stored-state contract schema 19→20; 1 receipt column added Existing databases and older readers are affected, making the recorded published-updater witness material to review.

Stored data model

Persistent data-model change detected: database schema: src/state/openclaw-state-schema.sql, migration/backfill/repair: scripts/pr-lib/wrapper-components.txt, migration/backfill/repair: src/state/openclaw-state-db-cron-delivery-migration.ts, migration/backfill/repair: src/state/openclaw-state-db-maintenance.ts, unknown-truncated-pull-files. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep the run receipt as the single durable attempt owner, replay only exact never-started one-shots, and present ambiguous interrupted jobs for recipient inspection before any manual retry.

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

Yes at the source boundary: current main still replays interrupted one-shots without checking delivery attempts, and the PR records a frozen-main negative control that duplicated delivery. This review did not execute a current-main live-recipient reproduction.

Is this the best way to solve the issue?

Yes. Recording a monotonic attempt fact in the existing receipt and checking it at recovery and handoff is a coherent single-owner repair; the conservative Unknown outcome matches the accepted storage decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b1b1f19f7d3a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Duplicate one-shot delivery is a concrete user-facing Cron defect with a bounded but meaningful delivery impact.
  • merge-risk: 🚨 compatibility: Schema 20 changes older-reader admission and conservatively holds ambiguous legacy one-shots; the accepted tradeoff and upgrade witness bound that impact.
  • merge-risk: 🚨 message-delivery: The new receipt state controls whether Cron announcements and webhooks can be sent or replayed after interruption.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The collaborator proof gate does not apply. For the reviewed head, the matching PR body records a published-updater schema-19→20 run, Doctor, and two Gateway starts with four ambiguous jobs held and one never-started control recovered; recipient transports were synthetic. The migrated receipt observations and focused downgrade/rollback tests support existing-state compatibility, although this review did not independently open the linked archive.

Evidence

What I checked:

  • Current main still needs the fix: The fetched main revision passes startup mode directly as recoverInterruptedOneShot, without consulting a delivery-attempt state. (src/cron/store/run-recovery.kernel.ts:150, b1b1f19f7d3a)
  • Durable recovery rule: The introduced recovery code requires the exact receipt to read not-started; missing and legacy evidence resolves to unknown. New receipt claims explicitly start as not-started. (src/cron/store/run-recovery.kernel.ts:151, 65862a058521)
  • Stored-state migration: Schema 20 adds one checked receipt column defaulting to unknown, while the worker commits started before delivery. This is a stored-data change, independently assessed for upgrade compatibility. (src/state/openclaw-state-schema.sql:1501, 65862a058521)
  • Final-effect authority: The new run capability carries a delivery-attempt callback and current-run assertion into message actions; the Cron fence checks admission, reservation, cancellation, agent availability, and lifecycle before its worker mutation. (src/cron/run-admission.ts:100, 65862a058521)
  • Restart and authority controls: Focused tests cover accepted-then-lost acknowledgment, never-started recovery, repeated startup, and refusal before mocked platform sends after fence failure or revocation. The final recipients are simulated. (src/cron/service.restart-delivery.test.ts:39, 65862a058521)
  • Accepted conservative recovery tradeoff: A collaborator with repository admin access recorded acceptance of schema 19→20 and of holding legacy ambiguous or post-admission interrupted one-shots as Unknown, while explicitly retaining migration, rollback, and proof requirements. See fix(cron): prevent duplicate one-shot delivery after restart #159873 (comment).

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (26 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-30T09:13:30.362Z sha 875c597 :: blocked before merge. :: none
  • reviewed 2026-09-30T09:37:05.337Z sha 875c597 :: blocked before merge. :: none
  • reviewed 2026-09-30T23:15:40.486Z sha 65862a0 :: blocked before merge. :: none
  • reviewed 2026-09-30T23:33:35.474Z sha 65862a0 :: blocked before merge. :: none
  • reviewed 2026-09-30T23:42:11.289Z sha 65862a0 :: blocked before merge. :: none
  • reviewed 2026-10-01T00:12:09.118Z sha 65862a0 :: blocked before merge. :: none
  • reviewed 2026-10-01T00:37:02.306Z sha 65862a0 :: blocked before merge. :: none
  • reviewed 2026-10-01T00:54:06.446Z sha 65862a0 :: blocked before merge. :: none

@joshavant
joshavant force-pushed the codex/qa-p04-restart-duplicate branch 2 times, most recently from bf00fbc to b168e7b Compare September 27, 2026 21:28
@joshavant
joshavant marked this pull request as ready for review September 27, 2026 21:28
@joshavant

Copy link
Copy Markdown
Collaborator Author

P-04 accepted storage decision — September 27, 2026.

This records the campaign lead’s explicit task approval, granted before implementation, for the reviewed durable delivery-attempt fence and its SQLite schema/content-version migration. The lead separately clarified that approval does not cover an OpenClaw release, package, or protocol version bump. This is a record of existing authority, not a new approval or a merge request.

  • Owner: the existing shared SQLite cron occurrence receipt. Its canonical monotonic attempt fact distinguishes not-started, started, and legacy unknown; there is no sidecar store or second recovery owner.
  • Accepted tradeoff: state schema 19 → 20 adds the receipt column. Legacy ambiguous interrupted one-shots remain disabled as Unknown, including jobs that may never have sent and jobs normally deleted after running. Proven never-started occurrences retain startup recovery. A crash between durable admission and transport handoff can hold an unsent job. Removing startup recovery globally was rejected because it breaks the documented never-started contract; volatile evidence cannot survive the recovery boundary.
  • Lifecycle: the field inherits existing receipt retention and deletion. FIFO worker writes, exact receipt identity, current owner authority immediately before dispatch, integrity checks, and settlement remain required. The durable transition adds a worker transaction before delivery; repeated admission is monotonic and only the first transition changes the field.
  • Upgrade/rollback: use existing migration, backup, deferred-publication, and rollback owners. Schema-19 readers refuse migrated state outside the existing updater-owned admission window. Restoring an old database loses newer receipt facts and cannot reconcile messages already sent after that backup. No new updater exception is authorized.
  • Validation limits: the original four-case regression failed for both duplicate paths and preserved both never-started controls before implementation; focused migration/rollback/admission tests passed. The single published-driver run installed original head e318c7aeb39a43863a3b0100301302dcd4b5af9f and returned ok, then failed standalone Doctor on WhatsApp reload. It did not capture migrated receipt columns and is not current-head survivor acceptance. The lead explicitly prohibited additional updater/Testbox attempts in this continuation.

The approval covers the persistence and conservative recovery design above. It does not waive CI, independent review, upgrade-evidence limits, or authorize merge, queue, or automerge.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 27, 2026
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Exact product head 818dd85ae1892e4d63cd431ee00d3baff8e66be2 now has a successful published-driver migration/survivor witness: run 36367832126, receipt and phase evidence. Published [email protected] created schema 18; its installed updater migrated both announcement/webhook receipts to schema 20/unknown using the original frozen candidate tarball. Standalone Doctor and both isolated Gateway recovery checks passed; legacy ambiguous one-shots stayed disabled Unknown without replacement receipts. Existing owner regressions retain never-started recovery. This is explicitly approved published 18→20 proof; no published driver owns shared schema 19.

Product bytes remain unchanged. Qualification harness 6615bbd751b238de2a4bdc1b9f2662244f372987 contains the reviewed one-line SQLite-row normalization; direct DatabaseSync regression proved red→green before the single final dispatch. PR body records identities, costs, prior failed attempts, and existing canceled/failed exact-head CI. Review only; no merge, queue, or automerge is authorized.

@clawsweeper

clawsweeper Bot commented Sep 28, 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@joshavant
joshavant force-pushed the codex/qa-p04-restart-duplicate branch from 818dd85 to 55a2bc6 Compare September 28, 2026 03:00
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Please review exact head 55a2bc6128a949f66db31dc6411c71efcc22cecf, rebased as two commits onto pinned main 056e84786a061fdc92bd0ce5ff4eac23c6fa2e09. The actual #158567/#158877 conflicts are resolved; upload-policy/route ownership and P04 delivery custody compose at every write boundary. Focused regressions, changed-input checks, and final P1 autoreview pass; details and test cost are in the updated PR body.

Preserve the accepted published schema18→20/Doctor/two-restart witness 36367832126 at product818dd85 as compatibility evidence: schema, migration, recovery, and fence-owner bytes are unchanged. It was not rerun or relabeled as current-head process execution. GitHub reports MERGEABLE; exact-head CI is running. Review only; no repair, merge, queue, or automerge requested.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@joshavant
joshavant force-pushed the codex/qa-p04-restart-duplicate branch from 55a2bc6 to 5ec5ddc Compare September 28, 2026 03:16
@joshavant
joshavant force-pushed the codex/qa-p04-restart-duplicate branch from 875c597 to 65862a0 Compare September 30, 2026 23:08
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. labels Sep 30, 2026
@clawsweeper clawsweeper Bot added 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. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. labels Oct 1, 2026
@joshavant
joshavant merged commit 187594c into main Oct 1, 2026
299 of 314 checks passed
@joshavant
joshavant deleted the codex/qa-p04-restart-duplicate branch October 1, 2026 02:01
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…w#159873)

* fix(cron): prevent duplicate one-shot delivery after restart

* fix(cron): include delivery migration in PR wrapper closure

* fix(cron): reconcile restart tests and delivery execution

* fix(cron): scope completion authority to background commits

* fix(cron): retain synchronous webhook delivery authority
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed 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