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
|
|
@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
from rein_aharness.approaches import ApproachResult, APPROACH_FI_RESEARCH_BRIEF
|
||||
from rein_aharness.claim_loop import process_one, poll_peek
|
||||
from rein_aharness.glas_execution import GLAS_APPROACH, GlasExecutionError
|
||||
from rein_aharness.ops_run_client import OpsRun, OpsRunConfig, ActivityCoreOpsClient
|
||||
|
||||
|
||||
|
|
@ -95,3 +96,90 @@ def test_poll_peek() -> None:
|
|||
rows = poll_peek(client)
|
||||
assert len(rows) == 1
|
||||
assert rows[0]["approach"] == APPROACH_FI_RESEARCH_BRIEF
|
||||
|
||||
|
||||
def test_profiled_run_uses_glas_and_completes_with_full_result() -> None:
|
||||
client = MagicMock(spec=ActivityCoreOpsClient)
|
||||
client.config = OpsRunConfig(worker_id="w", lease_seconds=90)
|
||||
run = _claimed_run()
|
||||
run.harness_profile_ref = "harness.agent-dev-local@1.0.0"
|
||||
run.approach_hint = "fi-research-brief"
|
||||
client.claim.return_value = [run]
|
||||
client.complete.return_value = OpsRun(
|
||||
id=run.id,
|
||||
activity_definition_id="def",
|
||||
idempotency_key="k",
|
||||
target_repo=run.target_repo,
|
||||
title=run.title,
|
||||
description="",
|
||||
state="succeeded",
|
||||
)
|
||||
gateway_result = {
|
||||
"ok": True,
|
||||
"evidence": {
|
||||
"outcome": "succeeded",
|
||||
"profile_ref": run.harness_profile_ref,
|
||||
"sandbox_id": "sbx-1",
|
||||
},
|
||||
"tool_output": "not copied into ProcessResult.detail",
|
||||
"tool_error": None,
|
||||
}
|
||||
with (
|
||||
patch("rein_aharness.claim_loop.execute_profiled_run", return_value=gateway_result),
|
||||
patch("rein_aharness.claim_loop.select_approach") as select,
|
||||
patch("rein_aharness.claim_loop.execute_approach") as execute,
|
||||
):
|
||||
result = process_one(client)
|
||||
|
||||
assert result.ok is True
|
||||
assert result.approach == GLAS_APPROACH
|
||||
assert result.detail == {"execution_evidence": gateway_result["evidence"]}
|
||||
client.complete.assert_called_once_with(run.id, result=gateway_result)
|
||||
client.fail.assert_not_called()
|
||||
select.assert_not_called()
|
||||
execute.assert_not_called()
|
||||
|
||||
|
||||
def test_profile_refusal_fails_terminally_without_legacy_fallback() -> None:
|
||||
client = MagicMock(spec=ActivityCoreOpsClient)
|
||||
client.config = OpsRunConfig(worker_id="w", lease_seconds=90)
|
||||
run = _claimed_run()
|
||||
run.harness_profile_ref = "harness.unknown@9.9.9"
|
||||
run.approach_hint = "fi-research-brief"
|
||||
client.claim.return_value = [run]
|
||||
client.fail.return_value = OpsRun(
|
||||
id=run.id,
|
||||
activity_definition_id="def",
|
||||
idempotency_key="k",
|
||||
target_repo=run.target_repo,
|
||||
title=run.title,
|
||||
description="",
|
||||
state="failed",
|
||||
)
|
||||
with (
|
||||
patch(
|
||||
"rein_aharness.claim_loop.execute_profiled_run",
|
||||
side_effect=GlasExecutionError("unknown harness profile"),
|
||||
),
|
||||
patch("rein_aharness.claim_loop.select_approach") as select,
|
||||
patch("rein_aharness.claim_loop.execute_approach") as execute,
|
||||
):
|
||||
result = process_one(client)
|
||||
|
||||
assert result.ok is False
|
||||
assert result.ops_state == "failed"
|
||||
assert client.fail.call_args.kwargs["reopen"] is False
|
||||
select.assert_not_called()
|
||||
execute.assert_not_called()
|
||||
|
||||
|
||||
def test_poll_peek_reports_authoritative_profile_route() -> None:
|
||||
client = MagicMock(spec=ActivityCoreOpsClient)
|
||||
run = _claimed_run()
|
||||
run.harness_profile_ref = "harness.agent-dev-local@1.0.0"
|
||||
client.list_open.return_value = [run]
|
||||
with patch("rein_aharness.claim_loop.select_approach") as select:
|
||||
rows = poll_peek(client)
|
||||
assert rows[0]["approach"] == GLAS_APPROACH
|
||||
assert rows[0]["harness_profile_ref"] == run.harness_profile_ref
|
||||
select.assert_not_called()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue