Skip to content

espn: fix roster-edit outcome classification (FREEAGENT/EXECUTED misrecorded as waiver_pending) - #184

Open
warnerktsang wants to merge 2 commits into
mainfrom
espn-roster-edit-outcome-classification
Open

warnerktsang wants to merge 2 commits into
mainfrom
espn-roster-edit-outcome-classification

Conversation

@warnerktsang

Copy link
Copy Markdown
Collaborator

The bug (live incident, 2026-10-30 ~23:00 ET)

Edit baefb882 (add Aday Mara, drop Myles Turner) was approved and submitted. ESPN's transaction 4024e95b is unambiguous: type FREEAGENT, status EXECUTED, effective the next scoring period (period 12). The module nevertheless recorded the edit's outcome as waiver_pending — implying a waiver claim and a priority spend that never happened. The propose-time snapshot had correctly said on_waivers: false, and the move itself worked.

Root cause

Two compounding defects in backend/espn/roster_edits.py:

  1. _classify_outcome never looked at the response's type field — it keyed solely off status (plus the propose-time snapshot), so claim vs free-agent semantics were conflated.
  2. The actual mislabel came from _execute's post-submit roster verification: when classification returned EXECUTED, it re-read the current-period roster and, if the added player was absent, overrode the outcome to waiver_pending on the theory that ESPN's EXECUTED echo could not be trusted. But a FREEAGENT move submitted after the day's games lock is applied by ESPN from the NEXT scoring period, so the add legitimately is not on the current-period roster yet — absence proved nothing, and the check flipped a correct EXECUTED into waiver_pending.

The fix

  • _classify_outcome now keys off the transaction's actual type/status: FAILED/error → failed (unchanged); type WAIVER, or an explicitly pending/processing status → waiver_pending; FREEAGENT + EXECUTED → executed; the snapshot fallback for echo-less responses is unchanged.
  • The roster-verification safety net is retained but gated to waiver submissions (on_waivers), the only case it was designed for — catching a claim ESPN echoed as EXECUTED but actually parked. A straight free-agent edit now trusts ESPN's EXECUTED.

The genuine waiver path is preserved: an edit for a player who IS on waivers still records waiver_pending (existing test with a WAIVER/PENDING response, plus a new test where ESPN echoes EXECUTED on a WAIVER transaction, plus a preservation test for the no-type-echo verification path).

Tests

ESPN scope: 565 passed (562 baseline + 3 new). The incident regression test replays a FREEAGENT/EXECUTED response (ADD/DROP items) with the add not yet on the roster (next-period effectiveness) and asserts executed; it and the type-keying test both fail on the pre-fix code, verified by stashing the fix.

Not in scope

The historical record baefb882 stays mislabeled in the DB — no backfill and no data migration for one row in this PR. No changes to propose/approve flows, payload stamping, or response shapes.

warnerktsang added a commit that referenced this pull request Oct 31, 2026
warnerktsang added a commit that referenced this pull request Oct 31, 2026
* espn: fix roster-edit outcome classification (redo of #184/#185 on current main)

* Regression tests for outcome classification
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