From 329add8b5e4aeea44df9b66d7a98e0a8c6583ed7 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Thu, 12 Dec 2024 12:28:54 +0000 Subject: [PATCH 1/5] (feat) initial changes for auto-tagging --- changes.proto | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) diff --git a/changes.proto b/changes.proto index 1085e79..ee5e42b 100644 --- a/changes.proto +++ b/changes.proto @@ -159,6 +159,170 @@ service ChangesService { rpc PopulateChangeFilters(PopulateChangeFiltersRequest) returns (PopulateChangeFiltersResponse); } +service RuleService { + // Used on the auto-tagging page to list all rules for an account + // Returns a list of rules + rpc ListRules(ListRulesRequest) returns (ListRulesResponse); + // Creates a new rule, user provides properties + // It will check for the uniqueness of the tag key + // Returns the created rule, or the submitted rule and an error + rpc CreateRule(CreateRuleRequest) returns (CreateRuleResponse); + // Given a rule UUID + // Returns the rule metadata and properties + rpc GetRule(GetRuleRequest) returns (GetRuleResponse); + // Given a rule UUID, updates the rule properties. + // Note the key can be updated, but it only applies to new changes. We still check for uniqueness. + // Returns the updated rule, or the old rule and an error + rpc UpdateRule(UpdateRuleRequest) returns (UpdateRuleResponse); + // Given a rule UUID permanently delete that rule, existing changes will not be affected + // Returns nothing + rpc DeleteRule(DeleteRuleRequest) returns (DeleteRuleResponse); + // Given a rule UUID, Rule applied to all future changes + // Returns the rule + rpc EnableRule(EnableRuleRequest) returns (EnableRuleResponse); + // Given a rule UUID, Rule no longer applied to future changes + // Returns the rule + rpc DisableRule(DisableRuleRequest) returns (DisableRuleResponse); + // Given a rule UUID Exports a rule + // returns the metadata so it can be saved locally + rpc ExportRule(ExportRuleRequest) returns (ExportRuleResponse); + // Given a rule uuid, and a list of changes uuids + // The response will contain the rule uuid and a list of changes and what tags they would have if the rule was applied + rpc TestRule(TestRuleRequest) returns (TestRuleResponse); + // Given a list of rule uuids, and a single change uuid + // The response will contain a list of rule uuids and the tags to be applied + rpc TestRules(TestRulesRequest) returns (TestRulesResponse); +} + +message RuleMetadata { + // The unique identifier for this rule + bytes UUID = 1; + + // The time that this rule was created + google.protobuf.Timestamp createdAt = 2; + + // The time that this rule was last run + google.protobuf.Timestamp lastRunAt = 3; + + // The time that this rule added a tag to a change + google.protobuf.Timestamp lastActivated = 4; +} + +message RuleProperties { + // The name of the rule, friendly for users + string name = 1; + + // The key that will be set in a change's tags if this rule is applied + string tagKey = 2; + + // whether the rule is enabled or not + bool enabled = 3; + + // The query that will be run to find items that this rule applies to + string query = 4; +} + +message Rule { + // The auto-generated metadata for this rule + RuleMetadata metadata = 1; + // The user provided properties for this rule + RuleProperties properties = 2; +} + +message ListRulesRequest {} +message ListRulesResponse { + repeated Rule rules = 1; +} + +message CreateRuleRequest { + RuleProperties properties = 1; +} +message CreateRuleResponse { + Rule rule = 1; + string error = 2; +} + +message GetRuleRequest { + bytes UUID = 1; +} +message GetRuleResponse { + Rule rule = 1; +} + +message UpdateRuleRequest { + bytes UUID = 1; + RuleProperties properties = 2; +} +message UpdateRuleResponse { + Rule rule = 1; + string error = 2; +} + +message DeleteRuleRequest { + bytes UUID = 1; +} +message DeleteRuleResponse {} + +message EnableRuleRequest { + bytes UUID = 1; +} +message EnableRuleResponse { + Rule rule = 1; +} + +message DisableRuleRequest { + bytes UUID = 1; +} +message DisableRuleResponse { + Rule rule = 1; +} + +message ExportRuleRequest { + bytes UUID = 1; +} +message ExportRuleResponse { + // metadata for the rule + RuleMetadata metadata = 1; +} + +message TestRuleRequest { + // the uuid of the rule to test + bytes ruleUUID = 1; + repeated bytes changeUUID = 2; +} + +message RuleTestResult { + // the uuid of the item that was tested + bytes itemUUID = 1; + // the tag that would be set if the rule was applied, or an empty string if it would not be applied + string tag = 2; +} + +message TestRuleResponse { + // the uuid of the rule that was tested + bytes ruleUUID = 1; + // list of changes and what tags they would have if the rule was applied + repeated RuleTestResult results = 2; +} + +message TestRulesRequest { + // the uuid of the rule to test + repeated bytes ruleUUID = 1; + bytes changeUUID = 2; +} + +message RulesTestResult { + // the uuid of the item that was tested + bytes itemUUID = 1; + // the tag that would be set if the rule was applied, or an empty string if it would not be applied + string tag = 2; +} + +message TestRulesResponse { + // list of changes and what tags they would have if the rule was applied + repeated RulesTestResult results = 1; +} + message GetChangeTimelineRequest { bytes changeUUID = 1; } @@ -583,6 +747,9 @@ message ChangeSummary { // User-defined tags associated with this change, will be populated via the CLI and not the UI. map tags = 17; + + // Description of the auto tagging rules that were applied to this change + string autoTaggingDescription = 18; } // a complete Change with machine-supplied and user-supplied values @@ -723,6 +890,9 @@ message ChangeProperties { // User-defined tags associated with this change, will be populated via the CLI and not the UI. map tags = 16; + + // Description of the auto tagging rules that were applied to this change + string autoTaggingDescription = 17; } //////////////////////////// From 8ae6d3342d876bbbef59de7953f8028ad57fa773 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Fri, 13 Dec 2024 11:07:02 +0000 Subject: [PATCH 2/5] feedback session improvements --- changes.proto | 64 ++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/changes.proto b/changes.proto index ee5e42b..0fc8ed8 100644 --- a/changes.proto +++ b/changes.proto @@ -188,10 +188,7 @@ service RuleService { rpc ExportRule(ExportRuleRequest) returns (ExportRuleResponse); // Given a rule uuid, and a list of changes uuids // The response will contain the rule uuid and a list of changes and what tags they would have if the rule was applied - rpc TestRule(TestRuleRequest) returns (TestRuleResponse); - // Given a list of rule uuids, and a single change uuid - // The response will contain a list of rule uuids and the tags to be applied - rpc TestRules(TestRulesRequest) returns (TestRulesResponse); + rpc TestRule(TestRuleRequest) returns (stream TestRuleResponse); } message RuleMetadata { @@ -218,8 +215,13 @@ message RuleProperties { // whether the rule is enabled or not bool enabled = 3; - // The query that will be run to find items that this rule applies to - string query = 4; + // The instructions that will be run by the llm to determine if the tag should be applied and what its value should be + string instructions = 4; + + // list of strings to validate the values calculated by the instructions + // eg an enum of high, medium, low + // or it could be empty if the instruction returns a calculated value + repeated string validation = 5; } message Rule { @@ -286,41 +288,25 @@ message ExportRuleResponse { } message TestRuleRequest { - // the uuid of the rule to test - bytes ruleUUID = 1; + // the entire rule to test, so they don't have to save it first + RuleProperties properties = 1; + // list of changes to test the rule on repeated bytes changeUUID = 2; } - -message RuleTestResult { - // the uuid of the item that was tested - bytes itemUUID = 1; - // the tag that would be set if the rule was applied, or an empty string if it would not be applied - string tag = 2; -} - message TestRuleResponse { - // the uuid of the rule that was tested - bytes ruleUUID = 1; - // list of changes and what tags they would have if the rule was applied - repeated RuleTestResult results = 2; -} - -message TestRulesRequest { - // the uuid of the rule to test - repeated bytes ruleUUID = 1; - bytes changeUUID = 2; -} - -message RulesTestResult { - // the uuid of the item that was tested - bytes itemUUID = 1; + // the uuid of the change that was tested + bytes changeUUID = 1; // the tag that would be set if the rule was applied, or an empty string if it would not be applied - string tag = 2; + // key=value, eg "risk=high" or "author=jimmy" + map tag = 2; } -message TestRulesResponse { - // list of changes and what tags they would have if the rule was applied - repeated RulesTestResult results = 1; +message TagValue { + // the tag that would be set if the rule was applied, or an empty string if it would not be applied + // key=value, eg "risk=high" or "author=jimmy" + string value = 1; + // reasoning for the tag, returned by the llm + string reasoning = 2; } message GetChangeTimelineRequest { @@ -745,11 +731,11 @@ message ChangeSummary { // Repo information; can be an empty string. CLI attempts auto-population, but users can override. Not necessarily a URL. The UI will be responsible for any formatting/shortnening/sprucing up should it be required. string repo = 16; - // User-defined tags associated with this change, will be populated via the CLI and not the UI. - map tags = 17; + // tags associated with this change, user defined in the cli, and successful auto-tagging rules + map tags = 17; - // Description of the auto tagging rules that were applied to this change - string autoTaggingDescription = 18; + // tags that were skipped by auto-tagging rules + map skippedAutoTags = 17; } // a complete Change with machine-supplied and user-supplied values From 524cfeda0d11f6d26eab441033d96ac6ae34654d Mon Sep 17 00:00:00 2001 From: TP Honey Date: Fri, 13 Dec 2024 12:22:06 +0000 Subject: [PATCH 3/5] feedback session 2 improvements --- changes.proto | 149 ++++++++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 66 deletions(-) diff --git a/changes.proto b/changes.proto index 0fc8ed8..d08ee28 100644 --- a/changes.proto +++ b/changes.proto @@ -159,32 +159,24 @@ service ChangesService { rpc PopulateChangeFilters(PopulateChangeFiltersRequest) returns (PopulateChangeFiltersResponse); } -service RuleService { +service AutoTaggingService { // Used on the auto-tagging page to list all rules for an account // Returns a list of rules rpc ListRules(ListRulesRequest) returns (ListRulesResponse); - // Creates a new rule, user provides properties - // It will check for the uniqueness of the tag key - // Returns the created rule, or the submitted rule and an error + // Creates a new rule, with the provided properties. This will return a + // CodeAlreadyExists error if the `tagKey` is not unique rpc CreateRule(CreateRuleRequest) returns (CreateRuleResponse); - // Given a rule UUID - // Returns the rule metadata and properties + // Get the details of a rule rpc GetRule(GetRuleRequest) returns (GetRuleResponse); - // Given a rule UUID, updates the rule properties. - // Note the key can be updated, but it only applies to new changes. We still check for uniqueness. - // Returns the updated rule, or the old rule and an error + // Given a rule UUID, updates the rule properties. Note the key can be + // updated, but it only applies to new changes. This will return a + // CodeAlreadyExists error if the new `tagKey` is not unique rpc UpdateRule(UpdateRuleRequest) returns (UpdateRuleResponse); - // Given a rule UUID permanently delete that rule, existing changes will not be affected - // Returns nothing + // Given a rule UUID permanently delete that rule, existing changes will not + // be affected rpc DeleteRule(DeleteRuleRequest) returns (DeleteRuleResponse); - // Given a rule UUID, Rule applied to all future changes - // Returns the rule - rpc EnableRule(EnableRuleRequest) returns (EnableRuleResponse); - // Given a rule UUID, Rule no longer applied to future changes - // Returns the rule - rpc DisableRule(DisableRuleRequest) returns (DisableRuleResponse); - // Given a rule UUID Exports a rule - // returns the metadata so it can be saved locally + // Convert a rule's properties to a string that can be used in the rules + // config file rpc ExportRule(ExportRuleRequest) returns (ExportRuleResponse); // Given a rule uuid, and a list of changes uuids // The response will contain the rule uuid and a list of changes and what tags they would have if the rule was applied @@ -212,16 +204,17 @@ message RuleProperties { // The key that will be set in a change's tags if this rule is applied string tagKey = 2; - // whether the rule is enabled or not + // Whether the rule is enabled or not bool enabled = 3; - // The instructions that will be run by the llm to determine if the tag should be applied and what its value should be + // The instructions that will be run by the llm to determine if the tag should + // be applied and what its value should be string instructions = 4; - // list of strings to validate the values calculated by the instructions - // eg an enum of high, medium, low - // or it could be empty if the instruction returns a calculated value - repeated string validation = 5; + // A list of valid tag values. If the instructions produce a value that is not + // in this list, the rule will be retried, however if we cannot converge on a + // valid value after some number of tries, the rule will not be applied + repeated string validValues = 5; } message Rule { @@ -241,7 +234,6 @@ message CreateRuleRequest { } message CreateRuleResponse { Rule rule = 1; - string error = 2; } message GetRuleRequest { @@ -257,7 +249,6 @@ message UpdateRuleRequest { } message UpdateRuleResponse { Rule rule = 1; - string error = 2; } message DeleteRuleRequest { @@ -265,48 +256,30 @@ message DeleteRuleRequest { } message DeleteRuleResponse {} -message EnableRuleRequest { - bytes UUID = 1; -} -message EnableRuleResponse { - Rule rule = 1; -} - -message DisableRuleRequest { - bytes UUID = 1; -} -message DisableRuleResponse { - Rule rule = 1; -} - message ExportRuleRequest { bytes UUID = 1; } message ExportRuleResponse { - // metadata for the rule - RuleMetadata metadata = 1; + // Content that should be added to auto-tagging config file to represent this + // rule it is in the format that the cli expects + string rule = 1; } message TestRuleRequest { - // the entire rule to test, so they don't have to save it first + // The entire rule to test, so they don't have to save it first RuleProperties properties = 1; - // list of changes to test the rule on + // List of changes to test the rule on repeated bytes changeUUID = 2; } message TestRuleResponse { - // the uuid of the change that was tested + // The change UUID that the rule was tested against bytes changeUUID = 1; - // the tag that would be set if the rule was applied, or an empty string if it would not be applied - // key=value, eg "risk=high" or "author=jimmy" - map tag = 2; -} -message TagValue { - // the tag that would be set if the rule was applied, or an empty string if it would not be applied - // key=value, eg "risk=high" or "author=jimmy" - string value = 1; - // reasoning for the tag, returned by the llm - string reasoning = 2; + // Whether or not the tag was applied to this change + bool applied = 2; + + // The value of the tag and the reasoning for it + AutoTagValue value = 3; } message GetChangeTimelineRequest { @@ -386,11 +359,16 @@ message UpdatePlannedChangesRequest { // The change to update bytes changeUUID = 1; - // the changing items + // The changing items repeated MappedItemDiff changingItems = 2; // Overrides the stored blast radius config for this change optional config.BlastRadiusConfig blastRadiusConfigOverride = 3; + + // Overrides the auto-tagging rules with rules that have been read from the + // local config file. If this is empty the rules that have been configured in + // the UI will be used + repeated RuleProperties autoTaggingRulesOverride = 4; } message ListAppChangesSummaryRequest { @@ -659,6 +637,26 @@ message ListAppChangesResponse { // Changes // ///////////// +message TagValue { + // The value of the tag, this can be user-defined or auto-generated + oneof value { + UserTagValue userTagValue = 1; + AutoTagValue autoTagValue = 2; + } +} + +message UserTagValue { + // The value of the tag that was set by the user + string value = 1; +} + +message AutoTagValue { + // The value of the tag + string value = 1; + // Reasoning for this decision + string reasoning = 2; +} + enum ChangeStatus { // The change has been created, but the blast radius has not yet been // calculated. The blast radius can be calculated using the @@ -728,14 +726,19 @@ message ChangeSummary { // Example: "upgrade of the database to get access to the new contoso management processor" string description = 14; - // Repo information; can be an empty string. CLI attempts auto-population, but users can override. Not necessarily a URL. The UI will be responsible for any formatting/shortnening/sprucing up should it be required. + // Repo information; can be an empty string. CLI attempts auto-population, but + // users can override. Not necessarily a URL. The UI will be responsible for + // any formatting/shortening/sprucing up should it be required. string repo = 16; - // tags associated with this change, user defined in the cli, and successful auto-tagging rules - map tags = 17; + // Tags that were set bu the user when the tag was created + // + // Deprecated: Use enrichedTags instead + map tags = 17 [deprecated = true]; + + // Tags associated with this change + map enrichedTags = 18; - // tags that were skipped by auto-tagging rules - map skippedAutoTags = 17; } // a complete Change with machine-supplied and user-supplied values @@ -874,11 +877,25 @@ message ChangeProperties { // Repo information; can be an empty string. CLI attempts auto-population, but users can override. Not necessarily a URL. The UI will be responsible for any formatting/shortnening/sprucing up should it be required. string repo = 15; - // User-defined tags associated with this change, will be populated via the CLI and not the UI. - map tags = 16; + // Tags that were set bu the user when the tag was created + // + // Deprecated: Use enrichedTags instead + map tags = 16 [deprecated = true]; + + // Tags associated with this change + map enrichedTags = 18; - // Description of the auto tagging rules that were applied to this change - string autoTaggingDescription = 17; + // Tags that were skipped by auto-tagging rules + map skippedAutoTags = 19; + + // origin of auto-tagging rules + // this is an enum of file or ui provided rules + enum AutoTaggingRuleSource { + AUTO_TAGGING_RULE_SOURCE_UNSPECIFIED = 0; + AUTO_TAGGING_RULE_SOURCE_FILE = 1; + AUTO_TAGGING_RULE_SOURCE_UI = 2; + } + AutoTaggingRuleSource autoTaggingRuleSource = 20; } //////////////////////////// From 981d2f13c22457ab3a82153bb405e39d23c36931 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Fri, 13 Dec 2024 14:05:44 +0000 Subject: [PATCH 4/5] rename risks --- changes.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changes.proto b/changes.proto index d08ee28..4d91ab8 100644 --- a/changes.proto +++ b/changes.proto @@ -949,7 +949,7 @@ message GetChangeRisksRequest { message ChangeRiskMetadata { // The status of the risk calculation - RiskCalculationStatus riskCalculationStatus = 1; + ChangeAnalysisStatus changeAnalysisStatus = 1; // The risks that are related to this change repeated Risk risks = 5; @@ -1188,7 +1188,7 @@ message Risk { repeated Reference relatedItems = 4; } -message RiskCalculationStatus { +message ChangeAnalysisStatus { enum Status { STATUS_UNSPECIFIED = 0; STATUS_INPROGRESS = 1; From e968510e142ab3ecd6b11c0f28bd4ad44f938c82 Mon Sep 17 00:00:00 2001 From: TP Honey Date: Mon, 16 Dec 2024 09:13:51 +0000 Subject: [PATCH 5/5] Update changes.proto Co-authored-by: Dylan --- changes.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.proto b/changes.proto index 4d91ab8..6a1e40e 100644 --- a/changes.proto +++ b/changes.proto @@ -178,7 +178,7 @@ service AutoTaggingService { // Convert a rule's properties to a string that can be used in the rules // config file rpc ExportRule(ExportRuleRequest) returns (ExportRuleResponse); - // Given a rule uuid, and a list of changes uuids + // Given a rule, and a list of changes uuids // The response will contain the rule uuid and a list of changes and what tags they would have if the rule was applied rpc TestRule(TestRuleRequest) returns (stream TestRuleResponse); }