update_odds_current_week does not guard against a locked week #446

Closed
opened 2026-09-02 09:36:26 +02:00 by johnsturgeon · 1 comment
Owner

update_odds_current_week fetches and writes lines unconditionally:

def update_odds_current_week():
    """Refresh odds for this week's games."""
    with Session(engine) as session:
        tank01: Tank01Client = Tank01Client()
        for game_date in Week.unique_gamedays(session):
            for odds in tank01.nfl_betting_odds(game_date=game_date):
                update_line(session, to_line_facts(odds))
        session.commit()

The write barrier lives entirely in dispatcher rule 4's guard
(week.odds_state == OddsState.PRELIMINARY). Anything that reaches the job
another way -- an admin button, a manual run during an incident, a future
caller -- overwrites a locked week's spreads and says nothing.

What that costs: OddsState.LOCKED means every pick in a week was made against
the same number. Moving a spread after picks are open scores two players
against different lines for the same game, silently and unrecoverably.

The guard belongs in the job as well as the rule. Rule 4 decides when to
refresh; the job should refuse to write a week that has been frozen, whoever
asked.

Split out of #435, which was closed as an accepted risk -- that was about the
timing of the lock, this is about the barrier itself.

`update_odds_current_week` fetches and writes lines unconditionally: ```python def update_odds_current_week(): """Refresh odds for this week's games.""" with Session(engine) as session: tank01: Tank01Client = Tank01Client() for game_date in Week.unique_gamedays(session): for odds in tank01.nfl_betting_odds(game_date=game_date): update_line(session, to_line_facts(odds)) session.commit() ``` The write barrier lives entirely in dispatcher rule 4's guard (`week.odds_state == OddsState.PRELIMINARY`). Anything that reaches the job another way -- an admin button, a manual run during an incident, a future caller -- overwrites a locked week's spreads and says nothing. What that costs: `OddsState.LOCKED` means every pick in a week was made against the same number. Moving a spread after picks are open scores two players against different lines for the same game, silently and unrecoverably. The guard belongs in the job as well as the rule. Rule 4 decides *when* to refresh; the job should refuse to write a week that has been frozen, whoever asked. Split out of #435, which was closed as an accepted risk -- that was about the timing of the lock, this is about the barrier itself.
Author
Owner

This was resolved in 73f68ed5c9

This was resolved in 73f68ed5c91a17c843968020f7c4c6abfad1e0c8
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
johnsturgeon/tgfp-web#446
No description provided.