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.jsonis 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_teamwhenroiWebhookUrlis configured and validated. - state_
path - Expose the state path for ops/debugging (
lean-ctx team … statuslater). - validate_
webhook_ url - Validate the webhook URL at boot: HTTPS only.