Skip to content

Commit 007c6b6

Browse files
derek73claude
andcommitted
Build the name list instead of mutating Hypothesis's
`drawn.insert(...)` writes into the list `st.lists` handed back. Safe today -- that strategy builds a fresh list per draw -- but the hazard class is the kind a fuzzer should not carry: a strategy that ever handed back a shared or memoized list would turn this into a bug in the test harness, reported as a bug in the code under test. The rebuild costs nothing and draws in the same order, so the committed seed still counts 23 surname splits and one peel. Also names the shape honestly in the comment above it: the pool CAN produce that token, it just loses the draw. "cannot deliver on its own" contradicted the paragraph four lines up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent d834f01 commit 007c6b6

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tests/v2/test_properties.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,22 @@ def _names_using(draw: st.DrawFn, lexicon: Lexicon,
392392
pieces = st.sampled_from(
393393
vocab + unspaced + glued + ["John", "Smith", "Q.", ",", "(", "'"])
394394
drawn = draw(st.lists(pieces, min_size=1, max_size=8))
395-
# The one shape the pool cannot deliver on its own. Inserted at a
396-
# drawn position rather than the front: the stage takes the first
397-
# ACTIVATED-script token, not the first token, so a leading Latin
398-
# word must not hide it -- and both placements are worth covering.
395+
# The one shape the pool does not deliver RELIABLY -- it is in
396+
# there, it just loses the draw. Inserted at a drawn position
397+
# rather than the front: the stage takes the first ACTIVATED-script
398+
# token, not the first token, so a leading Latin word cannot hide
399+
# it -- and both placements are worth covering.
399400
activatable = sorted(
400401
w + "민준" for w in lexicon.surnames
401402
if effective_script(w + "민준") in policy.segment_scripts)
402403
if activatable:
403-
drawn.insert(draw(st.integers(0, len(drawn))),
404-
draw(st.sampled_from(activatable)))
404+
# rebuilt rather than list.insert()d: st.lists hands back a
405+
# fresh list today, so mutating it is safe today, and a
406+
# strategy that ever memoized one would make this a bug in the
407+
# fuzzer rather than in the code under test
408+
at = draw(st.integers(0, len(drawn)))
409+
token = draw(st.sampled_from(activatable))
410+
drawn = [*drawn[:at], token, *drawn[at:]]
405411
return " ".join(drawn)
406412

407413

0 commit comments

Comments
 (0)