tractor/ai/prompt-io/claude/20260702T161624Z_65bf9df5_p...

81 lines
2.6 KiB
Markdown
Raw Normal View History

Add `.trionics.start_or_cancel()` test suite Resolve #474 with a new `tests/trionics/test_taskc.py` (9 tests) covering the `trio.Nursery.start()` wrapper landed in PR #464, incl. the `modden.runtime.progman.open_wks()` use case dug out as a minimal repro. Deats, - the lossy `RuntimeError('child exited without calling task_status.started()')` only fires when the child absorbs its ambient cancel pre-`.started()` (graceful-teardown pattern); a well-behaved child surfaces `Cancelled` direct from `.start()` on `trio` 0.29 - verified empirically 1st. - `test_sibling_err_not_masked_by_startup_rte`: the `modden` case; ONLY the root-cause sibling `ValueError` escapes the nursery with the wrapper vs. bare-`.start()`'s lossy riding-along startup-RTE noise. - `test_pure_oob_cancel_not_morphed_to_rte`: plain ancestor `cs.cancel()` exits clean vs. bare's eg-wrapped RTE. - `test_genuine_startup_rte_still_raised`: sans cancellation the protocol-bug RTE re-raises same as bare. - `test_childs_own_rte_never_demoted_to_cancel`: exact-msg + `isinstance`-guard regression cover; a child's own `RuntimeError('never got started!')`/`RuntimeError(1234)` never demotes to a `Cancelled`. - `test_started_value_and_args_passthru`: positional args, `name=` and `.started()`-value forwarding. Also, - `use_start_or_cancel=False` params pin upstream `trio`'s current lossy behaviour as wart-documentation: a break on a `trio` upgrade likely means new upstream porcelain and the wrapper deserves a re-audit. - verified 0 flakes over 50 hammer runs + 2 impl mutations each caught by exactly the targeted tests. Prompt-IO: ai/prompt-io/claude/20260702T161624Z_65bf9df5_prompt_io.md (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
2026-07-02 16:20:37 +00:00
---
model: claude-fable-5
service: claude
session: f4da6654-63f9-4641-b567-f200da46d697
timestamp: 2026-07-02T16:16:24Z
git_ref: 65bf9df5
scope: tests
substantive: true
raw_file: 20260702T161624Z_65bf9df5_prompt_io.raw.md
---
## Prompt
> attempt to resolve
> https://github.com/goodboy/tractor/issues/474
> do it with /open-wkt.
Issue #474: "We need test suite for
`.trionics.start_or_cancel()`" — dig out the use case
from `modden` as a unit test (and provide motivation
for upstream `trio` to possibly provide better
porcelain around this case). The wrapper landed via
PR #464 with no tests.
## Response summary
New `tests/trionics/test_taskc.py` (9 tests) covering
`start_or_cancel()`, authored in wkt
`start_or_cancel_tests_474`.
Behaviour was first probed empirically (trio 0.29):
the lossy `RuntimeError('child exited without calling
task_status.started()')` only fires when the child
exits pre-`.started()` WITHOUT propagating the ambient
`Cancelled` — i.e. when the child (or lib code it
calls) absorbs the cancel in a graceful-teardown
pattern; a well-behaved child surfaces `Cancelled`
straight out of `.start()`. The `modden`
`progman.open_wks()` use case was reconstructed from
`modden/runtime/progman.py` accordingly.
Tests (each `use_start_or_cancel` parametrization also
pins upstream trio's current lossy behaviour as
wart-documentation):
- `test_sibling_err_not_masked_by_startup_rte` — the
`modden` case: sibling error OOB-cancels the shared
nursery scope; with the wrapper ONLY the root-cause
`ValueError` escapes; bare `.start()` adds the lossy
RTE alongside.
- `test_pure_oob_cancel_not_morphed_to_rte` — plain
ancestor `cs.cancel()`: wrapper → clean exit; bare
→ eg-wrapped RTE.
- `test_genuine_startup_rte_still_raised` — no
cancellation → protocol-bug RTE re-raised same as
bare.
- `test_childs_own_rte_never_demoted_to_cancel` — a
child's own `RuntimeError('never got started!')` /
`RuntimeError(1234)` under ambient cancel is never
demoted to `Cancelled` (exact-msg-match + str-guard
regression cover).
- `test_started_value_and_args_passthru` — happy path:
positional args, `name=`, `.started()` value.
Verified: 9/9 pass; 0 flakes across 50 hammer runs;
two impl mutations (checkpoint removed; guard relaxed
to substring match) each caught by exactly the
targeted tests; `tests/trionics/` +
`tests/test_trioisms.py` subset green (23 passed,
5 xfailed); ruff clean; 69-col style.
## Files changed
- `tests/trionics/test_taskc.py` — new
`start_or_cancel()` unit-test suite (gh #474).
## Human edits
Pending review — session paused pre-commit per user
deadline; nothing committed as of this entry.