caelum0x 0ac750ab4b fix(oss-fund): per-leg conservation + idempotent settlement nonces
settleFundingPlan claimed "no money created, none lost" but its reconciled
flag only checked leg COUNT and the aggregate total — a settler that paid the
wrong wallets the wrong amounts (summing correctly) still reported reconciled.
Now reconciliation is exact and per-leg: every leg must settle for precisely
its planned amount AND the total must equal the budget.

Also closes a double-pay gap: each leg used a fresh random nonce, so re-settling
a plan after a partial failure re-paid the completed legs. Add an optional
idempotencyKey that derives stable per-leg nonces, making retries dedupable by a
nonce-tracking verifier/settler. This satisfies the LEPTON plan's Principle 3
("every payment path carries an idempotency key"); omitting the key preserves
the prior one-shot random behavior for demos.

Tests: misrouted-but-total-conserved settlement now fails reconciliation;
same plan + same key yields identical (still per-leg-unique) nonces; no key
yields differing nonces run-to-run. Full suite 903 green; 25 contract tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 17:40:05 +03:00
..