feat(workbench): keep only actionable notifications
This commit is contained in:
@@ -132,11 +132,16 @@ async def test_postgres_task_artifacts_approval_and_project_isolation_roll_back(
|
||||
assert member_notifications
|
||||
assert all(item.task_id == task.task_id for item in member_notifications)
|
||||
action_pending = next(
|
||||
item for item in member_notifications if item.kind == "action_pending"
|
||||
item for item in member_notifications
|
||||
if item.kind == "action_approval_pending"
|
||||
)
|
||||
task_created = next(
|
||||
item for item in member_notifications if item.kind == "task_created"
|
||||
human_input = next(
|
||||
item for item in member_notifications
|
||||
if item.kind == "human_input_required"
|
||||
)
|
||||
assert not any(item.kind in {
|
||||
"task_created", "report_updated", "task_completed"
|
||||
} for item in member_notifications)
|
||||
assert action_pending.required_permission == action.required_approval_permission
|
||||
|
||||
viewer_context = ProjectContext(
|
||||
@@ -153,7 +158,7 @@ async def test_postgres_task_artifacts_approval_and_project_isolation_roll_back(
|
||||
viewer_notifications, _ = await viewer_service.list_notifications(
|
||||
unread_only=True, limit=100, offset=0
|
||||
)
|
||||
assert task_created.notification_id in {
|
||||
assert human_input.notification_id in {
|
||||
item.notification_id for item in viewer_notifications
|
||||
}
|
||||
assert action_pending.notification_id not in {
|
||||
@@ -161,9 +166,9 @@ async def test_postgres_task_artifacts_approval_and_project_isolation_roll_back(
|
||||
}
|
||||
|
||||
acknowledged = await service.acknowledge_notification(
|
||||
task_created.notification_id,
|
||||
human_input.notification_id,
|
||||
NotificationAcknowledgeCommand(
|
||||
request_id=uuid4(), expected_version=task_created.version
|
||||
request_id=uuid4(), expected_version=human_input.version
|
||||
),
|
||||
)
|
||||
assert acknowledged.status == "read"
|
||||
@@ -179,21 +184,21 @@ async def test_postgres_task_artifacts_approval_and_project_isolation_roll_back(
|
||||
)
|
||||
persisted_created = next(
|
||||
item for item in persisted_notifications
|
||||
if item.notification_id == task_created.notification_id
|
||||
if item.notification_id == human_input.notification_id
|
||||
)
|
||||
assert persisted_created.status == "read"
|
||||
assert persisted_created.version == task_created.version + 1
|
||||
assert persisted_created.version == human_input.version + 1
|
||||
assert persisted_created.read_by == f"principal:{context.user_id}"
|
||||
unread_notifications, _ = await persisted_service.list_notifications(
|
||||
unread_only=True, limit=100, offset=0
|
||||
)
|
||||
assert task_created.notification_id not in {
|
||||
assert human_input.notification_id not in {
|
||||
item.notification_id for item in unread_notifications
|
||||
}
|
||||
viewer_after_member_ack, _ = await viewer_service.list_notifications(
|
||||
unread_only=True, limit=100, offset=0
|
||||
)
|
||||
assert task_created.notification_id in {
|
||||
assert human_input.notification_id in {
|
||||
item.notification_id for item in viewer_after_member_ack
|
||||
}
|
||||
action = await service.decide_action(task.task_id, action.action_id, ActionDecisionCommand(
|
||||
|
||||
@@ -357,6 +357,7 @@ async def test_complete_without_same_generation_artifacts_fails_run_explicitly()
|
||||
assert repository.run["failure_code"] == "ARTIFACT_INCOMPLETE"
|
||||
assert completed.lifecycle_status == "failed"
|
||||
assert completed.active_run is None
|
||||
assert [item["kind"] for item in repository.notifications] == ["task_failed"]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -451,6 +452,9 @@ async def test_plan_only_keeps_lease_until_same_generation_report_closes_run():
|
||||
)
|
||||
assert completed.status == "waiting_human"
|
||||
assert completed.agent_lease_expires_at is None
|
||||
assert [item["kind"] for item in repository.notifications] == [
|
||||
"human_input_required"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -521,6 +525,9 @@ async def test_action_proposal_keeps_running_lease_until_plan_and_report_close_r
|
||||
)
|
||||
assert closed.status == "waiting_human"
|
||||
assert closed.actions[0].action_id == action.action_id
|
||||
assert [item["kind"] for item in repository.notifications] == [
|
||||
"action_approval_pending"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -786,6 +793,9 @@ async def test_interrupted_submit_replays_unknown_without_dispatching_twice():
|
||||
assert dispatcher.calls == 1
|
||||
assert replay.execution_status == "unknown"
|
||||
assert replay.execution_request_id is not None
|
||||
assert [item["kind"] for item in repository.notifications] == [
|
||||
"external_coordination_failed"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
Reference in New Issue
Block a user