Record the hang failure mode in the split recipes
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run

A mispointed mock.patch does not always fail loudly. In code_tutor it
spins, because the code under test reads from an input callable in a
retry loop. Documents running under timeout, asserting patch targets
resolve first, the absolute-patch-string cost, and the silent no-op sed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
This commit is contained in:
Krzysztof Rudnicki 2026-08-16 17:43:34 +02:00
parent 277cb9fd6f
commit 6c999e3242

View File

@ -76,6 +76,36 @@ every delegate needs a full docstring with `Args:`, so a 25-line function
leaves a 12-line stub. Eight of those to make a line count is the cap-gaming
the spec forbids.
### A mispointed patch can HANG rather than fail
In `brother_printer` a stale patch target raised `AttributeError` or made a
real `subprocess` call — loud, or at worst a side effect you could check for
afterwards. In `code_tutor` it **spins**: `_write_tests_first_flow` reads from
an `input_fn` in a retry loop, so an unintercepted `_collect_and_rate_tests`
ran the real interactive flow and the suite hung for two minutes with no
output. `ps` showed it `State: R`, not blocked on I/O.
Two consequences for any package whose code prompts, retries or shells out:
- **Run the suite under `timeout`.** A hang is indistinguishable from a slow
run until you have waited longer than you should.
- **Assert the patch targets resolve before invoking pytest**, since a missing
one is exactly what causes the hang:
```bash
PYTHONPATH=. python3 -c "
from python_pkg.pkg import mod_a as a, mod_b as b
for n in ('_helper', 'Thing'): assert hasattr(a, n), n
"
```
`code_tutor` also patches by **absolute string with no `MOD` constant**, so a
seam there costs one rewrite per patch string rather than one `sed`. Prefer
seams whose moved block has few patched names, even at slightly worse line
arithmetic. Watch out for a `sed` with escaped alternation silently matching
nothing — a no-op rewrite looks exactly like a successful one at the shell, so
`grep` the result before trusting it.
### You may edit the tests to follow the code (agreed 2026-08-16)
When a patch target moves, **update the patch target**. Bounded by: