It would probably fit to make it based on unit type so
for example
Soldier units:+2 str highest affinity OR +3 str second highest affinity (whichever is more.)
Battlesuits: +5 str/Purity
Then remove a lot of the str from the upgrades themselves (the upgrades would be more Perks)
The complication would be ranged upgrades that have 2x attack instead of a ranged strength bonus... for those, just give them a x2 and penalty to ranged strength. (the generic bonus would still apply)
I love your idea! Might I add that there should be more upgrades and more units?
I think each of the 6 Affinities should get 5 tiers of units (there is a thread on that somewhere). I also think that there should be more upgrades for all units. The aircraft (Tacjets), submarines, and carriers should get Tier 5 upgrades (such as Evolved Shrike at 18H and Prime Shroud at 16S) and hybrid upgrades but the lower tiers should be weaker and Tier 5 should only be moderately stronger than current Tier 4 (such that the Prime Shroud has 45 Strength and 50 Ranged Strength). The explorers (I've seen a good thread on that) should get 4 Tiers. The Unique Affinity Units should also get 2 upgrades with the first upgrade for different affinities getting the hybrid term (Battle Suits to True, Master, or First Battle Suits) and the 2nd upgrade called the normal upgrades (so Master to Prime and First to Evolved) unless they have even higher main affinity then it gets Ultra appended (Ultra True Battle Suits, Ultra Master Battle Suits, Ultra First Battle Suits). Straight-line affinity upgrades should be stronger than the first hybrid upgrades (so the Master Battle Suits (40) should be weaker than the current Prime Battle Suits) but weaker than the 2nd hybrid upgrades (so the new Prime Battle Suits should be slightly stronger (70) than they are now). Ultra upgrades should be at the strength of current Tier 2 upgrades (66 for Ultra Battle Suits) but the new straight Tier 2 upgrades should be weaker (55 for Pure Battle Suits). If my idea for changing Affinity costs is added then you can get an Ultra True Lev Destroyer (Purity 20), an Ultra Prime ANGEL (Supremacy 20), or an Ultra Evolved Xeno Titan (Harmony 20) easier than a Prime Lev Destroyer (16P/10S), Evolved ANGEL (16S/10H), or True Xeno Titan (16H/10P).
Of course the strength numbers I'm suggesting are relative to the current mod-free SM CivBERT without your (passive) affinity perk or the Affinity Ideology tenet perk in the equation. The numbers would be different, with the base numbers for the upgrades much lower than the base number for the base units but the ratio of strength for the affinity upgrades of Tiers 2 & 3 should be around my provided ratio (I added the quantitative numbers after being confused with my own qualitative descriptions). Purity Affinity perks and upgrades should focus on strength while defending, within borders, and against aliens. Supremacy Affinity perks and upgrades should focus on strength while flanking, outside borders, and against stronger units. Harmony Affinity perks and upgrade should focus on miasma (reduced harm, then immunity, then increased healing, then increased strength and mobility from miasma), defending against stronger units (no bonus against weaker units, such as aliens, or when initiating attack), and movement (hills and rivers treated like plains (like hover units get), forests treated like roads (like Shoshone got)). I also want to see the passive affinity perks for level 1 vanilla CivBE divided across 1 and 2 (so Harmony 1 grants reduced miasma damage to explorers and Harmony 2 grants explorer miasma immunity).
While we are at it, let's talk graphics! The base Affinity Units should get a new model (base Battle Suits losing the cape and flag) and the 2nd upgrades should get a new texture (Prime Battle Suits going silver with sky blue capes & flags with the P/S icon and Evolved Battle Suits going bronze and gold with orange-gold (not yellow-gold) capes & flags with the P/H icon). The Ultra upgrades should look more "affinity-aligned" (Ultra True Battle Suits getting "Bling of War"). I also think that the Ultimate Affinity Units should scale with affinity level. The Ultra Evolved Xeno Titan would look the same as the current Xeno Titan and the base ANGEL and Lev Destroyers would look the same as they do now but the True ANGEL should be about the same size as the base Xeno Titan and the and Prime Lev Destroyer should be almost the size as a base ANGEL.
Texture examples (unchanged models): Tungsten-Carbide Prime ANGEL vs Stainless Steel True ANGEL vs weird (likely rich in Bismuth & Cobalt) purple alloy Evolved ANGEL; Copper-plated True Lev Destroyer vs Gold-plated Evolved Lev Destroyer vs Chrome-plated Prime Lev Destroyer; (Lush biome alien) green Evolved Xeno Titan vs (Fungal biome alien) purple Prime Xeno Titan with cybernetic implants vs (Primordial biome alien) orange True Xeno Titan with bronze armor.
When I earned the 42 achievement, I had 18/18/18 Affinity and I never got free Harmony affinity points or levels (I always chose Purity or Supremacy in quests) and I had Harmony 8 before I won. Simply put, it should be
IMPOSSIBLE to max-out
All 3 Affinity Levels with research
alone but
should be
feasible to max-out 2 Affinity levels with research+quests but difficult with research alone.