From 484ea701fe86265db8a8c9f0967ad3ff2f540bef Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 26 Sep 2026 13:26:27 +1000 Subject: [PATCH] =?UTF-8?q?feat(store):=20workflow.call=20contract=20?= =?UTF-8?q?=E2=80=94=20callee=20enqueue,=20parent-scoped=20status=20read,?= =?UTF-8?q?=20task-scoped=20grant=20widening=20(archie-core-t2db.41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/agentworker/task_execution.go | 2 + .../app/agentworker/task_execution_test.go | 2 +- internal/app/agentworker/worker.go | 4 + internal/app/agentworker/worker_test.go | 3 + internal/app/archied/state_store.go | 3 + internal/contracts/state/v1/state.pb.go | 745 ++++++++++++------ internal/contracts/state/v1/state_grpc.pb.go | 86 ++ .../domain/storecontract/storecontract.go | 21 + .../agenttransport/nats/transport.go | 34 + .../migrations/0015_workflow_calls.sql | 20 + .../postgres/postgresdb/call_tasks.sql.go | 118 +++ .../postgres/postgresdb/models.go | 2 + .../postgres/postgresdb/tasks.sql.go | 24 +- .../postgres/queries/call_tasks.sql | 34 + internal/infrastructure/postgres/store.go | 86 +- internal/infrastructure/staterpc/client.go | 27 + .../staterpc/conformance_test.go | 2 +- internal/infrastructure/staterpc/server.go | 40 + .../infrastructure/staterpc/task_grants.go | 21 +- .../staterpc/task_grants_call_test.go | 87 ++ .../staterpc/task_grants_test.go | 3 +- internal/infrastructure/staterpc/values.go | 7 + .../workflow_call_conformance_test.go | 114 +++ proto/state/v1/state.proto | 37 + 24 files changed, 1268 insertions(+), 254 deletions(-) create mode 100644 internal/infrastructure/postgres/migrations/0015_workflow_calls.sql create mode 100644 internal/infrastructure/postgres/postgresdb/call_tasks.sql.go create mode 100644 internal/infrastructure/postgres/queries/call_tasks.sql create mode 100644 internal/infrastructure/staterpc/task_grants_call_test.go create mode 100644 internal/infrastructure/staterpc/workflow_call_conformance_test.go diff --git a/internal/app/agentworker/task_execution.go b/internal/app/agentworker/task_execution.go index 2f348d5e9..afee06abf 100644 --- a/internal/app/agentworker/task_execution.go +++ b/internal/app/agentworker/task_execution.go @@ -183,6 +183,7 @@ func worktreeOwnerID(env string) int { type taskDependencies struct { forge workflow.Forger store workflow.Store + calls task.Caller trees remoteTrees events agentexec.EventPublisher // steps is the workflow step vocabulary pinned definitions are compiled @@ -314,6 +315,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen Cfg: req.Cfg.ToConfig(), Forge: dependencies.forge, Store: dependencies.store, + Calls: dependencies.calls, Trees: trees, Agent: agent, Reviewer: reviewer, diff --git a/internal/app/agentworker/task_execution_test.go b/internal/app/agentworker/task_execution_test.go index 22b2b5502..b72e8da2f 100644 --- a/internal/app/agentworker/task_execution_test.go +++ b/internal/app/agentworker/task_execution_test.go @@ -382,7 +382,7 @@ func startStateStoreGRPC(t *testing.T, local *pgstore.TaskDB) string { eda := pgstore.EDA(t, nil) staterpc.RegisterServer(server, staterpc.Deps{ Tasks: local, Captures: eda, Mappings: eda, Bindings: eda, - BindingDispatcher: eda, BindingTaskCreator: local, + BindingDispatcher: eda, BindingTaskCreator: local, WorkflowCalls: local, }) go func() { _ = server.Serve(listener) }() t.Cleanup(func() { server.Stop(); _ = listener.Close() }) diff --git a/internal/app/agentworker/worker.go b/internal/app/agentworker/worker.go index 5d279d8ad..73279290f 100644 --- a/internal/app/agentworker/worker.go +++ b/internal/app/agentworker/worker.go @@ -8,6 +8,7 @@ import ( "github.com/samcharles93/archie-core/internal/agentexec" "github.com/samcharles93/archie-core/internal/domain/workflow" + "github.com/samcharles93/archie-core/internal/domain/workflow/task" "github.com/samcharles93/archie-core/internal/infrastructure/agentboot" "github.com/samcharles93/archie-core/internal/infrastructure/agentgit" agentnats "github.com/samcharles93/archie-core/internal/infrastructure/agenttransport/nats" @@ -50,6 +51,7 @@ type workerTransport interface { SubscribeTasks(context.Context, int64, agentnats.TaskHandler, *slog.Logger) (agentnats.Subscription, error) Forger(string, time.Duration) workflow.Forger Store(time.Duration) workflow.Store + Calls(time.Duration) task.Caller Trees(string, string, time.Duration) agentnats.RemoteTrees } @@ -152,6 +154,7 @@ func run(ctx context.Context, settings Settings, log *slog.Logger, dependencies type taskServiceTransport interface { Forger(string, time.Duration) workflow.Forger Store(time.Duration) workflow.Store + Calls(time.Duration) task.Caller Trees(string, string, time.Duration) agentnats.RemoteTrees EventPublisher() agentexec.EventPublisher } @@ -161,6 +164,7 @@ func executeTaskRequest(ctx context.Context, request taskrun.Request, transport dependencies := taskDependencies{ forge: transport.Forger(request.Task.Identity, rpcTimeout), store: transport.Store(rpcTimeout), + calls: transport.Calls(rpcTimeout), trees: transport.Trees(request.Task.Identity, request.WorktreeGrant, rpcTimeout), events: transport.EventPublisher(), steps: steps, diff --git a/internal/app/agentworker/worker_test.go b/internal/app/agentworker/worker_test.go index a50063fb6..9d623ad08 100644 --- a/internal/app/agentworker/worker_test.go +++ b/internal/app/agentworker/worker_test.go @@ -11,6 +11,7 @@ import ( "github.com/samcharles93/archie-core/internal/agentexec" "github.com/samcharles93/archie-core/internal/domain/workflow" + "github.com/samcharles93/archie-core/internal/domain/workflow/task" agentnats "github.com/samcharles93/archie-core/internal/infrastructure/agenttransport/nats" ) @@ -75,6 +76,8 @@ func (*workerTransportStub) Forger(string, time.Duration) workflow.Forger { retu func (*workerTransportStub) Store(time.Duration) workflow.Store { return nil } +func (*workerTransportStub) Calls(time.Duration) task.Caller { return nil } + func (*workerTransportStub) Trees(string, string, time.Duration) agentnats.RemoteTrees { return nil } func TestRunPassesCompleteTransportConfiguration(t *testing.T) { diff --git a/internal/app/archied/state_store.go b/internal/app/archied/state_store.go index fe2b606b5..d1e76bc8c 100644 --- a/internal/app/archied/state_store.go +++ b/internal/app/archied/state_store.go @@ -284,6 +284,9 @@ func (b *boot) stateStoreDeps(grants *staterpc.TaskGrants) staterpc.Deps { if btc, ok := b.st.(storecontract.BindingTaskCreator); ok { deps.BindingTaskCreator = btc } + if wc, ok := b.st.(storecontract.WorkflowCaller); ok { + deps.WorkflowCalls = wc + } if css, ok := b.st.(storecontract.ConfigSnapshotStore); ok { deps.ConfigSnapshots = css } diff --git a/internal/contracts/state/v1/state.pb.go b/internal/contracts/state/v1/state.pb.go index 38edeb98e..887637d55 100644 --- a/internal/contracts/state/v1/state.pb.go +++ b/internal/contracts/state/v1/state.pb.go @@ -1323,9 +1323,15 @@ type Task struct { // 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 + Org string `protobuf:"bytes,35,opt,name=org,proto3" json:"org,omitempty"` + // The workflow.call linkage (docs/prds/workflow-calls.md): the task whose + // workflow.call step started this one (0 on a root run) and how many + // call hops this row is from that root. Columns default, so an older + // writer reads as a depth-0 root run. + CallParentTaskId int64 `protobuf:"varint,36,opt,name=call_parent_task_id,json=callParentTaskId,proto3" json:"call_parent_task_id,omitempty"` + CallDepth int32 `protobuf:"varint,37,opt,name=call_depth,json=callDepth,proto3" json:"call_depth,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Task) Reset() { @@ -1603,6 +1609,20 @@ func (x *Task) GetOrg() string { return "" } +func (x *Task) GetCallParentTaskId() int64 { + if x != nil { + return x.CallParentTaskId + } + return 0 +} + +func (x *Task) GetCallDepth() int32 { + if x != nil { + return x.CallDepth + } + return 0 +} + // 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. @@ -9106,6 +9126,226 @@ func (x *EnqueueBindingTaskResponse) GetTask() *Task { return nil } +// workflow.call: the caller's grant names the caller; the store derives the +// rest from the caller's row (docs/prds/workflow-calls.md). +type EnqueueCallTaskRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + CallerTaskId int64 `protobuf:"varint,1,opt,name=caller_task_id,json=callerTaskId,proto3" json:"caller_task_id,omitempty"` + Workflow string `protobuf:"bytes,2,opt,name=workflow,proto3" json:"workflow,omitempty"` + InputsJson string `protobuf:"bytes,3,opt,name=inputs_json,json=inputsJson,proto3" json:"inputs_json,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EnqueueCallTaskRequest) Reset() { + *x = EnqueueCallTaskRequest{} + mi := &file_state_v1_state_proto_msgTypes[170] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EnqueueCallTaskRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnqueueCallTaskRequest) ProtoMessage() {} + +func (x *EnqueueCallTaskRequest) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_state_proto_msgTypes[170] + 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 EnqueueCallTaskRequest.ProtoReflect.Descriptor instead. +func (*EnqueueCallTaskRequest) Descriptor() ([]byte, []int) { + return file_state_v1_state_proto_rawDescGZIP(), []int{170} +} + +func (x *EnqueueCallTaskRequest) GetCallerTaskId() int64 { + if x != nil { + return x.CallerTaskId + } + return 0 +} + +func (x *EnqueueCallTaskRequest) GetWorkflow() string { + if x != nil { + return x.Workflow + } + return "" +} + +func (x *EnqueueCallTaskRequest) GetInputsJson() string { + if x != nil { + return x.InputsJson + } + return "" +} + +type EnqueueCallTaskResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"` + Accepted bool `protobuf:"varint,2,opt,name=accepted,proto3" json:"accepted,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *EnqueueCallTaskResponse) Reset() { + *x = EnqueueCallTaskResponse{} + mi := &file_state_v1_state_proto_msgTypes[171] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *EnqueueCallTaskResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EnqueueCallTaskResponse) ProtoMessage() {} + +func (x *EnqueueCallTaskResponse) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_state_proto_msgTypes[171] + 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 EnqueueCallTaskResponse.ProtoReflect.Descriptor instead. +func (*EnqueueCallTaskResponse) Descriptor() ([]byte, []int) { + return file_state_v1_state_proto_rawDescGZIP(), []int{171} +} + +func (x *EnqueueCallTaskResponse) GetTask() *Task { + if x != nil { + return x.Task + } + return nil +} + +func (x *EnqueueCallTaskResponse) GetAccepted() bool { + if x != nil { + return x.Accepted + } + return false +} + +type WorkflowCallStatusRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + CallerTaskId int64 `protobuf:"varint,1,opt,name=caller_task_id,json=callerTaskId,proto3" json:"caller_task_id,omitempty"` + CallTaskId int64 `protobuf:"varint,2,opt,name=call_task_id,json=callTaskId,proto3" json:"call_task_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WorkflowCallStatusRequest) Reset() { + *x = WorkflowCallStatusRequest{} + mi := &file_state_v1_state_proto_msgTypes[172] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WorkflowCallStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WorkflowCallStatusRequest) ProtoMessage() {} + +func (x *WorkflowCallStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_state_proto_msgTypes[172] + 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 WorkflowCallStatusRequest.ProtoReflect.Descriptor instead. +func (*WorkflowCallStatusRequest) Descriptor() ([]byte, []int) { + return file_state_v1_state_proto_rawDescGZIP(), []int{172} +} + +func (x *WorkflowCallStatusRequest) GetCallerTaskId() int64 { + if x != nil { + return x.CallerTaskId + } + return 0 +} + +func (x *WorkflowCallStatusRequest) GetCallTaskId() int64 { + if x != nil { + return x.CallTaskId + } + return 0 +} + +type WorkflowCallStatusResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // status is the callee's task status and detail its latest transition + // detail (empty before the callee first moves). + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + Detail string `protobuf:"bytes,2,opt,name=detail,proto3" json:"detail,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WorkflowCallStatusResponse) Reset() { + *x = WorkflowCallStatusResponse{} + mi := &file_state_v1_state_proto_msgTypes[173] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WorkflowCallStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WorkflowCallStatusResponse) ProtoMessage() {} + +func (x *WorkflowCallStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_state_proto_msgTypes[173] + 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 WorkflowCallStatusResponse.ProtoReflect.Descriptor instead. +func (*WorkflowCallStatusResponse) Descriptor() ([]byte, []int) { + return file_state_v1_state_proto_rawDescGZIP(), []int{173} +} + +func (x *WorkflowCallStatusResponse) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *WorkflowCallStatusResponse) GetDetail() string { + if x != nil { + return x.Detail + } + return "" +} + type InstalledPackage struct { state protoimpl.MessageState `protogen:"open.v1"` OrgId string `protobuf:"bytes,1,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"` @@ -9121,7 +9361,7 @@ type InstalledPackage struct { func (x *InstalledPackage) Reset() { *x = InstalledPackage{} - mi := &file_state_v1_state_proto_msgTypes[170] + mi := &file_state_v1_state_proto_msgTypes[174] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9133,7 +9373,7 @@ func (x *InstalledPackage) String() string { func (*InstalledPackage) ProtoMessage() {} func (x *InstalledPackage) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[170] + mi := &file_state_v1_state_proto_msgTypes[174] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9146,7 +9386,7 @@ func (x *InstalledPackage) ProtoReflect() protoreflect.Message { // Deprecated: Use InstalledPackage.ProtoReflect.Descriptor instead. func (*InstalledPackage) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{170} + return file_state_v1_state_proto_rawDescGZIP(), []int{174} } func (x *InstalledPackage) GetOrgId() string { @@ -9210,7 +9450,7 @@ type InstallPackageRequest struct { func (x *InstallPackageRequest) Reset() { *x = InstallPackageRequest{} - mi := &file_state_v1_state_proto_msgTypes[171] + mi := &file_state_v1_state_proto_msgTypes[175] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9222,7 +9462,7 @@ func (x *InstallPackageRequest) String() string { func (*InstallPackageRequest) ProtoMessage() {} func (x *InstallPackageRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[171] + mi := &file_state_v1_state_proto_msgTypes[175] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9235,7 +9475,7 @@ func (x *InstallPackageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InstallPackageRequest.ProtoReflect.Descriptor instead. func (*InstallPackageRequest) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{171} + return file_state_v1_state_proto_rawDescGZIP(), []int{175} } func (x *InstallPackageRequest) GetOrgId() string { @@ -9275,7 +9515,7 @@ type InstallPackageResponse struct { func (x *InstallPackageResponse) Reset() { *x = InstallPackageResponse{} - mi := &file_state_v1_state_proto_msgTypes[172] + mi := &file_state_v1_state_proto_msgTypes[176] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9287,7 +9527,7 @@ func (x *InstallPackageResponse) String() string { func (*InstallPackageResponse) ProtoMessage() {} func (x *InstallPackageResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[172] + mi := &file_state_v1_state_proto_msgTypes[176] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9300,7 +9540,7 @@ func (x *InstallPackageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use InstallPackageResponse.ProtoReflect.Descriptor instead. func (*InstallPackageResponse) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{172} + return file_state_v1_state_proto_rawDescGZIP(), []int{176} } func (x *InstallPackageResponse) GetPackage() *InstalledPackage { @@ -9320,7 +9560,7 @@ type GetInstalledPackageRequest struct { func (x *GetInstalledPackageRequest) Reset() { *x = GetInstalledPackageRequest{} - mi := &file_state_v1_state_proto_msgTypes[173] + mi := &file_state_v1_state_proto_msgTypes[177] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9332,7 +9572,7 @@ func (x *GetInstalledPackageRequest) String() string { func (*GetInstalledPackageRequest) ProtoMessage() {} func (x *GetInstalledPackageRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[173] + mi := &file_state_v1_state_proto_msgTypes[177] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9345,7 +9585,7 @@ func (x *GetInstalledPackageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInstalledPackageRequest.ProtoReflect.Descriptor instead. func (*GetInstalledPackageRequest) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{173} + return file_state_v1_state_proto_rawDescGZIP(), []int{177} } func (x *GetInstalledPackageRequest) GetOrgId() string { @@ -9371,7 +9611,7 @@ type GetInstalledPackageResponse struct { func (x *GetInstalledPackageResponse) Reset() { *x = GetInstalledPackageResponse{} - mi := &file_state_v1_state_proto_msgTypes[174] + mi := &file_state_v1_state_proto_msgTypes[178] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9383,7 +9623,7 @@ func (x *GetInstalledPackageResponse) String() string { func (*GetInstalledPackageResponse) ProtoMessage() {} func (x *GetInstalledPackageResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[174] + mi := &file_state_v1_state_proto_msgTypes[178] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9396,7 +9636,7 @@ func (x *GetInstalledPackageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInstalledPackageResponse.ProtoReflect.Descriptor instead. func (*GetInstalledPackageResponse) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{174} + return file_state_v1_state_proto_rawDescGZIP(), []int{178} } func (x *GetInstalledPackageResponse) GetPackage() *InstalledPackage { @@ -9415,7 +9655,7 @@ type ListInstalledPackagesRequest struct { func (x *ListInstalledPackagesRequest) Reset() { *x = ListInstalledPackagesRequest{} - mi := &file_state_v1_state_proto_msgTypes[175] + mi := &file_state_v1_state_proto_msgTypes[179] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9427,7 +9667,7 @@ func (x *ListInstalledPackagesRequest) String() string { func (*ListInstalledPackagesRequest) ProtoMessage() {} func (x *ListInstalledPackagesRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[175] + mi := &file_state_v1_state_proto_msgTypes[179] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9440,7 +9680,7 @@ func (x *ListInstalledPackagesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListInstalledPackagesRequest.ProtoReflect.Descriptor instead. func (*ListInstalledPackagesRequest) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{175} + return file_state_v1_state_proto_rawDescGZIP(), []int{179} } func (x *ListInstalledPackagesRequest) GetOrgId() string { @@ -9459,7 +9699,7 @@ type ListInstalledPackagesResponse struct { func (x *ListInstalledPackagesResponse) Reset() { *x = ListInstalledPackagesResponse{} - mi := &file_state_v1_state_proto_msgTypes[176] + mi := &file_state_v1_state_proto_msgTypes[180] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9471,7 +9711,7 @@ func (x *ListInstalledPackagesResponse) String() string { func (*ListInstalledPackagesResponse) ProtoMessage() {} func (x *ListInstalledPackagesResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[176] + mi := &file_state_v1_state_proto_msgTypes[180] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9484,7 +9724,7 @@ func (x *ListInstalledPackagesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListInstalledPackagesResponse.ProtoReflect.Descriptor instead. func (*ListInstalledPackagesResponse) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{176} + return file_state_v1_state_proto_rawDescGZIP(), []int{180} } func (x *ListInstalledPackagesResponse) GetPackages() []*InstalledPackage { @@ -9504,7 +9744,7 @@ type RemoveInstalledPackageRequest struct { func (x *RemoveInstalledPackageRequest) Reset() { *x = RemoveInstalledPackageRequest{} - mi := &file_state_v1_state_proto_msgTypes[177] + mi := &file_state_v1_state_proto_msgTypes[181] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9516,7 +9756,7 @@ func (x *RemoveInstalledPackageRequest) String() string { func (*RemoveInstalledPackageRequest) ProtoMessage() {} func (x *RemoveInstalledPackageRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[177] + mi := &file_state_v1_state_proto_msgTypes[181] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9529,7 +9769,7 @@ func (x *RemoveInstalledPackageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveInstalledPackageRequest.ProtoReflect.Descriptor instead. func (*RemoveInstalledPackageRequest) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{177} + return file_state_v1_state_proto_rawDescGZIP(), []int{181} } func (x *RemoveInstalledPackageRequest) GetOrgId() string { @@ -9554,7 +9794,7 @@ type RemoveInstalledPackageResponse struct { func (x *RemoveInstalledPackageResponse) Reset() { *x = RemoveInstalledPackageResponse{} - mi := &file_state_v1_state_proto_msgTypes[178] + mi := &file_state_v1_state_proto_msgTypes[182] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -9566,7 +9806,7 @@ func (x *RemoveInstalledPackageResponse) String() string { func (*RemoveInstalledPackageResponse) ProtoMessage() {} func (x *RemoveInstalledPackageResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_state_proto_msgTypes[178] + mi := &file_state_v1_state_proto_msgTypes[182] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -9579,7 +9819,7 @@ func (x *RemoveInstalledPackageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveInstalledPackageResponse.ProtoReflect.Descriptor instead. func (*RemoveInstalledPackageResponse) Descriptor() ([]byte, []int) { - return file_state_v1_state_proto_rawDescGZIP(), []int{178} + return file_state_v1_state_proto_rawDescGZIP(), []int{182} } var File_state_v1_state_proto protoreflect.FileDescriptor @@ -9662,7 +9902,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\"\x8c\t\n" + + "\bidentity\x18\x01 \x01(\v2\x12.state.v1.IdentityR\bidentity\"\xda\t\n" + "\x04Task\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" + "\x05owner\x18\x02 \x01(\tR\x05owner\x12\x12\n" + @@ -9709,7 +9949,10 @@ const file_state_v1_state_proto_rawDesc = "" + "\x12remediation_rounds\x18! \x01(\x05R\x11remediationRounds\x12\x1f\n" + "\vinputs_json\x18\" \x01(\tR\n" + "inputsJson\x12\x10\n" + - "\x03org\x18# \x01(\tR\x03org\"\xf8\x02\n" + + "\x03org\x18# \x01(\tR\x03org\x12-\n" + + "\x13call_parent_task_id\x18$ \x01(\x03R\x10callParentTaskId\x12\x1d\n" + + "\n" + + "call_depth\x18% \x01(\x05R\tcallDepth\"\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" + @@ -10178,7 +10421,22 @@ const file_state_v1_state_proto_rawDesc = "" + "\vinputs_json\x18\t \x01(\tR\n" + "inputsJson\"@\n" + "\x1aEnqueueBindingTaskResponse\x12\"\n" + - "\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"\xd7\x01\n" + + "\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"{\n" + + "\x16EnqueueCallTaskRequest\x12$\n" + + "\x0ecaller_task_id\x18\x01 \x01(\x03R\fcallerTaskId\x12\x1a\n" + + "\bworkflow\x18\x02 \x01(\tR\bworkflow\x12\x1f\n" + + "\vinputs_json\x18\x03 \x01(\tR\n" + + "inputsJson\"Y\n" + + "\x17EnqueueCallTaskResponse\x12\"\n" + + "\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\x12\x1a\n" + + "\baccepted\x18\x02 \x01(\bR\baccepted\"c\n" + + "\x19WorkflowCallStatusRequest\x12$\n" + + "\x0ecaller_task_id\x18\x01 \x01(\x03R\fcallerTaskId\x12 \n" + + "\fcall_task_id\x18\x02 \x01(\x03R\n" + + "callTaskId\"L\n" + + "\x1aWorkflowCallStatusResponse\x12\x16\n" + + "\x06status\x18\x01 \x01(\tR\x06status\x12\x16\n" + + "\x06detail\x18\x02 \x01(\tR\x06detail\"\xd7\x01\n" + "\x10InstalledPackage\x12\x15\n" + "\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x1c\n" + @@ -10206,7 +10464,7 @@ const file_state_v1_state_proto_rawDesc = "" + "\x1dRemoveInstalledPackageRequest\x12\x15\n" + "\x06org_id\x18\x01 \x01(\tR\x05orgId\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\" \n" + - "\x1eRemoveInstalledPackageResponse2\xd44\n" + + "\x1eRemoveInstalledPackageResponse2\x8d6\n" + "\x11StateStoreService\x12S\n" + "\x0eInstallPackage\x12\x1f.state.v1.InstallPackageRequest\x1a .state.v1.InstallPackageResponse\x12b\n" + "\x13GetInstalledPackage\x12$.state.v1.GetInstalledPackageRequest\x1a%.state.v1.GetInstalledPackageResponse\x12h\n" + @@ -10291,7 +10549,9 @@ const file_state_v1_state_proto_rawDesc = "" + "\x16RecordPlaybookDispatch\x12'.state.v1.RecordPlaybookDispatchRequest\x1a(.state.v1.RecordPlaybookDispatchResponse\x12q\n" + "\x18DeletePlaybookDispatches\x12).state.v1.DeletePlaybookDispatchesRequest\x1a*.state.v1.DeletePlaybookDispatchesResponse\x12y\n" + "\x1aStreamUndispatchedCaptures\x12+.state.v1.StreamUndispatchedCapturesRequest\x1a,.state.v1.StreamUndispatchedCapturesResponse0\x01\x12_\n" + - "\x12EnqueueBindingTask\x12#.state.v1.EnqueueBindingTaskRequest\x1a$.state.v1.EnqueueBindingTaskResponseB\xa4\x01\n" + + "\x12EnqueueBindingTask\x12#.state.v1.EnqueueBindingTaskRequest\x1a$.state.v1.EnqueueBindingTaskResponse\x12V\n" + + "\x0fEnqueueCallTask\x12 .state.v1.EnqueueCallTaskRequest\x1a!.state.v1.EnqueueCallTaskResponse\x12_\n" + + "\x12WorkflowCallStatus\x12#.state.v1.WorkflowCallStatusRequest\x1a$.state.v1.WorkflowCallStatusResponseB\xa4\x01\n" + "\fcom.state.v1B\n" + "StateProtoP\x01ZGgithub.com/samcharles93/archie-core/internal/contracts/state/v1;statev1\xa2\x02\x03SXX\xaa\x02\bState.V1\xca\x02\bState\\V1\xe2\x02\x14State\\V1\\GPBMetadata\xea\x02\tState::V1b\x06proto3" @@ -10307,7 +10567,7 @@ func file_state_v1_state_proto_rawDescGZIP() []byte { return file_state_v1_state_proto_rawDescData } -var file_state_v1_state_proto_msgTypes = make([]protoimpl.MessageInfo, 181) +var file_state_v1_state_proto_msgTypes = make([]protoimpl.MessageInfo, 185) var file_state_v1_state_proto_goTypes = []any{ (*RegisterTaskGrantRequest)(nil), // 0: state.v1.RegisterTaskGrantRequest (*RegisterTaskGrantResponse)(nil), // 1: state.v1.RegisterTaskGrantResponse @@ -10479,22 +10739,26 @@ var file_state_v1_state_proto_goTypes = []any{ (*StreamUndispatchedCapturesResponse)(nil), // 167: state.v1.StreamUndispatchedCapturesResponse (*EnqueueBindingTaskRequest)(nil), // 168: state.v1.EnqueueBindingTaskRequest (*EnqueueBindingTaskResponse)(nil), // 169: state.v1.EnqueueBindingTaskResponse - (*InstalledPackage)(nil), // 170: state.v1.InstalledPackage - (*InstallPackageRequest)(nil), // 171: state.v1.InstallPackageRequest - (*InstallPackageResponse)(nil), // 172: state.v1.InstallPackageResponse - (*GetInstalledPackageRequest)(nil), // 173: state.v1.GetInstalledPackageRequest - (*GetInstalledPackageResponse)(nil), // 174: state.v1.GetInstalledPackageResponse - (*ListInstalledPackagesRequest)(nil), // 175: state.v1.ListInstalledPackagesRequest - (*ListInstalledPackagesResponse)(nil), // 176: state.v1.ListInstalledPackagesResponse - (*RemoveInstalledPackageRequest)(nil), // 177: state.v1.RemoveInstalledPackageRequest - (*RemoveInstalledPackageResponse)(nil), // 178: state.v1.RemoveInstalledPackageResponse - nil, // 179: state.v1.EventType.SchemaEntry - nil, // 180: state.v1.StatusCountsResponse.CountsEntry - (*timestamppb.Timestamp)(nil), // 181: google.protobuf.Timestamp + (*EnqueueCallTaskRequest)(nil), // 170: state.v1.EnqueueCallTaskRequest + (*EnqueueCallTaskResponse)(nil), // 171: state.v1.EnqueueCallTaskResponse + (*WorkflowCallStatusRequest)(nil), // 172: state.v1.WorkflowCallStatusRequest + (*WorkflowCallStatusResponse)(nil), // 173: state.v1.WorkflowCallStatusResponse + (*InstalledPackage)(nil), // 174: state.v1.InstalledPackage + (*InstallPackageRequest)(nil), // 175: state.v1.InstallPackageRequest + (*InstallPackageResponse)(nil), // 176: state.v1.InstallPackageResponse + (*GetInstalledPackageRequest)(nil), // 177: state.v1.GetInstalledPackageRequest + (*GetInstalledPackageResponse)(nil), // 178: state.v1.GetInstalledPackageResponse + (*ListInstalledPackagesRequest)(nil), // 179: state.v1.ListInstalledPackagesRequest + (*ListInstalledPackagesResponse)(nil), // 180: state.v1.ListInstalledPackagesResponse + (*RemoveInstalledPackageRequest)(nil), // 181: state.v1.RemoveInstalledPackageRequest + (*RemoveInstalledPackageResponse)(nil), // 182: state.v1.RemoveInstalledPackageResponse + nil, // 183: state.v1.EventType.SchemaEntry + nil, // 184: state.v1.StatusCountsResponse.CountsEntry + (*timestamppb.Timestamp)(nil), // 185: google.protobuf.Timestamp } var file_state_v1_state_proto_depIdxs = []int32{ - 181, // 0: state.v1.Identity.created_at:type_name -> google.protobuf.Timestamp - 181, // 1: state.v1.Identity.updated_at:type_name -> google.protobuf.Timestamp + 185, // 0: state.v1.Identity.created_at:type_name -> google.protobuf.Timestamp + 185, // 1: state.v1.Identity.updated_at:type_name -> google.protobuf.Timestamp 4, // 2: state.v1.ListIdentitiesResponse.identities:type_name -> state.v1.Identity 4, // 3: state.v1.GetIdentityResponse.identity:type_name -> state.v1.Identity 5, // 4: state.v1.CreateIdentityRequest.audit:type_name -> state.v1.IdentityAudit @@ -10510,24 +10774,24 @@ var file_state_v1_state_proto_depIdxs = []int32{ 4, // 14: state.v1.ResolveIdentitySubjectResponse.identity:type_name -> state.v1.Identity 5, // 15: state.v1.BindIdentitySubjectRequest.audit:type_name -> state.v1.IdentityAudit 4, // 16: state.v1.BindIdentitySubjectResponse.identity:type_name -> state.v1.Identity - 181, // 17: state.v1.Task.created_at:type_name -> google.protobuf.Timestamp - 181, // 18: state.v1.Task.updated_at:type_name -> google.protobuf.Timestamp - 181, // 19: state.v1.Event.at:type_name -> google.protobuf.Timestamp - 181, // 20: state.v1.CapturedEvent.received_at:type_name -> google.protobuf.Timestamp + 185, // 17: state.v1.Task.created_at:type_name -> google.protobuf.Timestamp + 185, // 18: state.v1.Task.updated_at:type_name -> google.protobuf.Timestamp + 185, // 19: state.v1.Event.at:type_name -> google.protobuf.Timestamp + 185, // 20: state.v1.CapturedEvent.received_at:type_name -> google.protobuf.Timestamp 27, // 21: state.v1.EventType.header_conditions:type_name -> state.v1.EventTypeHeaderCondition 28, // 22: state.v1.EventType.payload_conditions:type_name -> state.v1.EventTypePayloadCondition - 179, // 23: state.v1.EventType.schema:type_name -> state.v1.EventType.SchemaEntry - 181, // 24: state.v1.EventType.created_at:type_name -> google.protobuf.Timestamp - 181, // 25: state.v1.EventType.updated_at:type_name -> google.protobuf.Timestamp + 183, // 23: state.v1.EventType.schema:type_name -> state.v1.EventType.SchemaEntry + 185, // 24: state.v1.EventType.created_at:type_name -> google.protobuf.Timestamp + 185, // 25: state.v1.EventType.updated_at:type_name -> google.protobuf.Timestamp 30, // 26: state.v1.Mapping.fields:type_name -> state.v1.MappingField - 181, // 27: state.v1.Mapping.created_at:type_name -> google.protobuf.Timestamp - 181, // 28: state.v1.Mapping.updated_at:type_name -> google.protobuf.Timestamp - 181, // 29: state.v1.Mapping.last_matched_at:type_name -> google.protobuf.Timestamp + 185, // 27: state.v1.Mapping.created_at:type_name -> google.protobuf.Timestamp + 185, // 28: state.v1.Mapping.updated_at:type_name -> google.protobuf.Timestamp + 185, // 29: state.v1.Mapping.last_matched_at:type_name -> google.protobuf.Timestamp 32, // 30: state.v1.Binding.matcher:type_name -> state.v1.BindingMatcher - 181, // 31: state.v1.Binding.created_at:type_name -> google.protobuf.Timestamp - 181, // 32: state.v1.Binding.updated_at:type_name -> google.protobuf.Timestamp - 181, // 33: state.v1.Source.created_at:type_name -> google.protobuf.Timestamp - 181, // 34: state.v1.Source.updated_at:type_name -> google.protobuf.Timestamp + 185, // 31: state.v1.Binding.created_at:type_name -> google.protobuf.Timestamp + 185, // 32: state.v1.Binding.updated_at:type_name -> google.protobuf.Timestamp + 185, // 33: state.v1.Source.created_at:type_name -> google.protobuf.Timestamp + 185, // 34: state.v1.Source.updated_at:type_name -> google.protobuf.Timestamp 24, // 35: state.v1.EnqueueChatTaskResponse.task:type_name -> state.v1.Task 24, // 36: state.v1.ClaimNextResponse.task:type_name -> state.v1.Task 24, // 37: state.v1.ClaimByIssueResponse.task:type_name -> state.v1.Task @@ -10538,25 +10802,25 @@ var file_state_v1_state_proto_depIdxs = []int32{ 24, // 42: state.v1.TaskByIDResponse.task:type_name -> state.v1.Task 24, // 43: state.v1.OpenPRsResponse.tasks:type_name -> state.v1.Task 24, // 44: state.v1.TasksResponse.tasks:type_name -> state.v1.Task - 180, // 45: state.v1.StatusCountsResponse.counts:type_name -> state.v1.StatusCountsResponse.CountsEntry + 184, // 45: state.v1.StatusCountsResponse.counts:type_name -> state.v1.StatusCountsResponse.CountsEntry 25, // 46: state.v1.InsertEventRequest.event:type_name -> state.v1.Event 25, // 47: state.v1.EventsSinceResponse.events:type_name -> state.v1.Event 25, // 48: state.v1.TaskEventsResponse.events:type_name -> state.v1.Event 35, // 49: state.v1.WorkflowStatsResponse.stats:type_name -> state.v1.WorkflowStat 36, // 50: state.v1.StageStatsResponse.stats:type_name -> state.v1.StageStat 37, // 51: state.v1.TokensByDayResponse.tokens:type_name -> state.v1.DayTokens - 181, // 52: state.v1.ConfigSnapshot.published_at:type_name -> google.protobuf.Timestamp + 185, // 52: state.v1.ConfigSnapshot.published_at:type_name -> google.protobuf.Timestamp 92, // 53: state.v1.PutConfigSnapshotRequest.snapshot:type_name -> state.v1.ConfigSnapshot 92, // 54: state.v1.GetConfigSnapshotResponse.snapshot:type_name -> state.v1.ConfigSnapshot - 181, // 55: state.v1.ChannelStatus.observed_at:type_name -> google.protobuf.Timestamp + 185, // 55: state.v1.ChannelStatus.observed_at:type_name -> google.protobuf.Timestamp 97, // 56: state.v1.PutChannelStatusRequest.channels:type_name -> state.v1.ChannelStatus 97, // 57: state.v1.ListChannelStatusResponse.channels:type_name -> state.v1.ChannelStatus - 181, // 58: state.v1.ApplyStatus.reported_at:type_name -> google.protobuf.Timestamp + 185, // 58: state.v1.ApplyStatus.reported_at:type_name -> google.protobuf.Timestamp 102, // 59: state.v1.PutApplyStatusRequest.status:type_name -> state.v1.ApplyStatus 102, // 60: state.v1.ListApplyStatusResponse.statuses:type_name -> state.v1.ApplyStatus - 181, // 61: state.v1.TaskLogEntry.time:type_name -> google.protobuf.Timestamp - 181, // 62: state.v1.ReadTaskLogRequest.since:type_name -> google.protobuf.Timestamp - 181, // 63: state.v1.ReadTaskLogRequest.until:type_name -> google.protobuf.Timestamp + 185, // 61: state.v1.TaskLogEntry.time:type_name -> google.protobuf.Timestamp + 185, // 62: state.v1.ReadTaskLogRequest.since:type_name -> google.protobuf.Timestamp + 185, // 63: state.v1.ReadTaskLogRequest.until:type_name -> google.protobuf.Timestamp 107, // 64: state.v1.ReadTaskLogResponse.entries:type_name -> state.v1.TaskLogEntry 26, // 65: state.v1.InsertCaptureRequest.capture:type_name -> state.v1.CapturedEvent 26, // 66: state.v1.StreamCapturesResponse.capture:type_name -> state.v1.CapturedEvent @@ -10577,172 +10841,177 @@ var file_state_v1_state_proto_depIdxs = []int32{ 33, // 81: state.v1.ArmedBindingsForSourceResponse.bindings:type_name -> state.v1.Binding 26, // 82: state.v1.StreamUndispatchedCapturesResponse.capture:type_name -> state.v1.CapturedEvent 24, // 83: state.v1.EnqueueBindingTaskResponse.task:type_name -> state.v1.Task - 170, // 84: state.v1.InstallPackageResponse.package:type_name -> state.v1.InstalledPackage - 170, // 85: state.v1.GetInstalledPackageResponse.package:type_name -> state.v1.InstalledPackage - 170, // 86: state.v1.ListInstalledPackagesResponse.packages:type_name -> state.v1.InstalledPackage - 171, // 87: state.v1.StateStoreService.InstallPackage:input_type -> state.v1.InstallPackageRequest - 173, // 88: state.v1.StateStoreService.GetInstalledPackage:input_type -> state.v1.GetInstalledPackageRequest - 175, // 89: state.v1.StateStoreService.ListInstalledPackages:input_type -> state.v1.ListInstalledPackagesRequest - 177, // 90: state.v1.StateStoreService.RemoveInstalledPackage:input_type -> state.v1.RemoveInstalledPackageRequest - 0, // 91: state.v1.StateStoreService.RegisterTaskGrant:input_type -> state.v1.RegisterTaskGrantRequest - 2, // 92: state.v1.StateStoreService.RevokeTaskGrant:input_type -> state.v1.RevokeTaskGrantRequest - 6, // 93: state.v1.StateStoreService.ListIdentities:input_type -> state.v1.ListIdentitiesRequest - 8, // 94: state.v1.StateStoreService.GetIdentity:input_type -> state.v1.GetIdentityRequest - 10, // 95: state.v1.StateStoreService.CreateIdentity:input_type -> state.v1.CreateIdentityRequest - 11, // 96: state.v1.StateStoreService.RenameIdentity:input_type -> state.v1.RenameIdentityRequest - 12, // 97: state.v1.StateStoreService.SuspendIdentity:input_type -> state.v1.SuspendIdentityRequest - 13, // 98: state.v1.StateStoreService.ReactivateIdentity:input_type -> state.v1.ReactivateIdentityRequest - 14, // 99: state.v1.StateStoreService.RetireIdentity:input_type -> state.v1.RetireIdentityRequest - 20, // 100: state.v1.StateStoreService.ResolveIdentitySubject:input_type -> state.v1.ResolveIdentitySubjectRequest - 22, // 101: state.v1.StateStoreService.BindIdentitySubject:input_type -> state.v1.BindIdentitySubjectRequest - 38, // 102: state.v1.StateStoreService.EnqueueIssue:input_type -> state.v1.EnqueueIssueRequest - 40, // 103: state.v1.StateStoreService.EnqueueChatTask:input_type -> state.v1.EnqueueChatTaskRequest - 42, // 104: state.v1.StateStoreService.ClaimNext:input_type -> state.v1.ClaimNextRequest - 44, // 105: state.v1.StateStoreService.ClaimByIssue:input_type -> state.v1.ClaimByIssueRequest - 46, // 106: state.v1.StateStoreService.Transition:input_type -> state.v1.TransitionRequest - 48, // 107: state.v1.StateStoreService.Update:input_type -> state.v1.UpdateRequest - 50, // 108: state.v1.StateStoreService.Requeue:input_type -> state.v1.RequeueRequest - 52, // 109: state.v1.StateStoreService.ParkTask:input_type -> state.v1.ParkTaskRequest - 54, // 110: state.v1.StateStoreService.RecoverStale:input_type -> state.v1.RecoverStaleRequest - 56, // 111: state.v1.StateStoreService.ArchiveTask:input_type -> state.v1.ArchiveTaskRequest - 58, // 112: state.v1.StateStoreService.RetryTask:input_type -> state.v1.RetryTaskRequest - 60, // 113: state.v1.StateStoreService.BeginRemediation:input_type -> state.v1.BeginRemediationRequest - 62, // 114: state.v1.StateStoreService.UpdateReviewPayload:input_type -> state.v1.UpdateReviewPayloadRequest - 64, // 115: state.v1.StateStoreService.SetReviewCursors:input_type -> state.v1.SetReviewCursorsRequest - 66, // 116: state.v1.StateStoreService.TaskByIssue:input_type -> state.v1.TaskByIssueRequest - 68, // 117: state.v1.StateStoreService.OpenTaskByPR:input_type -> state.v1.OpenTaskByPRRequest - 70, // 118: state.v1.StateStoreService.TaskByID:input_type -> state.v1.TaskByIDRequest - 72, // 119: state.v1.StateStoreService.OpenPRs:input_type -> state.v1.OpenPRsRequest - 74, // 120: state.v1.StateStoreService.ClearTerminalTasks:input_type -> state.v1.ClearTerminalTasksRequest - 76, // 121: state.v1.StateStoreService.Tasks:input_type -> state.v1.TasksRequest - 78, // 122: state.v1.StateStoreService.StatusCounts:input_type -> state.v1.StatusCountsRequest - 80, // 123: state.v1.StateStoreService.InsertEvent:input_type -> state.v1.InsertEventRequest - 82, // 124: state.v1.StateStoreService.EventsSince:input_type -> state.v1.EventsSinceRequest - 84, // 125: state.v1.StateStoreService.TaskEvents:input_type -> state.v1.TaskEventsRequest - 86, // 126: state.v1.StateStoreService.WorkflowStats:input_type -> state.v1.WorkflowStatsRequest - 88, // 127: state.v1.StateStoreService.StageStats:input_type -> state.v1.StageStatsRequest - 90, // 128: state.v1.StateStoreService.TokensByDay:input_type -> state.v1.TokensByDayRequest - 93, // 129: state.v1.StateStoreService.PutConfigSnapshot:input_type -> state.v1.PutConfigSnapshotRequest - 95, // 130: state.v1.StateStoreService.GetConfigSnapshot:input_type -> state.v1.GetConfigSnapshotRequest - 98, // 131: state.v1.StateStoreService.PutChannelStatus:input_type -> state.v1.PutChannelStatusRequest - 100, // 132: state.v1.StateStoreService.ListChannelStatus:input_type -> state.v1.ListChannelStatusRequest - 103, // 133: state.v1.StateStoreService.PutApplyStatus:input_type -> state.v1.PutApplyStatusRequest - 105, // 134: state.v1.StateStoreService.ListApplyStatus:input_type -> state.v1.ListApplyStatusRequest - 108, // 135: state.v1.StateStoreService.ReadTaskLog:input_type -> state.v1.ReadTaskLogRequest - 110, // 136: state.v1.StateStoreService.StreamTaskLogContent:input_type -> state.v1.StreamTaskLogContentRequest - 112, // 137: state.v1.StateStoreService.InsertCapture:input_type -> state.v1.InsertCaptureRequest - 114, // 138: state.v1.StateStoreService.StreamCaptures:input_type -> state.v1.StreamCapturesRequest - 116, // 139: state.v1.StateStoreService.InsertMapping:input_type -> state.v1.InsertMappingRequest - 118, // 140: state.v1.StateStoreService.GetMapping:input_type -> state.v1.GetMappingRequest - 120, // 141: state.v1.StateStoreService.ListMappings:input_type -> state.v1.ListMappingsRequest - 122, // 142: state.v1.StateStoreService.UpdateMapping:input_type -> state.v1.UpdateMappingRequest - 124, // 143: state.v1.StateStoreService.DeleteMapping:input_type -> state.v1.DeleteMappingRequest - 126, // 144: state.v1.StateStoreService.RecordMappingMatch:input_type -> state.v1.RecordMappingMatchRequest - 128, // 145: state.v1.StateStoreService.InsertEventType:input_type -> state.v1.InsertEventTypeRequest - 130, // 146: state.v1.StateStoreService.UpdateEventType:input_type -> state.v1.UpdateEventTypeRequest - 132, // 147: state.v1.StateStoreService.DeleteEventType:input_type -> state.v1.DeleteEventTypeRequest - 134, // 148: state.v1.StateStoreService.ListEventTypes:input_type -> state.v1.ListEventTypesRequest - 136, // 149: state.v1.StateStoreService.InsertBinding:input_type -> state.v1.InsertBindingRequest - 138, // 150: state.v1.StateStoreService.GetBinding:input_type -> state.v1.GetBindingRequest - 140, // 151: state.v1.StateStoreService.ListBindings:input_type -> state.v1.ListBindingsRequest - 142, // 152: state.v1.StateStoreService.UpdateBinding:input_type -> state.v1.UpdateBindingRequest - 144, // 153: state.v1.StateStoreService.DeleteBinding:input_type -> state.v1.DeleteBindingRequest - 146, // 154: state.v1.StateStoreService.ApproveBinding:input_type -> state.v1.ApproveBindingRequest - 148, // 155: state.v1.StateStoreService.InsertSource:input_type -> state.v1.InsertSourceRequest - 150, // 156: state.v1.StateStoreService.GetSource:input_type -> state.v1.GetSourceRequest - 152, // 157: state.v1.StateStoreService.ListSources:input_type -> state.v1.ListSourcesRequest - 154, // 158: state.v1.StateStoreService.SetSourceSigning:input_type -> state.v1.SetSourceSigningRequest - 156, // 159: state.v1.StateStoreService.SetSourceSecret:input_type -> state.v1.SetSourceSecretRequest - 158, // 160: state.v1.StateStoreService.ArmedBindingsForSource:input_type -> state.v1.ArmedBindingsForSourceRequest - 160, // 161: state.v1.StateStoreService.RecordDispatch:input_type -> state.v1.RecordDispatchRequest - 162, // 162: state.v1.StateStoreService.RecordPlaybookDispatch:input_type -> state.v1.RecordPlaybookDispatchRequest - 164, // 163: state.v1.StateStoreService.DeletePlaybookDispatches:input_type -> state.v1.DeletePlaybookDispatchesRequest - 166, // 164: state.v1.StateStoreService.StreamUndispatchedCaptures:input_type -> state.v1.StreamUndispatchedCapturesRequest - 168, // 165: state.v1.StateStoreService.EnqueueBindingTask:input_type -> state.v1.EnqueueBindingTaskRequest - 172, // 166: state.v1.StateStoreService.InstallPackage:output_type -> state.v1.InstallPackageResponse - 174, // 167: state.v1.StateStoreService.GetInstalledPackage:output_type -> state.v1.GetInstalledPackageResponse - 176, // 168: state.v1.StateStoreService.ListInstalledPackages:output_type -> state.v1.ListInstalledPackagesResponse - 178, // 169: state.v1.StateStoreService.RemoveInstalledPackage:output_type -> state.v1.RemoveInstalledPackageResponse - 1, // 170: state.v1.StateStoreService.RegisterTaskGrant:output_type -> state.v1.RegisterTaskGrantResponse - 3, // 171: state.v1.StateStoreService.RevokeTaskGrant:output_type -> state.v1.RevokeTaskGrantResponse - 7, // 172: state.v1.StateStoreService.ListIdentities:output_type -> state.v1.ListIdentitiesResponse - 9, // 173: state.v1.StateStoreService.GetIdentity:output_type -> state.v1.GetIdentityResponse - 15, // 174: state.v1.StateStoreService.CreateIdentity:output_type -> state.v1.CreateIdentityResponse - 16, // 175: state.v1.StateStoreService.RenameIdentity:output_type -> state.v1.RenameIdentityResponse - 17, // 176: state.v1.StateStoreService.SuspendIdentity:output_type -> state.v1.SuspendIdentityResponse - 18, // 177: state.v1.StateStoreService.ReactivateIdentity:output_type -> state.v1.ReactivateIdentityResponse - 19, // 178: state.v1.StateStoreService.RetireIdentity:output_type -> state.v1.RetireIdentityResponse - 21, // 179: state.v1.StateStoreService.ResolveIdentitySubject:output_type -> state.v1.ResolveIdentitySubjectResponse - 23, // 180: state.v1.StateStoreService.BindIdentitySubject:output_type -> state.v1.BindIdentitySubjectResponse - 39, // 181: state.v1.StateStoreService.EnqueueIssue:output_type -> state.v1.EnqueueIssueResponse - 41, // 182: state.v1.StateStoreService.EnqueueChatTask:output_type -> state.v1.EnqueueChatTaskResponse - 43, // 183: state.v1.StateStoreService.ClaimNext:output_type -> state.v1.ClaimNextResponse - 45, // 184: state.v1.StateStoreService.ClaimByIssue:output_type -> state.v1.ClaimByIssueResponse - 47, // 185: state.v1.StateStoreService.Transition:output_type -> state.v1.TransitionResponse - 49, // 186: state.v1.StateStoreService.Update:output_type -> state.v1.UpdateResponse - 51, // 187: state.v1.StateStoreService.Requeue:output_type -> state.v1.RequeueResponse - 53, // 188: state.v1.StateStoreService.ParkTask:output_type -> state.v1.ParkTaskResponse - 55, // 189: state.v1.StateStoreService.RecoverStale:output_type -> state.v1.RecoverStaleResponse - 57, // 190: state.v1.StateStoreService.ArchiveTask:output_type -> state.v1.ArchiveTaskResponse - 59, // 191: state.v1.StateStoreService.RetryTask:output_type -> state.v1.RetryTaskResponse - 61, // 192: state.v1.StateStoreService.BeginRemediation:output_type -> state.v1.BeginRemediationResponse - 63, // 193: state.v1.StateStoreService.UpdateReviewPayload:output_type -> state.v1.UpdateReviewPayloadResponse - 65, // 194: state.v1.StateStoreService.SetReviewCursors:output_type -> state.v1.SetReviewCursorsResponse - 67, // 195: state.v1.StateStoreService.TaskByIssue:output_type -> state.v1.TaskByIssueResponse - 69, // 196: state.v1.StateStoreService.OpenTaskByPR:output_type -> state.v1.OpenTaskByPRResponse - 71, // 197: state.v1.StateStoreService.TaskByID:output_type -> state.v1.TaskByIDResponse - 73, // 198: state.v1.StateStoreService.OpenPRs:output_type -> state.v1.OpenPRsResponse - 75, // 199: state.v1.StateStoreService.ClearTerminalTasks:output_type -> state.v1.ClearTerminalTasksResponse - 77, // 200: state.v1.StateStoreService.Tasks:output_type -> state.v1.TasksResponse - 79, // 201: state.v1.StateStoreService.StatusCounts:output_type -> state.v1.StatusCountsResponse - 81, // 202: state.v1.StateStoreService.InsertEvent:output_type -> state.v1.InsertEventResponse - 83, // 203: state.v1.StateStoreService.EventsSince:output_type -> state.v1.EventsSinceResponse - 85, // 204: state.v1.StateStoreService.TaskEvents:output_type -> state.v1.TaskEventsResponse - 87, // 205: state.v1.StateStoreService.WorkflowStats:output_type -> state.v1.WorkflowStatsResponse - 89, // 206: state.v1.StateStoreService.StageStats:output_type -> state.v1.StageStatsResponse - 91, // 207: state.v1.StateStoreService.TokensByDay:output_type -> state.v1.TokensByDayResponse - 94, // 208: state.v1.StateStoreService.PutConfigSnapshot:output_type -> state.v1.PutConfigSnapshotResponse - 96, // 209: state.v1.StateStoreService.GetConfigSnapshot:output_type -> state.v1.GetConfigSnapshotResponse - 99, // 210: state.v1.StateStoreService.PutChannelStatus:output_type -> state.v1.PutChannelStatusResponse - 101, // 211: state.v1.StateStoreService.ListChannelStatus:output_type -> state.v1.ListChannelStatusResponse - 104, // 212: state.v1.StateStoreService.PutApplyStatus:output_type -> state.v1.PutApplyStatusResponse - 106, // 213: state.v1.StateStoreService.ListApplyStatus:output_type -> state.v1.ListApplyStatusResponse - 109, // 214: state.v1.StateStoreService.ReadTaskLog:output_type -> state.v1.ReadTaskLogResponse - 111, // 215: state.v1.StateStoreService.StreamTaskLogContent:output_type -> state.v1.StreamTaskLogContentResponse - 113, // 216: state.v1.StateStoreService.InsertCapture:output_type -> state.v1.InsertCaptureResponse - 115, // 217: state.v1.StateStoreService.StreamCaptures:output_type -> state.v1.StreamCapturesResponse - 117, // 218: state.v1.StateStoreService.InsertMapping:output_type -> state.v1.InsertMappingResponse - 119, // 219: state.v1.StateStoreService.GetMapping:output_type -> state.v1.GetMappingResponse - 121, // 220: state.v1.StateStoreService.ListMappings:output_type -> state.v1.ListMappingsResponse - 123, // 221: state.v1.StateStoreService.UpdateMapping:output_type -> state.v1.UpdateMappingResponse - 125, // 222: state.v1.StateStoreService.DeleteMapping:output_type -> state.v1.DeleteMappingResponse - 127, // 223: state.v1.StateStoreService.RecordMappingMatch:output_type -> state.v1.RecordMappingMatchResponse - 129, // 224: state.v1.StateStoreService.InsertEventType:output_type -> state.v1.InsertEventTypeResponse - 131, // 225: state.v1.StateStoreService.UpdateEventType:output_type -> state.v1.UpdateEventTypeResponse - 133, // 226: state.v1.StateStoreService.DeleteEventType:output_type -> state.v1.DeleteEventTypeResponse - 135, // 227: state.v1.StateStoreService.ListEventTypes:output_type -> state.v1.ListEventTypesResponse - 137, // 228: state.v1.StateStoreService.InsertBinding:output_type -> state.v1.InsertBindingResponse - 139, // 229: state.v1.StateStoreService.GetBinding:output_type -> state.v1.GetBindingResponse - 141, // 230: state.v1.StateStoreService.ListBindings:output_type -> state.v1.ListBindingsResponse - 143, // 231: state.v1.StateStoreService.UpdateBinding:output_type -> state.v1.UpdateBindingResponse - 145, // 232: state.v1.StateStoreService.DeleteBinding:output_type -> state.v1.DeleteBindingResponse - 147, // 233: state.v1.StateStoreService.ApproveBinding:output_type -> state.v1.ApproveBindingResponse - 149, // 234: state.v1.StateStoreService.InsertSource:output_type -> state.v1.InsertSourceResponse - 151, // 235: state.v1.StateStoreService.GetSource:output_type -> state.v1.GetSourceResponse - 153, // 236: state.v1.StateStoreService.ListSources:output_type -> state.v1.ListSourcesResponse - 155, // 237: state.v1.StateStoreService.SetSourceSigning:output_type -> state.v1.SetSourceSigningResponse - 157, // 238: state.v1.StateStoreService.SetSourceSecret:output_type -> state.v1.SetSourceSecretResponse - 159, // 239: state.v1.StateStoreService.ArmedBindingsForSource:output_type -> state.v1.ArmedBindingsForSourceResponse - 161, // 240: state.v1.StateStoreService.RecordDispatch:output_type -> state.v1.RecordDispatchResponse - 163, // 241: state.v1.StateStoreService.RecordPlaybookDispatch:output_type -> state.v1.RecordPlaybookDispatchResponse - 165, // 242: state.v1.StateStoreService.DeletePlaybookDispatches:output_type -> state.v1.DeletePlaybookDispatchesResponse - 167, // 243: state.v1.StateStoreService.StreamUndispatchedCaptures:output_type -> state.v1.StreamUndispatchedCapturesResponse - 169, // 244: state.v1.StateStoreService.EnqueueBindingTask:output_type -> state.v1.EnqueueBindingTaskResponse - 166, // [166:245] is the sub-list for method output_type - 87, // [87:166] is the sub-list for method input_type - 87, // [87:87] is the sub-list for extension type_name - 87, // [87:87] is the sub-list for extension extendee - 0, // [0:87] is the sub-list for field type_name + 24, // 84: state.v1.EnqueueCallTaskResponse.task:type_name -> state.v1.Task + 174, // 85: state.v1.InstallPackageResponse.package:type_name -> state.v1.InstalledPackage + 174, // 86: state.v1.GetInstalledPackageResponse.package:type_name -> state.v1.InstalledPackage + 174, // 87: state.v1.ListInstalledPackagesResponse.packages:type_name -> state.v1.InstalledPackage + 175, // 88: state.v1.StateStoreService.InstallPackage:input_type -> state.v1.InstallPackageRequest + 177, // 89: state.v1.StateStoreService.GetInstalledPackage:input_type -> state.v1.GetInstalledPackageRequest + 179, // 90: state.v1.StateStoreService.ListInstalledPackages:input_type -> state.v1.ListInstalledPackagesRequest + 181, // 91: state.v1.StateStoreService.RemoveInstalledPackage:input_type -> state.v1.RemoveInstalledPackageRequest + 0, // 92: state.v1.StateStoreService.RegisterTaskGrant:input_type -> state.v1.RegisterTaskGrantRequest + 2, // 93: state.v1.StateStoreService.RevokeTaskGrant:input_type -> state.v1.RevokeTaskGrantRequest + 6, // 94: state.v1.StateStoreService.ListIdentities:input_type -> state.v1.ListIdentitiesRequest + 8, // 95: state.v1.StateStoreService.GetIdentity:input_type -> state.v1.GetIdentityRequest + 10, // 96: state.v1.StateStoreService.CreateIdentity:input_type -> state.v1.CreateIdentityRequest + 11, // 97: state.v1.StateStoreService.RenameIdentity:input_type -> state.v1.RenameIdentityRequest + 12, // 98: state.v1.StateStoreService.SuspendIdentity:input_type -> state.v1.SuspendIdentityRequest + 13, // 99: state.v1.StateStoreService.ReactivateIdentity:input_type -> state.v1.ReactivateIdentityRequest + 14, // 100: state.v1.StateStoreService.RetireIdentity:input_type -> state.v1.RetireIdentityRequest + 20, // 101: state.v1.StateStoreService.ResolveIdentitySubject:input_type -> state.v1.ResolveIdentitySubjectRequest + 22, // 102: state.v1.StateStoreService.BindIdentitySubject:input_type -> state.v1.BindIdentitySubjectRequest + 38, // 103: state.v1.StateStoreService.EnqueueIssue:input_type -> state.v1.EnqueueIssueRequest + 40, // 104: state.v1.StateStoreService.EnqueueChatTask:input_type -> state.v1.EnqueueChatTaskRequest + 42, // 105: state.v1.StateStoreService.ClaimNext:input_type -> state.v1.ClaimNextRequest + 44, // 106: state.v1.StateStoreService.ClaimByIssue:input_type -> state.v1.ClaimByIssueRequest + 46, // 107: state.v1.StateStoreService.Transition:input_type -> state.v1.TransitionRequest + 48, // 108: state.v1.StateStoreService.Update:input_type -> state.v1.UpdateRequest + 50, // 109: state.v1.StateStoreService.Requeue:input_type -> state.v1.RequeueRequest + 52, // 110: state.v1.StateStoreService.ParkTask:input_type -> state.v1.ParkTaskRequest + 54, // 111: state.v1.StateStoreService.RecoverStale:input_type -> state.v1.RecoverStaleRequest + 56, // 112: state.v1.StateStoreService.ArchiveTask:input_type -> state.v1.ArchiveTaskRequest + 58, // 113: state.v1.StateStoreService.RetryTask:input_type -> state.v1.RetryTaskRequest + 60, // 114: state.v1.StateStoreService.BeginRemediation:input_type -> state.v1.BeginRemediationRequest + 62, // 115: state.v1.StateStoreService.UpdateReviewPayload:input_type -> state.v1.UpdateReviewPayloadRequest + 64, // 116: state.v1.StateStoreService.SetReviewCursors:input_type -> state.v1.SetReviewCursorsRequest + 66, // 117: state.v1.StateStoreService.TaskByIssue:input_type -> state.v1.TaskByIssueRequest + 68, // 118: state.v1.StateStoreService.OpenTaskByPR:input_type -> state.v1.OpenTaskByPRRequest + 70, // 119: state.v1.StateStoreService.TaskByID:input_type -> state.v1.TaskByIDRequest + 72, // 120: state.v1.StateStoreService.OpenPRs:input_type -> state.v1.OpenPRsRequest + 74, // 121: state.v1.StateStoreService.ClearTerminalTasks:input_type -> state.v1.ClearTerminalTasksRequest + 76, // 122: state.v1.StateStoreService.Tasks:input_type -> state.v1.TasksRequest + 78, // 123: state.v1.StateStoreService.StatusCounts:input_type -> state.v1.StatusCountsRequest + 80, // 124: state.v1.StateStoreService.InsertEvent:input_type -> state.v1.InsertEventRequest + 82, // 125: state.v1.StateStoreService.EventsSince:input_type -> state.v1.EventsSinceRequest + 84, // 126: state.v1.StateStoreService.TaskEvents:input_type -> state.v1.TaskEventsRequest + 86, // 127: state.v1.StateStoreService.WorkflowStats:input_type -> state.v1.WorkflowStatsRequest + 88, // 128: state.v1.StateStoreService.StageStats:input_type -> state.v1.StageStatsRequest + 90, // 129: state.v1.StateStoreService.TokensByDay:input_type -> state.v1.TokensByDayRequest + 93, // 130: state.v1.StateStoreService.PutConfigSnapshot:input_type -> state.v1.PutConfigSnapshotRequest + 95, // 131: state.v1.StateStoreService.GetConfigSnapshot:input_type -> state.v1.GetConfigSnapshotRequest + 98, // 132: state.v1.StateStoreService.PutChannelStatus:input_type -> state.v1.PutChannelStatusRequest + 100, // 133: state.v1.StateStoreService.ListChannelStatus:input_type -> state.v1.ListChannelStatusRequest + 103, // 134: state.v1.StateStoreService.PutApplyStatus:input_type -> state.v1.PutApplyStatusRequest + 105, // 135: state.v1.StateStoreService.ListApplyStatus:input_type -> state.v1.ListApplyStatusRequest + 108, // 136: state.v1.StateStoreService.ReadTaskLog:input_type -> state.v1.ReadTaskLogRequest + 110, // 137: state.v1.StateStoreService.StreamTaskLogContent:input_type -> state.v1.StreamTaskLogContentRequest + 112, // 138: state.v1.StateStoreService.InsertCapture:input_type -> state.v1.InsertCaptureRequest + 114, // 139: state.v1.StateStoreService.StreamCaptures:input_type -> state.v1.StreamCapturesRequest + 116, // 140: state.v1.StateStoreService.InsertMapping:input_type -> state.v1.InsertMappingRequest + 118, // 141: state.v1.StateStoreService.GetMapping:input_type -> state.v1.GetMappingRequest + 120, // 142: state.v1.StateStoreService.ListMappings:input_type -> state.v1.ListMappingsRequest + 122, // 143: state.v1.StateStoreService.UpdateMapping:input_type -> state.v1.UpdateMappingRequest + 124, // 144: state.v1.StateStoreService.DeleteMapping:input_type -> state.v1.DeleteMappingRequest + 126, // 145: state.v1.StateStoreService.RecordMappingMatch:input_type -> state.v1.RecordMappingMatchRequest + 128, // 146: state.v1.StateStoreService.InsertEventType:input_type -> state.v1.InsertEventTypeRequest + 130, // 147: state.v1.StateStoreService.UpdateEventType:input_type -> state.v1.UpdateEventTypeRequest + 132, // 148: state.v1.StateStoreService.DeleteEventType:input_type -> state.v1.DeleteEventTypeRequest + 134, // 149: state.v1.StateStoreService.ListEventTypes:input_type -> state.v1.ListEventTypesRequest + 136, // 150: state.v1.StateStoreService.InsertBinding:input_type -> state.v1.InsertBindingRequest + 138, // 151: state.v1.StateStoreService.GetBinding:input_type -> state.v1.GetBindingRequest + 140, // 152: state.v1.StateStoreService.ListBindings:input_type -> state.v1.ListBindingsRequest + 142, // 153: state.v1.StateStoreService.UpdateBinding:input_type -> state.v1.UpdateBindingRequest + 144, // 154: state.v1.StateStoreService.DeleteBinding:input_type -> state.v1.DeleteBindingRequest + 146, // 155: state.v1.StateStoreService.ApproveBinding:input_type -> state.v1.ApproveBindingRequest + 148, // 156: state.v1.StateStoreService.InsertSource:input_type -> state.v1.InsertSourceRequest + 150, // 157: state.v1.StateStoreService.GetSource:input_type -> state.v1.GetSourceRequest + 152, // 158: state.v1.StateStoreService.ListSources:input_type -> state.v1.ListSourcesRequest + 154, // 159: state.v1.StateStoreService.SetSourceSigning:input_type -> state.v1.SetSourceSigningRequest + 156, // 160: state.v1.StateStoreService.SetSourceSecret:input_type -> state.v1.SetSourceSecretRequest + 158, // 161: state.v1.StateStoreService.ArmedBindingsForSource:input_type -> state.v1.ArmedBindingsForSourceRequest + 160, // 162: state.v1.StateStoreService.RecordDispatch:input_type -> state.v1.RecordDispatchRequest + 162, // 163: state.v1.StateStoreService.RecordPlaybookDispatch:input_type -> state.v1.RecordPlaybookDispatchRequest + 164, // 164: state.v1.StateStoreService.DeletePlaybookDispatches:input_type -> state.v1.DeletePlaybookDispatchesRequest + 166, // 165: state.v1.StateStoreService.StreamUndispatchedCaptures:input_type -> state.v1.StreamUndispatchedCapturesRequest + 168, // 166: state.v1.StateStoreService.EnqueueBindingTask:input_type -> state.v1.EnqueueBindingTaskRequest + 170, // 167: state.v1.StateStoreService.EnqueueCallTask:input_type -> state.v1.EnqueueCallTaskRequest + 172, // 168: state.v1.StateStoreService.WorkflowCallStatus:input_type -> state.v1.WorkflowCallStatusRequest + 176, // 169: state.v1.StateStoreService.InstallPackage:output_type -> state.v1.InstallPackageResponse + 178, // 170: state.v1.StateStoreService.GetInstalledPackage:output_type -> state.v1.GetInstalledPackageResponse + 180, // 171: state.v1.StateStoreService.ListInstalledPackages:output_type -> state.v1.ListInstalledPackagesResponse + 182, // 172: state.v1.StateStoreService.RemoveInstalledPackage:output_type -> state.v1.RemoveInstalledPackageResponse + 1, // 173: state.v1.StateStoreService.RegisterTaskGrant:output_type -> state.v1.RegisterTaskGrantResponse + 3, // 174: state.v1.StateStoreService.RevokeTaskGrant:output_type -> state.v1.RevokeTaskGrantResponse + 7, // 175: state.v1.StateStoreService.ListIdentities:output_type -> state.v1.ListIdentitiesResponse + 9, // 176: state.v1.StateStoreService.GetIdentity:output_type -> state.v1.GetIdentityResponse + 15, // 177: state.v1.StateStoreService.CreateIdentity:output_type -> state.v1.CreateIdentityResponse + 16, // 178: state.v1.StateStoreService.RenameIdentity:output_type -> state.v1.RenameIdentityResponse + 17, // 179: state.v1.StateStoreService.SuspendIdentity:output_type -> state.v1.SuspendIdentityResponse + 18, // 180: state.v1.StateStoreService.ReactivateIdentity:output_type -> state.v1.ReactivateIdentityResponse + 19, // 181: state.v1.StateStoreService.RetireIdentity:output_type -> state.v1.RetireIdentityResponse + 21, // 182: state.v1.StateStoreService.ResolveIdentitySubject:output_type -> state.v1.ResolveIdentitySubjectResponse + 23, // 183: state.v1.StateStoreService.BindIdentitySubject:output_type -> state.v1.BindIdentitySubjectResponse + 39, // 184: state.v1.StateStoreService.EnqueueIssue:output_type -> state.v1.EnqueueIssueResponse + 41, // 185: state.v1.StateStoreService.EnqueueChatTask:output_type -> state.v1.EnqueueChatTaskResponse + 43, // 186: state.v1.StateStoreService.ClaimNext:output_type -> state.v1.ClaimNextResponse + 45, // 187: state.v1.StateStoreService.ClaimByIssue:output_type -> state.v1.ClaimByIssueResponse + 47, // 188: state.v1.StateStoreService.Transition:output_type -> state.v1.TransitionResponse + 49, // 189: state.v1.StateStoreService.Update:output_type -> state.v1.UpdateResponse + 51, // 190: state.v1.StateStoreService.Requeue:output_type -> state.v1.RequeueResponse + 53, // 191: state.v1.StateStoreService.ParkTask:output_type -> state.v1.ParkTaskResponse + 55, // 192: state.v1.StateStoreService.RecoverStale:output_type -> state.v1.RecoverStaleResponse + 57, // 193: state.v1.StateStoreService.ArchiveTask:output_type -> state.v1.ArchiveTaskResponse + 59, // 194: state.v1.StateStoreService.RetryTask:output_type -> state.v1.RetryTaskResponse + 61, // 195: state.v1.StateStoreService.BeginRemediation:output_type -> state.v1.BeginRemediationResponse + 63, // 196: state.v1.StateStoreService.UpdateReviewPayload:output_type -> state.v1.UpdateReviewPayloadResponse + 65, // 197: state.v1.StateStoreService.SetReviewCursors:output_type -> state.v1.SetReviewCursorsResponse + 67, // 198: state.v1.StateStoreService.TaskByIssue:output_type -> state.v1.TaskByIssueResponse + 69, // 199: state.v1.StateStoreService.OpenTaskByPR:output_type -> state.v1.OpenTaskByPRResponse + 71, // 200: state.v1.StateStoreService.TaskByID:output_type -> state.v1.TaskByIDResponse + 73, // 201: state.v1.StateStoreService.OpenPRs:output_type -> state.v1.OpenPRsResponse + 75, // 202: state.v1.StateStoreService.ClearTerminalTasks:output_type -> state.v1.ClearTerminalTasksResponse + 77, // 203: state.v1.StateStoreService.Tasks:output_type -> state.v1.TasksResponse + 79, // 204: state.v1.StateStoreService.StatusCounts:output_type -> state.v1.StatusCountsResponse + 81, // 205: state.v1.StateStoreService.InsertEvent:output_type -> state.v1.InsertEventResponse + 83, // 206: state.v1.StateStoreService.EventsSince:output_type -> state.v1.EventsSinceResponse + 85, // 207: state.v1.StateStoreService.TaskEvents:output_type -> state.v1.TaskEventsResponse + 87, // 208: state.v1.StateStoreService.WorkflowStats:output_type -> state.v1.WorkflowStatsResponse + 89, // 209: state.v1.StateStoreService.StageStats:output_type -> state.v1.StageStatsResponse + 91, // 210: state.v1.StateStoreService.TokensByDay:output_type -> state.v1.TokensByDayResponse + 94, // 211: state.v1.StateStoreService.PutConfigSnapshot:output_type -> state.v1.PutConfigSnapshotResponse + 96, // 212: state.v1.StateStoreService.GetConfigSnapshot:output_type -> state.v1.GetConfigSnapshotResponse + 99, // 213: state.v1.StateStoreService.PutChannelStatus:output_type -> state.v1.PutChannelStatusResponse + 101, // 214: state.v1.StateStoreService.ListChannelStatus:output_type -> state.v1.ListChannelStatusResponse + 104, // 215: state.v1.StateStoreService.PutApplyStatus:output_type -> state.v1.PutApplyStatusResponse + 106, // 216: state.v1.StateStoreService.ListApplyStatus:output_type -> state.v1.ListApplyStatusResponse + 109, // 217: state.v1.StateStoreService.ReadTaskLog:output_type -> state.v1.ReadTaskLogResponse + 111, // 218: state.v1.StateStoreService.StreamTaskLogContent:output_type -> state.v1.StreamTaskLogContentResponse + 113, // 219: state.v1.StateStoreService.InsertCapture:output_type -> state.v1.InsertCaptureResponse + 115, // 220: state.v1.StateStoreService.StreamCaptures:output_type -> state.v1.StreamCapturesResponse + 117, // 221: state.v1.StateStoreService.InsertMapping:output_type -> state.v1.InsertMappingResponse + 119, // 222: state.v1.StateStoreService.GetMapping:output_type -> state.v1.GetMappingResponse + 121, // 223: state.v1.StateStoreService.ListMappings:output_type -> state.v1.ListMappingsResponse + 123, // 224: state.v1.StateStoreService.UpdateMapping:output_type -> state.v1.UpdateMappingResponse + 125, // 225: state.v1.StateStoreService.DeleteMapping:output_type -> state.v1.DeleteMappingResponse + 127, // 226: state.v1.StateStoreService.RecordMappingMatch:output_type -> state.v1.RecordMappingMatchResponse + 129, // 227: state.v1.StateStoreService.InsertEventType:output_type -> state.v1.InsertEventTypeResponse + 131, // 228: state.v1.StateStoreService.UpdateEventType:output_type -> state.v1.UpdateEventTypeResponse + 133, // 229: state.v1.StateStoreService.DeleteEventType:output_type -> state.v1.DeleteEventTypeResponse + 135, // 230: state.v1.StateStoreService.ListEventTypes:output_type -> state.v1.ListEventTypesResponse + 137, // 231: state.v1.StateStoreService.InsertBinding:output_type -> state.v1.InsertBindingResponse + 139, // 232: state.v1.StateStoreService.GetBinding:output_type -> state.v1.GetBindingResponse + 141, // 233: state.v1.StateStoreService.ListBindings:output_type -> state.v1.ListBindingsResponse + 143, // 234: state.v1.StateStoreService.UpdateBinding:output_type -> state.v1.UpdateBindingResponse + 145, // 235: state.v1.StateStoreService.DeleteBinding:output_type -> state.v1.DeleteBindingResponse + 147, // 236: state.v1.StateStoreService.ApproveBinding:output_type -> state.v1.ApproveBindingResponse + 149, // 237: state.v1.StateStoreService.InsertSource:output_type -> state.v1.InsertSourceResponse + 151, // 238: state.v1.StateStoreService.GetSource:output_type -> state.v1.GetSourceResponse + 153, // 239: state.v1.StateStoreService.ListSources:output_type -> state.v1.ListSourcesResponse + 155, // 240: state.v1.StateStoreService.SetSourceSigning:output_type -> state.v1.SetSourceSigningResponse + 157, // 241: state.v1.StateStoreService.SetSourceSecret:output_type -> state.v1.SetSourceSecretResponse + 159, // 242: state.v1.StateStoreService.ArmedBindingsForSource:output_type -> state.v1.ArmedBindingsForSourceResponse + 161, // 243: state.v1.StateStoreService.RecordDispatch:output_type -> state.v1.RecordDispatchResponse + 163, // 244: state.v1.StateStoreService.RecordPlaybookDispatch:output_type -> state.v1.RecordPlaybookDispatchResponse + 165, // 245: state.v1.StateStoreService.DeletePlaybookDispatches:output_type -> state.v1.DeletePlaybookDispatchesResponse + 167, // 246: state.v1.StateStoreService.StreamUndispatchedCaptures:output_type -> state.v1.StreamUndispatchedCapturesResponse + 169, // 247: state.v1.StateStoreService.EnqueueBindingTask:output_type -> state.v1.EnqueueBindingTaskResponse + 171, // 248: state.v1.StateStoreService.EnqueueCallTask:output_type -> state.v1.EnqueueCallTaskResponse + 173, // 249: state.v1.StateStoreService.WorkflowCallStatus:output_type -> state.v1.WorkflowCallStatusResponse + 169, // [169:250] is the sub-list for method output_type + 88, // [88:169] is the sub-list for method input_type + 88, // [88:88] is the sub-list for extension type_name + 88, // [88:88] is the sub-list for extension extendee + 0, // [0:88] is the sub-list for field type_name } func init() { file_state_v1_state_proto_init() } @@ -10756,7 +11025,7 @@ func file_state_v1_state_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_state_v1_state_proto_rawDesc), len(file_state_v1_state_proto_rawDesc)), NumEnums: 0, - NumMessages: 181, + NumMessages: 185, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/contracts/state/v1/state_grpc.pb.go b/internal/contracts/state/v1/state_grpc.pb.go index dace4c13c..967633d44 100644 --- a/internal/contracts/state/v1/state_grpc.pb.go +++ b/internal/contracts/state/v1/state_grpc.pb.go @@ -98,6 +98,8 @@ const ( StateStoreService_DeletePlaybookDispatches_FullMethodName = "/state.v1.StateStoreService/DeletePlaybookDispatches" StateStoreService_StreamUndispatchedCaptures_FullMethodName = "/state.v1.StateStoreService/StreamUndispatchedCaptures" StateStoreService_EnqueueBindingTask_FullMethodName = "/state.v1.StateStoreService/EnqueueBindingTask" + StateStoreService_EnqueueCallTask_FullMethodName = "/state.v1.StateStoreService/EnqueueCallTask" + StateStoreService_WorkflowCallStatus_FullMethodName = "/state.v1.StateStoreService/WorkflowCallStatus" ) // StateStoreServiceClient is the client API for StateStoreService service. @@ -243,6 +245,13 @@ type StateStoreServiceClient interface { StreamUndispatchedCaptures(ctx context.Context, in *StreamUndispatchedCapturesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamUndispatchedCapturesResponse], error) // BindingTaskCreator EnqueueBindingTask(ctx context.Context, in *EnqueueBindingTaskRequest, opts ...grpc.CallOption) (*EnqueueBindingTaskResponse, error) + // WorkflowCaller: a workflow.call step starts its callee and, with + // wait:true, reads it back while waiting. Both are the one sanctioned + // widening of a task-scoped grant -- the callee is the caller's child + // (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child + // relation server-side, so the grant only names the caller. + EnqueueCallTask(ctx context.Context, in *EnqueueCallTaskRequest, opts ...grpc.CallOption) (*EnqueueCallTaskResponse, error) + WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error) } type stateStoreServiceClient struct { @@ -1070,6 +1079,26 @@ func (c *stateStoreServiceClient) EnqueueBindingTask(ctx context.Context, in *En return out, nil } +func (c *stateStoreServiceClient) EnqueueCallTask(ctx context.Context, in *EnqueueCallTaskRequest, opts ...grpc.CallOption) (*EnqueueCallTaskResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(EnqueueCallTaskResponse) + err := c.cc.Invoke(ctx, StateStoreService_EnqueueCallTask_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *stateStoreServiceClient) WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(WorkflowCallStatusResponse) + err := c.cc.Invoke(ctx, StateStoreService_WorkflowCallStatus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // StateStoreServiceServer is the server API for StateStoreService service. // All implementations must embed UnimplementedStateStoreServiceServer // for forward compatibility. @@ -1213,6 +1242,13 @@ type StateStoreServiceServer interface { StreamUndispatchedCaptures(*StreamUndispatchedCapturesRequest, grpc.ServerStreamingServer[StreamUndispatchedCapturesResponse]) error // BindingTaskCreator EnqueueBindingTask(context.Context, *EnqueueBindingTaskRequest) (*EnqueueBindingTaskResponse, error) + // WorkflowCaller: a workflow.call step starts its callee and, with + // wait:true, reads it back while waiting. Both are the one sanctioned + // widening of a task-scoped grant -- the callee is the caller's child + // (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child + // relation server-side, so the grant only names the caller. + EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error) + WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error) mustEmbedUnimplementedStateStoreServiceServer() } @@ -1460,6 +1496,12 @@ func (UnimplementedStateStoreServiceServer) StreamUndispatchedCaptures(*StreamUn func (UnimplementedStateStoreServiceServer) EnqueueBindingTask(context.Context, *EnqueueBindingTaskRequest) (*EnqueueBindingTaskResponse, error) { return nil, status.Error(codes.Unimplemented, "method EnqueueBindingTask not implemented") } +func (UnimplementedStateStoreServiceServer) EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error) { + return nil, status.Error(codes.Unimplemented, "method EnqueueCallTask not implemented") +} +func (UnimplementedStateStoreServiceServer) WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error) { + return nil, status.Error(codes.Unimplemented, "method WorkflowCallStatus not implemented") +} func (UnimplementedStateStoreServiceServer) mustEmbedUnimplementedStateStoreServiceServer() {} func (UnimplementedStateStoreServiceServer) testEmbeddedByValue() {} @@ -2882,6 +2924,42 @@ func _StateStoreService_EnqueueBindingTask_Handler(srv interface{}, ctx context. return interceptor(ctx, in, info, handler) } +func _StateStoreService_EnqueueCallTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EnqueueCallTaskRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StateStoreServiceServer).EnqueueCallTask(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: StateStoreService_EnqueueCallTask_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StateStoreServiceServer).EnqueueCallTask(ctx, req.(*EnqueueCallTaskRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _StateStoreService_WorkflowCallStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WorkflowCallStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StateStoreServiceServer).WorkflowCallStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: StateStoreService_WorkflowCallStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StateStoreServiceServer).WorkflowCallStatus(ctx, req.(*WorkflowCallStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + // StateStoreService_ServiceDesc is the grpc.ServiceDesc for StateStoreService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -3193,6 +3271,14 @@ var StateStoreService_ServiceDesc = grpc.ServiceDesc{ MethodName: "EnqueueBindingTask", Handler: _StateStoreService_EnqueueBindingTask_Handler, }, + { + MethodName: "EnqueueCallTask", + Handler: _StateStoreService_EnqueueCallTask_Handler, + }, + { + MethodName: "WorkflowCallStatus", + Handler: _StateStoreService_WorkflowCallStatus_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/internal/domain/storecontract/storecontract.go b/internal/domain/storecontract/storecontract.go index f4a16a4ba..c577891d7 100644 --- a/internal/domain/storecontract/storecontract.go +++ b/internal/domain/storecontract/storecontract.go @@ -254,6 +254,15 @@ type BindingTaskCreator interface { EnqueueBindingTask(ctx context.Context, owner, repo, title, body, wf, identity, bindingID string, bindingVersion int, inputs map[string]any) (*task.Task, error) } +// WorkflowCaller is the consumer surface a workflow.call step crosses to +// start its callee and read it back while waiting (docs/prds/workflow-calls.md). +// It is the workflow engine's own task.Caller contract, satisfied by the +// PostgreSQL store and *staterpc.Client alike -- the same shape as +// workflow.Store. The caller task ID is explicit so both the wire grant and +// the store's own row check answer the same question: is this call this +// task's call? +type WorkflowCaller = task.Caller + // PlaybookDispatcher is the idempotency-ledger surface for side-effecting // playbook actions (docs/prds/eda-playbook-engine.md gap 2). // RecordPlaybookDispatch writes the (playbook, version, event, action) row @@ -421,6 +430,18 @@ var ( // the sentinel is shared so a caller treats "already recorded" the same // way across the two surfaces. ErrAlreadyDispatched = errors.New("store: binding already dispatched for capture") + // ErrCallNotYours is returned when a workflow.call status read names a + // task that is not a callee of the calling task, or the caller itself + // does not exist: a caller reads only the tasks it started + // (docs/prds/workflow-calls.md). + ErrCallNotYours = errors.New("store: task is not a callee of the calling task") + // ErrCallCallerNotRunning is returned when a workflow.call enqueue names + // a caller that is not running: a stale retry, or a bug in the caller. + ErrCallCallerNotRunning = errors.New("store: workflow.call caller is not running") + // ErrCallDepthExceeded is returned when a workflow.call enqueue would + // pass workflow.MaxCallDepth. The engine refuses the same call first; + // the store re-checks because it owns the table. + ErrCallDepthExceeded = errors.New("store: workflow.call would pass the depth limit") // ErrMappingNotFound is returned when a mapping ID does not exist. ErrMappingNotFound = errors.New("store: mapping not found") // ErrEventTypeNotFound is returned when an event type ID does not exist. diff --git a/internal/infrastructure/agenttransport/nats/transport.go b/internal/infrastructure/agenttransport/nats/transport.go index 233e25a6f..6d53ad787 100644 --- a/internal/infrastructure/agenttransport/nats/transport.go +++ b/internal/infrastructure/agenttransport/nats/transport.go @@ -15,6 +15,7 @@ import ( "github.com/samcharles93/archie-core/internal/agentexec" "github.com/samcharles93/archie-core/internal/domain/workflow" + "github.com/samcharles93/archie-core/internal/domain/workflow/task" "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/forgerpc" "github.com/samcharles93/archie-core/internal/infrastructure/staterpc" @@ -154,6 +155,39 @@ func (t *Transport) Store(timeout time.Duration) workflow.Store { return deadlineStore{Store: t.state, timeout: timeout} } +// Calls constructs the workflow.call RPC client over the same long-lived +// State Store client (docs/prds/workflow-calls.md), bounded by timeout the +// same way Store() is. +func (t *Transport) Calls(timeout time.Duration) task.Caller { + return deadlineCaller{Caller: t.state, timeout: timeout} +} + +// deadlineCaller applies a default per-call timeout to task.Caller calls +// whose context carries no deadline of its own, matching deadlineStore. +type deadlineCaller struct { + task.Caller + timeout time.Duration +} + +func (d deadlineCaller) withDeadline(ctx context.Context) (context.Context, context.CancelFunc) { + if _, ok := ctx.Deadline(); ok || d.timeout <= 0 { + return ctx, func() {} + } + return context.WithTimeout(ctx, d.timeout) +} + +func (d deadlineCaller) StartCall(ctx context.Context, callerTaskID int64, wf string, inputs map[string]any) (*task.Task, error) { + ctx, cancel := d.withDeadline(ctx) + defer cancel() + return d.Caller.StartCall(ctx, callerTaskID, wf, inputs) +} + +func (d deadlineCaller) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, error) { + ctx, cancel := d.withDeadline(ctx) + defer cancel() + return d.Caller.CallStatus(ctx, callerTaskID, callTaskID) +} + // deadlineStore applies a default per-call timeout to workflow.Store calls // whose context carries no deadline of its own, matching storerpc.Client's // Timeout field semantics for the gRPC path. diff --git a/internal/infrastructure/postgres/migrations/0015_workflow_calls.sql b/internal/infrastructure/postgres/migrations/0015_workflow_calls.sql new file mode 100644 index 000000000..7900c2ba6 --- /dev/null +++ b/internal/infrastructure/postgres/migrations/0015_workflow_calls.sql @@ -0,0 +1,20 @@ +-- Workflow calls: the callee linkage on the task row +-- (docs/prds/workflow-calls.md). +-- +-- tasks.call_parent_task_id names the task whose workflow.call step started +-- this one (0 on a root run) and call_depth counts workflow.call hops from +-- the root. Both default so every existing row and writer reads as a depth-0 +-- root run; the depth limit itself is re-checked by the engine and the +-- enqueue, so no path can write past it. + +-- +goose Up + +ALTER TABLE tasks ADD COLUMN call_parent_task_id bigint NOT NULL DEFAULT 0; +ALTER TABLE tasks ADD COLUMN call_depth int NOT NULL DEFAULT 0; +CREATE INDEX idx_tasks_call_parent ON tasks (call_parent_task_id); + +-- +goose Down + +DROP INDEX idx_tasks_call_parent; +ALTER TABLE tasks DROP COLUMN call_depth; +ALTER TABLE tasks DROP COLUMN call_parent_task_id; \ No newline at end of file diff --git a/internal/infrastructure/postgres/postgresdb/call_tasks.sql.go b/internal/infrastructure/postgres/postgresdb/call_tasks.sql.go new file mode 100644 index 000000000..5800758a0 --- /dev/null +++ b/internal/infrastructure/postgres/postgresdb/call_tasks.sql.go @@ -0,0 +1,118 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.31.1 +// source: call_tasks.sql + +package postgresdb + +import ( + "context" +) + +const callStatusDetail = `-- name: CallStatusDetail :one +SELECT detail FROM transitions WHERE task_id = $1 ORDER BY id DESC LIMIT 1 +` + +// The latest transition detail of one call's callee, the summary a wait:true +// caller receives (docs/prds/workflow-calls.md). +func (q *Queries) CallStatusDetail(ctx context.Context, taskID int64) (string, error) { + row := q.db.QueryRow(ctx, callStatusDetail, taskID) + var detail string + err := row.Scan(&detail) + return detail, err +} + +const enqueueCallTask = `-- name: EnqueueCallTask :one +WITH caller AS ( + SELECT t.id, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, t.status, t.workflow, t.stage, t.branch, t.plan, t.notes, t.pr_number, t.tokens_used, t.iterations, t.attempt, t.park_reason, t.watch_comment_id, t.park_class, t.remediation_rounds, t.retry_count, t.source, t.identity, t.binding_id, t.binding_version, t.review_payload, t.workflow_definition_version, t.workflow_definition_digest, t.workflow_definition_yaml, t.created_at, t.updated_at, t.review_cursor, t.inputs, t.org_id, t.workspace_id, t.call_parent_task_id, t.call_depth FROM tasks t WHERE t.id = $1 FOR UPDATE +) +INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, workspace_id, inputs, call_parent_task_id, call_depth) +SELECT + caller.owner, + caller.repo, + COALESCE(( + SELECT MAX(existing.issue_number) FROM tasks existing + WHERE existing.owner = caller.owner + AND existing.repo = caller.repo + AND existing.source = 'chat' + ), $2::bigint) + 1, + $3, $4, 'chat', $5, 'chat', caller.identity, + caller.org_id, caller.workspace_id, $6, + caller.id, caller.call_depth + 1 +FROM caller +WHERE caller.status = 'running' AND caller.call_depth + 1 <= $7::int +RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth +` + +type EnqueueCallTaskParams struct { + ID int64 + FallbackIssueNumber int64 + Title string + Body string + Workflow string + Inputs string + MaxDepth int32 +} + +// The callee of a workflow.call step (docs/prds/workflow-calls.md). The +// caller row is read FOR UPDATE, so two steps of the same run cannot race a +// depth re-check, and the callee inherits the caller's org, workspace, +// identity, owner and repo: a called workflow works the same run's context +// under its own definition and profile. The issue number is a fresh +// synthetic one for the inherited owner/repo, the same allocator +// InsertChatTask uses. The insert refuses a caller that is not running and +// a call that would pass the depth limit (the engine checks it too; the +// store is what owns the table, so it re-checks). +func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams) (Task, error) { + row := q.db.QueryRow(ctx, enqueueCallTask, + arg.ID, + arg.FallbackIssueNumber, + arg.Title, + arg.Body, + arg.Workflow, + arg.Inputs, + arg.MaxDepth, + ) + var i Task + err := row.Scan( + &i.ID, + &i.Owner, + &i.Repo, + &i.IssueNumber, + &i.Title, + &i.Body, + &i.Labels, + &i.Status, + &i.Workflow, + &i.Stage, + &i.Branch, + &i.Plan, + &i.Notes, + &i.PrNumber, + &i.TokensUsed, + &i.Iterations, + &i.Attempt, + &i.ParkReason, + &i.WatchCommentID, + &i.ParkClass, + &i.RemediationRounds, + &i.RetryCount, + &i.Source, + &i.Identity, + &i.BindingID, + &i.BindingVersion, + &i.ReviewPayload, + &i.WorkflowDefinitionVersion, + &i.WorkflowDefinitionDigest, + &i.WorkflowDefinitionYaml, + &i.CreatedAt, + &i.UpdatedAt, + &i.ReviewCursor, + &i.Inputs, + &i.OrgID, + &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, + ) + return i, err +} diff --git a/internal/infrastructure/postgres/postgresdb/models.go b/internal/infrastructure/postgres/postgresdb/models.go index 4b37ddb08..06e7999ec 100644 --- a/internal/infrastructure/postgres/postgresdb/models.go +++ b/internal/infrastructure/postgres/postgresdb/models.go @@ -323,6 +323,8 @@ type Task struct { Inputs string OrgID string WorkspaceID string + CallParentTaskID int64 + CallDepth int32 } type ToolCall struct { diff --git a/internal/infrastructure/postgres/postgresdb/tasks.sql.go b/internal/infrastructure/postgres/postgresdb/tasks.sql.go index 2be9fa4fe..3954a3b0d 100644 --- a/internal/infrastructure/postgres/postgresdb/tasks.sql.go +++ b/internal/infrastructure/postgres/postgresdb/tasks.sql.go @@ -48,7 +48,7 @@ func (q *Queries) BeginRemediationTask(ctx context.Context, arg BeginRemediation const claimByIssue = `-- name: ClaimByIssue :one UPDATE tasks SET status = 'running', attempt = attempt + 1, updated_at = now() WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND status = 'queued' -RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id +RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth ` type ClaimByIssueParams struct { @@ -97,6 +97,8 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas &i.Inputs, &i.OrgID, &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, ) return i, err } @@ -111,7 +113,7 @@ WHERE id = ( FOR UPDATE SKIP LOCKED LIMIT 1 ) -RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id +RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth ` // FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two @@ -157,6 +159,8 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) { &i.Inputs, &i.OrgID, &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, ) return i, err } @@ -266,7 +270,7 @@ VALUES ( 'default' ) ) -RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id +RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth ` type InsertChatTaskParams struct { @@ -331,6 +335,8 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams) &i.Inputs, &i.OrgID, &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, ) return i, err } @@ -619,7 +625,7 @@ func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingPara } const taskByID = `-- name: TaskByID :one -SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id FROM tasks WHERE id = $1 +SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth FROM tasks WHERE id = $1 ` func (q *Queries) TaskByID(ctx context.Context, id int64) (Task, error) { @@ -662,12 +668,14 @@ func (q *Queries) TaskByID(ctx context.Context, id int64) (Task, error) { &i.Inputs, &i.OrgID, &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, ) return i, err } const taskByIssue = `-- name: TaskByIssue :one -SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3 +SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3 ` type TaskByIssueParams struct { @@ -716,12 +724,14 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task, &i.Inputs, &i.OrgID, &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, ) return i, err } const taskByPR = `-- name: TaskByPR :one -SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4 +SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, branch, plan, notes, pr_number, tokens_used, iterations, attempt, park_reason, watch_comment_id, park_class, remediation_rounds, retry_count, source, identity, binding_id, binding_version, review_payload, workflow_definition_version, workflow_definition_digest, workflow_definition_yaml, created_at, updated_at, review_cursor, inputs, org_id, workspace_id, call_parent_task_id, call_depth FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4 ` type TaskByPRParams struct { @@ -779,6 +789,8 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error &i.Inputs, &i.OrgID, &i.WorkspaceID, + &i.CallParentTaskID, + &i.CallDepth, ) return i, err } diff --git a/internal/infrastructure/postgres/queries/call_tasks.sql b/internal/infrastructure/postgres/queries/call_tasks.sql new file mode 100644 index 000000000..dd8e42069 --- /dev/null +++ b/internal/infrastructure/postgres/queries/call_tasks.sql @@ -0,0 +1,34 @@ +-- name: EnqueueCallTask :one +-- The callee of a workflow.call step (docs/prds/workflow-calls.md). The +-- caller row is read FOR UPDATE, so two steps of the same run cannot race a +-- depth re-check, and the callee inherits the caller's org, workspace, +-- identity, owner and repo: a called workflow works the same run's context +-- under its own definition and profile. The issue number is a fresh +-- synthetic one for the inherited owner/repo, the same allocator +-- InsertChatTask uses. The insert refuses a caller that is not running and +-- a call that would pass the depth limit (the engine checks it too; the +-- store is what owns the table, so it re-checks). +WITH caller AS ( + SELECT t.* FROM tasks t WHERE t.id = $1 FOR UPDATE +) +INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, workspace_id, inputs, call_parent_task_id, call_depth) +SELECT + caller.owner, + caller.repo, + COALESCE(( + SELECT MAX(existing.issue_number) FROM tasks existing + WHERE existing.owner = caller.owner + AND existing.repo = caller.repo + AND existing.source = 'chat' + ), sqlc.arg('fallback_issue_number')::bigint) + 1, + sqlc.arg(title), sqlc.arg(body), 'chat', sqlc.arg(workflow), 'chat', caller.identity, + caller.org_id, caller.workspace_id, sqlc.arg(inputs), + caller.id, caller.call_depth + 1 +FROM caller +WHERE caller.status = 'running' AND caller.call_depth + 1 <= sqlc.arg('max_depth')::int +RETURNING *; + +-- name: CallStatusDetail :one +-- The latest transition detail of one call's callee, the summary a wait:true +-- caller receives (docs/prds/workflow-calls.md). +SELECT detail FROM transitions WHERE task_id = $1 ORDER BY id DESC LIMIT 1; \ No newline at end of file diff --git a/internal/infrastructure/postgres/store.go b/internal/infrastructure/postgres/store.go index 86872728b..1b5fbeaf3 100644 --- a/internal/infrastructure/postgres/store.go +++ b/internal/infrastructure/postgres/store.go @@ -12,7 +12,7 @@ import ( "github.com/samcharles93/archie-core/internal/domain/org" "github.com/samcharles93/archie-core/internal/domain/storecontract" "github.com/samcharles93/archie-core/internal/domain/workflow" - workflowtask "github.com/samcharles93/archie-core/internal/domain/workflow/task" + task "github.com/samcharles93/archie-core/internal/domain/workflow/task" "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/infrastructure/postgres/postgresdb" "github.com/samcharles93/archie-core/internal/taskstate" @@ -79,7 +79,7 @@ const syntheticIssueNumberBase = 1_000_000_000_000_000 func taskFromRow(t postgresdb.Task) *workflow.Task { // The inputs column is only ever written by EncodeInputs, so a decode // failure cannot arise from stored data this package produced. - inputs, _ := workflowtask.DecodeInputs(t.Inputs) + inputs, _ := task.DecodeInputs(t.Inputs) return &workflow.Task{ ID: t.ID, Owner: t.Owner, @@ -114,6 +114,8 @@ func taskFromRow(t postgresdb.Task) *workflow.Task { ReviewPayload: t.ReviewPayload, ParkClass: t.ParkClass, RemediationRounds: int(t.RemediationRounds), + CallParentTaskID: t.CallParentTaskID, + CallDepth: int(t.CallDepth), CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt, } @@ -126,6 +128,7 @@ var ( _ storecontract.ConfigSnapshotStore = (*Store)(nil) _ storecontract.ChannelStatusStore = (*Store)(nil) _ storecontract.ApplyStatusStore = (*Store)(nil) + _ task.Caller = (*Store)(nil) _ workflow.Store = (*Store)(nil) ) @@ -159,7 +162,7 @@ func (s *Store) EnqueueChatTask(ctx context.Context, owner, repo, title, body, w // EnqueueBindingTask enqueues a binding-triggered task and stamps its binding // provenance in a second statement (best-effort, as in the SQLite store). func (s *Store) EnqueueBindingTask(ctx context.Context, owner, repo, title, body, wf, identity, bindingID string, bindingVersion int, inputs map[string]any) (*workflow.Task, error) { - encoded, err := workflowtask.EncodeInputs(inputs) + encoded, err := task.EncodeInputs(inputs) if err != nil { return nil, err } @@ -539,3 +542,80 @@ func (s *Store) TaskByID(ctx context.Context, taskID int64) (*workflow.Task, err } return taskFromRow(t), nil } + +// StartCall enqueues the callee of callerTaskID's workflow.call step +// (docs/prds/workflow-calls.md). The store owns the table, so it re-checks +// both runtime invariants the engine checks: the caller must be running and +// the call must not pass workflow.MaxCallDepth. The callee inherits the +// caller's org, workspace, identity, owner and repo, and takes a fresh +// synthetic issue number, the same allocator chat tasks use. +func (s *Store) StartCall(ctx context.Context, callerTaskID int64, wf string, inputs map[string]any) (*workflow.Task, error) { + encoded, err := task.EncodeInputs(inputs) + if err != nil { + return nil, err + } + callee, err := s.queries().EnqueueCallTask(ctx, postgresdb.EnqueueCallTaskParams{ + ID: callerTaskID, + FallbackIssueNumber: syntheticIssueNumberBase - 1, + Title: fmt.Sprintf("workflow.call %s from task %d", wf, callerTaskID), + Body: fmt.Sprintf("Started by a workflow.call step from task %d (workflow %q); the call's inputs travel with the task.", callerTaskID, wf), + Workflow: wf, + Inputs: encoded, + MaxDepth: int32(workflow.MaxCallDepth), + }) + if errors.Is(err, pgx.ErrNoRows) { + // The WITH reads the caller FOR UPDATE before inserting, so "no + // rows" means the caller is missing, not running, or past the depth + // limit. Name which, off a plain read. + return nil, s.callRefusal(ctx, callerTaskID) + } + if err != nil { + return nil, err + } + return taskFromRow(callee), nil +} + +// callRefusal names why EnqueueCallTask inserted nothing. The three refusals +// are distinct failures an operator reads differently: a missing caller is a +// problem, a caller that is not running is a stale retry, and a depth +// refusal is the limit doing its job. The two behavioural ones carry the +// caller's detail in the log and the sentinel across the wire. +func (s *Store) callRefusal(ctx context.Context, callerTaskID int64) error { + caller, err := s.queries().TaskByID(ctx, callerTaskID) + if errors.Is(err, pgx.ErrNoRows) { + return fmt.Errorf("store: workflow.call caller task %d does not exist: %w", callerTaskID, storecontract.ErrCallNotYours) + } + if err != nil { + return err + } + if caller.Status != "running" { + return fmt.Errorf("store: workflow.call caller task %d is %s: %w", callerTaskID, caller.Status, storecontract.ErrCallCallerNotRunning) + } + return fmt.Errorf("store: workflow.call from task %d at depth %d: %w", callerTaskID, caller.CallDepth, storecontract.ErrCallDepthExceeded) +} + +// CallStatus reads one call's callee for a waiting caller: its status and +// latest transition detail. The parent check is the row check the wire grant +// cannot do: a caller reads only the tasks it started. +func (s *Store) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, error) { + callee, err := s.queries().TaskByID(ctx, callTaskID) + if errors.Is(err, pgx.ErrNoRows) { + return "", "", storecontract.ErrCallNotYours + } + if err != nil { + return "", "", err + } + if callee.CallParentTaskID != callerTaskID { + return "", "", storecontract.ErrCallNotYours + } + // A callee that has not moved yet has no transition row; its queue + // status is the whole answer, and the empty detail says so. + detail, err := s.queries().CallStatusDetail(ctx, callTaskID) + if errors.Is(err, pgx.ErrNoRows) { + return callee.Status, "", nil + } + if err != nil { + return "", "", err + } + return callee.Status, detail, nil +} diff --git a/internal/infrastructure/staterpc/client.go b/internal/infrastructure/staterpc/client.go index 61de72ba8..2c7efc6e0 100644 --- a/internal/infrastructure/staterpc/client.go +++ b/internal/infrastructure/staterpc/client.go @@ -44,6 +44,7 @@ func (c *Client) Close() error { return nil } var ( _ task.Store = (*Client)(nil) + _ task.Caller = (*Client)(nil) _ storecontract.TaskStore = (*Client)(nil) _ storecontract.TaskLogStore = (*Client)(nil) _ storecontract.CaptureStore = (*Client)(nil) @@ -566,6 +567,32 @@ func (c *Client) EnqueueBindingTask(ctx context.Context, owner, repo, title, bod return taskValue(r.Task), nil } +// WorkflowCaller: the workflow.call step's two RPCs (docs/prds/ +// workflow-calls.md). StartCall encodes the call's inputs in the same form +// every other wire crossing uses; CallStatus rehydrates the sentinels the +// server maps, so a caller's errors.Is(err, storecontract.ErrCallNotYours) +// works across the wire. + +func (c *Client) StartCall(ctx context.Context, callerTaskID int64, wf string, inputs map[string]any) (*task.Task, error) { + encoded, err := task.EncodeInputs(inputs) + if err != nil { + return nil, err + } + r, err := c.client.EnqueueCallTask(ctx, &pb.EnqueueCallTaskRequest{CallerTaskId: callerTaskID, Workflow: wf, InputsJson: encoded}) + if err != nil { + return nil, unmapError(err) + } + return taskValue(r.Task), nil +} + +func (c *Client) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, error) { + r, err := c.client.WorkflowCallStatus(ctx, &pb.WorkflowCallStatusRequest{CallerTaskId: callerTaskID, CallTaskId: callTaskID}) + if err != nil { + return "", "", unmapError(err) + } + return r.Status, r.Detail, nil +} + // Task log // TaskLog reads one task attempt's decoded log over the wire. found=false with diff --git a/internal/infrastructure/staterpc/conformance_test.go b/internal/infrastructure/staterpc/conformance_test.go index 987737bff..938c9cbd4 100644 --- a/internal/infrastructure/staterpc/conformance_test.go +++ b/internal/infrastructure/staterpc/conformance_test.go @@ -81,7 +81,7 @@ func remoteTaskStore(t *testing.T, local *pgstore.TaskDB, logs storecontract.Tas listener := bufconn.Listen(1 << 20) server := grpc.NewServer() deps := Deps{ - Tasks: local, BindingTaskCreator: local, + Tasks: local, BindingTaskCreator: local, WorkflowCalls: local, ConfigSnapshots: local, ApplyStatus: local, TaskLogs: logs, } diff --git a/internal/infrastructure/staterpc/server.go b/internal/infrastructure/staterpc/server.go index 7e6e53418..cb3a76bb6 100644 --- a/internal/infrastructure/staterpc/server.go +++ b/internal/infrastructure/staterpc/server.go @@ -42,6 +42,7 @@ var ( errBindingDispatchUnavailable = status.Error(codes.Unavailable, "binding dispatcher unavailable") errBindingTaskCreatorUnavailable = status.Error(codes.Unavailable, "binding task creator unavailable") errPlaybookDispatcherUnavailable = status.Error(codes.Unavailable, "playbook dispatcher unavailable") + errWorkflowCallerUnavailable = status.Error(codes.Unavailable, "workflow caller unavailable") // errTaskLogsUnavailable is the "this process cannot read task logs at // all" answer, and it is deliberately distinct from a found=false read // result: only the first is a deployment matter. A dashboard that receives @@ -89,6 +90,11 @@ type Deps struct { Sources storecontract.SourceStore BindingDispatcher storecontract.BindingDispatcher BindingTaskCreator storecontract.BindingTaskCreator + // WorkflowCalls is the workflow.call surface (docs/prds/workflow-calls.md): + // the workflow engine's task.Caller over this contract. Optional: nil + // answers both RPCs with codes.Unavailable, which is the honest answer + // for a store that owns no task table. + WorkflowCalls storecontract.WorkflowCaller // PlaybookDispatcher is the side-effecting-action idempotency ledger // (docs/prds/eda-playbook-engine.md gap 2). Optional: nil disables the // two playbook dispatch RPCs with codes.Unavailable. @@ -801,6 +807,40 @@ func (s *server) EnqueueBindingTask(ctx context.Context, r *pb.EnqueueBindingTas return &pb.EnqueueBindingTaskResponse{Task: taskProto(t)}, nil } +// WorkflowCaller: a workflow.call step starts its callee and reads it back +// while waiting (docs/prds/workflow-calls.md). The grant already named the +// caller; the store's own row checks are what make both calls answer only +// for this caller's own callees. + +func (s *server) EnqueueCallTask(ctx context.Context, r *pb.EnqueueCallTaskRequest) (*pb.EnqueueCallTaskResponse, error) { + if s.deps.WorkflowCalls == nil { + return nil, errWorkflowCallerUnavailable + } + if r.CallerTaskId <= 0 { + return nil, status.Error(codes.InvalidArgument, "caller task id is required") + } + inputs, err := task.DecodeInputs(r.InputsJson) + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + t, err := s.deps.WorkflowCalls.StartCall(ctx, r.CallerTaskId, r.Workflow, inputs) + if err != nil { + return nil, s.logErr("EnqueueCallTask", err) + } + return &pb.EnqueueCallTaskResponse{Task: taskProto(t), Accepted: true}, nil +} + +func (s *server) WorkflowCallStatus(ctx context.Context, r *pb.WorkflowCallStatusRequest) (*pb.WorkflowCallStatusResponse, error) { + if s.deps.WorkflowCalls == nil { + return nil, errWorkflowCallerUnavailable + } + status, detail, err := s.deps.WorkflowCalls.CallStatus(ctx, r.CallerTaskId, r.CallTaskId) + if err != nil { + return nil, s.logErr("WorkflowCallStatus", err) + } + return &pb.WorkflowCallStatusResponse{Status: status, Detail: detail}, nil +} + // Task log func (s *server) taskLogs() (storecontract.TaskLogStore, error) { diff --git a/internal/infrastructure/staterpc/task_grants.go b/internal/infrastructure/staterpc/task_grants.go index 4e7147165..ccbb4ebc4 100644 --- a/internal/infrastructure/staterpc/task_grants.go +++ b/internal/infrastructure/staterpc/task_grants.go @@ -90,10 +90,17 @@ func (g *TaskGrants) taskFor(token string) int64 { return 0 } -// authorizesTaskScopedCall reports whether req -- a call to one of the three -// task.Store RPCs a task grant may ever authorize -- targets taskID. -// Every other RPC (including RegisterTaskGrant/RevokeTaskGrant themselves) -// falls through to false: a task grant can only ever narrow, never expand. +// authorizesTaskScopedCall reports whether req -- a call to one of the RPCs +// a task grant may ever authorize -- targets taskID. Every other RPC +// (including RegisterTaskGrant/RevokeTaskGrant themselves) falls through to +// false: a task grant can only ever narrow, never expand. +// +// The two workflow.call RPCs are the one sanctioned widening +// (docs/prds/workflow-calls.md): a workflow.call step must start its callee +// and read it back, and the callee is the caller's child. Both requests +// carry the caller's own task ID, which the grant check verifies; the +// parent-child relation is a handler-side row check, so this interceptor +// never reads the database. func authorizesTaskScopedCall(fullMethod string, req any, taskID int64) bool { switch fullMethod { case pb.StateStoreService_Update_FullMethodName: @@ -105,6 +112,12 @@ func authorizesTaskScopedCall(fullMethod string, req any, taskID int64) bool { case pb.StateStoreService_InsertEvent_FullMethodName: r, ok := req.(*pb.InsertEventRequest) return ok && r.Event != nil && r.Event.TaskId == taskID + case pb.StateStoreService_EnqueueCallTask_FullMethodName: + r, ok := req.(*pb.EnqueueCallTaskRequest) + return ok && r.CallerTaskId == taskID + case pb.StateStoreService_WorkflowCallStatus_FullMethodName: + r, ok := req.(*pb.WorkflowCallStatusRequest) + return ok && r.CallerTaskId == taskID default: return false } diff --git a/internal/infrastructure/staterpc/task_grants_call_test.go b/internal/infrastructure/staterpc/task_grants_call_test.go new file mode 100644 index 000000000..615e2ffb7 --- /dev/null +++ b/internal/infrastructure/staterpc/task_grants_call_test.go @@ -0,0 +1,87 @@ +package staterpc + +import ( + "errors" + "testing" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + pb "github.com/samcharles93/archie-core/internal/contracts/state/v1" + "github.com/samcharles93/archie-core/internal/domain/storecontract" + "github.com/samcharles93/archie-core/internal/domain/workflow" +) + +// TestTaskGrantAuthorizesTheWorkflowCallRPCs: a workflow.call step starts its +// callee and reads it back while waiting, so the caller's task grant must +// reach the two call RPCs for its own task -- and nothing else's +// (docs/prds/workflow-calls.md). CallStatus's parent check stays server-side, +// so the grant itself only ever verifies the request names the granted task. +func TestTaskGrantAuthorizesTheWorkflowCallRPCs(t *testing.T) { + const adminToken = "daemon-admin-token" + _, dial := grantsServer(t, adminToken) + admin := dial(t, adminToken) + ctx := t.Context() + + caller, err := admin.EnqueueChatTask(ctx, "acme", "widget", "caller", "body", "implement", "") + if err != nil { + t.Fatal(err) + } + other, err := admin.EnqueueChatTask(ctx, "acme", "widget", "other", "body", "implement", "") + if err != nil { + t.Fatal(err) + } + if err := admin.Transition(ctx, caller.ID, caller.Status, workflow.StatusRunning, "started"); err != nil { + t.Fatal(err) + } + + workerToken, err := admin.RegisterTaskGrant(ctx, caller.ID, callGrantLifetime) + if err != nil { + t.Fatalf("RegisterTaskGrant: %v", err) + } + worker := dial(t, workerToken) + + callee, err := worker.StartCall(ctx, caller.ID, "callee", map[string]any{"src_ip": "10.0.0.9"}) + if err != nil { + t.Fatalf("task grant should authorize StartCall on its own task: %v", err) + } + if callee.CallParentTaskID != caller.ID || callee.CallDepth != 1 { + t.Fatalf("callee = %+v, want the parent link and depth 1", callee) + } + if _, _, err := worker.CallStatus(ctx, caller.ID, callee.ID); err != nil { + t.Fatalf("task grant should authorize CallStatus on its own callees: %v", err) + } + if _, _, err := worker.CallStatus(ctx, caller.ID, other.ID); !errors.Is(err, storecontract.ErrCallNotYours) { + t.Fatalf("CallStatus for a task that is not this caller's callee = %v, want ErrCallNotYours", err) + } + + // The grant names one caller: another task's grant cannot start calls + // under it, and the granted caller cannot be named by someone else's + // token -- the request-shape check refuses both before the store runs. + if _, err := worker.StartCall(ctx, other.ID, "callee", nil); status.Code(err) != codes.PermissionDenied { + t.Fatalf("StartCall for another task = %v, want PermissionDenied", err) + } + if _, _, err := worker.CallStatus(ctx, other.ID, callee.ID); status.Code(err) != codes.PermissionDenied { + t.Fatalf("CallStatus for another task = %v, want PermissionDenied", err) + } + + // The sentinels survive the wire: a stale retry surfaces the documented + // refusal, not an opaque internal. The admin dial carries it because the + // worker's grant names a caller that is still running; the refusal is + // what a later grant for a finished caller's task would see. + if _, err := admin.StartCall(ctx, callee.ID, "deeper", nil); !errors.Is(err, storecontract.ErrCallCallerNotRunning) { + t.Fatalf("StartCall from a completed caller = %v, want ErrCallCallerNotRunning", err) + } +} + +// callGrantLifetime mirrors the daemon's defaultGrantLifetime; the value is +// not under test, only the scoping. +const callGrantLifetime = defaultGrantLifetime + +// The wire requests this grant widens are the two call RPCs only; this +// compile-time check pins the full-method names the interceptor cases match +// on, so a rename on the proto side is caught here rather than at runtime. +var ( + _ = pb.StateStoreService_EnqueueCallTask_FullMethodName + _ = pb.StateStoreService_WorkflowCallStatus_FullMethodName +) diff --git a/internal/infrastructure/staterpc/task_grants_test.go b/internal/infrastructure/staterpc/task_grants_test.go index 3094fa592..3f37b5933 100644 --- a/internal/infrastructure/staterpc/task_grants_test.go +++ b/internal/infrastructure/staterpc/task_grants_test.go @@ -41,6 +41,7 @@ func grantsServer(t *testing.T, adminToken string) (grants *TaskGrants, dial fun Tasks: local, ConfigSnapshots: local, ApplyStatus: local, Captures: eda, Mappings: eda, Bindings: eda, BindingDispatcher: eda, PlaybookDispatcher: eda, EventTypes: eda, + BindingTaskCreator: local, WorkflowCalls: local, Grants: grants, }) go func() { _ = server.Serve(listener) }() @@ -163,7 +164,7 @@ func TestUpdateRejectsNilTask(t *testing.T) { // Transition/InsertEvent on its own task ID, never the admin-only surface // (StatusCounts here stands in for any of the other ~37 RPCs) and never // another task's ID. -func TestTaskGrantScopesWorkerToItsOwnThreeRPCs(t *testing.T) { +func TestTaskGrantScopesWorkerToItsOwnRPCs(t *testing.T) { const adminToken = "daemon-admin-token" grants, dial := grantsServer(t, adminToken) admin := dial(t, adminToken) diff --git a/internal/infrastructure/staterpc/values.go b/internal/infrastructure/staterpc/values.go index bb37bf167..dcffa1128 100644 --- a/internal/infrastructure/staterpc/values.go +++ b/internal/infrastructure/staterpc/values.go @@ -80,6 +80,8 @@ func taskProto(t *task.Task) *pb.Task { //nolint:dupl // mirror-image field-by-f WorkflowDefinitionDigest: t.WorkflowDefinitionDigest, WorkflowDefinitionYaml: t.WorkflowDefinitionYAML, Org: string(t.Org), + CallParentTaskId: t.CallParentTaskID, + CallDepth: int32(t.CallDepth), } } @@ -105,6 +107,8 @@ func taskValue(t *pb.Task) *task.Task { //nolint:dupl // see taskProto above WorkflowDefinitionDigest: t.WorkflowDefinitionDigest, WorkflowDefinitionYAML: t.WorkflowDefinitionYaml, Org: org.OrgID(t.Org), + CallParentTaskID: t.CallParentTaskId, + CallDepth: int(t.CallDepth), } } @@ -453,6 +457,9 @@ var wireErrors = []struct { {storecontract.ErrEventTypeNotFound, codes.NotFound, msgEventTypeNotFound}, {storecontract.ErrSourceNotFound, codes.NotFound, msgSourceNotFound}, {storecontract.ErrAlreadyDispatched, codes.AlreadyExists, msgAlreadyDispatched}, + {storecontract.ErrCallNotYours, codes.PermissionDenied, storecontract.ErrCallNotYours.Error()}, + {storecontract.ErrCallCallerNotRunning, codes.FailedPrecondition, storecontract.ErrCallCallerNotRunning.Error()}, + {storecontract.ErrCallDepthExceeded, codes.FailedPrecondition, storecontract.ErrCallDepthExceeded.Error()}, {storecontract.ErrSourcePathTaken, codes.AlreadyExists, msgSourcePathTaken}, {storepkg.ErrNotFound, codes.NotFound, storepkg.ErrNotFound.Error()}, {storepkg.ErrInstalled, codes.AlreadyExists, storepkg.ErrInstalled.Error()}, diff --git a/internal/infrastructure/staterpc/workflow_call_conformance_test.go b/internal/infrastructure/staterpc/workflow_call_conformance_test.go new file mode 100644 index 000000000..1947d2d8c --- /dev/null +++ b/internal/infrastructure/staterpc/workflow_call_conformance_test.go @@ -0,0 +1,114 @@ +package staterpc + +import ( + "errors" + "testing" + + "github.com/samcharles93/archie-core/internal/domain/storecontract" + "github.com/samcharles93/archie-core/internal/domain/workflow" + "github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore" +) + +// workflowCallerContract is the workflow.call surface both adapters must +// satisfy identically (ยง11), including refusal-sentinel fidelity across the +// wire (docs/prds/workflow-calls.md). +type workflowCallerContract interface { + storecontract.WorkflowCaller +} + +// TestWorkflowCallerConformance drives StartCall/CallStatus through the local +// PostgreSQL store and a bufconn-backed gRPC client. +func TestWorkflowCallerConformance(t *testing.T) { + for _, mode := range []string{"local", "grpc"} { + t.Run(mode, func(t *testing.T) { + ctx := t.Context() + local := pgstore.Open(t) + var c workflowCallerContract = local + if mode == "grpc" { + c = remoteTaskStore(t, local, nil, nil) + } + + caller, err := local.EnqueueChatTask(ctx, "acme", "widget", "caller", "body", "implement", "") + if err != nil { + t.Fatalf("EnqueueChatTask: %v", err) + } + if err := local.Transition(ctx, caller.ID, caller.Status, workflow.StatusRunning, "started"); err != nil { + t.Fatalf("Transition caller: %v", err) + } + + // A running caller's callee inherits its row and links back to it. + callee, err := c.StartCall(ctx, caller.ID, "callee", map[string]any{"src_ip": "10.0.0.9"}) + if err != nil || callee == nil { + t.Fatalf("StartCall: (%+v, %v)", callee, err) + } + if callee.Workflow != "callee" || callee.CallParentTaskID != caller.ID || callee.CallDepth != 1 { + t.Fatalf("callee = %+v, want the parent link and depth 1", callee) + } + if callee.Org != caller.Org || callee.Identity != caller.Identity { + t.Fatalf("callee org/identity = %q/%q, want the caller's %q/%q", callee.Org, callee.Identity, caller.Org, caller.Identity) + } + if callee.Owner != caller.Owner || callee.Repo != caller.Repo { + t.Fatalf("callee owner/repo = %s/%s, want the caller's %s/%s", callee.Owner, callee.Repo, caller.Owner, caller.Repo) + } + if callee.Source != "chat" || callee.IssueNumber == caller.IssueNumber { + t.Fatalf("callee source/issue = %s/%d, want a chat source with a fresh synthetic number", callee.Source, callee.IssueNumber) + } + if callee.Inputs["src_ip"] != "10.0.0.9" { + t.Fatalf("callee inputs = %+v, want the call's inputs", callee.Inputs) + } + + // A callee that has not moved yet answers its queued status with + // no detail; after a transition the detail is the latest one. + status, detail, err := c.CallStatus(ctx, caller.ID, callee.ID) + if err != nil || status != workflow.StatusQueued || detail != "" { + t.Fatalf("CallStatus queued = (%q, %q, %v), want (queued, \"\", nil)", status, detail, err) + } + if err := local.Transition(ctx, callee.ID, callee.Status, workflow.StatusCompleted, "contained 10.0.0.9"); err != nil { + t.Fatalf("Transition callee: %v", err) + } + status, detail, err = c.CallStatus(ctx, caller.ID, callee.ID) + if err != nil || status != workflow.StatusCompleted || detail != "contained 10.0.0.9" { + t.Fatalf("CallStatus completed = (%q, %q, %v), want the terminal status and detail", status, detail, err) + } + + // A caller reads only its own callees, over both adapters. + _, _, err = c.CallStatus(ctx, 99999, callee.ID) + if !errors.Is(err, storecontract.ErrCallNotYours) { + t.Fatalf("CallStatus foreign caller = %v, want ErrCallNotYours", err) + } + _, _, err = c.CallStatus(ctx, caller.ID, 99999) + if !errors.Is(err, storecontract.ErrCallNotYours) { + t.Fatalf("CallStatus missing callee = %v, want ErrCallNotYours", err) + } + + // Refusals: a caller that is not running, and the depth limit. The + // sentinels cross the wire, so both adapters report the same one. + if _, err := c.StartCall(ctx, callee.ID, "deeper", nil); !errors.Is(err, storecontract.ErrCallCallerNotRunning) { + t.Fatalf("StartCall from a completed caller = %v, want ErrCallCallerNotRunning", err) + } + // The depth limit is re-checked by the store, not just the engine: + // walk a chain of callees, claiming each so it is running, until + // the insert itself refuses at MaxCallDepth. + current, err := c.StartCall(ctx, caller.ID, "deeper", nil) + if err != nil { + t.Fatalf("StartCall at depth 1: %v", err) + } + for current.CallDepth < workflow.MaxCallDepth { + claimed, err := local.ClaimByIssue(ctx, current.Owner, current.Repo, current.IssueNumber) + if err != nil || claimed == nil { + t.Fatalf("claim depth %d callee: (%+v, %v)", current.CallDepth, claimed, err) + } + current, err = c.StartCall(ctx, current.ID, "deeper", nil) + if err != nil { + t.Fatalf("StartCall at depth %d: %v", claimed.CallDepth+1, err) + } + } + if _, err := local.ClaimByIssue(ctx, current.Owner, current.Repo, current.IssueNumber); err != nil { + t.Fatalf("claim depth %d callee: %v", current.CallDepth, err) + } + if _, err := c.StartCall(ctx, current.ID, "deeper", nil); !errors.Is(err, storecontract.ErrCallDepthExceeded) { + t.Fatalf("StartCall past the depth limit = %v, want ErrCallDepthExceeded", err) + } + }) + } +} diff --git a/proto/state/v1/state.proto b/proto/state/v1/state.proto index b2a90e523..48fb14798 100644 --- a/proto/state/v1/state.proto +++ b/proto/state/v1/state.proto @@ -157,6 +157,14 @@ service StateStoreService { // BindingTaskCreator rpc EnqueueBindingTask(EnqueueBindingTaskRequest) returns (EnqueueBindingTaskResponse); + + // WorkflowCaller: a workflow.call step starts its callee and, with + // wait:true, reads it back while waiting. Both are the one sanctioned + // widening of a task-scoped grant -- the callee is the caller's child + // (docs/prds/workflow-calls.md). CallStatus re-checks the parent-child + // relation server-side, so the grant only names the caller. + rpc EnqueueCallTask(EnqueueCallTaskRequest) returns (EnqueueCallTaskResponse); + rpc WorkflowCallStatus(WorkflowCallStatusRequest) returns (WorkflowCallStatusResponse); } message RegisterTaskGrantRequest { @@ -282,6 +290,12 @@ message Task { // 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; + // The workflow.call linkage (docs/prds/workflow-calls.md): the task whose + // workflow.call step started this one (0 on a root run) and how many + // call hops this row is from that root. Columns default, so an older + // writer reads as a depth-0 root run. + int64 call_parent_task_id = 36; + int32 call_depth = 37; } // Event mirrors internal/events.Event. Data is carried as a JSON object @@ -862,6 +876,29 @@ message EnqueueBindingTaskRequest { } message EnqueueBindingTaskResponse { Task task = 1; } +// workflow.call: the caller's grant names the caller; the store derives the +// rest from the caller's row (docs/prds/workflow-calls.md). +message EnqueueCallTaskRequest { + int64 caller_task_id = 1; + string workflow = 2; + string inputs_json = 3; +} +message EnqueueCallTaskResponse { + Task task = 1; + bool accepted = 2; +} + +message WorkflowCallStatusRequest { + int64 caller_task_id = 1; + int64 call_task_id = 2; +} +message WorkflowCallStatusResponse { + // status is the callee's task status and detail its latest transition + // detail (empty before the callee first moves). + string status = 1; + string detail = 2; +} + message InstalledPackage { string org_id = 1; string name = 2;