Skip to content

refactor: separate client funding reducer and policy - #158

Merged
SatsAndSports merged 1 commit into
mainfrom
refactor/client-funding-reducer
Oct 11, 2026
Merged

SatsAndSports merged 1 commit into
mainfrom
refactor/client-funding-reducer

Conversation

@SatsAndSports

Copy link
Copy Markdown
Owner

Summary

PR1 of the client funding refactor, following merged #156.

  • Add a pure ordinary-control/channel reducer. One Idle / Working / Submitting / AwaitingResponse slot owns main-client response attribution, replacing the FIFO plus separate in-flight flag.
  • Classify responses without mutation and commit only after wallet/status validation. Share pure response checks with ControlExchange, which remains available for pipelined harnesses.
  • Separate channel acquisition/reservation from linking. Optimistic selection of B retains previous A until the outcome; rejected replacement restores A unless independently evicted. Keep release advisories through outstanding operations and clean up all reservation roles on termination.
  • Extract a pure funding strategy and intent/effect boundary. Retain the 250 ms timer and default target/minimum-topup and exhaustion policy. Busy ordinary operations suppress policy evaluation; funded idle evaluations use only task-owned state and atomic counters.
  • Keep heartbeat/Ping/Pong and data forwarding outside the reducer. Preserve durable signed-payment handling and existing response-time wallet validation; the database-read optimization is PR2.
  • Update architecture, payment, wallet, and contributor documentation.

Coverage

  • Ordinary serialization and independent advisories/Pong
  • Nonmutating response validation, wrong-channel/wrong-balance/short-paid rejection
  • Policy can pay while unpaused or wait while paused
  • Replacement success/rejection, previous-channel eviction and release
  • Acquired reservation exclusivity and release without linking
  • Failed link preparation releases the candidate and clears excluded retry intent
  • Counting-wallet executor test: zero wallet calls during funded idle ticks and while each ordinary request type is pending

Verification

  • cargo fmt --all
  • make lint
  • cargo test: full workspace passed, including 173 relay integration tests
  • After final retry-preparation cleanup: make lint and cargo test -p monad-client --lib session_driver (67 passed)
  • git diff --check

No wire, YAML, or database schema changes. Opened after local verification; CI is intentionally not awaited.

@SatsAndSports
SatsAndSports merged commit 2aa937a into main Oct 11, 2026
2 checks passed
@SatsAndSports
SatsAndSports deleted the refactor/client-funding-reducer branch October 11, 2026 18:36
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.

1 participant