# Disable Per-Ticket Feishu Notifications

## Current Design

- Worker terminal outcomes call `notifyAutoAnalysisCompleted` once per ticket.
- Daily/weekly reports call `notifyAutoOncallReport`.
- Recent Evaluation calls `notifyRecentOptimizerCompleted`.
- All three methods share one Feishu sink and one global
  `AUTO_ONCALL_LARK_NOTIFY_ENABLED` switch, so disabling that switch would also
  disable report and Recent Evaluation messages.
- `deploy/app-delivery/` is the deployment source template. The live pod reads
  the resulting ConfigMap values.

## Risks

- Reusing the global switch would silence required aggregate notifications.
- A default-off code change would unexpectedly alter environments that have not
  opted into the new behavior.
- A template-only change without runtime support would have no effect.

## Target Contract

- `AUTO_ONCALL_LARK_NOTIFY_ENABLED` remains the global Feishu delivery gate.
- `AUTO_ONCALL_LARK_TICKET_NOTIFY_ENABLED=false` suppresses only
  `notifyAutoAnalysisCompleted` delivery.
- When the ticket switch is absent, per-ticket delivery remains enabled for
  backward compatibility.
- Daily/weekly reports and Recent Evaluation notifications continue to use the
  existing sink, credentials, target chat, and idempotency contracts.
- Jira writes, worker/job state, report generation, and Feishu Base projection
  are unchanged. Notification reads never mutate canonical state.

## Implementation Steps

1. Add the ticket-specific switch at the notification sink boundary.
2. Add a local contract test proving ticket delivery is suppressed while report
   and Recent Evaluation delivery still work.
3. Document the new switch and configure it as `false` in both staging and prod
   app-delivery source templates.
4. Render both kustomizations and run the notification tests and full suite.
5. Publish the source change, sync app-delivery, then verify the live pod env and
   the absence of new per-ticket messages without using message absence alone as
   rollout proof.

## Verification Checklist

- [x] Ticket notification with the new switch disabled performs no Feishu API
      request.
- [x] Daily/weekly report notification still sends.
- [x] Recent Evaluation notification still sends.
- [x] Existing behavior is preserved when the new switch is absent.
- [x] Staging and prod rendered ConfigMaps contain the explicit disabled value.
- [x] TypeScript build and full Node test suite pass.
- [ ] app-delivery source and live pod env agree after rollout.

## Non-Goals

- Do not disable daily/weekly reports, Recent Evaluation messages, Feishu Base,
  Feishu directory lookups, Jira comments, polling, or worker execution.
- Do not add a fallback notification channel or make read paths clean up sent
  messages.
- Do not delete historical Feishu messages.
