diff --git a/internal/contracts/state/v1/state.pb.go b/internal/contracts/state/v1/state.pb.go index fc9b93a54..38edeb98e 100644 --- a/internal/contracts/state/v1/state.pb.go +++ b/internal/contracts/state/v1/state.pb.go @@ -1319,7 +1319,11 @@ type Task struct { RemediationRounds int32 `protobuf:"varint,33,opt,name=remediation_rounds,json=remediationRounds,proto3" json:"remediation_rounds,omitempty"` // inputs_json is the JSON object of workflow inputs a binding dispatch // resolved (task.EncodeInputs); empty for a task no binding started. - InputsJson string `protobuf:"bytes,34,opt,name=inputs_json,json=inputsJson,proto3" json:"inputs_json,omitempty"` + InputsJson string `protobuf:"bytes,34,opt,name=inputs_json,json=inputsJson,proto3" json:"inputs_json,omitempty"` + // org is the org the task belongs to, derived store-side from the task's + // identity when the row is written; a task of a single-operator install + // belongs to the default org (docs/prds/orgs-and-access.md). + Org string `protobuf:"bytes,35,opt,name=org,proto3" json:"org,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1592,6 +1596,13 @@ func (x *Task) GetInputsJson() string { return "" } +func (x *Task) GetOrg() string { + if x != nil { + return x.Org + } + return "" +} + // Event mirrors internal/events.Event. Data is carried as a JSON object // string (matching the store's own on-disk representation) rather than // google.protobuf.Struct, to stay a direct mirror of the existing column. @@ -9651,7 +9662,7 @@ const file_state_v1_state_proto_rawDesc = "" + "\asubject\x18\x03 \x01(\tR\asubject\x12-\n" + "\x05audit\x18\x04 \x01(\v2\x17.state.v1.IdentityAuditR\x05audit\"M\n" + "\x1bBindIdentitySubjectResponse\x12.\n" + - "\bidentity\x18\x01 \x01(\v2\x12.state.v1.IdentityR\bidentity\"\xfa\b\n" + + "\bidentity\x18\x01 \x01(\v2\x12.state.v1.IdentityR\bidentity\"\x8c\t\n" + "\x04Task\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" + "\x05owner\x18\x02 \x01(\tR\x05owner\x12\x12\n" + @@ -9697,7 +9708,8 @@ const file_state_v1_state_proto_rawDesc = "" + "park_class\x18 \x01(\tR\tparkClass\x12-\n" + "\x12remediation_rounds\x18! \x01(\x05R\x11remediationRounds\x12\x1f\n" + "\vinputs_json\x18\" \x01(\tR\n" + - "inputsJson\"\xf8\x02\n" + + "inputsJson\x12\x10\n" + + "\x03org\x18# \x01(\tR\x03org\"\xf8\x02\n" + "\x05Event\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12*\n" + "\x02at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\x12\x12\n" + diff --git a/internal/forge/webhook/receiver_test.go b/internal/forge/webhook/receiver_test.go index 82900a842..9e041b161 100644 --- a/internal/forge/webhook/receiver_test.go +++ b/internal/forge/webhook/receiver_test.go @@ -244,8 +244,8 @@ func TestPublishedEnvelopeCarriesIssueIdentityAndKind(t *testing.T) { if !slices.Contains(task.Labels, testLabel) || !slices.Contains(task.Labels, "bug") { t.Errorf("envelope labels = %v, want to contain %q and %q", task.Labels, testLabel, "bug") } - if task.IdempotencyKey() != "archie:owner/repo/42" { - t.Errorf("idempotency key = %q, want archie:owner/repo/42", task.IdempotencyKey()) + if task.IdempotencyKey() != "archie:default//owner/repo/42" { + t.Errorf("idempotency key = %q, want archie:default//owner/repo/42", task.IdempotencyKey()) } } diff --git a/internal/infrastructure/staterpc/values.go b/internal/infrastructure/staterpc/values.go index ec7bf2268..4a15da081 100644 --- a/internal/infrastructure/staterpc/values.go +++ b/internal/infrastructure/staterpc/values.go @@ -15,6 +15,7 @@ import ( "github.com/samcharles93/archie-core/internal/domain/binding" "github.com/samcharles93/archie-core/internal/domain/eventtype" "github.com/samcharles93/archie-core/internal/domain/mapping" + "github.com/samcharles93/archie-core/internal/domain/org" "github.com/samcharles93/archie-core/internal/domain/source" "github.com/samcharles93/archie-core/internal/domain/storecontract" "github.com/samcharles93/archie-core/internal/domain/storepkg" @@ -78,6 +79,7 @@ func taskProto(t *task.Task) *pb.Task { //nolint:dupl // mirror-image field-by-f WorkflowDefinitionVersion: t.WorkflowDefinitionVersion, WorkflowDefinitionDigest: t.WorkflowDefinitionDigest, WorkflowDefinitionYaml: t.WorkflowDefinitionYAML, + Org: string(t.Org), } } @@ -102,6 +104,7 @@ func taskValue(t *pb.Task) *task.Task { //nolint:dupl // see taskProto above WorkflowDefinitionVersion: t.WorkflowDefinitionVersion, WorkflowDefinitionDigest: t.WorkflowDefinitionDigest, WorkflowDefinitionYAML: t.WorkflowDefinitionYaml, + Org: org.OrgID(t.Org), } } diff --git a/proto/state/v1/state.proto b/proto/state/v1/state.proto index b5262af80..b2a90e523 100644 --- a/proto/state/v1/state.proto +++ b/proto/state/v1/state.proto @@ -278,6 +278,10 @@ message Task { // inputs_json is the JSON object of workflow inputs a binding dispatch // resolved (task.EncodeInputs); empty for a task no binding started. string inputs_json = 34; + // org is the org the task belongs to, derived store-side from the task's + // identity when the row is written; a task of a single-operator install + // belongs to the default org (docs/prds/orgs-and-access.md). + string org = 35; } // Event mirrors internal/events.Event. Data is carried as a JSON object