Repository navigation
feat(lavaflow): report pull request delivery in the CLI - #499
Conversation
AI review: no P0-P2 findingsAdds LavaFlow delivery output: the run list shows covering PRs and Waiting/Undelivered/Stopped states, ⚪ P3
Not checked: The AI review read the diff, the code, and the PR's text; it ran no tests or builds and read nothing outside this repository.
Human review: not needed |
| return lavaflowPullRequestCell(pr) | ||
| } | ||
| if cover := delivery.Coverage; cover != nil { | ||
| return fmt.Sprintf("Covered by #%d (%s)", cover.Number, cover.State) |
There was a problem hiding this comment.
⚪ P3: Covering PR state is printed without clean(), unlike every other API-provided state
lavaflowDeliveryCell (line 186) and lavaflowFix (line 501) print cover.State as received. Every other API string or enum in this file goes through clean(), including lavaflowPullRequestCell, which uses clean(string(pr.State)). The generated enum type isn't checked when the JSON is decoded, so the server can send any string here and it reaches the terminal raw. Use clean(string(cover.State)) in both places so the escaping stays consistent.
Found by claude-opus-5-5
| } | ||
| return | ||
| } | ||
| if delivery.NextAction != nil && run.PullRequest == nil { |
There was a problem hiding this comment.
⚪ P3: Detail view says "Waiting" whenever next_action is set, whatever the delivery state
The list cell picks "Waiting", "Undelivered" or "Stopped" from delivery.State. The detail view prints Delivery: Waiting (...) whenever next_action is present and there is no PR, without checking the state. If the server sends a next_action with terminal_miss or stopped, the list and detail views disagree. This branch also returns before lavaflowNoFix, so the run view shows a raw code like ungated_workflows instead of the existing plain-language explanation. Fix: gate the branch on delivery.State == waiting_for_prerequisite, or reuse the lavaflowNoFix text for the reason.
Found by claude-opus-5-5
| for _, skip := range delivery.PriorSkips { | ||
| fixKV(w, on, "Previous blocker", "%s (%s)", clean(string(skip.Reason)), formatLavaflowTimePtr(skip.RecordedAt, "time unknown")) | ||
| } | ||
| if cover := delivery.Coverage; cover != nil { |
There was a problem hiding this comment.
⚪ P3: Coverage branch hides the run's own PR and merge lines; the list prefers the own PR
When delivery.Coverage is set, lavaflowFix prints the covering PR and returns. That skips run.PullRequest, its state and lavaflowMergeLines. lavaflowDeliveryCell does the opposite and shows the run's own PR whenever one exists. If a run carries both, for example its own closed PR plus another run's covering PR, runs list shows #N closed while show hides that PR completely. Pick one order of precedence and use it in both views, or print the run's own PR before the coverage lines.
Found by claude-opus-5-5
| } | ||
| } | ||
|
|
||
| func lavaflowDeliveryCell(pr *apiclient.LavaflowPullRequest, delivery *apiclient.LavaflowDelivery) string { |
There was a problem hiding this comment.
⚪ P3: New delivery rendering has no tests
The diff adds lavaflowDeliveryCell, three new branches in lavaflowFix (prior skips, coverage, next action) and the stats delivery lines, but no _test.go changes. A search of the head checkout finds no test that mentions Delivery, "Covered by", "Previous blocker" or "Runs without an owned PR". The output tests the description says passed only cover the old paths, where Delivery is nil. Add table cases for each delivery state, coverage with and without a deployment, next_action with and without a PR, and stats with null and non-null means.
Found by claude-opus-5-5
| if cover := delivery.Coverage; cover != nil { | ||
| return fmt.Sprintf("Covered by #%d (%s)", cover.Number, cover.State) | ||
| } | ||
| switch string(delivery.State) { |
There was a problem hiding this comment.
⚪ P3: New switches compare string literals instead of the generated enum constants
switch string(delivery.State) with "waiting_for_prerequisite" and similar values, and cover.State == "merged" (line 502), use literals. The surrounding code switches on apiclient constants, such as apiclient.LavaflowMergeStatusHeld, and the generator now provides LavaflowDeliveryStateWaitingForPrerequisite and LavaflowDeliveryCoverageStateMerged. A typo in a literal compiles silently. Separately, lavaflowDeliveryCell has no doc comment, and the lavaflowFix doc comment no longer mentions covering PRs or the next action.
Found by claude-opus-5-5
| } | ||
| return | ||
| } | ||
| if delivery.NextAction != nil && run.PullRequest == nil { |
There was a problem hiding this comment.
🟡 P2: Detail delivery status is inferred from optional action text
The schema requires delivery.state but makes next_action optional. A waiting delivery without action text falls through to lavaflowNoFix, dropping its waiting state and delivery reason. Conversely, a terminal_miss or stopped delivery with remediation text prints as Waiting, contradicting lavaflow list. Render the status from delivery.State and display action text independently, retaining the legacy fallback when delivery is absent.
Found by gpt-6.1-sol
| } else { | ||
| fixKV(w, on, "Delivery", "%s", state) | ||
| } | ||
| if delivery.State == apiclient.LavaflowDeliveryStateWaitingForPrerequisite || run.PullRequestSkipped == nil { |
There was a problem hiding this comment.
⚪ P3: A waiting delivery with no next_action shows only a raw skip code
For waiting_for_prerequisite, lavaflowFix prints Delivery: Waiting (<reason>) and returns before lavaflowNoFix, even when run.PullRequestSkipped is set. The schema says next_action is sent only "when known". If it is missing, show prints a bare code such as ungated_workflows or permission_missing and skips the existing plain-language advice, for example "Gate that workflow on a label a person adds…". One fix is to fall through to the lavaflowNoFix text, or a waiting-specific version of it, when NextAction is nil.
Found by claude-opus-5-5
| kv(w, on, "Runs without an owned PR", "%d of %d (%d finished)", delivery.RunsWithoutOwnedPr, delivery.Runs, delivery.FinishedWithoutOwnedPr) | ||
| kv(w, on, "Issues with PR coverage", "%d of %d", delivery.IssuesWithPrCoverage, delivery.IssuesWithRuns) | ||
| if delivery.MeanTimeToPrSeconds != nil { | ||
| kv(w, on, "Mean time to PR", "%ds (%d samples)", *delivery.MeanTimeToPrSeconds, delivery.TimeToPrSamples) |
There was a problem hiding this comment.
⚪ P3: Stats print mean latency as raw seconds
Mean time to PR and Mean time to coverage print %ds, so a one-day mean reads as 86400s. Other output in this package formats second counts with (time.Duration(n) * time.Second).String() (see deployments.go:74 and durable.go:418). Formatting these the same way would make them readable and consistent. The companion docs PR would need the same change.
Found by claude-opus-5-5
| var out bytes.Buffer | ||
| lavaflowFix(&out, false, run) | ||
| require.Contains(t, out.String(), "Delivery: "+tc.label+" ("+reason+")") | ||
| if tc.action != nil { |
There was a problem hiding this comment.
⚪ P3: New test skips the coverage, prior-skip, fall-through and stats paths
TestLavaflowDeliveryStatus covers only the three status labels with PullRequestSkipped nil, so every case returns early. Several paths are never exercised: the covering-PR list cell and detail block (including merged with and without deployed_at), Previous blocker lines, the non-waiting fall-through to lavaflowNoFix when PullRequestSkipped is set, Next action alongside a real PR, and the new LavaflowStats delivery lines with null and non-null means. Adding table cases for these would protect the precedence rules this PR set.
Found by claude-opus-5-5
| } { | ||
| t.Run(string(tc.state), func(t *testing.T) { | ||
| t.Parallel() | ||
| delivery := &apiclient.LavaflowDelivery{State: tc.state, Reason: &reason, NextAction: tc.action} |
There was a problem hiding this comment.
⚪ P3: Covering-PR and delivery-stat output remain untested
The new test covers three delivery states, but no tests populate coverage, prior skips, or stats delivery fields. The covering-PR precedence, deployment output, and nullable latency branches therefore lack regression coverage. Add focused output cases for these paths.
Found by gpt-6.1-sol
Summary
Show delivery and covering PRs in list and detail output. Show raw no-PR counts, issue coverage, and latency in stats. Existing Hosting releases can omit the new fields.
Verification
Docs companion Kong/volcano-docs#215