Repository navigation
ESPN: approval-gated trade proposals (propose → approve) - #181
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ESPN module's third write, mirroring the add/drop gate (PR #176) end to end.
Gate:
POST /espn/tradesvalidates against the live league (counterparty exists and isn't the caller's team; every give player on the caller's roster; every receive player on the counterparty's; post-trade roster legal for BOTH teams under the league slot counts with IR accounting, so 2-for-1/1-for-2 change sizes on both sides; trade deadline from league settings not passed) and persists a pending proposal with both sides' snapshots + preview + 30-min expiry, submitting NOTHING.POST /espn/trades/{id}/approveclaims atomically (double-approve 409, cross-account 404), re-validates fail-closed, submits ONE ESPN TRADE transaction, records offered/failed + the ESPN transaction id.GET /espn/trades[/{id}]reads. MCP tools propose_trade / approve_trade / get_trades mirror the routes.Payload shape: the TRADE item shape ({playerId, type: TRADE, fromTeamId, toTeamId} per player, correct directions) is sourced from a real mTransactions2 read fixture already in the repo (t-trade in test_espn_logic.py); the submission envelope mirrors post_roster_transaction's. No fixture captures a trade SUBMISSION, so post_trade_transaction's docstring flags the envelope as derived — if ESPN wants a trade-specific envelope field, the first live offer surfaces it as a recorded rejection rather than a silent bad write. Development used mocked clients only; no live submissions.
Migration 0015 creates espn_trade_proposals (contract 14 → 15). Tests: ESPN scope 559 passed locally (533 baseline + 26 new). CLI verbs (trade / trade-approve / trades) + gate discipline documented in the local connector (edited in place, lands with the deploy).