fix: wire WP-14 tier-up notification embeds into post-game hook #118
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#118
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/wp14-wire-notifications"
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
notify_tier_completionstub inlogic_gameplay.pywith the real embed-sending implementation fromhelpers/refractor_notifs.pyContext
This is the last code change blocking WP-15 (Refractor deployment and smoke testing). The embed builder and all API endpoints have been merged and tested — this PR wires them together so notifications actually fire in Discord.
The API's
evaluate-gameendpoint returns the full dict shape (player_name,track_name, etc.) thatbuild_tier_up_embedexpects, so no KeyError risk exists in production.Files Changed
command_logic/logic_gameplay.pynotify_tier_completionfromhelpers.refractor_notifs, remove 16-line stub function, remove redundant inline loggingtests/test_complete_game_hook.pytests/test_refractor_notifs.pyTestTierUpDictShapeMismatchdiagnostic withTestTierUpDictShapeValidationregression guardsTest Results
All refractor tests pass: notifs (26), commands (81), card embed (15), hook (5).
🤖 Generated with Claude Code
AI Code Review
Files Reviewed
command_logic/logic_gameplay.py(modified)tests/test_complete_game_hook.py(modified)tests/test_refractor_notifs.py(modified)helpers/refractor_notifs.py(read in full for import target verification)Findings
Correctness
from helpers.refractor_notifs import notify_tier_completionappears at line 26, after thefrom helpers import (...)block and beforefrom in_game.ai_manager import .... Placement follows the existing grouping convention and no duplicate definition remains — the 16-line stub at ~L4243 is fully removed.complete_gameis unchanged:await notify_tier_completion(interaction.channel, tier_up)inside the non-fataltry/except. The non-fatal contract is maintained end-to-end:notify_tier_completionitself wrapschannel.sendin its owntry/exceptand logs on failure, so a Discord API error will not bubble up to the outerexcept Exceptionand will not surface as "Post-game refractor processing failed".build_tier_up_embedaccessestier_up["player_name"],tier_up["new_tier"], andtier_up["track_name"]as bare dict lookups. If the API ever returns a partial response, aKeyErrorwill be raised insidenotify_tier_completion, caught there, and logged as an error — no crash to the game flow. This is acceptable given the stated API contract.Security
tier_updict originates from the internal database API, not directly from Discord user input.Style & Conventions
asyncioandloggingimports removed fromtest_complete_game_hook.pyare correct — neither is referenced after the test rewrite.AsyncMock()directly rather than_make_channel()(MagicMock), which is the right choice sincechannel.sendmust be awaitable.channel.send.call_args.kwargs["embed"]is the correct introspection path forawait channel.send(embed=embed)withAsyncMock. Works correctly in Python 3.8+.TestTierUpDictShapeValidation.test_empty_dict_raises_key_erroris a tighter guard than the removed diagnostic test. The old test was documenting a known bug rather than a stable contract; the replacement reflects the actual production API shape.track_name="Batter Track"(with space) in both test files is a quiet correctness fix — the old tests used"Batter"which did not match the display string format.Suggestions
test_hook_processes_tier_ups_from_evo_resulttest still passes minimal-shape dicts (noplayer_name/track_name) to the patchedmock_notify. This is safe becausenotify_tier_completionis mocked and never reachesbuild_tier_up_embed, but if anyone reads that test in isolation they may not realize real calls need the full shape. Not a blocker.test_complete_game_hook.py(line 14) still says "so WP-14 can present them to the player" in future tense. Minor housekeeping item for a future pass.Verdict: APPROVED (self-review blocked by Gitea)
The import replacement is correct, the stub removal is clean, and the non-fatal error handling contract is preserved at both layers. Test updates accurately reflect real behavior instead of documenting a known bug. No runtime error risk introduced. Safe to merge.
Automated review by Claude PR Reviewer