feat(workflow): a handoff starts a separate linked run of the next workflow (#1791)
This commit is contained in:
27 files changed
+702
-166
No files matched your search
@@ -7,6 +7,8 @@ release's per-component sections are labelled beneath its heading.
|
||||
|
||||
### archied
|
||||
|
||||
- A `workflow.handoff` now finishes its run and starts a separate, linked run of the next workflow on the same issue, instead of continuing as another attempt. The task page links each run to the one before and after it; attempts count only retries of one run.
|
||||
|
||||
- A task no longer fails to prepare its worktree with "some refs were not updated" after a tag or branch moves on the forge.
|
||||
|
||||
### archie-ui
|
||||
|
||||
@@ -77,6 +77,13 @@ func (b *boot) removeTaskWorktree(task *taskactions.Task) error {
|
||||
if b.d == nil {
|
||||
return nil
|
||||
}
|
||||
// A run that handed off shares the work item's worktree with its
|
||||
// successor; archiving the old run must not remove it.
|
||||
if current, err := b.stateStore.TaskByIssue(context.Background(), task.Owner, task.Repo, task.IssueNumber); err != nil {
|
||||
return err
|
||||
} else if current != nil && current.ID != task.ID {
|
||||
return nil
|
||||
}
|
||||
return b.d.RemoveWorktree(&workflow.Task{Owner: task.Owner, Repo: task.Repo, Identity: task.Identity, IssueNumber: task.IssueNumber, Org: task.Org})
|
||||
}
|
||||
|
||||
|
||||
@@ -2163,6 +2163,110 @@ func (x *EnqueueCallTaskRequest) GetCallKey() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type HandoffTaskRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`
|
||||
Workflow string `protobuf:"bytes,2,opt,name=workflow,proto3" json:"workflow,omitempty"`
|
||||
Detail string `protobuf:"bytes,3,opt,name=detail,proto3" json:"detail,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *HandoffTaskRequest) Reset() {
|
||||
*x = HandoffTaskRequest{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[41]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *HandoffTaskRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HandoffTaskRequest) ProtoMessage() {}
|
||||
|
||||
func (x *HandoffTaskRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[41]
|
||||
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 HandoffTaskRequest.ProtoReflect.Descriptor instead.
|
||||
func (*HandoffTaskRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{41}
|
||||
}
|
||||
|
||||
func (x *HandoffTaskRequest) GetTaskId() int64 {
|
||||
if x != nil {
|
||||
return x.TaskId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *HandoffTaskRequest) GetWorkflow() string {
|
||||
if x != nil {
|
||||
return x.Workflow
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *HandoffTaskRequest) GetDetail() string {
|
||||
if x != nil {
|
||||
return x.Detail
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type HandoffTaskResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *HandoffTaskResponse) Reset() {
|
||||
*x = HandoffTaskResponse{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[42]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *HandoffTaskResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HandoffTaskResponse) ProtoMessage() {}
|
||||
|
||||
func (x *HandoffTaskResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[42]
|
||||
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 HandoffTaskResponse.ProtoReflect.Descriptor instead.
|
||||
func (*HandoffTaskResponse) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{42}
|
||||
}
|
||||
|
||||
func (x *HandoffTaskResponse) GetTask() *Task {
|
||||
if x != nil {
|
||||
return x.Task
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type EnqueueCallTaskResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
||||
@@ -2173,7 +2277,7 @@ type EnqueueCallTaskResponse struct {
|
||||
|
||||
func (x *EnqueueCallTaskResponse) Reset() {
|
||||
*x = EnqueueCallTaskResponse{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[41]
|
||||
mi := &file_state_v1_task_proto_msgTypes[43]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2185,7 +2289,7 @@ func (x *EnqueueCallTaskResponse) String() string {
|
||||
func (*EnqueueCallTaskResponse) ProtoMessage() {}
|
||||
|
||||
func (x *EnqueueCallTaskResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[41]
|
||||
mi := &file_state_v1_task_proto_msgTypes[43]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2198,7 +2302,7 @@ func (x *EnqueueCallTaskResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use EnqueueCallTaskResponse.ProtoReflect.Descriptor instead.
|
||||
func (*EnqueueCallTaskResponse) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{41}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{43}
|
||||
}
|
||||
|
||||
func (x *EnqueueCallTaskResponse) GetTask() *Task {
|
||||
@@ -2225,7 +2329,7 @@ type WorkflowCallStatusRequest struct {
|
||||
|
||||
func (x *WorkflowCallStatusRequest) Reset() {
|
||||
*x = WorkflowCallStatusRequest{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[42]
|
||||
mi := &file_state_v1_task_proto_msgTypes[44]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2237,7 +2341,7 @@ func (x *WorkflowCallStatusRequest) String() string {
|
||||
func (*WorkflowCallStatusRequest) ProtoMessage() {}
|
||||
|
||||
func (x *WorkflowCallStatusRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[42]
|
||||
mi := &file_state_v1_task_proto_msgTypes[44]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2250,7 +2354,7 @@ func (x *WorkflowCallStatusRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use WorkflowCallStatusRequest.ProtoReflect.Descriptor instead.
|
||||
func (*WorkflowCallStatusRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{42}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{44}
|
||||
}
|
||||
|
||||
func (x *WorkflowCallStatusRequest) GetCallerTaskId() int64 {
|
||||
@@ -2283,7 +2387,7 @@ type WorkflowCallStatusResponse struct {
|
||||
|
||||
func (x *WorkflowCallStatusResponse) Reset() {
|
||||
*x = WorkflowCallStatusResponse{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[43]
|
||||
mi := &file_state_v1_task_proto_msgTypes[45]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2295,7 +2399,7 @@ func (x *WorkflowCallStatusResponse) String() string {
|
||||
func (*WorkflowCallStatusResponse) ProtoMessage() {}
|
||||
|
||||
func (x *WorkflowCallStatusResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[43]
|
||||
mi := &file_state_v1_task_proto_msgTypes[45]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2308,7 +2412,7 @@ func (x *WorkflowCallStatusResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use WorkflowCallStatusResponse.ProtoReflect.Descriptor instead.
|
||||
func (*WorkflowCallStatusResponse) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{43}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{45}
|
||||
}
|
||||
|
||||
func (x *WorkflowCallStatusResponse) GetStatus() string {
|
||||
@@ -2341,7 +2445,7 @@ type TaskModelsRequest struct {
|
||||
|
||||
func (x *TaskModelsRequest) Reset() {
|
||||
*x = TaskModelsRequest{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[44]
|
||||
mi := &file_state_v1_task_proto_msgTypes[46]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2353,7 +2457,7 @@ func (x *TaskModelsRequest) String() string {
|
||||
func (*TaskModelsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *TaskModelsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[44]
|
||||
mi := &file_state_v1_task_proto_msgTypes[46]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2366,7 +2470,7 @@ func (x *TaskModelsRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TaskModelsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*TaskModelsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{44}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{46}
|
||||
}
|
||||
|
||||
func (x *TaskModelsRequest) GetTaskId() int64 {
|
||||
@@ -2385,7 +2489,7 @@ type TaskInstructionsRequest struct {
|
||||
|
||||
func (x *TaskInstructionsRequest) Reset() {
|
||||
*x = TaskInstructionsRequest{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[45]
|
||||
mi := &file_state_v1_task_proto_msgTypes[47]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2397,7 +2501,7 @@ func (x *TaskInstructionsRequest) String() string {
|
||||
func (*TaskInstructionsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *TaskInstructionsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[45]
|
||||
mi := &file_state_v1_task_proto_msgTypes[47]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2410,7 +2514,7 @@ func (x *TaskInstructionsRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TaskInstructionsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*TaskInstructionsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{45}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{47}
|
||||
}
|
||||
|
||||
func (x *TaskInstructionsRequest) GetTaskId() int64 {
|
||||
@@ -2430,7 +2534,7 @@ type TaskInstructionsResponse struct {
|
||||
|
||||
func (x *TaskInstructionsResponse) Reset() {
|
||||
*x = TaskInstructionsResponse{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[46]
|
||||
mi := &file_state_v1_task_proto_msgTypes[48]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2442,7 +2546,7 @@ func (x *TaskInstructionsResponse) String() string {
|
||||
func (*TaskInstructionsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *TaskInstructionsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[46]
|
||||
mi := &file_state_v1_task_proto_msgTypes[48]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2455,7 +2559,7 @@ func (x *TaskInstructionsResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TaskInstructionsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*TaskInstructionsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{46}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{48}
|
||||
}
|
||||
|
||||
func (x *TaskInstructionsResponse) GetInstance() string {
|
||||
@@ -2483,7 +2587,7 @@ type TaskModelsResponse struct {
|
||||
|
||||
func (x *TaskModelsResponse) Reset() {
|
||||
*x = TaskModelsResponse{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[47]
|
||||
mi := &file_state_v1_task_proto_msgTypes[49]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2495,7 +2599,7 @@ func (x *TaskModelsResponse) String() string {
|
||||
func (*TaskModelsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *TaskModelsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[47]
|
||||
mi := &file_state_v1_task_proto_msgTypes[49]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2508,7 +2612,7 @@ func (x *TaskModelsResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use TaskModelsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*TaskModelsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{47}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{49}
|
||||
}
|
||||
|
||||
func (x *TaskModelsResponse) GetOrgId() string {
|
||||
@@ -2550,7 +2654,7 @@ type ModelProvider struct {
|
||||
|
||||
func (x *ModelProvider) Reset() {
|
||||
*x = ModelProvider{}
|
||||
mi := &file_state_v1_task_proto_msgTypes[48]
|
||||
mi := &file_state_v1_task_proto_msgTypes[50]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -2562,7 +2666,7 @@ func (x *ModelProvider) String() string {
|
||||
func (*ModelProvider) ProtoMessage() {}
|
||||
|
||||
func (x *ModelProvider) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_state_v1_task_proto_msgTypes[48]
|
||||
mi := &file_state_v1_task_proto_msgTypes[50]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -2575,7 +2679,7 @@ func (x *ModelProvider) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ModelProvider.ProtoReflect.Descriptor instead.
|
||||
func (*ModelProvider) Descriptor() ([]byte, []int) {
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{48}
|
||||
return file_state_v1_task_proto_rawDescGZIP(), []int{50}
|
||||
}
|
||||
|
||||
func (x *ModelProvider) GetClass() string {
|
||||
@@ -2746,7 +2850,13 @@ const file_state_v1_task_proto_rawDesc = "" +
|
||||
"\bworkflow\x18\x02 \x01(\tR\bworkflow\x12\x1f\n" +
|
||||
"\vinputs_json\x18\x03 \x01(\tR\n" +
|
||||
"inputsJson\x12\x19\n" +
|
||||
"\bcall_key\x18\x04 \x01(\tR\acallKey\"Y\n" +
|
||||
"\bcall_key\x18\x04 \x01(\tR\acallKey\"a\n" +
|
||||
"\x12HandoffTaskRequest\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\x03R\x06taskId\x12\x1a\n" +
|
||||
"\bworkflow\x18\x02 \x01(\tR\bworkflow\x12\x16\n" +
|
||||
"\x06detail\x18\x03 \x01(\tR\x06detail\"9\n" +
|
||||
"\x13HandoffTaskResponse\x12\"\n" +
|
||||
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"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" +
|
||||
@@ -2780,7 +2890,7 @@ const file_state_v1_task_proto_rawDesc = "" +
|
||||
"\bbase_url\x18\x02 \x01(\tR\abaseUrl\x12\x1e\n" +
|
||||
"\vapi_key_env\x18\x03 \x01(\tR\tapiKeyEnv\x12$\n" +
|
||||
"\x0eapi_key_engine\x18\x04 \x01(\tR\fapiKeyEngine\x12\x1e\n" +
|
||||
"\vapi_key_key\x18\x05 \x01(\tR\tapiKeyKey2\xe6\x0e\n" +
|
||||
"\vapi_key_key\x18\x05 \x01(\tR\tapiKeyKey2\xb2\x0f\n" +
|
||||
"\vTaskService\x12M\n" +
|
||||
"\fEnqueueIssue\x12\x1d.state.v1.EnqueueIssueRequest\x1a\x1e.state.v1.EnqueueIssueResponse\x12V\n" +
|
||||
"\x0fEnqueueChatTask\x12 .state.v1.EnqueueChatTaskRequest\x1a!.state.v1.EnqueueChatTaskResponse\x12b\n" +
|
||||
@@ -2806,7 +2916,8 @@ const file_state_v1_task_proto_rawDesc = "" +
|
||||
"\aOpenPRs\x12\x18.state.v1.OpenPRsRequest\x1a\x19.state.v1.OpenPRsResponse\x12_\n" +
|
||||
"\x12ClearTerminalTasks\x12#.state.v1.ClearTerminalTasksRequest\x1a$.state.v1.ClearTerminalTasksResponse\x128\n" +
|
||||
"\x05Tasks\x12\x16.state.v1.TasksRequest\x1a\x17.state.v1.TasksResponse\x12V\n" +
|
||||
"\x0fEnqueueCallTask\x12 .state.v1.EnqueueCallTaskRequest\x1a!.state.v1.EnqueueCallTaskResponse\x12_\n" +
|
||||
"\x0fEnqueueCallTask\x12 .state.v1.EnqueueCallTaskRequest\x1a!.state.v1.EnqueueCallTaskResponse\x12J\n" +
|
||||
"\vHandoffTask\x12\x1c.state.v1.HandoffTaskRequest\x1a\x1d.state.v1.HandoffTaskResponse\x12_\n" +
|
||||
"\x12WorkflowCallStatus\x12#.state.v1.WorkflowCallStatusRequest\x1a$.state.v1.WorkflowCallStatusResponseB\xa3\x01\n" +
|
||||
"\fcom.state.v1B\tTaskProtoP\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"
|
||||
|
||||
@@ -2822,7 +2933,7 @@ func file_state_v1_task_proto_rawDescGZIP() []byte {
|
||||
return file_state_v1_task_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_state_v1_task_proto_msgTypes = make([]protoimpl.MessageInfo, 51)
|
||||
var file_state_v1_task_proto_msgTypes = make([]protoimpl.MessageInfo, 53)
|
||||
var file_state_v1_task_proto_goTypes = []any{
|
||||
(*EnqueueIssueRequest)(nil), // 0: state.v1.EnqueueIssueRequest
|
||||
(*EnqueueIssueResponse)(nil), // 1: state.v1.EnqueueIssueResponse
|
||||
@@ -2865,91 +2976,96 @@ var file_state_v1_task_proto_goTypes = []any{
|
||||
(*TasksRequest)(nil), // 38: state.v1.TasksRequest
|
||||
(*TasksResponse)(nil), // 39: state.v1.TasksResponse
|
||||
(*EnqueueCallTaskRequest)(nil), // 40: state.v1.EnqueueCallTaskRequest
|
||||
(*EnqueueCallTaskResponse)(nil), // 41: state.v1.EnqueueCallTaskResponse
|
||||
(*WorkflowCallStatusRequest)(nil), // 42: state.v1.WorkflowCallStatusRequest
|
||||
(*WorkflowCallStatusResponse)(nil), // 43: state.v1.WorkflowCallStatusResponse
|
||||
(*TaskModelsRequest)(nil), // 44: state.v1.TaskModelsRequest
|
||||
(*TaskInstructionsRequest)(nil), // 45: state.v1.TaskInstructionsRequest
|
||||
(*TaskInstructionsResponse)(nil), // 46: state.v1.TaskInstructionsResponse
|
||||
(*TaskModelsResponse)(nil), // 47: state.v1.TaskModelsResponse
|
||||
(*ModelProvider)(nil), // 48: state.v1.ModelProvider
|
||||
nil, // 49: state.v1.TaskModelsResponse.AliasesEntry
|
||||
nil, // 50: state.v1.TaskModelsResponse.ProvidersEntry
|
||||
(*Task)(nil), // 51: state.v1.Task
|
||||
(*Event)(nil), // 52: state.v1.Event
|
||||
(*timestamppb.Timestamp)(nil), // 53: google.protobuf.Timestamp
|
||||
(*HandoffTaskRequest)(nil), // 41: state.v1.HandoffTaskRequest
|
||||
(*HandoffTaskResponse)(nil), // 42: state.v1.HandoffTaskResponse
|
||||
(*EnqueueCallTaskResponse)(nil), // 43: state.v1.EnqueueCallTaskResponse
|
||||
(*WorkflowCallStatusRequest)(nil), // 44: state.v1.WorkflowCallStatusRequest
|
||||
(*WorkflowCallStatusResponse)(nil), // 45: state.v1.WorkflowCallStatusResponse
|
||||
(*TaskModelsRequest)(nil), // 46: state.v1.TaskModelsRequest
|
||||
(*TaskInstructionsRequest)(nil), // 47: state.v1.TaskInstructionsRequest
|
||||
(*TaskInstructionsResponse)(nil), // 48: state.v1.TaskInstructionsResponse
|
||||
(*TaskModelsResponse)(nil), // 49: state.v1.TaskModelsResponse
|
||||
(*ModelProvider)(nil), // 50: state.v1.ModelProvider
|
||||
nil, // 51: state.v1.TaskModelsResponse.AliasesEntry
|
||||
nil, // 52: state.v1.TaskModelsResponse.ProvidersEntry
|
||||
(*Task)(nil), // 53: state.v1.Task
|
||||
(*Event)(nil), // 54: state.v1.Event
|
||||
(*timestamppb.Timestamp)(nil), // 55: google.protobuf.Timestamp
|
||||
}
|
||||
var file_state_v1_task_proto_depIdxs = []int32{
|
||||
51, // 0: state.v1.ActiveTasksByOriginResponse.tasks:type_name -> state.v1.Task
|
||||
51, // 1: state.v1.UnpostedOutcomesResponse.tasks:type_name -> state.v1.Task
|
||||
51, // 2: state.v1.EnqueueChatTaskResponse.task:type_name -> state.v1.Task
|
||||
51, // 3: state.v1.ClaimNextResponse.task:type_name -> state.v1.Task
|
||||
51, // 4: state.v1.ClaimByIssueResponse.task:type_name -> state.v1.Task
|
||||
51, // 5: state.v1.UpdateRequest.task:type_name -> state.v1.Task
|
||||
52, // 6: state.v1.ArchiveTaskRequest.audit:type_name -> state.v1.Event
|
||||
51, // 7: state.v1.TaskByIssueResponse.task:type_name -> state.v1.Task
|
||||
51, // 8: state.v1.OpenTaskByPRResponse.task:type_name -> state.v1.Task
|
||||
51, // 9: state.v1.TaskByIDResponse.task:type_name -> state.v1.Task
|
||||
51, // 10: state.v1.OpenPRsResponse.tasks:type_name -> state.v1.Task
|
||||
53, // 11: state.v1.TasksRequest.after_updated_at:type_name -> google.protobuf.Timestamp
|
||||
51, // 12: state.v1.TasksResponse.tasks:type_name -> state.v1.Task
|
||||
51, // 13: state.v1.EnqueueCallTaskResponse.task:type_name -> state.v1.Task
|
||||
49, // 14: state.v1.TaskModelsResponse.aliases:type_name -> state.v1.TaskModelsResponse.AliasesEntry
|
||||
50, // 15: state.v1.TaskModelsResponse.providers:type_name -> state.v1.TaskModelsResponse.ProvidersEntry
|
||||
48, // 16: state.v1.TaskModelsResponse.ProvidersEntry.value:type_name -> state.v1.ModelProvider
|
||||
0, // 17: state.v1.TaskService.EnqueueIssue:input_type -> state.v1.EnqueueIssueRequest
|
||||
8, // 18: state.v1.TaskService.EnqueueChatTask:input_type -> state.v1.EnqueueChatTaskRequest
|
||||
2, // 19: state.v1.TaskService.ActiveTasksByOrigin:input_type -> state.v1.ActiveTasksByOriginRequest
|
||||
4, // 20: state.v1.TaskService.UnpostedOutcomes:input_type -> state.v1.UnpostedOutcomesRequest
|
||||
6, // 21: state.v1.TaskService.MarkOutcomePosted:input_type -> state.v1.MarkOutcomePostedRequest
|
||||
10, // 22: state.v1.TaskService.ClaimNext:input_type -> state.v1.ClaimNextRequest
|
||||
12, // 23: state.v1.TaskService.ClaimByIssue:input_type -> state.v1.ClaimByIssueRequest
|
||||
14, // 24: state.v1.TaskService.Transition:input_type -> state.v1.TransitionRequest
|
||||
16, // 25: state.v1.TaskService.Update:input_type -> state.v1.UpdateRequest
|
||||
44, // 26: state.v1.TaskService.TaskModels:input_type -> state.v1.TaskModelsRequest
|
||||
45, // 27: state.v1.TaskService.TaskInstructions:input_type -> state.v1.TaskInstructionsRequest
|
||||
18, // 28: state.v1.TaskService.Requeue:input_type -> state.v1.RequeueRequest
|
||||
20, // 29: state.v1.TaskService.ParkTask:input_type -> state.v1.ParkTaskRequest
|
||||
22, // 30: state.v1.TaskService.RecoverStale:input_type -> state.v1.RecoverStaleRequest
|
||||
24, // 31: state.v1.TaskService.ArchiveTask:input_type -> state.v1.ArchiveTaskRequest
|
||||
26, // 32: state.v1.TaskService.RetryTask:input_type -> state.v1.RetryTaskRequest
|
||||
28, // 33: state.v1.TaskService.TaskByIssue:input_type -> state.v1.TaskByIssueRequest
|
||||
30, // 34: state.v1.TaskService.OpenTaskByPR:input_type -> state.v1.OpenTaskByPRRequest
|
||||
32, // 35: state.v1.TaskService.TaskByID:input_type -> state.v1.TaskByIDRequest
|
||||
34, // 36: state.v1.TaskService.OpenPRs:input_type -> state.v1.OpenPRsRequest
|
||||
36, // 37: state.v1.TaskService.ClearTerminalTasks:input_type -> state.v1.ClearTerminalTasksRequest
|
||||
38, // 38: state.v1.TaskService.Tasks:input_type -> state.v1.TasksRequest
|
||||
40, // 39: state.v1.TaskService.EnqueueCallTask:input_type -> state.v1.EnqueueCallTaskRequest
|
||||
42, // 40: state.v1.TaskService.WorkflowCallStatus:input_type -> state.v1.WorkflowCallStatusRequest
|
||||
1, // 41: state.v1.TaskService.EnqueueIssue:output_type -> state.v1.EnqueueIssueResponse
|
||||
9, // 42: state.v1.TaskService.EnqueueChatTask:output_type -> state.v1.EnqueueChatTaskResponse
|
||||
3, // 43: state.v1.TaskService.ActiveTasksByOrigin:output_type -> state.v1.ActiveTasksByOriginResponse
|
||||
5, // 44: state.v1.TaskService.UnpostedOutcomes:output_type -> state.v1.UnpostedOutcomesResponse
|
||||
7, // 45: state.v1.TaskService.MarkOutcomePosted:output_type -> state.v1.MarkOutcomePostedResponse
|
||||
11, // 46: state.v1.TaskService.ClaimNext:output_type -> state.v1.ClaimNextResponse
|
||||
13, // 47: state.v1.TaskService.ClaimByIssue:output_type -> state.v1.ClaimByIssueResponse
|
||||
15, // 48: state.v1.TaskService.Transition:output_type -> state.v1.TransitionResponse
|
||||
17, // 49: state.v1.TaskService.Update:output_type -> state.v1.UpdateResponse
|
||||
47, // 50: state.v1.TaskService.TaskModels:output_type -> state.v1.TaskModelsResponse
|
||||
46, // 51: state.v1.TaskService.TaskInstructions:output_type -> state.v1.TaskInstructionsResponse
|
||||
19, // 52: state.v1.TaskService.Requeue:output_type -> state.v1.RequeueResponse
|
||||
21, // 53: state.v1.TaskService.ParkTask:output_type -> state.v1.ParkTaskResponse
|
||||
23, // 54: state.v1.TaskService.RecoverStale:output_type -> state.v1.RecoverStaleResponse
|
||||
25, // 55: state.v1.TaskService.ArchiveTask:output_type -> state.v1.ArchiveTaskResponse
|
||||
27, // 56: state.v1.TaskService.RetryTask:output_type -> state.v1.RetryTaskResponse
|
||||
29, // 57: state.v1.TaskService.TaskByIssue:output_type -> state.v1.TaskByIssueResponse
|
||||
31, // 58: state.v1.TaskService.OpenTaskByPR:output_type -> state.v1.OpenTaskByPRResponse
|
||||
33, // 59: state.v1.TaskService.TaskByID:output_type -> state.v1.TaskByIDResponse
|
||||
35, // 60: state.v1.TaskService.OpenPRs:output_type -> state.v1.OpenPRsResponse
|
||||
37, // 61: state.v1.TaskService.ClearTerminalTasks:output_type -> state.v1.ClearTerminalTasksResponse
|
||||
39, // 62: state.v1.TaskService.Tasks:output_type -> state.v1.TasksResponse
|
||||
41, // 63: state.v1.TaskService.EnqueueCallTask:output_type -> state.v1.EnqueueCallTaskResponse
|
||||
43, // 64: state.v1.TaskService.WorkflowCallStatus:output_type -> state.v1.WorkflowCallStatusResponse
|
||||
41, // [41:65] is the sub-list for method output_type
|
||||
17, // [17:41] is the sub-list for method input_type
|
||||
17, // [17:17] is the sub-list for extension type_name
|
||||
17, // [17:17] is the sub-list for extension extendee
|
||||
0, // [0:17] is the sub-list for field type_name
|
||||
53, // 0: state.v1.ActiveTasksByOriginResponse.tasks:type_name -> state.v1.Task
|
||||
53, // 1: state.v1.UnpostedOutcomesResponse.tasks:type_name -> state.v1.Task
|
||||
53, // 2: state.v1.EnqueueChatTaskResponse.task:type_name -> state.v1.Task
|
||||
53, // 3: state.v1.ClaimNextResponse.task:type_name -> state.v1.Task
|
||||
53, // 4: state.v1.ClaimByIssueResponse.task:type_name -> state.v1.Task
|
||||
53, // 5: state.v1.UpdateRequest.task:type_name -> state.v1.Task
|
||||
54, // 6: state.v1.ArchiveTaskRequest.audit:type_name -> state.v1.Event
|
||||
53, // 7: state.v1.TaskByIssueResponse.task:type_name -> state.v1.Task
|
||||
53, // 8: state.v1.OpenTaskByPRResponse.task:type_name -> state.v1.Task
|
||||
53, // 9: state.v1.TaskByIDResponse.task:type_name -> state.v1.Task
|
||||
53, // 10: state.v1.OpenPRsResponse.tasks:type_name -> state.v1.Task
|
||||
55, // 11: state.v1.TasksRequest.after_updated_at:type_name -> google.protobuf.Timestamp
|
||||
53, // 12: state.v1.TasksResponse.tasks:type_name -> state.v1.Task
|
||||
53, // 13: state.v1.HandoffTaskResponse.task:type_name -> state.v1.Task
|
||||
53, // 14: state.v1.EnqueueCallTaskResponse.task:type_name -> state.v1.Task
|
||||
51, // 15: state.v1.TaskModelsResponse.aliases:type_name -> state.v1.TaskModelsResponse.AliasesEntry
|
||||
52, // 16: state.v1.TaskModelsResponse.providers:type_name -> state.v1.TaskModelsResponse.ProvidersEntry
|
||||
50, // 17: state.v1.TaskModelsResponse.ProvidersEntry.value:type_name -> state.v1.ModelProvider
|
||||
0, // 18: state.v1.TaskService.EnqueueIssue:input_type -> state.v1.EnqueueIssueRequest
|
||||
8, // 19: state.v1.TaskService.EnqueueChatTask:input_type -> state.v1.EnqueueChatTaskRequest
|
||||
2, // 20: state.v1.TaskService.ActiveTasksByOrigin:input_type -> state.v1.ActiveTasksByOriginRequest
|
||||
4, // 21: state.v1.TaskService.UnpostedOutcomes:input_type -> state.v1.UnpostedOutcomesRequest
|
||||
6, // 22: state.v1.TaskService.MarkOutcomePosted:input_type -> state.v1.MarkOutcomePostedRequest
|
||||
10, // 23: state.v1.TaskService.ClaimNext:input_type -> state.v1.ClaimNextRequest
|
||||
12, // 24: state.v1.TaskService.ClaimByIssue:input_type -> state.v1.ClaimByIssueRequest
|
||||
14, // 25: state.v1.TaskService.Transition:input_type -> state.v1.TransitionRequest
|
||||
16, // 26: state.v1.TaskService.Update:input_type -> state.v1.UpdateRequest
|
||||
46, // 27: state.v1.TaskService.TaskModels:input_type -> state.v1.TaskModelsRequest
|
||||
47, // 28: state.v1.TaskService.TaskInstructions:input_type -> state.v1.TaskInstructionsRequest
|
||||
18, // 29: state.v1.TaskService.Requeue:input_type -> state.v1.RequeueRequest
|
||||
20, // 30: state.v1.TaskService.ParkTask:input_type -> state.v1.ParkTaskRequest
|
||||
22, // 31: state.v1.TaskService.RecoverStale:input_type -> state.v1.RecoverStaleRequest
|
||||
24, // 32: state.v1.TaskService.ArchiveTask:input_type -> state.v1.ArchiveTaskRequest
|
||||
26, // 33: state.v1.TaskService.RetryTask:input_type -> state.v1.RetryTaskRequest
|
||||
28, // 34: state.v1.TaskService.TaskByIssue:input_type -> state.v1.TaskByIssueRequest
|
||||
30, // 35: state.v1.TaskService.OpenTaskByPR:input_type -> state.v1.OpenTaskByPRRequest
|
||||
32, // 36: state.v1.TaskService.TaskByID:input_type -> state.v1.TaskByIDRequest
|
||||
34, // 37: state.v1.TaskService.OpenPRs:input_type -> state.v1.OpenPRsRequest
|
||||
36, // 38: state.v1.TaskService.ClearTerminalTasks:input_type -> state.v1.ClearTerminalTasksRequest
|
||||
38, // 39: state.v1.TaskService.Tasks:input_type -> state.v1.TasksRequest
|
||||
40, // 40: state.v1.TaskService.EnqueueCallTask:input_type -> state.v1.EnqueueCallTaskRequest
|
||||
41, // 41: state.v1.TaskService.HandoffTask:input_type -> state.v1.HandoffTaskRequest
|
||||
44, // 42: state.v1.TaskService.WorkflowCallStatus:input_type -> state.v1.WorkflowCallStatusRequest
|
||||
1, // 43: state.v1.TaskService.EnqueueIssue:output_type -> state.v1.EnqueueIssueResponse
|
||||
9, // 44: state.v1.TaskService.EnqueueChatTask:output_type -> state.v1.EnqueueChatTaskResponse
|
||||
3, // 45: state.v1.TaskService.ActiveTasksByOrigin:output_type -> state.v1.ActiveTasksByOriginResponse
|
||||
5, // 46: state.v1.TaskService.UnpostedOutcomes:output_type -> state.v1.UnpostedOutcomesResponse
|
||||
7, // 47: state.v1.TaskService.MarkOutcomePosted:output_type -> state.v1.MarkOutcomePostedResponse
|
||||
11, // 48: state.v1.TaskService.ClaimNext:output_type -> state.v1.ClaimNextResponse
|
||||
13, // 49: state.v1.TaskService.ClaimByIssue:output_type -> state.v1.ClaimByIssueResponse
|
||||
15, // 50: state.v1.TaskService.Transition:output_type -> state.v1.TransitionResponse
|
||||
17, // 51: state.v1.TaskService.Update:output_type -> state.v1.UpdateResponse
|
||||
49, // 52: state.v1.TaskService.TaskModels:output_type -> state.v1.TaskModelsResponse
|
||||
48, // 53: state.v1.TaskService.TaskInstructions:output_type -> state.v1.TaskInstructionsResponse
|
||||
19, // 54: state.v1.TaskService.Requeue:output_type -> state.v1.RequeueResponse
|
||||
21, // 55: state.v1.TaskService.ParkTask:output_type -> state.v1.ParkTaskResponse
|
||||
23, // 56: state.v1.TaskService.RecoverStale:output_type -> state.v1.RecoverStaleResponse
|
||||
25, // 57: state.v1.TaskService.ArchiveTask:output_type -> state.v1.ArchiveTaskResponse
|
||||
27, // 58: state.v1.TaskService.RetryTask:output_type -> state.v1.RetryTaskResponse
|
||||
29, // 59: state.v1.TaskService.TaskByIssue:output_type -> state.v1.TaskByIssueResponse
|
||||
31, // 60: state.v1.TaskService.OpenTaskByPR:output_type -> state.v1.OpenTaskByPRResponse
|
||||
33, // 61: state.v1.TaskService.TaskByID:output_type -> state.v1.TaskByIDResponse
|
||||
35, // 62: state.v1.TaskService.OpenPRs:output_type -> state.v1.OpenPRsResponse
|
||||
37, // 63: state.v1.TaskService.ClearTerminalTasks:output_type -> state.v1.ClearTerminalTasksResponse
|
||||
39, // 64: state.v1.TaskService.Tasks:output_type -> state.v1.TasksResponse
|
||||
43, // 65: state.v1.TaskService.EnqueueCallTask:output_type -> state.v1.EnqueueCallTaskResponse
|
||||
42, // 66: state.v1.TaskService.HandoffTask:output_type -> state.v1.HandoffTaskResponse
|
||||
45, // 67: state.v1.TaskService.WorkflowCallStatus:output_type -> state.v1.WorkflowCallStatusResponse
|
||||
43, // [43:68] is the sub-list for method output_type
|
||||
18, // [18:43] is the sub-list for method input_type
|
||||
18, // [18:18] is the sub-list for extension type_name
|
||||
18, // [18:18] is the sub-list for extension extendee
|
||||
0, // [0:18] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_state_v1_task_proto_init() }
|
||||
@@ -2964,7 +3080,7 @@ func file_state_v1_task_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_state_v1_task_proto_rawDesc), len(file_state_v1_task_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 51,
|
||||
NumMessages: 53,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
@@ -42,6 +42,7 @@ const (
|
||||
TaskService_ClearTerminalTasks_FullMethodName = "/state.v1.TaskService/ClearTerminalTasks"
|
||||
TaskService_Tasks_FullMethodName = "/state.v1.TaskService/Tasks"
|
||||
TaskService_EnqueueCallTask_FullMethodName = "/state.v1.TaskService/EnqueueCallTask"
|
||||
TaskService_HandoffTask_FullMethodName = "/state.v1.TaskService/HandoffTask"
|
||||
TaskService_WorkflowCallStatus_FullMethodName = "/state.v1.TaskService/WorkflowCallStatus"
|
||||
)
|
||||
|
||||
@@ -84,6 +85,9 @@ type TaskServiceClient interface {
|
||||
// (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)
|
||||
// HandoffTask completes a running run and starts its linked successor on
|
||||
// the same work item under another workflow.
|
||||
HandoffTask(ctx context.Context, in *HandoffTaskRequest, opts ...grpc.CallOption) (*HandoffTaskResponse, error)
|
||||
WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error)
|
||||
}
|
||||
|
||||
@@ -325,6 +329,16 @@ func (c *taskServiceClient) EnqueueCallTask(ctx context.Context, in *EnqueueCall
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) HandoffTask(ctx context.Context, in *HandoffTaskRequest, opts ...grpc.CallOption) (*HandoffTaskResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(HandoffTaskResponse)
|
||||
err := c.cc.Invoke(ctx, TaskService_HandoffTask_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *taskServiceClient) WorkflowCallStatus(ctx context.Context, in *WorkflowCallStatusRequest, opts ...grpc.CallOption) (*WorkflowCallStatusResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(WorkflowCallStatusResponse)
|
||||
@@ -374,6 +388,9 @@ type TaskServiceServer interface {
|
||||
// (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)
|
||||
// HandoffTask completes a running run and starts its linked successor on
|
||||
// the same work item under another workflow.
|
||||
HandoffTask(context.Context, *HandoffTaskRequest) (*HandoffTaskResponse, error)
|
||||
WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error)
|
||||
mustEmbedUnimplementedTaskServiceServer()
|
||||
}
|
||||
@@ -454,6 +471,9 @@ func (UnimplementedTaskServiceServer) Tasks(context.Context, *TasksRequest) (*Ta
|
||||
func (UnimplementedTaskServiceServer) EnqueueCallTask(context.Context, *EnqueueCallTaskRequest) (*EnqueueCallTaskResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method EnqueueCallTask not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) HandoffTask(context.Context, *HandoffTaskRequest) (*HandoffTaskResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method HandoffTask not implemented")
|
||||
}
|
||||
func (UnimplementedTaskServiceServer) WorkflowCallStatus(context.Context, *WorkflowCallStatusRequest) (*WorkflowCallStatusResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method WorkflowCallStatus not implemented")
|
||||
}
|
||||
@@ -892,6 +912,24 @@ func _TaskService_EnqueueCallTask_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_HandoffTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(HandoffTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(TaskServiceServer).HandoffTask(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: TaskService_HandoffTask_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TaskServiceServer).HandoffTask(ctx, req.(*HandoffTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _TaskService_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 {
|
||||
@@ -1009,6 +1047,10 @@ var TaskService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "EnqueueCallTask",
|
||||
Handler: _TaskService_EnqueueCallTask_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "HandoffTask",
|
||||
Handler: _TaskService_HandoffTask_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "WorkflowCallStatus",
|
||||
Handler: _TaskService_WorkflowCallStatus_Handler,
|
||||
|
||||
@@ -229,9 +229,13 @@ type Task struct {
|
||||
// recorded at the park site; empty when the park has no known fix.
|
||||
ParkBlocker string `protobuf:"bytes,48,opt,name=park_blocker,json=parkBlocker,proto3" json:"park_blocker,omitempty"`
|
||||
// plan_document is the structured plan (JSON) plan was rendered from.
|
||||
PlanDocument string `protobuf:"bytes,50,opt,name=plan_document,json=planDocument,proto3" json:"plan_document,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
PlanDocument string `protobuf:"bytes,50,opt,name=plan_document,json=planDocument,proto3" json:"plan_document,omitempty"`
|
||||
// handoff_from_task_id is the run that handed off to this one; 0 when none.
|
||||
HandoffFromTaskId int64 `protobuf:"varint,51,opt,name=handoff_from_task_id,json=handoffFromTaskId,proto3" json:"handoff_from_task_id,omitempty"`
|
||||
// handoff_to_task_id is the run this one handed off to; 0 when none.
|
||||
HandoffToTaskId int64 `protobuf:"varint,52,opt,name=handoff_to_task_id,json=handoffToTaskId,proto3" json:"handoff_to_task_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Task) Reset() {
|
||||
@@ -608,6 +612,20 @@ func (x *Task) GetPlanDocument() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Task) GetHandoffFromTaskId() int64 {
|
||||
if x != nil {
|
||||
return x.HandoffFromTaskId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Task) GetHandoffToTaskId() int64 {
|
||||
if x != nil {
|
||||
return x.HandoffToTaskId
|
||||
}
|
||||
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.
|
||||
@@ -784,7 +802,7 @@ const file_state_v1_types_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"created_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" +
|
||||
"\n" +
|
||||
"updated_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\x91\r\n" +
|
||||
"updated_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\xef\r\n" +
|
||||
"\x04Task\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x03R\x02id\x12\x14\n" +
|
||||
"\x05owner\x18\x02 \x01(\tR\x05owner\x12\x12\n" +
|
||||
@@ -849,7 +867,9 @@ const file_state_v1_types_proto_rawDesc = "" +
|
||||
"\x11binding_signature\x18. \x01(\tR\x10bindingSignature\x12!\n" +
|
||||
"\fbinding_addr\x18/ \x01(\tR\vbindingAddr\x12!\n" +
|
||||
"\fpark_blocker\x180 \x01(\tR\vparkBlocker\x12#\n" +
|
||||
"\rplan_document\x182 \x01(\tR\fplanDocumentJ\x04\b1\x102R\tplan_view\"\xf8\x02\n" +
|
||||
"\rplan_document\x182 \x01(\tR\fplanDocument\x12/\n" +
|
||||
"\x14handoff_from_task_id\x183 \x01(\x03R\x11handoffFromTaskId\x12+\n" +
|
||||
"\x12handoff_to_task_id\x184 \x01(\x03R\x0fhandoffToTaskIdJ\x04\b1\x102R\tplan_view\"\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" +
|
||||
|
||||
@@ -1753,7 +1753,9 @@ func (d *Daemon) cleanupTerminalTaskWorktree(ctx context.Context, task *workflow
|
||||
d.Log.WarnContext(ctx, "terminal worktree cleanup task lookup failed", "task", task.ID, "err", err)
|
||||
return
|
||||
}
|
||||
if latest == nil {
|
||||
// A run that handed off shares its work item's worktree with its
|
||||
// successor, which owns it from here.
|
||||
if latest == nil || latest.HandoffToTaskID != 0 {
|
||||
return
|
||||
}
|
||||
// Settled statuses. Keep the worktree while a PR exists.
|
||||
|
||||
@@ -36,8 +36,8 @@ type handoffSettings struct {
|
||||
Detail string `yaml:"detail" doc:"Why the task was handed off."`
|
||||
}
|
||||
|
||||
// newHandoffStage requeues the task under another workflow: the same task,
|
||||
// not a child run, so its history stays in one place.
|
||||
// newHandoffStage completes the run and starts a linked run of another
|
||||
// workflow on the same work item.
|
||||
func newHandoffStage(settings yaml.Node) (Stage, error) {
|
||||
s, err := decodeSettings[handoffSettings](HandoffStepName, settings)
|
||||
if err != nil {
|
||||
@@ -47,8 +47,7 @@ func newHandoffStage(settings yaml.Node) (Stage, error) {
|
||||
return Stage{}, fmt.Errorf("%s: settings.workflow is required", HandoffStepName)
|
||||
}
|
||||
return Stage{Name: HandoffStepName, Run: func(_ context.Context, tc *TaskContext) error {
|
||||
tc.Task.Workflow = strings.TrimSpace(s.Workflow)
|
||||
tc.Outcome = Outcome{Status: StatusQueued, Detail: s.Detail}
|
||||
tc.Outcome = Outcome{Status: StatusCompleted, Detail: s.Detail, Handoff: strings.TrimSpace(s.Workflow)}
|
||||
return nil
|
||||
}}, nil
|
||||
}
|
||||
|
||||
@@ -16,4 +16,8 @@ type Caller interface {
|
||||
// call_parent_task_id is callerTaskID, so a caller reads only its own
|
||||
// callees.
|
||||
CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (status, detail string, outputs map[string]any, err error)
|
||||
// Handoff completes the running task fromTaskID with detail and starts
|
||||
// its linked successor on the same work item under workflow, returning
|
||||
// the successor.
|
||||
Handoff(ctx context.Context, fromTaskID int64, workflow, detail string) (*Task, error)
|
||||
}
|
||||
@@ -141,6 +141,10 @@ type Task struct {
|
||||
// one; 0 on a root run. A caller reads only the tasks it started,
|
||||
// through WorkflowCallStatus.
|
||||
CallParentTaskID int64 `json:"call_parent_task_id,omitempty"`
|
||||
// HandoffFromTaskID is the run whose workflow.handoff started this one,
|
||||
// and HandoffToTaskID the run this one handed off to; 0 when none.
|
||||
HandoffFromTaskID int64 `json:"handoff_from_task_id,omitempty"`
|
||||
HandoffToTaskID int64 `json:"handoff_to_task_id,omitempty"`
|
||||
// CallDepth counts workflow.call hops from the root run. The engine
|
||||
// refuses a call past workflow.MaxCallDepth, and the store re-checks on
|
||||
// insert, so no enqueue path can pass the limit.
|
||||
|
||||
@@ -279,6 +279,9 @@ func transcriptData(entry agentrun.TranscriptEntry) (map[string]any, error) {
|
||||
type Outcome struct {
|
||||
Status string // Status* value; empty = continue to next stage
|
||||
Detail string // park reason / close rationale / PR body context
|
||||
// Handoff names the workflow a linked successor run starts under once
|
||||
// this run completes; empty starts none.
|
||||
Handoff string
|
||||
}
|
||||
|
||||
// Stage is one named step. Returning an error parks the task with the
|
||||
@@ -507,6 +510,26 @@ func publishEvent(ctx context.Context, tc *TaskContext, e events.Event) {
|
||||
tc.Bus.Publish(ctx, e)
|
||||
}
|
||||
|
||||
// handoff completes the run and starts its linked successor in one store
|
||||
// write, so the work item keeps exactly one current run.
|
||||
func handoff(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
||||
if tc.Calls == nil {
|
||||
park(ctx, tc, "workflow.handoff: this runner cannot start a linked run")
|
||||
return
|
||||
}
|
||||
next, err := tc.Calls.Handoff(ctx, tc.Task.ID, tc.Outcome.Handoff, tc.Outcome.Detail)
|
||||
if err != nil {
|
||||
log.ErrorContext(ctx, "workflow handoff failed", "err", err)
|
||||
park(ctx, tc, fmt.Sprintf("workflow.handoff to %s: %v", tc.Outcome.Handoff, err))
|
||||
return
|
||||
}
|
||||
tc.Task.HandoffToTaskID = next.ID
|
||||
tc.Emit(ctx, events.KindOutcome, tc.Stage, tc.Outcome.Detail, map[string]any{
|
||||
"status": tc.Outcome.Status, "handoff_task_id": next.ID, "workflow": tc.Outcome.Handoff,
|
||||
})
|
||||
log.InfoContext(ctx, "workflow handed off", "workflow", tc.Outcome.Handoff, "task", next.ID)
|
||||
}
|
||||
|
||||
func finish(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
||||
t := tc.Task
|
||||
if tc.Outcome.Status == StatusParked {
|
||||
@@ -525,6 +548,10 @@ func finish(ctx context.Context, tc *TaskContext, log *slog.Logger) {
|
||||
park(ctx, tc, fmt.Sprintf("persist workflow outcome: %v", err))
|
||||
return
|
||||
}
|
||||
if tc.Outcome.Handoff != "" {
|
||||
handoff(ctx, tc, log)
|
||||
return
|
||||
}
|
||||
if err := tc.Store.Transition(ctx, t.ID, StatusRunning, tc.Outcome.Status, tc.Outcome.Detail); err != nil {
|
||||
log.ErrorContext(ctx, "workflow outcome transition failed", "err", err)
|
||||
return
|
||||
|
||||
@@ -37,6 +37,10 @@ func (c *callSpy) StartCall(_ context.Context, callerTaskID int64, callKey, _ st
|
||||
return child, nil
|
||||
}
|
||||
|
||||
func (c *callSpy) Handoff(context.Context, int64, string, string) (*task.Task, error) {
|
||||
return nil, errors.New("no handoff")
|
||||
}
|
||||
|
||||
func (c *callSpy) CallStatus(context.Context, int64, int64) (string, string, map[string]any, error) {
|
||||
return StatusCompleted, "", nil, nil
|
||||
}
|
||||
@@ -384,6 +388,10 @@ func (c *wobblyCaller) StartCall(_ context.Context, callerTaskID int64, _, _ str
|
||||
return &task.Task{ID: 42, CallParentTaskID: callerTaskID}, nil
|
||||
}
|
||||
|
||||
func (c *wobblyCaller) Handoff(context.Context, int64, string, string) (*task.Task, error) {
|
||||
return nil, errors.New("no handoff")
|
||||
}
|
||||
|
||||
func (c *wobblyCaller) CallStatus(context.Context, int64, int64) (string, string, map[string]any, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
@@ -193,6 +193,12 @@ func (d deadlineCaller) StartCall(ctx context.Context, callerTaskID int64, callK
|
||||
return d.Caller.StartCall(ctx, callerTaskID, callKey, wf, inputs)
|
||||
}
|
||||
|
||||
func (d deadlineCaller) Handoff(ctx context.Context, fromTaskID int64, wf, detail string) (*task.Task, error) {
|
||||
ctx, cancel := d.withDeadline(ctx)
|
||||
defer cancel()
|
||||
return d.Caller.Handoff(ctx, fromTaskID, wf, detail)
|
||||
}
|
||||
|
||||
func (d deadlineCaller) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, map[string]any, error) {
|
||||
ctx, cancel := d.withDeadline(ctx)
|
||||
defer cancel()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
-- A workflow.handoff ends its run and starts a linked run of the next workflow
|
||||
-- on the same work item. Only the current run of an item is unique; a run
|
||||
-- that handed off points at its successor and leaves the key.
|
||||
ALTER TABLE tasks
|
||||
ADD COLUMN handoff_from_task_id bigint REFERENCES tasks (id) ON DELETE SET NULL,
|
||||
ADD COLUMN handoff_to_task_id bigint;
|
||||
ALTER TABLE tasks DROP CONSTRAINT tasks_org_identity_owner_repo_number_key;
|
||||
CREATE UNIQUE INDEX tasks_current_item_key ON tasks (org_id, identity, owner, repo, issue_number)
|
||||
WHERE handoff_to_task_id IS NULL;
|
||||
|
||||
-- +goose Down
|
||||
DELETE FROM tasks WHERE handoff_to_task_id IS NOT NULL;
|
||||
DROP INDEX tasks_current_item_key;
|
||||
ALTER TABLE tasks ADD CONSTRAINT tasks_org_identity_owner_repo_number_key
|
||||
UNIQUE (org_id, identity, owner, repo, issue_number);
|
||||
ALTER TABLE tasks DROP COLUMN handoff_to_task_id, DROP COLUMN handoff_from_task_id;
|
||||
@@ -24,7 +24,7 @@ func (q *Queries) CallStatusDetail(ctx context.Context, taskID int64) (string, e
|
||||
|
||||
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.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, t.outputs, t.review_gate, t.rereview_rounds, t.retry_mode, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.binding_signature, t.binding_addr, t.park_blocker, t.outcome_posted_status, t.plan_document FROM tasks t WHERE t.id = $1 FOR UPDATE
|
||||
SELECT t.id, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, t.status, t.workflow, 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, t.outputs, t.review_gate, t.rereview_rounds, t.retry_mode, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.binding_signature, t.binding_addr, t.park_blocker, t.outcome_posted_status, t.plan_document, t.handoff_from_task_id, t.handoff_to_task_id FROM tasks t WHERE t.id = $1 FOR UPDATE
|
||||
), number AS (
|
||||
INSERT INTO chat_issue_numbers (owner, repo, last_number)
|
||||
SELECT caller.owner, caller.repo, $9::bigint + 1 FROM caller
|
||||
@@ -43,7 +43,7 @@ SELECT
|
||||
FROM caller, number
|
||||
WHERE caller.status = 'running' AND caller.call_depth + 1 <= $8::int
|
||||
ON CONFLICT (call_parent_task_id, call_key) WHERE call_key <> '' AND status NOT IN ('dead', 'closed_wont_do') DO UPDATE SET call_key = EXCLUDED.call_key
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||
`
|
||||
|
||||
type EnqueueCallTaskParams struct {
|
||||
@@ -137,6 +137,8 @@ func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -584,6 +584,8 @@ type Task struct {
|
||||
ParkBlocker string
|
||||
OutcomePostedStatus string
|
||||
PlanDocument string
|
||||
HandoffFromTaskID pgtype.Int8
|
||||
HandoffToTaskID pgtype.Int8
|
||||
}
|
||||
|
||||
type ToolCall struct {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
const activeTasksByOrigin = `-- name: ActiveTasksByOrigin :many
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks
|
||||
WHERE origin = $1 AND origin <> '' AND status IN ('queued', 'running') AND ($2::text IS NULL OR org_id = $2)
|
||||
ORDER BY id
|
||||
`
|
||||
@@ -85,6 +85,8 @@ func (q *Queries) ActiveTasksByOrigin(ctx context.Context, arg ActiveTasksByOrig
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -164,7 +166,7 @@ func (q *Queries) BeginRemediationTask(ctx context.Context, arg BeginRemediation
|
||||
const claimByIssue = `-- name: ClaimByIssue :one
|
||||
UPDATE tasks SET status = 'running', attempt = attempt + 1, outputs = '', 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, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||
`
|
||||
|
||||
type ClaimByIssueParams struct {
|
||||
@@ -230,6 +232,8 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -244,7 +248,7 @@ WHERE id = (
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
)
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||
`
|
||||
|
||||
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
||||
@@ -308,6 +312,8 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -367,7 +373,7 @@ VALUES (
|
||||
),
|
||||
'default'
|
||||
)
|
||||
ON CONFLICT (org_id, identity, owner, repo, issue_number) DO NOTHING
|
||||
ON CONFLICT (org_id, identity, owner, repo, issue_number) WHERE handoff_to_task_id IS NULL DO NOTHING
|
||||
`
|
||||
|
||||
type EnqueueIssueParams struct {
|
||||
@@ -427,7 +433,7 @@ FROM number, (SELECT COALESCE(
|
||||
'org-sys'
|
||||
) AS id) AS owner_org
|
||||
WHERE $11::text IS NULL OR owner_org.id = $11
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||
`
|
||||
|
||||
type InsertChatTaskParams struct {
|
||||
@@ -525,6 +531,88 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertHandoffTask = `-- name: InsertHandoffTask :one
|
||||
INSERT INTO tasks (id, owner, repo, issue_number, title, body, labels, workflow, source, identity,
|
||||
org_id, workspace_id, inputs, plan, plan_document, binding_id, binding_version, binding_signature,
|
||||
binding_addr, origin, call_parent_task_id, call_depth, handoff_from_task_id)
|
||||
SELECT $1, t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, $2, t.source, t.identity,
|
||||
t.org_id, t.workspace_id, t.inputs, t.plan, t.plan_document, t.binding_id, t.binding_version, t.binding_signature,
|
||||
t.binding_addr, t.origin, t.call_parent_task_id, t.call_depth, t.id
|
||||
FROM tasks t WHERE t.id = $3
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id
|
||||
`
|
||||
|
||||
type InsertHandoffTaskParams struct {
|
||||
SuccessorID int64
|
||||
Workflow string
|
||||
ID int64
|
||||
}
|
||||
|
||||
// The successor run carries the work item and the decisions made on it; its
|
||||
// run state (attempts, branch, outputs, review state) starts fresh.
|
||||
func (q *Queries) InsertHandoffTask(ctx context.Context, arg InsertHandoffTaskParams) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, insertHandoffTask, arg.SuccessorID, arg.Workflow, arg.ID)
|
||||
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.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,
|
||||
&i.Outputs,
|
||||
&i.ReviewGate,
|
||||
&i.RereviewRounds,
|
||||
&i.RetryMode,
|
||||
&i.ResumeFrom,
|
||||
&i.ResumeResults,
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.BindingSignature,
|
||||
&i.BindingAddr,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -609,7 +697,8 @@ const listTaskSummaries = `-- name: ListTaskSummaries :many
|
||||
SELECT id, owner, repo, issue_number, title, status, workflow,
|
||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||
created_at, updated_at, plan, plan_document, source, identity, binding_id, binding_version,
|
||||
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker
|
||||
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker,
|
||||
handoff_from_task_id, handoff_to_task_id
|
||||
FROM tasks
|
||||
WHERE ($1::text IS NULL OR org_id = $1)
|
||||
AND (cardinality($2::text[]) = 0 OR status = ANY($2::text[]))
|
||||
@@ -630,33 +719,35 @@ type ListTaskSummariesParams struct {
|
||||
}
|
||||
|
||||
type ListTaskSummariesRow struct {
|
||||
ID int64
|
||||
Owner string
|
||||
Repo string
|
||||
IssueNumber int64
|
||||
Title string
|
||||
Status string
|
||||
Workflow string
|
||||
PrNumber int64
|
||||
TokensUsed int64
|
||||
Iterations int64
|
||||
Attempt int64
|
||||
ParkReason string
|
||||
RetryCount int64
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Plan string
|
||||
PlanDocument string
|
||||
Source string
|
||||
Identity string
|
||||
BindingID string
|
||||
BindingVersion int64
|
||||
Outputs string
|
||||
ReviewGate string
|
||||
RereviewRounds int64
|
||||
OrgID string
|
||||
ParkClass string
|
||||
ParkBlocker string
|
||||
ID int64
|
||||
Owner string
|
||||
Repo string
|
||||
IssueNumber int64
|
||||
Title string
|
||||
Status string
|
||||
Workflow string
|
||||
PrNumber int64
|
||||
TokensUsed int64
|
||||
Iterations int64
|
||||
Attempt int64
|
||||
ParkReason string
|
||||
RetryCount int64
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Plan string
|
||||
PlanDocument string
|
||||
Source string
|
||||
Identity string
|
||||
BindingID string
|
||||
BindingVersion int64
|
||||
Outputs string
|
||||
ReviewGate string
|
||||
RereviewRounds int64
|
||||
OrgID string
|
||||
ParkClass string
|
||||
ParkBlocker string
|
||||
HandoffFromTaskID pgtype.Int8
|
||||
HandoffToTaskID pgtype.Int8
|
||||
}
|
||||
|
||||
// The dashboard's list. This projection is deliberately narrow: Plan gates
|
||||
@@ -712,6 +803,8 @@ func (q *Queries) ListTaskSummaries(ctx context.Context, arg ListTaskSummariesPa
|
||||
&i.OrgID,
|
||||
&i.ParkClass,
|
||||
&i.ParkBlocker,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -763,6 +856,25 @@ func (q *Queries) LockTaskStatus(ctx context.Context, id int64) (string, error)
|
||||
return status, err
|
||||
}
|
||||
|
||||
const markHandedOff = `-- name: MarkHandedOff :execrows
|
||||
UPDATE tasks SET handoff_to_task_id = $1, updated_at = now()
|
||||
WHERE id = $2 AND handoff_to_task_id IS NULL
|
||||
`
|
||||
|
||||
type MarkHandedOffParams struct {
|
||||
SuccessorID pgtype.Int8
|
||||
ID int64
|
||||
}
|
||||
|
||||
// The run leaves the item's unique key before its successor takes it.
|
||||
func (q *Queries) MarkHandedOff(ctx context.Context, arg MarkHandedOffParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, markHandedOff, arg.SuccessorID, arg.ID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const markOutcomePosted = `-- name: MarkOutcomePosted :exec
|
||||
UPDATE tasks SET outcome_posted_status = COALESCE(NULLIF($1::text, ''), status) WHERE id = $2
|
||||
`
|
||||
@@ -780,6 +892,17 @@ func (q *Queries) MarkOutcomePosted(ctx context.Context, arg MarkOutcomePostedPa
|
||||
return err
|
||||
}
|
||||
|
||||
const nextTaskID = `-- name: NextTaskID :one
|
||||
SELECT nextval(pg_get_serial_sequence('tasks', 'id'))::bigint
|
||||
`
|
||||
|
||||
func (q *Queries) NextTaskID(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, nextTaskID)
|
||||
var column_1 int64
|
||||
err := row.Scan(&column_1)
|
||||
return column_1, err
|
||||
}
|
||||
|
||||
const parkTask = `-- name: ParkTask :execrows
|
||||
UPDATE tasks
|
||||
SET status = 'parked', park_reason = $2, park_class = $3, park_blocker = $5, updated_at = now()
|
||||
@@ -1014,7 +1137,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, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||
`
|
||||
|
||||
type TaskByIDParams struct {
|
||||
@@ -1077,12 +1200,14 @@ func (q *Queries) TaskByID(ctx context.Context, arg TaskByIDParams) (Task, error
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const taskByIssue = `-- name: TaskByIssue :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3 AND handoff_to_task_id IS NULL
|
||||
AND ($4::text IS NULL OR org_id = $4)
|
||||
`
|
||||
|
||||
@@ -1153,12 +1278,14 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task,
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const taskByPR = `-- name: TaskByPR :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document 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, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
|
||||
AND ($5::text IS NULL OR org_id = $5)
|
||||
`
|
||||
|
||||
@@ -1234,6 +1361,8 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -1273,9 +1402,10 @@ func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams)
|
||||
}
|
||||
|
||||
const unpostedOutcomes = `-- name: UnpostedOutcomes :many
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document FROM tasks
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, 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, outputs, review_gate, rereview_rounds, retry_mode, resume_from, resume_results, pending_reviews, origin, call_key, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_document, handoff_from_task_id, handoff_to_task_id FROM tasks
|
||||
WHERE origin <> '' AND outcome_posted_status <> status
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||
AND handoff_to_task_id IS NULL
|
||||
AND ($1::text IS NULL OR org_id = $1)
|
||||
ORDER BY id
|
||||
LIMIT 50
|
||||
@@ -1344,6 +1474,8 @@ func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([
|
||||
&i.ParkBlocker,
|
||||
&i.OutcomePostedStatus,
|
||||
&i.PlanDocument,
|
||||
&i.HandoffFromTaskID,
|
||||
&i.HandoffToTaskID,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ RETURNING *;
|
||||
SELECT * FROM tasks WHERE id = sqlc.arg(id) AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||
|
||||
-- name: TaskByIssue :one
|
||||
SELECT * FROM tasks WHERE owner = sqlc.arg(owner) AND repo = sqlc.arg(repo) AND issue_number = sqlc.arg(issue_number)
|
||||
SELECT * FROM tasks WHERE owner = sqlc.arg(owner) AND repo = sqlc.arg(repo) AND issue_number = sqlc.arg(issue_number) AND handoff_to_task_id IS NULL
|
||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||
|
||||
-- name: TaskByPR :one
|
||||
@@ -43,7 +43,8 @@ SELECT * FROM tasks WHERE owner = sqlc.arg(owner) AND repo = sqlc.arg(repo) AND
|
||||
SELECT id, owner, repo, issue_number, title, status, workflow,
|
||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||
created_at, updated_at, plan, plan_document, source, identity, binding_id, binding_version,
|
||||
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker
|
||||
outputs, review_gate, rereview_rounds, org_id, park_class, park_blocker,
|
||||
handoff_from_task_id, handoff_to_task_id
|
||||
FROM tasks
|
||||
WHERE (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
AND (cardinality(@statuses::text[]) = 0 OR status = ANY(@statuses::text[]))
|
||||
@@ -109,6 +110,7 @@ ORDER BY id;
|
||||
SELECT * FROM tasks
|
||||
WHERE origin <> '' AND outcome_posted_status <> status
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
|
||||
AND handoff_to_task_id IS NULL
|
||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
ORDER BY id
|
||||
LIMIT 50;
|
||||
@@ -199,7 +201,7 @@ VALUES (
|
||||
),
|
||||
'default'
|
||||
)
|
||||
ON CONFLICT (org_id, identity, owner, repo, issue_number) DO NOTHING;
|
||||
ON CONFLICT (org_id, identity, owner, repo, issue_number) WHERE handoff_to_task_id IS NULL DO NOTHING;
|
||||
|
||||
-- name: ClaimByIssue :one
|
||||
-- The claim starts the attempt's output set empty, as ClaimNextTask does:
|
||||
@@ -291,3 +293,23 @@ DELETE FROM tasks WHERE id = $1 AND status = $2;
|
||||
-- name: ListOpenPRs :many
|
||||
SELECT id, owner, repo, issue_number, pr_number, status, source, identity, attempt, review_cursor, watch_comment_id, outputs
|
||||
FROM tasks WHERE status = 'pr_open' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org));
|
||||
|
||||
-- name: NextTaskID :one
|
||||
SELECT nextval(pg_get_serial_sequence('tasks', 'id'))::bigint;
|
||||
|
||||
-- name: MarkHandedOff :execrows
|
||||
-- The run leaves the item's unique key before its successor takes it.
|
||||
UPDATE tasks SET handoff_to_task_id = sqlc.arg(successor_id), updated_at = now()
|
||||
WHERE id = sqlc.arg(id) AND handoff_to_task_id IS NULL;
|
||||
|
||||
-- name: InsertHandoffTask :one
|
||||
-- The successor run carries the work item and the decisions made on it; its
|
||||
-- run state (attempts, branch, outputs, review state) starts fresh.
|
||||
INSERT INTO tasks (id, owner, repo, issue_number, title, body, labels, workflow, source, identity,
|
||||
org_id, workspace_id, inputs, plan, plan_document, binding_id, binding_version, binding_signature,
|
||||
binding_addr, origin, call_parent_task_id, call_depth, handoff_from_task_id)
|
||||
SELECT sqlc.arg(successor_id), t.owner, t.repo, t.issue_number, t.title, t.body, t.labels, sqlc.arg(workflow), t.source, t.identity,
|
||||
t.org_id, t.workspace_id, t.inputs, t.plan, t.plan_document, t.binding_id, t.binding_version, t.binding_signature,
|
||||
t.binding_addr, t.origin, t.call_parent_task_id, t.call_depth, t.id
|
||||
FROM tasks t WHERE t.id = sqlc.arg(id)
|
||||
RETURNING *;
|
||||
@@ -124,6 +124,8 @@ func taskFromRow(t postgresdb.Task) *workflow.Task {
|
||||
ParkBlocker: t.ParkBlocker,
|
||||
RemediationRounds: int(t.RemediationRounds),
|
||||
CallParentTaskID: t.CallParentTaskID,
|
||||
HandoffFromTaskID: t.HandoffFromTaskID.Int64,
|
||||
HandoffToTaskID: t.HandoffToTaskID.Int64,
|
||||
CallDepth: int(t.CallDepth),
|
||||
Origin: t.Origin,
|
||||
CreatedAt: t.CreatedAt,
|
||||
@@ -790,6 +792,7 @@ func (s *Store) TasksPage(ctx context.Context, page storecontract.TaskPage) ([]w
|
||||
Outputs: outputs,
|
||||
ReviewGate: r.ReviewGate, RereviewRounds: int(r.RereviewRounds),
|
||||
Org: org.OrgID(r.OrgID), ParkClass: r.ParkClass, ParkBlocker: r.ParkBlocker,
|
||||
HandoffFromTaskID: r.HandoffFromTaskID.Int64, HandoffToTaskID: r.HandoffToTaskID.Int64,
|
||||
})
|
||||
}
|
||||
return tasks, nil
|
||||
@@ -886,6 +889,58 @@ func (s *Store) StartCall(ctx context.Context, callerTaskID int64, callKey, wf s
|
||||
return taskFromRow(callee), nil
|
||||
}
|
||||
|
||||
// Handoff completes the running task fromTaskID and starts its linked
|
||||
// successor on the same work item under wf, in one transaction: the item is
|
||||
// never without a current run, and never has two.
|
||||
func (s *Store) Handoff(ctx context.Context, fromTaskID int64, wf, detail string) (*workflow.Task, error) {
|
||||
tx, err := s.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { _ = tx.Rollback(ctx) }()
|
||||
q := postgresdb.New(tx)
|
||||
from, to := workflow.StatusRunning, workflow.StatusCompleted
|
||||
if err := guardTransition(ctx, q, fromTaskID, from, to); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n, err := q.TransitionTask(ctx, postgresdb.TransitionTaskParams{
|
||||
ID: fromTaskID, Status: to, ParkClass: taskstate.ParkNeedsDecision, Status_2: from,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if n == 0 {
|
||||
return nil, storecontract.ErrStaleTransition
|
||||
}
|
||||
if err := recordTransition(ctx, q, postgresdb.InsertTransitionParams{
|
||||
TaskID: fromTaskID, FromStatus: from, ToStatus: to, Detail: clip(detail, 4000),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
successor, err := q.NextTaskID(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if n, err := q.MarkHandedOff(ctx, postgresdb.MarkHandedOffParams{ID: fromTaskID, SuccessorID: pgtype.Int8{Int64: successor, Valid: true}}); err != nil {
|
||||
return nil, err
|
||||
} else if n == 0 {
|
||||
return nil, fmt.Errorf("store: task %d already handed off: %w", fromTaskID, storecontract.ErrStaleTransition)
|
||||
}
|
||||
row, err := q.InsertHandoffTask(ctx, postgresdb.InsertHandoffTaskParams{ID: fromTaskID, SuccessorID: successor, Workflow: wf})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := recordTransition(ctx, q, postgresdb.InsertTransitionParams{
|
||||
TaskID: row.ID, FromStatus: "", ToStatus: workflow.StatusQueued, Detail: fmt.Sprintf("handed off from task %d", fromTaskID),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return taskFromRow(row), nil
|
||||
}
|
||||
|
||||
// callerIdentity is the identity the caller's pinned workflow declares, the
|
||||
// one its callees are started by. The pin does not change while the caller's
|
||||
// call step runs.
|
||||
|
||||
@@ -149,6 +149,13 @@ var taskScopedTargets = map[string]func(any) int64{
|
||||
}
|
||||
return r.CallerTaskId
|
||||
},
|
||||
pb.TaskService_HandoffTask_FullMethodName: func(req any) int64 {
|
||||
r, ok := req.(*pb.HandoffTaskRequest)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return r.TaskId
|
||||
},
|
||||
pb.TaskService_WorkflowCallStatus_FullMethodName: func(req any) int64 {
|
||||
r, ok := req.(*pb.WorkflowCallStatusRequest)
|
||||
if !ok {
|
||||
|
||||
@@ -267,6 +267,20 @@ func (s *taskServer) EnqueueCallTask(ctx context.Context, r *pb.EnqueueCallTaskR
|
||||
return &pb.EnqueueCallTaskResponse{Task: taskProto(t), Accepted: true}, nil
|
||||
}
|
||||
|
||||
func (s *taskServer) HandoffTask(ctx context.Context, r *pb.HandoffTaskRequest) (*pb.HandoffTaskResponse, error) {
|
||||
if s.deps.WorkflowCalls == nil {
|
||||
return nil, errWorkflowCallerUnavailable
|
||||
}
|
||||
if r.TaskId <= 0 || r.Workflow == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "task id and workflow are required")
|
||||
}
|
||||
t, err := s.deps.WorkflowCalls.Handoff(ctx, r.TaskId, r.Workflow, r.Detail)
|
||||
if err != nil {
|
||||
return nil, s.logErr("HandoffTask", err)
|
||||
}
|
||||
return &pb.HandoffTaskResponse{Task: taskProto(t)}, nil
|
||||
}
|
||||
|
||||
func (s *taskServer) WorkflowCallStatus(ctx context.Context, r *pb.WorkflowCallStatusRequest) (*pb.WorkflowCallStatusResponse, error) {
|
||||
if s.deps.WorkflowCalls == nil {
|
||||
return nil, errWorkflowCallerUnavailable
|
||||
@@ -485,6 +499,14 @@ func (c *Client) StartCall(ctx context.Context, callerTaskID int64, callKey, wf
|
||||
return taskValue(r.Task), nil
|
||||
}
|
||||
|
||||
func (c *Client) Handoff(ctx context.Context, fromTaskID int64, wf, detail string) (*task.Task, error) {
|
||||
r, err := c.task.HandoffTask(ctx, &pb.HandoffTaskRequest{TaskId: fromTaskID, Workflow: wf, Detail: detail})
|
||||
if err != nil {
|
||||
return nil, unmapError(err)
|
||||
}
|
||||
return taskValue(r.Task), nil
|
||||
}
|
||||
|
||||
func (c *Client) CallStatus(ctx context.Context, callerTaskID, callTaskID int64) (string, string, map[string]any, error) {
|
||||
r, err := c.task.WorkflowCallStatus(ctx, &pb.WorkflowCallStatusRequest{CallerTaskId: callerTaskID, CallTaskId: callTaskID})
|
||||
if err != nil {
|
||||
|
||||
@@ -85,6 +85,8 @@ func taskProto(t *task.Task) *pb.Task { // mirror-image field-by-field proto<->d
|
||||
Org: string(t.Org),
|
||||
Workspace: string(t.Workspace),
|
||||
CallParentTaskId: t.CallParentTaskID,
|
||||
HandoffFromTaskId: t.HandoffFromTaskID,
|
||||
HandoffToTaskId: t.HandoffToTaskID,
|
||||
CallDepth: int32(t.CallDepth),
|
||||
Origin: t.Origin,
|
||||
BindingSignature: t.BindingSignature,
|
||||
@@ -122,6 +124,8 @@ func taskValue(t *pb.Task) *task.Task { // see taskProto above
|
||||
Org: org.OrgID(t.Org),
|
||||
Workspace: org.WorkspaceID(t.Workspace),
|
||||
CallParentTaskID: t.CallParentTaskId,
|
||||
HandoffFromTaskID: t.HandoffFromTaskId,
|
||||
HandoffToTaskID: t.HandoffToTaskId,
|
||||
CallDepth: int(t.CallDepth),
|
||||
Origin: t.Origin,
|
||||
BindingSignature: t.BindingSignature,
|
||||
|
||||
@@ -39,6 +39,10 @@ type taskAttemptsView struct {
|
||||
Inputs map[string]any `json:"inputs,omitempty"`
|
||||
Outputs map[string]any `json:"outputs,omitempty"`
|
||||
CalledBy int64 `json:"called_by,omitempty"`
|
||||
// HandedOffFrom and HandedOffTo are the linked runs of the same work
|
||||
// item before and after this one.
|
||||
HandedOffFrom int64 `json:"handed_off_from,omitempty"`
|
||||
HandedOffTo int64 `json:"handed_off_to,omitempty"`
|
||||
// Recovery links a parked task to the page that fixes its blocker,
|
||||
// present only when the viewer may act there.
|
||||
Recovery *taskRecoveryView `json:"recovery,omitempty"`
|
||||
@@ -117,6 +121,8 @@ func (a *tasksAPI) handleTaskAttempts(w http.ResponseWriter, r *http.Request) {
|
||||
Inputs: t.Inputs,
|
||||
Outputs: t.Outputs,
|
||||
CalledBy: t.CallParentTaskID,
|
||||
HandedOffFrom: t.HandoffFromTaskID,
|
||||
HandedOffTo: t.HandoffToTaskID,
|
||||
Recovery: a.recovery(r, t),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ service TaskService {
|
||||
// (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);
|
||||
// HandoffTask completes a running run and starts its linked successor on
|
||||
// the same work item under another workflow.
|
||||
rpc HandoffTask(HandoffTaskRequest) returns (HandoffTaskResponse);
|
||||
rpc WorkflowCallStatus(WorkflowCallStatusRequest) returns (WorkflowCallStatusResponse);
|
||||
}
|
||||
|
||||
@@ -196,6 +199,12 @@ message EnqueueCallTaskRequest {
|
||||
// cannot duplicate the child's work.
|
||||
string call_key = 4;
|
||||
}
|
||||
message HandoffTaskRequest {
|
||||
int64 task_id = 1;
|
||||
string workflow = 2;
|
||||
string detail = 3;
|
||||
}
|
||||
message HandoffTaskResponse { Task task = 1; }
|
||||
message EnqueueCallTaskResponse {
|
||||
Task task = 1;
|
||||
bool accepted = 2;
|
||||
|
||||
@@ -128,6 +128,10 @@ message Task {
|
||||
reserved "plan_view";
|
||||
// plan_document is the structured plan (JSON) plan was rendered from.
|
||||
string plan_document = 50;
|
||||
// handoff_from_task_id is the run that handed off to this one; 0 when none.
|
||||
int64 handoff_from_task_id = 51;
|
||||
// handoff_to_task_id is the run this one handed off to; 0 when none.
|
||||
int64 handoff_to_task_id = 52;
|
||||
}
|
||||
// Event mirrors internal/events.Event. Data is carried as a JSON object
|
||||
// string (matching the store's own on-disk representation) rather than
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface DashboardTask {
|
||||
owner?: string;
|
||||
repo?: string;
|
||||
issue_number?: number;
|
||||
handoff_to_task_id?: number;
|
||||
}
|
||||
|
||||
export function taskIDForEvent(event: ActivityEvent, bySource: Map<string, number>): number {
|
||||
@@ -58,7 +59,8 @@ export const useTasksStore = defineStore("tasks", () => {
|
||||
]);
|
||||
const map = new Map<string, number>();
|
||||
for (const task of nextTasks) {
|
||||
if (task.owner && task.repo && task.issue_number)
|
||||
// A run that handed off yields its work item to its successor.
|
||||
if (task.owner && task.repo && task.issue_number && !task.handoff_to_task_id)
|
||||
map.set(`${task.owner}/${task.repo}#${task.issue_number}`, Number(task.id));
|
||||
}
|
||||
taskIDsBySource.value = map;
|
||||
|
||||
@@ -164,7 +164,19 @@ const headerActions = computed(() =>
|
||||
<p class="whitespace-pre-wrap break-words text-sm text-fg-muted">{{ description }}</p>
|
||||
</Section>
|
||||
|
||||
<div v-if="sections.length || run.attempts?.called_by" class="mt-3 flex flex-wrap items-start gap-3">
|
||||
<div v-if="sections.length || run.attempts?.called_by || run.attempts?.handed_off_from || run.attempts?.handed_off_to" class="mt-3 flex flex-wrap items-start gap-3">
|
||||
<p v-if="run.attempts?.handed_off_from" class="text-xs text-fg-subtle">
|
||||
Continues
|
||||
<RouterLink :to="`/tasks/${run.attempts.handed_off_from}`" class="font-mono text-fg-muted hover:text-foreground hover:underline"
|
||||
>task #{{ run.attempts.handed_off_from }}</RouterLink
|
||||
>
|
||||
</p>
|
||||
<p v-if="run.attempts?.handed_off_to" class="text-xs text-fg-subtle">
|
||||
Handed off to
|
||||
<RouterLink :to="`/tasks/${run.attempts.handed_off_to}`" class="font-mono text-fg-muted hover:text-foreground hover:underline"
|
||||
>task #{{ run.attempts.handed_off_to }}</RouterLink
|
||||
>
|
||||
</p>
|
||||
<p v-if="run.attempts?.called_by" class="text-xs text-fg-subtle">
|
||||
Called by
|
||||
<RouterLink :to="`/tasks/${run.attempts.called_by}`" class="font-mono text-fg-muted hover:text-foreground hover:underline"
|
||||
|
||||
@@ -96,6 +96,9 @@ export interface AttemptsState {
|
||||
outputs?: Record<string, unknown>;
|
||||
/** The task whose workflow.call started this one. */
|
||||
called_by?: number;
|
||||
/** The linked runs of the same work item before and after this one. */
|
||||
handed_off_from?: number;
|
||||
handed_off_to?: number;
|
||||
/** The page that fixes a parked task's blocker, when the viewer may act there. */
|
||||
recovery?: { blocker: string; label: string; link: string };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user