---
id: w3/m9/t002
title: Hook into the deploy-status transition path (`w2/m5`) to fire notifications on success/failure
worker: worker3
status: todo
estimate: 45m
depends_on: [w3/m9/t001]
---

## Objective

Trigger a notification event whenever a deploy's status transitions to success or failure, using the settings from t001.

## Context

- `lego/backend/internal/deploys/` — deploy object lifecycle shipped in `w2/m5`; find where deploy status is written/transitioned.

## Steps

1. Locate the deploy-status write path (likely in `internal/deploys/` or wherever the reconciler/webhook updates deploy status).
2. Add a hook that checks the owning workspace's `notification_settings` and, if enabled for that event, enqueues/fires a notification.
3. Keep this synchronous-but-non-blocking: a notification failure must not fail the deploy-status write itself.

## Files

- `lego/backend/internal/deploys/`
- `lego/backend/internal/notifications/`

## Acceptance criteria

- [ ] A deploy transitioning to success/failure fires exactly one notification event when enabled, zero when disabled.
- [ ] A notification-delivery failure does not roll back or fail the deploy-status write.

## Out of scope

- Retry/backoff queueing for notification delivery — best-effort is acceptable for v1.
