fix: claim/unclaim use view endpoint so tasks actually move buckets, log review skips at INFO
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Zoë 2026-05-31 07:42:57 -07:00
parent e092792730
commit 06798e68f6

View file

@ -185,10 +185,20 @@ def list_todo_tasks(vikunja_token: str, project_id: int, todo_id: int) -> list[d
] ]
def claim_task(vikunja_token: str, task_id: int, in_progress_id: int) -> bool: def claim_task(
"""Move task from Todo → In Progress.""" vikunja_token: str,
task_id: int,
in_progress_id: int,
project_id: int,
view_id: int,
) -> bool:
"""Move task from Todo → In Progress via the kanban view endpoint."""
try: try:
vikunja_post(vikunja_token, f"tasks/{task_id}", {"bucket_id": in_progress_id}) vikunja_post(
vikunja_token,
f"projects/{project_id}/views/{view_id}/buckets/{in_progress_id}/tasks",
{"task_id": task_id},
)
log.info("Moved task %d → In Progress (bucket %d)", task_id, in_progress_id) log.info("Moved task %d → In Progress (bucket %d)", task_id, in_progress_id)
return True return True
except Exception as e: except Exception as e:
@ -196,10 +206,20 @@ def claim_task(vikunja_token: str, task_id: int, in_progress_id: int) -> bool:
return False return False
def unclaim_task(vikunja_token: str, task_id: int, todo_id: int) -> None: def unclaim_task(
"""Move task back to Todo on job spawn failure.""" vikunja_token: str,
task_id: int,
todo_id: int,
project_id: int,
view_id: int,
) -> None:
"""Move task back to Todo on job spawn failure via the kanban view endpoint."""
try: try:
vikunja_post(vikunja_token, f"tasks/{task_id}", {"bucket_id": todo_id}) vikunja_post(
vikunja_token,
f"projects/{project_id}/views/{view_id}/buckets/{todo_id}/tasks",
{"task_id": task_id},
)
log.info("Unclaimed task %d → Todo", task_id) log.info("Unclaimed task %d → Todo", task_id)
except Exception as e: except Exception as e:
log.warning("Failed to unclaim task %d: %s", task_id, e) log.warning("Failed to unclaim task %d: %s", task_id, e)
@ -473,7 +493,7 @@ def orchestrate_review_tasks(
role = extract_agent_role(task) role = extract_agent_role(task)
if not role or role in REVIEW_SKIP_ROLES: if not role or role in REVIEW_SKIP_ROLES:
log.debug("Task %d role=%s skipped for review orchestration", task_id, role) log.info("Task %d role=%s skipped for review orchestration", task_id, role)
continue continue
spawn_review_pm_job( spawn_review_pm_job(
@ -697,7 +717,7 @@ def main() -> None:
continue continue
log.info("Claiming task %d (%s) for role=%s", task_id, title[:60], role) log.info("Claiming task %d (%s) for role=%s", task_id, title[:60], role)
if not claim_task(vikunja_token, task_id, in_progress_id): if not claim_task(vikunja_token, task_id, in_progress_id, project_id, view_id):
continue continue
try: try:
@ -707,7 +727,7 @@ def main() -> None:
active_by_role[role] = active_by_role.get(role, 0) + 1 active_by_role[role] = active_by_role.get(role, 0) + 1
except Exception as e: except Exception as e:
log.error("Failed to spawn job for task %d: %s", task_id, e) log.error("Failed to spawn job for task %d: %s", task_id, e)
unclaim_task(vikunja_token, task_id, todo_id) unclaim_task(vikunja_token, task_id, todo_id, project_id, view_id)
log.info("Dispatcher done. Claimed %d tasks.", claimed) log.info("Dispatcher done. Claimed %d tasks.", claimed)