From 8d0b90caf130fe8c0fcab9e51b1bdf600d16d1d9 Mon Sep 17 00:00:00 2001 From: Sean Keever <33592180+swkeever@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:32:54 -0500 Subject: [PATCH 1/3] feat(lavaflow): report pull request delivery in the CLI --- internal/apiclient/client.gen.go | 165 ++++++++++++++++++++++++++++--- internal/output/lavaflow.go | 49 ++++++++- openapi/openapi.yaml | 133 +++++++++++++++++++++++++ 3 files changed, 331 insertions(+), 16 deletions(-) diff --git a/internal/apiclient/client.gen.go b/internal/apiclient/client.gen.go index 2ef04360..30fd386e 100644 --- a/internal/apiclient/client.gen.go +++ b/internal/apiclient/client.gen.go @@ -2394,6 +2394,54 @@ func (e LavaflowCommitOrigin) Valid() bool { } } +// Defines values for LavaflowDeliveryCoverageState. +const ( + LavaflowDeliveryCoverageStateMerged LavaflowDeliveryCoverageState = "merged" + LavaflowDeliveryCoverageStateOpen LavaflowDeliveryCoverageState = "open" +) + +// Valid indicates whether the value is a known member of the LavaflowDeliveryCoverageState enum. +func (e LavaflowDeliveryCoverageState) Valid() bool { + switch e { + case LavaflowDeliveryCoverageStateMerged: + return true + case LavaflowDeliveryCoverageStateOpen: + return true + default: + return false + } +} + +// Defines values for LavaflowDeliveryState. +const ( + LavaflowDeliveryStateCovered LavaflowDeliveryState = "covered" + LavaflowDeliveryStatePending LavaflowDeliveryState = "pending" + LavaflowDeliveryStatePrCreated LavaflowDeliveryState = "pr_created" + LavaflowDeliveryStateStopped LavaflowDeliveryState = "stopped" + LavaflowDeliveryStateTerminalMiss LavaflowDeliveryState = "terminal_miss" + LavaflowDeliveryStateWaitingForPrerequisite LavaflowDeliveryState = "waiting_for_prerequisite" +) + +// Valid indicates whether the value is a known member of the LavaflowDeliveryState enum. +func (e LavaflowDeliveryState) Valid() bool { + switch e { + case LavaflowDeliveryStateCovered: + return true + case LavaflowDeliveryStatePending: + return true + case LavaflowDeliveryStatePrCreated: + return true + case LavaflowDeliveryStateStopped: + return true + case LavaflowDeliveryStateTerminalMiss: + return true + case LavaflowDeliveryStateWaitingForPrerequisite: + return true + default: + return false + } +} + // Defines values for LavaflowDraftReason. const ( LavaflowDraftReasonConvertedToDraft LavaflowDraftReason = "converted_to_draft" @@ -5798,22 +5846,22 @@ func (e ListLavaflowRunsParamsCategory) Valid() bool { // Defines values for ListLavaflowRunsParamsPullRequestState. const ( - Closed ListLavaflowRunsParamsPullRequestState = "closed" - Merged ListLavaflowRunsParamsPullRequestState = "merged" - None ListLavaflowRunsParamsPullRequestState = "none" - Open ListLavaflowRunsParamsPullRequestState = "open" + ListLavaflowRunsParamsPullRequestStateClosed ListLavaflowRunsParamsPullRequestState = "closed" + ListLavaflowRunsParamsPullRequestStateMerged ListLavaflowRunsParamsPullRequestState = "merged" + ListLavaflowRunsParamsPullRequestStateNone ListLavaflowRunsParamsPullRequestState = "none" + ListLavaflowRunsParamsPullRequestStateOpen ListLavaflowRunsParamsPullRequestState = "open" ) // Valid indicates whether the value is a known member of the ListLavaflowRunsParamsPullRequestState enum. func (e ListLavaflowRunsParamsPullRequestState) Valid() bool { switch e { - case Closed: + case ListLavaflowRunsParamsPullRequestStateClosed: return true - case Merged: + case ListLavaflowRunsParamsPullRequestStateMerged: return true - case None: + case ListLavaflowRunsParamsPullRequestStateNone: return true - case Open: + case ListLavaflowRunsParamsPullRequestStateOpen: return true default: return false @@ -10363,6 +10411,84 @@ type LavaflowDayCounts struct { PullRequestsOpened int64 `json:"pull_requests_opened"` } +// LavaflowDelivery Pull request delivery recorded independently of run execution and live recovery. +type LavaflowDelivery struct { + // Coverage Another run's verified covering pull request. That run owns the pull request. + Coverage *LavaflowDeliveryCoverage `json:"coverage,omitempty"` + + // NextAction Action required before delivery can proceed, when known. + NextAction *string `json:"next_action,omitempty"` + + // PriorSkips Reasons recorded before the run resumed, in order. + PriorSkips []LavaflowDeliverySkip `json:"prior_skips"` + + // Reason Recorded skip or failure code for an undelivered run. + Reason *string `json:"reason,omitempty"` + + // RecordedAt When the current delivery result was recorded, if known. + RecordedAt *time.Time `json:"recorded_at"` + + // State Where pull request delivery stands. A run can complete its diagnosis and still wait for a prerequisite, reach a terminal miss, or stop at diagnosis. A draft counts as a created pull request. + State LavaflowDeliveryState `json:"state"` +} + +// LavaflowDeliveryCoverage Another run's verified covering pull request. That run owns the pull request. +type LavaflowDeliveryCoverage struct { + DeployedAt *time.Time `json:"deployed_at"` + MergedAt *time.Time `json:"merged_at"` + Number int64 `json:"number"` + OpenedAt *time.Time `json:"opened_at"` + + // RepositoryId Repository ID recorded for the pull request. Omitted if unknown. + RepositoryId *int64 `json:"repository_id,omitempty"` + RunId openapi_types.UUID `json:"run_id"` + State LavaflowDeliveryCoverageState `json:"state"` + Url string `json:"url"` +} + +// LavaflowDeliveryCoverageState defines model for LavaflowDeliveryCoverage.State. +type LavaflowDeliveryCoverageState string + +// LavaflowDeliverySkip defines model for LavaflowDeliverySkip. +type LavaflowDeliverySkip struct { + // Reason Why a finished run opened no pull request, with what you can do next. `diagnose_only`: the project's `autonomy` was `diagnose_only` when the run was queued, or became it before the pull request opened, so LavaFlow only diagnosed the issue; read the diagnosis, and set `autonomy` to `open_pr` or `merge` for later runs to open pull requests. `not_fixable`: the diagnosis found no change in the code that fixes the error, for example because the cause is outside it; read the diagnosis. `low_confidence`: the diagnosis is not confident enough to propose a fix; read the diagnosis. `no_patch`: LavaFlow proposed no change; read the diagnosis. `possible_credential`: the fix or its description held what looks like a credential or a project secret, so LavaFlow pushed nothing; apply the fix yourself from the diagnosis. `possible_personal_data`: the fix adds an email address the repository lacks, and the repository isn't private, so LavaFlow pushed nothing; apply the fix yourself. `ungated_workflows`: a workflow could run the fix with the repository's secrets before a person approves it; gate the workflow on a label a person adds, or turn on `allow_ungated_workflows`. `convention_unsatisfiable`: LavaFlow would merge the fix, but no title can meet the repository's commit convention, so it kept the fix on the run; apply the fix yourself, or relax the convention. `pull_request_open`: another LavaFlow pull request for the issue is open; review or close it first. `source_unavailable`: LavaFlow couldn't read the repository at the deployed commit, or the production branch no longer holds it; check the project's repository connection and that the commit exists on that branch. `permission_missing`: the Volcano GitHub App, or the project owner's GitHub account, lacks a permission LavaFlow needs; grant the App's requested permissions and make sure the owner can push to the repository. `repository_changed`: the project no longer deploys from the repository the run read; a new run uses the current one. `publish_failed`: opening the pull request failed; a new run tries again. `lineage_cap`: LavaFlow opened as many pull requests in this fix's lineage as it may; review the lineage's pull requests and fix the rest yourself. `lineage_held`: an earlier pull request in this fix's lineage was held, stopped or closed, so LavaFlow opens no more in it; apply the fix yourself from the diagnosis. `review_unresolved`: LavaFlow's review didn't pass a Code Quality fix; read the diagnosis. `duplicate_in_repository`: another project on the repository has the open Code Quality pull request for the same finding. `security_finding`: the finding has security impact and the repository isn't private, so the fix would disclose it; fix it yourself. New reasons may appear. + Reason LavaflowSkipReason `json:"reason"` + RecordedAt *time.Time `json:"recorded_at"` +} + +// LavaflowDeliveryState Where pull request delivery stands. A run can complete its diagnosis and still wait for a prerequisite, reach a terminal miss, or stop at diagnosis. A draft counts as a created pull request. +type LavaflowDeliveryState string + +// LavaflowDeliveryStats Delivery for retained runs created in the requested UTC window and category, evaluated at as_of. +type LavaflowDeliveryStats struct { + AsOf time.Time `json:"as_of"` + + // FinishedWithoutOwnedPr Runs without a pull request of their own that were no longer queued or running at as_of. + FinishedWithoutOwnedPr int64 `json:"finished_without_owned_pr"` + + // IssuesWithPrCoverage Distinct issues with an open or merged pull request owned by a cohort run or linked through verified coverage. + IssuesWithPrCoverage int64 `json:"issues_with_pr_coverage"` + + // IssuesWithRuns Distinct issues represented by runs in the cohort. + IssuesWithRuns int64 `json:"issues_with_runs"` + + // MeanTimeToCoverageSeconds Mean seconds from run creation to recorded coverage by another pull request. Null when there are no samples. + MeanTimeToCoverageSeconds *int64 `json:"mean_time_to_coverage_seconds"` + + // MeanTimeToPrSeconds Mean seconds from run creation to opening its own pull request. Null when there are no samples. + MeanTimeToPrSeconds *int64 `json:"mean_time_to_pr_seconds"` + Runs int64 `json:"runs"` + + // RunsWithoutOwnedPr All runs in the cohort without a pull request of their own, including active, stopped, and covered runs. + RunsWithoutOwnedPr int64 `json:"runs_without_owned_pr"` + + // TimeToCoverageSamples Covered runs with a recorded coverage time at or after run creation. + TimeToCoverageSamples int64 `json:"time_to_coverage_samples"` + + // TimeToPrSamples Runs with a recorded opening time at or after run creation. + TimeToPrSamples int64 `json:"time_to_pr_samples"` +} + // LavaflowDiagnosis defines model for LavaflowDiagnosis. type LavaflowDiagnosis struct { Evidence []string `json:"evidence"` @@ -10644,9 +10770,12 @@ type LavaflowRun struct { Category *LavaflowRunCategory `json:"category"` // ChangedFiles Repository paths the fix changes, sorted; empty without a fix. A path that may itself hold a credential is listed as "", as `diff_withheld` lists it, and so is every path when `diff` can't tell the fix's files apart. A file past a truncated `diff`'s cut is listed. - ChangedFiles []string `json:"changed_files"` - CreatedAt time.Time `json:"created_at"` - Diagnosis *LavaflowDiagnosis `json:"diagnosis"` + ChangedFiles []string `json:"changed_files"` + CreatedAt time.Time `json:"created_at"` + + // Delivery Pull request delivery recorded independently of run execution and live recovery. + Delivery *LavaflowDelivery `json:"delivery,omitempty"` + Diagnosis *LavaflowDiagnosis `json:"diagnosis"` // Diff The fix LavaFlow saved, as the unified diff its reviewers read, cut short past 256 KiB as they read it, with a last line that starts with `[diff truncated`. When a file's content, before or after the fix, or any change to it may hold a credential, or the file is too long for LavaFlow to read whole (over 64 KiB, or past 256 KiB across the fix's files), every change to that file is left out, with one line in their place that starts with `# LavaFlow withheld` and names the file. A run held with `possible_credential` leaves out every file. Null for a run with no saved fix, or one saved before LavaFlow kept its diff. Diff *string `json:"diff"` @@ -10775,10 +10904,13 @@ type LavaflowRunStatusCounts struct { // LavaflowRunSummary defines model for LavaflowRunSummary. type LavaflowRunSummary struct { // Category A Code Quality run carries its finding's from the start. Any other run's is null until LavaFlow records a diagnosis. Runs from before categories get one when their diagnosis names one or their saved fix's paths imply one, and stay null only when neither does. - Category *LavaflowRunCategory `json:"category"` - CreatedAt time.Time `json:"created_at"` - FinishedAt *time.Time `json:"finished_at"` - Id openapi_types.UUID `json:"id"` + Category *LavaflowRunCategory `json:"category"` + CreatedAt time.Time `json:"created_at"` + + // Delivery Pull request delivery recorded independently of run execution and live recovery. + Delivery *LavaflowDelivery `json:"delivery,omitempty"` + FinishedAt *time.Time `json:"finished_at"` + Id openapi_types.UUID `json:"id"` // Issue Null only for a run that works on no issue. Issue *LavaflowIssueSummary `json:"issue"` @@ -11184,6 +11316,9 @@ type LavaflowStats struct { // Days One entry per UTC day, oldest first, zeros included. Days []LavaflowDayCounts `json:"days"` + // Delivery Delivery for retained runs created in the requested UTC window and category, evaluated at as_of. + Delivery *LavaflowDeliveryStats `json:"delivery,omitempty"` + // ProjectId The project the counts are for. ProjectId openapi_types.UUID `json:"project_id"` Totals struct { diff --git a/internal/output/lavaflow.go b/internal/output/lavaflow.go index c2ce46a7..38a3a932 100644 --- a/internal/output/lavaflow.go +++ b/internal/output/lavaflow.go @@ -111,6 +111,16 @@ func LavaflowStats(w io.Writer, stats *apiclient.LavaflowStats) { summary(w, on, "%d issue(s) opened and %d fix pull request(s) opened, %s to %s", stats.Totals.IssuesOpened, stats.Totals.PullRequestsOpened, stats.WindowStart.Format(time.DateOnly), stats.WindowEnd.Format(time.DateOnly)) + if delivery := stats.Delivery; delivery != nil { + 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) + } + if delivery.MeanTimeToCoverageSeconds != nil { + kv(w, on, "Mean time to coverage", "%ds (%d samples)", *delivery.MeanTimeToCoverageSeconds, delivery.TimeToCoverageSamples) + } + } } // LavaflowResources renders every function, frontend and durable function with @@ -160,7 +170,7 @@ func LavaflowRuns(w io.Writer, page LavaflowRunsPage) { for _, run := range page.Runs { fmt.Fprintf(w, "%-36s %-31s %-24s %-30s %-16s %s\n", run.Id.String(), Truncate(lavaflowRunListStatus(run), 31), Truncate(clean(run.Resource.Name), 24), - Truncate(clean(stringOr(run.Title, "-")), 30), formatLavaflowTime(run.CreatedAt), lavaflowPullRequestCell(run.PullRequest)) + Truncate(clean(stringOr(run.Title, "-")), 30), formatLavaflowTime(run.CreatedAt), lavaflowDeliveryCell(run.PullRequest, run.Delivery)) } summary(w, on, "Showing %d run(s)", len(page.Runs)) if page.NextCommand != "" { @@ -168,6 +178,25 @@ func LavaflowRuns(w io.Writer, page LavaflowRunsPage) { } } +func lavaflowDeliveryCell(pr *apiclient.LavaflowPullRequest, delivery *apiclient.LavaflowDelivery) string { + if pr != nil || delivery == nil { + return lavaflowPullRequestCell(pr) + } + if cover := delivery.Coverage; cover != nil { + return fmt.Sprintf("Covered by #%d (%s)", cover.Number, cover.State) + } + switch string(delivery.State) { + case "waiting_for_prerequisite": + return "Waiting" + case "terminal_miss": + return "Undelivered" + case "stopped": + return "Stopped" + default: + return "-" + } +} + // LavaflowRunStarted renders a run a person started: its ID and status, and // the command that follows it. func LavaflowRunStarted(w io.Writer, runID string, status apiclient.LavaflowRunStatus, showCommand string) { @@ -463,6 +492,24 @@ func lavaflowHumanReviewPaths(w io.Writer, on bool, policy apiclient.LavaflowMer // state and where its merge is, or why the run has no pull request. func lavaflowFix(w io.Writer, on bool, run *apiclient.LavaflowRun) { fmt.Fprintln(w, theme.Dim("Fix:", on)) + if delivery := run.Delivery; delivery != nil { + 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 { + fixKV(w, on, "Covering pull request", "#%d %s", cover.Number, clean(cover.Url)) + fixKV(w, on, "State", "%s", cover.State) + if cover.State == "merged" { + fixKV(w, on, "Deployment", "%s", formatLavaflowTimePtr(cover.DeployedAt, "unconfirmed")) + } + return + } + if delivery.NextAction != nil { + fixKV(w, on, "Delivery", "Waiting (%s)", clean(stringOr(delivery.Reason, "prerequisite"))) + fixKV(w, on, "Next action", "%s", clean(*delivery.NextAction)) + return + } + } pr := run.PullRequest if pr == nil { fmt.Fprintf(w, " %s\n", lavaflowNoFix(run)) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 1b9588f6..30183b72 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -31364,6 +31364,8 @@ components: description: One entry per UTC day, oldest first, zeros included. items: $ref: '#/components/schemas/LavaflowDayCounts' + delivery: + $ref: '#/components/schemas/LavaflowDeliveryStats' totals: type: object properties: @@ -31382,6 +31384,61 @@ components: - window_end - days - totals + LavaflowDeliveryStats: + type: object + description: Delivery for retained runs created in the requested UTC window and category, evaluated at as_of. + properties: + as_of: + type: string + format: date-time + runs: + type: integer + format: int64 + runs_without_owned_pr: + type: integer + format: int64 + description: All runs in the cohort without a pull request of their own, including active, stopped, and covered runs. + finished_without_owned_pr: + type: integer + format: int64 + description: Runs without a pull request of their own that were no longer queued or running at as_of. + issues_with_runs: + type: integer + format: int64 + description: Distinct issues represented by runs in the cohort. + issues_with_pr_coverage: + type: integer + format: int64 + description: Distinct issues with an open or merged pull request owned by a cohort run or linked through verified coverage. + time_to_pr_samples: + type: integer + format: int64 + description: Runs with a recorded opening time at or after run creation. + mean_time_to_pr_seconds: + type: integer + format: int64 + nullable: true + description: Mean seconds from run creation to opening its own pull request. Null when there are no samples. + time_to_coverage_samples: + type: integer + format: int64 + description: Covered runs with a recorded coverage time at or after run creation. + mean_time_to_coverage_seconds: + type: integer + format: int64 + nullable: true + description: Mean seconds from run creation to recorded coverage by another pull request. Null when there are no samples. + required: + - as_of + - runs + - runs_without_owned_pr + - finished_without_owned_pr + - issues_with_runs + - issues_with_pr_coverage + - time_to_pr_samples + - mean_time_to_pr_seconds + - time_to_coverage_samples + - mean_time_to_coverage_seconds LavaflowResourceReference: type: object description: A function, durable function or frontend in the project, or the project of a user-reported problem. @@ -31583,6 +31640,80 @@ components: - LavaflowSkipReasonDuplicateInRepository - LavaflowSkipReasonSecurityFinding description: 'Why a finished run opened no pull request, with what you can do next. `diagnose_only`: the project''s `autonomy` was `diagnose_only` when the run was queued, or became it before the pull request opened, so LavaFlow only diagnosed the issue; read the diagnosis, and set `autonomy` to `open_pr` or `merge` for later runs to open pull requests. `not_fixable`: the diagnosis found no change in the code that fixes the error, for example because the cause is outside it; read the diagnosis. `low_confidence`: the diagnosis is not confident enough to propose a fix; read the diagnosis. `no_patch`: LavaFlow proposed no change; read the diagnosis. `possible_credential`: the fix or its description held what looks like a credential or a project secret, so LavaFlow pushed nothing; apply the fix yourself from the diagnosis. `possible_personal_data`: the fix adds an email address the repository lacks, and the repository isn''t private, so LavaFlow pushed nothing; apply the fix yourself. `ungated_workflows`: a workflow could run the fix with the repository''s secrets before a person approves it; gate the workflow on a label a person adds, or turn on `allow_ungated_workflows`. `convention_unsatisfiable`: LavaFlow would merge the fix, but no title can meet the repository''s commit convention, so it kept the fix on the run; apply the fix yourself, or relax the convention. `pull_request_open`: another LavaFlow pull request for the issue is open; review or close it first. `source_unavailable`: LavaFlow couldn''t read the repository at the deployed commit, or the production branch no longer holds it; check the project''s repository connection and that the commit exists on that branch. `permission_missing`: the Volcano GitHub App, or the project owner''s GitHub account, lacks a permission LavaFlow needs; grant the App''s requested permissions and make sure the owner can push to the repository. `repository_changed`: the project no longer deploys from the repository the run read; a new run uses the current one. `publish_failed`: opening the pull request failed; a new run tries again. `lineage_cap`: LavaFlow opened as many pull requests in this fix''s lineage as it may; review the lineage''s pull requests and fix the rest yourself. `lineage_held`: an earlier pull request in this fix''s lineage was held, stopped or closed, so LavaFlow opens no more in it; apply the fix yourself from the diagnosis. `review_unresolved`: LavaFlow''s review didn''t pass a Code Quality fix; read the diagnosis. `duplicate_in_repository`: another project on the repository has the open Code Quality pull request for the same finding. `security_finding`: the finding has security impact and the repository isn''t private, so the fix would disclose it; fix it yourself. New reasons may appear.' + LavaflowDeliveryState: + type: string + enum: [pending, pr_created, covered, waiting_for_prerequisite, terminal_miss, stopped] + description: >- + Where pull request delivery stands. A run can complete its diagnosis and still wait for a prerequisite, + reach a terminal miss, or stop at diagnosis. A draft counts as a created pull request. + LavaflowDeliveryCoverage: + type: object + description: Another run's verified covering pull request. That run owns the pull request. + properties: + run_id: + type: string + format: uuid + repository_id: + type: integer + format: int64 + description: Repository ID recorded for the pull request. Omitted if unknown. + number: + type: integer + format: int64 + url: + type: string + format: uri + state: + type: string + enum: [open, merged] + opened_at: + type: string + format: date-time + nullable: true + merged_at: + type: string + format: date-time + nullable: true + deployed_at: + type: string + format: date-time + nullable: true + required: [run_id, number, url, state, opened_at, merged_at, deployed_at] + LavaflowDeliverySkip: + type: object + properties: + reason: + $ref: '#/components/schemas/LavaflowSkipReason' + recorded_at: + type: string + format: date-time + nullable: true + required: [reason, recorded_at] + LavaflowDelivery: + type: object + description: Pull request delivery recorded independently of run execution and live recovery. + properties: + state: + $ref: '#/components/schemas/LavaflowDeliveryState' + reason: + type: string + description: Recorded skip or failure code for an undelivered run. + next_action: + type: string + description: Action required before delivery can proceed, when known. + recorded_at: + type: string + format: date-time + nullable: true + description: When the current delivery result was recorded, if known. + coverage: + $ref: '#/components/schemas/LavaflowDeliveryCoverage' + prior_skips: + type: array + description: Reasons recorded before the run resumed, in order. + items: + $ref: '#/components/schemas/LavaflowDeliverySkip' + required: [state, recorded_at, prior_skips] LavaflowRunSummary: type: object properties: @@ -31641,6 +31772,8 @@ components: - $ref: '#/components/schemas/LavaflowRunProgress' nullable: true description: Where a run LavaFlow is still working on stands; null once it has nothing left to do. + delivery: + $ref: '#/components/schemas/LavaflowDelivery' pull_request_skipped: allOf: - $ref: '#/components/schemas/LavaflowSkipReason' From e777edc41961d7b438365e97ee5857a0bb9dc6ac Mon Sep 17 00:00:00 2001 From: Sean Keever <33592180+swkeever@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:44:39 -0500 Subject: [PATCH 2/3] fix(lavaflow): show the PR and its pending setup action --- internal/output/lavaflow.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/output/lavaflow.go b/internal/output/lavaflow.go index 38a3a932..d0f6df39 100644 --- a/internal/output/lavaflow.go +++ b/internal/output/lavaflow.go @@ -504,7 +504,7 @@ func lavaflowFix(w io.Writer, on bool, run *apiclient.LavaflowRun) { } return } - if delivery.NextAction != nil { + if delivery.NextAction != nil && run.PullRequest == nil { fixKV(w, on, "Delivery", "Waiting (%s)", clean(stringOr(delivery.Reason, "prerequisite"))) fixKV(w, on, "Next action", "%s", clean(*delivery.NextAction)) return @@ -523,6 +523,9 @@ func lavaflowFix(w io.Writer, on bool, run *apiclient.LavaflowRun) { if run.Merge != nil { lavaflowMergeLines(w, on, run.Merge, pr) } + if run.Delivery != nil && run.Delivery.NextAction != nil { + fixKV(w, on, "Next action", "%s", clean(*run.Delivery.NextAction)) + } // The API doesn't say yet whether a merged fix deployed. Print it here // once the pull request carries deployed_at. } From fdca11378c58f7f3a8157b5979c92f3563d39fb1 Mon Sep 17 00:00:00 2001 From: Sean Keever <33592180+swkeever@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:32:51 -0500 Subject: [PATCH 3/3] fix(lavaflow): render the recorded delivery outcome --- internal/output/lavaflow.go | 48 ++++++++++++++++++++------------ internal/output/lavaflow_test.go | 40 ++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 internal/output/lavaflow_test.go diff --git a/internal/output/lavaflow.go b/internal/output/lavaflow.go index d0f6df39..d6dae77f 100644 --- a/internal/output/lavaflow.go +++ b/internal/output/lavaflow.go @@ -183,17 +183,24 @@ func lavaflowDeliveryCell(pr *apiclient.LavaflowPullRequest, delivery *apiclient return lavaflowPullRequestCell(pr) } if cover := delivery.Coverage; cover != nil { - return fmt.Sprintf("Covered by #%d (%s)", cover.Number, cover.State) + return fmt.Sprintf("Covered by #%d (%s)", cover.Number, clean(string(cover.State))) } - switch string(delivery.State) { - case "waiting_for_prerequisite": + if status := lavaflowDeliveryStatus(delivery.State); status != "" { + return status + } + return "-" +} + +func lavaflowDeliveryStatus(state apiclient.LavaflowDeliveryState) string { + switch state { + case apiclient.LavaflowDeliveryStateWaitingForPrerequisite: return "Waiting" - case "terminal_miss": + case apiclient.LavaflowDeliveryStateTerminalMiss: return "Undelivered" - case "stopped": + case apiclient.LavaflowDeliveryStateStopped: return "Stopped" default: - return "-" + return "" } } @@ -492,25 +499,33 @@ func lavaflowHumanReviewPaths(w io.Writer, on bool, policy apiclient.LavaflowMer // state and where its merge is, or why the run has no pull request. func lavaflowFix(w io.Writer, on bool, run *apiclient.LavaflowRun) { fmt.Fprintln(w, theme.Dim("Fix:", on)) - if delivery := run.Delivery; delivery != nil { + pr, delivery := run.PullRequest, run.Delivery + if delivery != nil { 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 { + if delivery.NextAction != nil { + defer fixKV(w, on, "Next action", "%s", clean(*delivery.NextAction)) + } + if cover := delivery.Coverage; cover != nil && pr == nil { fixKV(w, on, "Covering pull request", "#%d %s", cover.Number, clean(cover.Url)) - fixKV(w, on, "State", "%s", cover.State) - if cover.State == "merged" { + fixKV(w, on, "State", "%s", clean(string(cover.State))) + if cover.State == apiclient.LavaflowDeliveryCoverageStateMerged { fixKV(w, on, "Deployment", "%s", formatLavaflowTimePtr(cover.DeployedAt, "unconfirmed")) } return } - if delivery.NextAction != nil && run.PullRequest == nil { - fixKV(w, on, "Delivery", "Waiting (%s)", clean(stringOr(delivery.Reason, "prerequisite"))) - fixKV(w, on, "Next action", "%s", clean(*delivery.NextAction)) - return + if state := lavaflowDeliveryStatus(delivery.State); state != "" && pr == nil { + if delivery.Reason != nil { + fixKV(w, on, "Delivery", "%s (%s)", state, clean(*delivery.Reason)) + } else { + fixKV(w, on, "Delivery", "%s", state) + } + if delivery.State == apiclient.LavaflowDeliveryStateWaitingForPrerequisite || run.PullRequestSkipped == nil { + return + } } } - pr := run.PullRequest if pr == nil { fmt.Fprintf(w, " %s\n", lavaflowNoFix(run)) return @@ -523,9 +538,6 @@ func lavaflowFix(w io.Writer, on bool, run *apiclient.LavaflowRun) { if run.Merge != nil { lavaflowMergeLines(w, on, run.Merge, pr) } - if run.Delivery != nil && run.Delivery.NextAction != nil { - fixKV(w, on, "Next action", "%s", clean(*run.Delivery.NextAction)) - } // The API doesn't say yet whether a merged fix deployed. Print it here // once the pull request carries deployed_at. } diff --git a/internal/output/lavaflow_test.go b/internal/output/lavaflow_test.go new file mode 100644 index 00000000..ed21e70d --- /dev/null +++ b/internal/output/lavaflow_test.go @@ -0,0 +1,40 @@ +package output + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/Kong/volcano-cli/internal/apiclient" +) + +func TestLavaflowDeliveryStatus(t *testing.T) { + t.Parallel() + + nextAction := "Check the repository connection." + reason := "source_unavailable" + for _, tc := range []struct { + state apiclient.LavaflowDeliveryState + label string + action *string + }{ + {apiclient.LavaflowDeliveryStateWaitingForPrerequisite, "Waiting", nil}, + {apiclient.LavaflowDeliveryStateTerminalMiss, "Undelivered", &nextAction}, + {apiclient.LavaflowDeliveryStateStopped, "Stopped", &nextAction}, + } { + t.Run(string(tc.state), func(t *testing.T) { + t.Parallel() + delivery := &apiclient.LavaflowDelivery{State: tc.state, Reason: &reason, NextAction: tc.action} + run := &apiclient.LavaflowRun{Status: apiclient.LavaflowRunStatusCompleted, Delivery: delivery} + + require.Equal(t, tc.label, lavaflowDeliveryCell(nil, delivery)) + var out bytes.Buffer + lavaflowFix(&out, false, run) + require.Contains(t, out.String(), "Delivery: "+tc.label+" ("+reason+")") + if tc.action != nil { + require.Contains(t, out.String(), "Next action: "+*tc.action) + } + }) + } +}