Files
ciwatch/testdata/logs/devvm-shared-second.log
w3cjandClaude Sonnet 5.5 d108f34228 feat(steplog): start a step's log window at its group line
The jobs JSON gives whole seconds, so lines the previous step printed
in the second a failed step started fell inside the step's window. They
were counted in its earlier lines, and a previous ##[error] line could
end the window early. In the recorded devvm log, the lint step's two
"Finished in" lines were counted for the test step.

Parse now treats the first ##[group] line stamped in a step's start
second as the start of the step's own lines. Lines taken before it in
that second, and untimestamped lines that follow them, are dropped, and
a dropped ##[error] line no longer ends the window. If no ##[group] line
falls in the start second, including a log that ends in it, the window
is exactly what it was. Nothing outside the start second changes. For
the recorded devvm log the tail is unchanged and its omitted count goes
from 263 to 261.

The change relies on GitHub writing a log in order and starting each
step with a ##[group] line. A step that prints a ##[group] line in its
first second without a header of its own loses its lines before that
group; that is under a second of output. Memory stays bounded: the lines
go straight into the span's tail, which keeps at most 2*Tail lines.

Tests cover the shared-second cut, an untimestamped follower, a previous
##[error] line with and without the step's own, two group lines in the
start second, and the cases that must not change. A new fixture, written
by hand from real lines of the recorded devvm log, drives a CLI test.

Backlog:
- TestRunStepLeavesOutPreviousStepsSameSecond (internal/cli): the
  "omitted":0 check in --json also passes with the old code, since the
  fixture's window is short. Asserting on the first line or the line
  count would tighten it. Off path: the test as a whole already fails
  on the old code.
- The design's AC-1 case 5 (a step with only pre-group lines is left
  out) can't be reached, because the group line is in the window and is
  kept. No test row covers it. Rewording the case or pinning the
  intended behaviour would remove the ambiguity. Off path: spec wording;
  no reachable input gives wrong output.

Spec: acceptance cases
1. **AC-1:** The step's span starts at 10:00:05. The log has `prev a` (10:00:05.1), `prev b` (10:00:05.2), `##[group]Run go test` (10:00:05.3), `go test` (10:00:05.4) and `##[error]x` (10:00:06). The step's lines are `##[group]Run go test`, `go test`, `##[error]x`, with `Omitted` 0.
2. **AC-1:** A line without a timestamp after `prev b` (it belongs to `prev b`) is left out with it.
3. **AC-1:** If the previous step's lines in the shared second include `##[error]prev`, the failed step's window doesn't end at that line. Its tail ends at its own `##[error]` line, as in AC-1 case 1. If the step has no `##[error]` of its own, its tail ends at its last line in the window.
4. **AC-1:** If the start second has more than one `##[group]` line (the step's header, then a group the step itself prints), the cut is at the first one. The step's own group and the lines after it are kept.
5. **AC-1:** If the step's only lines are in its start second and come before its `##[group]` line, then nothing is left. The step is left out, as a step with no lines is today.
6. **AC-2:** For the recorded `devvm-44705166834.log` and the span `Run mise run test` from 08:47:47 to 08:52:20, the tail is unchanged, but `Omitted` drops by the 2 lint lines. Its 40 lines go from 263 omitted to 261: the 301 lines from line 400 to line 700, less 40. With a short log written by hand from the same real lines, `ciwatch HEAD` exits 1, and the step's block starts `##[group]Run mise run test`, with no `[lint:code]` or `Finished in` line.
7. **AC-3:** If no `##[group]` line falls in the step's start second, the window is exactly what it is today. That covers start-second lines with no group line, a group line stamped before `startedAt`, and every existing `TestParse` case. `devvm-short-step.log` also keeps its current output.
8. **AC-3:** If the start second's lines are the last lines of the log (EOF before the second ends), they're kept as today, unless a `##[group]` line came first.

Spec: non-goals
- Using step names from the log (`##[group]Run <name>`), or matching the `Run ` prefix.
- The other end of the window: lines of the next step within a second of the failed step's completion. These are still kept when the step has no `##[error]` line.
- Showing passed steps; changing `Whole`, `--json` fields or exit codes.
- Logs where gh labels lines with real step names (the attempt logs). They're treated by time as today.

Spec: inference
- **That the step's lines start at its own `##[group]` line, and that GitHub writes the log in order.** In the start second, a line before the first `##[group]` line is taken to be the previous step's. GitHub starts every `run:` and `uses:` step with `##[group]Run …`, and the log comes in the order it was written.
- **When the guess is wrong:** Take a step that doesn't start with a group header (say a post step) but prints a `##[group]` in its first second. Its own lines from before that group are dropped. That's under a second of output, and only when a group line appears in that same second. If the previous step prints a `##[group]` in the shared second, the cut lands at that group line. Some of the previous step's lines are then still shown, which is today's behaviour, never worse. With no group line in the start second, nothing changes.

Spec: approved with
Approved by CJ as designed, including the inference (the first ##[group] line in the step's start second marks where its lines begin) and your two assumed answers: cut at any ##[group], and AC-2 shown by the Omitted count plus the short fixture from real lines.

Built in steps:
- test(steplog): cut a step's window at its group line
- feat(steplog): start a step's window at its group line
- fix(steplog): polish from review

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-23 23:03:49 -07:00

21 lines
2.5 KiB
Plaintext

check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:45.5018111Z ^[[38;5;12m[lint:code]^[[0m ^[[32mNo findings to report. Good job!^[[39m (^[[1m^[[93m19^[[39m suppressed^[[0m)
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:45.5033792Z ^[[38;5;12m[lint:code]^[[0m ^[[1m$ git ls-files --cached --others --exclude-standard -z -- . ':!:.agents/skills/security-audit' ':!:testdata/script' |^[[0m
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7871520Z ^[[38;5;12m[lint:code]^[[0m Finished in 58.23s
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7897680Z ^[[2mFinished in 58.24s^[[0m
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7959427Z ##[group]Run mise run test
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7959824Z ^[[36;1mmise run test^[[0m
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7979198Z shell: /usr/bin/bash -e {0}
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7979494Z env:
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7979805Z MISE_LOG_LEVEL: info
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7980097Z MISE_TRUSTED_CONFIG_PATHS: /home/runner/work/devvm/devvm
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7980479Z MISE_YES: 1
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7980697Z CGO_ENABLED: 0
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7981006Z GOBIN: /home/runner/.local/share/mise/installs/go/1.27.4/bin
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7981362Z GOROOT: /home/runner/.local/share/mise/installs/go/1.27.4
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7981688Z TZ: America/Los_Angeles
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:47:47.7981962Z ##[endgroup]
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:52:20.9321737Z === ^[[31mFAIL^[[0m: internal/vm TestAgentImportFailsWhole (0.01s)
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:52:20.9322130Z agentimport_test.go:957: changed:
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:52:20.9323954Z DONE 4183 tests, 55 skipped, 1 failure in 263.817s
check (ubuntu-latest, America/Los_Angeles) UNKNOWN STEP 2026-11-20T08:52:20.9584442Z ##[error]Process completed with exit code 1.