Add reconciliation state-change API contract

This commit is contained in:
2026-05-23 17:22:12 +02:00
parent 4d62768a3a
commit add650d4fa
5 changed files with 219 additions and 1 deletions

View File

@@ -392,3 +392,75 @@ class TestFlowEndpoints:
r = await client.get(f"/workstreams/{ws['id']}")
assert r.json()["status"] == "active"
class TestReconciliationEndpoints:
async def test_classify_workstream_open_transition_write_through(self, client):
await _create_domain(client)
topic = await _create_topic(client)
ws = await _create_workstream(client, topic["id"])
r = await client.post("/reconciliation/state-change", json={
"target_type": "workstream",
"target_id": ws["id"],
"target_status": "backlog",
"actor": "dashboard",
"intent": "push back to backlog",
"file_backed": True,
})
assert r.status_code == 200
body = r.json()
assert body["current_status"] == "active"
assert body["target_status"] == "backlog"
assert body["reconciliation_class"] == "write_through"
assert body["write_through_result"] == "not_attempted"
assert body["intent"] == "push back to backlog"
async def test_classify_workstream_finish_with_open_task_needs_confirmation(self, client):
await _create_domain(client)
topic = await _create_topic(client)
ws = await _create_workstream(client, topic["id"])
await _create_task(client, ws["id"])
r = await client.post("/reconciliation/state-change", json={
"target_type": "workstream",
"target_id": ws["id"],
"target_status": "finished",
"file_backed": True,
})
assert r.status_code == 200
body = r.json()
assert body["tasks_terminal"] is False
assert body["reconciliation_class"] == "human_confirmation"
assert "open work" in body["reason"]
async def test_classify_task_blocked_without_reason_needs_confirmation(self, client):
await _create_domain(client)
topic = await _create_topic(client)
ws = await _create_workstream(client, topic["id"])
task = await _create_task(client, ws["id"])
r = await client.post("/reconciliation/state-change", json={
"target_type": "task",
"target_id": task["id"],
"target_status": "blocked",
"file_backed": True,
"task_linked": True,
})
assert r.status_code == 200
body = r.json()
assert body["current_status"] == "todo"
assert body["reconciliation_class"] == "human_confirmation"
assert "blocking reason" in body["reason"]
async def test_classify_unknown_workstream_returns_404(self, client):
r = await client.post("/reconciliation/state-change", json={
"target_type": "workstream",
"target_id": "00000000-0000-0000-0000-000000000001",
"target_status": "active",
})
assert r.status_code == 404