Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) initial changes for auto-tagging #296

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 181 additions & 8 deletions changes.proto
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,129 @@ service ChangesService {
rpc PopulateChangeFilters(PopulateChangeFiltersRequest) returns (PopulateChangeFiltersResponse);
}

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, with the provided properties. This will return a
// CodeAlreadyExists error if the `tagKey` is not unique
rpc CreateRule(CreateRuleRequest) returns (CreateRuleResponse);
// 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. 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
rpc DeleteRule(DeleteRuleRequest) returns (DeleteRuleResponse);
// 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, 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);
}

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 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;

// 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 {
// 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;
}

message GetRuleRequest {
bytes UUID = 1;
}
message GetRuleResponse {
Rule rule = 1;
}

message UpdateRuleRequest {
bytes UUID = 1;
RuleProperties properties = 2;
}
message UpdateRuleResponse {
Rule rule = 1;
}

message DeleteRuleRequest {
bytes UUID = 1;
}
message DeleteRuleResponse {}

message ExportRuleRequest {
bytes UUID = 1;
}
message ExportRuleResponse {
// 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
RuleProperties properties = 1;
// List of changes to test the rule on
repeated bytes changeUUID = 2;
}
message TestRuleResponse {
// The change UUID that the rule was tested against
bytes changeUUID = 1;

// 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 {
bytes changeUUID = 1;
}
Expand Down Expand Up @@ -236,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 {
Expand Down Expand Up @@ -509,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
Expand Down Expand Up @@ -578,11 +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;

// User-defined tags associated with this change, will be populated via the CLI and not the UI.
map<string, string> tags = 17;
// Tags that were set bu the user when the tag was created
//
// Deprecated: Use enrichedTags instead
map<string, string> tags = 17 [deprecated = true];

// Tags associated with this change
map<string, TagValue> enrichedTags = 18;

}

// a complete Change with machine-supplied and user-supplied values
Expand Down Expand Up @@ -721,8 +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<string, string> tags = 16;
// Tags that were set bu the user when the tag was created
//
// Deprecated: Use enrichedTags instead
map<string, string> tags = 16 [deprecated = true];

// Tags associated with this change
map<string, TagValue> enrichedTags = 18;

// Tags that were skipped by auto-tagging rules
map<string, AutoTagValue> 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;
}

////////////////////////////
Expand Down Expand Up @@ -776,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;
Expand Down Expand Up @@ -1015,7 +1188,7 @@ message Risk {
repeated Reference relatedItems = 4;
}

message RiskCalculationStatus {
message ChangeAnalysisStatus {
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_INPROGRESS = 1;
Expand Down
Loading