Skip to main content

Module roi_webhook

Module roi_webhook 

Source
Expand description

Weekly team-ROI webhook (GL #388) — posts the savings roll-up to Slack, Discord, or any generic JSON webhook once per ISO week.

Design:

  • The team server itself owns the cron (hourly tick): it already holds the savings store locally, so no control-plane round trip is needed.
  • Post-once-per-week is enforced through a tiny state file next to the savings store (roi_webhook_state.json). A failed POST does not advance the state, so the next tick retries; a week with zero reporting members posts nothing (no synthetic numbers, no noise).
  • Payload shape is detected from the URL: Slack incoming webhooks take {"text": …}, Discord webhooks take {"content": …}, anything else gets both keys so generic receivers can pick.
  • HTTPS is enforced — team.json is operator-controlled, but a webhook URL is the one field that leaves the box, so it gets the hard gate.

Functions§

spawn_weekly_roi_webhook
Spawn the weekly poster. Call once from serve_team when roiWebhookUrl is configured and validated.
state_path
Expose the state path for ops/debugging (lean-ctx team … status later).
validate_webhook_url
Validate the webhook URL at boot: HTTPS only.