Description
profits.rs::calculate_profit, calculate_treasury_split and fees.rs::calculate_transaction_fees have been refactored repeatedly (tiered fees, dust handling, treasury splits). To catch silent semantic drift during future refactors, add a differential harness that captures a frozen golden-vector corpus of (investment_amount, payment_amount, fee_bps, tier, volume) -> (investor_return, platform_fee, treasury, dust) and re-evaluates it against the live implementation. Any divergence fails CI and forces the author to explicitly bless the change.
Requirements and context
- Secure: bless workflow is admin-reviewed via PR; no auto-bless.
- Tested: corpus covers at least 500 input combinations including edge cases at
i128::MAX, zero payment, overpayment.
- Documented:
docs/profit-fee-differential.md describing corpus refresh policy.
- Reference:
src/profits.rs, src/fees.rs.
Suggested execution
git checkout -b feature/profit-fee-differential
- Add
tests/profit_fee_golden.rs; store corpus as JSON under tests/fixtures/profit_fee_corpus.json.
- Implement
scripts/refresh-profit-fee-corpus.sh that regenerates the corpus from the current implementation, gated behind an env var to prevent accidental blessing.
- Rust doc comments on the corpus loader explaining bless semantics.
- Docs:
docs/profit-fee-differential.md.
- Validate that
verify_no_dust is exercised across the corpus.
Test and commit
Run cargo test --test profit_fee_golden and confirm zero diffs against the committed corpus. Include the output and a note that any future delta requires a corpus refresh PR.
Example commit message
test(profits): add differential golden-vector harness for profit and fee math
Guidelines
- Minimum 95% test coverage
- Clear documentation in
docs/profit-fee-differential.md
- Timeframe: 96 hours
Description
profits.rs::calculate_profit,calculate_treasury_splitandfees.rs::calculate_transaction_feeshave been refactored repeatedly (tiered fees, dust handling, treasury splits). To catch silent semantic drift during future refactors, add a differential harness that captures a frozen golden-vector corpus of(investment_amount, payment_amount, fee_bps, tier, volume) -> (investor_return, platform_fee, treasury, dust)and re-evaluates it against the live implementation. Any divergence fails CI and forces the author to explicitly bless the change.Requirements and context
i128::MAX, zero payment, overpayment.docs/profit-fee-differential.mddescribing corpus refresh policy.src/profits.rs,src/fees.rs.Suggested execution
git checkout -b feature/profit-fee-differentialtests/profit_fee_golden.rs; store corpus as JSON undertests/fixtures/profit_fee_corpus.json.scripts/refresh-profit-fee-corpus.shthat regenerates the corpus from the current implementation, gated behind an env var to prevent accidental blessing.docs/profit-fee-differential.md.verify_no_dustis exercised across the corpus.Test and commit
Run
cargo test --test profit_fee_goldenand confirm zero diffs against the committed corpus. Include the output and a note that any future delta requires a corpus refresh PR.Example commit message
test(profits): add differential golden-vector harness for profit and fee mathGuidelines
docs/profit-fee-differential.md