Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(review): add the RunReview API and the review run runtime for SQL Review V2

rebeliceab4ba87b1ac6
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 02dccafc3a..0c3a5df167 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -3098,6 +3098,47 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Issue'
+ /bytebase.v1.IssueService/RunReview:
+ post:
+ tags:
+ - bytebase.v1.IssueService
+ summary: RunReview
+ description: |-
+ Triggers a review run. The slot is reset unconditionally: a RUNNING
+ execution is superseded (its completion is fenced off), the attempt
+ number is bumped, and the returned run is AVAILABLE.
+ The audit log is the only record of who triggered a run.
+ Permissions required: bb.reviewRuns.run
+ operationId: bytebase.v1.IssueService.RunReview
+ parameters:
+ - name: Connect-Protocol-Version
+ in: header
+ required: true
+ schema:
+ $ref: '#/components/schemas/connect-protocol-version'
+ - name: Connect-Timeout-Ms
+ in: header
+ schema:
+ $ref: '#/components/schemas/connect-timeout-header'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.RunReviewRequest'
+ required: true
+ responses:
+ default:
+ description: Error
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/connect.error'
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.ReviewRun'
/bytebase.v1.IssueService/SearchIssues:
post:
tags:
@@ -17913,6 +17954,62 @@ components:
Format: {resource}/{resource id}, e.g., environments/test.
title: ReviewConfig
additionalProperties: false
+ bytebase.v1.ReviewRun:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: |-
+ Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ The {reviewRun} id is the reviewer: "rule" or "guideline". The name
+ addresses a slot, not an execution.
+ type:
+ title: type
+ description: Derived from the name.
+ $ref: '#/components/schemas/bytebase.v1.ReviewRun.Type'
+ status:
+ title: status
+ $ref: '#/components/schemas/bytebase.v1.ReviewRun.Status'
+ createTime:
+ title: create_time
+ description: When the current run was triggered. Reset on every re-run.
+ $ref: '#/components/schemas/google.protobuf.Timestamp'
+ endTime:
+ title: end_time
+ description: |-
+ When the run reached a terminal status. Unset while AVAILABLE or
+ RUNNING.
+ $ref: '#/components/schemas/google.protobuf.Timestamp'
+ error:
+ type: string
+ title: error
+ description: |-
+ Fatal execution error, set if and only if status is FAILED: the review
+ failed to execute (a platform problem, never the SQL — SQL problems are
+ review results on a DONE run).
+ title: ReviewRun
+ additionalProperties: false
+ bytebase.v1.ReviewRun.Status:
+ type: string
+ title: Status
+ enum:
+ - STATUS_UNSPECIFIED
+ - AVAILABLE
+ - RUNNING
+ - DONE
+ - FAILED
+ description: |-
+ States follow task_run, minus PENDING (review needs no admission
+ control) and minus CANCELED (runs are side-effect-free until the fenced
+ completion transaction, so re-running supersedes instead of canceling).
+ bytebase.v1.ReviewRun.Type:
+ type: string
+ title: Type
+ enum:
+ - TYPE_UNSPECIFIED
+ - RULE
+ - GUIDELINE
bytebase.v1.Revision:
type: object
properties:
@@ -18320,6 +18417,15 @@ components:
type: object
title: RunPlanChecksResponse
additionalProperties: false
+ bytebase.v1.RunReviewRequest:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: 'Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}'
+ title: RunReviewRequest
+ additionalProperties: false
bytebase.v1.SASLConfig:
type: object
oneOf:
diff --git a/backend/api/v1/audit_redact_inventory_test.go b/backend/api/v1/audit_redact_inventory_test.go
index 1a189470ea..9513aec643 100644
--- a/backend/api/v1/audit_redact_inventory_test.go
+++ b/backend/api/v1/audit_redact_inventory_test.go
@@ -816,6 +816,8 @@ var auditRecordedFields = []string{
"bytebase.v1.ReviewConfig.name",
"bytebase.v1.ReviewConfig.resources",
"bytebase.v1.ReviewConfig.title",
+ "bytebase.v1.ReviewRun.error",
+ "bytebase.v1.ReviewRun.name",
"bytebase.v1.Revision.deleter",
"bytebase.v1.Revision.file",
"bytebase.v1.Revision.name",
@@ -837,6 +839,7 @@ var auditRecordedFields = []string{
"bytebase.v1.RotateDirectorySyncTokenRequest.name",
"bytebase.v1.RunPlanChecksRequest.name",
"bytebase.v1.RunPlanChecksRequest.spec_id",
+ "bytebase.v1.RunReviewRequest.name",
"bytebase.v1.SQLEditorThemeSetting.id",
"bytebase.v1.SQLEditorThemeSetting.monaco_base",
"bytebase.v1.SQLEditorThemeSetting.name",
diff --git a/backend/api/v1/issue_service_review_run.go b/backend/api/v1/issue_service_review_run.go
new file mode 100644
index 0000000000..98db11b5fb
--- /dev/null
+++ b/backend/api/v1/issue_service_review_run.go
@@ -0,0 +1,179 @@
+package v1
+
+import (
+ "context"
+
+ "connectrpc.com/connect"
+ "github.com/pkg/errors"
+ "google.golang.org/protobuf/types/known/timestamppb"
+
+ "github.com/bytebase/bytebase/backend/common"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
+ "github.com/bytebase/bytebase/backend/runner/plancheck"
+ "github.com/bytebase/bytebase/backend/store"
+)
+
+// Review run resource IDs: the {reviewRun} segment of
+// projects/{project}/issues/{issue}/reviewRuns/{reviewRun}.
+const (
+ reviewRunIDRule = "rule"
+ reviewRunIDGuideline = "guideline"
+)
+
+// RunReview triggers a review run. The slot is reset unconditionally: a
+// RUNNING execution is superseded, the attempt number is bumped, and the
+// returned run is AVAILABLE.
+func (s *IssueService) RunReview(ctx context.Context, req *connect.Request[v1pb.RunReviewRequest]) (*connect.Response[v1pb.ReviewRun], error) {
+ projectID, issueUID, reviewRunID, err := common.GetProjectIDIssueUIDReviewRunID(req.Msg.Name)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, err)
+ }
+ reviewType, ok := reviewRunTypeFromID(reviewRunID)
+ if !ok {
+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unknown reviewer type %q", reviewRunID))
+ }
+
+ issue, err := s.store.GetIssue(ctx, &store.FindIssueMessage{
+ Workspace: common.GetWorkspaceIDFromContext(ctx),
+ ProjectIDs: []string{projectID},
+ UID: &issueUID,
+ })
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get issue"))
+ }
+ if issue == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("issue %d not found in project %s", issueUID, projectID))
+ }
+ if issue.Status != storepb.Issue_OPEN {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("review runs only on an open issue; issue is %s", issue.Status))
+ }
+ if issue.PlanUID == nil {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("issue %d has no SQL to review", issueUID))
+ }
+ plan, err := s.store.GetPlan(ctx, &store.FindPlanMessage{ProjectID: projectID, UID: issue.PlanUID})
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get plan"))
+ }
+ if plan == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("plan %d not found in project %s", *issue.PlanUID, projectID))
+ }
+ if plan.Config.GetHasRollout() {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("the plan already has a rollout; its SQL is frozen"))
+ }
+
+ // Applicability: the review type must apply to this issue right now — a
+ // slot for an inapplicable type must not exist, so it is not created.
+ project, err := s.store.GetProjectByResourceID(ctx, projectID)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get project"))
+ }
+ if project == nil {
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("project %s not found", projectID))
+ }
+ databaseGroup, err := plancheck.GetDatabaseGroupForPlan(ctx, s.store, plan, nil)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get database group for plan"))
+ }
+ targets, err := plancheck.DeriveCheckTargets(ctx, s.store, project, plan, databaseGroup)
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to derive review targets"))
+ }
+ if len(targets) == 0 {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("the plan has no reviewable SQL"))
+ }
+ if reviewType == store.ReviewRunTypeGuideline {
+ aiSetting, err := s.store.GetAISetting(ctx, common.GetWorkspaceIDFromContext(ctx))
+ if err != nil {
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get AI setting"))
+ }
+ if !aiSetting.Enabled {
+ return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("guideline review requires AI to be enabled"))
+ }
+ }
+
+ reviewRun, err := s.store.CreateReviewRun(ctx, projectID, issueUID, reviewType)
+ if err != nil {
+ if common.ErrorCode(err) == common.NotFound {
+ return nil, connect.NewError(connect.CodeNotFound, err)
+ }
+ return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to create review run"))
+ }
+
+ s.bus.ReviewRunTickleChan <- 0
+
+ return connect.NewResponse(convertToReviewRun(reviewRun)), nil
+}
+
+// reviewRunTypeFromID maps a review run resource ID to the stored reviewer
+// type.
+func reviewRunTypeFromID(reviewRunID string) (string, bool) {
+ switch reviewRunID {
+ case reviewRunIDRule:
+ return store.ReviewRunTypeRule, true
+ case reviewRunIDGuideline:
+ return store.ReviewRunTypeGuideline, true
+ default:
+ return "", false
+ }
+}
+
+// reviewRunIDFromType maps a stored reviewer type to its resource ID. An
+// unknown type maps to itself: the reviewer-id space is open, and a name
+// beats an empty segment.
+func reviewRunIDFromType(reviewType string) string {
+ switch reviewType {
+ case store.ReviewRunTypeRule:
+ return reviewRunIDRule
+ case store.ReviewRunTypeGuideline:
+ return reviewRunIDGuideline
+ default:
+ return reviewType
+ }
+}
+
+func convertToReviewRun(reviewRun *store.ReviewRunMessage) *v1pb.ReviewRun {
+ converted := &v1pb.ReviewRun{
+ Name: common.FormatReviewRun(reviewRun.ProjectID, reviewRun.IssueUID, reviewRunIDFromType(reviewRun.Type)),
+ Type: convertToReviewRunType(reviewRun.Type),
+ Status: convertToReviewRunStatus(reviewRun.Status),
+ CreateTime: timestamppb.New(reviewRun.CreatedAt),
+ }
+ switch reviewRun.Status {
+ case storepb.ReviewRun_DONE, storepb.ReviewRun_FAILED:
+ // A terminal row is never written again, so updated_at is the end
+ // time.
+ converted.EndTime = timestamppb.New(reviewRun.UpdatedAt)
+ default:
+ }
+ if reviewRun.Status == storepb.ReviewRun_FAILED {
+ converted.Error = reviewRun.Payload.GetError()
+ }
+ return converted
+}
+
+func convertToReviewRunType(reviewType string) v1pb.ReviewRun_Type {
+ switch reviewType {
+ case store.ReviewRunTypeRule:
+ return v1pb.ReviewRun_RULE
+ case store.ReviewRunTypeGuideline:
+ return v1pb.ReviewRun_GUIDELINE
+ default:
+ return v1pb.ReviewRun_TYPE_UNSPECIFIED
+ }
+}
+
+func convertToReviewRunStatus(status storepb.ReviewRun_Status) v1pb.ReviewRun_Status {
+ switch status {
+ case storepb.ReviewRun_AVAILABLE:
+ return v1pb.ReviewRun_AVAILABLE
+ case storepb.ReviewRun_RUNNING:
+ return v1pb.ReviewRun_RUNNING
+ case storepb.ReviewRun_DONE:
+ return v1pb.ReviewRun_DONE
+ case storepb.ReviewRun_FAILED:
+ return v1pb.ReviewRun_FAILED
+ default:
+ return v1pb.ReviewRun_STATUS_UNSPECIFIED
+ }
+}
diff --git a/backend/api/v1/testdata/mcp_method_classification.md b/backend/api/v1/testdata/mcp_method_classification.md
index 493493f335..88c9faf735 100644
--- a/backend/api/v1/testdata/mcp_method_classification.md
+++ b/backend/api/v1/testdata/mcp_method_classification.md
@@ -17,11 +17,11 @@ served by no ceiling.
| Class | Methods | Meaning |
|---|---|---|
| READ | 57 | served to a read-only session and above |
-| WRITE | 40 | served to a read-write session only |
+| WRITE | 41 | served to a read-write session only |
| EXCLUDED | 85 | served by no ceiling this phase ships |
| FORBIDDEN | 35 | never served, whatever the ceiling |
| MCP_METHOD_CLASS_UNSPECIFIED | 0 | unclassified — CI rejects this, and the gate refuses it |
-| **total** | **217** | |
+| **total** | **218** | |
| Method | Class | Reason | Permission |
|---|---|---|---|
@@ -106,6 +106,7 @@ served by no ceiling.
| IssueService/RejectIssue | FORBIDDEN | DRIVES_THE_APPROVAL_DECISION | — |
| IssueService/RequestIssue | WRITE | — | — |
| IssueService/RetryIssueApproval | FORBIDDEN | DRIVES_THE_APPROVAL_DECISION | — |
+| IssueService/RunReview | WRITE | — | bb.reviewRuns.run |
| IssueService/SearchIssues | READ | — | bb.issues.get |
| IssueService/UpdateIssue | WRITE | — | bb.issues.update |
| IssueService/UpdateIssueComment | WRITE | — | bb.issueComments.update |
diff --git a/backend/common/permission/permission.go b/backend/common/permission/permission.go
index 7870c44ca6..146e5468b6 100644
--- a/backend/common/permission/permission.go
+++ b/backend/common/permission/permission.go
@@ -95,6 +95,7 @@ const (
ReviewConfigsGet Permission = "bb.reviewConfigs.get"
ReviewConfigsList Permission = "bb.reviewConfigs.list"
ReviewConfigsUpdate Permission = "bb.reviewConfigs.update"
+ ReviewRunsRun Permission = "bb.reviewRuns.run"
RevisionsCreate Permission = "bb.revisions.create"
RevisionsDelete Permission = "bb.revisions.delete"
RevisionsGet Permission = "bb.revisions.get"
diff --git a/backend/common/permission/permission.yaml b/backend/common/permission/permission.yaml
index 8921d3e5f5..6185a30242 100644
--- a/backend/common/permission/permission.yaml
+++ b/backend/common/permission/permission.yaml
@@ -87,6 +87,7 @@ permissions:
- bb.reviewConfigs.get
- bb.reviewConfigs.list
- bb.reviewConfigs.update
+ - bb.reviewRuns.run
- bb.revisions.create
- bb.revisions.delete
- bb.revisions.get
diff --git a/backend/common/resource_name.go b/backend/common/resource_name.go
index 166fecf874..94c45f871a 100644
--- a/backend/common/resource_name.go
+++ b/backend/common/resource_name.go
@@ -41,6 +41,7 @@ const (
ChangelogPrefix = "changelogs/"
IssueNamePrefix = "issues/"
IssueCommentNamePrefix = "issueComments/"
+ ReviewRunNamePrefix = "reviewRuns/"
PipelineNamePrefix = "pipelines/"
LogNamePrefix = "logs/"
BranchPrefix = "branches/"
@@ -308,6 +309,20 @@ func GetProjectIDIssueUIDIssueCommentID(name string) (string, int64, string, err
return tokens[0], issueUID, tokens[2], nil
}
+// GetProjectIDIssueUIDReviewRunID returns the project ID, issue UID, and
+// review run ID from a resource name.
+func GetProjectIDIssueUIDReviewRunID(name string) (string, int64, string, error) {
+ tokens, err := GetNameParentTokens(name, ProjectNamePrefix, IssueNamePrefix, ReviewRunNamePrefix)
+ if err != nil {
+ return "", 0, "", err
+ }
+ issueUID, err := strconv.ParseInt(tokens[1], 10, 64)
+ if err != nil {
+ return "", 0, "", errors.Errorf("invalid issue ID %q", tokens[1])
+ }
+ return tokens[0], issueUID, tokens[2], nil
+}
+
// GetProjectIDPlanID returns the project ID and plan ID from a resource name.
func GetProjectIDPlanID(name string) (string, int64, error) {
tokens, err := GetNameParentTokens(name, ProjectNamePrefix, PlanPrefix)
@@ -704,6 +719,12 @@ func FormatSheet(projectID string, sheetSha256 string) string {
return fmt.Sprintf("%s/%s%s", FormatProject(projectID), SheetIDPrefix, sheetSha256)
}
+// FormatReviewRun formats a review run resource name. The review run ID is
+// the reviewer: "rule" or "guideline".
+func FormatReviewRun(projectID string, issueUID int64, reviewRunID string) string {
+ return fmt.Sprintf("%s/%s%s", FormatIssue(projectID, issueUID), ReviewRunNamePrefix, reviewRunID)
+}
+
func FormatIssue(projectID string, issueUID int64) string {
return fmt.Sprintf("%s/%s%d", FormatProject(projectID), IssueNamePrefix, issueUID)
}
diff --git a/backend/component/bus/bus.go b/backend/component/bus/bus.go
index 93384ba12e..bf8e7cf09a 100644
--- a/backend/component/bus/bus.go
+++ b/backend/component/bus/bus.go
@@ -46,6 +46,8 @@ type Bus struct {
PlanCheckTickleChan chan int
// TaskRunTickleChan is the tickler for task run scheduler.
TaskRunTickleChan chan int
+ // ReviewRunTickleChan is the tickler for the review run scheduler.
+ ReviewRunTickleChan chan int
// RolloutCreationChan is the channel for automatic rollout creation.
RolloutCreationChan chan PlanRef
@@ -59,6 +61,7 @@ func New() (*Bus, error) {
ApprovalCheckChan: make(chan IssueRef, 1000),
PlanCheckTickleChan: make(chan int, 1000),
TaskRunTickleChan: make(chan int, 1000),
+ ReviewRunTickleChan: make(chan int, 1000),
RolloutCreationChan: make(chan PlanRef, 100),
PlanCompletionCheckChan: make(chan PlanRef, 1000),
}, nil
diff --git a/backend/component/productmetrics/productmetrics.go b/backend/component/productmetrics/productmetrics.go
index f04f5a01f3..6e92ae3d1c 100644
--- a/backend/component/productmetrics/productmetrics.go
+++ b/backend/component/productmetrics/productmetrics.go
@@ -25,6 +25,7 @@ type Runner string
const (
RunnerPlanCheck Runner = "plan_check"
+ RunnerReviewRun Runner = "review_run"
RunnerTaskPending Runner = "task_pending"
RunnerTaskDispatch Runner = "task_dispatch"
RunnerInstanceSync Runner = "instance_sync"
diff --git a/backend/generated-go/v1/issue_service.pb.go b/backend/generated-go/v1/issue_service.pb.go
index 6799c37a3a..6b6e28c2a5 100644
--- a/backend/generated-go/v1/issue_service.pb.go
+++ b/backend/generated-go/v1/issue_service.pb.go
@@ -198,6 +198,119 @@ func (IssueComment_Approval_Status) EnumDescriptor() ([]byte, []int) {
return file_v1_issue_service_proto_rawDescGZIP(), []int{21, 0, 0}
}
+type ReviewRun_Type int32
+
+const (
+ ReviewRun_TYPE_UNSPECIFIED ReviewRun_Type = 0
+ // Review against the standard rules.
+ ReviewRun_RULE ReviewRun_Type = 1
+ // Review against natural-language guidelines, performed by AI.
+ ReviewRun_GUIDELINE ReviewRun_Type = 2
+)
+
+// Enum value maps for ReviewRun_Type.
+var (
+ ReviewRun_Type_name = map[int32]string{
+ 0: "TYPE_UNSPECIFIED",
+ 1: "RULE",
+ 2: "GUIDELINE",
+ }
+ ReviewRun_Type_value = map[string]int32{
+ "TYPE_UNSPECIFIED": 0,
+ "RULE": 1,
+ "GUIDELINE": 2,
+ }
+)
+
+func (x ReviewRun_Type) Enum() *ReviewRun_Type {
+ p := new(ReviewRun_Type)
+ *p = x
+ return p
+}
+
+func (x ReviewRun_Type) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (ReviewRun_Type) Descriptor() protoreflect.EnumDescriptor {
+ return file_v1_issue_service_proto_enumTypes[3].Descriptor()
+}
+
+func (ReviewRun_Type) Type() protoreflect.EnumType {
+ return &file_v1_issue_service_proto_enumTypes[3]
+}
+
+func (x ReviewRun_Type) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use ReviewRun_Type.Descriptor instead.
+func (ReviewRun_Type) EnumDescriptor() ([]byte, []int) {
+ return file_v1_issue_service_proto_rawDescGZIP(), []int{22, 0}
+}
+
+// States follow task_run, minus PENDING (review needs no admission
+// control) and minus CANCELED (runs are side-effect-free until the fenced
+// completion transaction, so re-running supersedes instead of canceling).
+type ReviewRun_Status int32
+
+const (
+ ReviewRun_STATUS_UNSPECIFIED ReviewRun_Status = 0
+ // Created and claimable by any replica.
+ ReviewRun_AVAILABLE ReviewRun_Status = 1
+ ReviewRun_RUNNING ReviewRun_Status = 2
+ // Every (spec, target) unit was evaluated. DONE does not mean the
+ // review passed: whether problems remain is judged from open comments.
+ ReviewRun_DONE ReviewRun_Status = 3
+ // At least one unit was not evaluated; the cause is in `error`.
+ ReviewRun_FAILED ReviewRun_Status = 4
+)
+
+// Enum value maps for ReviewRun_Status.
+var (
+ ReviewRun_Status_name = map[int32]string{
+ 0: "STATUS_UNSPECIFIED",
+ 1: "AVAILABLE",
+ 2: "RUNNING",
+ 3: "DONE",
+ 4: "FAILED",
+ }
+ ReviewRun_Status_value = map[string]int32{
+ "STATUS_UNSPECIFIED": 0,
+ "AVAILABLE": 1,
+ "RUNNING": 2,
+ "DONE": 3,
+ "FAILED": 4,
+ }
+)
+
+func (x ReviewRun_Status) Enum() *ReviewRun_Status {
+ p := new(ReviewRun_Status)
+ *p = x
+ return p
+}
+
+func (x ReviewRun_Status) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (ReviewRun_Status) Descriptor() protoreflect.EnumDescriptor {
+ return file_v1_issue_service_proto_enumTypes[4].Descriptor()
+}
+
+func (ReviewRun_Status) Type() protoreflect.EnumType {
+ return &file_v1_issue_service_proto_enumTypes[4]
+}
+
+func (x ReviewRun_Status) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use ReviewRun_Status.Descriptor instead.
+func (ReviewRun_Status) EnumDescriptor() ([]byte, []int) {
+ return file_v1_issue_service_proto_rawDescGZIP(), []int{22, 1}
+}
+
type GetIssueRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The name of the issue to retrieve.
@@ -1839,6 +1952,145 @@ func (*IssueComment_PlanUpdate_) isIssueComment_Event() {}
func (*IssueComment_ReviewSubmission_) isIssueComment_Event() {}
+type ReviewRun struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ // The {reviewRun} id is the reviewer: "rule" or "guideline". The name
+ // addresses a slot, not an execution.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // Derived from the name.
+ Type ReviewRun_Type `protobuf:"varint,2,opt,name=type,proto3,enum=bytebase.v1.ReviewRun_Type" json:"type,omitempty"`
+ Status ReviewRun_Status `protobuf:"varint,3,opt,name=status,proto3,enum=bytebase.v1.ReviewRun_Status" json:"status,omitempty"`
+ // When the current run was triggered. Reset on every re-run.
+ CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
+ // When the run reached a terminal status. Unset while AVAILABLE or
+ // RUNNING.
+ EndTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"`
+ // Fatal execution error, set if and only if status is FAILED: the review
+ // failed to execute (a platform problem, never the SQL — SQL problems are
+ // review results on a DONE run).
+ Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *ReviewRun) Reset() {
+ *x = ReviewRun{}
+ mi := &file_v1_issue_service_proto_msgTypes[22]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *ReviewRun) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ReviewRun) ProtoMessage() {}
+
+func (x *ReviewRun) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_issue_service_proto_msgTypes[22]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use ReviewRun.ProtoReflect.Descriptor instead.
+func (*ReviewRun) Descriptor() ([]byte, []int) {
+ return file_v1_issue_service_proto_rawDescGZIP(), []int{22}
+}
+
+func (x *ReviewRun) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+func (x *ReviewRun) GetType() ReviewRun_Type {
+ if x != nil {
+ return x.Type
+ }
+ return ReviewRun_TYPE_UNSPECIFIED
+}
+
+func (x *ReviewRun) GetStatus() ReviewRun_Status {
+ if x != nil {
+ return x.Status
+ }
+ return ReviewRun_STATUS_UNSPECIFIED
+}
+
+func (x *ReviewRun) GetCreateTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.CreateTime
+ }
+ return nil
+}
+
+func (x *ReviewRun) GetEndTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.EndTime
+ }
+ return nil
+}
+
+func (x *ReviewRun) GetError() string {
+ if x != nil {
+ return x.Error
+ }
+ return ""
+}
+
+type RunReviewRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ // Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *RunReviewRequest) Reset() {
+ *x = RunReviewRequest{}
+ mi := &file_v1_issue_service_proto_msgTypes[23]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *RunReviewRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*RunReviewRequest) ProtoMessage() {}
+
+func (x *RunReviewRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_issue_service_proto_msgTypes[23]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use RunReviewRequest.ProtoReflect.Descriptor instead.
+func (*RunReviewRequest) Descriptor() ([]byte, []int) {
+ return file_v1_issue_service_proto_rawDescGZIP(), []int{23}
+}
+
+func (x *RunReviewRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
// Approvers and their approval status for the issue.
type Issue_Approver struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -1852,7 +2104,7 @@ type Issue_Approver struct {
func (x *Issue_Approver) Reset() {
*x = Issue_Approver{}
- mi := &file_v1_issue_service_proto_msgTypes[22]
+ mi := &file_v1_issue_service_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1864,7 +2116,7 @@ func (x *Issue_Approver) String() string {
func (*Issue_Approver) ProtoMessage() {}
func (x *Issue_Approver) ProtoReflect() protoreflect.Message {
- mi := &file_v1_issue_service_proto_msgTypes[22]
+ mi := &file_v1_issue_service_proto_msgTypes[24]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1905,7 +2157,7 @@ type IssueComment_Approval struct {
func (x *IssueComment_Approval) Reset() {
*x = IssueComment_Approval{}
- mi := &file_v1_issue_service_proto_msgTypes[23]
+ mi := &file_v1_issue_service_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1917,7 +2169,7 @@ func (x *IssueComment_Approval) String() string {
func (*IssueComment_Approval) ProtoMessage() {}
func (x *IssueComment_Approval) ProtoReflect() protoreflect.Message {
- mi := &file_v1_issue_service_proto_msgTypes[23]
+ mi := &file_v1_issue_service_proto_msgTypes[25]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1957,7 +2209,7 @@ type IssueComment_IssueUpdate struct {
func (x *IssueComment_IssueUpdate) Reset() {
*x = IssueComment_IssueUpdate{}
- mi := &file_v1_issue_service_proto_msgTypes[24]
+ mi := &file_v1_issue_service_proto_msgTypes[26]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1969,7 +2221,7 @@ func (x *IssueComment_IssueUpdate) String() string {
func (*IssueComment_IssueUpdate) ProtoMessage() {}
func (x *IssueComment_IssueUpdate) ProtoReflect() protoreflect.Message {
- mi := &file_v1_issue_service_proto_msgTypes[24]
+ mi := &file_v1_issue_service_proto_msgTypes[26]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2050,7 +2302,7 @@ type IssueComment_ReviewSubmission struct {
func (x *IssueComment_ReviewSubmission) Reset() {
*x = IssueComment_ReviewSubmission{}
- mi := &file_v1_issue_service_proto_msgTypes[25]
+ mi := &file_v1_issue_service_proto_msgTypes[27]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2062,7 +2314,7 @@ func (x *IssueComment_ReviewSubmission) String() string {
func (*IssueComment_ReviewSubmission) ProtoMessage() {}
func (x *IssueComment_ReviewSubmission) ProtoReflect() protoreflect.Message {
- mi := &file_v1_issue_service_proto_msgTypes[25]
+ mi := &file_v1_issue_service_proto_msgTypes[27]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2090,7 +2342,7 @@ type IssueComment_PlanUpdate struct {
func (x *IssueComment_PlanUpdate) Reset() {
*x = IssueComment_PlanUpdate{}
- mi := &file_v1_issue_service_proto_msgTypes[26]
+ mi := &file_v1_issue_service_proto_msgTypes[28]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2102,7 +2354,7 @@ func (x *IssueComment_PlanUpdate) String() string {
func (*IssueComment_PlanUpdate) ProtoMessage() {}
func (x *IssueComment_PlanUpdate) ProtoReflect() protoreflect.Message {
- mi := &file_v1_issue_service_proto_msgTypes[26]
+ mi := &file_v1_issue_service_proto_msgTypes[28]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2315,7 +2567,30 @@ const file_v1_issue_service_proto_rawDesc = "" +
"\n" +
"from_specs\x18\x01 \x03(\v2\x16.bytebase.v1.Plan.SpecR\tfromSpecs\x121\n" +
"\bto_specs\x18\x02 \x03(\v2\x16.bytebase.v1.Plan.SpecR\atoSpecsB\a\n" +
- "\x05eventJ\x04\b\t\x10\f2\xaf\x11\n" +
+ "\x05eventJ\x04\b\t\x10\f\"\x8c\x04\n" +
+ "\tReviewRun\x12\x12\n" +
+ "\x04name\x18\x01 \x01(\tR\x04name\x124\n" +
+ "\x04type\x18\x02 \x01(\x0e2\x1b.bytebase.v1.ReviewRun.TypeB\x03\xe0A\x03R\x04type\x12:\n" +
+ "\x06status\x18\x03 \x01(\x0e2\x1d.bytebase.v1.ReviewRun.StatusB\x03\xe0A\x03R\x06status\x12@\n" +
+ "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x03R\n" +
+ "createTime\x12:\n" +
+ "\bend_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x03R\aendTime\x12\x19\n" +
+ "\x05error\x18\x06 \x01(\tB\x03\xe0A\x03R\x05error\"5\n" +
+ "\x04Type\x12\x14\n" +
+ "\x10TYPE_UNSPECIFIED\x10\x00\x12\b\n" +
+ "\x04RULE\x10\x01\x12\r\n" +
+ "\tGUIDELINE\x10\x02\"R\n" +
+ "\x06Status\x12\x16\n" +
+ "\x12STATUS_UNSPECIFIED\x10\x00\x12\r\n" +
+ "\tAVAILABLE\x10\x01\x12\v\n" +
+ "\aRUNNING\x10\x02\x12\b\n" +
+ "\x04DONE\x10\x03\x12\n" +
+ "\n" +
+ "\x06FAILED\x10\x04:U\xeaAR\n" +
+ "\x16bytebase.com/ReviewRun\x128projects/{project}/issues/{issue}/reviewRuns/{reviewRun}\"F\n" +
+ "\x10RunReviewRequest\x122\n" +
+ "\x04name\x18\x01 \x01(\tB\x1e\xe0A\x02\xfaA\x18\n" +
+ "\x16bytebase.com/ReviewRunR\x04name2\xd8\x12\n" +
"\fIssueService\x12\x84\x01\n" +
"\bGetIssue\x12\x1c.bytebase.v1.GetIssueRequest\x1a\x12.bytebase.v1.Issue\"F\xdaA\x04name\x8a\xea0\rbb.issues.get\x90\xea0\x01\xa0\xea0\x01\x82\xd3\xe4\x93\x02 \x12\x1e/v1/{name=projects/*/issues/*}\x12\xa0\x01\n" +
"\vCreateIssue\x12\x1f.bytebase.v1.CreateIssueRequest\x1a\x12.bytebase.v1.Issue\"\\\xdaA\fparent,issue\x8a\xea0\x10bb.issues.create\x90\xea0\x01\x98\xea0\x01\xa0\xea0\x02\x82\xd3\xe4\x93\x02':\x05issue\"\x1e/v1/{parent=projects/*}/issues\x12\x98\x01\n" +
@@ -2330,7 +2605,8 @@ const file_v1_issue_service_proto_rawDesc = "" +
"\fApproveIssue\x12 .bytebase.v1.ApproveIssueRequest\x1a\x12.bytebase.v1.Issue\"A\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x03\xa8\xea0\b\x82\xd3\xe4\x93\x02+:\x01*\"&/v1/{name=projects/*/issues/*}:approve\x12\x84\x01\n" +
"\vRejectIssue\x12\x1f.bytebase.v1.RejectIssueRequest\x1a\x12.bytebase.v1.Issue\"@\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x03\xa8\xea0\b\x82\xd3\xe4\x93\x02*:\x01*\"%/v1/{name=projects/*/issues/*}:reject\x12\x83\x01\n" +
"\fRequestIssue\x12 .bytebase.v1.RequestIssueRequest\x1a\x12.bytebase.v1.Issue\"=\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x02\x82\xd3\xe4\x93\x02+:\x01*\"&/v1/{name=projects/*/issues/*}:request\x12\x99\x01\n" +
- "\x12RetryIssueApproval\x12&.bytebase.v1.RetryIssueApprovalRequest\x1a\x12.bytebase.v1.Issue\"G\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x03\xa8\xea0\b\x82\xd3\xe4\x93\x021:\x01*\",/v1/{name=projects/*/issues/*}:retryApprovalB\xa7\x01\n" +
+ "\x12RetryIssueApproval\x12&.bytebase.v1.RetryIssueApprovalRequest\x1a\x12.bytebase.v1.Issue\"G\x90\xea0\x02\x98\xea0\x01\xa0\xea0\x03\xa8\xea0\b\x82\xd3\xe4\x93\x021:\x01*\",/v1/{name=projects/*/issues/*}:retryApproval\x12\xa6\x01\n" +
+ "\tRunReview\x12\x1d.bytebase.v1.RunReviewRequest\x1a\x16.bytebase.v1.ReviewRun\"b\xdaA\x04name\x8a\xea0\x11bb.reviewRuns.run\x90\xea0\x01\x98\xea0\x01\xa0\xea0\x02\x82\xd3\xe4\x93\x024:\x01*\"//v1/{name=projects/*/issues/*/reviewRuns/*}:runB\xa7\x01\n" +
"\x0fcom.bytebase.v1B\x11IssueServiceProtoP\x01Z4github.com/bytebase/bytebase/backend/generated-go/v1\xa2\x02\x03BXX\xaa\x02\vBytebase.V1\xca\x02\vBytebase\\V1\xe2\x02\x17Bytebase\\V1\\GPBMetadata\xea\x02\fBytebase::V1b\x06proto3"
var (
@@ -2345,114 +2621,124 @@ func file_v1_issue_service_proto_rawDescGZIP() []byte {
return file_v1_issue_service_proto_rawDescData
}
-var file_v1_issue_service_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
-var file_v1_issue_service_proto_msgTypes = make([]protoimpl.MessageInfo, 27)
+var file_v1_issue_service_proto_enumTypes = make([]protoimpl.EnumInfo, 5)
+var file_v1_issue_service_proto_msgTypes = make([]protoimpl.MessageInfo, 29)
var file_v1_issue_service_proto_goTypes = []any{
(Issue_Type)(0), // 0: bytebase.v1.Issue.Type
(Issue_Approver_Status)(0), // 1: bytebase.v1.Issue.Approver.Status
(IssueComment_Approval_Status)(0), // 2: bytebase.v1.IssueComment.Approval.Status
- (*GetIssueRequest)(nil), // 3: bytebase.v1.GetIssueRequest
- (*CreateIssueRequest)(nil), // 4: bytebase.v1.CreateIssueRequest
- (*ListIssuesRequest)(nil), // 5: bytebase.v1.ListIssuesRequest
- (*ListIssuesResponse)(nil), // 6: bytebase.v1.ListIssuesResponse
- (*SearchIssuesRequest)(nil), // 7: bytebase.v1.SearchIssuesRequest
- (*SearchIssuesResponse)(nil), // 8: bytebase.v1.SearchIssuesResponse
- (*UpdateIssueRequest)(nil), // 9: bytebase.v1.UpdateIssueRequest
- (*BatchUpdateIssuesStatusRequest)(nil), // 10: bytebase.v1.BatchUpdateIssuesStatusRequest
- (*BatchUpdateIssuesStatusResponse)(nil), // 11: bytebase.v1.BatchUpdateIssuesStatusResponse
- (*ApproveIssueRequest)(nil), // 12: bytebase.v1.ApproveIssueRequest
- (*RejectIssueRequest)(nil), // 13: bytebase.v1.RejectIssueRequest
- (*RequestIssueRequest)(nil), // 14: bytebase.v1.RequestIssueRequest
- (*RetryIssueApprovalRequest)(nil), // 15: bytebase.v1.RetryIssueApprovalRequest
- (*Issue)(nil), // 16: bytebase.v1.Issue
- (*RoleGrant)(nil), // 17: bytebase.v1.RoleGrant
- (*ApprovalTemplate)(nil), // 18: bytebase.v1.ApprovalTemplate
- (*ApprovalFlow)(nil), // 19: bytebase.v1.ApprovalFlow
- (*ListIssueCommentsRequest)(nil), // 20: bytebase.v1.ListIssueCommentsRequest
- (*ListIssueCommentsResponse)(nil), // 21: bytebase.v1.ListIssueCommentsResponse
- (*CreateIssueCommentRequest)(nil), // 22: bytebase.v1.CreateIssueCommentRequest
- (*UpdateIssueCommentRequest)(nil), // 23: bytebase.v1.UpdateIssueCommentRequest
- (*IssueComment)(nil), // 24: bytebase.v1.IssueComment
- (*Issue_Approver)(nil), // 25: bytebase.v1.Issue.Approver
- (*IssueComment_Approval)(nil), // 26: bytebase.v1.IssueComment.Approval
- (*IssueComment_IssueUpdate)(nil), // 27: bytebase.v1.IssueComment.IssueUpdate
- (*IssueComment_ReviewSubmission)(nil), // 28: bytebase.v1.IssueComment.ReviewSubmission
- (*IssueComment_PlanUpdate)(nil), // 29: bytebase.v1.IssueComment.PlanUpdate
- (*fieldmaskpb.FieldMask)(nil), // 30: google.protobuf.FieldMask
- (IssueStatus)(0), // 31: bytebase.v1.IssueStatus
- (*timestamppb.Timestamp)(nil), // 32: google.protobuf.Timestamp
- (RiskLevel)(0), // 33: bytebase.v1.RiskLevel
- (ApprovalStatus)(0), // 34: bytebase.v1.ApprovalStatus
- (*expr.Expr)(nil), // 35: google.type.Expr
- (*durationpb.Duration)(nil), // 36: google.protobuf.Duration
- (*Plan_Spec)(nil), // 37: bytebase.v1.Plan.Spec
+ (ReviewRun_Type)(0), // 3: bytebase.v1.ReviewRun.Type
+ (ReviewRun_Status)(0), // 4: bytebase.v1.ReviewRun.Status
+ (*GetIssueRequest)(nil), // 5: bytebase.v1.GetIssueRequest
+ (*CreateIssueRequest)(nil), // 6: bytebase.v1.CreateIssueRequest
+ (*ListIssuesRequest)(nil), // 7: bytebase.v1.ListIssuesRequest
+ (*ListIssuesResponse)(nil), // 8: bytebase.v1.ListIssuesResponse
+ (*SearchIssuesRequest)(nil), // 9: bytebase.v1.SearchIssuesRequest
+ (*SearchIssuesResponse)(nil), // 10: bytebase.v1.SearchIssuesResponse
+ (*UpdateIssueRequest)(nil), // 11: bytebase.v1.UpdateIssueRequest
+ (*BatchUpdateIssuesStatusRequest)(nil), // 12: bytebase.v1.BatchUpdateIssuesStatusRequest
+ (*BatchUpdateIssuesStatusResponse)(nil), // 13: bytebase.v1.BatchUpdateIssuesStatusResponse
+ (*ApproveIssueRequest)(nil), // 14: bytebase.v1.ApproveIssueRequest
+ (*RejectIssueRequest)(nil), // 15: bytebase.v1.RejectIssueRequest
+ (*RequestIssueRequest)(nil), // 16: bytebase.v1.RequestIssueRequest
+ (*RetryIssueApprovalRequest)(nil), // 17: bytebase.v1.RetryIssueApprovalRequest
+ (*Issue)(nil), // 18: bytebase.v1.Issue
+ (*RoleGrant)(nil), // 19: bytebase.v1.RoleGrant
+ (*ApprovalTemplate)(nil), // 20: bytebase.v1.ApprovalTemplate
+ (*ApprovalFlow)(nil), // 21: bytebase.v1.ApprovalFlow
+ (*ListIssueCommentsRequest)(nil), // 22: bytebase.v1.ListIssueCommentsRequest
+ (*ListIssueCommentsResponse)(nil), // 23: bytebase.v1.ListIssueCommentsResponse
+ (*CreateIssueCommentRequest)(nil), // 24: bytebase.v1.CreateIssueCommentRequest
+ (*UpdateIssueCommentRequest)(nil), // 25: bytebase.v1.UpdateIssueCommentRequest
+ (*IssueComment)(nil), // 26: bytebase.v1.IssueComment
+ (*ReviewRun)(nil), // 27: bytebase.v1.ReviewRun
+ (*RunReviewRequest)(nil), // 28: bytebase.v1.RunReviewRequest
+ (*Issue_Approver)(nil), // 29: bytebase.v1.Issue.Approver
+ (*IssueComment_Approval)(nil), // 30: bytebase.v1.IssueComment.Approval
+ (*IssueComment_IssueUpdate)(nil), // 31: bytebase.v1.IssueComment.IssueUpdate
+ (*IssueComment_ReviewSubmission)(nil), // 32: bytebase.v1.IssueComment.ReviewSubmission
+ (*IssueComment_PlanUpdate)(nil), // 33: bytebase.v1.IssueComment.PlanUpdate
+ (*fieldmaskpb.FieldMask)(nil), // 34: google.protobuf.FieldMask
+ (IssueStatus)(0), // 35: bytebase.v1.IssueStatus
+ (*timestamppb.Timestamp)(nil), // 36: google.protobuf.Timestamp
+ (RiskLevel)(0), // 37: bytebase.v1.RiskLevel
+ (ApprovalStatus)(0), // 38: bytebase.v1.ApprovalStatus
+ (*expr.Expr)(nil), // 39: google.type.Expr
+ (*durationpb.Duration)(nil), // 40: google.protobuf.Duration
+ (*Plan_Spec)(nil), // 41: bytebase.v1.Plan.Spec
}
var file_v1_issue_service_proto_depIdxs = []int32{
- 16, // 0: bytebase.v1.CreateIssueRequest.issue:type_name -> bytebase.v1.Issue
- 16, // 1: bytebase.v1.ListIssuesResponse.issues:type_name -> bytebase.v1.Issue
- 16, // 2: bytebase.v1.SearchIssuesResponse.issues:type_name -> bytebase.v1.Issue
- 16, // 3: bytebase.v1.UpdateIssueRequest.issue:type_name -> bytebase.v1.Issue
- 30, // 4: bytebase.v1.UpdateIssueRequest.update_mask:type_name -> google.protobuf.FieldMask
- 31, // 5: bytebase.v1.BatchUpdateIssuesStatusRequest.status:type_name -> bytebase.v1.IssueStatus
+ 18, // 0: bytebase.v1.CreateIssueRequest.issue:type_name -> bytebase.v1.Issue
+ 18, // 1: bytebase.v1.ListIssuesResponse.issues:type_name -> bytebase.v1.Issue
+ 18, // 2: bytebase.v1.SearchIssuesResponse.issues:type_name -> bytebase.v1.Issue
+ 18, // 3: bytebase.v1.UpdateIssueRequest.issue:type_name -> bytebase.v1.Issue
+ 34, // 4: bytebase.v1.UpdateIssueRequest.update_mask:type_name -> google.protobuf.FieldMask
+ 35, // 5: bytebase.v1.BatchUpdateIssuesStatusRequest.status:type_name -> bytebase.v1.IssueStatus
0, // 6: bytebase.v1.Issue.type:type_name -> bytebase.v1.Issue.Type
- 31, // 7: bytebase.v1.Issue.status:type_name -> bytebase.v1.IssueStatus
- 25, // 8: bytebase.v1.Issue.approvers:type_name -> bytebase.v1.Issue.Approver
- 18, // 9: bytebase.v1.Issue.approval_template:type_name -> bytebase.v1.ApprovalTemplate
- 32, // 10: bytebase.v1.Issue.create_time:type_name -> google.protobuf.Timestamp
- 32, // 11: bytebase.v1.Issue.update_time:type_name -> google.protobuf.Timestamp
- 17, // 12: bytebase.v1.Issue.role_grant:type_name -> bytebase.v1.RoleGrant
- 33, // 13: bytebase.v1.Issue.risk_level:type_name -> bytebase.v1.RiskLevel
- 34, // 14: bytebase.v1.Issue.approval_status:type_name -> bytebase.v1.ApprovalStatus
- 35, // 15: bytebase.v1.RoleGrant.condition:type_name -> google.type.Expr
- 36, // 16: bytebase.v1.RoleGrant.expiration:type_name -> google.protobuf.Duration
- 19, // 17: bytebase.v1.ApprovalTemplate.flow:type_name -> bytebase.v1.ApprovalFlow
- 24, // 18: bytebase.v1.ListIssueCommentsResponse.issue_comments:type_name -> bytebase.v1.IssueComment
- 24, // 19: bytebase.v1.CreateIssueCommentRequest.issue_comment:type_name -> bytebase.v1.IssueComment
- 24, // 20: bytebase.v1.UpdateIssueCommentRequest.issue_comment:type_name -> bytebase.v1.IssueComment
- 30, // 21: bytebase.v1.UpdateIssueCommentRequest.update_mask:type_name -> google.protobuf.FieldMask
- 32, // 22: bytebase.v1.IssueComment.create_time:type_name -> google.protobuf.Timestamp
- 32, // 23: bytebase.v1.IssueComment.update_time:type_name -> google.protobuf.Timestamp
- 26, // 24: bytebase.v1.IssueComment.approval:type_name -> bytebase.v1.IssueComment.Approval
- 27, // 25: bytebase.v1.IssueComment.issue_update:type_name -> bytebase.v1.IssueComment.IssueUpdate
- 29, // 26: bytebase.v1.IssueComment.plan_update:type_name -> bytebase.v1.IssueComment.PlanUpdate
- 28, // 27: bytebase.v1.IssueComment.review_submission:type_name -> bytebase.v1.IssueComment.ReviewSubmission
- 1, // 28: bytebase.v1.Issue.Approver.status:type_name -> bytebase.v1.Issue.Approver.Status
- 2, // 29: bytebase.v1.IssueComment.Approval.status:type_name -> bytebase.v1.IssueComment.Approval.Status
- 31, // 30: bytebase.v1.IssueComment.IssueUpdate.from_status:type_name -> bytebase.v1.IssueStatus
- 31, // 31: bytebase.v1.IssueComment.IssueUpdate.to_status:type_name -> bytebase.v1.IssueStatus
- 37, // 32: bytebase.v1.IssueComment.PlanUpdate.from_specs:type_name -> bytebase.v1.Plan.Spec
- 37, // 33: bytebase.v1.IssueComment.PlanUpdate.to_specs:type_name -> bytebase.v1.Plan.Spec
- 3, // 34: bytebase.v1.IssueService.GetIssue:input_type -> bytebase.v1.GetIssueRequest
- 4, // 35: bytebase.v1.IssueService.CreateIssue:input_type -> bytebase.v1.CreateIssueRequest
- 5, // 36: bytebase.v1.IssueService.ListIssues:input_type -> bytebase.v1.ListIssuesRequest
- 7, // 37: bytebase.v1.IssueService.SearchIssues:input_type -> bytebase.v1.SearchIssuesRequest
- 9, // 38: bytebase.v1.IssueService.UpdateIssue:input_type -> bytebase.v1.UpdateIssueRequest
- 20, // 39: bytebase.v1.IssueService.ListIssueComments:input_type -> bytebase.v1.ListIssueCommentsRequest
- 22, // 40: bytebase.v1.IssueService.CreateIssueComment:input_type -> bytebase.v1.CreateIssueCommentRequest
- 23, // 41: bytebase.v1.IssueService.UpdateIssueComment:input_type -> bytebase.v1.UpdateIssueCommentRequest
- 10, // 42: bytebase.v1.IssueService.BatchUpdateIssuesStatus:input_type -> bytebase.v1.BatchUpdateIssuesStatusRequest
- 12, // 43: bytebase.v1.IssueService.ApproveIssue:input_type -> bytebase.v1.ApproveIssueRequest
- 13, // 44: bytebase.v1.IssueService.RejectIssue:input_type -> bytebase.v1.RejectIssueRequest
- 14, // 45: bytebase.v1.IssueService.RequestIssue:input_type -> bytebase.v1.RequestIssueRequest
- 15, // 46: bytebase.v1.IssueService.RetryIssueApproval:input_type -> bytebase.v1.RetryIssueApprovalRequest
- 16, // 47: bytebase.v1.IssueService.GetIssue:output_type -> bytebase.v1.Issue
- 16, // 48: bytebase.v1.IssueService.CreateIssue:output_type -> bytebase.v1.Issue
- 6, // 49: bytebase.v1.IssueService.ListIssues:output_type -> bytebase.v1.ListIssuesResponse
- 8, // 50: bytebase.v1.IssueService.SearchIssues:output_type -> bytebase.v1.SearchIssuesResponse
- 16, // 51: bytebase.v1.IssueService.UpdateIssue:output_type -> bytebase.v1.Issue
- 21, // 52: bytebase.v1.IssueService.ListIssueComments:output_type -> bytebase.v1.ListIssueCommentsResponse
- 24, // 53: bytebase.v1.IssueService.CreateIssueComment:output_type -> bytebase.v1.IssueComment
- 24, // 54: bytebase.v1.IssueService.UpdateIssueComment:output_type -> bytebase.v1.IssueComment
- 11, // 55: bytebase.v1.IssueService.BatchUpdateIssuesStatus:output_type -> bytebase.v1.BatchUpdateIssuesStatusResponse
- 16, // 56: bytebase.v1.IssueService.ApproveIssue:output_type -> bytebase.v1.Issue
- 16, // 57: bytebase.v1.IssueService.RejectIssue:output_type -> bytebase.v1.Issue
- 16, // 58: bytebase.v1.IssueService.RequestIssue:output_type -> bytebase.v1.Issue
- 16, // 59: bytebase.v1.IssueService.RetryIssueApproval:output_type -> bytebase.v1.Issue
- 47, // [47:60] is the sub-list for method output_type
- 34, // [34:47] is the sub-list for method input_type
- 34, // [34:34] is the sub-list for extension type_name
- 34, // [34:34] is the sub-list for extension extendee
- 0, // [0:34] is the sub-list for field type_name
+ 35, // 7: bytebase.v1.Issue.status:type_name -> bytebase.v1.IssueStatus
+ 29, // 8: bytebase.v1.Issue.approvers:type_name -> bytebase.v1.Issue.Approver
+ 20, // 9: bytebase.v1.Issue.approval_template:type_name -> bytebase.v1.ApprovalTemplate
+ 36, // 10: bytebase.v1.Issue.create_time:type_name -> google.protobuf.Timestamp
+ 36, // 11: bytebase.v1.Issue.update_time:type_name -> google.protobuf.Timestamp
+ 19, // 12: bytebase.v1.Issue.role_grant:type_name -> bytebase.v1.RoleGrant
+ 37, // 13: bytebase.v1.Issue.risk_level:type_name -> bytebase.v1.RiskLevel
+ 38, // 14: bytebase.v1.Issue.approval_status:type_name -> bytebase.v1.ApprovalStatus
+ 39, // 15: bytebase.v1.RoleGrant.condition:type_name -> google.type.Expr
+ 40, // 16: bytebase.v1.RoleGrant.expiration:type_name -> google.protobuf.Duration
+ 21, // 17: bytebase.v1.ApprovalTemplate.flow:type_name -> bytebase.v1.ApprovalFlow
+ 26, // 18: bytebase.v1.ListIssueCommentsResponse.issue_comments:type_name -> bytebase.v1.IssueComment
+ 26, // 19: bytebase.v1.CreateIssueCommentRequest.issue_comment:type_name -> bytebase.v1.IssueComment
+ 26, // 20: bytebase.v1.UpdateIssueCommentRequest.issue_comment:type_name -> bytebase.v1.IssueComment
+ 34, // 21: bytebase.v1.UpdateIssueCommentRequest.update_mask:type_name -> google.protobuf.FieldMask
+ 36, // 22: bytebase.v1.IssueComment.create_time:type_name -> google.protobuf.Timestamp
+ 36, // 23: bytebase.v1.IssueComment.update_time:type_name -> google.protobuf.Timestamp
+ 30, // 24: bytebase.v1.IssueComment.approval:type_name -> bytebase.v1.IssueComment.Approval
+ 31, // 25: bytebase.v1.IssueComment.issue_update:type_name -> bytebase.v1.IssueComment.IssueUpdate
+ 33, // 26: bytebase.v1.IssueComment.plan_update:type_name -> bytebase.v1.IssueComment.PlanUpdate
+ 32, // 27: bytebase.v1.IssueComment.review_submission:type_name -> bytebase.v1.IssueComment.ReviewSubmission
+ 3, // 28: bytebase.v1.ReviewRun.type:type_name -> bytebase.v1.ReviewRun.Type
+ 4, // 29: bytebase.v1.ReviewRun.status:type_name -> bytebase.v1.ReviewRun.Status
+ 36, // 30: bytebase.v1.ReviewRun.create_time:type_name -> google.protobuf.Timestamp
+ 36, // 31: bytebase.v1.ReviewRun.end_time:type_name -> google.protobuf.Timestamp
+ 1, // 32: bytebase.v1.Issue.Approver.status:type_name -> bytebase.v1.Issue.Approver.Status
+ 2, // 33: bytebase.v1.IssueComment.Approval.status:type_name -> bytebase.v1.IssueComment.Approval.Status
+ 35, // 34: bytebase.v1.IssueComment.IssueUpdate.from_status:type_name -> bytebase.v1.IssueStatus
+ 35, // 35: bytebase.v1.IssueComment.IssueUpdate.to_status:type_name -> bytebase.v1.IssueStatus
+ 41, // 36: bytebase.v1.IssueComment.PlanUpdate.from_specs:type_name -> bytebase.v1.Plan.Spec
+ 41, // 37: bytebase.v1.IssueComment.PlanUpdate.to_specs:type_name -> bytebase.v1.Plan.Spec
+ 5, // 38: bytebase.v1.IssueService.GetIssue:input_type -> bytebase.v1.GetIssueRequest
+ 6, // 39: bytebase.v1.IssueService.CreateIssue:input_type -> bytebase.v1.CreateIssueRequest
+ 7, // 40: bytebase.v1.IssueService.ListIssues:input_type -> bytebase.v1.ListIssuesRequest
+ 9, // 41: bytebase.v1.IssueService.SearchIssues:input_type -> bytebase.v1.SearchIssuesRequest
+ 11, // 42: bytebase.v1.IssueService.UpdateIssue:input_type -> bytebase.v1.UpdateIssueRequest
+ 22, // 43: bytebase.v1.IssueService.ListIssueComments:input_type -> bytebase.v1.ListIssueCommentsRequest
+ 24, // 44: bytebase.v1.IssueService.CreateIssueComment:input_type -> bytebase.v1.CreateIssueCommentRequest
+ 25, // 45: bytebase.v1.IssueService.UpdateIssueComment:input_type -> bytebase.v1.UpdateIssueCommentRequest
+ 12, // 46: bytebase.v1.IssueService.BatchUpdateIssuesStatus:input_type -> bytebase.v1.BatchUpdateIssuesStatusRequest
+ 14, // 47: bytebase.v1.IssueService.ApproveIssue:input_type -> bytebase.v1.ApproveIssueRequest
+ 15, // 48: bytebase.v1.IssueService.RejectIssue:input_type -> bytebase.v1.RejectIssueRequest
+ 16, // 49: bytebase.v1.IssueService.RequestIssue:input_type -> bytebase.v1.RequestIssueRequest
+ 17, // 50: bytebase.v1.IssueService.RetryIssueApproval:input_type -> bytebase.v1.RetryIssueApprovalRequest
+ 28, // 51: bytebase.v1.IssueService.RunReview:input_type -> bytebase.v1.RunReviewRequest
+ 18, // 52: bytebase.v1.IssueService.GetIssue:output_type -> bytebase.v1.Issue
+ 18, // 53: bytebase.v1.IssueService.CreateIssue:output_type -> bytebase.v1.Issue
+ 8, // 54: bytebase.v1.IssueService.ListIssues:output_type -> bytebase.v1.ListIssuesResponse
+ 10, // 55: bytebase.v1.IssueService.SearchIssues:output_type -> bytebase.v1.SearchIssuesResponse
+ 18, // 56: bytebase.v1.IssueService.UpdateIssue:output_type -> bytebase.v1.Issue
+ 23, // 57: bytebase.v1.IssueService.ListIssueComments:output_type -> bytebase.v1.ListIssueCommentsResponse
+ 26, // 58: bytebase.v1.IssueService.CreateIssueComment:output_type -> bytebase.v1.IssueComment
+ 26, // 59: bytebase.v1.IssueService.UpdateIssueComment:output_type -> bytebase.v1.IssueComment
+ 13, // 60: bytebase.v1.IssueService.BatchUpdateIssuesStatus:output_type -> bytebase.v1.BatchUpdateIssuesStatusResponse
+ 18, // 61: bytebase.v1.IssueService.ApproveIssue:output_type -> bytebase.v1.Issue
+ 18, // 62: bytebase.v1.IssueService.RejectIssue:output_type -> bytebase.v1.Issue
+ 18, // 63: bytebase.v1.IssueService.RequestIssue:output_type -> bytebase.v1.Issue
+ 18, // 64: bytebase.v1.IssueService.RetryIssueApproval:output_type -> bytebase.v1.Issue
+ 27, // 65: bytebase.v1.IssueService.RunReview:output_type -> bytebase.v1.ReviewRun
+ 52, // [52:66] is the sub-list for method output_type
+ 38, // [38:52] is the sub-list for method input_type
+ 38, // [38:38] is the sub-list for extension type_name
+ 38, // [38:38] is the sub-list for extension extendee
+ 0, // [0:38] is the sub-list for field type_name
}
func init() { file_v1_issue_service_proto_init() }
@@ -2469,14 +2755,14 @@ func file_v1_issue_service_proto_init() {
(*IssueComment_PlanUpdate_)(nil),
(*IssueComment_ReviewSubmission_)(nil),
}
- file_v1_issue_service_proto_msgTypes[24].OneofWrappers = []any{}
+ file_v1_issue_service_proto_msgTypes[26].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_issue_service_proto_rawDesc), len(file_v1_issue_service_proto_rawDesc)),
- NumEnums: 3,
- NumMessages: 27,
+ NumEnums: 5,
+ NumMessages: 29,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/backend/generated-go/v1/issue_service.pb.gw.go b/backend/generated-go/v1/issue_service.pb.gw.go
index a2dd1a302d..ba7321d850 100644
--- a/backend/generated-go/v1/issue_service.pb.gw.go
+++ b/backend/generated-go/v1/issue_service.pb.gw.go
@@ -716,6 +716,51 @@ func local_request_IssueService_RetryIssueApproval_0(ctx context.Context, marsha
return msg, metadata, err
}
+func request_IssueService_RunReview_0(ctx context.Context, marshaler runtime.Marshaler, client IssueServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq RunReviewRequest
+ metadata runtime.ServerMetadata
+ err error
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ val, ok := pathParams["name"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
+ }
+ protoReq.Name, err = runtime.String(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
+ }
+ if req.Body != nil {
+ _, _ = io.Copy(io.Discard, req.Body)
+ }
+ msg, err := client.RunReview(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+}
+
+func local_request_IssueService_RunReview_0(ctx context.Context, marshaler runtime.Marshaler, server IssueServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var (
+ protoReq RunReviewRequest
+ metadata runtime.ServerMetadata
+ err error
+ )
+ if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ val, ok := pathParams["name"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
+ }
+ protoReq.Name, err = runtime.String(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
+ }
+ msg, err := server.RunReview(ctx, &protoReq)
+ return msg, metadata, err
+}
+
// RegisterIssueServiceHandlerServer registers the http handlers for service IssueService to "mux".
// UnaryRPC :call IssueServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -982,6 +1027,26 @@ func RegisterIssueServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu
}
forward_IssueService_RetryIssueApproval_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_IssueService_RunReview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.IssueService/RunReview", runtime.WithHTTPPathPattern("/v1/{name=projects/*/issues/*/reviewRuns/*}:run"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_IssueService_RunReview_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_IssueService_RunReview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
return nil
}
@@ -1243,6 +1308,23 @@ func RegisterIssueServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
}
forward_IssueService_RetryIssueApproval_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
+ mux.Handle(http.MethodPost, pattern_IssueService_RunReview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.IssueService/RunReview", runtime.WithHTTPPathPattern("/v1/{name=projects/*/issues/*/reviewRuns/*}:run"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_IssueService_RunReview_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ forward_IssueService_RunReview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+ })
return nil
}
@@ -1260,6 +1342,7 @@ var (
pattern_IssueService_RejectIssue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3}, []string{"v1", "projects", "issues", "name"}, "reject"))
pattern_IssueService_RequestIssue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3}, []string{"v1", "projects", "issues", "name"}, "request"))
pattern_IssueService_RetryIssueApproval_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3}, []string{"v1", "projects", "issues", "name"}, "retryApproval"))
+ pattern_IssueService_RunReview_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 4, 6, 5, 4}, []string{"v1", "projects", "issues", "reviewRuns", "name"}, "run"))
)
var (
@@ -1276,4 +1359,5 @@ var (
forward_IssueService_RejectIssue_0 = runtime.ForwardResponseMessage
forward_IssueService_RequestIssue_0 = runtime.ForwardResponseMessage
forward_IssueService_RetryIssueApproval_0 = runtime.ForwardResponseMessage
+ forward_IssueService_RunReview_0 = runtime.ForwardResponseMessage
)
diff --git a/backend/generated-go/v1/issue_service_equal.pb.go b/backend/generated-go/v1/issue_service_equal.pb.go
index 036c2d862d..64e542c473 100644
--- a/backend/generated-go/v1/issue_service_equal.pb.go
+++ b/backend/generated-go/v1/issue_service_equal.pb.go
@@ -622,3 +622,44 @@ func (x *IssueComment) Equal(y *IssueComment) bool {
}
return true
}
+
+func (x *ReviewRun) Equal(y *ReviewRun) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Name != y.Name {
+ return false
+ }
+ if x.Type != y.Type {
+ return false
+ }
+ if x.Status != y.Status {
+ return false
+ }
+ if p, q := x.CreateTime, y.CreateTime; (p == nil && q != nil) || (p != nil && (q == nil || p.Seconds != q.Seconds || p.Nanos != q.Nanos)) {
+ return false
+ }
+ if p, q := x.EndTime, y.EndTime; (p == nil && q != nil) || (p != nil && (q == nil || p.Seconds != q.Seconds || p.Nanos != q.Nanos)) {
+ return false
+ }
+ if x.Error != y.Error {
+ return false
+ }
+ return true
+}
+
+func (x *RunReviewRequest) Equal(y *RunReviewRequest) bool {
+ if x == y {
+ return true
+ }
+ if x == nil || y == nil {
+ return x == nil && y == nil
+ }
+ if x.Name != y.Name {
+ return false
+ }
+ return true
+}
diff --git a/backend/generated-go/v1/issue_service_grpc.pb.go b/backend/generated-go/v1/issue_service_grpc.pb.go
index 55e8e84e46..3f6731d39c 100644
--- a/backend/generated-go/v1/issue_service_grpc.pb.go
+++ b/backend/generated-go/v1/issue_service_grpc.pb.go
@@ -32,6 +32,7 @@ const (
IssueService_RejectIssue_FullMethodName = "/bytebase.v1.IssueService/RejectIssue"
IssueService_RequestIssue_FullMethodName = "/bytebase.v1.IssueService/RequestIssue"
IssueService_RetryIssueApproval_FullMethodName = "/bytebase.v1.IssueService/RetryIssueApproval"
+ IssueService_RunReview_FullMethodName = "/bytebase.v1.IssueService/RunReview"
)
// IssueServiceClient is the client API for IssueService service.
@@ -86,6 +87,12 @@ type IssueServiceClient interface {
// Permissions required: None (caller must be the issue creator;
// mirrors RequestIssue's authorization model).
RetryIssueApproval(ctx context.Context, in *RetryIssueApprovalRequest, opts ...grpc.CallOption) (*Issue, error)
+ // Triggers a review run. The slot is reset unconditionally: a RUNNING
+ // execution is superseded (its completion is fenced off), the attempt
+ // number is bumped, and the returned run is AVAILABLE.
+ // The audit log is the only record of who triggered a run.
+ // Permissions required: bb.reviewRuns.run
+ RunReview(ctx context.Context, in *RunReviewRequest, opts ...grpc.CallOption) (*ReviewRun, error)
}
type issueServiceClient struct {
@@ -226,6 +233,16 @@ func (c *issueServiceClient) RetryIssueApproval(ctx context.Context, in *RetryIs
return out, nil
}
+func (c *issueServiceClient) RunReview(ctx context.Context, in *RunReviewRequest, opts ...grpc.CallOption) (*ReviewRun, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(ReviewRun)
+ err := c.cc.Invoke(ctx, IssueService_RunReview_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// IssueServiceServer is the server API for IssueService service.
// All implementations must embed UnimplementedIssueServiceServer
// for forward compatibility.
@@ -278,6 +295,12 @@ type IssueServiceServer interface {
// Permissions required: None (caller must be the issue creator;
// mirrors RequestIssue's authorization model).
RetryIssueApproval(context.Context, *RetryIssueApprovalRequest) (*Issue, error)
+ // Triggers a review run. The slot is reset unconditionally: a RUNNING
+ // execution is superseded (its completion is fenced off), the attempt
+ // number is bumped, and the returned run is AVAILABLE.
+ // The audit log is the only record of who triggered a run.
+ // Permissions required: bb.reviewRuns.run
+ RunReview(context.Context, *RunReviewRequest) (*ReviewRun, error)
mustEmbedUnimplementedIssueServiceServer()
}
@@ -327,6 +350,9 @@ func (UnimplementedIssueServiceServer) RequestIssue(context.Context, *RequestIss
func (UnimplementedIssueServiceServer) RetryIssueApproval(context.Context, *RetryIssueApprovalRequest) (*Issue, error) {
return nil, status.Error(codes.Unimplemented, "method RetryIssueApproval not implemented")
}
+func (UnimplementedIssueServiceServer) RunReview(context.Context, *RunReviewRequest) (*ReviewRun, error) {
+ return nil, status.Error(codes.Unimplemented, "method RunReview not implemented")
+}
func (UnimplementedIssueServiceServer) mustEmbedUnimplementedIssueServiceServer() {}
func (UnimplementedIssueServiceServer) testEmbeddedByValue() {}
@@ -582,6 +608,24 @@ func _IssueService_RetryIssueApproval_Handler(srv interface{}, ctx context.Conte
return interceptor(ctx, in, info, handler)
}
+func _IssueService_RunReview_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(RunReviewRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(IssueServiceServer).RunReview(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: IssueService_RunReview_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(IssueServiceServer).RunReview(ctx, req.(*RunReviewRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
// IssueService_ServiceDesc is the grpc.ServiceDesc for IssueService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -641,6 +685,10 @@ var IssueService_ServiceDesc = grpc.ServiceDesc{
MethodName: "RetryIssueApproval",
Handler: _IssueService_RetryIssueApproval_Handler,
},
+ {
+ MethodName: "RunReview",
+ Handler: _IssueService_RunReview_Handler,
+ },
},
Streams: []grpc.StreamDesc{},
Metadata: "v1/issue_service.proto",
diff --git a/backend/generated-go/v1/v1connect/issue_service.connect.go b/backend/generated-go/v1/v1connect/issue_service.connect.go
index d5636b1f06..fc9e075440 100644
--- a/backend/generated-go/v1/v1connect/issue_service.connect.go
+++ b/backend/generated-go/v1/v1connect/issue_service.connect.go
@@ -70,6 +70,8 @@ const (
// IssueServiceRetryIssueApprovalProcedure is the fully-qualified name of the IssueService's
// RetryIssueApproval RPC.
IssueServiceRetryIssueApprovalProcedure = "/bytebase.v1.IssueService/RetryIssueApproval"
+ // IssueServiceRunReviewProcedure is the fully-qualified name of the IssueService's RunReview RPC.
+ IssueServiceRunReviewProcedure = "/bytebase.v1.IssueService/RunReview"
)
// IssueServiceClient is a client for the bytebase.v1.IssueService service.
@@ -120,6 +122,12 @@ type IssueServiceClient interface {
// Permissions required: None (caller must be the issue creator;
// mirrors RequestIssue's authorization model).
RetryIssueApproval(context.Context, *connect.Request[v1.RetryIssueApprovalRequest]) (*connect.Response[v1.Issue], error)
+ // Triggers a review run. The slot is reset unconditionally: a RUNNING
+ // execution is superseded (its completion is fenced off), the attempt
+ // number is bumped, and the returned run is AVAILABLE.
+ // The audit log is the only record of who triggered a run.
+ // Permissions required: bb.reviewRuns.run
+ RunReview(context.Context, *connect.Request[v1.RunReviewRequest]) (*connect.Response[v1.ReviewRun], error)
}
// NewIssueServiceClient constructs a client for the bytebase.v1.IssueService service. By default,
@@ -211,6 +219,12 @@ func NewIssueServiceClient(httpClient connect.HTTPClient, baseURL string, opts .
connect.WithSchema(issueServiceMethods.ByName("RetryIssueApproval")),
connect.WithClientOptions(opts...),
),
+ runReview: connect.NewClient[v1.RunReviewRequest, v1.ReviewRun](
+ httpClient,
+ baseURL+IssueServiceRunReviewProcedure,
+ connect.WithSchema(issueServiceMethods.ByName("RunReview")),
+ connect.WithClientOptions(opts...),
+ ),
}
}
@@ -229,6 +243,7 @@ type issueServiceClient struct {
rejectIssue *connect.Client[v1.RejectIssueRequest, v1.Issue]
requestIssue *connect.Client[v1.RequestIssueRequest, v1.Issue]
retryIssueApproval *connect.Client[v1.RetryIssueApprovalRequest, v1.Issue]
+ runReview *connect.Client[v1.RunReviewRequest, v1.ReviewRun]
}
// GetIssue calls bytebase.v1.IssueService.GetIssue.
@@ -296,6 +311,11 @@ func (c *issueServiceClient) RetryIssueApproval(ctx context.Context, req *connec
return c.retryIssueApproval.CallUnary(ctx, req)
}
+// RunReview calls bytebase.v1.IssueService.RunReview.
+func (c *issueServiceClient) RunReview(ctx context.Context, req *connect.Request[v1.RunReviewRequest]) (*connect.Response[v1.ReviewRun], error) {
+ return c.runReview.CallUnary(ctx, req)
+}
+
// IssueServiceHandler is an implementation of the bytebase.v1.IssueService service.
type IssueServiceHandler interface {
// Retrieves an issue by name.
@@ -344,6 +364,12 @@ type IssueServiceHandler interface {
// Permissions required: None (caller must be the issue creator;
// mirrors RequestIssue's authorization model).
RetryIssueApproval(context.Context, *connect.Request[v1.RetryIssueApprovalRequest]) (*connect.Response[v1.Issue], error)
+ // Triggers a review run. The slot is reset unconditionally: a RUNNING
+ // execution is superseded (its completion is fenced off), the attempt
+ // number is bumped, and the returned run is AVAILABLE.
+ // The audit log is the only record of who triggered a run.
+ // Permissions required: bb.reviewRuns.run
+ RunReview(context.Context, *connect.Request[v1.RunReviewRequest]) (*connect.Response[v1.ReviewRun], error)
}
// NewIssueServiceHandler builds an HTTP handler from the service implementation. It returns the
@@ -431,6 +457,12 @@ func NewIssueServiceHandler(svc IssueServiceHandler, opts ...connect.HandlerOpti
connect.WithSchema(issueServiceMethods.ByName("RetryIssueApproval")),
connect.WithHandlerOptions(opts...),
)
+ issueServiceRunReviewHandler := connect.NewUnaryHandler(
+ IssueServiceRunReviewProcedure,
+ svc.RunReview,
+ connect.WithSchema(issueServiceMethods.ByName("RunReview")),
+ connect.WithHandlerOptions(opts...),
+ )
return "/bytebase.v1.IssueService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case IssueServiceGetIssueProcedure:
@@ -459,6 +491,8 @@ func NewIssueServiceHandler(svc IssueServiceHandler, opts ...connect.HandlerOpti
issueServiceRequestIssueHandler.ServeHTTP(w, r)
case IssueServiceRetryIssueApprovalProcedure:
issueServiceRetryIssueApprovalHandler.ServeHTTP(w, r)
+ case IssueServiceRunReviewProcedure:
+ issueServiceRunReviewHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
@@ -519,3 +553,7 @@ func (UnimplementedIssueServiceHandler) RequestIssue(context.Context, *connect.R
func (UnimplementedIssueServiceHandler) RetryIssueApproval(context.Context, *connect.Request[v1.RetryIssueApprovalRequest]) (*connect.Response[v1.Issue], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.IssueService.RetryIssueApproval is not implemented"))
}
+
+func (UnimplementedIssueServiceHandler) RunReview(context.Context, *connect.Request[v1.RunReviewRequest]) (*connect.Response[v1.ReviewRun], error) {
+ return nil, connect.NewError(connect.CodeUnimplemented, errors.New("bytebase.v1.IssueService.RunReview is not implemented"))
+}
diff --git a/backend/runner/cleaner/data_cleaner.go b/backend/runner/cleaner/data_cleaner.go
index c8c48105d6..fecb46bae3 100644
--- a/backend/runner/cleaner/data_cleaner.go
+++ b/backend/runner/cleaner/data_cleaner.go
@@ -57,6 +57,7 @@ func (c *DataCleaner) Run(ctx context.Context, wg *sync.WaitGroup) {
c.cleanup(ctx)
c.detectStaleTaskRuns(ctx)
c.detectStalePlanCheckRuns(ctx)
+ c.detectStaleReviewRuns(ctx)
for {
select {
@@ -73,6 +74,7 @@ func (c *DataCleaner) Run(ctx context.Context, wg *sync.WaitGroup) {
}
c.detectStaleTaskRuns(ctx)
c.detectStalePlanCheckRuns(ctx)
+ c.detectStaleReviewRuns(ctx)
case <-ctx.Done():
return
}
@@ -99,6 +101,17 @@ func (c *DataCleaner) detectStaleTaskRuns(ctx context.Context) {
}
}
+func (c *DataCleaner) detectStaleReviewRuns(ctx context.Context) {
+ rowsAffected, err := c.store.FailStaleReviewRuns(ctx, stalenessThreshold)
+ if err != nil {
+ slog.Error("Failed to detect stale review runs", log.BBError(err))
+ return
+ }
+ if rowsAffected > 0 {
+ slog.Info("Marked stale review runs as failed", slog.Int64("count", rowsAffected))
+ }
+}
+
func (c *DataCleaner) detectStalePlanCheckRuns(ctx context.Context) {
rowsAffected, err := c.store.FailStalePlanCheckRuns(ctx, planCheckRunTimeout)
if err != nil {
diff --git a/backend/runner/reviewrun/guideline_executor.go b/backend/runner/reviewrun/guideline_executor.go
new file mode 100644
index 0000000000..6d0dce88f0
--- /dev/null
+++ b/backend/runner/reviewrun/guideline_executor.go
@@ -0,0 +1,26 @@
+package reviewrun
+
+import (
+ "context"
+
+ "github.com/pkg/errors"
+)
+
+// GuidelineExecutor is the natural-language guideline reviewer, performed by
+// AI.
+//
+// Not implemented yet: the guideline evaluation lands with the AI review
+// design. A claimed GUIDELINE run must still reach a terminal status, so it
+// fails honestly instead of reporting a vacuous DONE — DONE would carry the
+// "every unit was evaluated" meaning the gate later relies on.
+type GuidelineExecutor struct{}
+
+// NewGuidelineExecutor creates the guideline review executor.
+func NewGuidelineExecutor() *GuidelineExecutor {
+ return &GuidelineExecutor{}
+}
+
+// RunOnce implements Executor.
+func (*GuidelineExecutor) RunOnce(_ context.Context, _ string, _ int64) error {
+ return errors.New("guideline review is not implemented yet")
+}
diff --git a/backend/runner/reviewrun/rule_executor.go b/backend/runner/reviewrun/rule_executor.go
new file mode 100644
index 0000000000..0686dc4e58
--- /dev/null
+++ b/backend/runner/reviewrun/rule_executor.go
@@ -0,0 +1,110 @@
+package reviewrun
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ "github.com/pkg/errors"
+
+ "github.com/bytebase/bytebase/backend/component/dbfactory"
+ "github.com/bytebase/bytebase/backend/component/sheet"
+ "github.com/bytebase/bytebase/backend/runner/plancheck"
+ "github.com/bytebase/bytebase/backend/store"
+)
+
+// RuleExecutor evaluates the standard rules against every (spec, target)
+// unit of the issue's plan.
+//
+// Findings are not persisted yet: review results become issue comments, and
+// the comment integration lands with the comment-thread design. The executor
+// still evaluates every unit for real so the run lifecycle, fencing, and
+// failure aggregation exercise the true path; computed advices are
+// discarded.
+type RuleExecutor struct {
+ store *store.Store
+ sheetManager *sheet.Manager
+ dbFactory *dbfactory.DBFactory
+}
+
+// NewRuleExecutor creates the standard-rule review executor.
+func NewRuleExecutor(s *store.Store, sheetManager *sheet.Manager, dbFactory *dbfactory.DBFactory) *RuleExecutor {
+ return &RuleExecutor{
+ store: s,
+ sheetManager: sheetManager,
+ dbFactory: dbFactory,
+ }
+}
+
+// RunOnce implements Executor.
+func (e *RuleExecutor) RunOnce(ctx context.Context, projectID string, issueUID int64) error {
+ issue, err := e.store.GetIssue(ctx, &store.FindIssueMessage{ProjectIDs: []string{projectID}, UID: &issueUID})
+ if err != nil {
+ return errors.Wrapf(err, "failed to get issue")
+ }
+ if issue == nil {
+ return errors.Errorf("issue %d not found in project %s", issueUID, projectID)
+ }
+ if issue.PlanUID == nil {
+ return errors.Errorf("issue %d has no plan", issueUID)
+ }
+ plan, err := e.store.GetPlan(ctx, &store.FindPlanMessage{ProjectID: projectID, UID: issue.PlanUID})
+ if err != nil {
+ return errors.Wrapf(err, "failed to get plan")
+ }
+ if plan == nil {
+ return errors.Errorf("plan %d not found in project %s", *issue.PlanUID, projectID)
+ }
+ project, err := e.store.GetProjectByResourceID(ctx, projectID)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get project")
+ }
+ if project == nil {
+ return errors.Errorf("project %s not found", projectID)
+ }
+
+ databaseGroup, err := plancheck.GetDatabaseGroupForPlan(ctx, e.store, plan, nil)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get database group for plan")
+ }
+ targets, err := plancheck.DeriveCheckTargets(ctx, e.store, project, plan, databaseGroup)
+ if err != nil {
+ return errors.Wrapf(err, "failed to derive review targets")
+ }
+
+ adviseExecutor := plancheck.NewStatementAdviseExecutor(e.store, e.sheetManager, e.dbFactory)
+ var unitErrs []error
+ for _, target := range targets {
+ if err := ctx.Err(); err != nil {
+ return err
+ }
+ // Collect-all, no fail-fast: every unit is attempted, and failures
+ // aggregate into one message.
+ if _, err := adviseExecutor.RunForTarget(ctx, target); err != nil {
+ unitErrs = append(unitErrs, errors.Wrapf(err, "%s", target.Target))
+ }
+ }
+ return aggregateUnitErrors(len(targets), unitErrs)
+}
+
+// aggregateUnitErrors folds per-unit failures into one message, e.g.
+// "2 of 5 review units failed: instances/prod/databases/db1: ...;
+// instances/prod/databases/db2: ... (+1 more)".
+func aggregateUnitErrors(total int, unitErrs []error) error {
+ if len(unitErrs) == 0 {
+ return nil
+ }
+ const maxDetailed = 3
+ details := make([]string, 0, maxDetailed)
+ for i, err := range unitErrs {
+ if i >= maxDetailed {
+ break
+ }
+ details = append(details, err.Error())
+ }
+ suffix := ""
+ if len(unitErrs) > maxDetailed {
+ suffix = fmt.Sprintf(" (+%d more)", len(unitErrs)-maxDetailed)
+ }
+ return errors.Errorf("%d of %d review units failed: %s%s", len(unitErrs), total, strings.Join(details, "; "), suffix)
+}
diff --git a/backend/runner/reviewrun/scheduler.go b/backend/runner/reviewrun/scheduler.go
new file mode 100644
index 0000000000..990468d792
--- /dev/null
+++ b/backend/runner/reviewrun/scheduler.go
@@ -0,0 +1,209 @@
+// Package reviewrun is the runner executing SQL review runs.
+//
+// The execution model follows the task run runner: claim every AVAILABLE
+// slot for this replica, dispatch serially, execute each run in its own
+// goroutine, and guarantee a terminal write on every path. There is no
+// cancel — re-running supersedes a RUNNING execution, whose fenced
+// completion then matches zero rows — and no execution timeout: a run on a
+// dead replica is failed by the heartbeat reaper, and a hung run on a live
+// replica is superseded by the next re-run.
+package reviewrun
+
+import (
+ "context"
+ "fmt"
+ "log/slog"
+ "sync"
+ "time"
+
+ "github.com/pkg/errors"
+
+ "github.com/bytebase/bytebase/backend/common/log"
+ "github.com/bytebase/bytebase/backend/component/bus"
+ "github.com/bytebase/bytebase/backend/component/config"
+ "github.com/bytebase/bytebase/backend/component/productmetrics"
+ "github.com/bytebase/bytebase/backend/enterprise"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ "github.com/bytebase/bytebase/backend/store"
+)
+
+const reviewRunSchedulerInterval = 5 * time.Second
+
+// Executor executes one review run for one reviewer type.
+type Executor interface {
+ // RunOnce evaluates every (spec, target) unit of the issue's plan
+ // (collect-all, no fail-fast). A nil error marks the run DONE; a non-nil
+ // error marks it FAILED with the aggregated message. Findings will
+ // surface as issue comments once the comment integration lands; until
+ // then executors only report status.
+ RunOnce(ctx context.Context, projectID string, issueUID int64) error
+}
+
+// NewScheduler creates a new review run scheduler.
+func NewScheduler(s *store.Store, b *bus.Bus, profile *config.Profile, licenseService *enterprise.LicenseService, productMetrics *productmetrics.ProductMetrics) *Scheduler {
+ return &Scheduler{
+ store: s,
+ bus: b,
+ profile: profile,
+ licenseService: licenseService,
+ productMetrics: productMetrics,
+ executorMap: make(map[string]Executor),
+ }
+}
+
+// Scheduler is the review run scheduler.
+type Scheduler struct {
+ store *store.Store
+ bus *bus.Bus
+ profile *config.Profile
+ licenseService *enterprise.LicenseService
+ productMetrics *productmetrics.ProductMetrics
+ executorMap map[string]Executor
+}
+
+// Register registers an executor for a reviewer type. Call before Run.
+func (s *Scheduler) Register(reviewType string, executor Executor) {
+ if executor == nil {
+ panic(fmt.Sprintf("registered nil executor for reviewer type %q", reviewType))
+ }
+ s.executorMap[reviewType] = executor
+}
+
+// Run runs the scheduler.
+func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
+ ticker := time.NewTicker(reviewRunSchedulerInterval)
+ defer ticker.Stop()
+ defer wg.Done()
+ slog.Debug(fmt.Sprintf("Review run scheduler started and will run every %v", reviewRunSchedulerInterval))
+ for {
+ select {
+ case <-ticker.C:
+ if err := s.licenseService.CheckReplicaLimit(ctx); err != nil {
+ slog.Warn("Review run scheduler skipped due to HA license restriction", log.BBError(err))
+ continue
+ }
+ if err := s.scheduleReviewRuns(ctx); err != nil {
+ slog.Error("failed to schedule review runs", log.BBError(err))
+ }
+ case <-s.bus.ReviewRunTickleChan:
+ if err := s.licenseService.CheckReplicaLimit(ctx); err != nil {
+ slog.Warn("Review run scheduler skipped due to HA license restriction", log.BBError(err))
+ continue
+ }
+ if err := s.scheduleReviewRuns(ctx); err != nil {
+ slog.Error("failed to schedule review runs", log.BBError(err))
+ }
+ case <-ctx.Done():
+ return
+ }
+ }
+}
+
+func (s *Scheduler) scheduleReviewRuns(ctx context.Context) (retErr error) {
+ startedAt := time.Now()
+ result := productmetrics.ResultFailure
+ defer func() {
+ if r := recover(); r != nil {
+ panicErr, ok := r.(error)
+ if !ok {
+ panicErr = errors.Errorf("%v", r)
+ }
+ retErr = errors.Wrap(panicErr, "review run scheduler panic")
+ slog.Error("Review run scheduler PANIC RECOVER", log.BBError(retErr), log.BBStack("panic-stack"))
+ }
+ if !errors.Is(ctx.Err(), context.Canceled) && s.productMetrics != nil {
+ s.productMetrics.RecordRunnerRun(productmetrics.RunnerReviewRun, result, time.Since(startedAt))
+ }
+ }()
+
+ claimed, err := s.store.ClaimAvailableReviewRuns(ctx, s.profile.ReplicaID)
+ if err != nil {
+ return errors.Wrapf(err, "failed to claim available review runs")
+ }
+ for _, c := range claimed {
+ s.dispatchReviewRun(ctx, c)
+ }
+ result = productmetrics.ResultSuccess
+ return nil
+}
+
+// dispatchReviewRun starts one claimed run's execution. A reviewer type with
+// no registered executor fails immediately: the type space is open, and a
+// claimed run must always reach a terminal status.
+func (s *Scheduler) dispatchReviewRun(ctx context.Context, claimed *store.ClaimedReviewRun) {
+ executor, ok := s.executorMap[claimed.Type]
+ if !ok {
+ s.completeReviewRun(ctx, claimed, errors.Errorf("no executor registered for reviewer type %q", claimed.Type))
+ return
+ }
+ go s.runReviewRunOnce(ctx, claimed, executor)
+}
+
+func (s *Scheduler) runReviewRunOnce(ctx context.Context, claimed *store.ClaimedReviewRun, executor Executor) {
+ defer func() {
+ if r := recover(); r != nil {
+ err, ok := r.(error)
+ if !ok {
+ err = errors.Errorf("%v", r)
+ }
+ slog.Error("runReviewRunOnce PANIC RECOVER", log.BBError(err), log.BBStack("panic-stack"))
+ }
+ }()
+
+ err := runExecutorOnce(ctx, executor, claimed)
+ if err != nil && errors.Is(err, context.Canceled) {
+ // Shutdown: the completion write would fail on the same canceled
+ // context. The replica's heartbeat stops with the process, so the
+ // reaper fails this run.
+ slog.Info("review run interrupted by shutdown; leaving it to the reaper",
+ slog.String("project", claimed.ProjectID),
+ slog.Int64("issue_id", claimed.IssueUID),
+ slog.String("type", claimed.Type))
+ return
+ }
+ s.completeReviewRun(ctx, claimed, err)
+}
+
+// completeReviewRun writes the terminal status: DONE on a nil error, FAILED
+// with the aggregated message otherwise. Zero rows means the run was
+// superseded or reaped since the claim; the result is discarded.
+func (s *Scheduler) completeReviewRun(ctx context.Context, claimed *store.ClaimedReviewRun, execErr error) {
+ status := storepb.ReviewRun_DONE
+ payload := &storepb.ReviewRunPayload{}
+ if execErr != nil {
+ status = storepb.ReviewRun_FAILED
+ payload.Error = execErr.Error()
+ }
+ updated, err := s.store.CompleteReviewRun(ctx, claimed, s.profile.ReplicaID, status, payload)
+ if err != nil {
+ slog.Error("failed to complete review run",
+ slog.String("project", claimed.ProjectID),
+ slog.Int64("issue_id", claimed.IssueUID),
+ slog.String("type", claimed.Type),
+ log.BBError(err))
+ return
+ }
+ if !updated {
+ slog.Info("skip completing superseded review run",
+ slog.String("project", claimed.ProjectID),
+ slog.Int64("issue_id", claimed.IssueUID),
+ slog.String("type", claimed.Type),
+ slog.Int64("attempt", claimed.Attempt))
+ }
+}
+
+// runExecutorOnce wraps Executor.RunOnce with panic recovery so a panicking
+// executor fails its run instead of crashing the process.
+func runExecutorOnce(ctx context.Context, executor Executor, claimed *store.ClaimedReviewRun) (err error) {
+ defer func() {
+ if r := recover(); r != nil {
+ panicErr, ok := r.(error)
+ if !ok {
+ panicErr = errors.Errorf("%v", r)
+ }
+ slog.Error("Review run executor PANIC RECOVER", log.BBError(panicErr), log.BBStack("panic-stack"))
+ err = errors.Errorf("review run executor panic: %v", panicErr)
+ }
+ }()
+ return executor.RunOnce(ctx, claimed.ProjectID, claimed.IssueUID)
+}
diff --git a/backend/server/server.go b/backend/server/server.go
index e89abecea0..0286f6637f 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -43,6 +43,7 @@ import (
"github.com/bytebase/bytebase/backend/runner/monitor"
"github.com/bytebase/bytebase/backend/runner/notifylistener"
"github.com/bytebase/bytebase/backend/runner/plancheck"
+ "github.com/bytebase/bytebase/backend/runner/reviewrun"
samplerunner "github.com/bytebase/bytebase/backend/runner/sample"
"github.com/bytebase/bytebase/backend/runner/schemasync"
"github.com/bytebase/bytebase/backend/runner/taskrun"
@@ -63,6 +64,7 @@ type Server struct {
// Asynchronous runners.
taskScheduler *taskrun.Scheduler
planCheckScheduler *plancheck.Scheduler
+ reviewRunScheduler *reviewrun.Scheduler
schemaSyncer *schemasync.Syncer
approvalRunner *review.Runner
notifyListener *notifylistener.Listener
@@ -241,6 +243,10 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
combinedExecutor := plancheck.NewCombinedExecutor(stores, sheetManager, s.dbFactory)
s.planCheckScheduler = plancheck.NewScheduler(stores, s.bus, combinedExecutor, s.licenseService, productMetrics)
+
+ s.reviewRunScheduler = reviewrun.NewScheduler(stores, s.bus, profile, s.licenseService, productMetrics)
+ s.reviewRunScheduler.Register(store.ReviewRunTypeRule, reviewrun.NewRuleExecutor(stores, sheetManager, s.dbFactory))
+ s.reviewRunScheduler.Register(store.ReviewRunTypeGuideline, reviewrun.NewGuidelineExecutor())
s.notifyListener = notifylistener.NewListener(stores.GetDB(), s.bus)
// Data cleaner
@@ -312,6 +318,9 @@ func (s *Server) Run(ctx context.Context, port int) error {
s.runnerWG.Add(1)
go s.planCheckScheduler.Run(ctx, &s.runnerWG)
+ s.runnerWG.Add(1)
+ go s.reviewRunScheduler.Run(ctx, &s.runnerWG)
+
s.runnerWG.Add(1)
go s.dataCleaner.Run(ctx, &s.runnerWG)
diff --git a/backend/store/predefined_roles.go b/backend/store/predefined_roles.go
index 361919a80b..dc68637506 100644
--- a/backend/store/predefined_roles.go
+++ b/backend/store/predefined_roles.go
@@ -114,6 +114,7 @@ var PredefinedRoles = []*RoleMessage{
permission.ReviewConfigsGet,
permission.ReviewConfigsList,
permission.ReviewConfigsUpdate,
+ permission.ReviewRunsRun,
permission.RevisionsCreate,
permission.RevisionsDelete,
permission.RevisionsGet,
@@ -265,6 +266,7 @@ var PredefinedRoles = []*RoleMessage{
permission.ReviewConfigsGet,
permission.ReviewConfigsList,
permission.ReviewConfigsUpdate,
+ permission.ReviewRunsRun,
permission.RevisionsCreate,
permission.RevisionsDelete,
permission.RevisionsGet,
@@ -412,6 +414,7 @@ var PredefinedRoles = []*RoleMessage{
permission.ReleasesList,
permission.ReleasesUndelete,
permission.ReleasesUpdate,
+ permission.ReviewRunsRun,
permission.RevisionsCreate,
permission.RevisionsDelete,
permission.RevisionsGet,
@@ -485,6 +488,7 @@ var PredefinedRoles = []*RoleMessage{
permission.ReleasesCheck,
permission.ReleasesGet,
permission.ReleasesList,
+ permission.ReviewRunsRun,
permission.RevisionsGet,
permission.RevisionsList,
permission.RolloutsGet,
@@ -568,6 +572,7 @@ var PredefinedRoles = []*RoleMessage{
permission.ProjectsGetIAMPolicy,
permission.ReleasesGet,
permission.ReleasesList,
+ permission.ReviewRunsRun,
permission.RevisionsGet,
permission.RevisionsList,
permission.RolloutsCreate,
diff --git a/backend/store/review_run.go b/backend/store/review_run.go
new file mode 100644
index 0000000000..313039086d
--- /dev/null
+++ b/backend/store/review_run.go
@@ -0,0 +1,236 @@
+package store
+
+import (
+ "context"
+ "database/sql"
+ "time"
+
+ "github.com/pkg/errors"
+ "google.golang.org/protobuf/encoding/protojson"
+
+ "github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/common/qb"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+)
+
+// Reviewer type values stored in review_run.type. The column has no CHECK on
+// purpose: the reviewer-id space is open.
+const (
+ // ReviewRunTypeRule reviews against the standard rules.
+ ReviewRunTypeRule = "RULE"
+ // ReviewRunTypeGuideline reviews against natural-language guidelines,
+ // performed by AI.
+ ReviewRunTypeGuideline = "GUIDELINE"
+)
+
+// ReviewRunMessage is one review_run slot row: the current run of one
+// reviewer on one issue, reset in place on re-run.
+type ReviewRunMessage struct {
+ ProjectID string
+ IssueUID int64
+ Type string
+ Attempt int64
+ Status storepb.ReviewRun_Status
+ Payload *storepb.ReviewRunPayload
+ CreatedAt time.Time
+ UpdatedAt time.Time
+}
+
+// CreateReviewRun creates a new AVAILABLE run in the (issue, reviewer type)
+// slot. The slot row is reset in place unconditionally: created at attempt 0
+// when absent, attempt bumped otherwise, with created_at restarted and
+// replica_id and payload cleared. A RUNNING execution is superseded — its
+// completion transaction is fenced on the old attempt and will match zero
+// rows.
+//
+// Lifecycle policy: the slot requires an active project. The transaction
+// takes the project purge fence and then the project row lock (the sheet
+// creation shape), so it serializes against project purge; the INSERT reads
+// the issue row itself, so a missing issue returns NotFound instead of a
+// foreign-key error.
+func (s *Store) CreateReviewRun(ctx context.Context, projectID string, issueUID int64, reviewType string) (*ReviewRunMessage, error) {
+ tx, err := s.GetDB().BeginTx(ctx, nil)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to begin tx")
+ }
+ defer tx.Rollback()
+
+ if err := acquireProjectPurgeLock(ctx, tx, projectID); err != nil {
+ return nil, err
+ }
+ if err := lockActiveProject(ctx, tx, projectID); err != nil {
+ return nil, err
+ }
+
+ q := qb.Q().Space(`
+ INSERT INTO review_run (project, issue_id, type, status)
+ SELECT issue.project, issue.id, ?, ?
+ FROM issue
+ WHERE issue.project = ? AND issue.id = ?
+ ON CONFLICT (project, issue_id, type) DO UPDATE
+ SET status = EXCLUDED.status,
+ attempt = review_run.attempt + 1,
+ created_at = now(),
+ updated_at = now(),
+ replica_id = NULL,
+ payload = '{}'
+ RETURNING attempt, created_at, updated_at
+ `, reviewType, storepb.ReviewRun_AVAILABLE.String(), projectID, issueUID)
+
+ query, args, err := q.ToSQL()
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to build sql")
+ }
+
+ reviewRun := &ReviewRunMessage{
+ ProjectID: projectID,
+ IssueUID: issueUID,
+ Type: reviewType,
+ Status: storepb.ReviewRun_AVAILABLE,
+ Payload: &storepb.ReviewRunPayload{},
+ }
+ if err := tx.QueryRowContext(ctx, query, args...).Scan(&reviewRun.Attempt, &reviewRun.CreatedAt, &reviewRun.UpdatedAt); err != nil {
+ if errors.Is(err, sql.ErrNoRows) {
+ return nil, common.Errorf(common.NotFound, "issue %d not found in project %s", issueUID, projectID)
+ }
+ return nil, errors.Wrapf(err, "failed to create review run")
+ }
+
+ if err := tx.Commit(); err != nil {
+ return nil, errors.Wrapf(err, "failed to commit tx")
+ }
+ return reviewRun, nil
+}
+
+// ClaimedReviewRun identifies a claimed review run slot and carries the claim
+// fence (attempt).
+type ClaimedReviewRun struct {
+ ProjectID string
+ IssueUID int64
+ Type string
+ Attempt int64
+}
+
+// ClaimAvailableReviewRuns atomically claims every AVAILABLE review run for
+// this replica by moving it to RUNNING (the ClaimAvailableTaskRuns shape).
+// FOR UPDATE SKIP LOCKED lets concurrent replicas claim disjoint rows.
+func (s *Store) ClaimAvailableReviewRuns(ctx context.Context, replicaID string) ([]*ClaimedReviewRun, error) {
+ q := qb.Q().Space(`
+ UPDATE review_run
+ SET status = ?, updated_at = now(), replica_id = ?
+ WHERE (project, issue_id, type) IN (
+ SELECT review_run.project, review_run.issue_id, review_run.type
+ FROM review_run
+ JOIN project ON project.resource_id = review_run.project
+ WHERE review_run.status = ?
+ AND project.deleted = FALSE
+ FOR UPDATE OF review_run SKIP LOCKED
+ )
+ RETURNING project, issue_id, type, attempt
+ `, storepb.ReviewRun_RUNNING.String(), replicaID, storepb.ReviewRun_AVAILABLE.String())
+
+ query, args, err := q.ToSQL()
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to build sql")
+ }
+
+ rows, err := s.GetDB().QueryContext(ctx, query, args...)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to claim review runs")
+ }
+ defer rows.Close()
+
+ var claimed []*ClaimedReviewRun
+ for rows.Next() {
+ var c ClaimedReviewRun
+ if err := rows.Scan(&c.ProjectID, &c.IssueUID, &c.Type, &c.Attempt); err != nil {
+ return nil, errors.Wrapf(err, "failed to scan claimed review run")
+ }
+ claimed = append(claimed, &c)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, errors.Wrapf(err, "failed to iterate claimed review runs")
+ }
+ return claimed, nil
+}
+
+// CompleteReviewRun moves a RUNNING run this replica owns to a terminal
+// status, fenced on the claim's attempt. False means superseded: the slot was
+// reset or reaped since the claim, and the caller must discard its work.
+func (s *Store) CompleteReviewRun(ctx context.Context, claimed *ClaimedReviewRun, replicaID string, status storepb.ReviewRun_Status, payload *storepb.ReviewRunPayload) (bool, error) {
+ if status != storepb.ReviewRun_DONE && status != storepb.ReviewRun_FAILED {
+ return false, errors.Errorf("invalid terminal review run status %v", status)
+ }
+ if payload == nil {
+ payload = &storepb.ReviewRunPayload{}
+ }
+ payloadBytes, err := protojson.Marshal(payload)
+ if err != nil {
+ return false, errors.Wrapf(err, "failed to marshal review run payload")
+ }
+
+ q := qb.Q().Space(`
+ UPDATE review_run
+ SET status = ?, updated_at = now(), payload = ?
+ WHERE project = ? AND issue_id = ? AND type = ?
+ AND status = ? AND replica_id = ? AND attempt = ?
+ `, status.String(), payloadBytes,
+ claimed.ProjectID, claimed.IssueUID, claimed.Type,
+ storepb.ReviewRun_RUNNING.String(), replicaID, claimed.Attempt)
+
+ query, args, err := q.ToSQL()
+ if err != nil {
+ return false, errors.Wrapf(err, "failed to build sql")
+ }
+
+ result, err := s.GetDB().ExecContext(ctx, query, args...)
+ if err != nil {
+ return false, errors.Wrapf(err, "failed to complete review run")
+ }
+ rowsAffected, err := result.RowsAffected()
+ if err != nil {
+ return false, errors.Wrapf(err, "failed to get rows affected")
+ }
+ return rowsAffected > 0, nil
+}
+
+// FailStaleReviewRuns fails RUNNING review runs whose owning replica has no
+// recent heartbeat — the replica crashed, or its heartbeat row was cleaned
+// up. NOT EXISTS covers both a missing and an expired heartbeat row (the
+// FailStaleTaskRuns shape).
+func (s *Store) FailStaleReviewRuns(ctx context.Context, stalenessThreshold time.Duration) (int64, error) {
+ payloadBytes, err := protojson.Marshal(&storepb.ReviewRunPayload{
+ Error: "Review run abandoned: owning replica stopped responding",
+ })
+ if err != nil {
+ return 0, errors.Wrapf(err, "failed to marshal review run payload")
+ }
+
+ q := qb.Q().Space(`
+ UPDATE review_run
+ SET status = ?, updated_at = now(), payload = ?
+ WHERE status = ?
+ AND replica_id IS NOT NULL
+ AND NOT EXISTS (
+ SELECT 1 FROM replica_heartbeat rh
+ WHERE rh.replica_id = review_run.replica_id
+ AND rh.last_heartbeat >= now() - ?::INTERVAL
+ )
+ `, storepb.ReviewRun_FAILED.String(), payloadBytes,
+ storepb.ReviewRun_RUNNING.String(), stalenessThreshold.String())
+
+ query, args, err := q.ToSQL()
+ if err != nil {
+ return 0, errors.Wrapf(err, "failed to build sql")
+ }
+
+ result, err := s.GetDB().ExecContext(ctx, query, args...)
+ if err != nil {
+ return 0, errors.Wrapf(err, "failed to fail stale review runs")
+ }
+ rowsAffected, err := result.RowsAffected()
+ if err != nil {
+ return 0, errors.Wrapf(err, "failed to get rows affected")
+ }
+ return rowsAffected, nil
+}
diff --git a/backend/store/review_run_lock_order_test.go b/backend/store/review_run_lock_order_test.go
new file mode 100644
index 0000000000..9dec41ad3f
--- /dev/null
+++ b/backend/store/review_run_lock_order_test.go
@@ -0,0 +1,46 @@
+package store_test
+
+import (
+ "context"
+ "strings"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/store"
+)
+
+func createReviewRunInProjectA(ctx context.Context, s *store.Store) error {
+ _, err := s.CreateReviewRun(ctx, "project-a", 101, store.ReviewRunTypeRule)
+ return err
+}
+
+const reviewRunLockOrderSeedSQL = `
+ INSERT INTO issue (id, creator, project, name, status, type)
+ VALUES (101, '[email protected]', 'project-a', 'Issue A', 'OPEN', 'DATABASE_CHANGE');
+ INSERT INTO review_run (project, issue_id, type, status)
+ VALUES ('project-a', 101, 'RULE', 'DONE');
+`
+
+// Purge first: project deletion wedges inside its review_run delete while
+// CreateReviewRun queues behind the project purge fence. The create must end in
+// a clean NotFound once the purge wins — no deadlock, no FK failure — and the
+// purge itself must succeed against the seeded slot row.
+func TestCreateReviewRunDoesNotDeadlockWithProjectDeletion(t *testing.T) {
+ err := runWithConcurrentProjectDeletion(t, reviewRunLockOrderSeedSQL, "review_run", 9906, createReviewRunInProjectA)
+ require.Equal(t, common.NotFound, common.ErrorCode(err))
+ require.NotContains(t, strings.ToLower(err.Error()), "foreign key",
+ "the create must reject the purged project cleanly, not with an FK failure")
+}
+
+// Writer first: CreateReviewRun holds the purge fence and waits on the project
+// row; project deletion queues behind the fence. The create must reject the
+// soft-deleted project with NotFound, and the purge must then complete.
+func TestCreateReviewRunRejectsDeletedProjectDuringProjectDeletion(t *testing.T) {
+ operationErr, deleteErr := runWithCreationBeforeProjectDeletion(t, reviewRunLockOrderSeedSQL, "review_run", createReviewRunInProjectA)
+ require.NoError(t, deleteErr)
+ require.Equal(t, common.NotFound, common.ErrorCode(operationErr))
+ require.NotContains(t, strings.ToLower(operationErr.Error()), "foreign key",
+ "the create must reject the deleted project cleanly, not with an FK failure")
+}
diff --git a/backend/store/review_run_test.go b/backend/store/review_run_test.go
new file mode 100644
index 0000000000..ab62ba898e
--- /dev/null
+++ b/backend/store/review_run_test.go
@@ -0,0 +1,118 @@
+package store_test
+
+import (
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/bytebase/bytebase/backend/common"
+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"
+ "github.com/bytebase/bytebase/backend/store"
+)
+
+// TestReviewRunStoreLifecycle walks the slot through reset, claim, supersede,
+// fenced completion, and heartbeat reaping against a real PostgreSQL.
+func TestReviewRunStoreLifecycle(t *testing.T) {
+ fixture := newProjectDeletionLockOrderFixture(t, `
+ INSERT INTO issue (id, creator, project, name, status, type)
+ VALUES (201, '[email protected]', 'default', 'Issue Default', 'OPEN', 'DATABASE_CHANGE');
+ `)
+ ctx, db, s := fixture.ctx, fixture.db, fixture.store
+
+ // The first create initializes the slot at attempt 0, AVAILABLE.
+ run, err := s.CreateReviewRun(ctx, "default", 201, store.ReviewRunTypeRule)
+ require.NoError(t, err)
+ require.Equal(t, int64(0), run.Attempt)
+ require.Equal(t, storepb.ReviewRun_AVAILABLE, run.Status)
+
+ // A missing issue is a clean NotFound, not an FK failure.
+ _, err = s.CreateReviewRun(ctx, "default", 999, store.ReviewRunTypeRule)
+ require.Equal(t, common.NotFound, common.ErrorCode(err))
+
+ // Claim moves the slot to RUNNING for this replica and returns the fence.
+ claimed, err := s.ClaimAvailableReviewRuns(ctx, "replica-1")
+ require.NoError(t, err)
+ require.Len(t, claimed, 1)
+ require.Equal(t, "default", claimed[0].ProjectID)
+ require.Equal(t, int64(201), claimed[0].IssueUID)
+ require.Equal(t, store.ReviewRunTypeRule, claimed[0].Type)
+ require.Equal(t, int64(0), claimed[0].Attempt)
+
+ // Nothing is left to claim.
+ again, err := s.ClaimAvailableReviewRuns(ctx, "replica-1")
+ require.NoError(t, err)
+ require.Empty(t, again)
+
+ // Creating a new run supersedes the RUNNING execution: the attempt bumps
+ // and the slot returns to AVAILABLE.
+ run, err = s.CreateReviewRun(ctx, "default", 201, store.ReviewRunTypeRule)
+ require.NoError(t, err)
+ require.Equal(t, int64(1), run.Attempt)
+ require.Equal(t, storepb.ReviewRun_AVAILABLE, run.Status)
+
+ // The superseded execution's completion is fenced off.
+ updated, err := s.CompleteReviewRun(ctx, claimed[0], "replica-1", storepb.ReviewRun_DONE, nil)
+ require.NoError(t, err)
+ require.False(t, updated, "a superseded completion must match zero rows")
+
+ // Only terminal statuses complete a run.
+ _, err = s.CompleteReviewRun(ctx, claimed[0], "replica-1", storepb.ReviewRun_AVAILABLE, nil)
+ require.Error(t, err)
+
+ // Claim the new attempt and complete it for real.
+ claimed, err = s.ClaimAvailableReviewRuns(ctx, "replica-1")
+ require.NoError(t, err)
+ require.Len(t, claimed, 1)
+ require.Equal(t, int64(1), claimed[0].Attempt)
+ updated, err = s.CompleteReviewRun(ctx, claimed[0], "replica-1", storepb.ReviewRun_FAILED, &storepb.ReviewRunPayload{Error: "boom"})
+ require.NoError(t, err)
+ require.True(t, updated)
+
+ var status, payloadError string
+ require.NoError(t, db.QueryRowContext(ctx, `
+ SELECT status, payload->>'error' FROM review_run
+ WHERE project = 'default' AND issue_id = 201 AND type = 'RULE'
+ `).Scan(&status, &payloadError))
+ require.Equal(t, "FAILED", status)
+ require.Equal(t, "boom", payloadError)
+
+ // A terminal row never completes again.
+ updated, err = s.CompleteReviewRun(ctx, claimed[0], "replica-1", storepb.ReviewRun_DONE, nil)
+ require.NoError(t, err)
+ require.False(t, updated)
+
+ // The reaper fails a RUNNING run whose replica has no recent heartbeat
+ // and writes the abandonment error; the reset clears it again.
+ run, err = s.CreateReviewRun(ctx, "default", 201, store.ReviewRunTypeRule)
+ require.NoError(t, err)
+ require.Equal(t, int64(2), run.Attempt)
+ claimed, err = s.ClaimAvailableReviewRuns(ctx, "dead-replica")
+ require.NoError(t, err)
+ require.Len(t, claimed, 1)
+ rowsAffected, err := s.FailStaleReviewRuns(ctx, time.Minute)
+ require.NoError(t, err)
+ require.Equal(t, int64(1), rowsAffected)
+ require.NoError(t, db.QueryRowContext(ctx, `
+ SELECT status, payload->>'error' FROM review_run
+ WHERE project = 'default' AND issue_id = 201 AND type = 'RULE'
+ `).Scan(&status, &payloadError))
+ require.Equal(t, "FAILED", status)
+ require.Contains(t, payloadError, "abandoned")
+
+ // A run whose replica beats survives the reaper.
+ run, err = s.CreateReviewRun(ctx, "default", 201, store.ReviewRunTypeRule)
+ require.NoError(t, err)
+ require.Equal(t, int64(3), run.Attempt)
+ claimed, err = s.ClaimAvailableReviewRuns(ctx, "live-replica")
+ require.NoError(t, err)
+ require.Len(t, claimed, 1)
+ _, err = db.ExecContext(ctx, `
+ INSERT INTO replica_heartbeat (replica_id, last_heartbeat) VALUES ('live-replica', now())
+ ON CONFLICT (replica_id) DO UPDATE SET last_heartbeat = now()
+ `)
+ require.NoError(t, err)
+ rowsAffected, err = s.FailStaleReviewRuns(ctx, time.Minute)
+ require.NoError(t, err)
+ require.Equal(t, int64(0), rowsAffected)
+}
diff --git a/backend/tests/review_run_lifecycle_test.go b/backend/tests/review_run_lifecycle_test.go
new file mode 100644
index 0000000000..ee60b6e3ac
--- /dev/null
+++ b/backend/tests/review_run_lifecycle_test.go
@@ -0,0 +1,150 @@
+package tests
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ "connectrpc.com/connect"
+ "github.com/stretchr/testify/require"
+ "google.golang.org/protobuf/types/known/fieldmaskpb"
+
+ "github.com/bytebase/bytebase/backend/common"
+ v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
+)
+
+// waitReviewRunTerminal polls the review_run slot raw until it reaches a
+// terminal status and returns the row.
+func waitReviewRunTerminal(ctx context.Context, t *testing.T, ctl *controller, projectID string, issueUID int64, reviewType string) *reviewRun {
+ t.Helper()
+ a := require.New(t)
+ var row *reviewRun
+ a.Eventually(func() bool {
+ for _, r := range listReviewRuns(ctx, t, ctl, projectID) {
+ if r.IssueID == issueUID && r.Type == reviewType && (r.Status == "DONE" || r.Status == "FAILED") {
+ row = r
+ return true
+ }
+ }
+ return false
+ }, 90*time.Second, 500*time.Millisecond,
+ "review run (%s, %d, %s) should reach a terminal status", projectID, issueUID, reviewType)
+ return row
+}
+
+func runReview(ctx context.Context, ctl *controller, issueName, reviewRunID string) (*v1pb.ReviewRun, error) {
+ resp, err := ctl.issueServiceClient.RunReview(ctx, connect.NewRequest(&v1pb.RunReviewRequest{
+ Name: issueName + "/reviewRuns/" + reviewRunID,
+ }))
+ if err != nil {
+ return nil, err
+ }
+ return resp.Msg, nil
+}
+
+// TestCollision_RunReviewLifecycle drives RunReview end to end on two
+// projects whose issue ids collide: the scheduler claims and executes the
+// rule review for real, completions land on the right project, and a re-run
+// on one project leaves the other project's slot untouched.
+func TestCollision_RunReviewLifecycle(t *testing.T) {
+ t.Parallel()
+ a := require.New(t)
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
+ defer cancel()
+ ctl := &controller{}
+ ctx, err := ctl.StartServerWithExternalPg(ctx)
+ a.NoError(err)
+ defer ctl.Close(ctx)
+
+ fixture := setupCollidingProjects(ctx, t, ctl)
+
+ // The fixture issues carry rollouts; a rollout freezes the plan's SQL, so
+ // review is refused.
+ _, err = runReview(ctx, ctl, fixture.IssueA.Name, "rule")
+ a.Equal(connect.CodeFailedPrecondition, connect.CodeOf(err))
+
+ // Fresh colliding plan+issue pairs without rollouts.
+ _, issueA := createPlanAndIssue(ctx, t, ctl, fixture.ProjectA, fixture.DatabaseA, "Review lifecycle A")
+ _, issueB := createPlanAndIssue(ctx, t, ctl, fixture.ProjectB, fixture.DatabaseB, "Review lifecycle B")
+ projectAID, issueAUID, err := common.GetProjectIDIssueUID(issueA.Name)
+ a.NoError(err)
+ projectBID, issueBUID, err := common.GetProjectIDIssueUID(issueB.Name)
+ a.NoError(err)
+ a.Equal(issueAUID, issueBUID, "fixture issue ids should collide")
+
+ // Unknown reviewer type.
+ _, err = runReview(ctx, ctl, issueA.Name, "bogus")
+ a.Equal(connect.CodeInvalidArgument, connect.CodeOf(err))
+
+ // Guideline review requires AI, which is off in the test workspace.
+ _, err = runReview(ctx, ctl, issueA.Name, "guideline")
+ a.Equal(connect.CodeFailedPrecondition, connect.CodeOf(err))
+
+ // Rule review on both colliding issues.
+ runA, err := runReview(ctx, ctl, issueA.Name, "rule")
+ a.NoError(err)
+ a.Equal(issueA.Name+"/reviewRuns/rule", runA.Name)
+ a.Equal(v1pb.ReviewRun_RULE, runA.Type)
+ a.Equal(v1pb.ReviewRun_AVAILABLE, runA.Status)
+ a.NotNil(runA.CreateTime)
+ a.Nil(runA.EndTime)
+ a.Empty(runA.Error)
+ runB, err := runReview(ctx, ctl, issueB.Name, "rule")
+ a.NoError(err)
+ a.Equal(v1pb.ReviewRun_AVAILABLE, runB.Status)
+
+ // The scheduler claims and executes both; the rule engine evaluates the
+ // real test databases and the runs reach DONE.
+ rowA := waitReviewRunTerminal(ctx, t, ctl, projectAID, issueAUID, "RULE")
+ a.Equal("DONE", rowA.Status, "rule review on project A should succeed, got payload %s", rowA.Payload)
+ a.Equal(int64(0), rowA.Attempt)
+ rowB := waitReviewRunTerminal(ctx, t, ctl, projectBID, issueBUID, "RULE")
+ a.Equal("DONE", rowB.Status, "rule review on project B should succeed, got payload %s", rowB.Payload)
+ a.Equal(int64(0), rowB.Attempt)
+
+ // Re-running A bumps only A's attempt; B's colliding slot is untouched.
+ beforeB := listReviewRuns(ctx, t, ctl, projectBID)
+ a.Greater(len(beforeB), 0, "project B should have review_run rows")
+ runA2, err := runReview(ctx, ctl, issueA.Name, "rule")
+ a.NoError(err)
+ a.Equal(v1pb.ReviewRun_AVAILABLE, runA2.Status)
+ rowA2 := waitReviewRunTerminal(ctx, t, ctl, projectAID, issueAUID, "RULE")
+ a.Equal(int64(1), rowA2.Attempt)
+ a.Equal("DONE", rowA2.Status)
+ afterB := listReviewRuns(ctx, t, ctl, projectBID)
+ a.Equal(beforeB, afterB, "project B review_run rows must be untouched by A's re-run")
+
+ // With AI enabled, the guideline slot is created, claimed, and fails
+ // honestly: the executor is not implemented yet.
+ _, err = ctl.settingServiceClient.UpdateSetting(ctx, connect.NewRequest(&v1pb.UpdateSettingRequest{
+ AllowMissing: true,
+ Setting: &v1pb.Setting{
+ Name: "settings/" + v1pb.Setting_AI.String(),
+ Value: &v1pb.SettingValue{
+ Value: &v1pb.SettingValue_Ai{
+ Ai: &v1pb.AISetting{
+ Enabled: true,
+ Provider: v1pb.AISetting_GEMINI,
+ Endpoint: "https://ai.invalid",
+ ApiKey: "unused",
+ Model: "unused",
+ },
+ },
+ },
+ },
+ UpdateMask: &fieldmaskpb.FieldMask{
+ Paths: []string{"value.ai.enabled", "value.ai.provider", "value.ai.endpoint", "value.ai.api_key", "value.ai.model"},
+ },
+ }))
+ a.NoError(err)
+ runG, err := runReview(ctx, ctl, issueA.Name, "guideline")
+ a.NoError(err)
+ a.Equal(v1pb.ReviewRun_GUIDELINE, runG.Type)
+ rowG := waitReviewRunTerminal(ctx, t, ctl, projectAID, issueAUID, "GUIDELINE")
+ a.Equal("FAILED", rowG.Status)
+ a.Contains(rowG.Payload, "not implemented")
+ // The failed guideline run left A's rule slot alone.
+ rowA3 := waitReviewRunTerminal(ctx, t, ctl, projectAID, issueAUID, "RULE")
+ a.Equal(int64(1), rowA3.Attempt)
+ a.Equal("DONE", rowA3.Status)
+}
diff --git a/frontend/src/types/iam/permission-generated.ts b/frontend/src/types/iam/permission-generated.ts
index b357acb916..76d5db4f3b 100644
--- a/frontend/src/types/iam/permission-generated.ts
+++ b/frontend/src/types/iam/permission-generated.ts
@@ -90,6 +90,7 @@ export type Permission =
| "bb.reviewConfigs.get"
| "bb.reviewConfigs.list"
| "bb.reviewConfigs.update"
+ | "bb.reviewRuns.run"
| "bb.revisions.create"
| "bb.revisions.delete"
| "bb.revisions.get"
diff --git a/frontend/src/types/proto-es/v1/issue_service_pb.d.ts b/frontend/src/types/proto-es/v1/issue_service_pb.d.ts
index 51e0ad8833..6946298319 100644
--- a/frontend/src/types/proto-es/v1/issue_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/issue_service_pb.d.ts
@@ -1162,6 +1162,155 @@ export declare type IssueComment_PlanUpdate = Message<"bytebase.v1.IssueComment.
*/
export declare const IssueComment_PlanUpdateSchema: GenMessage<IssueComment_PlanUpdate>;
+/**
+ * @generated from message bytebase.v1.ReviewRun
+ */
+export declare type ReviewRun = Message<"bytebase.v1.ReviewRun"> & {
+ /**
+ * Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ * The {reviewRun} id is the reviewer: "rule" or "guideline". The name
+ * addresses a slot, not an execution.
+ *
+ * @generated from field: string name = 1;
+ */
+ name: string;
+
+ /**
+ * Derived from the name.
+ *
+ * @generated from field: bytebase.v1.ReviewRun.Type type = 2;
+ */
+ type: ReviewRun_Type;
+
+ /**
+ * @generated from field: bytebase.v1.ReviewRun.Status status = 3;
+ */
+ status: ReviewRun_Status;
+
+ /**
+ * When the current run was triggered. Reset on every re-run.
+ *
+ * @generated from field: google.protobuf.Timestamp create_time = 4;
+ */
+ createTime?: Timestamp | undefined;
+
+ /**
+ * When the run reached a terminal status. Unset while AVAILABLE or
+ * RUNNING.
+ *
+ * @generated from field: google.protobuf.Timestamp end_time = 5;
+ */
+ endTime?: Timestamp | undefined;
+
+ /**
+ * Fatal execution error, set if and only if status is FAILED: the review
+ * failed to execute (a platform problem, never the SQL — SQL problems are
+ * review results on a DONE run).
+ *
+ * @generated from field: string error = 6;
+ */
+ error: string;
+};
+
+/**
+ * Describes the message bytebase.v1.ReviewRun.
+ * Use `create(ReviewRunSchema)` to create a new message.
+ */
+export declare const ReviewRunSchema: GenMessage<ReviewRun>;
+
+/**
+ * @generated from enum bytebase.v1.ReviewRun.Type
+ */
+export enum ReviewRun_Type {
+ /**
+ * @generated from enum value: TYPE_UNSPECIFIED = 0;
+ */
+ TYPE_UNSPECIFIED = 0,
+
+ /**
+ * Review against the standard rules.
+ *
+ * @generated from enum value: RULE = 1;
+ */
+ RULE = 1,
+
+ /**
+ * Review against natural-language guidelines, performed by AI.
+ *
+ * @generated from enum value: GUIDELINE = 2;
+ */
+ GUIDELINE = 2,
+}
+
+/**
+ * Describes the enum bytebase.v1.ReviewRun.Type.
+ */
+export declare const ReviewRun_TypeSchema: GenEnum<ReviewRun_Type>;
+
+/**
+ * States follow task_run, minus PENDING (review needs no admission
+ * control) and minus CANCELED (runs are side-effect-free until the fenced
+ * completion transaction, so re-running supersedes instead of canceling).
+ *
+ * @generated from enum bytebase.v1.ReviewRun.Status
+ */
+export enum ReviewRun_Status {
+ /**
+ * @generated from enum value: STATUS_UNSPECIFIED = 0;
+ */
+ STATUS_UNSPECIFIED = 0,
+
+ /**
+ * Created and claimable by any replica.
+ *
+ * @generated from enum value: AVAILABLE = 1;
+ */
+ AVAILABLE = 1,
+
+ /**
+ * @generated from enum value: RUNNING = 2;
+ */
+ RUNNING = 2,
+
+ /**
+ * Every (spec, target) unit was evaluated. DONE does not mean the
+ * review passed: whether problems remain is judged from open comments.
+ *
+ * @generated from enum value: DONE = 3;
+ */
+ DONE = 3,
+
+ /**
+ * At least one unit was not evaluated; the cause is in `error`.
+ *
+ * @generated from enum value: FAILED = 4;
+ */
+ FAILED = 4,
+}
+
+/**
+ * Describes the enum bytebase.v1.ReviewRun.Status.
+ */
+export declare const ReviewRun_StatusSchema: GenEnum<ReviewRun_Status>;
+
+/**
+ * @generated from message bytebase.v1.RunReviewRequest
+ */
+export declare type RunReviewRequest = Message<"bytebase.v1.RunReviewRequest"> & {
+ /**
+ * Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ *
+ * @generated from field: string name = 1;
+ */
+ name: string;
+};
+
+/**
+ * Describes the message bytebase.v1.RunReviewRequest.
+ * Use `create(RunReviewRequestSchema)` to create a new message.
+ */
+export declare const RunReviewRequestSchema: GenMessage<RunReviewRequest>;
+
/**
* IssueService manages issues for tracking database changes and tasks.
*
@@ -1318,5 +1467,19 @@ export declare const IssueService: GenService<{
input: typeof RetryIssueApprovalRequestSchema;
output: typeof IssueSchema;
},
+ /**
+ * Triggers a review run. The slot is reset unconditionally: a RUNNING
+ * execution is superseded (its completion is fenced off), the attempt
+ * number is bumped, and the returned run is AVAILABLE.
+ * The audit log is the only record of who triggered a run.
+ * Permissions required: bb.reviewRuns.run
+ *
+ * @generated from rpc bytebase.v1.IssueService.RunReview
+ */
+ runReview: {
+ methodKind: "unary";
+ input: typeof RunReviewRequestSchema;
+ output: typeof ReviewRunSchema;
+ },
}>;
diff --git a/frontend/src/types/proto-es/v1/issue_service_pb.js b/frontend/src/types/proto-es/v1/issue_service_pb.js
index 695576dfdc..023b0010c3 100644
--- a/frontend/src/types/proto-es/v1/issue_service_pb.js
+++ b/frontend/src/types/proto-es/v1/issue_service_pb.js
@@ -18,7 +18,7 @@ import { file_v1_plan_service } from "./plan_service_pb";
* Describes the file v1/issue_service.proto.
*/
export const file_v1_issue_service = /*@__PURE__*/
- fileDesc("ChZ2MS9pc3N1ZV9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSJKCg9HZXRJc3N1ZVJlcXVlc3QSKAoEbmFtZRgBIAEoCUIa4EEC+kEUChJieXRlYmFzZS5jb20vSXNzdWUSDQoFZm9yY2UYAiABKAgiagoSQ3JlYXRlSXNzdWVSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBImCgVpc3N1ZRgCIAEoCzISLmJ5dGViYXNlLnYxLklzc3VlQgPgQQIimQEKEUxpc3RJc3N1ZXNSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBIRCglwYWdlX3NpemUYAiABKAUSEgoKcGFnZV90b2tlbhgDIAEoCRIOCgZmaWx0ZXIYBCABKAkSDQoFcXVlcnkYBSABKAkSEAoIb3JkZXJfYnkYBiABKAkiUQoSTGlzdElzc3Vlc1Jlc3BvbnNlEiIKBmlzc3VlcxgBIAMoCzISLmJ5dGViYXNlLnYxLklzc3VlEhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSKCAQoTU2VhcmNoSXNzdWVzUmVxdWVzdBITCgZwYXJlbnQYASABKAlCA+BBAhIRCglwYWdlX3NpemUYAiABKAUSEgoKcGFnZV90b2tlbhgDIAEoCRIOCgZmaWx0ZXIYBCABKAkSDQoFcXVlcnkYBSABKAkSEAoIb3JkZXJfYnk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mVxdWVzdElzc3VlEiAuYnl0ZWJhc2UudjEuUmVxdWVzdElzc3VlUmVxdWVzdBoSLmJ5dGViYXNlLnYxLklzc3VlIj2Q6jACmOowAaDqMAKC0+STAis6ASoiJi92MS97bmFtZT1wcm9qZWN0cy8qL2lzc3Vlcy8qfTpyZXF1ZXN0EpkBChJSZXRyeUlzc3VlQXBwcm92YWwSJi5ieXRlYmFzZS52MS5SZXRyeUlzc3VlQXBwcm92YWxSZXF1ZXN0GhIuYnl0ZWJhc2UudjEuSXNzdWUiR5DqMAKY6jABoOowA6jqMAiC0+STAjE6ASoiLC92MS97bmFtZT1wcm9qZWN0cy8qL2lzc3Vlcy8qfTpyZXRyeUFwcHJvdmFsQqcBCg9jb20uYnl0ZWJhc2UudjFCEUlzc3VlU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_protobuf_timestamp, file_google_type_expr, file_v1_annotation, file_v1_common, file_v1_plan_service]);
+ fileDesc("ChZ2MS9pc3N1ZV9zZXJ2aWNlLnByb3RvEgtieXRlYmFzZS52MSJKCg9HZXRJc3N1ZVJlcXVlc3QSKAoEbmFtZRgBIAEoCUIa4EEC+kEUChJieXRlYmFzZS5jb20vSXNzdWUSDQoFZm9yY2UYAiABKAgiagoSQ3JlYXRlSXNzdWVSZXF1ZXN0EiwKBnBhcmVudBgBIAEoCUIc4EEC+kEWChRieXRlYmFzZS5jb20vUHJvamVjdBImCgVpc3N1ZRgCIAEoCzISLmJ5dGViYXNlLnYxLklzc3VlQgPgQQI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GViYXNlLnYxLlJlamVjdElzc3VlUmVxdWVzdBoSLmJ5dGViYXNlLnYxLklzc3VlIkCQ6jACmOowAaDqMAOo6jAIgtPkkwIqOgEqIiUvdjEve25hbWU9cHJvamVjdHMvKi9pc3N1ZXMvKn06cmVqZWN0EoMBCgxSZXF1ZXN0SXNzdWUSIC5ieXRlYmFzZS52MS5SZXF1ZXN0SXNzdWVSZXF1ZXN0GhIuYnl0ZWJhc2UudjEuSXNzdWUiPZDqMAKY6jABoOowAoLT5JMCKzoBKiImL3YxL3tuYW1lPXByb2plY3RzLyovaXNzdWVzLyp9OnJlcXVlc3QSmQEKElJldHJ5SXNzdWVBcHByb3ZhbBImLmJ5dGViYXNlLnYxLlJldHJ5SXNzdWVBcHByb3ZhbFJlcXVlc3QaEi5ieXRlYmFzZS52MS5Jc3N1ZSJHkOowApjqMAGg6jADqOowCILT5JMCMToBKiIsL3YxL3tuYW1lPXByb2plY3RzLyovaXNzdWVzLyp9OnJldHJ5QXBwcm92YWwSpgEKCVJ1blJldmlldxIdLmJ5dGViYXNlLnYxLlJ1blJldmlld1JlcXVlc3QaFi5ieXRlYmFzZS52MS5SZXZpZXdSdW4iYtpBBG5hbWWK6jARYmIucmV2aWV3UnVucy5ydW6Q6jABmOowAaDqMAKC0+STAjQ6ASoiLy92MS97bmFtZT1wcm9qZWN0cy8qL2lzc3Vlcy8qL3Jldmlld1J1bnMvKn06cnVuQqcBCg9jb20uYnl0ZWJhc2UudjFCEUlzc3VlU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_buf_validate_validate, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_protobuf_timestamp, file_google_type_expr, file_v1_annotation, file_v1_common, file_v1_plan_service]);
/**
* Describes the message bytebase.v1.GetIssueRequest.
@@ -251,6 +251,48 @@ export const IssueComment_ReviewSubmissionSchema = /*@__PURE__*/
export const IssueComment_PlanUpdateSchema = /*@__PURE__*/
messageDesc(file_v1_issue_service, 21, 3);
+/**
+ * Describes the message bytebase.v1.ReviewRun.
+ * Use `create(ReviewRunSchema)` to create a new message.
+ */
+export const ReviewRunSchema = /*@__PURE__*/
+ messageDesc(file_v1_issue_service, 22);
+
+/**
+ * Describes the enum bytebase.v1.ReviewRun.Type.
+ */
+export const ReviewRun_TypeSchema = /*@__PURE__*/
+ enumDesc(file_v1_issue_service, 22, 0);
+
+/**
+ * @generated from enum bytebase.v1.ReviewRun.Type
+ */
+export const ReviewRun_Type = /*@__PURE__*/
+ tsEnum(ReviewRun_TypeSchema);
+
+/**
+ * Describes the enum bytebase.v1.ReviewRun.Status.
+ */
+export const ReviewRun_StatusSchema = /*@__PURE__*/
+ enumDesc(file_v1_issue_service, 22, 1);
+
+/**
+ * States follow task_run, minus PENDING (review needs no admission
+ * control) and minus CANCELED (runs are side-effect-free until the fenced
+ * completion transaction, so re-running supersedes instead of canceling).
+ *
+ * @generated from enum bytebase.v1.ReviewRun.Status
+ */
+export const ReviewRun_Status = /*@__PURE__*/
+ tsEnum(ReviewRun_StatusSchema);
+
+/**
+ * Describes the message bytebase.v1.RunReviewRequest.
+ * Use `create(RunReviewRequestSchema)` to create a new message.
+ */
+export const RunReviewRequestSchema = /*@__PURE__*/
+ messageDesc(file_v1_issue_service, 23);
+
/**
* IssueService manages issues for tracking database changes and tasks.
*
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 3c4a466fd1..6d1c798a7b 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -11231,6 +11231,44 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.ListIssueCommentsResponse'
+ /v1/projects/{project}/issues/{issue}/reviewRuns/{reviewRun}:run:
+ post:
+ tags:
+ - IssueService
+ summary: RunReview
+ description: |-
+ Triggers a review run. The slot is reset unconditionally: a RUNNING
+ execution is superseded (its completion is fenced off), the attempt
+ number is bumped, and the returned run is AVAILABLE.
+ The audit log is the only record of who triggered a run.
+ Permissions required: bb.reviewRuns.run
+ operationId: IssueService_RunReview
+ parameters:
+ - name: project
+ in: path
+ description: The project id.
+ required: true
+ schema:
+ type: string
+ - name: issue
+ in: path
+ description: The issue id.
+ required: true
+ schema:
+ type: string
+ - name: reviewRun
+ in: path
+ description: The reviewRun id.
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Success
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/bytebase.v1.ReviewRun'
/v1/projects/{project}/issues/{issue}:approve:
post:
tags:
@@ -29103,6 +29141,67 @@ components:
Format: {resource}/{resource id}, e.g., environments/test.
title: ReviewConfig
additionalProperties: false
+ bytebase.v1.ReviewRun:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: |-
+ Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ The {reviewRun} id is the reviewer: "rule" or "guideline". The name
+ addresses a slot, not an execution.
+ type:
+ title: type
+ description: Derived from the name.
+ readOnly: true
+ $ref: '#/components/schemas/bytebase.v1.ReviewRun.Type'
+ status:
+ title: status
+ readOnly: true
+ $ref: '#/components/schemas/bytebase.v1.ReviewRun.Status'
+ createTime:
+ title: create_time
+ description: When the current run was triggered. Reset on every re-run.
+ readOnly: true
+ $ref: '#/components/schemas/google.protobuf.Timestamp'
+ endTime:
+ title: end_time
+ description: |-
+ When the run reached a terminal status. Unset while AVAILABLE or
+ RUNNING.
+ readOnly: true
+ $ref: '#/components/schemas/google.protobuf.Timestamp'
+ error:
+ type: string
+ title: error
+ description: |-
+ Fatal execution error, set if and only if status is FAILED: the review
+ failed to execute (a platform problem, never the SQL — SQL problems are
+ review results on a DONE run).
+ readOnly: true
+ title: ReviewRun
+ additionalProperties: false
+ bytebase.v1.ReviewRun.Status:
+ type: string
+ title: Status
+ enum:
+ - STATUS_UNSPECIFIED
+ - AVAILABLE
+ - RUNNING
+ - DONE
+ - FAILED
+ description: |-
+ States follow task_run, minus PENDING (review needs no admission
+ control) and minus CANCELED (runs are side-effect-free until the fenced
+ completion transaction, so re-running supersedes instead of canceling).
+ bytebase.v1.ReviewRun.Type:
+ type: string
+ title: Type
+ enum:
+ - TYPE_UNSPECIFIED
+ - RULE
+ - GUIDELINE
bytebase.v1.Revision:
type: object
properties:
@@ -29525,6 +29624,17 @@ components:
type: object
title: RunPlanChecksResponse
additionalProperties: false
+ bytebase.v1.RunReviewRequest:
+ type: object
+ properties:
+ name:
+ type: string
+ title: name
+ description: 'Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}'
+ title: RunReviewRequest
+ required:
+ - name
+ additionalProperties: false
bytebase.v1.SASLConfig:
type: object
oneOf:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 3d5c4eccce..a8f230efc4 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -236,7 +236,9 @@
- [RejectIssueRequest](#bytebase-v1-RejectIssueRequest)
- [RequestIssueRequest](#bytebase-v1-RequestIssueRequest)
- [RetryIssueApprovalRequest](#bytebase-v1-RetryIssueApprovalRequest)
+ - [ReviewRun](#bytebase-v1-ReviewRun)
- [RoleGrant](#bytebase-v1-RoleGrant)
+ - [RunReviewRequest](#bytebase-v1-RunReviewRequest)
- [SearchIssuesRequest](#bytebase-v1-SearchIssuesRequest)
- [SearchIssuesResponse](#bytebase-v1-SearchIssuesResponse)
- [UpdateIssueCommentRequest](#bytebase-v1-UpdateIssueCommentRequest)
@@ -245,6 +247,8 @@
- [Issue.Approver.Status](#bytebase-v1-Issue-Approver-Status)
- [Issue.Type](#bytebase-v1-Issue-Type)
- [IssueComment.Approval.Status](#bytebase-v1-IssueComment-Approval-Status)
+ - [ReviewRun.Status](#bytebase-v1-ReviewRun-Status)
+ - [ReviewRun.Type](#bytebase-v1-ReviewRun-Type)
- [IssueService](#bytebase-v1-IssueService)
@@ -4277,6 +4281,26 @@ For example: creator == &#34;users/[email protected]&#34; &amp;&amp; status in [&#
+<a name="bytebase-v1-ReviewRun"></a>
+
+### ReviewRun
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| name | [string](#string) | | Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun} The {reviewRun} id is the reviewer: &#34;rule&#34; or &#34;guideline&#34;. The name addresses a slot, not an execution. |
+| type | [ReviewRun.Type](#bytebase-v1-ReviewRun-Type) | | Derived from the name. |
+| status | [ReviewRun.Status](#bytebase-v1-ReviewRun-Status) | | |
+| create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | When the current run was triggered. Reset on every re-run. |
+| end_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | When the run reached a terminal status. Unset while AVAILABLE or RUNNING. |
+| error | [string](#string) | | Fatal execution error, set if and only if status is FAILED: the review failed to execute (a platform problem, never the SQL — SQL problems are review results on a DONE run). |
+
+
+
+
+
+
<a name="bytebase-v1-RoleGrant"></a>
### RoleGrant
@@ -4295,6 +4319,21 @@ For example: creator == &#34;users/[email protected]&#34; &amp;&amp; status in [&#
+<a name="bytebase-v1-RunReviewRequest"></a>
+
+### RunReviewRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| name | [string](#string) | | Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun} |
+
+
+
+
+
+
<a name="bytebase-v1-SearchIssuesRequest"></a>
### SearchIssuesRequest
@@ -4413,6 +4452,36 @@ Approval status values.
| REJECTED | 3 | Rejected. |
+
+<a name="bytebase-v1-ReviewRun-Status"></a>
+
+### ReviewRun.Status
+States follow task_run, minus PENDING (review needs no admission
+control) and minus CANCELED (runs are side-effect-free until the fenced
+completion transaction, so re-running supersedes instead of canceling).
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| STATUS_UNSPECIFIED | 0 | |
+| AVAILABLE | 1 | Created and claimable by any replica. |
+| RUNNING | 2 | |
+| DONE | 3 | Every (spec, target) unit was evaluated. DONE does not mean the review passed: whether problems remain is judged from open comments. |
+| FAILED | 4 | At least one unit was not evaluated; the cause is in `error`. |
+
+
+
+<a name="bytebase-v1-ReviewRun-Type"></a>
+
+### ReviewRun.Type
+
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| TYPE_UNSPECIFIED | 0 | |
+| RULE | 1 | Review against the standard rules. |
+| GUIDELINE | 2 | Review against natural-language guidelines, performed by AI. |
+
+
@@ -4438,6 +4507,7 @@ IssueService manages issues for tracking database changes and tasks.
| RejectIssue | [RejectIssueRequest](#bytebase-v1-RejectIssueRequest) | [Issue](#bytebase-v1-Issue) | Rejects an issue. Access determined by approval flow configuration - caller must be a designated approver for the current approval step. Permissions required: None (determined by approval flow) |
| RequestIssue | [RequestIssueRequest](#bytebase-v1-RequestIssueRequest) | [Issue](#bytebase-v1-Issue) | Requests changes on an issue. Access determined by approval flow configuration - caller must be a designated approver for the current approval step. Permissions required: None (determined by approval flow) |
| RetryIssueApproval | [RetryIssueApprovalRequest](#bytebase-v1-RetryIssueApprovalRequest) | [Issue](#bytebase-v1-Issue) | Re-runs approval-template finding for an issue stuck in CHECKING. Useful when the synchronous post-create finding errored (e.g. against a malformed workspace approval rule) and the operator has since corrected it — without this, the issue would remain in CHECKING indefinitely because there is no other retry path for non-DATABASE_CHANGE issue types. Idempotent: returns the existing issue unchanged when approval-finding has already completed. Permissions required: None (caller must be the issue creator; mirrors RequestIssue&#39;s authorization model). |
+| RunReview | [RunReviewRequest](#bytebase-v1-RunReviewRequest) | [ReviewRun](#bytebase-v1-ReviewRun) | Triggers a review run. The slot is reset unconditionally: a RUNNING execution is superseded (its completion is fenced off), the attempt number is bumped, and the returned run is AVAILABLE. The audit log is the only record of who triggered a run. Permissions required: bb.reviewRuns.run |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 623514965b..81bc927cfa 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -1067,10 +1067,18 @@
<a href="#bytebase.v1.RetryIssueApprovalRequest"><span class="badge">M</span>RetryIssueApprovalRequest</a>
</li>
+ <li>
+ <a href="#bytebase.v1.ReviewRun"><span class="badge">M</span>ReviewRun</a>
+ </li>
+
<li>
<a href="#bytebase.v1.RoleGrant"><span class="badge">M</span>RoleGrant</a>
</li>
+ <li>
+ <a href="#bytebase.v1.RunReviewRequest"><span class="badge">M</span>RunReviewRequest</a>
+ </li>
+
<li>
<a href="#bytebase.v1.SearchIssuesRequest"><span class="badge">M</span>SearchIssuesRequest</a>
</li>
@@ -1100,6 +1108,14 @@
<a href="#bytebase.v1.IssueComment.Approval.Status"><span class="badge">E</span>IssueComment.Approval.Status</a>
</li>
+ <li>
+ <a href="#bytebase.v1.ReviewRun.Status"><span class="badge">E</span>ReviewRun.Status</a>
+ </li>
+
+ <li>
+ <a href="#bytebase.v1.ReviewRun.Type"><span class="badge">E</span>ReviewRun.Type</a>
+ </li>
+
<li>
@@ -12590,6 +12606,70 @@ Format: projects/{project}/issues/{issue} </p></td>
+ <h3 id="bytebase.v1.ReviewRun">ReviewRun</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>name</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+The {reviewRun} id is the reviewer: &#34;rule&#34; or &#34;guideline&#34;. The name
+addresses a slot, not an execution. </p></td>
+ </tr>
+
+ <tr>
+ <td>type</td>
+ <td><a href="#bytebase.v1.ReviewRun.Type">ReviewRun.Type</a></td>
+ <td></td>
+ <td><p>Derived from the name. </p></td>
+ </tr>
+
+ <tr>
+ <td>status</td>
+ <td><a href="#bytebase.v1.ReviewRun.Status">ReviewRun.Status</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>create_time</td>
+ <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>
+ <td></td>
+ <td><p>When the current run was triggered. Reset on every re-run. </p></td>
+ </tr>
+
+ <tr>
+ <td>end_time</td>
+ <td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>
+ <td></td>
+ <td><p>When the run reached a terminal status. Unset while AVAILABLE or
+RUNNING. </p></td>
+ </tr>
+
+ <tr>
+ <td>error</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Fatal execution error, set if and only if status is FAILED: the review
+failed to execute (a platform problem, never the SQL — SQL problems are
+review results on a DONE run). </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.RoleGrant">RoleGrant</h3>
<p></p>
@@ -12637,6 +12717,30 @@ Format: users/{email}. </p></td>
+ <h3 id="bytebase.v1.RunReviewRequest">RunReviewRequest</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>name</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun} </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
<h3 id="bytebase.v1.SearchIssuesRequest">SearchIssuesRequest</h3>
<p></p>
@@ -12944,6 +13048,77 @@ In this situation, `update_mask` is ignored. </p></td>
</tbody>
</table>
+ <h3 id="bytebase.v1.ReviewRun.Status">ReviewRun.Status</h3>
+ <p>States follow task_run, minus PENDING (review needs no admission</p><p>control) and minus CANCELED (runs are side-effect-free until the fenced</p><p>completion transaction, so re-running supersedes instead of canceling).</p>
+ <table class="enum-table">
+ <thead>
+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>STATUS_UNSPECIFIED</td>
+ <td>0</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>AVAILABLE</td>
+ <td>1</td>
+ <td><p>Created and claimable by any replica.</p></td>
+ </tr>
+
+ <tr>
+ <td>RUNNING</td>
+ <td>2</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>DONE</td>
+ <td>3</td>
+ <td><p>Every (spec, target) unit was evaluated. DONE does not mean the
+review passed: whether problems remain is judged from open comments.</p></td>
+ </tr>
+
+ <tr>
+ <td>FAILED</td>
+ <td>4</td>
+ <td><p>At least one unit was not evaluated; the cause is in `error`.</p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <h3 id="bytebase.v1.ReviewRun.Type">ReviewRun.Type</h3>
+ <p></p>
+ <table class="enum-table">
+ <thead>
+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>TYPE_UNSPECIFIED</td>
+ <td>0</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>RULE</td>
+ <td>1</td>
+ <td><p>Review against the standard rules.</p></td>
+ </tr>
+
+ <tr>
+ <td>GUIDELINE</td>
+ <td>2</td>
+ <td><p>Review against natural-language guidelines, performed by AI.</p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
@@ -13067,6 +13242,17 @@ Permissions required: None (caller must be the issue creator;
mirrors RequestIssue&#39;s authorization model).</p></td>
</tr>
+ <tr>
+ <td>RunReview</td>
+ <td><a href="#bytebase.v1.RunReviewRequest">RunReviewRequest</a></td>
+ <td><a href="#bytebase.v1.ReviewRun">ReviewRun</a></td>
+ <td><p>Triggers a review run. The slot is reset unconditionally: a RUNNING
+execution is superseded (its completion is fenced off), the attempt
+number is bumped, and the returned run is AVAILABLE.
+The audit log is the only record of who triggered a run.
+Permissions required: bb.reviewRuns.run</p></td>
+ </tr>
+
</tbody>
</table>
@@ -13215,6 +13401,16 @@ mirrors RequestIssue&#39;s authorization model).</p></td>
</tr>
+
+
+ <tr>
+ <td>RunReview</td>
+ <td>POST</td>
+ <td>/v1/{name=projects/*/issues/*/reviewRuns/*}:run</td>
+ <td>*</td>
+ </tr>
+
+
</tbody>
</table>
diff --git a/proto/v1/v1/issue_service.proto b/proto/v1/v1/issue_service.proto
index 76c717ee6f..6b5e1717cf 100644
--- a/proto/v1/v1/issue_service.proto
+++ b/proto/v1/v1/issue_service.proto
@@ -223,6 +223,23 @@ service IssueService {
option (bytebase.v1.mcp_method_class) = FORBIDDEN;
option (bytebase.v1.mcp_denial_reason) = DRIVES_THE_APPROVAL_DECISION;
}
+
+ // Triggers a review run. The slot is reset unconditionally: a RUNNING
+ // execution is superseded (its completion is fenced off), the attempt
+ // number is bumped, and the returned run is AVAILABLE.
+ // The audit log is the only record of who triggered a run.
+ // Permissions required: bb.reviewRuns.run
+ rpc RunReview(RunReviewRequest) returns (ReviewRun) {
+ option (google.api.http) = {
+ post: "/v1/{name=projects/*/issues/*/reviewRuns/*}:run"
+ body: "*"
+ };
+ option (google.api.method_signature) = "name";
+ option (bytebase.v1.permission) = "bb.reviewRuns.run";
+ option (bytebase.v1.auth_method) = IAM;
+ option (bytebase.v1.audit) = true;
+ option (bytebase.v1.mcp_method_class) = WRITE;
+ }
}
message GetIssueRequest {
@@ -699,3 +716,61 @@ message IssueComment {
repeated Plan.Spec to_specs = 2;
}
}
+
+message ReviewRun {
+ option (google.api.resource) = {
+ type: "bytebase.com/ReviewRun"
+ pattern: "projects/{project}/issues/{issue}/reviewRuns/{reviewRun}"
+ };
+
+ // Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ // The {reviewRun} id is the reviewer: "rule" or "guideline". The name
+ // addresses a slot, not an execution.
+ string name = 1;
+
+ enum Type {
+ TYPE_UNSPECIFIED = 0;
+ // Review against the standard rules.
+ RULE = 1;
+ // Review against natural-language guidelines, performed by AI.
+ GUIDELINE = 2;
+ }
+ // Derived from the name.
+ Type type = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ // States follow task_run, minus PENDING (review needs no admission
+ // control) and minus CANCELED (runs are side-effect-free until the fenced
+ // completion transaction, so re-running supersedes instead of canceling).
+ enum Status {
+ STATUS_UNSPECIFIED = 0;
+ // Created and claimable by any replica.
+ AVAILABLE = 1;
+ RUNNING = 2;
+ // Every (spec, target) unit was evaluated. DONE does not mean the
+ // review passed: whether problems remain is judged from open comments.
+ DONE = 3;
+ // At least one unit was not evaluated; the cause is in `error`.
+ FAILED = 4;
+ }
+ Status status = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ // When the current run was triggered. Reset on every re-run.
+ google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ // When the run reached a terminal status. Unset while AVAILABLE or
+ // RUNNING.
+ google.protobuf.Timestamp end_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ // Fatal execution error, set if and only if status is FAILED: the review
+ // failed to execute (a platform problem, never the SQL — SQL problems are
+ // review results on a DONE run).
+ string error = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
+}
+
+message RunReviewRequest {
+ // Format: projects/{project}/issues/{issue}/reviewRuns/{reviewRun}
+ string name = 1 [
+ (google.api.field_behavior) = REQUIRED,
+ (google.api.resource_reference) = {type: "bytebase.com/ReviewRun"}
+ ];
+}