Skip to content

fix(cron): report unusable cron delivery targets at resolution time - #217

Merged
holywend merged 1 commit into
boonfrom
wendy/eng-18097/cron-delivery-target-validation
Sep 11, 2026
Merged

holywend merged 1 commit into
boonfrom
wendy/eng-18097/cron-delivery-target-validation

Conversation

@holywend

@holywend holywend commented Sep 11, 2026 •

Copy link
Copy Markdown

Related: ENG-18097 (Linear)

What Problem This Solves

Fixes an issue where an operator whose cron job has a delivery target that the
channel cannot actually address would see no notification at all, and an error
that blamed the wrong subsystem.

On a channel with no directory, the only valid target is that channel's own
conversation id. An operator-typed email address configured as a cron delivery
target was nonetheless accepted, forwarded unresolved, and only failed much
later inside the outbound adapter — against an unrelated thread-id contract
check. The reported error therefore named the thread contract rather than the
misconfigured target, and the delivery never arrived.

Observed in production: one cron's failure-notification lane failed this way on
most working days for ten days (~57 captured failures, each paired with an
exhausted delivery-recovery attempt). Because the lane being black-holed was the
failure lane, nobody saw any of it.

Why This Change Was Made

Cron delivery resolution passed unknownTargetMode: "normalized". That mode is
a deliberate trust exemption for targets core supplies itself — an id core
inferred from a live conversation. A cron delivery target is not that: it is
operator-typed config, and behaves like an agent-supplied target, which already
resolves strictly.

Two broader fixes were tried and rejected, both caught by existing tests:

  • Applying the check inside the shared resolver broke the tool-context contract
    — core-injected conversation ids must still be forwarded even when a plugin's
    looksLikeId disowns them (message-action-runner.send-validation.test.ts).
  • Switching cron delivery to unknownTargetMode: "error" outright broke 36 cron
    tests; many valid delivery targets legitimately rely on the passthrough.

The surviving rule is deliberately narrow: reject only when the resolver fell
through to a normalized passthrough and the channel declares a looksLikeId
grammar that disowns the value. Directory-resolved targets, plugin-resolved
targets, and channels that declare no grammar all keep today's behaviour.

Non-goal: this does not make the message reachable. A target that a channel
cannot address is a configuration problem; this change only makes that failure
name itself correctly, at the point where it can be understood.

User Impact

Operators get the channel's own Unknown target error and its hint at
delivery-resolution time — naming the real problem — instead of a misleading
downstream contract error that repeats on every cron run. Correctly configured
deliveries are unaffected.

Evidence

Two tests added in src/cron/isolated-agent/delivery-target.runtime.test.ts:
one that a disowned target is rejected with the channel's hint, one that a
target the grammar accepts is still forwarded.

pnpm test src/cron             112 files, 1176 passed
pnpm test src/infra/outbound    36 files,  712 passed
pnpm tsgo                       clean
oxfmt --check / oxlint          clean

Both new tests were verified to fail with the production change reverted, so
neither passes vacuously. (An earlier draft of these tests passed for the wrong
reason — the harness was not wiring the plugin, so the resolver saw no plugin at
all and rejected everything. That version was discarded.)

Baseline comparison for the rejected "error" approach: pnpm test src/cron at
1174 passed / 1 failed (fix stashed) versus 37 failures with blanket strictness
— which is what narrowed the rule to its current form.

Not run: pnpm check:changed. It delegates to remote Blacksmith Testbox and
the Crabbox binary fails its --version/--help sanity check in this
environment. This still needs a real Testbox run before merge.


Summary by cubic

Fixes cron delivery target validation so a misconfigured target fails at resolution time with the channel's own "Unknown target" error, instead of passing through unresolved and failing later inside the outbound adapter against an unrelated thread-id contract check. Previously an operator-typed email on a directory-less channel was silently accepted, never delivered, and produced a misleading error that repeated on every cron run.

  • Rejects only when resolution falls through to a normalized passthrough and the channel's looksLikeId grammar disowns the value; directory-resolved, plugin-resolved targets, and channels with no grammar are unaffected.
  • Adds two tests: one rejects a disowned target with the channel's hint, one forwards a target the grammar accepts.
  • The fix names the misconfiguration; it does not make an unaddressable target deliverable.
  • Relates to ENG-18097, where this misconfiguration surfaced as a threadId required (contract v3) failure.

Written for commit ab9df28. Summary will update on new commits.

Review in cubic

Cron delivery resolution passed unknownTargetMode: "normalized", so a
delivery target that matched neither the channel's grammar nor its directory
was forwarded verbatim. On a directory-less channel an operator-typed email
then reached the outbound adapter and failed a downstream thread-id contract
check, naming the wrong subsystem and repeating on every run.

Reject only the case that is unambiguously a misconfiguration: the resolver
fell through to a normalized passthrough AND the channel declares a
looksLikeId grammar that disowns the value. Directory- and plugin-resolved
targets, and channels that declare no grammar, keep today's behaviour.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@holywend
holywend requested a review from a team September 11, 2026 15:16
@claude

claude Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — clean, well-scoped fix. Notes:

What it does: When a cron delivery target falls through to the normalized passthrough and the channel's looksLikeId grammar disowns the value, the misconfiguration is now surfaced as the channel's own Unknown target error at resolution time — instead of leaking downstream as a misleading threadId required (contract v3) failure.

Why the fix is correct:

  • The guard fires only when all three conditions hold: (1) resolution fell through to normalized passthrough, (2) the channel declares a looksLikeId grammar, and (3) that grammar rejects the input. This is deliberately narrow — directory-resolved targets, plugin-resolved targets, and channels with no grammar are untouched.
  • The two-arg looksLikeId(params.input, resolved.target.to) call matches the existing contract used in target-normalization.ts.
  • unknownTargetError is the shared helper already used by the target resolver itself, so the error message shape is consistent with the rest of the outbound stack.

Tests: Two tests covering the positive and negative cases, with the mock wiring a looksLikeId grammar that accepts thread-style ids and rejects emails — correctly exercising both branches. The PR description notes both tests were verified to fail with the change reverted.

CI: Security, CodeQL, contracts, boundaries all green. build-artifacts and a few cron/runtime shards still in progress but unrelated to the changed paths. pnpm check:changed (Testbox) noted as not-run — that should still complete before merge.

No blocking issues. Ship it.

@holywend
holywend enabled auto-merge (squash) September 11, 2026 15:32
@holywend
holywend merged commit c1dc7bc into boon Sep 11, 2026
147 of 148 checks passed
@holywend
holywend deleted the wendy/eng-18097/cron-delivery-target-validation branch September 11, 2026 15:34
Willi8910 added a commit that referenced this pull request Sep 14, 2026
…218)

Carries #210 (PDF fallback partial-read reporting) and #217 / ENG-18097
(cron delivery targets the channel disowns are rejected at resolution
time). Lockstep regenerated via `pnpm release:prep` — 208 files.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
convyusboy added a commit that referenced this pull request Oct 15, 2026
Related: ENG-21405 (Linear)

Adds an end-to-end regression test driving the real resolveDeliveryTarget
path against a faithful copy of anychat-boon-web's actual target grammar
(looksLikeId-only, no directory, no resolveTarget) with the exact email
from ENG-21405 ("[email protected]"), for both an explicit
delivery target and a session-inherited one.

Both are correctly rejected with "Unknown target" on current main. This
confirms PR #217's cron-resolver guard (ENG-18097) already covers this
shape of misconfiguration end-to-end, not just the narrow function its
own unit test exercises. Written during ENG-21405's investigation, which
root-caused the live Sentry errors (OPENCLAW-FLEET-10E/10F) to a stale
anychat-boon-web plugin install (v0.0.9-alpha, predating this guard
entirely) plus a misconfigured cron job on one customer box, not a core
code gap — this test documents that the resolver itself already behaves
correctly.

Co-Authored-By: Claude Opus 5 <[email protected]>
convyusboy added a commit that referenced this pull request Oct 15, 2026
…#294)

Related: ENG-21405 (Linear)

Adds an end-to-end regression test driving the real resolveDeliveryTarget
path against a faithful copy of anychat-boon-web's actual target grammar
(looksLikeId-only, no directory, no resolveTarget) with the exact email
from ENG-21405 ("[email protected]"), for both an explicit
delivery target and a session-inherited one.

Both are correctly rejected with "Unknown target" on current main. This
confirms PR #217's cron-resolver guard (ENG-18097) already covers this
shape of misconfiguration end-to-end, not just the narrow function its
own unit test exercises. Written during ENG-21405's investigation, which
root-caused the live Sentry errors (OPENCLAW-FLEET-10E/10F) to a stale
anychat-boon-web plugin install (v0.0.9-alpha, predating this guard
entirely) plus a misconfigured cron job on one customer box, not a core
code gap — this test documents that the resolver itself already behaves
correctly.

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants