Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(policy): add the REVIEW_AI policy (#21518)
h3n4ld46bd572f0a7
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yamlindex 8fc9a1375d..21772eecbb 100644--- a/backend/api/mcp/gen/openapi.yaml+++ b/backend/api/mcp/gen/openapi.yaml@@ -17891,6 +17891,13 @@ components:- $ref: '#/components/schemas/bytebase.v1.QueryDataPolicy'title: query_data_policytitle: query_data_policy+ - type: object+ properties:+ reviewAiPolicy:+ allOf:+ - $ref: '#/components/schemas/bytebase.v1.ReviewAIPolicy'+ title: review_ai_policy+ title: review_ai_policy- type: objectproperties:reviewRulePolicy:@@ -17922,6 +17929,8 @@ components:- maskingRulePolicy- required:- queryDataPolicy+ - required:+ - reviewAiPolicy- required:- reviewRulePolicy- required:@@ -17936,6 +17945,8 @@ components:- maskingRulePolicy- required:- queryDataPolicy+ - required:+ - reviewAiPolicy- required:- reviewRulePolicy- required:@@ -18002,6 +18013,7 @@ components:- TAG- DATA_QUERY- REVIEW_RULE+ - REVIEW_AIdescription: The type of organizational policy.bytebase.v1.Position:type: object@@ -19097,6 +19109,19 @@ components:Format: projects/{project}/issues/{issue}title: RetryIssueApprovalRequestadditionalProperties: false+ bytebase.v1.ReviewAIPolicy:+ type: object+ properties:+ content:+ type: string+ title: content+ description: The policy text. Must not be blank, at most 64 KiB.+ title: ReviewAIPolicy+ additionalProperties: false+ description: |-+ Natural-language policy for the AI review. Unlike the review rule policy,+ both levels apply: the workspace policy and the project policy both reach+ the reviewer, and the project policy wins where they conflict.bytebase.v1.ReviewConfig:type: objectproperties:diff --git a/backend/api/v1/audit_redact_inventory_test.go b/backend/api/v1/audit_redact_inventory_test.goindex 5ff848f49f..cee30b5851 100644--- a/backend/api/v1/audit_redact_inventory_test.go+++ b/backend/api/v1/audit_redact_inventory_test.go@@ -808,6 +808,7 @@ var auditRecordedFields = []string{"bytebase.v1.RequestReauthCodeRequest.name","bytebase.v1.ResetPasswordRequest.email","bytebase.v1.RetryIssueApprovalRequest.name",+ "bytebase.v1.ReviewAIPolicy.content","bytebase.v1.ReviewConfig.name","bytebase.v1.ReviewConfig.resources","bytebase.v1.ReviewConfig.title",diff --git a/backend/api/v1/org_policy_service.go b/backend/api/v1/org_policy_service.goindex e381c33f4f..0c1d762917 100644--- a/backend/api/v1/org_policy_service.go+++ b/backend/api/v1/org_policy_service.go@@ -30,6 +30,7 @@ var (storepb.Policy_MASKING_RULE: {storepb.Policy_WORKSPACE},storepb.Policy_MASKING_EXEMPTION: {storepb.Policy_PROJECT},storepb.Policy_REVIEW_RULE: {storepb.Policy_WORKSPACE, storepb.Policy_PROJECT},+ storepb.Policy_REVIEW_AI: {storepb.Policy_WORKSPACE, storepb.Policy_PROJECT},})@@ -238,10 +239,17 @@ func (s *OrgPolicyService) UpdatePolicy(ctx context.Context, req *connect.Reques"data_source_query_policy","export_data_policy","query_data_policy",- "review_rule_policy":+ "review_rule_policy",+ "review_ai_policy":if !pathMatchType(path, policy.Type) {return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid path %s for policy type %s", path, policy.Type.String()))}+ // The payload is serialized by the type the request declares, so a+ // request that names another type would store that type's empty+ // payload under this policy.+ if requestType, err := convertV1PBToStorePBPolicyType(req.Msg.Policy.Type); err != nil || requestType != policy.Type {+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("policy type %s does not match the policy's type %s", req.Msg.Policy.Type, policy.Type))+ }if err := validatePolicyPayload(policy.Type, req.Msg.Policy); err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrap(err, "invalid policy"))}@@ -284,6 +292,8 @@ func pathMatchType(path string, policyType storepb.Policy_Type) bool {return path == "query_data_policy"case storepb.Policy_REVIEW_RULE:return path == "review_rule_policy"+ case storepb.Policy_REVIEW_AI:+ return path == "review_ai_policy"default:return false}@@ -595,6 +605,17 @@ func validatePolicyPayload(policyType storepb.Policy_Type, policy *v1pb.Policy)if err := validateReviewRules(reviewRulePolicy.ReviewRulePolicy.Rules); err != nil {return connect.NewError(connect.CodeInvalidArgument, err)}+ case storepb.Policy_REVIEW_AI:+ reviewAIPolicy, ok := policy.Policy.(*v1pb.Policy_ReviewAiPolicy)+ if !ok {+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unmatched policy type %v and policy %v", policyType, policy.Policy))+ }+ if reviewAIPolicy.ReviewAiPolicy == nil {+ return connect.NewError(connect.CodeInvalidArgument, errors.New("AI review policy must be set"))+ }+ if err := validateReviewAIPolicyContent(reviewAIPolicy.ReviewAiPolicy.Content); err != nil {+ return connect.NewError(connect.CodeInvalidArgument, err)+ }default:}return nil@@ -619,6 +640,24 @@ func validateReviewRules(rules []v1pb.ReviewRuleType) error {return nil}+// maxReviewAIPolicyBytes bounds the policy text. The whole text goes into+// every review prompt, so the bound is a prompt budget, not a storage limit.+const maxReviewAIPolicyBytes = 64 << 10++// validateReviewAIPolicyContent rejects blank text, which would count as a+// policy in force that says nothing, and text over the prompt budget. To+// switch the AI review off for a resource, delete the policy or set enforce+// to false.+func validateReviewAIPolicyContent(content string) error {+ if strings.TrimSpace(content) == "" {+ return errors.New("AI review policy content must not be blank")+ }+ if len(content) > maxReviewAIPolicyBytes {+ return errors.Errorf("AI review policy content is %d bytes, the limit is %d", len(content), maxReviewAIPolicyBytes)+ }+ return nil+}+func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, policy *v1pb.Policy) (string, error) {switch policy.Type {case v1pb.PolicyType_ROLLOUT_POLICY:@@ -660,6 +699,12 @@ func (s *OrgPolicyService) convertPolicyPayloadToString(ctx context.Context, polreturn "", errors.Wrap(err, "failed to marshal review rule policy")}return string(payloadBytes), nil+ case v1pb.PolicyType_REVIEW_AI:+ payloadBytes, err := protojson.Marshal(convertToStorePBReviewAIPolicy(policy.GetReviewAiPolicy()))+ if err != nil {+ return "", errors.Wrap(err, "failed to marshal AI review policy")+ }+ return string(payloadBytes), nilcase v1pb.PolicyType_MASKING_RULE:if err := s.licenseService.IsFeatureEnabled(ctx, common.GetWorkspaceIDFromContext(ctx), v1pb.PlanFeature_FEATURE_DATA_MASKING); err != nil {return "", connect.NewError(connect.CodePermissionDenied, err)@@ -734,6 +779,12 @@ func convertToPolicy(policyMessage *store.PolicyMessage) (*v1pb.Policy, error) {return nil, err}policy.Policy = payload+ case storepb.Policy_REVIEW_AI:+ payload, err := convertToV1PBReviewAIPolicy(policyMessage.Payload)+ if err != nil {+ return nil, err+ }+ policy.Policy = payloadcase storepb.Policy_MASKING_RULE:maskingRulePolicy := &storepb.MaskingRulePolicy{}if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(policyMessage.Payload), maskingRulePolicy); err != nil {diff --git a/backend/api/v1/org_policy_service_converter.go b/backend/api/v1/org_policy_service_converter.goindex 759d8aa193..aab3537fa5 100644--- a/backend/api/v1/org_policy_service_converter.go+++ b/backend/api/v1/org_policy_service_converter.go@@ -211,6 +211,20 @@ func convertToStorePBReviewRulePolicy(policy *v1pb.ReviewRulePolicy) *storepb.Rereturn &storepb.ReviewRulePolicy{Rules: rules}}+func convertToV1PBReviewAIPolicy(payloadStr string) (*v1pb.Policy_ReviewAiPolicy, error) {+ payload := &storepb.ReviewAIPolicy{}+ if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(payloadStr), payload); err != nil {+ return nil, errors.Wrapf(err, "failed to unmarshal AI review policy payload")+ }+ return &v1pb.Policy_ReviewAiPolicy{+ ReviewAiPolicy: &v1pb.ReviewAIPolicy{Content: payload.Content},+ }, nil+}++func convertToStorePBReviewAIPolicy(policy *v1pb.ReviewAIPolicy) *storepb.ReviewAIPolicy {+ return &storepb.ReviewAIPolicy{Content: policy.GetContent()}+}+func convertToStorePBMskingRulePolicy(policy *v1pb.MaskingRulePolicy) *storepb.MaskingRulePolicy {var rules []*storepb.MaskingRulePolicy_MaskingRulefor _, rule := range policy.Rules {@@ -324,6 +338,8 @@ func convertV1PBToStorePBPolicyType(pType v1pb.PolicyType) (storepb.Policy_Type,return storepb.Policy_QUERY_DATA, nilcase v1pb.PolicyType_REVIEW_RULE:return storepb.Policy_REVIEW_RULE, nil+ case v1pb.PolicyType_REVIEW_AI:+ return storepb.Policy_REVIEW_AI, nildefault:}return storepb.Policy_TYPE_UNSPECIFIED, errors.Errorf("invalid policy type %v", pType)@@ -343,6 +359,8 @@ func convertStorePBToV1PBPolicyType(pType storepb.Policy_Type) v1pb.PolicyType {return v1pb.PolicyType_DATA_QUERYcase storepb.Policy_REVIEW_RULE:return v1pb.PolicyType_REVIEW_RULE+ case storepb.Policy_REVIEW_AI:+ return v1pb.PolicyType_REVIEW_AIdefault:}return v1pb.PolicyType_POLICY_TYPE_UNSPECIFIEDdiff --git a/backend/api/v1/org_policy_service_review_ai_test.go b/backend/api/v1/org_policy_service_review_ai_test.gonew file mode 100644index 0000000000..ea230d1eaa--- /dev/null+++ b/backend/api/v1/org_policy_service_review_ai_test.go@@ -0,0 +1,231 @@+package v1++import (+ "strings"+ "testing"++ "connectrpc.com/connect"+ "github.com/stretchr/testify/require"+ "google.golang.org/protobuf/encoding/protojson"+ "google.golang.org/protobuf/types/known/fieldmaskpb"++ "github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/component/iam"+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"+)++func TestReviewAIPolicyConverterRoundTrip(t *testing.T) {+ t.Parallel()+ const text = "Every table has a primary key.\n\nAn index on a table over 1 million rows is created CONCURRENTLY.\n表名用蛇形命名。"++ payload := convertToStorePBReviewAIPolicy(&v1pb.ReviewAIPolicy{Content: text})+ require.Equal(t, text, payload.Content)++ payloadBytes, err := protojson.Marshal(payload)+ require.NoError(t, err)+ out, err := convertToV1PBReviewAIPolicy(string(payloadBytes))+ require.NoError(t, err)+ require.Equal(t, text, out.ReviewAiPolicy.Content)++ require.Empty(t, convertToStorePBReviewAIPolicy(nil).Content)+ _, err = convertToV1PBReviewAIPolicy("not json")+ require.Error(t, err)+}++func TestReviewAIPolicyTypeConversion(t *testing.T) {+ t.Parallel()+ storeType, err := convertV1PBToStorePBPolicyType(v1pb.PolicyType_REVIEW_AI)+ require.NoError(t, err)+ require.Equal(t, storepb.Policy_REVIEW_AI, storeType)+ require.Equal(t, v1pb.PolicyType_REVIEW_AI, convertStorePBToV1PBPolicyType(storepb.Policy_REVIEW_AI))+}++func TestReviewAIPolicyResourceTypes(t *testing.T) {+ t.Parallel()+ require.NoError(t, validatePolicyType(storepb.Policy_REVIEW_AI, storepb.Policy_WORKSPACE))+ require.NoError(t, validatePolicyType(storepb.Policy_REVIEW_AI, storepb.Policy_PROJECT))+ require.Error(t, validatePolicyType(storepb.Policy_REVIEW_AI, storepb.Policy_ENVIRONMENT))+}++func TestReviewAIPolicyPathMatchType(t *testing.T) {+ t.Parallel()+ require.True(t, pathMatchType("review_ai_policy", storepb.Policy_REVIEW_AI))+ require.False(t, pathMatchType("review_rule_policy", storepb.Policy_REVIEW_AI))+ require.False(t, pathMatchType("review_ai_policy", storepb.Policy_REVIEW_RULE))+}++func TestValidateReviewAIPolicyPayload(t *testing.T) {+ t.Parallel()+ reviewAI := func(content string) *v1pb.Policy {+ return &v1pb.Policy{Policy: &v1pb.Policy_ReviewAiPolicy{+ ReviewAiPolicy: &v1pb.ReviewAIPolicy{Content: content},+ }}+ }+ for _, tc := range []struct {+ name string+ policy *v1pb.Policy+ ok bool+ }{+ {"one sentence", reviewAI("Every table has a primary key."), true},+ {"many lines", reviewAI("# Standards\n\n- Every table has a primary key.\n- No column is dropped in production.\n"), true},+ {"at the limit", reviewAI(strings.Repeat("a", maxReviewAIPolicyBytes)), true},+ {"empty", reviewAI(""), false},+ {"whitespace only", reviewAI(" \n\t"), false},+ {"over the limit", reviewAI(strings.Repeat("a", maxReviewAIPolicyBytes+1)), false},+ {"other payload", &v1pb.Policy{Policy: &v1pb.Policy_QueryDataPolicy{QueryDataPolicy: &v1pb.QueryDataPolicy{}}}, false},+ {"nil payload", &v1pb.Policy{Policy: &v1pb.Policy_ReviewAiPolicy{}}, false},+ } {+ t.Run(tc.name, func(t *testing.T) {+ t.Parallel()+ err := validatePolicyPayload(storepb.Policy_REVIEW_AI, tc.policy)+ if tc.ok {+ require.NoError(t, err)+ } else {+ require.Error(t, err)+ }+ })+ }+}++// TestReviewAIPolicyService walks the REVIEW_AI policy through the service+// against a real store at both levels: NotFound on a missing row, create,+// get, list, update, validation, enforce, and delete. The effective lookup+// is the store's behavior and is tested there.+func TestReviewAIPolicyService(t *testing.T) {+ t.Parallel()+ a := require.New(t)+ ctx := issueServiceTestContext()+ stores := setupIssueServiceTestStore(ctx, t)+ iamManager, err := iam.NewManager(stores, nil, false)+ a.NoError(err)+ service := NewOrgPolicyService(stores, nil, iamManager)++ const projectName = "projects/project-a"+ projectPolicyName := projectName + "/policies/review_ai"+ workspaceName := common.FormatWorkspace("default")+ workspacePolicyName := workspaceName + "/policies/review_ai"+ content := func(policy *v1pb.Policy) string {+ return policy.GetReviewAiPolicy().GetContent()+ }+ reviewAI := func(text string) *v1pb.Policy {+ return &v1pb.Policy{+ Type: v1pb.PolicyType_REVIEW_AI,+ Policy: &v1pb.Policy_ReviewAiPolicy{ReviewAiPolicy: &v1pb.ReviewAIPolicy{Content: text}},+ }+ }+ get := func(name string) (*v1pb.Policy, error) {+ response, err := service.GetPolicy(ctx, connect.NewRequest(&v1pb.GetPolicyRequest{Name: name}))+ if err != nil {+ return nil, err+ }+ return response.Msg, nil+ }+ // No row: NotFound. A missing policy has no default, unlike the rule policy.+ _, err = get(projectPolicyName)+ a.Equal(connect.CodeNotFound, connect.CodeOf(err))++ // Create on the project.+ const projectText = "Every new column on orders has a comment."+ created, err := service.CreatePolicy(ctx, connect.NewRequest(&v1pb.CreatePolicyRequest{+ Parent: projectName,+ Policy: reviewAI(projectText),+ }))+ a.NoError(err)+ a.Equal(projectPolicyName, created.Msg.Name)+ a.Equal(v1pb.PolicyType_REVIEW_AI, created.Msg.Type)+ a.Equal(v1pb.PolicyResourceType_PROJECT, created.Msg.ResourceType)+ a.Equal(projectText, content(created.Msg))+ a.True(created.Msg.Enforce)++ got, err := get(projectPolicyName)+ a.NoError(err)+ a.Equal(projectText, content(got))++ // List with the type filter finds it.+ listed, err := service.ListPolicies(ctx, connect.NewRequest(&v1pb.ListPoliciesRequest{+ Parent: projectName,+ PolicyType: v1pb.PolicyType_REVIEW_AI.Enum(),+ }))+ a.NoError(err)+ a.Len(listed.Msg.Policies, 1)+ a.Equal(projectPolicyName, listed.Msg.Policies[0].Name)++ // Update through the review_ai_policy mask path.+ const updatedText = "Every new column on orders has a comment, and no column of orders is dropped."+ updatedPolicy := reviewAI(updatedText)+ updatedPolicy.Name = projectPolicyName+ updated, err := service.UpdatePolicy(ctx, connect.NewRequest(&v1pb.UpdatePolicyRequest{+ Policy: updatedPolicy,+ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"review_ai_policy"}},+ }))+ a.NoError(err)+ a.Equal(updatedText, content(updated.Msg))++ // An update that declares another type is refused, and the row keeps its+ // content instead of storing the other type's empty payload.+ mismatched := reviewAI(updatedText)+ mismatched.Name = projectPolicyName+ mismatched.Type = v1pb.PolicyType_REVIEW_RULE+ _, err = service.UpdatePolicy(ctx, connect.NewRequest(&v1pb.UpdatePolicyRequest{+ Policy: mismatched,+ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"review_ai_policy"}},+ }))+ a.Equal(connect.CodeInvalidArgument, connect.CodeOf(err))+ got, err = get(projectPolicyName)+ a.NoError(err)+ a.Equal(updatedText, content(got))++ // Validation: blank or oversized policy content is refused.+ for _, bad := range []string{"", " \n\t", strings.Repeat("x", maxReviewAIPolicyBytes+1)} {+ badPolicy := reviewAI(bad)+ badPolicy.Name = projectPolicyName+ _, err = service.UpdatePolicy(ctx, connect.NewRequest(&v1pb.UpdatePolicyRequest{+ Policy: badPolicy,+ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"review_ai_policy"}},+ }))+ a.Equal(connect.CodeInvalidArgument, connect.CodeOf(err))+ }++ // The policy does not attach to an environment.+ _, err = service.CreatePolicy(ctx, connect.NewRequest(&v1pb.CreatePolicyRequest{+ Parent: "environments/prod",+ Policy: reviewAI(projectText),+ }))+ a.Equal(connect.CodeInvalidArgument, connect.CodeOf(err))++ // Workspace level: NotFound, then create.+ _, err = get(workspacePolicyName)+ a.Equal(connect.CodeNotFound, connect.CodeOf(err))+ const workspaceText = "An index on a table over 1 million rows is created CONCURRENTLY."+ created, err = service.CreatePolicy(ctx, connect.NewRequest(&v1pb.CreatePolicyRequest{+ Parent: workspaceName,+ Policy: reviewAI(workspaceText),+ }))+ a.NoError(err)+ a.Equal(workspacePolicyName, created.Msg.Name)+ a.Equal(v1pb.PolicyResourceType_WORKSPACE, created.Msg.ResourceType)+ got, err = get(workspacePolicyName)+ a.NoError(err)+ a.Equal(workspaceText, content(got))++ // Enforce is switched through its own mask path.+ off := reviewAI(updatedText)+ off.Name = projectPolicyName+ off.Enforce = false+ updated, err = service.UpdatePolicy(ctx, connect.NewRequest(&v1pb.UpdatePolicyRequest{+ Policy: off,+ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"enforce"}},+ }))+ a.NoError(err)+ a.False(updated.Msg.Enforce)++ // Deleted: NotFound, and the workspace policy is untouched.+ _, err = service.DeletePolicy(ctx, connect.NewRequest(&v1pb.DeletePolicyRequest{Name: projectPolicyName}))+ a.NoError(err)+ _, err = get(projectPolicyName)+ a.Equal(connect.CodeNotFound, connect.CodeOf(err))+ got, err = get(workspacePolicyName)+ a.NoError(err)+ a.Equal(workspaceText, content(got))+}diff --git a/backend/generated-go/store/policy.pb.go b/backend/generated-go/store/policy.pb.goindex e14d2f12bf..b281b33cb2 100644--- a/backend/generated-go/store/policy.pb.go+++ b/backend/generated-go/store/policy.pb.go@@ -33,6 +33,7 @@ const (Policy_IAM Policy_Type = 5Policy_TAG Policy_Type = 6Policy_REVIEW_RULE Policy_Type = 7+ Policy_REVIEW_AI Policy_Type = 8)// Enum value maps for Policy_Type.@@ -46,6 +47,7 @@ var (5: "IAM",6: "TAG",7: "REVIEW_RULE",+ 8: "REVIEW_AI",}Policy_Type_value = map[string]int32{"TYPE_UNSPECIFIED": 0,@@ -56,6 +58,7 @@ var ("IAM": 5,"TAG": 6,"REVIEW_RULE": 7,+ "REVIEW_AI": 8,})@@ -220,6 +223,54 @@ func (x *ReviewRulePolicy) GetRules() []ReviewRuleType {return nil}+// ReviewAIPolicy holds the natural-language policy the AI review judges a+// change against. Both levels apply: the workspace policy and the project+// policy both reach the reviewer, and the project policy wins where they+// conflict.+type ReviewAIPolicy struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *ReviewAIPolicy) Reset() {+ *x = ReviewAIPolicy{}+ mi := &file_store_policy_proto_msgTypes[2]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *ReviewAIPolicy) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*ReviewAIPolicy) ProtoMessage() {}++func (x *ReviewAIPolicy) ProtoReflect() protoreflect.Message {+ mi := &file_store_policy_proto_msgTypes[2]+ 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 ReviewAIPolicy.ProtoReflect.Descriptor instead.+func (*ReviewAIPolicy) Descriptor() ([]byte, []int) {+ return file_store_policy_proto_rawDescGZIP(), []int{2}+}++func (x *ReviewAIPolicy) GetContent() string {+ if x != nil {+ return x.Content+ }+ return ""+}+type RolloutPolicy struct {state protoimpl.MessageState `protogen:"open.v1"`Automatic bool `protobuf:"varint,1,opt,name=automatic,proto3" json:"automatic,omitempty"`@@ -230,7 +281,7 @@ type RolloutPolicy struct {func (x *RolloutPolicy) Reset() {*x = RolloutPolicy{}- mi := &file_store_policy_proto_msgTypes[2]+ mi := &file_store_policy_proto_msgTypes[3]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -242,7 +293,7 @@ func (x *RolloutPolicy) String() string {func (*RolloutPolicy) ProtoMessage() {}func (x *RolloutPolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[2]+ mi := &file_store_policy_proto_msgTypes[3]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -255,7 +306,7 @@ func (x *RolloutPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use RolloutPolicy.ProtoReflect.Descriptor instead.func (*RolloutPolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{2}+ return file_store_policy_proto_rawDescGZIP(), []int{3}}func (x *RolloutPolicy) GetAutomatic() bool {@@ -282,7 +333,7 @@ type MaskingExemptionPolicy struct {func (x *MaskingExemptionPolicy) Reset() {*x = MaskingExemptionPolicy{}- mi := &file_store_policy_proto_msgTypes[3]+ mi := &file_store_policy_proto_msgTypes[4]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -294,7 +345,7 @@ func (x *MaskingExemptionPolicy) String() string {func (*MaskingExemptionPolicy) ProtoMessage() {}func (x *MaskingExemptionPolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[3]+ mi := &file_store_policy_proto_msgTypes[4]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -307,7 +358,7 @@ func (x *MaskingExemptionPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingExemptionPolicy.ProtoReflect.Descriptor instead.func (*MaskingExemptionPolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{3}+ return file_store_policy_proto_rawDescGZIP(), []int{4}}func (x *MaskingExemptionPolicy) GetExemptions() []*MaskingExemptionPolicy_Exemption {@@ -326,7 +377,7 @@ type MaskingRulePolicy struct {func (x *MaskingRulePolicy) Reset() {*x = MaskingRulePolicy{}- mi := &file_store_policy_proto_msgTypes[4]+ mi := &file_store_policy_proto_msgTypes[5]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -338,7 +389,7 @@ func (x *MaskingRulePolicy) String() string {func (*MaskingRulePolicy) ProtoMessage() {}func (x *MaskingRulePolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[4]+ mi := &file_store_policy_proto_msgTypes[5]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -351,7 +402,7 @@ func (x *MaskingRulePolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingRulePolicy.ProtoReflect.Descriptor instead.func (*MaskingRulePolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{4}+ return file_store_policy_proto_rawDescGZIP(), []int{5}}func (x *MaskingRulePolicy) GetRules() []*MaskingRulePolicy_MaskingRule {@@ -372,7 +423,7 @@ type TagPolicy struct {func (x *TagPolicy) Reset() {*x = TagPolicy{}- mi := &file_store_policy_proto_msgTypes[5]+ mi := &file_store_policy_proto_msgTypes[6]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -384,7 +435,7 @@ func (x *TagPolicy) String() string {func (*TagPolicy) ProtoMessage() {}func (x *TagPolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[5]+ mi := &file_store_policy_proto_msgTypes[6]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -397,7 +448,7 @@ func (x *TagPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use TagPolicy.ProtoReflect.Descriptor instead.func (*TagPolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{5}+ return file_store_policy_proto_rawDescGZIP(), []int{6}}func (x *TagPolicy) GetTags() map[string]string {@@ -426,7 +477,7 @@ type Binding struct {func (x *Binding) Reset() {*x = Binding{}- mi := &file_store_policy_proto_msgTypes[6]+ mi := &file_store_policy_proto_msgTypes[7]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -438,7 +489,7 @@ func (x *Binding) String() string {func (*Binding) ProtoMessage() {}func (x *Binding) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[6]+ mi := &file_store_policy_proto_msgTypes[7]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -451,7 +502,7 @@ func (x *Binding) ProtoReflect() protoreflect.Message {// Deprecated: Use Binding.ProtoReflect.Descriptor instead.func (*Binding) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{6}+ return file_store_policy_proto_rawDescGZIP(), []int{7}}func (x *Binding) GetRole() string {@@ -486,7 +537,7 @@ type IamPolicy struct {func (x *IamPolicy) Reset() {*x = IamPolicy{}- mi := &file_store_policy_proto_msgTypes[7]+ mi := &file_store_policy_proto_msgTypes[8]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -498,7 +549,7 @@ func (x *IamPolicy) String() string {func (*IamPolicy) ProtoMessage() {}func (x *IamPolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[7]+ mi := &file_store_policy_proto_msgTypes[8]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -511,7 +562,7 @@ func (x *IamPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use IamPolicy.ProtoReflect.Descriptor instead.func (*IamPolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{7}+ return file_store_policy_proto_rawDescGZIP(), []int{8}}func (x *IamPolicy) GetBindings() []*Binding {@@ -549,7 +600,7 @@ type QueryDataPolicy struct {func (x *QueryDataPolicy) Reset() {*x = QueryDataPolicy{}- mi := &file_store_policy_proto_msgTypes[8]+ mi := &file_store_policy_proto_msgTypes[9]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -561,7 +612,7 @@ func (x *QueryDataPolicy) String() string {func (*QueryDataPolicy) ProtoMessage() {}func (x *QueryDataPolicy) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[8]+ mi := &file_store_policy_proto_msgTypes[9]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -574,7 +625,7 @@ func (x *QueryDataPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use QueryDataPolicy.ProtoReflect.Descriptor instead.func (*QueryDataPolicy) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{8}+ return file_store_policy_proto_rawDescGZIP(), []int{9}}func (x *QueryDataPolicy) GetDisableExport() bool {@@ -648,7 +699,7 @@ type MaskingExemptionPolicy_Exemption struct {func (x *MaskingExemptionPolicy_Exemption) Reset() {*x = MaskingExemptionPolicy_Exemption{}- mi := &file_store_policy_proto_msgTypes[9]+ mi := &file_store_policy_proto_msgTypes[10]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -660,7 +711,7 @@ func (x *MaskingExemptionPolicy_Exemption) String() string {func (*MaskingExemptionPolicy_Exemption) ProtoMessage() {}func (x *MaskingExemptionPolicy_Exemption) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[9]+ mi := &file_store_policy_proto_msgTypes[10]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -673,7 +724,7 @@ func (x *MaskingExemptionPolicy_Exemption) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingExemptionPolicy_Exemption.ProtoReflect.Descriptor instead.func (*MaskingExemptionPolicy_Exemption) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{3, 0}+ return file_store_policy_proto_rawDescGZIP(), []int{4, 0}}func (x *MaskingExemptionPolicy_Exemption) GetMembers() []string {@@ -702,7 +753,7 @@ type MaskingRulePolicy_MaskingRule struct {func (x *MaskingRulePolicy_MaskingRule) Reset() {*x = MaskingRulePolicy_MaskingRule{}- mi := &file_store_policy_proto_msgTypes[10]+ mi := &file_store_policy_proto_msgTypes[11]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -714,7 +765,7 @@ func (x *MaskingRulePolicy_MaskingRule) String() string {func (*MaskingRulePolicy_MaskingRule) ProtoMessage() {}func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {- mi := &file_store_policy_proto_msgTypes[10]+ mi := &file_store_policy_proto_msgTypes[11]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -727,7 +778,7 @@ func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingRulePolicy_MaskingRule.ProtoReflect.Descriptor instead.func (*MaskingRulePolicy_MaskingRule) Descriptor() ([]byte, []int) {- return file_store_policy_proto_rawDescGZIP(), []int{4, 0}+ return file_store_policy_proto_rawDescGZIP(), []int{5, 0}}func (x *MaskingRulePolicy_MaskingRule) GetId() string {@@ -755,8 +806,8 @@ var File_store_policy_proto protoreflect.FileDescriptorconst file_store_policy_proto_rawDesc = "" +"\n" +- "\x12store/policy.proto\x12\x0ebytebase.store\x1a\x16google/type/expr.proto\x1a\x17store/review_rule.proto\"\xe3\x01\n" +- "\x06Policy\"\x85\x01\n" ++ "\x12store/policy.proto\x12\x0ebytebase.store\x1a\x16google/type/expr.proto\x1a\x17store/review_rule.proto\"\xf2\x01\n" ++ "\x06Policy\"\x94\x01\n" +"\x04Type\x12\x14\n" +"\x10TYPE_UNSPECIFIED\x10\x00\x12\v\n" +"\aROLLOUT\x10\x01\x12\x15\n" +@@ -766,14 +817,17 @@ const file_store_policy_proto_rawDesc = "" +"\fMASKING_RULE\x10\x04\x12\a\n" +"\x03IAM\x10\x05\x12\a\n" +"\x03TAG\x10\x06\x12\x0f\n" +- "\vREVIEW_RULE\x10\a\"Q\n" ++ "\vREVIEW_RULE\x10\a\x12\r\n" ++ "\tREVIEW_AI\x10\b\"Q\n" +"\bResource\x12\x18\n" +"\x14RESOURCE_UNSPECIFIED\x10\x00\x12\r\n" +"\tWORKSPACE\x10\x01\x12\x0f\n" +"\vENVIRONMENT\x10\x02\x12\v\n" +"\aPROJECT\x10\x03\"H\n" +"\x10ReviewRulePolicy\x124\n" +- "\x05rules\x18\x01 \x03(\x0e2\x1e.bytebase.store.ReviewRuleTypeR\x05rules\"C\n" ++ "\x05rules\x18\x01 \x03(\x0e2\x1e.bytebase.store.ReviewRuleTypeR\x05rules\"*\n" ++ "\x0eReviewAIPolicy\x12\x18\n" ++ "\acontent\x18\x01 \x01(\tR\acontent\"C\n" +"\rRolloutPolicy\x12\x1c\n" +"\tautomatic\x18\x01 \x01(\bR\tautomatic\x12\x14\n" +"\x05roles\x18\x02 \x03(\tR\x05roles\"\xc2\x01\n" +@@ -823,34 +877,35 @@ func file_store_policy_proto_rawDescGZIP() []byte {}var file_store_policy_proto_enumTypes = make([]protoimpl.EnumInfo, 2)-var file_store_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 12)+var file_store_policy_proto_msgTypes = make([]protoimpl.MessageInfo, 13)var file_store_policy_proto_goTypes = []any{(Policy_Type)(0), // 0: bytebase.store.Policy.Type(Policy_Resource)(0), // 1: bytebase.store.Policy.Resource(*Policy)(nil), // 2: bytebase.store.Policy(*ReviewRulePolicy)(nil), // 3: bytebase.store.ReviewRulePolicy- (*RolloutPolicy)(nil), // 4: bytebase.store.RolloutPolicy- (*MaskingExemptionPolicy)(nil), // 5: bytebase.store.MaskingExemptionPolicy- (*MaskingRulePolicy)(nil), // 6: bytebase.store.MaskingRulePolicy- (*TagPolicy)(nil), // 7: bytebase.store.TagPolicy- (*Binding)(nil), // 8: bytebase.store.Binding- (*IamPolicy)(nil), // 9: bytebase.store.IamPolicy- (*QueryDataPolicy)(nil), // 10: bytebase.store.QueryDataPolicy- (*MaskingExemptionPolicy_Exemption)(nil), // 11: bytebase.store.MaskingExemptionPolicy.Exemption- (*MaskingRulePolicy_MaskingRule)(nil), // 12: bytebase.store.MaskingRulePolicy.MaskingRule- nil, // 13: bytebase.store.TagPolicy.TagsEntry- (ReviewRuleType)(0), // 14: bytebase.store.ReviewRuleType- (*expr.Expr)(nil), // 15: google.type.Expr+ (*ReviewAIPolicy)(nil), // 4: bytebase.store.ReviewAIPolicy+ (*RolloutPolicy)(nil), // 5: bytebase.store.RolloutPolicy+ (*MaskingExemptionPolicy)(nil), // 6: bytebase.store.MaskingExemptionPolicy+ (*MaskingRulePolicy)(nil), // 7: bytebase.store.MaskingRulePolicy+ (*TagPolicy)(nil), // 8: bytebase.store.TagPolicy+ (*Binding)(nil), // 9: bytebase.store.Binding+ (*IamPolicy)(nil), // 10: bytebase.store.IamPolicy+ (*QueryDataPolicy)(nil), // 11: bytebase.store.QueryDataPolicy+ (*MaskingExemptionPolicy_Exemption)(nil), // 12: bytebase.store.MaskingExemptionPolicy.Exemption+ (*MaskingRulePolicy_MaskingRule)(nil), // 13: bytebase.store.MaskingRulePolicy.MaskingRule+ nil, // 14: bytebase.store.TagPolicy.TagsEntry+ (ReviewRuleType)(0), // 15: bytebase.store.ReviewRuleType+ (*expr.Expr)(nil), // 16: google.type.Expr}var file_store_policy_proto_depIdxs = []int32{- 14, // 0: bytebase.store.ReviewRulePolicy.rules:type_name -> bytebase.store.ReviewRuleType- 11, // 1: bytebase.store.MaskingExemptionPolicy.exemptions:type_name -> bytebase.store.MaskingExemptionPolicy.Exemption- 12, // 2: bytebase.store.MaskingRulePolicy.rules:type_name -> bytebase.store.MaskingRulePolicy.MaskingRule- 13, // 3: bytebase.store.TagPolicy.tags:type_name -> bytebase.store.TagPolicy.TagsEntry- 15, // 4: bytebase.store.Binding.condition:type_name -> google.type.Expr- 8, // 5: bytebase.store.IamPolicy.bindings:type_name -> bytebase.store.Binding- 15, // 6: bytebase.store.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr- 15, // 7: bytebase.store.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr+ 15, // 0: bytebase.store.ReviewRulePolicy.rules:type_name -> bytebase.store.ReviewRuleType+ 12, // 1: bytebase.store.MaskingExemptionPolicy.exemptions:type_name -> bytebase.store.MaskingExemptionPolicy.Exemption+ 13, // 2: bytebase.store.MaskingRulePolicy.rules:type_name -> bytebase.store.MaskingRulePolicy.MaskingRule+ 14, // 3: bytebase.store.TagPolicy.tags:type_name -> bytebase.store.TagPolicy.TagsEntry+ 16, // 4: bytebase.store.Binding.condition:type_name -> google.type.Expr+ 9, // 5: bytebase.store.IamPolicy.bindings:type_name -> bytebase.store.Binding+ 16, // 6: bytebase.store.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr+ 16, // 7: bytebase.store.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr8, // [8:8] is the sub-list for method output_type8, // [8:8] is the sub-list for method input_type8, // [8:8] is the sub-list for extension type_name@@ -870,7 +925,7 @@ func file_store_policy_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_policy_proto_rawDesc), len(file_store_policy_proto_rawDesc)),NumEnums: 2,- NumMessages: 12,+ NumMessages: 13,NumExtensions: 0,NumServices: 0,},diff --git a/backend/generated-go/store/policy_equal.pb.go b/backend/generated-go/store/policy_equal.pb.goindex c5ecfaceec..eb6f3a9095 100644--- a/backend/generated-go/store/policy_equal.pb.go+++ b/backend/generated-go/store/policy_equal.pb.go@@ -36,6 +36,19 @@ func (x *ReviewRulePolicy) Equal(y *ReviewRulePolicy) bool {return true}+func (x *ReviewAIPolicy) Equal(y *ReviewAIPolicy) bool {+ if x == y {+ return true+ }+ if x == nil || y == nil {+ return x == nil && y == nil+ }+ if x.Content != y.Content {+ return false+ }+ return true+}+func (x *RolloutPolicy) Equal(y *RolloutPolicy) bool {if x == y {return truediff --git a/backend/generated-go/store/review_run.pb.go b/backend/generated-go/store/review_run.pb.goindex 95d4285273..daa7ebad24 100644--- a/backend/generated-go/store/review_run.pb.go+++ b/backend/generated-go/store/review_run.pb.go@@ -30,8 +30,8 @@ const (ReviewRun_TYPE_UNSPECIFIED ReviewRun_Type = 0// Review against the standard rules.ReviewRun_RULE ReviewRun_Type = 1- // Review against the AI review policy's natural-language instructions,- // performed by a model.+ // Review against the natural-language AI review policy, performed by a+ // model.ReviewRun_AI ReviewRun_Type = 2)diff --git a/backend/generated-go/v1/issue_service.pb.go b/backend/generated-go/v1/issue_service.pb.goindex 500f1caf42..ccf411274e 100644--- a/backend/generated-go/v1/issue_service.pb.go+++ b/backend/generated-go/v1/issue_service.pb.go@@ -310,8 +310,8 @@ const (ReviewRun_TYPE_UNSPECIFIED ReviewRun_Type = 0// Review against the standard rules.ReviewRun_RULE ReviewRun_Type = 1- // Review against the AI review policy's natural-language instructions,- // performed by a model.+ // Review against the natural-language AI review policy, performed by a+ // model.ReviewRun_AI ReviewRun_Type = 2)diff --git a/backend/generated-go/v1/org_policy_service.pb.go b/backend/generated-go/v1/org_policy_service.pb.goindex b80b581642..a513fcdfec 100644--- a/backend/generated-go/v1/org_policy_service.pb.go+++ b/backend/generated-go/v1/org_policy_service.pb.go@@ -43,6 +43,8 @@ const (PolicyType_DATA_QUERY PolicyType = 6// Standard review rule switch. Allowed on WORKSPACE and PROJECT.PolicyType_REVIEW_RULE PolicyType = 7+ // Natural-language policy for the AI review. Allowed on WORKSPACE and PROJECT.+ PolicyType_REVIEW_AI PolicyType = 8)// Enum value maps for PolicyType.@@ -55,6 +57,7 @@ var (4: "TAG",6: "DATA_QUERY",7: "REVIEW_RULE",+ 8: "REVIEW_AI",}PolicyType_value = map[string]int32{"POLICY_TYPE_UNSPECIFIED": 0,@@ -64,6 +67,7 @@ var ("TAG": 4,"DATA_QUERY": 6,"REVIEW_RULE": 7,+ "REVIEW_AI": 8,})@@ -509,6 +513,7 @@ type Policy struct {// *Policy_TagPolicy// *Policy_QueryDataPolicy// *Policy_ReviewRulePolicy+ // *Policy_ReviewAiPolicyPolicy isPolicy_Policy `protobuf_oneof:"policy"`// Whether the policy is enforced.Enforce bool `protobuf:"varint,10,opt,name=enforce,proto3" json:"enforce,omitempty"`@@ -630,6 +635,15 @@ func (x *Policy) GetReviewRulePolicy() *ReviewRulePolicy {return nil}+func (x *Policy) GetReviewAiPolicy() *ReviewAIPolicy {+ if x != nil {+ if x, ok := x.Policy.(*Policy_ReviewAiPolicy); ok {+ return x.ReviewAiPolicy+ }+ }+ return nil+}+func (x *Policy) GetEnforce() bool {if x != nil {return x.Enforce@@ -672,6 +686,10 @@ type Policy_ReviewRulePolicy struct {ReviewRulePolicy *ReviewRulePolicy `protobuf:"bytes,12,opt,name=review_rule_policy,json=reviewRulePolicy,proto3,oneof"`}+type Policy_ReviewAiPolicy struct {+ ReviewAiPolicy *ReviewAIPolicy `protobuf:"bytes,13,opt,name=review_ai_policy,json=reviewAiPolicy,proto3,oneof"`+}+func (*Policy_RolloutPolicy) isPolicy_Policy() {}func (*Policy_MaskingRulePolicy) isPolicy_Policy() {}@@ -684,6 +702,8 @@ func (*Policy_QueryDataPolicy) isPolicy_Policy() {}func (*Policy_ReviewRulePolicy) isPolicy_Policy() {}+func (*Policy_ReviewAiPolicy) isPolicy_Policy() {}+// Standard review rule policy: the rules switched on. The nearest policy// wins: a project's own policy applies as is; a project without one uses// the workspace policy; with neither, every rule is on.@@ -736,6 +756,54 @@ func (x *ReviewRulePolicy) GetRules() []ReviewRuleType {return nil}+// Natural-language policy for the AI review. Unlike the review rule policy,+// both levels apply: the workspace policy and the project policy both reach+// the reviewer, and the project policy wins where they conflict.+type ReviewAIPolicy struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // The policy text. Must not be blank, at most 64 KiB.+ Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *ReviewAIPolicy) Reset() {+ *x = ReviewAIPolicy{}+ mi := &file_v1_org_policy_service_proto_msgTypes[8]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *ReviewAIPolicy) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*ReviewAIPolicy) ProtoMessage() {}++func (x *ReviewAIPolicy) ProtoReflect() protoreflect.Message {+ mi := &file_v1_org_policy_service_proto_msgTypes[8]+ 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 ReviewAIPolicy.ProtoReflect.Descriptor instead.+func (*ReviewAIPolicy) Descriptor() ([]byte, []int) {+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{8}+}++func (x *ReviewAIPolicy) GetContent() string {+ if x != nil {+ return x.Content+ }+ return ""+}+// Rollout policy configuration.type RolloutPolicy struct {state protoimpl.MessageState `protogen:"open.v1"`@@ -749,7 +817,7 @@ type RolloutPolicy struct {func (x *RolloutPolicy) Reset() {*x = RolloutPolicy{}- mi := &file_v1_org_policy_service_proto_msgTypes[8]+ mi := &file_v1_org_policy_service_proto_msgTypes[9]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -761,7 +829,7 @@ func (x *RolloutPolicy) String() string {func (*RolloutPolicy) ProtoMessage() {}func (x *RolloutPolicy) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[8]+ mi := &file_v1_org_policy_service_proto_msgTypes[9]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -774,7 +842,7 @@ func (x *RolloutPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use RolloutPolicy.ProtoReflect.Descriptor instead.func (*RolloutPolicy) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{8}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{9}}func (x *RolloutPolicy) GetAutomatic() bool {@@ -817,7 +885,7 @@ type QueryDataPolicy struct {func (x *QueryDataPolicy) Reset() {*x = QueryDataPolicy{}- mi := &file_v1_org_policy_service_proto_msgTypes[9]+ mi := &file_v1_org_policy_service_proto_msgTypes[10]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -829,7 +897,7 @@ func (x *QueryDataPolicy) String() string {func (*QueryDataPolicy) ProtoMessage() {}func (x *QueryDataPolicy) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[9]+ mi := &file_v1_org_policy_service_proto_msgTypes[10]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -842,7 +910,7 @@ func (x *QueryDataPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use QueryDataPolicy.ProtoReflect.Descriptor instead.func (*QueryDataPolicy) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{9}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{10}}func (x *QueryDataPolicy) GetMaximumResultRows() int32 {@@ -883,7 +951,7 @@ type MaskingExemptionPolicy struct {func (x *MaskingExemptionPolicy) Reset() {*x = MaskingExemptionPolicy{}- mi := &file_v1_org_policy_service_proto_msgTypes[10]+ mi := &file_v1_org_policy_service_proto_msgTypes[11]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -895,7 +963,7 @@ func (x *MaskingExemptionPolicy) String() string {func (*MaskingExemptionPolicy) ProtoMessage() {}func (x *MaskingExemptionPolicy) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[10]+ mi := &file_v1_org_policy_service_proto_msgTypes[11]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -908,7 +976,7 @@ func (x *MaskingExemptionPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingExemptionPolicy.ProtoReflect.Descriptor instead.func (*MaskingExemptionPolicy) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{10}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{11}}func (x *MaskingExemptionPolicy) GetExemptions() []*MaskingExemptionPolicy_Exemption {@@ -929,7 +997,7 @@ type MaskingRulePolicy struct {func (x *MaskingRulePolicy) Reset() {*x = MaskingRulePolicy{}- mi := &file_v1_org_policy_service_proto_msgTypes[11]+ mi := &file_v1_org_policy_service_proto_msgTypes[12]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -941,7 +1009,7 @@ func (x *MaskingRulePolicy) String() string {func (*MaskingRulePolicy) ProtoMessage() {}func (x *MaskingRulePolicy) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[11]+ mi := &file_v1_org_policy_service_proto_msgTypes[12]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -954,7 +1022,7 @@ func (x *MaskingRulePolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingRulePolicy.ProtoReflect.Descriptor instead.func (*MaskingRulePolicy) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{11}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{12}}func (x *MaskingRulePolicy) GetRules() []*MaskingRulePolicy_MaskingRule {@@ -976,7 +1044,7 @@ type TagPolicy struct {func (x *TagPolicy) Reset() {*x = TagPolicy{}- mi := &file_v1_org_policy_service_proto_msgTypes[12]+ mi := &file_v1_org_policy_service_proto_msgTypes[13]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -988,7 +1056,7 @@ func (x *TagPolicy) String() string {func (*TagPolicy) ProtoMessage() {}func (x *TagPolicy) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[12]+ mi := &file_v1_org_policy_service_proto_msgTypes[13]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1001,7 +1069,7 @@ func (x *TagPolicy) ProtoReflect() protoreflect.Message {// Deprecated: Use TagPolicy.ProtoReflect.Descriptor instead.func (*TagPolicy) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{12}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{13}}func (x *TagPolicy) GetTags() map[string]string {@@ -1042,7 +1110,7 @@ type MaskingExemptionPolicy_Exemption struct {func (x *MaskingExemptionPolicy_Exemption) Reset() {*x = MaskingExemptionPolicy_Exemption{}- mi := &file_v1_org_policy_service_proto_msgTypes[13]+ mi := &file_v1_org_policy_service_proto_msgTypes[14]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1054,7 +1122,7 @@ func (x *MaskingExemptionPolicy_Exemption) String() string {func (*MaskingExemptionPolicy_Exemption) ProtoMessage() {}func (x *MaskingExemptionPolicy_Exemption) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[13]+ mi := &file_v1_org_policy_service_proto_msgTypes[14]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1067,7 +1135,7 @@ func (x *MaskingExemptionPolicy_Exemption) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingExemptionPolicy_Exemption.ProtoReflect.Descriptor instead.func (*MaskingExemptionPolicy_Exemption) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{10, 0}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{11, 0}}func (x *MaskingExemptionPolicy_Exemption) GetMembers() []string {@@ -1122,7 +1190,7 @@ type MaskingRulePolicy_MaskingRule struct {func (x *MaskingRulePolicy_MaskingRule) Reset() {*x = MaskingRulePolicy_MaskingRule{}- mi := &file_v1_org_policy_service_proto_msgTypes[14]+ mi := &file_v1_org_policy_service_proto_msgTypes[15]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1134,7 +1202,7 @@ func (x *MaskingRulePolicy_MaskingRule) String() string {func (*MaskingRulePolicy_MaskingRule) ProtoMessage() {}func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {- mi := &file_v1_org_policy_service_proto_msgTypes[14]+ mi := &file_v1_org_policy_service_proto_msgTypes[15]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1147,7 +1215,7 @@ func (x *MaskingRulePolicy_MaskingRule) ProtoReflect() protoreflect.Message {// Deprecated: Use MaskingRulePolicy_MaskingRule.ProtoReflect.Descriptor instead.func (*MaskingRulePolicy_MaskingRule) Descriptor() ([]byte, []int) {- return file_v1_org_policy_service_proto_rawDescGZIP(), []int{11, 0}+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{12, 0}}func (x *MaskingRulePolicy_MaskingRule) GetId() string {@@ -1198,7 +1266,7 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\fshow_deleted\x18\x03 \x01(\bR\vshowDeletedB\x0e\n" +"\f_policy_type\"G\n" +"\x14ListPoliciesResponse\x12/\n" +- "\bpolicies\x18\x01 \x03(\v2\x13.bytebase.v1.PolicyR\bpolicies\"\xd4\x06\n" ++ "\bpolicies\x18\x01 \x03(\v2\x13.bytebase.v1.PolicyR\bpolicies\"\x9d\a\n" +"\x06Policy\x12\x12\n" +"\x04name\x18\x01 \x01(\tR\x04name\x12.\n" +"\x13inherit_from_parent\x18\x02 \x01(\bR\x11inheritFromParent\x12+\n" +@@ -1209,14 +1277,17 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\n" +"tag_policy\x18\a \x01(\v2\x16.bytebase.v1.TagPolicyH\x00R\ttagPolicy\x12J\n" +"\x11query_data_policy\x18\t \x01(\v2\x1c.bytebase.v1.QueryDataPolicyH\x00R\x0fqueryDataPolicy\x12M\n" +- "\x12review_rule_policy\x18\f \x01(\v2\x1d.bytebase.v1.ReviewRulePolicyH\x00R\x10reviewRulePolicy\x12\x18\n" ++ "\x12review_rule_policy\x18\f \x01(\v2\x1d.bytebase.v1.ReviewRulePolicyH\x00R\x10reviewRulePolicy\x12G\n" ++ "\x10review_ai_policy\x18\r \x01(\v2\x1b.bytebase.v1.ReviewAIPolicyH\x00R\x0ereviewAiPolicy\x12\x18\n" +"\aenforce\x18\n" +" \x01(\bR\aenforce\x12I\n" +"\rresource_type\x18\v \x01(\x0e2\x1f.bytebase.v1.PolicyResourceTypeB\x03\xe0A\x03R\fresourceType:\x97\x01\xeaA\x93\x01\n" +"\x13bytebase.com/Policy\x12(workspaces/{workspace}/policies/{policy}\x12$projects/{project}/policies/{policy}\x12,environments/{environment}/policies/{policy}B\b\n" +"\x06policyJ\x04\b\b\x10\t\"E\n" +"\x10ReviewRulePolicy\x121\n" +- "\x05rules\x18\x01 \x03(\x0e2\x1b.bytebase.v1.ReviewRuleTypeR\x05rules\"C\n" ++ "\x05rules\x18\x01 \x03(\x0e2\x1b.bytebase.v1.ReviewRuleTypeR\x05rules\"*\n" ++ "\x0eReviewAIPolicy\x12\x18\n" ++ "\acontent\x18\x01 \x01(\tR\acontent\"C\n" +"\rRolloutPolicy\x12\x1c\n" +"\tautomatic\x18\x01 \x01(\bR\tautomatic\x12\x14\n" +"\x05roles\x18\x02 \x03(\tR\x05roles\"\xcb\x01\n" +@@ -1242,7 +1313,7 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\x04tags\x18\x01 \x03(\v2 .bytebase.v1.TagPolicy.TagsEntryR\x04tags\x1a7\n" +"\tTagsEntry\x12\x10\n" +"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +- "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01*\x96\x01\n" ++ "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01*\xa5\x01\n" +"\n" +"PolicyType\x12\x1b\n" +"\x17POLICY_TYPE_UNSPECIFIED\x10\x00\x12\x10\n" +@@ -1252,7 +1323,8 @@ const file_v1_org_policy_service_proto_rawDesc = "" +"\x03TAG\x10\x04\x12\x0e\n" +"\n" +"DATA_QUERY\x10\x06\x12\x0f\n" +- "\vREVIEW_RULE\x10\a\"\x04\b\x05\x10\x05*`\n" ++ "\vREVIEW_RULE\x10\a\x12\r\n" ++ "\tREVIEW_AI\x10\b\"\x04\b\x05\x10\x05*`\n" +"\x12PolicyResourceType\x12\x1d\n" +"\x19RESOURCE_TYPE_UNSPECIFIED\x10\x00\x12\r\n" +"\tWORKSPACE\x10\x01\x12\x0f\n" +@@ -1280,7 +1352,7 @@ func file_v1_org_policy_service_proto_rawDescGZIP() []byte {}var file_v1_org_policy_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)-var file_v1_org_policy_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16)+var file_v1_org_policy_service_proto_msgTypes = make([]protoimpl.MessageInfo, 17)var file_v1_org_policy_service_proto_goTypes = []any{(PolicyType)(0), // 0: bytebase.v1.PolicyType(PolicyResourceType)(0), // 1: bytebase.v1.PolicyResourceType@@ -1292,55 +1364,57 @@ var file_v1_org_policy_service_proto_goTypes = []any{(*ListPoliciesResponse)(nil), // 7: bytebase.v1.ListPoliciesResponse(*Policy)(nil), // 8: bytebase.v1.Policy(*ReviewRulePolicy)(nil), // 9: bytebase.v1.ReviewRulePolicy- (*RolloutPolicy)(nil), // 10: bytebase.v1.RolloutPolicy- (*QueryDataPolicy)(nil), // 11: bytebase.v1.QueryDataPolicy- (*MaskingExemptionPolicy)(nil), // 12: bytebase.v1.MaskingExemptionPolicy- (*MaskingRulePolicy)(nil), // 13: bytebase.v1.MaskingRulePolicy- (*TagPolicy)(nil), // 14: bytebase.v1.TagPolicy- (*MaskingExemptionPolicy_Exemption)(nil), // 15: bytebase.v1.MaskingExemptionPolicy.Exemption- (*MaskingRulePolicy_MaskingRule)(nil), // 16: bytebase.v1.MaskingRulePolicy.MaskingRule- nil, // 17: bytebase.v1.TagPolicy.TagsEntry- (*fieldmaskpb.FieldMask)(nil), // 18: google.protobuf.FieldMask- (ReviewRuleType)(0), // 19: bytebase.v1.ReviewRuleType- (*expr.Expr)(nil), // 20: google.type.Expr- (*emptypb.Empty)(nil), // 21: google.protobuf.Empty+ (*ReviewAIPolicy)(nil), // 10: bytebase.v1.ReviewAIPolicy+ (*RolloutPolicy)(nil), // 11: bytebase.v1.RolloutPolicy+ (*QueryDataPolicy)(nil), // 12: bytebase.v1.QueryDataPolicy+ (*MaskingExemptionPolicy)(nil), // 13: bytebase.v1.MaskingExemptionPolicy+ (*MaskingRulePolicy)(nil), // 14: bytebase.v1.MaskingRulePolicy+ (*TagPolicy)(nil), // 15: bytebase.v1.TagPolicy+ (*MaskingExemptionPolicy_Exemption)(nil), // 16: bytebase.v1.MaskingExemptionPolicy.Exemption+ (*MaskingRulePolicy_MaskingRule)(nil), // 17: bytebase.v1.MaskingRulePolicy.MaskingRule+ nil, // 18: bytebase.v1.TagPolicy.TagsEntry+ (*fieldmaskpb.FieldMask)(nil), // 19: google.protobuf.FieldMask+ (ReviewRuleType)(0), // 20: bytebase.v1.ReviewRuleType+ (*expr.Expr)(nil), // 21: google.type.Expr+ (*emptypb.Empty)(nil), // 22: google.protobuf.Empty}var file_v1_org_policy_service_proto_depIdxs = []int32{8, // 0: bytebase.v1.CreatePolicyRequest.policy:type_name -> bytebase.v1.Policy0, // 1: bytebase.v1.CreatePolicyRequest.type:type_name -> bytebase.v1.PolicyType8, // 2: bytebase.v1.UpdatePolicyRequest.policy:type_name -> bytebase.v1.Policy- 18, // 3: bytebase.v1.UpdatePolicyRequest.update_mask:type_name -> google.protobuf.FieldMask+ 19, // 3: bytebase.v1.UpdatePolicyRequest.update_mask:type_name -> google.protobuf.FieldMask0, // 4: bytebase.v1.ListPoliciesRequest.policy_type:type_name -> bytebase.v1.PolicyType8, // 5: bytebase.v1.ListPoliciesResponse.policies:type_name -> bytebase.v1.Policy0, // 6: bytebase.v1.Policy.type:type_name -> bytebase.v1.PolicyType- 10, // 7: bytebase.v1.Policy.rollout_policy:type_name -> bytebase.v1.RolloutPolicy- 13, // 8: bytebase.v1.Policy.masking_rule_policy:type_name -> bytebase.v1.MaskingRulePolicy- 12, // 9: bytebase.v1.Policy.masking_exemption_policy:type_name -> bytebase.v1.MaskingExemptionPolicy- 14, // 10: bytebase.v1.Policy.tag_policy:type_name -> bytebase.v1.TagPolicy- 11, // 11: bytebase.v1.Policy.query_data_policy:type_name -> bytebase.v1.QueryDataPolicy+ 11, // 7: bytebase.v1.Policy.rollout_policy:type_name -> bytebase.v1.RolloutPolicy+ 14, // 8: bytebase.v1.Policy.masking_rule_policy:type_name -> bytebase.v1.MaskingRulePolicy+ 13, // 9: bytebase.v1.Policy.masking_exemption_policy:type_name -> bytebase.v1.MaskingExemptionPolicy+ 15, // 10: bytebase.v1.Policy.tag_policy:type_name -> bytebase.v1.TagPolicy+ 12, // 11: bytebase.v1.Policy.query_data_policy:type_name -> bytebase.v1.QueryDataPolicy9, // 12: bytebase.v1.Policy.review_rule_policy:type_name -> bytebase.v1.ReviewRulePolicy- 1, // 13: bytebase.v1.Policy.resource_type:type_name -> bytebase.v1.PolicyResourceType- 19, // 14: bytebase.v1.ReviewRulePolicy.rules:type_name -> bytebase.v1.ReviewRuleType- 15, // 15: bytebase.v1.MaskingExemptionPolicy.exemptions:type_name -> bytebase.v1.MaskingExemptionPolicy.Exemption- 16, // 16: bytebase.v1.MaskingRulePolicy.rules:type_name -> bytebase.v1.MaskingRulePolicy.MaskingRule- 17, // 17: bytebase.v1.TagPolicy.tags:type_name -> bytebase.v1.TagPolicy.TagsEntry- 20, // 18: bytebase.v1.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr- 20, // 19: bytebase.v1.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr- 5, // 20: bytebase.v1.OrgPolicyService.GetPolicy:input_type -> bytebase.v1.GetPolicyRequest- 6, // 21: bytebase.v1.OrgPolicyService.ListPolicies:input_type -> bytebase.v1.ListPoliciesRequest- 2, // 22: bytebase.v1.OrgPolicyService.CreatePolicy:input_type -> bytebase.v1.CreatePolicyRequest- 3, // 23: bytebase.v1.OrgPolicyService.UpdatePolicy:input_type -> bytebase.v1.UpdatePolicyRequest- 4, // 24: bytebase.v1.OrgPolicyService.DeletePolicy:input_type -> bytebase.v1.DeletePolicyRequest- 8, // 25: bytebase.v1.OrgPolicyService.GetPolicy:output_type -> bytebase.v1.Policy- 7, // 26: bytebase.v1.OrgPolicyService.ListPolicies:output_type -> bytebase.v1.ListPoliciesResponse- 8, // 27: bytebase.v1.OrgPolicyService.CreatePolicy:output_type -> bytebase.v1.Policy- 8, // 28: bytebase.v1.OrgPolicyService.UpdatePolicy:output_type -> bytebase.v1.Policy- 21, // 29: bytebase.v1.OrgPolicyService.DeletePolicy:output_type -> google.protobuf.Empty- 25, // [25:30] is the sub-list for method output_type- 20, // [20:25] is the sub-list for method input_type- 20, // [20:20] is the sub-list for extension type_name- 20, // [20:20] is the sub-list for extension extendee- 0, // [0:20] is the sub-list for field type_name+ 10, // 13: bytebase.v1.Policy.review_ai_policy:type_name -> bytebase.v1.ReviewAIPolicy+ 1, // 14: bytebase.v1.Policy.resource_type:type_name -> bytebase.v1.PolicyResourceType+ 20, // 15: bytebase.v1.ReviewRulePolicy.rules:type_name -> bytebase.v1.ReviewRuleType+ 16, // 16: bytebase.v1.MaskingExemptionPolicy.exemptions:type_name -> bytebase.v1.MaskingExemptionPolicy.Exemption+ 17, // 17: bytebase.v1.MaskingRulePolicy.rules:type_name -> bytebase.v1.MaskingRulePolicy.MaskingRule+ 18, // 18: bytebase.v1.TagPolicy.tags:type_name -> bytebase.v1.TagPolicy.TagsEntry+ 21, // 19: bytebase.v1.MaskingExemptionPolicy.Exemption.condition:type_name -> google.type.Expr+ 21, // 20: bytebase.v1.MaskingRulePolicy.MaskingRule.condition:type_name -> google.type.Expr+ 5, // 21: bytebase.v1.OrgPolicyService.GetPolicy:input_type -> bytebase.v1.GetPolicyRequest+ 6, // 22: bytebase.v1.OrgPolicyService.ListPolicies:input_type -> bytebase.v1.ListPoliciesRequest+ 2, // 23: bytebase.v1.OrgPolicyService.CreatePolicy:input_type -> bytebase.v1.CreatePolicyRequest+ 3, // 24: bytebase.v1.OrgPolicyService.UpdatePolicy:input_type -> bytebase.v1.UpdatePolicyRequest+ 4, // 25: bytebase.v1.OrgPolicyService.DeletePolicy:input_type -> bytebase.v1.DeletePolicyRequest+ 8, // 26: bytebase.v1.OrgPolicyService.GetPolicy:output_type -> bytebase.v1.Policy+ 7, // 27: bytebase.v1.OrgPolicyService.ListPolicies:output_type -> bytebase.v1.ListPoliciesResponse+ 8, // 28: bytebase.v1.OrgPolicyService.CreatePolicy:output_type -> bytebase.v1.Policy+ 8, // 29: bytebase.v1.OrgPolicyService.UpdatePolicy:output_type -> bytebase.v1.Policy+ 22, // 30: bytebase.v1.OrgPolicyService.DeletePolicy:output_type -> google.protobuf.Empty+ 26, // [26:31] is the sub-list for method output_type+ 21, // [21:26] is the sub-list for method input_type+ 21, // [21:21] is the sub-list for extension type_name+ 21, // [21:21] is the sub-list for extension extendee+ 0, // [0:21] is the sub-list for field type_name}func init() { file_v1_org_policy_service_proto_init() }@@ -1358,6 +1432,7 @@ func file_v1_org_policy_service_proto_init() {(*Policy_TagPolicy)(nil),(*Policy_QueryDataPolicy)(nil),(*Policy_ReviewRulePolicy)(nil),+ (*Policy_ReviewAiPolicy)(nil),}type x struct{}out := protoimpl.TypeBuilder{@@ -1365,7 +1440,7 @@ func file_v1_org_policy_service_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_org_policy_service_proto_rawDesc), len(file_v1_org_policy_service_proto_rawDesc)),NumEnums: 2,- NumMessages: 16,+ NumMessages: 17,NumExtensions: 0,NumServices: 1,},diff --git a/backend/generated-go/v1/org_policy_service_equal.pb.go b/backend/generated-go/v1/org_policy_service_equal.pb.goindex 62fb144cf2..924473eefa 100644--- a/backend/generated-go/v1/org_policy_service_equal.pb.go+++ b/backend/generated-go/v1/org_policy_service_equal.pb.go@@ -148,6 +148,9 @@ func (x *Policy) Equal(y *Policy) bool {if !x.GetReviewRulePolicy().Equal(y.GetReviewRulePolicy()) {return false}+ if !x.GetReviewAiPolicy().Equal(y.GetReviewAiPolicy()) {+ return false+ }if x.Enforce != y.Enforce {return false}@@ -175,6 +178,19 @@ func (x *ReviewRulePolicy) Equal(y *ReviewRulePolicy) bool {return true}+func (x *ReviewAIPolicy) Equal(y *ReviewAIPolicy) bool {+ if x == y {+ return true+ }+ if x == nil || y == nil {+ return x == nil && y == nil+ }+ if x.Content != y.Content {+ return false+ }+ return true+}+func (x *RolloutPolicy) Equal(y *RolloutPolicy) bool {if x == y {return truediff --git a/backend/migrator/migration/3.23/0000##review_run.sql b/backend/migrator/migration/3.23/0000##review_run.sqlindex ef303de363..a6717b4c6d 100644--- a/backend/migrator/migration/3.23/0000##review_run.sql+++ b/backend/migrator/migration/3.23/0000##review_run.sql@@ -5,9 +5,9 @@CREATE TABLE review_run (project text NOT NULL REFERENCES project(resource_id),issue_id bigint NOT NULL,- -- Reviewer type: 'RULE' (standard rules) or 'AI' (the AI review policy's- -- natural-language instructions, judged by a model). No CHECK on purpose:- -- the reviewer-id space is open.+ -- Reviewer type: 'RULE' (standard rules) or 'AI' (the natural-language AI+ -- review policy, judged by a model). No CHECK on purpose: the reviewer-id+ -- space is open.type text NOT NULL,created_at timestamptz NOT NULL DEFAULT now(),updated_at timestamptz NOT NULL DEFAULT now(),diff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sqlindex 896413fd02..9ac55a974d 100644--- a/backend/migrator/migration/LATEST.sql+++ b/backend/migrator/migration/LATEST.sql@@ -116,7 +116,7 @@ CREATE TABLE policy (resource_type text NOT NULL,-- resource: resource name in format like "environments/{environment}", "projects/{project}", etc.resource TEXT NOT NULL,- -- type: ROLLOUT, MASKING_EXCEPTION, QUERY_DATA, MASKING_RULE, IAM, TAG, REVIEW_RULE+ -- type: ROLLOUT, MASKING_EXCEPTION, QUERY_DATA, MASKING_RULE, IAM, TAG, REVIEW_RULE, REVIEW_AI-- Enum: Policy.Type (proto/store/store/policy.proto)type text NOT NULL,-- Stored as different types based on policy type (proto/store/store/policy.proto):@@ -127,6 +127,7 @@ CREATE TABLE policy (-- IAM: IamPolicy-- TAG: TagPolicy-- REVIEW_RULE: ReviewRulePolicy (the standard review rules switched on; nearest policy wins)+ -- REVIEW_AI: ReviewAIPolicy (the natural-language policy for the AI review; workspace and project both apply, project wins on conflict)payload jsonb NOT NULL DEFAULT '{}',inherit_from_parent boolean NOT NULL DEFAULT TRUE,PRIMARY KEY (workspace, resource_type, resource, type)@@ -393,9 +394,9 @@ CREATE INDEX idx_issue_comment_open_thread ON issue_comment(project, issue_id)CREATE TABLE review_run (project text NOT NULL REFERENCES project(resource_id),issue_id bigint NOT NULL,- -- Reviewer type: 'RULE' (standard rules) or 'AI' (the AI review policy's- -- natural-language instructions, judged by a model). No CHECK on purpose:- -- the reviewer-id space is open.+ -- Reviewer type: 'RULE' (standard rules) or 'AI' (the natural-language AI+ -- review policy, judged by a model). No CHECK on purpose: the reviewer-id+ -- space is open.type text NOT NULL,created_at timestamptz NOT NULL DEFAULT now(),updated_at timestamptz NOT NULL DEFAULT now(),diff --git a/backend/runner/reviewrun/ai_review_executor.go b/backend/runner/reviewrun/ai_review_executor.goindex ae6dd53440..a442f0b07d 100644--- a/backend/runner/reviewrun/ai_review_executor.go+++ b/backend/runner/reviewrun/ai_review_executor.go@@ -9,7 +9,7 @@ import ()// AIReviewExecutor is the AI review: a model judges the change against the-// natural-language instructions of the AI review policy.+// natural-language AI review policy.//// Not implemented yet: the evaluation lands with the AI review design. A// claimed AI run must still reach a terminal status, so it fails honestlydiff --git a/backend/store/policy.go b/backend/store/policy.goindex aac99fea5f..f70d8e1c8f 100644--- a/backend/store/policy.go+++ b/backend/store/policy.go@@ -526,6 +526,50 @@ func (s *Store) getReviewRulePolicy(ctx context.Context, workspaceID string, resreturn p, nil}+// EffectiveReviewAIPolicy is the AI review policy text in force for a project.+// Both levels apply: the reviewer reads the workspace policy and the project+// policy, and the project policy wins where they conflict. A level without an+// enforced policy is the empty string.+type EffectiveReviewAIPolicy struct {+ Workspace string+ Project string+}++// GetEffectiveReviewAIPolicy returns the policy text of both levels.+func (s *Store) GetEffectiveReviewAIPolicy(ctx context.Context, workspaceID string, projectID string) (*EffectiveReviewAIPolicy, error) {+ workspace, err := s.getReviewAIPolicyContent(ctx, workspaceID, storepb.Policy_WORKSPACE, common.FormatWorkspace(workspaceID))+ if err != nil {+ return nil, err+ }+ project, err := s.getReviewAIPolicyContent(ctx, workspaceID, storepb.Policy_PROJECT, common.FormatProject(projectID))+ if err != nil {+ return nil, err+ }+ return &EffectiveReviewAIPolicy{Workspace: workspace, Project: project}, nil+}++// getReviewAIPolicyContent returns "" when the resource has no enforced AI+// review policy.+func (s *Store) getReviewAIPolicyContent(ctx context.Context, workspaceID string, resourceType storepb.Policy_Resource, resource string) (string, error) {+ policy, err := s.GetPolicy(ctx, &FindPolicyMessage{+ Workspace: workspaceID,+ ResourceType: &resourceType,+ Resource: &resource,+ Type: new(storepb.Policy_REVIEW_AI),+ })+ if err != nil {+ return "", errors.Wrapf(err, "failed to get AI review policy for %s", resource)+ }+ if policy == nil || !policy.Enforce {+ return "", nil+ }+ p := &storepb.ReviewAIPolicy{}+ if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(policy.Payload), p); err != nil {+ return "", errors.Wrapf(err, "failed to unmarshal AI review policy for %s", resource)+ }+ return p.Content, nil+}+type reviewConfigResource struct {resourceType storepb.Policy_Resourceresource stringdiff --git a/backend/store/policy_review_ai_test.go b/backend/store/policy_review_ai_test.gonew file mode 100644index 0000000000..7bcfaf5c03--- /dev/null+++ b/backend/store/policy_review_ai_test.go@@ -0,0 +1,78 @@+package store_test++import (+ "context"+ "testing"++ "github.com/stretchr/testify/require"+ "google.golang.org/protobuf/encoding/protojson"++ "github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/common/testcontainer"+ storepb "github.com/bytebase/bytebase/backend/generated-go/store"+ "github.com/bytebase/bytebase/backend/store"++ _ "github.com/bytebase/bytebase/backend/plugin/db/pg"+)++// TestGetEffectiveReviewAIPolicy pins that both levels apply: the workspace+// and the project policy come back side by side, a level without a policy+// or with one that is not enforced is empty, and another workspace's rows+// under the same resource names never leak in.+func TestGetEffectiveReviewAIPolicy(t *testing.T) {+ t.Parallel()+ ctx := context.Background()+ db, stores, _ := testcontainer.NewMetadataDB(t)+ _, err := db.ExecContext(ctx, `+ INSERT INTO workspace (resource_id) VALUES ('ws'), ('other');+ INSERT INTO project (resource_id, workspace, name) VALUES ('p', 'ws', 'P');+ `)+ require.NoError(t, err)++ upsert := func(workspace string, resourceType storepb.Policy_Resource, resource string, enforce bool, content string) {+ payload, err := protojson.Marshal(&storepb.ReviewAIPolicy{Content: content})+ require.NoError(t, err)+ _, err = stores.CreatePolicy(ctx, &store.PolicyMessage{+ Workspace: workspace,+ ResourceType: resourceType,+ Resource: resource,+ Type: storepb.Policy_REVIEW_AI,+ Payload: string(payload),+ Enforce: enforce,+ })+ require.NoError(t, err)+ }+ effective := func(workspace string) *store.EffectiveReviewAIPolicy {+ p, err := stores.GetEffectiveReviewAIPolicy(ctx, workspace, "p")+ require.NoError(t, err)+ return p+ }++ // Neither level has a policy.+ require.Equal(t, &store.EffectiveReviewAIPolicy{}, effective("ws"))++ // Workspace only.+ upsert("ws", storepb.Policy_WORKSPACE, common.FormatWorkspace("ws"), true, "W1")+ require.Equal(t, &store.EffectiveReviewAIPolicy{Workspace: "W1"}, effective("ws"))++ // Both levels come back side by side; the reviewer, not the store, merges them.+ upsert("ws", storepb.Policy_PROJECT, common.FormatProject("p"), true, "P1")+ require.Equal(t, &store.EffectiveReviewAIPolicy{Workspace: "W1", Project: "P1"}, effective("ws"))++ // A project policy that is not enforced counts as absent.+ upsert("ws", storepb.Policy_PROJECT, common.FormatProject("p"), false, "P1")+ require.Equal(t, &store.EffectiveReviewAIPolicy{Workspace: "W1"}, effective("ws"))++ // Same for the workspace.+ upsert("ws", storepb.Policy_PROJECT, common.FormatProject("p"), true, "P2")+ upsert("ws", storepb.Policy_WORKSPACE, common.FormatWorkspace("ws"), false, "W1")+ require.Equal(t, &store.EffectiveReviewAIPolicy{Project: "P2"}, effective("ws"))++ // The policy key is (workspace, resource_type, resource, type): rows of+ // another workspace under the same resource names are a different key and+ // never leak in, in either direction.+ upsert("other", storepb.Policy_WORKSPACE, common.FormatWorkspace("other"), true, "OW")+ upsert("other", storepb.Policy_PROJECT, common.FormatProject("p"), true, "OP")+ require.Equal(t, &store.EffectiveReviewAIPolicy{Project: "P2"}, effective("ws"))+ require.Equal(t, &store.EffectiveReviewAIPolicy{Workspace: "OW", Project: "OP"}, effective("other"))+}diff --git a/backend/store/review_run.go b/backend/store/review_run.goindex f38616982e..f7609b4953 100644--- a/backend/store/review_run.go+++ b/backend/store/review_run.go@@ -18,8 +18,8 @@ import (const (// ReviewRunTypeRule reviews against the standard rules.ReviewRunTypeRule = "RULE"- // ReviewRunTypeAI reviews against the AI review policy's natural-language- // instructions, judged by a model.+ // ReviewRunTypeAI reviews against the natural-language AI review policy,+ // judged by a model.ReviewRunTypeAI = "AI")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.tsindex 70db3c34f2..4a4ca1c4a4 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@@ -1430,8 +1430,8 @@ export enum ReviewRun_Type {RULE = 1,/**- * Review against the AI review policy's natural-language instructions,- * performed by a model.+ * Review against the natural-language AI review policy, performed by a+ * model.** @generated from enum value: AI = 2;*/diff --git a/frontend/src/types/proto-es/v1/org_policy_service_pb.d.ts b/frontend/src/types/proto-es/v1/org_policy_service_pb.d.tsindex 2e3a2dfae3..9ee88552b8 100644--- a/frontend/src/types/proto-es/v1/org_policy_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/org_policy_service_pb.d.ts@@ -245,6 +245,12 @@ export declare type Policy = Message<"bytebase.v1.Policy"> & {*/value: ReviewRulePolicy;case: "reviewRulePolicy";+ } | {+ /**+ * @generated from field: bytebase.v1.ReviewAIPolicy review_ai_policy = 13;+ */+ value: ReviewAIPolicy;+ case: "reviewAiPolicy";} | { case: undefined; value?: undefined };/**@@ -294,6 +300,28 @@ export declare type ReviewRulePolicy = Message<"bytebase.v1.ReviewRulePolicy"> &*/export declare const ReviewRulePolicySchema: GenMessage<ReviewRulePolicy>;+/**+ * Natural-language policy for the AI review. Unlike the review rule policy,+ * both levels apply: the workspace policy and the project policy both reach+ * the reviewer, and the project policy wins where they conflict.+ *+ * @generated from message bytebase.v1.ReviewAIPolicy+ */+export declare type ReviewAIPolicy = Message<"bytebase.v1.ReviewAIPolicy"> & {+ /**+ * The policy text. Must not be blank, at most 64 KiB.+ *+ * @generated from field: string content = 1;+ */+ content: string;+};++/**+ * Describes the message bytebase.v1.ReviewAIPolicy.+ * Use `create(ReviewAIPolicySchema)` to create a new message.+ */+export declare const ReviewAIPolicySchema: GenMessage<ReviewAIPolicy>;+/*** Rollout policy configuration.*@@ -585,6 +613,13 @@ export enum PolicyType {* @generated from enum value: REVIEW_RULE = 7;*/REVIEW_RULE = 7,++ /**+ * Natural-language policy for the AI review. Allowed on WORKSPACE and PROJECT.+ *+ * @generated from enum value: REVIEW_AI = 8;+ */+ REVIEW_AI = 8,}/**diff --git a/frontend/src/types/proto-es/v1/org_policy_service_pb.js b/frontend/src/types/proto-es/v1/org_policy_service_pb.jsindex 52f8d0597e..c4edcee586 100644--- a/frontend/src/types/proto-es/v1/org_policy_service_pb.js+++ b/frontend/src/types/proto-es/v1/org_policy_service_pb.js@@ -16,7 +16,7 @@ import { file_v1_review_rule } from "./review_rule_pb";* Describes the file v1/org_policy_service.proto.*/export const file_v1_org_policy_service = /*@__PURE__*/- fileDesc("Cht2MS9vcmdfcG9saWN5X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIpMBChNDcmVhdGVQb2xpY3lSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EigKBnBvbGljeRgCIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEiUKBHR5cGUYAyABKA4yFy5ieXRlYmFzZS52MS5Qb2xpY3lUeXBlIocBChNVcGRhdGVQb2xpY3lSZXF1ZXN0EigKBnBvbGljeRgBIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIVCg1hbGxvd19taXNzaW5nGAMgASgIIkAKE0RlbGV0ZVBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5Ij0KEEdldFBvbGljeVJlcXV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uY29tL2J5dGViYXNlL2J5dGViYXNlL2JhY2tlbmQvZ2VuZXJhdGVkLWdvL3YxogIDQlhYqgILQnl0ZWJhc2UuVjHKAgtCeXRlYmFzZVxWMeICF0J5dGViYXNlXFYxXEdQQk1ldGFkYXRh6gIMQnl0ZWJhc2U6OlYxYgZwcm90bzM", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation, file_v1_review_rule]);+ fileDesc("Cht2MS9vcmdfcG9saWN5X3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIpMBChNDcmVhdGVQb2xpY3lSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EigKBnBvbGljeRgCIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEiUKBHR5cGUYAyABKA4yFy5ieXRlYmFzZS52MS5Qb2xpY3lUeXBlIocBChNVcGRhdGVQb2xpY3lSZXF1ZXN0EigKBnBvbGljeRgBIAEoCzITLmJ5dGViYXNlLnYxLlBvbGljeUID4EECEi8KC3VwZGF0ZV9tYXNrGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLkZpZWxkTWFzaxIVCg1hbGxvd19taXNzaW5nGAMgASgIIkAKE0RlbGV0ZVBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5Ij0KEEdldFBvbGljeVJlcXVlc3QSKQoEbmFtZRgBIAEoCUIb4EEC+kEVChNieXRlYmFzZS5jb20vUG9saWN5IpsBChNMaXN0UG9saWNpZXNSZXF1ZXN0EisKBnBhcmVudBgBIAEoCUIb4EEC+kEVEhNieXRlYmFzZS5jb20vUG9saWN5EjEKC3BvbGljeV90eXBlGAIgASgOMhcuYnl0ZWJhc2UudjEuUG9saWN5VHlwZUgAiAEBEhQKDHNob3dfZGVsZXRlZBgDIAE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0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_type_expr, file_v1_annotation, file_v1_review_rule]);/*** Describes the message bytebase.v1.CreatePolicyRequest.@@ -74,54 +74,61 @@ export const PolicySchema = /*@__PURE__*/export const ReviewRulePolicySchema = /*@__PURE__*/messageDesc(file_v1_org_policy_service, 7);+/**+ * Describes the message bytebase.v1.ReviewAIPolicy.+ * Use `create(ReviewAIPolicySchema)` to create a new message.+ */+export const ReviewAIPolicySchema = /*@__PURE__*/+ messageDesc(file_v1_org_policy_service, 8);+/*** Describes the message bytebase.v1.RolloutPolicy.* Use `create(RolloutPolicySchema)` to create a new message.*/export const RolloutPolicySchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 8);+ messageDesc(file_v1_org_policy_service, 9);/*** Describes the message bytebase.v1.QueryDataPolicy.* Use `create(QueryDataPolicySchema)` to create a new message.*/export const QueryDataPolicySchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 9);+ messageDesc(file_v1_org_policy_service, 10);/*** Describes the message bytebase.v1.MaskingExemptionPolicy.* Use `create(MaskingExemptionPolicySchema)` to create a new message.*/export const MaskingExemptionPolicySchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 10);+ messageDesc(file_v1_org_policy_service, 11);/*** Describes the message bytebase.v1.MaskingExemptionPolicy.Exemption.* Use `create(MaskingExemptionPolicy_ExemptionSchema)` to create a new message.*/export const MaskingExemptionPolicy_ExemptionSchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 10, 0);+ messageDesc(file_v1_org_policy_service, 11, 0);/*** Describes the message bytebase.v1.MaskingRulePolicy.* Use `create(MaskingRulePolicySchema)` to create a new message.*/export const MaskingRulePolicySchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 11);+ messageDesc(file_v1_org_policy_service, 12);/*** Describes the message bytebase.v1.MaskingRulePolicy.MaskingRule.* Use `create(MaskingRulePolicy_MaskingRuleSchema)` to create a new message.*/export const MaskingRulePolicy_MaskingRuleSchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 11, 0);+ messageDesc(file_v1_org_policy_service, 12, 0);/*** Describes the message bytebase.v1.TagPolicy.* Use `create(TagPolicySchema)` to create a new message.*/export const TagPolicySchema = /*@__PURE__*/- messageDesc(file_v1_org_policy_service, 12);+ messageDesc(file_v1_org_policy_service, 13);/*** Describes the enum bytebase.v1.PolicyType.diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex caa21060f4..8f1f2eb90e 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -25556,6 +25556,13 @@ components:- $ref: '#/components/schemas/bytebase.v1.QueryDataPolicy'title: query_data_policytitle: query_data_policy+ - type: object+ properties:+ reviewAiPolicy:+ allOf:+ - $ref: '#/components/schemas/bytebase.v1.ReviewAIPolicy'+ title: review_ai_policy+ title: review_ai_policy- type: objectproperties:reviewRulePolicy:@@ -25587,6 +25594,8 @@ components:- maskingRulePolicy- required:- queryDataPolicy+ - required:+ - reviewAiPolicy- required:- reviewRulePolicy- required:@@ -25601,6 +25610,8 @@ components:- maskingRulePolicy- required:- queryDataPolicy+ - required:+ - reviewAiPolicy- required:- reviewRulePolicy- required:@@ -25668,6 +25679,7 @@ components:- TAG- DATA_QUERY- REVIEW_RULE+ - REVIEW_AIdescription: The type of organizational policy.bytebase.v1.Position:type: object@@ -26802,6 +26814,19 @@ components:required:- nameadditionalProperties: false+ bytebase.v1.ReviewAIPolicy:+ type: object+ properties:+ content:+ type: string+ title: content+ description: The policy text. Must not be blank, at most 64 KiB.+ title: ReviewAIPolicy+ additionalProperties: false+ description: |-+ Natural-language policy for the AI review. Unlike the review rule policy,+ both levels apply: the workspace policy and the project policy both reach+ the reviewer, and the project policy wins where they conflict.bytebase.v1.ReviewConfig:type: objectproperties:diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex 431719addd..ab93fb3eb5 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -169,6 +169,7 @@- [MaskingRulePolicy.MaskingRule](#bytebase-store-MaskingRulePolicy-MaskingRule)- [Policy](#bytebase-store-Policy)- [QueryDataPolicy](#bytebase-store-QueryDataPolicy)+ - [ReviewAIPolicy](#bytebase-store-ReviewAIPolicy)- [ReviewRulePolicy](#bytebase-store-ReviewRulePolicy)- [RolloutPolicy](#bytebase-store-RolloutPolicy)- [TagPolicy](#bytebase-store-TagPolicy)@@ -2195,7 +2196,7 @@ new reviewer is a new value, not a migration.| ---- | ------ | ----------- || TYPE_UNSPECIFIED | 0 | || RULE | 1 | Review against the standard rules. |-| AI | 2 | Review against the AI review policy's natural-language instructions, performed by a model. |+| AI | 2 | Review against the natural-language AI review policy, performed by a model. |@@ -2743,6 +2744,24 @@ QueryDataPolicy is the policy configuration for querying data in the SQL Editor.+<a name="bytebase-store-ReviewAIPolicy"></a>++### ReviewAIPolicy+ReviewAIPolicy holds the natural-language policy the AI review judges a+change against. Both levels apply: the workspace policy and the project+policy both reach the reviewer, and the project policy wins where they+conflict.+++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| content | [string](#string) | | |++++++<a name="bytebase-store-ReviewRulePolicy"></a>### ReviewRulePolicy@@ -2837,6 +2856,7 @@ wins: the project's if it has one, else the workspace's, else every rule| IAM | 5 | || TAG | 6 | || REVIEW_RULE | 7 | |+| REVIEW_AI | 8 | |diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.htmlindex 206340df1c..48a60f8a05 100644--- a/proto/gen/grpc-doc/store/index.html+++ b/proto/gen/grpc-doc/store/index.html@@ -840,6 +840,10 @@<a href="#bytebase.store.QueryDataPolicy"><span class="badge">M</span>QueryDataPolicy</a></li>+ <li>+ <a href="#bytebase.store.ReviewAIPolicy"><span class="badge">M</span>ReviewAIPolicy</a>+ </li>+<li><a href="#bytebase.store.ReviewRulePolicy"><span class="badge">M</span>ReviewRulePolicy</a></li>@@ -6315,8 +6319,8 @@ executor or by the reaper. </p></td><tr><td>AI</td><td>2</td>- <td><p>Review against the AI review policy's natural-language instructions,-performed by a model.</p></td>+ <td><p>Review against the natural-language AI review policy, performed by a+model.</p></td></tr></tbody>@@ -7467,6 +7471,30 @@ Disallow running DDL statements in the SQL editor. </p></td>+ <h3 id="bytebase.store.ReviewAIPolicy">ReviewAIPolicy</h3>+ <p>ReviewAIPolicy holds the natural-language policy the AI review judges a</p><p>change against. Both levels apply: the workspace policy and the project</p><p>policy both reach the reviewer, and the project policy wins where they</p><p>conflict.</p>+++ <table class="field-table">+ <thead>+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>content</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p> </p></td>+ </tr>++ </tbody>+ </table>+++++<h3 id="bytebase.store.ReviewRulePolicy">ReviewRulePolicy</h3><p>ReviewRulePolicy is the standard review rule switch. The nearest policy</p><p>wins: the project's if it has one, else the workspace's, else every rule.</p>@@ -7671,6 +7699,12 @@ For example, the environment resource can have the SQL review config tag, such a<td><p></p></td></tr>+ <tr>+ <td>REVIEW_AI</td>+ <td>8</td>+ <td><p></p></td>+ </tr>+</tbody></table>diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 3ea89f7d70..879883a121 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -600,6 +600,7 @@- [MaskingRulePolicy.MaskingRule](#bytebase-v1-MaskingRulePolicy-MaskingRule)- [Policy](#bytebase-v1-Policy)- [QueryDataPolicy](#bytebase-v1-QueryDataPolicy)+ - [ReviewAIPolicy](#bytebase-v1-ReviewAIPolicy)- [ReviewRulePolicy](#bytebase-v1-ReviewRulePolicy)- [RolloutPolicy](#bytebase-v1-RolloutPolicy)- [TagPolicy](#bytebase-v1-TagPolicy)@@ -4055,7 +4056,7 @@ completion transaction, so re-running supersedes instead of canceling).| ---- | ------ | ----------- || TYPE_UNSPECIFIED | 0 | || RULE | 1 | Review against the standard rules. |-| AI | 2 | Review against the AI review policy's natural-language instructions, performed by a model. |+| AI | 2 | Review against the natural-language AI review policy, performed by a model. |@@ -9975,6 +9976,7 @@ For example: resource.environment_id == "test" && resource.proje| tag_policy | [TagPolicy](#bytebase-v1-TagPolicy) | | || query_data_policy | [QueryDataPolicy](#bytebase-v1-QueryDataPolicy) | | || review_rule_policy | [ReviewRulePolicy](#bytebase-v1-ReviewRulePolicy) | | |+| review_ai_policy | [ReviewAIPolicy](#bytebase-v1-ReviewAIPolicy) | | || enforce | [bool](#bool) | | Whether the policy is enforced. || resource_type | [PolicyResourceType](#bytebase-v1-PolicyResourceType) | | The resource type for the policy. |@@ -10001,6 +10003,23 @@ QueryDataPolicy is the policy configuration for querying data in the SQL Editor.+<a name="bytebase-v1-ReviewAIPolicy"></a>++### ReviewAIPolicy+Natural-language policy for the AI review. Unlike the review rule policy,+both levels apply: the workspace policy and the project policy both reach+the reviewer, and the project policy wins where they conflict.+++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| content | [string](#string) | | The policy text. Must not be blank, at most 64 KiB. |++++++<a name="bytebase-v1-ReviewRulePolicy"></a>### ReviewRulePolicy@@ -10118,6 +10137,7 @@ The type of organizational policy.| TAG | 4 | Resource tag policy. || DATA_QUERY | 6 | Query data access policy. || REVIEW_RULE | 7 | Standard review rule switch. Allowed on WORKSPACE and PROJECT. |+| REVIEW_AI | 8 | Natural-language policy for the AI review. Allowed on WORKSPACE and PROJECT. |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 28324f6912..cd72c388af 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -2477,6 +2477,10 @@<a href="#bytebase.v1.QueryDataPolicy"><span class="badge">M</span>QueryDataPolicy</a></li>+ <li>+ <a href="#bytebase.v1.ReviewAIPolicy"><span class="badge">M</span>ReviewAIPolicy</a>+ </li>+<li><a href="#bytebase.v1.ReviewRulePolicy"><span class="badge">M</span>ReviewRulePolicy</a></li>@@ -12069,8 +12073,8 @@ review passed: whether problems remain is judged from open comments.</p></td><tr><td>AI</td><td>2</td>- <td><p>Review against the AI review policy's natural-language instructions,-performed by a model.</p></td>+ <td><p>Review against the natural-language AI review policy, performed by a+model.</p></td></tr></tbody>@@ -28413,6 +28417,13 @@ Environment resource name: environments/environment-id. </p></td><td><p> </p></td></tr>+ <tr>+ <td>review_ai_policy</td>+ <td><a href="#bytebase.v1.ReviewAIPolicy">ReviewAIPolicy</a></td>+ <td></td>+ <td><p> </p></td>+ </tr>+<tr><td>enforce</td><td><a href="#bool">bool</a></td>@@ -28488,6 +28499,30 @@ If false,+ <h3 id="bytebase.v1.ReviewAIPolicy">ReviewAIPolicy</h3>+ <p>Natural-language policy for the AI review. Unlike the review rule policy,</p><p>both levels apply: the workspace policy and the project policy both reach</p><p>the reviewer, and the project policy wins where they conflict.</p>+++ <table class="field-table">+ <thead>+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>content</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The policy text. Must not be blank, at most 64 KiB. </p></td>+ </tr>++ </tbody>+ </table>+++++<h3 id="bytebase.v1.ReviewRulePolicy">ReviewRulePolicy</h3><p>Standard review rule policy: the rules switched on. The nearest policy</p><p>wins: a project's own policy applies as is; a project without one uses</p><p>the workspace policy; with neither, every rule is on.</p><p>A saved list is explicit, so a rule added to the standard set in a later</p><p>release is appended to every saved policy by a data migration in that</p><p>release.</p>@@ -28730,6 +28765,12 @@ In this situation, `update_mask` is ignored. </p></td><td><p>Standard review rule switch. Allowed on WORKSPACE and PROJECT.</p></td></tr>+ <tr>+ <td>REVIEW_AI</td>+ <td>8</td>+ <td><p>Natural-language policy for the AI review. Allowed on WORKSPACE and PROJECT.</p></td>+ </tr>+</tbody></table>diff --git a/proto/store/store/policy.proto b/proto/store/store/policy.protoindex d3aedf568c..950bfbf3a0 100644--- a/proto/store/store/policy.proto+++ b/proto/store/store/policy.proto@@ -17,6 +17,7 @@ message Policy {IAM = 5;TAG = 6;REVIEW_RULE = 7;+ REVIEW_AI = 8;}enum Resource {@@ -33,6 +34,14 @@ message ReviewRulePolicy {repeated ReviewRuleType rules = 1;}+// ReviewAIPolicy holds the natural-language policy the AI review judges a+// change against. Both levels apply: the workspace policy and the project+// policy both reach the reviewer, and the project policy wins where they+// conflict.+message ReviewAIPolicy {+ string content = 1;+}+message RolloutPolicy {bool automatic = 1;repeated string roles = 2;diff --git a/proto/store/store/review_run.proto b/proto/store/store/review_run.protoindex d37c6fc7ba..16d1f37ec1 100644--- a/proto/store/store/review_run.proto+++ b/proto/store/store/review_run.proto@@ -14,8 +14,8 @@ message ReviewRun {TYPE_UNSPECIFIED = 0;// Review against the standard rules.RULE = 1;- // Review against the AI review policy's natural-language instructions,- // performed by a model.+ // Review against the natural-language AI review policy, performed by a+ // model.AI = 2;}diff --git a/proto/v1/v1/issue_service.proto b/proto/v1/v1/issue_service.protoindex 8e06a9f3de..8b308904b3 100644--- a/proto/v1/v1/issue_service.proto+++ b/proto/v1/v1/issue_service.proto@@ -808,8 +808,8 @@ message ReviewRun {TYPE_UNSPECIFIED = 0;// Review against the standard rules.RULE = 1;- // Review against the AI review policy's natural-language instructions,- // performed by a model.+ // Review against the natural-language AI review policy, performed by a+ // model.AI = 2;}// Derived from the name.diff --git a/proto/v1/v1/org_policy_service.proto b/proto/v1/v1/org_policy_service.protoindex b3999ded97..bad9083aa8 100644--- a/proto/v1/v1/org_policy_service.proto+++ b/proto/v1/v1/org_policy_service.proto@@ -216,6 +216,7 @@ message Policy {TagPolicy tag_policy = 7;QueryDataPolicy query_data_policy = 9;ReviewRulePolicy review_rule_policy = 12;+ ReviewAIPolicy review_ai_policy = 13;}// Whether the policy is enforced.@@ -242,6 +243,8 @@ enum PolicyType {DATA_QUERY = 6;// Standard review rule switch. Allowed on WORKSPACE and PROJECT.REVIEW_RULE = 7;+ // Natural-language policy for the AI review. Allowed on WORKSPACE and PROJECT.+ REVIEW_AI = 8;}// The resource type that a policy can be attached to.@@ -268,6 +271,14 @@ message ReviewRulePolicy {repeated ReviewRuleType rules = 1;}+// Natural-language policy for the AI review. Unlike the review rule policy,+// both levels apply: the workspace policy and the project policy both reach+// the reviewer, and the project policy wins where they conflict.+message ReviewAIPolicy {+ // The policy text. Must not be blank, at most 64 KiB.+ string content = 1;+}+// Rollout policy configuration.message RolloutPolicy {// Whether rollout is automatic without manual approval.