run logs: read a job's task by id, page the task list, keep loaded logs on the older-server path (CLS-1022) #301
Loading…
Reference in a new issue
No description provided.
Delete branch "stephen/cls-1022-run-logs-edge-cases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The two edge cases deferred from #300 (CLS-963).
GET /actions/tasksignores itsrunfilter on Forgejo 16 and answers with repository tasks, so the run's task could be absent from a capped or shifted list while its logs exist in Loki. Now:task_id) is matched to that task by id, not by its position in the list. A task that is not in the list is a retrieval error for that job (the others still print, and the command fails after printing), not "log unavailable".list_run_taskspages (limit=50,page=N) until the wanted ids are found, the walk has passed them (the list is newest first), or the list is exhausted (total_countreached, or a page with nothing new). A short page is not taken as the end, since a server may clamp the page size. A list cut off by the 40 page cap, by a page that fails after the first, or by a page that repeats while the count says more, comes back marked incomplete with what was found: resolved tasks still read, unresolved ones fail with the reason. A first page that fails is an error.task_idis matched by position in the run's whole list, so any such job makes the walk exhaustive; with an incomplete list it fails instead of guessing.fetch_run_logs_from_tasks, explicitly configured Loki) returned on the first failed Loki query. It now settles each task on its own like the native path: failures are kept inerrors(the command fails after printing), a confirmed-missing log reads as unavailable, and it only returns an error when nothing at all loaded.I probed the live endpoint read-only first: it honours
limitandpage, returnstotal_count, and orders newest first.Failure paths
list_run_tasksagainst wiremock, and throughfetch_run_logs_with_sourcesfor the per-job outcome.total_countcosts one extra confirming request (the integration mocks now expect 1 to 2 task requests). Forgejo 16 sends the count; the native path still never loads the list when Forgejo serves the logs (existing test).Fix scope
run view --logandrun logsthroughfetch_run_logs.workflow_logs.rsplus the four integration mocks that count task requests.cargo testpasses; clippy shows nothing in the touched files (it flagschunks_exactinsrc/cli/pr_line_comment.rs, which is not part of this change).Known edge cases (follow-up)
Closes CLS-1022.
Automated Codex review (read-only) of head
7dbbe28faf.src/api/workflow_logs.rs:1027. Invariant: incomplete reads must not certify completeness (standards 8 and 15).seen.len()includes tasks deleted between requests, so comparing it with the latesttotal_countcan terminate the walk early. For example, with two tasks per page, read[30,29], then delete task 30. Page 2 returns[27], skipping task 28 because offsets shifted. The new total is 3, matchingseen.len(), so this incomplete list is marked complete. Newly paginated positional fallback can consequently assign task 27 to task 28's job; the older-server adapter can silently omit task 28. Both CLI entry points inherit this behavior. Detect changing counts and mark the result incomplete, or restart against a stable list before certifying positional matches. Add a real-adapter deletion-between-pages test.The documented 2000-task cap remains an accepted follow-up.
BLOCKING: 0
Reviewed head
7dbbe28fafat 2026-10-31T19:35:53Z by codex exec (read-only sandbox).