Skip to content

Generalize cost function from payjoin-specific to conceptual terms#7

Open
0xZaddyy wants to merge 2 commits intopayjoin:masterfrom
0xZaddyy:generalize-cost-function-terms
Open

Generalize cost function from payjoin-specific to conceptual terms#7
0xZaddyy wants to merge 2 commits intopayjoin:masterfrom
0xZaddyy:generalize-cost-function-terms

Conversation

@0xZaddyy
Copy link
Contributor

The cost function coefficients were scaffolding that unnecessarily coupled decision-making to specific payjoin implementations. This refactors them to model fundamental user preferences that apply broadly, this makes the cost function reusable for any privacy or coordination protocol.

This removes scaffolding code and makes the cost function applicable to any privacy-enhancing or interactive protocol, not just payjoins.
@arminsabouri arminsabouri self-requested a review February 28, 2026 22:41
Replace coarse per-action-type utility factors with independent
per-dimension weights across all outcome scoring. All score() methods
now accept &CompositeScorer directly instead of a single opaque f64,
allowing each outcome to apply only the weights relevant to its
dimensions.

fix format errors

Fix missed ScorerConfig field renames in lib.rs test fixtures
@0xZaddyy 0xZaddyy force-pushed the generalize-cost-function-terms branch from e76e9c0 to efc1b9e Compare March 1, 2026 11:37

impl PaymentObligationHandledOutcome {
fn score(&self, payment_obligation_utility_factor: f64) -> ActionScore {
fn score(&self, weights: &CompositeScorer) -> ActionScore {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a regression. I would prefer a specific weight vs the CompositeScorer. This way you know exactly what weights influnce a particular score from just the function signature.

Comment on lines +151 to +152
let fee_benefit = self.fee_savings.to_float_in(bitcoin::Denomination::Satoshi)
* weights.fee_savings_weight;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will currently be 0, correct? If so maybe we comment it out and leave a TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants