fix(pipeline): decouple Runner from extension permissions (LANG-54) (#2723)

* fix(pipeline): decouple runner from extension allowlist

Co-authored-by: multica-agent <[email protected]>

* fix(pipeline): complete runner diagnostics and real runtime coverage

Co-authored-by: multica-agent <[email protected]>

---------

Co-authored-by: multica-agent <[email protected]>
This commit is contained in:
RockChinQ
2026-10-19 23:07:11 +08:00
committed by GitHub
co-authored by multica-agent
parent 5a6ddbff6f
commit d9e4e7d9df
24 changed files with 1012 additions and 35 deletions
+11 -10
View File
@@ -8,7 +8,7 @@ import pytest
from langbot.pkg.agent.runner.registry import RunnerRegistry
from langbot.pkg.agent.runner.descriptor import RunnerDescriptor
from langbot.pkg.agent.runner.errors import RunnerNotFoundError, RunnerNotAuthorizedError
from langbot.pkg.agent.runner.errors import RunnerNotFoundError
from langbot.pkg.api.http.context import ExecutionContext
@@ -242,8 +242,9 @@ class TestRegistryGet:
assert ap.plugin_connector.list_runners.await_count == 2
@pytest.mark.asyncio
async def test_get_runner_with_bound_plugins_filter(self):
"""Get runner with bound plugins authorization."""
@pytest.mark.parametrize('plugins', [None, [], ['langbot-team/LocalAgent']])
async def test_get_runner_independent_of_extension_filter(self, plugins):
"""Selecting a Runner must not grant or require extension authorization."""
ap = FakeApplication()
registry = RunnerRegistry(ap)
@@ -255,13 +256,13 @@ class TestRegistryGet:
)
assert descriptor is not None
# Not authorized - plugin not in bound list
with pytest.raises(RunnerNotAuthorizedError):
await registry.get(
TEST_CONTEXT,
'plugin:alice/my-agent/custom',
bound_plugins=['langbot-team/LocalAgent'],
)
descriptor = await registry.get(
TEST_CONTEXT,
'plugin:alice/my-agent/custom',
bound_plugins=plugins,
)
assert descriptor.id == 'plugin:alice/my-agent/custom'
assert plugins in (None, [], ['langbot-team/LocalAgent'])
class TestRegistryMetadataForPipeline:
@@ -0,0 +1,39 @@
import ast
import yaml
from langbot_plugin.api.entities.builtin.runner.manifest import RunnerManifest
from langbot_plugin.api.definition.components.manifest import ComponentManifest
from tests.e2e.test_runner_plugin_runtime import _write_qa_runner_plugin
def test_real_runtime_fixture_contains_all_four_component_kinds(tmp_path):
_write_qa_runner_plugin(tmp_path)
manifest = yaml.safe_load((tmp_path / 'manifest.yaml').read_text())
assert set(manifest['spec']['components']) == {'Runner', 'Tool', 'Command', 'EventListener'}
kinds = set()
for path in (tmp_path / 'components').rglob('*.yaml'):
raw = yaml.safe_load(path.read_text())
component = ComponentManifest(
owner='e2e/agent-runner-qa', manifest=raw, rel_path=str(path.relative_to(tmp_path))
)
kinds.add(component.kind)
if component.kind == 'Runner':
spec = raw['spec']
runner = RunnerManifest(
id=f'plugin:e2e/agent-runner-qa/{raw["metadata"]["name"]}',
name=raw['metadata']['name'],
label=raw['metadata']['label'],
usages=spec['usages'],
supported_event_patterns=spec.get('events') or ['*'],
capabilities=spec.get('capabilities') or {},
permissions=spec.get('permissions') or {},
config_schema=spec.get('config') or [],
)
if path.stem == 'default':
assert runner.capabilities.tool_calling is True
assert set(runner.permissions.tools) == {'detail', 'call'}
assert kinds == {'Runner', 'Tool', 'Command', 'EventListener'}
for path in tmp_path.rglob('*.py'):
ast.parse(path.read_text(), filename=str(path))