mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-02 07:46:02 +00:00
a36873810a
I'm currently on a quest to separate cred computation away from any plugin metadata (see #1557). This means we need a way to represent node and edge weights without any explicit concept of 'types'. This commit is a first step towards that. It removes the distinction between 'type weights' and 'manual weights' in the weights data type. Instead, we now just have node weights and edge weights. In contrast to before, all weights are now interpreted as prefix matchers, e.g. a single node or edge may match multiple weights; when this occurs, the weights compose multiplicatively. Since types were already identified by prefix, if a plugin wants to assign a weight to a particular type, it may do so by specifying a weight for that type's prefix. As before, it's possible to have a type-level weight and a weight on a specific node, and compose them multiplicatively. As an added bonus, we could now sensibly have 'plugin-level' weights and 'type-level weights' and compose them multiplicatively. Thus, if we realized that the Foo plugin is undervalued relative to the Bar plugin, we could increase the Foo weight rather than needing to adjust all of its types individually. So as to keep the scope for this commit somewhat manageable, I modified the underlying data type for Weights, but not any of the cred computation interfaces. The weights pipeline still takes the plugin declarations, and we still get the default type level weights from the plugin's types. A future commit will modify the pipeline so that the plugins provide default types alongside the Graph. I deliberately did not provide an upgrade handler for the old style weights JSON. This is sensible as the semantics are now different. In the past, it was possible to specify a weight for a single node without affecting the weights of other nodes whose addresses have the first node's address as a prefix. Since this is no longer possible, there is no universally "correct" way to handle the old weights files. In practice, there are so few users that it is not a big deal either way. Test plan: This change has implications across the codebase and UI. In addition to `yarn test --full` passing, I verified that: - updating and recomputing works in the mainline UI - updating and recomputing works in the legacy UI - downloading weights from the UI and then explicitly loading them still works