feat: enforce FA lock deadline after week 14 #122
No reviewers
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#122
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/fa-lock-enforcement"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
fa_lock_week(14) inTransactionBuilder.add_move()— blocks/dropaddfrom adding players FROM Free Agency whencurrent_week >= 14league_service.get_current_state()calls into a single shared fetch, eliminating a redundant API round-trip on every FA pickupTest plan
test_add_move_from_fa_blocked_after_deadline— verifies FA pickups blocked at week 15test_drop_to_fa_allowed_after_deadline— verifies drops to FA still work after deadline/dropaddwith an FA player in prod after deployment🤖 Generated with Claude Code
Review — feat: enforce FA lock deadline after week 14
transaction_builder.py
is_fa_pickupdetection: Correct asymmetry.from_roster == FREE_AGENCY and to_roster != FREE_AGENCYprecisely targets FA pickups only; drops to FA havefrom_roster != FREE_AGENCYand bypass the check entirely.API call consolidation: Clean.
needs_current_statecorrectly unifies the two previously separate fetch paths — FA lock check and pending-transaction week resolution — into one call.Fallback on API failure (
current_week = 1): Permissive fail. Week 1 never triggers the lock, so aget_current_state()outage won't accidentally block all FA activity. Correct default.current_week is not Noneguard: Safe.current_weekis onlyNonewhenneeds_current_statewasFalse, meaningis_fa_pickupwas alsoFalse, so the block can never fire incorrectly on non-FA moves.Pending transaction
next_weekderivation:(current_week + 1) if current_week else 1preserves prior behavior exactly. No regression.tests
autousefixture (both test classes): Correct approach — all existing tests run at week 10 (safely below the deadline) without modification. No existing tests impacted.test_add_move_from_fa_blocked_after_deadline: Week 15 → FA pickup →success=False, error message contains "Free agency is closed",move_count == 0. Solid.test_drop_to_fa_allowed_after_deadline: Verifies ML→FA is not blocked. Minor gap: this test runs at week 10, so it doesn't prove drops are allowed specifically after the deadline. Not a blocker — the logic clearly excludes drops from the check path.Edge cases verified
current_statereturnsNoneis_fa_pickup=False, no check fires>=correctly blocks (inclusive deadline)next_weekpre-supplied by callerVerdict: APPROVED
Logic is correct, consolidation is clean, failure modes are permissive. Approved for merge.
LGTM — FA lock enforcement is clean, tests cover both directions, and the consolidated API call is a nice efficiency win.
AI Code Review
Files Reviewed
services/transaction_builder.py(modified)tests/test_services_transaction_builder.py(modified)Findings
Correctness
is_fa_pickup = (from_roster == FREE_AGENCY and to_roster != FREE_AGENCY)correctly identifies pickups while allowing drops to FA (from_roster != FREE_AGENCY, to_roster == FREE_AGENCY) to pass through.needs_current_statecovers both the FA lock check and thenext_week is Nonecase for pending transactions, eliminating the redundant API call.get_current_state()failure,current_week = 1means the FA lock is NOT triggered (1 < 14). This allows FA pickups when the week can't be determined, which is the safe choice for service availability.current_week is not Noneguard on the FA check block. Whenis_fa_pickup = True,needs_current_stateis alwaysTrue, socurrent_weekis always set (either tocurrent_state.weekor the1fallback). Theis not Nonecheck can never beTruewhileis_fa_pickupisTrue. Not a bug, just dead logic."already has a move". Now it returns"Free agency is closed"when locked. Behavior change is harmless but worth noting.Security
Style & Conventions
# This prevents duplicate claims that would need to be resolved at freeze time# Only applies to /dropadd (scheduled moves), not /ilmove (immediate moves)These aren't blocking, but they explained non-obvious behavior. Consider preserving them.
Test Coverage
test_add_move_from_fa_blocked_after_deadlineusesweek=15, which verifies blocking after the deadline. However, the boundary caseweek=14(the first blocked week percurrent_week >= fa_lock_week) is not tested. Consider addingtest_add_move_from_fa_blocked_at_deadlinewithweek=14.test_drop_to_fa_allowed_after_deadlineuses the autouse fixture atweek=10, not a post-deadline week. The test name implies it proves drops work after the deadline, but the FA lock check is never triggered for drops regardless of week (becauseis_fa_pickup = False). The assertion is correct, but a comment noting this would clarify why week=10 is sufficient.autousefixtures on both test classes correctly prevent the productionleague_service.get_current_state()from being called during existing tests — good isolation.Suggestions
week=14boundary test to confirm the first locked week.test_drop_to_fa_allowed_after_deadlinename or add a comment clarifying that the FA lock is direction-based, not week-based for drops.Verdict: COMMENT
Clean, correct implementation. The consolidation logic is sound, the permissive fallback is appropriate, and the
autousefixture approach correctly protects existing tests. The two notes above (boundary test atweek=14and misleading test name) are suggestions, not blockers.Automated review by Claude PR Reviewer