Repository navigation
fix: keep script reports pending after required delivery fails - #208403
Conversation
Co-authored-by: daniel-lxs <[email protected]>
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 2d262f4c-ad65-47be-87ce-d03eead0ed6b
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. |
|
I ran the built CLI against the same receiver outage on Crabbox AWS. On main, the next occurrence skipped R-42 after recovery (0 reports accepted). With the fix, the next occurrence delivered R-42 (1 accepted) and a third occurrence did not duplicate it. The second row in each capture is the run after recovery. Before After |
|
Codex review: passed. What this changesThis PR advances script checkpoints only after whole-run completion succeeds, including during restart recovery. Example: A recurring script returns Report R-42 and its checkpoint, but the required webhook returns HTTP 503.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a report-loss bug still present on main, with no actionable correctness or security findings. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron executes scripts, settles their delivery, and sends completion facts to the SQLite worker that updates job state; startup recovery applies retained completion facts through the same checkpoint writer. flowchart LR
A[Scheduled occurrence] --> B[Script executor]
B --> C[Delivery owner]
C --> D[Whole run completion]
D --> E[Checkpoint writer]
E --> F[SQLite job state]
F --> A
Technical reviewBest possible solution: Use recorded whole-run completion to gate the existing script-state writer during normal finalization and restart recovery. Do we have a high-confidence way to reproduce the issue? Current main exposes the status-only checkpoint condition, and the supplied CLI captures demonstrate the resulting lost report after a required HTTP 503; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete fix: both paths consume the existing completion fact while preserving best-effort behavior, execution retry accounting, and edit ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 603078e5cab6. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -3, Tests +38, Docs 0. Total +35 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 29, 2026, 11:26 AM ET / 16:26 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 2d262f4c-ad65-47be-87ce-d03eead0ed6b (cherry picked from commit d4509c4) Release adaptation: Apply the run completion-status check to the beta.2 timer-outcomes owner rather than replacing it with the main layout. Co-authored-by: RomneyDa <[email protected]>
## What Problem This Solves Automations created before OpenClaw recorded the creating conversation (every job without `sourceConversation`, i.e. created before #179062) name that conversation only by session key. Their scheduled runs get no memory at all: every `knowledge_*` or memory tool call fails with "the host granted this session no memory audience", and the Gateway logs `memory audience unavailable: root session agent:<agent>:cron:<job>:run:<run> has no durable chat type`. The same runs still hold owner-only tools such as `exec`. A production automation that reads and writes the owner's knowledge vault every week hit this on every run. ## User Impact - A key-only detached automation (`isolated` / `current`) now reads its conversation's current memory, the same way a bound automation does: - created in the owner's direct chat: the owner's private memory; - created in a group or channel: only that conversation's memory, never owner-private. - When the job recorded a requester (profile or channel sender), that requester's owner status is checked at each occurrence first; without one, the run's existing owner bit decides, as it already does for the run's tools. - If the conversation row is gone, archived or cannot be read, the run proceeds exactly as before (no memory, no pause, no failure). - Board, workspace, sandbox, event target and the run's tools are unchanged. `main` and `session:<key>` targets are unchanged. - `automations bind` stays available for the exact-incarnation link but is no longer needed for memory. Docs (`cli/cron` "Binding older jobs", `automation/cron-jobs/payloads`) and Doctor's unbound note say so. Accepted edge case: a key-only run whose agent sandbox mode is `non-main` or `all` now gets owner-private memory it did not have, when the job was created in the owner's direct chat. The owner created these jobs in their own DM, and the run already holds owner authority. ## Why This Change Was Made `resolveScheduledPrincipal` classifies these jobs as `unbound-parent` and gives them legacy owner authority, but `buildScheduledExecutionContext` pointed their memory at the cron run row, which never has a chat type, so the memory resolver always denied. The fix stays in the existing owner: - `admitScheduledOccurrence` (`src/cron/execution-context-admission.ts`): for an `unbound-parent` principal on a detached run, read the key-linked conversation row once. A failed read becomes "no row". No generation lease, workspace binding, sandbox or pause change. A recorded requester is admitted per occurrence through the existing `admitScheduledRequesterGrant`. - `buildScheduledExecutionContext` (`src/cron/execution-context.ts`): with a live row, memory becomes `{ source: "parent", parent: <current sessionKey/sessionId/lifecycleRevision>, owner }`. Everything else for `unbound-parent` is unchanged. - The memory resolver (`src/plugins/memory-audience.ts`) does not change: it already maps a direct root + owner to owner-private and direct/group/channel to that conversation's partition, for both the embedded and the CLI runtime. - `scheduledParentKeyOf` now derives the key from `resolveScheduledPrincipal` itself, so Doctor's access review and the development replay read the same row the runtime does; the replay vector (`execution-context-projection.ts`) already labels the memory gain as intended, so it needed no edit. Not changed: Doctor auto-bind or any stored-row write, jobs with no parent key, bound jobs with no recorded requester. On current `main`, bound jobs keep following their conversation after a reset (#205887), so no reset-degraded path exists to special-case. ## Evidence Real-admission tests (red on the merge base `bb5c001bb6fc`, green on this head; 6 tests failed on base, all pass on head): - `execution-context-memory-audience.test.ts` (real admission → registry → embedded and CLI resolvers): key-only owner-DM job → owner-private; key-only group job → that group's conversation only; key-only job with a revoked recorded requester → conversation only; key-only job whose conversation is gone → no audience, run admitted. - `execution-context.test.ts`: key-only detached job gets parent memory and nothing else (board/workspace/sandbox stay the run's); archived, removed and in-session (`session:<key>`) cases keep run-session memory. - `execution-context-admission.test.ts`: key-only read takes no generation lease; a failed read still admits the run with its own memory. - `isolated-agent/run.bind-parent.test.ts` (real cron service + timer): the unbound job now reaches its conversation's memory, without a run-row receipt. Local runs: the 27 test files that import the changed sources passed (`ocx test`, 6 shards). `pnpm check:changed`: typecheck, lint, guards all ok; the dead-export scan fails only on files this PR does not touch (`src/agents/command/types.ts`, `src/plugins/native-module-require.ts`, `ui/src/...`, `src/gateway/server-methods/update.test-harness.ts`), same as `main`. End to end, scratch Gateway from source, `plugins.slots.memory: "knowledge"`, real model (`openai/gpt-5.5`). An owner Control UI direct chat was created by one real `chat.send` (row `chatType: "direct"`). A key-only isolated `agentTurn` job (owner key = that chat, no `sourceConversation`, no recorded requester, no tool policy, `toolsAllow` incl. `knowledge_remember`, `knowledge_grep`, `exec`) fired from its own `at` schedule about two minutes ahead (no forced run). Base (`bb5c001bb6fc`): ``` [agent/embedded] memory audience unavailable: root session agent:main:cron:<job>:run:<run> has no durable chat type ``` ``` knowledge_remember: "Knowledge access unavailable: the host granted this session no memory audience. The Gateway log entry "memory_audience_denied" for this session names the reason and its repair." knowledge_grep: "Knowledge access unavailable: the host granted this session no memory audience. ..." ``` Head: no `memory audience unavailable` line in the Gateway log; the run's result: ``` knowledge_remember: inserted claim <claim-id>. knowledge_grep: 1 hit — <claim-id>: "The owner's favorite tea is masala chai." ``` The claim was written under the store's `vault/private/` (owner-private). Observed, not changed here: a session created only through `openclaw agent --session-key agent:main:main` from the CLI has no `chatType`, so a key-only job linked to such a row still gets no memory (Doctor already lists these under "no stored chat type"). Channel DMs and Control UI chats record `chatType: "direct"`. Merge danger: two-way door. No schema, stored-row, config or protocol change; a revert restores the previous memory decision. Blast radius: memory audience of detached scheduled runs whose jobs have no `sourceConversation` but an owner/policy session key. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 9143f38) Later same-path commits from the pinned scan (separate behavior unless named as folded/selected below): 00e025a fix: report skipped manual automation runs without timing out (#208453); d4509c4 fix: keep script reports pending after required delivery fails (#208403); 03cdb2c fix: let the oldest automations read their conversation's memory (#208190). Later PR-number mentions: `03cdb2cef17e` fix: let the oldest automations read their conversation's memory (#208190), `16a2d4b59d75` refactor(ui): lowercase log search text only once (#207383), `21786f65ed93` refactor(ui): stop sending 28 additional unused labels to translators (#207982), `34d4f8f308ba` improve: list Docker streams and flag unconfirmed cleanup in Doctor (#201292), `9cec330df50d` refactor(workboard): group session tiles without rescanning each column (#207380) Later commit-SHA mentions: none Co-authored-by: RomneyDa <[email protected]>
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 2d262f4c-ad65-47be-87ce-d03eead0ed6b (cherry picked from commit d4509c4) Release adaptation: Require authoritative whole-run completion before writing the payload-script checkpoint. Keep stable auto-disable imports, stale trigger ownership fences, and existing legacy startup completion derivation. Companion audit: PR #208403 is selected. The separate once-watcher transition (row 58) owns trigger evaluation state; do not replay it in this payload checkpoint fix. Co-authored-by: RomneyDa <[email protected]>
Automations created before OpenClaw recorded the creating conversation (every job without `sourceConversation`, i.e. created before #179062) name that conversation only by session key. Their scheduled runs get no memory at all: every `knowledge_*` or memory tool call fails with "the host granted this session no memory audience", and the Gateway logs `memory audience unavailable: root session agent:<agent>:cron:<job>:run:<run> has no durable chat type`. The same runs still hold owner-only tools such as `exec`. A production automation that reads and writes the owner's knowledge vault every week hit this on every run. - A key-only detached automation (`isolated` / `current`) now reads its conversation's current memory, the same way a bound automation does: - created in the owner's direct chat: the owner's private memory; - created in a group or channel: only that conversation's memory, never owner-private. - When the job recorded a requester (profile or channel sender), that requester's owner status is checked at each occurrence first; without one, the run's existing owner bit decides, as it already does for the run's tools. - If the conversation row is gone, archived or cannot be read, the run proceeds exactly as before (no memory, no pause, no failure). - Board, workspace, sandbox, event target and the run's tools are unchanged. `main` and `session:<key>` targets are unchanged. - `automations bind` stays available for the exact-incarnation link but is no longer needed for memory. Docs (`cli/cron` "Binding older jobs", `automation/cron-jobs/payloads`) and Doctor's unbound note say so. Accepted edge case: a key-only run whose agent sandbox mode is `non-main` or `all` now gets owner-private memory it did not have, when the job was created in the owner's direct chat. The owner created these jobs in their own DM, and the run already holds owner authority. `resolveScheduledPrincipal` classifies these jobs as `unbound-parent` and gives them legacy owner authority, but `buildScheduledExecutionContext` pointed their memory at the cron run row, which never has a chat type, so the memory resolver always denied. The fix stays in the existing owner: - `admitScheduledOccurrence` (`src/cron/execution-context-admission.ts`): for an `unbound-parent` principal on a detached run, read the key-linked conversation row once. A failed read becomes "no row". No generation lease, workspace binding, sandbox or pause change. A recorded requester is admitted per occurrence through the existing `admitScheduledRequesterGrant`. - `buildScheduledExecutionContext` (`src/cron/execution-context.ts`): with a live row, memory becomes `{ source: "parent", parent: <current sessionKey/sessionId/lifecycleRevision>, owner }`. Everything else for `unbound-parent` is unchanged. - The memory resolver (`src/plugins/memory-audience.ts`) does not change: it already maps a direct root + owner to owner-private and direct/group/channel to that conversation's partition, for both the embedded and the CLI runtime. - `scheduledParentKeyOf` now derives the key from `resolveScheduledPrincipal` itself, so Doctor's access review and the development replay read the same row the runtime does; the replay vector (`execution-context-projection.ts`) already labels the memory gain as intended, so it needed no edit. Not changed: Doctor auto-bind or any stored-row write, jobs with no parent key, bound jobs with no recorded requester. On current `main`, bound jobs keep following their conversation after a reset (#205887), so no reset-degraded path exists to special-case. Real-admission tests (red on the merge base `bb5c001bb6fc`, green on this head; 6 tests failed on base, all pass on head): - `execution-context-memory-audience.test.ts` (real admission → registry → embedded and CLI resolvers): key-only owner-DM job → owner-private; key-only group job → that group's conversation only; key-only job with a revoked recorded requester → conversation only; key-only job whose conversation is gone → no audience, run admitted. - `execution-context.test.ts`: key-only detached job gets parent memory and nothing else (board/workspace/sandbox stay the run's); archived, removed and in-session (`session:<key>`) cases keep run-session memory. - `execution-context-admission.test.ts`: key-only read takes no generation lease; a failed read still admits the run with its own memory. - `isolated-agent/run.bind-parent.test.ts` (real cron service + timer): the unbound job now reaches its conversation's memory, without a run-row receipt. Local runs: the 27 test files that import the changed sources passed (`ocx test`, 6 shards). `pnpm check:changed`: typecheck, lint, guards all ok; the dead-export scan fails only on files this PR does not touch (`src/agents/command/types.ts`, `src/plugins/native-module-require.ts`, `ui/src/...`, `src/gateway/server-methods/update.test-harness.ts`), same as `main`. End to end, scratch Gateway from source, `plugins.slots.memory: "knowledge"`, real model (`openai/gpt-5.5`). An owner Control UI direct chat was created by one real `chat.send` (row `chatType: "direct"`). A key-only isolated `agentTurn` job (owner key = that chat, no `sourceConversation`, no recorded requester, no tool policy, `toolsAllow` incl. `knowledge_remember`, `knowledge_grep`, `exec`) fired from its own `at` schedule about two minutes ahead (no forced run). Base (`bb5c001bb6fc`): ``` [agent/embedded] memory audience unavailable: root session agent:main:cron:<job>:run:<run> has no durable chat type ``` ``` knowledge_remember: "Knowledge access unavailable: the host granted this session no memory audience. The Gateway log entry "memory_audience_denied" for this session names the reason and its repair." knowledge_grep: "Knowledge access unavailable: the host granted this session no memory audience. ..." ``` Head: no `memory audience unavailable` line in the Gateway log; the run's result: ``` knowledge_remember: inserted claim <claim-id>. knowledge_grep: 1 hit — <claim-id>: "The owner's favorite tea is masala chai." ``` The claim was written under the store's `vault/private/` (owner-private). Observed, not changed here: a session created only through `openclaw agent --session-key agent:main:main` from the CLI has no `chatType`, so a key-only job linked to such a row still gets no memory (Doctor already lists these under "no stored chat type"). Channel DMs and Control UI chats record `chatType: "direct"`. Merge danger: two-way door. No schema, stored-row, config or protocol change; a revert restores the previous memory decision. Blast radius: memory audience of detached scheduled runs whose jobs have no `sourceConversation` but an owner/policy session key. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 9143f38) Release adaptation: Resolve admission and payload documentation against the stable owners. Read a detached key-only parent once at occurrence admission without changing placement, workspace, sandbox, tools, or run-row receipts. Only an initially verified recorded requester can receive owner-private memory. With no verified requester, use conversation memory only; after a human ownership transfer, keep run-session memory. No new role or ownership rechecks, persisted fields, or config. Follow-up audit: #208190 (03cdb2c) extends the fix to top-level historical keys and is separately assigned to release lane w5-43; integrate this prerequisite first. #201287 (bf2c75e) changes general owner admission and watcher launch, not the key-only memory fix. #208453 (00e025a) and #208403 (d4509c4) address distinct manual-run and script-delivery behavior. Remaining PR-number hits (#207383, #207982, #201292, #207380) are incidental, with no related cron-memory change. Co-authored-by: RomneyDa <[email protected]>
…law#208403) Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 2d262f4c-ad65-47be-87ce-d03eead0ed6b


Related: #126163
What Problem This Solves
A recurring script can return a report and a checkpoint in the same run. If its required webhook rejects the report, main still saves the checkpoint. The next run can then skip a report nobody received.
User Impact
A failed or unconfirmed required delivery leaves the previous script state in place. The next normal occurrence can produce the report again. Best-effort delivery keeps its existing behavior. No configuration change or migration is needed. This does not reconstruct checkpoints that older versions already advanced, or guarantee exactly-once delivery when a receiver accepts a request but its acknowledgment is lost.
Why This Change Was Made
Both normal completion and restart recovery already have the whole-run completion status. I used that fact for the checkpoint instead of treating successful script execution as successful delivery. This preserves the distinction made in #126164 and #131228: delivery failure does not increment execution-error counters or schedule a payload retry. The existing protection for edits made during a run is unchanged.
Evidence
I ran the built CLI and an isolated Gateway on Crabbox AWS. I created a recurring script that returned
Report R-42and its dedup checkpoint together, then invoked consecutive occurrences withautomations run --wait. The HTTP receiver rejected every first-run request with 503, then returned 200.3f9c2bbok, completionfailed, checkpointR-42saved8ace32e7ok, completionfailed, checkpoint still unsetThe timer and restart-recovery regression tests failed on main because the stored revision was 2 instead of 1. The best-effort control passed. The runtime build passed. I repeated the live receiver test and all 62 focused tests on the published head
8ace32e7, which has the same source tree asce2243c5in the before-and-after CLI captures.Formatting, lint, and core and test typechecks passed. The only failing
check:changedlane was the dead-export scan. I ran that scan separately on3f9c2bb: its production and full-tree findings matched the PR tree exactly. I did not test a live network acknowledgment loss or attempt to repair historical checkpoints.Reported and co-authored by @daniel-lxs.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by
🦞 Made with OpenClaw