Skip to content

feat(lavaflow): report pull request delivery in the CLI - #499

Merged
swkeever merged 3 commits into
mainfrom
skeever/lavaflow-delivery-reporting
Nov 18, 2026
Merged

swkeever merged 3 commits into
mainfrom
skeever/lavaflow-delivery-reporting

Conversation

@swkeever

Copy link
Copy Markdown
Collaborator

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

  • LavaFlow command and output tests passed.
  • Vendored OpenAPI and generated client agree.
  • CLI E2E deferred to CI.

Docs companion Kong/volcano-docs#215

@swkeever
swkeever marked this pull request as ready for review November 18, 2026 17:23
@swkeever
swkeever requested a review from a team as a code owner November 18, 2026 17:23
Copilot AI balanced review requested due to automatic review settings November 18, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

AI review: no P0-P2 findings

Reviewed fdca113. Run log

Adds LavaFlow delivery output: the run list shows covering PRs and Waiting/Undelivered/Stopped states, show prints covering PRs, earlier blockers and the next action, and stats prints counts and mean latency for runs without their own PR. The vendored OpenAPI spec and generated client are updated to match. The earlier P2 is fixed because the detail status now comes from delivery.state. The earlier P3s are fixed too: cover.State now goes through clean(), the enum constants replace string literals, the run's own PR takes precedence over coverage in both views, and the new code has a basic test. The remaining risk is limited to how output looks.

⚪ P3

  • internal/output/lavaflow.go:524 A waiting delivery with no next_action shows only a raw skip code
  • internal/output/lavaflow.go:118 Stats print mean latency as raw seconds
  • internal/output/lavaflow_test.go:28,35 New test skips the coverage, prior-skip, fall-through and stats paths (also reported as: Covering-PR and delivery-stat output remain untested)

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

Comment thread internal/output/lavaflow.go Outdated
return lavaflowPullRequestCell(pr)
}
if cover := delivery.Coverage; cover != nil {
return fmt.Sprintf("Covered by #%d (%s)", cover.Number, cover.State)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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

Comment thread internal/output/lavaflow.go Outdated
}
return
}
if delivery.NextAction != nil && run.PullRequest == nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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

Comment thread internal/output/lavaflow.go Outdated
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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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

Comment thread internal/output/lavaflow.go Outdated
if cover := delivery.Coverage; cover != nil {
return fmt.Sprintf("Covered by #%d (%s)", cover.Number, cover.State)
}
switch string(delivery.State) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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

Comment thread internal/output/lavaflow.go Outdated
}
return
}
if delivery.NextAction != nil && run.PullRequest == nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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

@swkeever
swkeever added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit e94260c Nov 18, 2026
19 checks passed
@swkeever
swkeever deleted the skeever/lavaflow-delivery-reporting branch November 18, 2026 19:17
@kong-volcano-app kong-volcano-app Bot mentioned this pull request Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants