mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-23 05:59:44 +08:00
* chore(sdk): import langbot-plugin-sdk v0.7.24 snapshot into sdk/ (LANG-420) Snapshot of langbot-app/langbot-plugin-sdk at 76443bb8 (tag v0.7.24), without history. The repository's .github/ workflows are not imported; they are replaced by sdk-*.yml workflows in the next commit. The root .gitignore keeps the template .vscode/launch.json.example tracked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> * feat(sdk): move the plugin SDK into the monorepo with independent releases (LANG-420) - CI: sdk-tests.yml / sdk-box-docker.yml run the SDK suite from sdk/ in its own environment (Python 3.10-3.12); run-tests.yml gains a "Core with in-tree SDK" job that overlays sdk/ on Core's venv. - Releases: sdk-publish.yml publishes langbot-plugin from sdk/vX.Y.Z tag pushes and never creates a GitHub Release. Core release workflows now only accept v* tags, and scripts/check_sdk_release_pin.py blocks a Core PyPI/Docker release whose langbot-plugin pin differs from the released, unchanged sdk/. - Packaging: Core still installs the PyPI pin. Core wheel/sdist, git export, Docker context, release ZIP and fnOS package exclude sdk/. - Generator/tests: generate_plugin_workspace_api.py writes sdk/ directly; the SDK's generator drift tests now run instead of skipping. - Docs: AGENTS/ARCHITECTURE, sdk/ guides (+ RELEASING.md, SOURCE.json), agent skills and lbs probes, public docs (zh/en/ja) and dev-docs point at sdk/ instead of the sibling langbot-plugin-sdk checkout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
"""Individual worker lifecycle changes must not stop the Runtime workload."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
|
|
from langbot_plugin.entities.io.context import ActionContext
|
|
from langbot_plugin.runtime.context import RuntimeContext
|
|
from langbot_plugin.runtime.plugin.mgr import PluginManager
|
|
|
|
|
|
def manager_with_no_legacy_directories(monkeypatch):
|
|
context = RuntimeContext()
|
|
context.ws_debug_port = 18080
|
|
manager = PluginManager(context)
|
|
context.plugin_mgr = manager
|
|
context.bind_workspace(
|
|
ActionContext(
|
|
instance_uuid="test-instance",
|
|
workspace_uuid="test-workspace",
|
|
placement_generation=1,
|
|
)
|
|
)
|
|
monkeypatch.setattr("langbot_plugin.runtime.plugin.mgr.glob.glob", lambda _: [])
|
|
return manager
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("worker_exit", ["cancel", "raise"])
|
|
async def test_worker_exit_does_not_abort_startup_workload(monkeypatch, worker_exit):
|
|
manager = manager_with_no_legacy_directories(monkeypatch)
|
|
exit_first = asyncio.Event()
|
|
finish_sibling = asyncio.Event()
|
|
|
|
async def first_worker():
|
|
await exit_first.wait()
|
|
raise RuntimeError("isolated worker failure")
|
|
|
|
first = asyncio.create_task(first_worker())
|
|
sibling = asyncio.create_task(finish_sibling.wait())
|
|
manager.plugin_run_tasks.extend([first, sibling])
|
|
workload = asyncio.create_task(manager.launch_all_plugins())
|
|
try:
|
|
for _ in range(3):
|
|
await asyncio.sleep(0)
|
|
if worker_exit == "cancel":
|
|
first.cancel()
|
|
else:
|
|
exit_first.set()
|
|
await asyncio.gather(first, return_exceptions=True)
|
|
for _ in range(3):
|
|
await asyncio.sleep(0)
|
|
assert not workload.done(), "One worker stopped the entire Runtime workload"
|
|
assert not sibling.done(), "Sibling worker must stay alive"
|
|
finish_sibling.set()
|
|
await asyncio.wait_for(workload, 1)
|
|
assert not workload.cancelled()
|
|
finally:
|
|
for task in [workload, first, sibling]:
|
|
task.cancel()
|
|
await asyncio.gather(workload, first, sibling, return_exceptions=True)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_parent_workload_cancellation_still_cancels_all_children(monkeypatch):
|
|
manager = manager_with_no_legacy_directories(monkeypatch)
|
|
children = [asyncio.create_task(asyncio.Event().wait()) for _ in range(2)]
|
|
manager.plugin_run_tasks.extend(children)
|
|
workload = asyncio.create_task(manager.launch_all_plugins())
|
|
try:
|
|
for _ in range(3):
|
|
await asyncio.sleep(0)
|
|
workload.cancel()
|
|
with pytest.raises(asyncio.CancelledError):
|
|
await workload
|
|
assert all(task.done() and task.cancelled() for task in children)
|
|
finally:
|
|
for task in [workload, *children]:
|
|
task.cancel()
|
|
await asyncio.gather(workload, *children, return_exceptions=True)
|