fix(awooop): record source review dry-run audit
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
CD Pipeline / tests (push) Successful in 4m4s
CD Pipeline / build-and-deploy (push) Successful in 3m34s
CD Pipeline / post-deploy-checks (push) Successful in 1m49s

This commit is contained in:
Your Name
2026-05-21 09:08:46 +08:00
parent 2e54b803f0
commit b5deca91df
3 changed files with 138 additions and 44 deletions

View File

@@ -555,6 +555,82 @@ def test_build_recurrence_work_item_dry_run_returns_ticket_preview_without_write
assert dry_run["read_model_route"]["required_scope"] == "read"
@pytest.mark.asyncio
async def test_source_correlation_dry_run_history_records_without_incident(
monkeypatch,
) -> None:
appended: list[dict[str, object]] = []
class FakeRecord:
id = "alert-op-1"
class FakeRepo:
async def append(self, event_type: str, **kwargs): # noqa: ANN001
appended.append({"event_type": event_type, **kwargs})
return FakeRecord()
from src.repositories import alert_operation_log_repository
monkeypatch.setattr(
alert_operation_log_repository,
"get_alert_operation_log_repository",
lambda: FakeRepo(),
)
history = (
await channel_event_dossier_service._record_recurrence_work_item_dry_run_history(
{
"source": "channel_event_dossier.recurrence",
"project_id": "awoooi",
"work_item_id": (
"source-evidence:sentry:upstream_canary:"
"awoooi-canary-codex-t115-production"
),
"incident_id": None,
"auto_repair_id": None,
"mode": "observe",
"requested_mode": "auto",
"allowed": True,
"executed": True,
"safety_level": "read_only",
"writes_incident_state": False,
"writes_auto_repair_result": False,
"writes_ticket": False,
"verification_result_preview": "observe_only",
"current_state_summary": {
"work_item_kind": "source_correlation_review",
"work_item_next_step": "review_provider_source_match",
"repair_status": "source_correlation_review",
"latest_stage": "upstream_canary",
"latest_provider_event_id": (
"sentry:upstream_canary:"
"awoooi-canary-codex-t115-production"
),
},
"ticket_preview": {"would_create": False},
"read_model_route": {
"agent_id": "awooop_recurrence_coordinator",
"tool_name": "channel_event_dossier.recurrence",
"required_scope": "read",
},
"checks": [],
"next_step": "review_provider_source_match",
}
)
)
assert history == {
"recorded": True,
"alert_operation_id": "alert-op-1",
"timeline_event_id": None,
"timeline_reason": "source_review_not_incident_scoped",
}
assert appended[0]["event_type"] == "PRE_FLIGHT_PASSED"
assert appended[0]["incident_id"] is None
assert appended[0]["actor"] == "awooop_recurrence_work_item_service"
assert appended[0]["context"]["work_item_id"].startswith("source-evidence:")
def test_build_recurrence_work_item_handoff_records_ticket_proposal_contract() -> None:
recurrence = build_dossier_recurrence(
[