Skip to content

Commit cbdf1eb

Browse files
committed
Guard subint_forkserver stub against re-alias
Add `test_subint_forkserver_key_errors_cleanly` — a tn-tier regression guard that pins down the variant-2 reservation contract: the `'subint_forkserver'` key in `_spawn._methods` MUST raise `NotImplementedError` today, not silently dispatch to `main_thread_forkserver_proc`. The transient alias-state existed briefly during the rename (commit `57dae0e4`'s "Split forkserver backend into variant 1/2 mods" landed the alias; `5e83881f` flipped it to the stub). Without a guard, a future refactor could easily re-collapse the two keys back to a single coro and silently break the variant-1 / variant-2 contract. Also asserts the stub's error msg surfaces the two pointers an operator hitting it actually needs: - `'main_thread_forkserver'` — the working backend they prolly meant, - `'msgspec#1026'` — the upstream blocker that has to land before variant-2 can ship. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent 205382a commit cbdf1eb

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

tests/spawn/test_main_thread_forkserver.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,3 +603,50 @@ def test_orphaned_subactor_sigint_cleanup_DRAFT(
603603
proc.wait(timeout=2.0)
604604
except subprocess.TimeoutExpired:
605605
pass
606+
607+
608+
# ----------------------------------------------------------------
609+
# regression guard: variant-2 (`subint_forkserver`) placeholder
610+
# MUST raise `NotImplementedError` today — guards against future
611+
# commits accidentally re-aliasing the key to the variant-1
612+
# coroutine (which was a transient state during the rename).
613+
# ----------------------------------------------------------------
614+
def test_subint_forkserver_key_errors_cleanly() -> None:
615+
'''
616+
`--spawn-backend=subint_forkserver` is reserved for the
617+
eventual variant-2 (subint-isolated child runtime)
618+
backend, gated on jcrist/msgspec#1026 unblocking PEP 684
619+
isolated-mode subints upstream.
620+
621+
Until that lands, the dispatch entry MUST raise
622+
`NotImplementedError` immediately rather than silently
623+
aliasing to `main_thread_forkserver_proc`. Verify the
624+
error message also surfaces both the working-backend
625+
pointer and the upstream-blocker ref so an operator
626+
arriving at the error has somewhere to go.
627+
628+
'''
629+
import asyncio
630+
from tractor.spawn._spawn import _methods
631+
632+
proc = _methods['subint_forkserver']
633+
with pytest.raises(NotImplementedError) as ei:
634+
# signature args match `main_thread_forkserver_proc`'s
635+
# — the stub raises before touching them so dummy
636+
# values are fine.
637+
asyncio.run(
638+
proc(
639+
'x', None, None, {}, [],
640+
('127.0.0.1', 0), {},
641+
)
642+
)
643+
644+
msg: str = str(ei.value)
645+
assert 'main_thread_forkserver' in msg, (
646+
f'stub error msg should redirect to the working '
647+
f'variant-1 backend; got: {msg!r}'
648+
)
649+
assert 'msgspec#1026' in msg or '1026' in msg, (
650+
f'stub error msg should reference the upstream '
651+
f'blocker (jcrist/msgspec#1026); got: {msg!r}'
652+
)

0 commit comments

Comments
 (0)