feat: route profiled ops runs through Glas
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02b6f-7db1-7222-918b-e813a6bda38d
This commit is contained in:
parent
68ab94581a
commit
0f01c3e421
17 changed files with 895 additions and 11 deletions
93
tests/test_glas_execution.py
Normal file
93
tests/test_glas_execution.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
"""Tests for the authoritative activity-core -> Glas consumer boundary."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from rein_aharness.glas_execution import GlasExecutionError, execute_profiled_run
|
||||
from rein_aharness.ops_run_client import OpsRun, OpsRunConfig
|
||||
|
||||
|
||||
def _repo(tmp_path: Path) -> Path:
|
||||
repo = tmp_path / "target"
|
||||
repo.mkdir()
|
||||
subprocess.run(["git", "init", "-q"], cwd=repo, check=True)
|
||||
return repo
|
||||
|
||||
|
||||
def _run(repo: Path) -> OpsRun:
|
||||
return OpsRun(
|
||||
id="run-1",
|
||||
activity_definition_id="def-1",
|
||||
idempotency_key="key-1",
|
||||
target_repo="target",
|
||||
title="Governed task",
|
||||
description="Do the bounded work",
|
||||
state="claimed",
|
||||
harness_profile_ref="harness.agent-dev-local@1.0.0",
|
||||
approach_hint="agent-session",
|
||||
execution_refs={
|
||||
"correlation_id": "corr-1",
|
||||
"assignment_ref": "assignment:1",
|
||||
"role_ref": "role:1",
|
||||
"duty_ref": "duty:1",
|
||||
"goal_refs": ["goal:1"],
|
||||
"resource_envelope_refs": ["resource:1"],
|
||||
"unknown": "must-not-cross",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_profiled_run_builds_complete_execution_request(tmp_path: Path) -> None:
|
||||
repo = _repo(tmp_path)
|
||||
captured = {}
|
||||
|
||||
def request_factory(**kwargs):
|
||||
captured.update(kwargs)
|
||||
return kwargs
|
||||
|
||||
expected = {
|
||||
"ok": True,
|
||||
"evidence": {"outcome": "succeeded", "profile_ref": "profile"},
|
||||
"tool_output": "direct caller output",
|
||||
"tool_error": None,
|
||||
}
|
||||
result = execute_profiled_run(
|
||||
_run(repo),
|
||||
OpsRunConfig(worker_id="rein-aharness@test", repo_roots=(str(tmp_path),)),
|
||||
report_to_hub=False,
|
||||
request_factory=request_factory,
|
||||
gateway=lambda request: expected,
|
||||
)
|
||||
|
||||
assert result is expected
|
||||
assert captured == {
|
||||
"harness_profile_ref": "harness.agent-dev-local@1.0.0",
|
||||
"repo": str(repo.resolve()),
|
||||
"title": "Governed task",
|
||||
"description": "Do the bounded work",
|
||||
"actor": "rein-aharness@test",
|
||||
"project": "rein-aharness",
|
||||
"request_id": "run-1",
|
||||
"correlation_id": "corr-1",
|
||||
"assignment_ref": "assignment:1",
|
||||
"role_ref": "role:1",
|
||||
"duty_ref": "duty:1",
|
||||
"goal_refs": ["goal:1"],
|
||||
"resource_envelope_refs": ["resource:1"],
|
||||
"report_to_hub": False,
|
||||
}
|
||||
|
||||
|
||||
def test_profiled_run_rejects_invalid_gateway_result(tmp_path: Path) -> None:
|
||||
repo = _repo(tmp_path)
|
||||
with pytest.raises(GlasExecutionError, match="invalid GatewayResult"):
|
||||
execute_profiled_run(
|
||||
_run(repo),
|
||||
OpsRunConfig(repo_roots=(str(tmp_path),)),
|
||||
request_factory=lambda **kwargs: kwargs,
|
||||
gateway=lambda request: {"evidence": {}},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue