4.1 KiB
4.1 KiB
summary, owner, status, last_updated
| summary | owner | status | last_updated |
|---|---|---|---|
| Harden cron.add input handling, align schemas, and improve cron UI/agent tooling | clawdbot | complete | 2026-01-05 |
Cron Add Hardening & Schema Alignment
Context
Recent gateway logs show repeated cron.add failures with invalid parameters (missing sessionTarget, wakeMode, payload, and malformed schedule). This indicates that at least one client (likely the agent tool call path) is sending wrapped or partially specified job payloads. Separately, there is drift between cron provider enums in TypeScript, gateway schema, CLI flags, and UI form types, plus a UI mismatch for cron.status (expects jobCount while gateway returns jobs).
Goals
- Stop
cron.addINVALID_REQUEST spam by normalizing common wrapper payloads and inferring missingkindfields. - Align cron provider lists across gateway schema, cron types, CLI docs, and UI forms.
- Make agent cron tool schema explicit so the LLM produces correct job payloads.
- Fix the Control UI cron status job count display.
- Add tests to cover normalization and tool behavior.
Non-goals
- Change cron scheduling semantics or job execution behavior.
- Add new schedule kinds or cron expression parsing.
- Overhaul the UI/UX for cron beyond the necessary field fixes.
Findings (current gaps)
CronPayloadSchemain gateway excludessignal+imessage, while TS types include them.- Control UI CronStatus expects
jobCount, but gateway returnsjobs. - Agent cron tool schema allows arbitrary
jobobjects, enabling malformed inputs. - Gateway strictly validates
cron.addwith no normalization, so wrapped payloads fail.
Proposed Approach
- Normalize incoming
cron.addpayloads (unwrapdata/job, inferschedule.kindandpayload.kind, defaultwakeMode+sessionTargetwhen safe). - Harden the agent cron tool schema using the canonical gateway
CronAddParamsSchemaand normalize before sending to the gateway. - Align provider enums and cron status fields across gateway schema, TS types, CLI descriptions, and UI form controls.
- Test normalization in gateway tests and tool behavior in agent tests.
Multi-phase Execution Plan
Phase 1 — Schema + type alignment
- Expand gateway
CronPayloadSchemaprovider enum to includesignalandimessage. - Update CLI
--providerdescriptions to includeslack(already supported by gateway). - Update UI Cron payload/provider union types to include all supported providers.
- Fix UI CronStatus type to match gateway (
jobsinstead ofjobCount). - Update cron UI provider select to include Discord/Slack/Signal/iMessage.
- Update macOS CronJobEditor provider picker + enum to include Slack/Signal/iMessage.
- Document cron compatibility normalization policy in
docs/cron.md.
Phase 2 — Input normalization + tooling hardening
- Add shared cron input normalization helpers (
normalizeCronJobCreate/normalizeCronJobPatch). - Apply normalization in gateway
cron.add(and patch normalization incron.update). - Tighten agent cron tool schema to
CronAddParamsSchemaand normalize job/patch before sending.
Phase 3 — Tests
- Add gateway test covering wrapped
cron.addpayload normalization. - Add cron tool test to assert normalization and defaulting for
cron.add. - Add gateway test covering
cron.updatenormalization. - Add UI + Swift conformance test for cron channels + status fields.
Phase 4 — Verification
- Run tests (full suite executed via
pnpm test -- cron-tool).
Rollout/Monitoring
- Watch gateway logs for reduced
cron.addINVALID_REQUEST errors. - Confirm Control UI cron status shows job count after refresh.
- If errors persist, extend normalization for additional common shapes (e.g.,
schedule.at,payload.messagewithoutkind).
Optional Follow-ups
- Manual Control UI smoke: add cron job per provider + verify status job count.
Open Questions
- Should
cron.addaccept explicitstatefrom clients (currently disallowed by schema)? - Should we allow
webchatas an explicit delivery provider (currently filtered in delivery resolution)?