Repository navigation
fix(cron): report unusable cron delivery targets at resolution time - #217
Conversation
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]>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
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
normalizedpassthrough, (2) the channel declares alooksLikeIdgrammar, 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 intarget-normalization.ts. unknownTargetErroris 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.
…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]>
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]>
…#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]>
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 isa 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:
— core-injected conversation ids must still be forwarded even when a plugin's
looksLikeIddisowns them (message-action-runner.send-validation.test.ts).unknownTargetMode: "error"outright broke 36 crontests; 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
looksLikeIdgrammar 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 targeterror and its hint atdelivery-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.
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/cronat1174 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 andthe Crabbox binary fails its
--version/--helpsanity check in thisenvironment. 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.
looksLikeIdgrammar disowns the value; directory-resolved, plugin-resolved targets, and channels with no grammar are unaffected.threadId required (contract v3)failure.Written for commit ab9df28. Summary will update on new commits.