Files
openclaw/src/cron
Jerry-Xin 30b39c6eab fix(cron): guard against undefined sourceDelivery in isolated executor (#85249)
* fix(cron): guard against undefined sourceDelivery in isolated executor

* fix: narrow legacy sourceReplyDeliveryMode to closed union

Validate legacy sourceReplyDeliveryMode values against the
SourceReplyDeliveryMode union before forwarding them to typed runner
APIs. Unrecognized legacy values now fall back to the sourceDelivery
plan with a warning log.

* fix: align test imports with upstream renames

- SkillSnapshot moved from agents/skills.js to skills/types.js
- runEmbeddedPiAgentMock renamed to runEmbeddedAgentMock

* fix(cron): align sourceDelivery fallback defaults with current cron semantics

* refactor(cron): extract shared source-delivery fallback helper aligned with current main semantics

Replace inline legacy field sniffing in both createCronPromptExecutor and
executeCronRun with a shared resolveFallbackCronSourceDeliveryPlan helper
that derives webhook/none/announce plans from resolveCronDeliveryPlan(job)
and resolvedDelivery, matching current main's resolveCronSourceDeliveryPlan
exactly.

Changes:
- Created source-delivery-fallback.ts with shared helper
- Removed all legacy toolPolicy/sourceReplyDeliveryMode/messageChannel reads
- Updated guard tests to drive fallback via job delivery config
- Added tests verifying stale legacy fields are ignored
- All 12 guard tests pass, 99 cron files / 1002 tests pass

* refactor(cron): unify source-delivery planner into single shared helper

Extract resolveCronSourceDeliveryPlan as the single canonical cron
source-delivery planner in source-delivery-fallback.ts. Both the normal
cron execution path (run.ts) and the version-skew fallback path
(run-executor.ts) now use this shared helper, eliminating the duplicate
implementation that ClawSweeper flagged as P1.

- Remove private resolveCronSourceDeliveryPlan from run.ts
- Export shared resolveCronSourceDeliveryPlan from source-delivery-fallback.ts
- Keep resolveFallbackCronSourceDeliveryPlan as thin wrapper for executor
- Add CronSourceDeliveryResolvedTarget type for shared contract
- Add parity tests verifying normal path matches fallback wrapper
- All 1000 cron tests pass, autoreview clean

* fix: preserve announce fallback skip state when resolvedDelivery.ok is absent

When a stale executor artifact passes resolvedDelivery without the ok
field, the announce fallback path set skipFallbackWhenMessageToolSentToTarget
to undefined (falsy), causing the direct fallback to fire even when the
message tool already delivered — resulting in double-posted messages.

Default ok to true (skip fallback when message tool sent) so stale callers
preserve duplicate suppression. Callers that explicitly set ok=false still
get fallback delivery as intended.

Add regression test for the missing-ok announce fallback path.

---------

Co-authored-by: 忻役 <xinyi@mininglamp.com>
2026-06-28 15:45:33 -07:00
..