How exactly does user_id work and what is the difference between the top level user_id and the ones in identities?

I just added this to my rule to this and it works! But is this the right way to do it?

context.accessToken[namespace + "uuid"] = user.app_metadata.uuid;