Add notification digests with ON CONFLICT DO UPDATE, migrations 00068-00070, supplementimpact module (analyze → confirm → claim-aware split), and wire coordinator/mutate hooks plus proposal_required digests.
29 lines
855 B
Go
29 lines
855 B
Go
package supplementimpact
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"time"
|
|
)
|
|
|
|
// TriggerAsync kicks CreateFromSupplement in a background goroutine with panic recovery
|
|
// so chat / mutate paths are never blocked by impact analysis.
|
|
func TriggerAsync(svc *Service, projectID, userID int64, sessionID, summary, markdown string) {
|
|
if svc == nil {
|
|
return
|
|
}
|
|
go func() {
|
|
defer func() {
|
|
if rec := recover(); rec != nil {
|
|
slog.Error("supplementimpact: TriggerAsync panic", "recover", rec, "project_id", projectID)
|
|
}
|
|
}()
|
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
|
defer cancel()
|
|
if _, err := svc.CreateFromSupplement(ctx, projectID, userID, sessionID, summary, markdown); err != nil {
|
|
slog.Warn("supplementimpact: CreateFromSupplement failed",
|
|
"project_id", projectID, "user_id", userID, "error", err)
|
|
}
|
|
}()
|
|
}
|