Pin the voyage event roll on the module docks actually calls (CI red on main) - #202
Conversation
#201 patched rollEvent on src.business.adventures, but docks imports adventures as business.adventures - pytest.ini puts both . and src on the path, so those are two module objects and the patch never reached the call site. The flake it meant to fix survived it: main went red again on the very next run (35556530705). The roll is now pinned with patch.object on docks.adventures, and the day assertion is exact (she founders on leg one), so a roll that isn't pinned fails five runs in seven instead of one in forty. Forcing the real roll to driftwood every leg fails on main's version of the test and passes here; 200 consecutive plain runs, 0 failures. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Self-review rubric (posted as a comment; the formal Review API is not available to this session):
One observation outside the diff, not acted on here: the same dual-module trap (
This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
mainhas been red for its last two runs (35554330178, 35556530705) ontests/location/test_docks.py::test_a_voyage_that_founders_ends_early, the flake that Pin the event roll in the foundering-voyage test (flake) #201 was meant to fix.src.business.adventures.rollEvent, butsrc/location/docks.pyimportsfrom business import adventures. Becausepytest.iniputs both.andsrcon the path,src.business.adventuresandbusiness.adventuresare two separate module objects, so the patch never reached the call site and the realrandom.choiceroll kept running. (Therandom.randint/random.randompatches were unaffected:randomis one shared module either way.)patch.object(docks.adventures, "rollEvent", ...)— the module docks actually resolves — and the event is taken from that module's ownEVENTS.< startingDay + legsto== startingDay + 1: with 51% of hull and a 99-point leak the boat founders on the first leg exactly. An unpinned roll now fails five runs in seven rather than one in forty, so a regression of this kind would surface on the first CI run rather than the fortieth.No tracking issue — #200 was closed by #201; this is the gap found at triage (CI red on
main). No open issues were skipped: the backlog was empty at triage time.Test-only change; no production code, schema, or persistence path is touched.
Test plan
random.choiceforced to draw driftwood every leg, the test onmainfails and the test on this branch passes (the stash-and-run check for the rubric's Tests-fix item).main's version.blackon the changed file: unchanged.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code