feat: reconcile granted ops run closes
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a06bfe-2a55-7ed3-bacd-879977b099bf
This commit is contained in:
parent
b72fdb5452
commit
b63131e863
21 changed files with 1240 additions and 43 deletions
|
|
@ -242,6 +242,47 @@ async def test_emit_tasks_refuses_absent_profile_in_strict_mode(monkeypatch) ->
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit_tasks_refuses_invalid_grant_before_any_side_effect(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
from temporalio.exceptions import ApplicationError
|
||||
|
||||
monkeypatch.setattr(
|
||||
activities,
|
||||
"get_issue_sink",
|
||||
lambda: pytest.fail("IssueSink must not be opened after grant refusal"),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
activities,
|
||||
"_get_session_factory",
|
||||
lambda: pytest.fail("DB must not be opened after grant refusal"),
|
||||
)
|
||||
|
||||
with pytest.raises(ApplicationError, match="repository grant refused") as exc_info:
|
||||
await activities.emit_tasks(
|
||||
{
|
||||
"activity_id": "00000000-0000-0000-0000-000000000001",
|
||||
"triggering_event_id": "event-1",
|
||||
"task_specs": [
|
||||
{
|
||||
"title": "Must not emit",
|
||||
"source_type": "rule",
|
||||
"source_id": "unsafe-grant",
|
||||
"repository_grant": {
|
||||
"version": "1",
|
||||
"allowed_paths": ["../escape"],
|
||||
"commit_count": {"min": 1, "max": 1},
|
||||
"publish": False,
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
assert exc_info.value.non_retryable is True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit_tasks_passes_unknown_versioned_profile_to_queue(monkeypatch) -> None:
|
||||
captured: dict[str, Any] = {}
|
||||
|
|
@ -297,6 +338,12 @@ async def test_emit_tasks_passes_unknown_versioned_profile_to_queue(monkeypatch)
|
|||
"correlation_id": "corr-9",
|
||||
"api_key": "must-be-dropped",
|
||||
},
|
||||
"repository_grant": {
|
||||
"version": "1",
|
||||
"allowed_paths": ["docs/", "README.md"],
|
||||
"commit_count": {"min": 1, "max": 1},
|
||||
"publish": False,
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
@ -306,3 +353,9 @@ async def test_emit_tasks_passes_unknown_versioned_profile_to_queue(monkeypatch)
|
|||
assert captured["harness_profile_ref"] == "harness.unknown-locally@9.9.9"
|
||||
assert captured["approach_hint"] == "legacy-only"
|
||||
assert captured["execution_refs"] == {"correlation_id": "corr-9"}
|
||||
assert captured["repository_grant"] == {
|
||||
"version": "1",
|
||||
"allowed_paths": ["docs/", "README.md"],
|
||||
"commit_count": {"min": 1, "max": 1},
|
||||
"publish": False,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue