TypeSet is not picking up correct changes

In your Update function you can call either d.Get("role") to get a data structure representing all of the blocks in the new configuration or d.GetChange("role") to get both the old blocks (from the prior state) and the new blocks (from the configuration) at once.

Once you have that data structure you can process it in any way you need. One way you could do it is to iterate over the set and transform the two d.GetChange values into a single map containing the old and new values for each distinct name value. I don’t have a real provider handy to test this right now so the following probably isn’t completely right but hopefully it’s some useful pseudocode:

type RoleChange struct {
    Old, New map[string]interface{}
}

o, n := d.GetChange("role")
vals := make(map[string]*RoleChange)
for _, raw := range o.(*schema.Set).List() {
    obj := raw.(map[string]interface{})
    k := obj["name"].(string)
    vals[k] = &Change{ Old: obj }
}
for _, raw := range o.(*schema.Set).List() {
    obj := raw.(map[string]interface{})
    k := obj["name"].(string)
    if _, ok := vals[k]; !ok {
        vals[k] = &Change{}
    }
    vals[k].New = obj
}

for name, change := range vals {
    // A few different situations to deal with in here:
    // - change.Old is nil: create a new role
    // - change.New is nil: remove an existing role
    // - both are set: test if New is different than Old and update if not
}

For this I’m assuming that yours is an API where adding, removing, and updating individual roles for a project are all distinct operations from adding, removing, and updating the project itself, and so you’d presumably be doing an API operation within each iteration of that last loop I included above as a placeholder. If your API just treats roles as a directly property of projects, writing all of them together as part of create/update on the project object, then you probably wouldn’t need anything like this because you can just use the d.Get("role") result directly to populate the new set of roles, without worrying about the old values.