fix: use filter API for bucket scanning, bucket_id is view-local not on task object
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Zoë 2026-05-30 21:01:34 -07:00
parent fbc5e33292
commit b0fb10706e

View file

@ -156,23 +156,32 @@ def vikunja_post(vikunja_token: str, path: str, body: dict) -> dict:
return resp.json() return resp.json()
def list_todo_tasks(vikunja_token: str, project_id: int, todo_id: int) -> list[dict]: def list_tasks_in_bucket(vikunja_token: str, project_id: int, bucket_id: int) -> list[dict]:
"""Return all undone tasks in the Todo bucket with agent labels.""" """Return all undone tasks in a specific bucket using the filter API."""
tasks = [] tasks = []
page = 1 page = 1
while True: while True:
batch = vikunja_get(vikunja_token, f"projects/{project_id}/tasks", page=page, per_page=50) batch = vikunja_get(
vikunja_token,
f"projects/{project_id}/tasks",
page=page,
per_page=50,
filter=f"bucket_id = {bucket_id}",
)
if not batch: if not batch:
break break
tasks.extend(batch) tasks.extend(batch)
if len(batch) < 50: if len(batch) < 50:
break break
page += 1 page += 1
return [t for t in tasks if not t.get("done")]
def list_todo_tasks(vikunja_token: str, project_id: int, todo_id: int) -> list[dict]:
"""Return all undone tasks in the Todo bucket that have agent labels."""
return [ return [
t for t in tasks t for t in list_tasks_in_bucket(vikunja_token, project_id, todo_id)
if not t.get("done") if t.get("labels")
and t.get("labels")
and t.get("bucket_id") == todo_id
] ]
@ -297,18 +306,7 @@ def watchdog_stale_tasks(
- attempt count < MAX_TASK_RETRIES move back to Todo - attempt count < MAX_TASK_RETRIES move back to Todo
- attempt count >= MAX_TASK_RETRIES move to Backlog + comment - attempt count >= MAX_TASK_RETRIES move to Backlog + comment
""" """
page = 1 stale = list_tasks_in_bucket(vikunja_token, project_id, in_progress_id)
tasks = []
while True:
batch = vikunja_get(vikunja_token, f"projects/{project_id}/tasks", page=page, per_page=50)
if not batch:
break
tasks.extend(batch)
if len(batch) < 50:
break
page += 1
stale = [t for t in tasks if not t.get("done") and t.get("bucket_id") == in_progress_id]
log.info("Watchdog: checking %d InProgress tasks", len(stale)) log.info("Watchdog: checking %d InProgress tasks", len(stale))
for task in stale: for task in stale:
@ -467,21 +465,7 @@ def orchestrate_review_tasks(
Scan the Review bucket. For each task that has a non-pm/non-reviewer agent Scan the Review bucket. For each task that has a non-pm/non-reviewer agent
label and no review-pm job yet, spawn a PM agent to create review sub-tasks. label and no review-pm job yet, spawn a PM agent to create review sub-tasks.
""" """
page = 1 review_tasks = list_tasks_in_bucket(vikunja_token, project_id, in_review_id)
tasks = []
while True:
batch = vikunja_get(vikunja_token, f"projects/{project_id}/tasks", page=page, per_page=50)
if not batch:
break
tasks.extend(batch)
if len(batch) < 50:
break
page += 1
review_tasks = [
t for t in tasks
if not t.get("done") and t.get("bucket_id") == in_review_id
]
log.info("Review orchestration: checking %d tasks in Review bucket", len(review_tasks)) log.info("Review orchestration: checking %d tasks in Review bucket", len(review_tasks))
for task in review_tasks: for task in review_tasks: