Skip to content

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

Merged
arminsabouri merged 1 commit intopayjoin:masterfrom
0xZaddyy:generalize-cost-function-terms
Mar 5, 2026
Merged

Generalize cost function from payjoin-specific to conceptual terms#7
arminsabouri merged 1 commit 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.

@arminsabouri arminsabouri self-requested a review February 28, 2026 22:41
@0xZaddyy 0xZaddyy force-pushed the generalize-cost-function-terms branch from e76e9c0 to efc1b9e Compare March 1, 2026 11:37
src/actions.rs Outdated

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.

src/actions.rs Outdated
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

@0xZaddyy 0xZaddyy force-pushed the generalize-cost-function-terms branch 2 times, most recently from 0ccc110 to 79b1051 Compare March 3, 2026 13:32
@0xZaddyy 0xZaddyy requested a review from arminsabouri March 3, 2026 13:32
@arminsabouri
Copy link
Collaborator

Heads up lint and test failing

@0xZaddyy
Copy link
Contributor Author

0xZaddyy commented Mar 4, 2026

oh shoot thought i fix that, doing it right away

This removes scaffolding code and makes the cost function applicable to any privacy-enhancing or interactive protocol, not just payjoins.

Decompose CompositeScorer into per-dimension weights

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

pass specific weights to score() not CompositeScorer
@0xZaddyy 0xZaddyy force-pushed the generalize-cost-function-terms branch from 79b1051 to 8346c21 Compare March 4, 2026 15:55
Copy link
Collaborator

@arminsabouri arminsabouri left a comment

Choose a reason for hiding this comment

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

Ack

@arminsabouri arminsabouri merged commit 292b136 into payjoin:master Mar 5, 2026
1 check passed
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