mirror of
https://github.com/devvmhq/ciwatch.git
synced 2026-12-01 06:13:17 -10:00
After a rerun, jobs and logs come from the reported attempt, but crash artifacts are listed for the whole run. Since upload-artifact v4 an artifact name can be used only once per run, so when attempt 2 crashes the same target again, the crash artifact the run lists is attempt 1's. For a run reported at attempt 2 or later with at least one crash artifact, ciwatch now asks once when that attempt started, with the same retries as the artifact listing. A crash artifact created strictly before that start is marked: one stderr line names it, as "was uploaded by attempt 1, not attempt 2" or, from attempt 3, "by an attempt before attempt N", and --json gets "earlier_attempt": true. The input is still listed and still fetched with --fetch-crashes, and exit codes don't change. If the lookup fails, ciwatch warns once and marks nothing; after it runs out of network retries, later runs' lookups aren't retried. Ctrl-C during it exits 4 before anything is fetched. Attempts 0 and 1, and runs without crash artifacts, make no call. An artifact with no usable created_at is never marked. The comparison rests on GitHub rerunning only completed runs and on both timestamps coming from GitHub's clock. If that is wrong, an artifact created within moments of the attempt's start could be mislabelled; only the label and one stderr line are affected. gh.Artifact gains CreatedAt, Artifacts asks for created_at, and the new Runner.AttemptStarted reads run_started_at. docs/json.md, the README and AGENTS.md are updated. The tests add a fake attempts call, a recorded attempt-start fixture and a hand-written artifacts fixture. AC-1's "calls unchanged" at attempt 1 means no attempts call and the same sequence of gh calls; the artifacts --jq now asks for created_at at every attempt. Left from review: - internal/gh/gh.go: the artifacts --jq asks for created_at at attempt 1 too, so AC-1's "calls byte-for-byte unchanged" doesn't hold literally; making the query depend on the attempt wasn't worth the complexity. Backlog: - TestFuzzAttemptOneUnchanged doesn't compare stdout and stderr byte for byte with a run before the change, as AC-1 words it. Off the path: test tightness, the behaviour works. - When the attempt start doesn't parse, the warning ends with "decoding gh api output: parsing time ...", which doesn't name the attempts call. Off the path: message clarity, the line already names the run. Spec: acceptance cases AC-1: A failed run at attempt 1 with a crash artifact. Stdout, stderr, `--json` and the `gh` calls are byte-for-byte what they are today. There is no attempts call and no `earlier_attempt` field. Exit 1. AC-2: A failed run at attempt 2, where `crash-FuzzParse` has `created_at` 2026-11-13T23:58:40Z and attempt 2 started at 2026-11-14T00:15:04Z. - stderr gets exactly one line: `ciwatch: crash-FuzzParse of run 43529187615 (CI) was uploaded by attempt 1, not attempt 2` - `--json` has `"earlier_attempt": true` on that crash. - With `--fetch-crashes` it is still downloaded to the same place as today. - Exit 1, as today. AC-3: The same run, with `crash-FuzzOther` created at 2026-11-14T00:21:02Z (after attempt 2 started). No line and no field for that artifact. If a run has one artifact of each kind, only the earlier one is marked. AC-4: A run at attempt 3 with an artifact created before attempt 3 started. The line reads `… was uploaded by an attempt before attempt 3`. We can't tell whether that was attempt 1 or 2. AC-5: A run at attempt 2 where the attempts call fails (not a network error). - stderr gets exactly one line: `ciwatch: can't tell which crash inputs of run 43529187615 (CI) came from an earlier attempt: <error>` - No crash is marked, the output is otherwise as today, and the exit code doesn't change. - A network or temporary error is retried like the artifact listing, and the warning comes after the retries run out. AC-6: Ctrl-C during the attempts call, or during its backoff, prints `ciwatch: context canceled` with no table and exits 4. Nothing has been fetched yet at that point. AC-7: A run at attempt 0 (gh didn't say), or a failed run at attempt 2 with no crash artifacts. There is no attempts call and the output is as today. AC-8: A run at attempt 2 whose artifact has no `created_at`, or one that doesn't parse. That artifact is not marked and gets no line. This is the case for the existing recorded fixture, which lacks the field. Spec: non-goals - Handling two artifacts with the same name (upload-artifact v4+ makes that impossible). - Downloading by artifact ID. - Showing artifacts per attempt, or naming exactly which earlier attempt when N ≥ 3. - Changing exit codes, or skipping or refusing to fetch earlier-attempt inputs. - Marking earlier-attempt inputs in the table output (stderr carries it). - Artifacts other than `crash-Fuzz*`. Spec: inference There is one place: comparing artifact `created_at` against attempt N's `run_started_at`. It rests on two things: GitHub reruns only a completed run, and both timestamps come from GitHub's own clock. If that's wrong, an artifact created within moments of attempt N's start could be labelled the wrong way. The comparison is strict (`created_at` before start), so equal times count as the current attempt. If the guess is wrong, the only effect is a wrong label and one stderr line: fetching and exit codes don't change. Spec: approved with Approved under CJ's standing delegation, including the single-boundary inference: a wrong guess only mislabels and adds one stderr line, and fetching and exit codes don't change. Your three answers are accepted: no table mark, no mark without created_at, and no attempts call without crash artifacts. Record the attempt-start fixture read-only from the real call as planned. Built in steps: - test(cli): cover marking crash inputs from an earlier attempt - feat(cli): say which crash inputs came from an earlier attempt - docs: describe crash inputs from an earlier attempt in the README - fix(cli): polish from review Co-Authored-By: Claude Sonnet 5.5 <[email protected]>