Files
w3cjandClaude Sonnet 5.5 7c4f7c74a2 feat(cli): show no jobs under a kept run that wasn't completed
A run that drops out of gh run list is kept at its last listed state,
but its jobs were still fetched with gh run view. A run last seen
in_progress could then show an in_progress row above jobs that GitHub
now reports as completed. ciwatch now skips the jobs fetch for a run
that the latest list doesn't have and that was last seen in any status
other than completed. Its table row has no job rows under it, and in
--json its jobs array is empty with no jobs_error. The existing "no
longer listed" warning still explains it, and the exit code is still 4.

A kept run last seen completed is fetched at its reported attempt as
before, and so are runs that never drop out, runs that come back before
the last list, and every run under --once. The rule is a small method
on listed, keptUnfinished, and docs/json.md says when jobs is empty for
this reason.

The new tests cover the table for in_progress, queued, waiting,
requested and pending, the --json output, and a rerun's new attempt
that drops out. The test for a kept run that passed now checks the full
table with its job rows, so a skip that is too broad would fail it.

Backlog: TestWatchRunVanishesInProgressJSON checks only in_progress.
It could loop over the same five statuses as the table test. It is off
this feature's path because the behaviour works and the table subtests
already cover every status that isn't completed, so it only makes the
test stricter.

Spec: acceptance cases
1. AC-1: A run last seen `in_progress` drops out and is still missing at the last list (`ciwatch <sha>`). The table shows its row `CI  in_progress` with no job rows under it. `gh run view` isn't called for it. Stderr has the existing `ciwatch: run <id> (CI) is no longer listed for this commit` line once. Exit code is 4.
2. AC-2: Same as AC-1 with `--json`. That run's `jobs` is `[]` and it has no `jobs_error`. Its other fields come from its last listed state. Exit code is 4.
3. AC-3: Under `--rerun-failed`, a run's new attempt is last seen `in_progress` and then drops out for good. Its row is `CI  in_progress` with no job rows, and there's no `gh run view` for it. The warning ends with `; not waiting for it`. Exit code is 4.
4. AC-4: A kept run last seen `completed` (failure or success) gets its jobs fetched and shown exactly as today. That includes failure blocks, `--go-tests` and crash hints. Exit codes are 1 and 0, as today.
5. AC-5: A run that drops out and comes back before the last list is reported with its jobs, exactly as today.
6. AC-6: Runs that never drop out, including in `--once` mode, which never tracks dropped runs, report their jobs exactly as today. All existing golden files stay byte-for-byte the same.
7. AC-7: Statuses other than `in_progress` that aren't completed (`queued`, `waiting`, `requested`, `pending`) on a kept run are treated like AC-1.

Spec: non-goals
- Looking up the missing run by ID to get its real current state.
- Marking the run as kept in `--json`, or adding any new field.
- A new stderr line, or a table note such as "(jobs not shown)". The existing "no longer listed" warning is the explanation.
- Changing how a kept completed run's jobs are fetched, or what attempt they're fetched at.
- Kept runs' artifacts, timeouts and crash lookups. These already skip runs that aren't completed.

Spec: inference
none. The rule rests only on two facts ciwatch already has: whether the run was missing from the last list (`listed.missing`), and the status from its last listing.
**Behaviour.** No new flags, and exit codes are unchanged. Example: CI was `in_progress` when it dropped out, and Docs passed:
```
$ ciwatch abc1234
ciwatch: run 111 (CI) is no longer listed for this commit
WORKFLOW  STATUS       CONCLUSION
CI        in_progress
Docs      completed    success
  build   completed    success
$ echo $?
4
```
Today, rows such as `  test  completed  failure` would appear under `CI  in_progress`.

Spec: approved with
Approved under CJ's standing delegation: no inference, and the choice removes the mismatch from both the table and --json. Your answers are accepted: no placeholder line, and kept completed runs are still fetched at their reported attempt.

Built in steps:
- test(cli): no job rows under a kept run that wasn't completed
- feat(cli): don't fetch jobs for a kept run that wasn't completed

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-24 00:21:40 -07:00

4.7 KiB

The --json output

ciwatch --json <commit> prints one compact JSON document on stdout, and the table is drawn from the same data.

Versioning

The top-level schema field is the version of this document, currently 1. Adding a field keeps the version. Removing a field or changing its meaning bumps it.

Schema 1 is not frozen yet: it freezes at ciwatch's first release, and until then fields may still be removed without a bump.

Fields

Field Type Present
schema integer always
sha string always: the commit the runs are for
runs array of objects always
runs[].id integer always
runs[].attempt integer always: 1 for a run's first attempt, higher after a rerun (--rerun-failed), 0 when gh doesn't report it; the report is of this attempt
runs[].workflow string always
runs[].status string always
runs[].conclusion string always, empty while the run is not completed
runs[].url string always
runs[].jobs array of objects always, empty if the jobs could not be fetched, or if the run is no longer listed and was last seen not completed
runs[].jobs_error string only when the run's jobs could not be fetched
runs[].fuzz_crashes array of objects only for a failed run (failure or timed_out) with crash-Fuzz<Name> artifacts, in the order the API lists them
runs[].fuzz_crashes[].target string always, with fuzz_crashes: the fuzz target, from the artifact name
runs[].fuzz_crashes[].artifact string always, with fuzz_crashes: the artifact's name, crash-<target>
runs[].fuzz_crashes[].run_id integer always, with fuzz_crashes: the run the artifact belongs to
runs[].fuzz_crashes[].earlier_attempt boolean only when the run is reported at attempt 2 or later and the artifact was created before that attempt started, so an earlier attempt uploaded it; it is still listed and fetched
runs[].fuzz_crashes[].fetched_to string only with --fetch-crashes, once downloaded or already present: the directory, relative to the checkout
runs[].fuzz_crashes[].already_present boolean only with --fetch-crashes, when every file of the artifact was already in fetched_to
runs[].fuzz_crashes[].fetch_error string only with --fetch-crashes, when the download was skipped or failed
runs[].artifacts_error string only when the run's artifacts could not be listed
runs[].newer_run object only for a cancelled run whose workflow has a first run after it on the branch, for another commit
runs[].newer_run.id integer always, with newer_run: the newer run's ID
runs[].newer_run.sha string always, with newer_run: the newer run's commit
runs[].jobs[].id integer always
runs[].jobs[].name string always
runs[].jobs[].status string always
runs[].jobs[].conclusion string always, empty while the job is not completed
runs[].jobs[].url string always
runs[].jobs[].timed_out_after string only for a cancelled job whose check-run annotation says it exceeded the maximum execution time: the limit as GitHub gives it, such as 1m0s; conclusion stays cancelled
runs[].jobs[].steps array of objects only for a failed or timed-out job whose log was read, empty if no failed (for a timed-out job, cancelled) step had a line in the log
runs[].jobs[].steps[].name string always: the failed step's name, or (job log) when the job has no failed step
runs[].jobs[].steps[].lines array of strings always: the last 40 lines of the step's log, without gh's prefix and the timestamp
runs[].jobs[].steps[].omitted integer always: how many earlier lines were left out, 0 if none
runs[].jobs[].log_error string only for a failed or timed-out job whose log could not be read
runs[].jobs[].tests array of objects only with --go-tests, for a failed or timed-out job whose log was read, empty if no failing test was found
runs[].jobs[].tests[].package string always, empty if the log names no package
runs[].jobs[].tests[].name string always
runs[].jobs[].tests[].lines array of strings always: the log lines around the failure
runs[].jobs[].tests[].running_test string only for a crash: the test that was running

Exit codes

Code Meaning
0 every run passed
1 a run failed
2 usage error
3 a run was cancelled
4 ciwatch could not check

A run that is no longer listed (not under --once) counts at its last known state. If that state wasn't completed, its jobs are not fetched, since they would be newer than its row, and jobs is empty.