Skip to content

fix(cron): reject ambiguous multi-channel announce jobs - #118272

Merged
steipete merged 2 commits into
mainfrom
codex/cron-delivery-create-validation
Aug 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cron-delivery-create-validation

Conversation

@steipete

@steipete steipete commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #118236

What Problem This Solves

Fixes an issue where operators could persist isolated announce automations whose fallback delivery could never choose among multiple configured channels. The agent run would complete, but every delivery would fail later because no deterministic channel existed.

Why This Change Was Made

CronService now owns a static create/update/declarative validation gate. Gateway supplies only the current configured channel IDs, keeping cron core plugin-agnostic. The gate rejects only isolated announce jobs with an implicit last channel, no preserved session route, no provider-prefixed target, no bestEffort opt-in, and at least two configured channels. Discovery failures accept the mutation so this check cannot create false rejections.

PATCH validation runs only when delivery resolution can change (delivery, sessionTarget, agentId, or sessionKey). Existing ambiguous jobs can still be disabled or renamed. The current service type has no independent top-level channel patch field; delivery.channel is covered by the delivery gate.

The issue says creation was accepted at the cited production SHA, but that source already had a Gateway-only missing-channel preflight. That preflight was broader than the requested contract, did not exempt best-effort/session-backed cases, and did not protect direct CronService or declarative callers. This change narrows Gateway to explicit-channel validation and makes the service mutation boundary canonical.

The production delta is +85 net lines, covering the injected channel-list fact, three mutation paths, PATCH compatibility ownership, Gateway delegation, and invalid-request classification. No legacy path or duplicate service policy remains.

User Impact

On multi-channel hosts, statically ambiguous isolated announce jobs now fail immediately with configured channel IDs and actionable fixes: set --channel <id> or opt into --best-effort-deliver. Explicit channels, one-channel hosts, provider-prefixed targets, preserved session routes, and best-effort jobs continue to work.

The automation docs now explain --channel for create/edit and clarify that --best-effort-deliver permits delivery failure but does not choose a channel.

Evidence

  • pnpm install — passed (pnpm v11.15.1)
  • pnpm docs:list — passed; docs/automation/cron-jobs.md reviewed before editing
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs src/cron/service.jobs.test.ts src/gateway/server-cron.test.ts src/gateway/server-methods/cron-error-classification.test.ts — passed, 177 tests across 3 files / 2 shards
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/check-changed.mjs — passed all selected core, core-test, and docs gates, including production/test typecheck, lint, max-lines, import cycles, boundaries, and dead exports
  • git diff --check — passed
  • Codex autoreview (--mode local --engine codex --model gpt-5.6-sol --thinking high) — clean; no accepted/actionable findings, overall correctness 0.98

The first node scripts/check-changed.mjs attempt could not start Blacksmith/Testbox because the installed Crabbox client did not meet the broker version requirement and no authenticated cloud fallback was ready. Per repository trusted-source fallback policy, the same changed gate then ran locally and passed. A proposed direct-RPC test was not retained because that cheap harness does not load configured channel plugins; the real service mutation helpers and Gateway invalid-request classifier provide the relevant boundary proof without a registry mock.


Maintainer live proof (dist build, ephemeral gateway :19875, isolated state dir, telegram+slack configured)

=== ambiguous announce job rejected at creation ===
GatewayClientRequestError: invalid cron.add params: cron announce delivery requires an explicit channel when multiple channels are configured (slack, telegram): set --channel <id> or use --best-effort-deliver
=== nothing persisted ===
automations list --all --json | grep -c ambig-proof -> 0
=== explicit --channel telegram accepted ===  job created
=== --best-effort-deliver accepted ===        job created

Also: the pre-existing method-layer tests asserting implicit-announce rejection at the RPC boundary were moved to the new service owner in 64ee87a (the method layer keeps explicit-channel/prefix validation; the service validates the merged job where session-backed/best-effort shapes are visible). On the merge-risk note about accept-when-in-doubt bypasses (session-backed, provider-prefixed, best-effort): intentional static-only scope — those shapes can resolve legitimately at run time, and a false creation-time rejection is worse than a recorded late failure; the bypass predicates are each covered by tests.

@steipete
steipete marked this pull request as ready for review August 2, 2026 22:40
@steipete
steipete requested a review from a team as a code owner August 2, 2026 22:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 7:19 PM ET / 23:19 UTC.

ClawSweeper review

What this changes

The PR moves multi-channel isolated announce-job validation into CronService create, update, and declarative mutation paths, then documents when operators must choose an explicit channel.

Merge readiness

⛔ Blocked until real behavior proof is added - 7 items remain

Keep this PR open: its service-level validation still accepts generic or unknown colon-prefixed targets that cannot select a channel, so the original delayed delivery failure remains possible. The prior P1 finding is unchanged at the new head, and the PR still needs inspectable after-fix runtime proof.

Priority: P1
Reviewed head: 64ee87adbc7a68d6eef7b404bcf33b79735cc803

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has a concrete P1 correctness gap and lacks real behavior proof, despite otherwise focused automated validation.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body records tests and checks but no inspectable after-fix CLI, Gateway, or runtime output showing an ambiguous request rejected and a deterministic request accepted; add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body records tests and checks but no inspectable after-fix CLI, Gateway, or runtime output showing an ambiguous request rejected and a deterministic request accepted; add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items PR validation bypasses the real prefix contract: The proposed validation accepts any alphabetic colon prefix via a regular expression, including generic target-kind prefixes and unknown prefixes, before rejecting an ambiguous multi-channel announce job.
Current prefix resolver recognizes only plugin-owned selectors: Current main excludes generic target kinds such as channel and user, then resolves a prefix only when an active channel plugin advertises it; therefore a syntactically colon-prefixed target is not inherently deterministic.
Cron delivery planning already carries the authoritative fact: Current main derives a channel from resolveTargetPrefixedChannel and otherwise preserves the configured or last-channel route, so the proposed validator can rely on the resolved plan instead of a weaker syntax test.
Findings 1 actionable finding [P1] Use the resolved provider channel instead of any colon prefix
Security None None.

How this fits together

Cron jobs enter through CLI, Gateway, or declarative configuration and are validated by CronService before being persisted for later scheduling. Announce delivery then needs a deterministic channel from explicit delivery settings, a plugin-owned target prefix, session routing, or the configured channel set.

flowchart LR
  A[CLI, Gateway, or declarative job request] --> B[CronService mutation boundary]
  B --> C[Resolve delivery plan]
  G[Configured message channels] --> D{Deterministic channel available?}
  C --> D
  D -->|Yes| E[Persist and schedule job]
  D -->|No| F[Return actionable invalid request]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body records tests and checks but no inspectable after-fix CLI, Gateway, or runtime output showing an ambiguous request rejected and a deterministic request accepted; add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Use the resolved provider channel instead of any colon prefix (P1) - targetMaySelectChannel treats any foo: string as a deterministic provider route. resolveCronDeliveryPlan already uses resolveTargetPrefixedChannel, which recognizes only active plugin prefixes and excludes generic target kinds such as channel: and user:. Thus to: "channel:ops" or an unknown prefix bypasses this guard while the plan remains last, preserving the delayed ambiguous-delivery failure this PR intends to prevent. Remove the regex exemption or derive it from the resolved plan, and cover generic and unknown prefixes.
  • Resolve merge risk (P1) - Merging as written lets targets such as channel:ops, user:alice, or an unadvertised foo:bar bypass the create-time guard even though no provider has selected a channel; those jobs can still persist and fail only when they run.
  • Resolve merge risk (P1) - The PR has no inspectable after-fix CLI, Gateway, or runtime evidence; automated tests and CI do not demonstrate the operator-visible mutation result.
  • Complete next step (P2) - The remaining code fix is narrow, but the protected maintainer label and missing contributor-owned real behavior proof keep this in normal human-reviewed PR follow-up rather than an automated repair lane.
  • Improve patch quality - Replace the broad prefix regex with the canonical resolved-channel result and add regression coverage for generic and unknown prefixes.
  • Improve patch quality - Add a redacted CLI or Gateway transcript that shows the rejected ambiguous case and an accepted plugin-prefixed target.

Findings

  • [P1] Use the resolved provider channel instead of any colon prefix — src/cron/service/jobs-validation.ts:255
Agent review details

Security

None.

PR surface

Source +80, Tests +116, Docs +2. Total +198 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 85 5 +80
Tests 3 126 10 +116
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 213 15 +198

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #118236
Summary: This PR is the candidate fix for the canonical report, but its remaining prefix-validation defect means it does not yet resolve that report's central delayed-delivery failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Use the authoritative resolved channel (recommended)
    Remove the broad colon-prefix exemption, cover generic and unknown prefixes, and provide a redacted real mutation transcript before merge.
  2. Pause the PR
    Do not merge if the intended product contract is to accept arbitrary prefixes, because that would retain the delayed nondelivery behavior this PR claims to prevent.

Technical review

Best possible solution:

Base the exemption solely on the delivery plan’s actual plugin-resolved channel, add regression cases for generic and unknown prefixes, and attach a redacted CLI or Gateway transcript showing both rejection and a valid provider-prefixed alternative.

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

Yes, from source: creating an isolated announce job on a multi-channel host with channel: "last" and to: "channel:ops" or an unknown prefix passes the PR regex while the canonical resolver does not select a provider channel. This review did not execute the path.

Is this the best way to solve the issue?

No. The PR already computes the delivery plan through the canonical plugin-backed resolver, but then adds a weaker any-prefix heuristic that contradicts that resolver’s generic-prefix contract.

Full review comments:

  • [P1] Use the resolved provider channel instead of any colon prefix — src/cron/service/jobs-validation.ts:255
    targetMaySelectChannel treats any foo: string as a deterministic provider route. resolveCronDeliveryPlan already uses resolveTargetPrefixedChannel, which recognizes only active plugin prefixes and excludes generic target kinds such as channel: and user:. Thus to: "channel:ops" or an unknown prefix bypasses this guard while the plan remains last, preserving the delayed ambiguous-delivery failure this PR intends to prevent. Remove the regex exemption or derive it from the resolved plan, and cover generic and unknown prefixes.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P1: The patch leaves a common multi-channel announce-job path able to persist a job that later fails delivery rather than returning an actionable create-time error.
  • merge-risk: 🚨 message-delivery: The introduced broad prefix exemption can preserve delayed announce-delivery failures for existing multi-channel operators.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body records tests and checks but no inspectable after-fix CLI, Gateway, or runtime output showing an ambiguous request rejected and a deterministic request accepted; add redacted proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • PR validation bypasses the real prefix contract: The proposed validation accepts any alphabetic colon prefix via a regular expression, including generic target-kind prefixes and unknown prefixes, before rejecting an ambiguous multi-channel announce job. (src/cron/service/jobs-validation.ts:255, 64ee87adbc7a)
  • Current prefix resolver recognizes only plugin-owned selectors: Current main excludes generic target kinds such as channel and user, then resolves a prefix only when an active channel plugin advertises it; therefore a syntactically colon-prefixed target is not inherently deterministic. (src/infra/outbound/channel-target-prefix.ts:61, 15560382a2ad)
  • Cron delivery planning already carries the authoritative fact: Current main derives a channel from resolveTargetPrefixedChannel and otherwise preserves the configured or last-channel route, so the proposed validator can rely on the resolved plan instead of a weaker syntax test. (src/cron/delivery-plan.ts:52, 15560382a2ad)
  • Prior P1 finding remains at the current head: The validation file and the focused service test have identical blob IDs at the prior reviewed SHA and current PR head, so the earlier finding was neither addressed nor covered by the follow-up test commit. (src/cron/service/jobs-validation.ts:255, 64ee87adbc7a)
  • Real behavior proof is absent: The PR body reports focused tests, changed checks, and autoreview, but provides no inspectable CLI, Gateway, or runtime transcript showing the rejected ambiguous input and a valid deterministic alternative.

Likely related people:

  • steipete: Peter Steinberger authored the current-main delivery-plan and channel-selection area commit and both commits on this PR. (role: recent area contributor and feature owner; confidence: high; commits: 8729d541a9f0, 7e5321dee698, 64ee87adbc7a; files: src/cron/delivery-plan.ts, src/infra/outbound/channel-target-prefix.ts, src/cron/service/jobs-validation.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-02T22:46:28.903Z sha 7e5321d :: needs real behavior proof before merge. :: [P1] Reject non-provider target prefixes

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 2, 2026
@steipete
steipete merged commit 181da6f into main Aug 2, 2026
130 of 132 checks passed
@steipete
steipete deleted the codex/cron-delivery-create-validation branch August 2, 2026 23:25
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: multi-channel hosts accept isolated-agent cron jobs that can never deliver (no create-time channel validation)

1 participant