|
| 1 | +// Copyright (c) 2026 Uber Technologies, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package entity |
| 16 | + |
| 17 | +// BuildReportState describes the availability of a validation report. |
| 18 | +type BuildReportState string |
| 19 | + |
| 20 | +const ( |
| 21 | + // BuildReportStateUnknown means report availability has not been established. |
| 22 | + BuildReportStateUnknown BuildReportState = "" |
| 23 | + // BuildReportStatePending means a final report is not available yet. |
| 24 | + BuildReportStatePending BuildReportState = "pending" |
| 25 | + // BuildReportStateAvailable means a final validation report can be interpreted. |
| 26 | + BuildReportStateAvailable BuildReportState = "available" |
| 27 | + // BuildReportStateUnavailable means the attempt ended without a usable final report. |
| 28 | + BuildReportStateUnavailable BuildReportState = "unavailable" |
| 29 | +) |
| 30 | + |
| 31 | +// BuildRetryDisposition describes the automatic retry decision for an attempt of a |
| 32 | +// validation task, not manual reruns or the retries used to read its evidence. |
| 33 | +type BuildRetryDisposition string |
| 34 | + |
| 35 | +const ( |
| 36 | + // BuildRetryDispositionUnknown means the automatic retry decision is not known. |
| 37 | + BuildRetryDispositionUnknown BuildRetryDisposition = "" |
| 38 | + // BuildRetryDispositionPending means an automatic retry is scheduled or running. |
| 39 | + BuildRetryDispositionPending BuildRetryDisposition = "pending" |
| 40 | + // BuildRetryDispositionExhausted means no automatic retry remains under the applicable policy. |
| 41 | + BuildRetryDispositionExhausted BuildRetryDisposition = "exhausted" |
| 42 | +) |
| 43 | + |
| 44 | +// BuildReport contains validation evidence from the current attempt of a validation task. |
| 45 | +// A validation task is work executed and retried together; a unit is the |
| 46 | +// granularity of reported outcomes. All identifiers are opaque. |
| 47 | +type BuildReport struct { |
| 48 | + // TaskID identifies the logical validation task within the build, stable across attempts. |
| 49 | + TaskID string `json:"task_id"` |
| 50 | + // AttemptID identifies this execution of the validation task; empty if none exists yet. |
| 51 | + AttemptID string `json:"attempt_id"` |
| 52 | + // State describes whether this attempt's final validation report is available. |
| 53 | + State BuildReportState `json:"state"` |
| 54 | + // FailedUnits lists failed validation-unit identifiers when State is available. |
| 55 | + // An empty list establishes no failure within the report's coverage, not build success. |
| 56 | + FailedUnits []string `json:"failed_units"` |
| 57 | + // RetryDisposition describes the automatic retry decision for this attempt. |
| 58 | + RetryDisposition BuildRetryDisposition `json:"retry_disposition"` |
| 59 | +} |
| 60 | + |
| 61 | +// BuildAnalysis is the current validation-report snapshot for one build. |
| 62 | +// BuildID is immutable; reports are replaced as a complete snapshot. |
| 63 | +type BuildAnalysis struct { |
| 64 | + // BuildID identifies the build within its validation queue. |
| 65 | + BuildID string `json:"build_id"` |
| 66 | + // Reports contains the current attempt of each observed validation task. |
| 67 | + Reports []BuildReport `json:"reports"` |
| 68 | + // ObservedAtMs is the observation time in milliseconds since the Unix epoch. |
| 69 | + ObservedAtMs int64 `json:"observed_at_ms"` |
| 70 | + // Version is the optimistic storage version, starting at one. |
| 71 | + Version int32 `json:"version"` |
| 72 | +} |
0 commit comments