@@ -57,15 +57,15 @@ type Coordinator struct {
5757
5858// StateStore interface for persistent state - allows dependency injection for testing.
5959type StateStore interface {
60- Thread (owner , repo string , number int , channelID string ) (cache.ThreadInfo , bool )
61- SaveThread (owner , repo string , number int , channelID string , info cache.ThreadInfo ) error
62- LastDM (userID , prURL string ) (time.Time , bool )
63- RecordDM (userID , prURL string , sentAt time.Time ) error
64- ListDMUsers (prURL string ) []string
65- WasProcessed (eventKey string ) bool
66- MarkProcessed (eventKey string , ttl time.Duration ) error
67- LastNotification (prURL string ) time.Time
68- RecordNotification (prURL string , notifiedAt time.Time ) error
60+ Thread (ctx context. Context , owner , repo string , number int , channelID string ) (cache.ThreadInfo , bool )
61+ SaveThread (ctx context. Context , owner , repo string , number int , channelID string , info cache.ThreadInfo ) error
62+ LastDM (ctx context. Context , userID , prURL string ) (time.Time , bool )
63+ RecordDM (ctx context. Context , userID , prURL string , sentAt time.Time ) error
64+ ListDMUsers (ctx context. Context , prURL string ) []string
65+ WasProcessed (ctx context. Context , eventKey string ) bool
66+ MarkProcessed (ctx context. Context , eventKey string , ttl time.Duration ) error
67+ LastNotification (ctx context. Context , prURL string ) time.Time
68+ RecordNotification (ctx context. Context , prURL string , notifiedAt time.Time ) error
6969 Close () error
7070}
7171
@@ -118,13 +118,13 @@ func New(
118118
119119// saveThread persists thread info to both cache and persistent storage.
120120// This ensures threads survive restarts and are available for closed PR updates.
121- func (c * Coordinator ) saveThread (owner , repo string , number int , channelID string , info cache.ThreadInfo ) {
121+ func (c * Coordinator ) saveThread (ctx context. Context , owner , repo string , number int , channelID string , info cache.ThreadInfo ) {
122122 // Save to in-memory cache for fast lookups
123123 key := fmt .Sprintf ("%s/%s#%d:%s" , owner , repo , number , channelID )
124124 c .threadCache .Set (key , info )
125125
126126 // Persist to state store for cross-instance sharing and restart recovery
127- if err := c .stateStore .SaveThread (owner , repo , number , channelID , info ); err != nil {
127+ if err := c .stateStore .SaveThread (ctx , owner , repo , number , channelID , info ); err != nil {
128128 slog .Warn ("failed to persist thread to state store" ,
129129 "pr" , fmt .Sprintf ("%s/%s#%d" , owner , repo , number ),
130130 "channel_id" , channelID ,
@@ -196,7 +196,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
196196 "current_message_preview" , initialSearchText [:min (100 , len (initialSearchText ))])
197197
198198 // Save the found thread (cache + persist)
199- c .saveThread (owner , repo , prNumber , channelID , cache.ThreadInfo {
199+ c .saveThread (ctx , owner , repo , prNumber , channelID , cache.ThreadInfo {
200200 ThreadTS : initialSearchTS ,
201201 ChannelID : channelID ,
202202 LastState : prState ,
@@ -272,7 +272,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
272272 "note" , "this prevented duplicate thread creation during rolling deployment" )
273273
274274 // Save it and return (cache + persist)
275- c .saveThread (owner , repo , prNumber , channelID , cache.ThreadInfo {
275+ c .saveThread (ctx , owner , repo , prNumber , channelID , cache.ThreadInfo {
276276 ThreadTS : crossInstanceCheckTS ,
277277 ChannelID : channelID ,
278278 LastState : prState ,
@@ -295,7 +295,7 @@ func (c *Coordinator) findOrCreatePRThread(ctx context.Context, channelID, owner
295295 }
296296
297297 // Save the new thread (cache + persist)
298- c .saveThread (owner , repo , prNumber , channelID , cache.ThreadInfo {
298+ c .saveThread (ctx , owner , repo , prNumber , channelID , cache.ThreadInfo {
299299 ThreadTS : newThreadTS ,
300300 ChannelID : channelID ,
301301 LastState : prState ,
@@ -925,7 +925,7 @@ func (c *Coordinator) updateDMMessagesForPR(ctx context.Context, pr prUpdateInfo
925925
926926 // For terminal states (merged/closed), update all users who received DMs
927927 if prState == "merged" || prState == "closed" {
928- slackUserIDs = c .stateStore .ListDMUsers (prURL )
928+ slackUserIDs = c .stateStore .ListDMUsers (ctx , prURL )
929929 if len (slackUserIDs ) == 0 {
930930 slog .Debug ("no DM recipients found for merged/closed PR" ,
931931 "pr" , fmt .Sprintf ("%s/%s#%d" , owner , repo , prNumber ),
@@ -983,8 +983,7 @@ func (c *Coordinator) updateDMMessagesForPR(ctx context.Context, pr prUpdateInfo
983983 slog .Info ("no analysis available - using state-based emoji fallback" ,
984984 "pr" , fmt .Sprintf ("%s/%s#%d" , owner , repo , prNumber ),
985985 "pr_state" , prState )
986- //nolint:staticcheck // deprecated method kept for backward compatibility
987- prefix = notify .PrefixForState (prState )
986+ prefix = notify .PrefixForAnalysis ("" , nil )
988987 }
989988 var action string
990989 switch prState {
@@ -1216,6 +1215,8 @@ func (c *Coordinator) processChannelsInParallel(
12161215
12171216// processPRForChannel handles PR processing for a single channel (extracted from the main loop).
12181217// Returns a map of Slack user IDs that were successfully tagged in this channel.
1218+ //
1219+ //nolint:maintidx // Core PR processing logic with necessary complexity for handling notifications
12191220func (c * Coordinator ) processPRForChannel (
12201221 ctx context.Context , prCtx prContext , channelName , workspaceID string ,
12211222) map [string ]bool {
@@ -1385,7 +1386,7 @@ func (c *Coordinator) processPRForChannel(
13851386 "next_poll_in" , "5m" )
13861387 } else {
13871388 // Save updated thread info (cache + persist)
1388- c .saveThread (owner , repo , prNumber , channelID , cache.ThreadInfo {
1389+ c .saveThread (ctx , owner , repo , prNumber , channelID , cache.ThreadInfo {
13891390 ThreadTS : threadTS ,
13901391 ChannelID : channelID ,
13911392 LastState : prState ,
0 commit comments