8b1451cdda
* feat(runtime): add application-scoped async runtime * refactor(cli): use owned runtime for session stats * refactor(onboard): use the owned async runtime * docs(runtime): record async bridge ownership * refactor(middleware): keep sync fallback synchronous * refactor(mcp): load tools on an owned runtime * refactor(cli): share owned runtime across entry points * refactor(channels): make inbound sync bridge explicit * refactor(stream): run Rich streaming on owned runtime * chore(runtime): remove nest-asyncio dependency * refactor(asyncio): require active loops in async code * docs(runtime): document final event loop ownership * fix(stream): cancel stalled owned streams * fix(cli): recover cleanly from stream cancellation * fix(runtime): drain executor work before shutdown * fix(runtime): terminate cancelled shell process trees * fix(models): let fallback bypass selector failures * fix(cli): reset interrupt handling between turns * docs: rm implementation spec * fix(serve): cancel active turns during shutdown * fix(runtime): protect settlement from waiter cancellation * fix(backends): reject empty shell commands * fix(runtime): terminate descendants after shell exit * fix(mcp): keep standalone discovery off channel loop * fix(cli): own and settle interactive prompt cancellation * fix(serve): keep channel sends off runtime loop * fix(stream): scope cancel context to iterator steps * refactor(serve): require the owned async runtime * fix(channels): keep interactive sends off runtime loop * fix(selector): surface fallback without log spam * test(runtime): normalize Windows shell marker * fix(cli): serialize interactive session turns * fix(shell): bound output drain after termination * fix(ui): do not retry owned runtime failures * fix(shell): allow signal-safe registry reentry * fix(shell): avoid terminating reused process ids * fix(channels): preserve streaming send order * fix(cli): report runtime shutdown timeouts cleanly * fix(mcp): guide async callers to async loader * docs(runtime): clarify reserved async bridge APIs * fix(runtime): bound code interpreter cleanup * test(shell): use active Python for drain regression --------- Co-authored-by: Xi Zhang <106144707+X-iZhang@users.noreply.github.com>
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Owned-runtime coverage for bounded onboarding async work."""
|
|
|
|
import asyncio
|
|
import threading
|
|
|
|
from EvoScientist.config import EvoScientistConfig
|
|
from EvoScientist.config.onboard.channels import _probe_channel
|
|
from EvoScientist.runtime import AsyncRuntime
|
|
|
|
|
|
def test_channel_probes_reuse_the_provided_runtime(monkeypatch):
|
|
executions: list[tuple[str, asyncio.AbstractEventLoop]] = []
|
|
|
|
async def validate_telegram(_token, _proxy):
|
|
executions.append((threading.current_thread().name, asyncio.get_running_loop()))
|
|
return True, "telegram ok"
|
|
|
|
async def validate_discord(_token, _proxy):
|
|
executions.append((threading.current_thread().name, asyncio.get_running_loop()))
|
|
return True, "discord ok"
|
|
|
|
monkeypatch.setattr(
|
|
"EvoScientist.channels.telegram.probe.validate_telegram_token",
|
|
validate_telegram,
|
|
)
|
|
monkeypatch.setattr(
|
|
"EvoScientist.channels.discord.probe.validate_discord_token",
|
|
validate_discord,
|
|
)
|
|
monkeypatch.setattr(
|
|
"EvoScientist.config.onboard.channels.console.print", lambda *_a, **_k: None
|
|
)
|
|
|
|
config = EvoScientistConfig()
|
|
updates = {
|
|
"telegram_bot_token": "telegram-token",
|
|
"discord_bot_token": "discord-token",
|
|
}
|
|
with AsyncRuntime(thread_name="test-onboard-runtime") as runtime:
|
|
_probe_channel("telegram", config, updates, runtime=runtime)
|
|
_probe_channel("discord", config, updates, runtime=runtime)
|
|
|
|
assert [thread for thread, _loop in executions] == [
|
|
"test-onboard-runtime",
|
|
"test-onboard-runtime",
|
|
]
|
|
assert executions[0][1] is executions[1][1]
|