Refuse an odd keyword count in createPairs - #22
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Self-review rubric (scored against the diff, the local test runs, and CI run 36119039250):
Judgment call noted for the owner: Summary: no do-not-auto-merge path is touched, and the regression evidence was confirmed by actually running the tests with the fix removed and then restored. This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
createPairs()now raisesValueError("keywords must have an even count to be paired, got N") whenself.keywordshas an odd length, instead of reading past the end of the list with an unguardedkeywords[i+1]and raisingIndexError.self.pairsempty rather than half-filled.numKeywordswith aValueError: an unpartnered keyword is treated as an error in both places, rather than being silently dropped or turned into a one-element pair.testOddKeywordCountRaisesIndexErroris replaced bytestOddKeywordCountRaisesValueError, andtestOddKeywordCountCreatesNoPairsis added.The CLI path is unaffected:
getKeywords()always collects an evennumKeywords, so an odd list only reachescreatePairs()when it is called directly.Closes #9
Test plan
python3 -m py_compile src/collide.py src/ideaCollisionGenerator.py src/usage_reporting.py src/trace_client.py— cleanpython3 -m unittest discover -s tests(Python 3.8.10) —Ran 61 tests ... OKgit stash push -- src/ideaCollisionGenerator.pythenpython3 -m unittest tests.test_ideaCollisionGenerator.TestCreatePairs:Ran 5 tests ... FAILED (errors=2), both new tests erroring withIndexError: list index out of rangeatpair.append(self.keywords[i+1])Ran 5 tests ... OKsrc/collide.pylocally was denied by the session's command classifier, so this step is covered only by the CI workflow's "Run the program end to end" step (15-line fixture on stdin, 5 written lines asserted).Deferred
.vscode/launch.json"python"→"debugpy") was selected for this batch, but writing that path was again refused by the harness as a sensitive file, so it is left open for a person to make.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson