Skip to content

test(cron): add delivery regressions and sync docs#411

Merged
penso merged 4 commits intomainfrom
issue-195-and-264
Mar 14, 2026
Merged

test(cron): add delivery regressions and sync docs#411
penso merged 4 commits intomainfrom
issue-195-and-264

Conversation

@penso
Copy link
Copy Markdown
Collaborator

@penso penso commented Mar 11, 2026

Summary

Closes #195
Closes #264

Validation

Completed

  • just format
  • cargo test -p moltis-tools delivery_fields -- --nocapture
  • cargo test -p moltis-cron test_deliver_ -- --nocapture

Remaining

  • cargo test -p moltis-gateway maybe_deliver_cron_output_ -- --nocapture (stopped after exceeding the repo's 5-minute command limit while compiling heavy gateway dependencies)

Manual QA

  1. Create or edit an isolated cron job with deliver=true, channel=<account_id>, and to=<chat_id>, then confirm the saved job retains those fields.
  2. Trigger a delivered cron job and verify the final agent output is posted to the configured destination chat.
  3. Open Settings -> Heartbeat and confirm the delivery controls match the documented deliver/channel/to behavior.
  4. In a channel-bound session, inspect the raw prompt/runtime context and confirm surface, session_kind, and channel identifiers are present.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 11, 2026

Greptile Summary

This PR adds regression tests for the cron delivery pipeline (deliver/channel/to fields on both add and update flows), refactors the inline delivery block in prepare_gateway into a small maybe_deliver_cron_output helper with its own unit tests, and syncs the scheduling, channels, and system-prompt docs with the current shipped behavior.

Key changes:

  • crates/gateway/src/server.rs: Extracts channel-delivery logic into maybe_deliver_cron_output; refactoring is logically equivalent to the original. Two new async tests cover the happy path (sends to channel) and blank-text skip, but the deliver=false and outbound=None branches are not yet exercised.
  • crates/tools/src/cron_tool.rs: Two new regression tests confirm that deliver, channel, and to round-trip correctly through both add and update in the cron tool.
  • docs/src/scheduling.md: Corrects heartbeat default interval (15 → 30 min, matching crates/cron/src/heartbeat.rs), fixes cron schedule field name (cron_exprexpr/tz, matching CronSchedule::Cron), adds the run action, and introduces a Channel Delivery section with a worked example. The Session Targeting table now accurately reflects the Main/Isolated/Named enum variants; the named("<name>") row is marked "Internal" but does not explicitly state it is not user-configurable via the cron tool.
  • docs/src/channels.md and docs/src/system-prompt.md: Doc-only additions covering proactive outbound messaging patterns and channel-bound session metadata; no issues found.

Confidence Score: 4/5

  • Safe to merge; the gateway refactoring is behaviorally equivalent to the original, and the test and doc gaps are minor style-level items.
  • The core refactoring is a straightforward extraction with no logic change, backed by regression tests for the main delivery path. The only gaps are missing test coverage for two maybe_deliver_cron_output branches (deliver=false and outbound=None) and a minor docs ambiguity around the named(...) session target. Neither poses a runtime risk.
  • crates/gateway/src/server.rs — worth adding the two missing branch tests before the gateway test suite is run fully (PR notes it couldn't run due to compile time).

Important Files Changed

Filename Overview
crates/gateway/src/server.rs Extracts inline delivery logic into maybe_deliver_cron_output helper and adds two unit tests; refactoring is logically equivalent to original, but deliver=false and outbound=None branches in the helper are not covered by the new tests.
crates/tools/src/cron_tool.rs Adds two regression tests confirming that deliver, channel, and to round-trip correctly through the add and update flows; no functional code changes.
docs/src/scheduling.md Corrects heartbeat interval (15→30 min), updates cron schedule field name (cron_exprexpr/tz), adds run action, adds Channel Delivery section, and expands Session Targeting table — the named("<name>") row is internal-only but not explicitly flagged as non-user-configurable.
docs/src/channels.md Adds a new "Proactive Outbound Messaging" section documenting send_message, cron delivery, and heartbeat delivery patterns with a concrete JSON example; no issues found.
docs/src/system-prompt.md Documents channel-bound session context metadata (surface, session_kind, channel identifiers) in the runtime context section; doc-only change with no issues.

Sequence Diagram

sequenceDiagram
    participant Scheduler as Cron Scheduler
    participant Gateway as Gateway (server.rs)
    participant Agent as Agent Runner
    participant Helper as maybe_deliver_cron_output
    participant Channel as ChannelOutbound

    Scheduler->>Gateway: AgentTurnRequest (deliver, channel, to)
    Gateway->>Agent: run isolated agent turn
    Agent-->>Gateway: AgentTurnResult (text)
    Gateway->>Gateway: strip heartbeat token (if heartbeat turn)
    Gateway->>Helper: maybe_deliver_cron_output(outbound, req, delivery_text)
    alt deliver=false OR text is blank
        Helper-->>Gateway: return (skip)
    else channel/to missing
        Helper-->>Gateway: return (skip)
    else outbound not configured
        Helper->>Helper: tracing::debug!(...)
        Helper-->>Gateway: return (skip)
    else all conditions met
        Helper->>Channel: send_text(channel_account, chat_id, text)
        Channel-->>Helper: Ok(()) or Err(e)
        alt Err
            Helper->>Helper: tracing::warn!(error)
        end
        Helper-->>Gateway: return
    end
    Gateway-->>Scheduler: AgentTurnResult { output: text }
Loading

Last reviewed commit: 08550ba

Comment thread crates/gateway/src/server.rs
Comment thread docs/src/scheduling.md
@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented Mar 11, 2026

Merging this PR will degrade performance by 21.33%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 38 untouched benchmarks
⏩ 5 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
env_substitution 10 µs 12.7 µs -21.33%

Comparing issue-195-and-264 (6bd83f9) with main (d43261b)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 92.50000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/gateway/src/server.rs 92.50% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@penso penso merged commit adaa74e into main Mar 14, 2026
34 of 35 checks passed
@penso penso deleted the issue-195-and-264 branch March 14, 2026 17:01
penso added a commit that referenced this pull request Mar 23, 2026
* test(cron): add delivery regressions and sync docs

* fix(cron): address PR review feedback

* test(web-ui): stabilize voice fallback websocket e2e
jmikedupont2 pushed a commit to meta-introspector/moltis that referenced this pull request Mar 23, 2026
* test(cron): add delivery regressions and sync docs

* fix(cron): address PR review feedback

* test(web-ui): stabilize voice fallback websocket e2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant