diff --git a/internal/server/server.go b/internal/server/server.go index fdbbf98..851486f 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -3917,11 +3917,14 @@ func (s *Server) ensureCouncilAgentStatusConstraint(ctx context.Context) error { // triggerTeamCompositionForCouncil starts team composition for the task linked to the council func (s *Server) triggerTeamCompositionForCouncil(ctx context.Context, councilID uuid.UUID) error { - // Look up the task associated with this council. For now we assume the task ID matches the council ID. - // Future work could store an explicit mapping in the database. - taskID := councilID.String() + // Look up the task associated with this council from the database + var taskID uuid.UUID + err := s.db.Pool.QueryRow(ctx, "SELECT task_id FROM councils WHERE id = $1", councilID).Scan(&taskID) + if err != nil { + return fmt.Errorf("failed to get task_id for council: %w", err) + } - log := zerolog.Ctx(ctx).With().Str("council_id", councilID.String()).Str("task_id", taskID).Logger() + log := zerolog.Ctx(ctx).With().Str("council_id", councilID.String()).Str("task_id", taskID.String()).Logger() log.Info().Msg("🔁 Triggering team composition for council-linked task") // Reuse the monitor's capability to run team composition if available. @@ -3931,7 +3934,7 @@ func (s *Server) triggerTeamCompositionForCouncil(ctx context.Context, councilID } // Use the monitor's helper so the same logic runs as for bzzz-task issues. - go s.repoMonitor.TriggerTeamCompositionForCouncil(ctx, taskID) + go s.repoMonitor.TriggerTeamCompositionForCouncil(ctx, taskID.String()) return nil }