feat(pr-review): operator/chat trigger queues a pr-review task
review_pr self-omitted since d73e0748 deleted the synchronous reviewer it
called. It is rebuilt on the task enqueue path everything else uses: the
tool resolves the identity's configured repo, then queues a pr-review task
naming the pull request through the workflow's declared pr_number input,
which is the same generic input mechanism a watched-repos binding uses.
That input has to reach the store with the task, so
EnqueueChatTaskRequest gains inputs_json and the tasks insert writes the
inputs column directly. StampTaskBinding no longer writes it: the insert is
now the column's only writer, and a chat task must not acquire binding
provenance just to carry an input.
ChatPRReviewer, its result shape and the reviewer wiring are deleted with
the path they served.
This commit is contained in:
39 files changed
+227
-192
No files matched your search
@@ -355,7 +355,7 @@ func TestStateStoreRealProcessSmoke(t *testing.T) {
|
|||||||
// Combined task/event/capture view: a task, an event on that task, and an
|
// Combined task/event/capture view: a task, an event on that task, and an
|
||||||
// unrelated capture written through one consumer, read back across all
|
// unrelated capture written through one consumer, read back across all
|
||||||
// three surfaces in a single pass (the dashboard/observability read path).
|
// three surfaces in a single pass (the dashboard/observability read path).
|
||||||
task, err := cl.EnqueueChatTask(ctx, "acme", "widget", "verify state store", "body", "implement", "")
|
task, err := cl.EnqueueChatTask(ctx, "acme", "widget", "verify state store", "body", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("EnqueueChatTask = %+v, %v", task, err)
|
t.Fatalf("EnqueueChatTask = %+v, %v", task, err)
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ func TestStateStoreRealProcessRestartRecovery(t *testing.T) {
|
|||||||
|
|
||||||
first := startStateStoreProcess(t, bin, cfg)
|
first := startStateStoreProcess(t, bin, cfg)
|
||||||
s1 := dial(t, first.addr)
|
s1 := dial(t, first.addr)
|
||||||
task, err := s1.EnqueueChatTask(t.Context(), "acme", "widget", "survive restart", "body", "implement", "")
|
task, err := s1.EnqueueChatTask(t.Context(), "acme", "widget", "survive restart", "body", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("first EnqueueChatTask = %+v, %v", task, err)
|
t.Fatalf("first EnqueueChatTask = %+v, %v", task, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func recoveryFixture(t *testing.T) (string, *pgstore.TaskDB) {
|
|||||||
// seedTask writes one task so the database holds more than its settings.
|
// seedTask writes one task so the database holds more than its settings.
|
||||||
func seedTask(t *testing.T, st *pgstore.TaskDB, title string) {
|
func seedTask(t *testing.T, st *pgstore.TaskDB, title string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if _, err := st.EnqueueChatTask(t.Context(), "acme", "widget", title, "body", "implement", ""); err != nil {
|
if _, err := st.EnqueueChatTask(t.Context(), "acme", "widget", title, "body", "implement", "", nil); err != nil {
|
||||||
t.Fatalf("seed task %q: %v", title, err)
|
t.Fatalf("seed task %q: %v", title, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func TestExecuteTaskRequestStartsWorkflowCallCallee(t *testing.T) {
|
|||||||
const callerYAML = "id: caller\nrepository: none\ninputs:\n src_ip: {type: string}\nsteps:\n - type: workflow.call\n settings:\n workflow: callee\n inputs: {src_ip: \"inputs.src_ip\"}\n wait: false\n - type: agent.run\n settings:\n mission: report\n"
|
const callerYAML = "id: caller\nrepository: none\ninputs:\n src_ip: {type: string}\nsteps:\n - type: workflow.call\n settings:\n workflow: callee\n inputs: {src_ip: \"inputs.src_ip\"}\n wait: false\n - type: agent.run\n settings:\n mission: report\n"
|
||||||
// A real caller row, claimed and running, so the store's enqueue reads
|
// A real caller row, claimed and running, so the store's enqueue reads
|
||||||
// the same row shape production does.
|
// the same row shape production does.
|
||||||
task, err := st.EnqueueChatTask(ctx, "", "", "workflow.call integration", "", "caller", "")
|
task, err := st.EnqueueChatTask(ctx, "", "", "workflow.call integration", "", "caller", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("seed caller task: %v", err)
|
t.Fatalf("seed caller task: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ type chatSetup struct {
|
|||||||
ChatTaskLister gateway.ChatTaskLister
|
ChatTaskLister gateway.ChatTaskLister
|
||||||
ChatTaskLogs gateway.ChatTaskLogReader
|
ChatTaskLogs gateway.ChatTaskLogReader
|
||||||
ChatTaskActor gateway.ChatTaskActor
|
ChatTaskActor gateway.ChatTaskActor
|
||||||
ChatPRReviewer gateway.ChatPRReviewer
|
|
||||||
DefaultChatIdentity string
|
DefaultChatIdentity string
|
||||||
// Bus carries primary-input events (archie-core-035): a completed
|
// Bus carries primary-input events (archie-core-035): a completed
|
||||||
// chat turn is published here so input-driven curators can wake. Nil
|
// chat turn is published here so input-driven curators can wake. Nil
|
||||||
@@ -182,7 +181,6 @@ func newChatTurnRunner(
|
|||||||
TaskLogs: s.ChatTaskLogs,
|
TaskLogs: s.ChatTaskLogs,
|
||||||
TaskActor: s.ChatTaskActor,
|
TaskActor: s.ChatTaskActor,
|
||||||
TaskIdentity: s.DefaultChatIdentity,
|
TaskIdentity: s.DefaultChatIdentity,
|
||||||
PRReviewer: s.ChatPRReviewer,
|
|
||||||
Bus: s.Bus,
|
Bus: s.Bus,
|
||||||
BotUser: cfg.BotUser,
|
BotUser: cfg.BotUser,
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
|
|||||||
@@ -126,16 +126,9 @@ func (b *boot) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskActor
|
|||||||
setup := chatSetup{
|
setup := chatSetup{
|
||||||
Cfg: config.NewHolder(cfg), LLM: b.chatLLM, ChatModels: b.chatModels, ToolReg: b.toolReg,
|
Cfg: config.NewHolder(cfg), LLM: b.chatLLM, ChatModels: b.chatModels, ToolReg: b.toolReg,
|
||||||
Personas: b.personas, ChatTasks: b.chatTasks,
|
Personas: b.personas, ChatTasks: b.chatTasks,
|
||||||
ChatTaskLister: chatTaskListerAdapter{tasks: b.stateStore.Tasks},
|
ChatTaskLister: chatTaskListerAdapter{tasks: b.stateStore.Tasks},
|
||||||
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.taskLogs},
|
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.taskLogs},
|
||||||
// ChatPRReviewer is nil for now: the synchronous operator-review
|
ChatTaskActor: actor,
|
||||||
// implementation (prReviewer) was removed with the adversarial
|
|
||||||
// self-review system it depended on (archie-core-afbk.7). The
|
|
||||||
// review_pr chat tool self-omits when its reviewer is nil, so the
|
|
||||||
// dashboard/chat simply stops advertising the capability until the
|
|
||||||
// operator trigger is rebuilt to enqueue an async pr-review task
|
|
||||||
// instead (tracked in that bead's continuation).
|
|
||||||
ChatTaskActor: actor, ChatPRReviewer: nil,
|
|
||||||
DefaultChatIdentity: b.defaultChatIdentity,
|
DefaultChatIdentity: b.defaultChatIdentity,
|
||||||
Bus: b.bus, Log: b.log,
|
Bus: b.bus, Log: b.log,
|
||||||
MemoryEngine: b.memoryStore(),
|
MemoryEngine: b.memoryStore(),
|
||||||
|
|||||||
@@ -539,14 +539,16 @@ type chatTaskWriterAdapter struct {
|
|||||||
enqueue func(
|
enqueue func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
owner, repo, title, body, workflow, identity string,
|
owner, repo, title, body, workflow, identity string,
|
||||||
|
inputs map[string]any,
|
||||||
) (*workflow.Task, error)
|
) (*workflow.Task, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a chatTaskWriterAdapter) EnqueueChatTask(
|
func (a chatTaskWriterAdapter) EnqueueChatTask(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
owner, repo, title, body, workflow, identity string,
|
owner, repo, title, body, workflow, identity string,
|
||||||
|
inputs map[string]any,
|
||||||
) (int64, error) {
|
) (int64, error) {
|
||||||
task, err := a.enqueue(ctx, owner, repo, title, body, workflow, identity)
|
task, err := a.enqueue(ctx, owner, repo, title, body, workflow, identity, inputs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ func TestManualRequeueTaskRejectsOtherStatuses(t *testing.T) {
|
|||||||
func TestChatTaskListerAdapterReadsSQLiteIdentity(t *testing.T) {
|
func TestChatTaskListerAdapterReadsSQLiteIdentity(t *testing.T) {
|
||||||
st := pgstore.Open(t)
|
st := pgstore.Open(t)
|
||||||
t.Cleanup(func() { _ = st.Close() })
|
t.Cleanup(func() { _ = st.Close() })
|
||||||
want, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "identity task", "", "tdd", "reviewer")
|
want, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "identity task", "", "tdd", "reviewer", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -610,13 +610,14 @@ func TestChatTaskWriterAdapter(t *testing.T) {
|
|||||||
enqueue: func(
|
enqueue: func(
|
||||||
context.Context,
|
context.Context,
|
||||||
string, string, string, string, string, string,
|
string, string, string, string, string, string,
|
||||||
|
map[string]any,
|
||||||
) (*workflow.Task, error) {
|
) (*workflow.Task, error) {
|
||||||
return tt.result, tt.err
|
return tt.result, tt.err
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
id, err := adapter.EnqueueChatTask(
|
id, err := adapter.EnqueueChatTask(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
"owner", "repo", "title", "body", "workflow", "identity",
|
"owner", "repo", "title", "body", "workflow", "identity", nil,
|
||||||
)
|
)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Fatalf("EnqueueChatTask() error = %v, wantErr %t", err, tt.wantErr)
|
t.Fatalf("EnqueueChatTask() error = %v, wantErr %t", err, tt.wantErr)
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ func TestStateStoreDataSurvivesRestart(t *testing.T) {
|
|||||||
if err := first.openStateStore(t.Context()); err != nil {
|
if err := first.openStateStore(t.Context()); err != nil {
|
||||||
t.Fatalf("first openStateStore: %v", err)
|
t.Fatalf("first openStateStore: %v", err)
|
||||||
}
|
}
|
||||||
task, err := first.st.EnqueueChatTask(t.Context(), "acme", "widget", "restart check", "body", "implement", "")
|
task, err := first.st.EnqueueChatTask(t.Context(), "acme", "widget", "restart check", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("EnqueueChatTask: %v", err)
|
t.Fatalf("EnqueueChatTask: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func TestChatTaskActorAdapterCrossIdentityRefused(t *testing.T) {
|
|||||||
st := pgstore.Open(t)
|
st := pgstore.Open(t)
|
||||||
t.Cleanup(func() { _ = st.Close() })
|
t.Cleanup(func() { _ = st.Close() })
|
||||||
|
|
||||||
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "parked job", "", "", "identity-owner")
|
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "parked job", "", "", "identity-owner", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ func TestChatTaskActorAdapterRefusesDisallowedStateAction(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "test task", "", "", "archie")
|
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "test task", "", "", "archie", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ func TestChatTaskActorAdapterAppliesActionsToStore(t *testing.T) {
|
|||||||
|
|
||||||
adapter := newChatTaskActorForTest(t, st, config.Config{MaxRetries: 3})
|
adapter := newChatTaskActorForTest(t, st, config.Config{MaxRetries: 3})
|
||||||
|
|
||||||
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "actionable task", "", "", "archie")
|
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "actionable task", "", "", "archie", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func TestDashboardAndChatAgreeOnTerminalStates(t *testing.T) {
|
|||||||
st := pgstore.Open(t)
|
st := pgstore.Open(t)
|
||||||
t.Cleanup(func() { _ = st.Close() })
|
t.Cleanup(func() { _ = st.Close() })
|
||||||
|
|
||||||
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "decide on me", "", "", "reviewer")
|
task, err := st.EnqueueChatTask(ctx, "acme", "widget", "decide on me", "", "", "reviewer", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ func composeUIProcess(t *testing.T) (*webui.Server, int64) {
|
|||||||
}
|
}
|
||||||
t.Cleanup(closeClient)
|
t.Cleanup(closeClient)
|
||||||
|
|
||||||
task, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "a task", "body", "implement", "")
|
task, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "a task", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("seed task: %v", err)
|
t.Fatalf("seed task: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ func serveGRPC(t *testing.T, register func(grpc.ServiceRegistrar)) (target strin
|
|||||||
func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
func TestUIServesDashboardAgainstRemoteContracts(t *testing.T) {
|
||||||
st := pgstore.Open(t)
|
st := pgstore.Open(t)
|
||||||
defer st.Close()
|
defer st.Close()
|
||||||
if _, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "remote summary", "body", "implement", ""); err != nil {
|
if _, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "remote summary", "body", "implement", "", nil); err != nil {
|
||||||
t.Fatalf("seed task: %v", err)
|
t.Fatalf("seed task: %v", err)
|
||||||
}
|
}
|
||||||
// Claimed (not just enqueued): StartStep guards on the execution's own
|
// Claimed (not just enqueued): StartStep guards on the execution's own
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ func composeUIProcessWithLog(t *testing.T) (*webui.Server, int64, int) {
|
|||||||
st := pgstore.Open(t)
|
st := pgstore.Open(t)
|
||||||
t.Cleanup(func() { _ = st.Close() })
|
t.Cleanup(func() { _ = st.Close() })
|
||||||
|
|
||||||
task, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "a task", "body", "implement", "")
|
task, err := st.EnqueueChatTask(t.Context(), "acme", "widget", "a task", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("seed task: %v", err)
|
t.Fatalf("seed task: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2957,13 +2957,17 @@ func (x *EnqueueIssueResponse) GetInserted() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EnqueueChatTaskRequest struct {
|
type EnqueueChatTaskRequest struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
|
Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||||
Repo string `protobuf:"bytes,2,opt,name=repo,proto3" json:"repo,omitempty"`
|
Repo string `protobuf:"bytes,2,opt,name=repo,proto3" json:"repo,omitempty"`
|
||||||
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
|
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
|
||||||
Body string `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
|
Body string `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
Workflow string `protobuf:"bytes,5,opt,name=workflow,proto3" json:"workflow,omitempty"`
|
Workflow string `protobuf:"bytes,5,opt,name=workflow,proto3" json:"workflow,omitempty"`
|
||||||
Identity string `protobuf:"bytes,6,opt,name=identity,proto3" json:"identity,omitempty"`
|
Identity string `protobuf:"bytes,6,opt,name=identity,proto3" json:"identity,omitempty"`
|
||||||
|
// inputs_json assigns workflow inputs, a JSON object of the same form
|
||||||
|
// EnqueueBindingTaskRequest carries. A chat task sets them at insert
|
||||||
|
// time: it has no binding provenance to stamp afterwards.
|
||||||
|
InputsJson string `protobuf:"bytes,7,opt,name=inputs_json,json=inputsJson,proto3" json:"inputs_json,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -3040,6 +3044,13 @@ func (x *EnqueueChatTaskRequest) GetIdentity() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *EnqueueChatTaskRequest) GetInputsJson() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.InputsJson
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type EnqueueChatTaskResponse struct {
|
type EnqueueChatTaskResponse struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
|
||||||
@@ -11902,14 +11913,16 @@ const file_state_v1_state_proto_rawDesc = "" +
|
|||||||
"\x06labels\x18\x06 \x01(\tR\x06labels\x12\x1a\n" +
|
"\x06labels\x18\x06 \x01(\tR\x06labels\x12\x1a\n" +
|
||||||
"\bidentity\x18\a \x01(\tR\bidentity\"2\n" +
|
"\bidentity\x18\a \x01(\tR\bidentity\"2\n" +
|
||||||
"\x14EnqueueIssueResponse\x12\x1a\n" +
|
"\x14EnqueueIssueResponse\x12\x1a\n" +
|
||||||
"\binserted\x18\x01 \x01(\bR\binserted\"\xa4\x01\n" +
|
"\binserted\x18\x01 \x01(\bR\binserted\"\xc5\x01\n" +
|
||||||
"\x16EnqueueChatTaskRequest\x12\x14\n" +
|
"\x16EnqueueChatTaskRequest\x12\x14\n" +
|
||||||
"\x05owner\x18\x01 \x01(\tR\x05owner\x12\x12\n" +
|
"\x05owner\x18\x01 \x01(\tR\x05owner\x12\x12\n" +
|
||||||
"\x04repo\x18\x02 \x01(\tR\x04repo\x12\x14\n" +
|
"\x04repo\x18\x02 \x01(\tR\x04repo\x12\x14\n" +
|
||||||
"\x05title\x18\x03 \x01(\tR\x05title\x12\x12\n" +
|
"\x05title\x18\x03 \x01(\tR\x05title\x12\x12\n" +
|
||||||
"\x04body\x18\x04 \x01(\tR\x04body\x12\x1a\n" +
|
"\x04body\x18\x04 \x01(\tR\x04body\x12\x1a\n" +
|
||||||
"\bworkflow\x18\x05 \x01(\tR\bworkflow\x12\x1a\n" +
|
"\bworkflow\x18\x05 \x01(\tR\bworkflow\x12\x1a\n" +
|
||||||
"\bidentity\x18\x06 \x01(\tR\bidentity\"=\n" +
|
"\bidentity\x18\x06 \x01(\tR\bidentity\x12\x1f\n" +
|
||||||
|
"\vinputs_json\x18\a \x01(\tR\n" +
|
||||||
|
"inputsJson\"=\n" +
|
||||||
"\x17EnqueueChatTaskResponse\x12\"\n" +
|
"\x17EnqueueChatTaskResponse\x12\"\n" +
|
||||||
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"\x12\n" +
|
"\x04task\x18\x01 \x01(\v2\x0e.state.v1.TaskR\x04task\"\x12\n" +
|
||||||
"\x10ClaimNextRequest\"M\n" +
|
"\x10ClaimNextRequest\"M\n" +
|
||||||
|
|||||||
@@ -1911,7 +1911,7 @@ func TestReconcilePRsSkipsChatTasks(t *testing.T) {
|
|||||||
d, s, fg := testDaemon(t, 3, 0)
|
d, s, fg := testDaemon(t, 3, 0)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
task, err := s.EnqueueChatTask(ctx, "acme", "widget", "chat task", "", "", "")
|
task, err := s.EnqueueChatTask(ctx, "acme", "widget", "chat task", "", "", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (s *workflowDefinitionsStub) WorkflowDefinitions(context.Context) (workflow
|
|||||||
func TestWorkflowDefinitionPinSurvivesActiveOverride(t *testing.T) {
|
func TestWorkflowDefinitionPinSurvivesActiveOverride(t *testing.T) {
|
||||||
resources := pgstore.Open(t)
|
resources := pgstore.Open(t)
|
||||||
defer resources.Close()
|
defer resources.Close()
|
||||||
task, err := resources.EnqueueChatTask(t.Context(), "acme", "widget", "custom", "", "custom", "operator")
|
task, err := resources.EnqueueChatTask(t.Context(), "acme", "widget", "custom", "", "custom", "operator", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,10 +52,14 @@ type Inbound struct {
|
|||||||
// Workflow are optional -- empty means "the daemon's configured
|
// Workflow are optional -- empty means "the daemon's configured
|
||||||
// default for this identity".
|
// default for this identity".
|
||||||
type SpawnRequest struct {
|
type SpawnRequest struct {
|
||||||
Title string
|
Title string
|
||||||
Body string // operator instructions carried into the admitted task
|
Body string // operator instructions carried into the admitted task
|
||||||
Repo string // "owner/name"; empty = identity's default repo
|
Repo string // "owner/name"; empty = identity's default repo
|
||||||
|
// Workflow may name a workflow whose interface declares inputs
|
||||||
|
// (pr-review's pr_number, for instance). Inputs assigns them; a
|
||||||
|
// workflow that declares none ignores it.
|
||||||
Workflow string // empty = daemon's default workflow routing
|
Workflow string // empty = daemon's default workflow routing
|
||||||
|
Inputs map[string]any
|
||||||
Identity string // the identity spawning this task; propagated from Router.Identity
|
Identity string // the identity spawning this task; propagated from Router.Identity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ type TaskStore interface {
|
|||||||
// poll, chat spawn, drain loop) do not acquire a binding-specific shape.
|
// poll, chat spawn, drain loop) do not acquire a binding-specific shape.
|
||||||
type TaskLifecycle interface {
|
type TaskLifecycle interface {
|
||||||
EnqueueIssue(ctx context.Context, owner, repo string, number int, title, body, labels, identity string) (bool, error)
|
EnqueueIssue(ctx context.Context, owner, repo string, number int, title, body, labels, identity string) (bool, error)
|
||||||
EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity string) (*task.Task, error)
|
EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity string, inputs map[string]any) (*task.Task, error)
|
||||||
ClaimNext(ctx context.Context) (*task.Task, error)
|
ClaimNext(ctx context.Context) (*task.Task, error)
|
||||||
ClaimByIssue(ctx context.Context, owner, repo string, number int) (*task.Task, error)
|
ClaimByIssue(ctx context.Context, owner, repo string, number int) (*task.Task, error)
|
||||||
Transition(ctx context.Context, taskID int64, from, to, detail string) error
|
Transition(ctx context.Context, taskID int64, from, to, detail string) error
|
||||||
|
|||||||
@@ -8,69 +8,33 @@ import (
|
|||||||
"github.com/samcharles93/archie-core/internal/tools"
|
"github.com/samcharles93/archie-core/internal/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PRReviewResult is the structured outcome of an operator-triggered PR
|
// ReviewTools builds the review_pr chat tool. A nil creator omits the tool
|
||||||
// review, returned to the channel that requested it. It mirrors
|
// rather than registering one that always fails, so a daemon without a task
|
||||||
// workflow.ReviewReport without importing the domain package: the gateway
|
// store advertises nothing.
|
||||||
// states what it needs and the daemon adapts between the two (the
|
|
||||||
// ChatTaskActor pattern). Status is "completed", "not_run", or "skipped";
|
|
||||||
// a zero-finding "completed" result is a review that ran and cleared, and
|
|
||||||
// is structurally distinct from "not_run".
|
|
||||||
type PRReviewResult struct {
|
|
||||||
Repo string `json:"repo"`
|
|
||||||
Number int `json:"number"`
|
|
||||||
Model string `json:"model,omitempty"`
|
|
||||||
Status string `json:"status"`
|
|
||||||
Summary string `json:"summary,omitempty"`
|
|
||||||
// Reason explains why a not_run/skipped review did not execute.
|
|
||||||
Reason string `json:"reason,omitempty"`
|
|
||||||
Findings []PRReviewFinding `json:"findings"`
|
|
||||||
// ArtifactURL is the editor deep link for the published review artifact,
|
|
||||||
// empty when artifact publishing is disabled or failed.
|
|
||||||
ArtifactURL string `json:"artifact_url,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PRReviewFinding is one defect from an operator-triggered review.
|
|
||||||
type PRReviewFinding struct {
|
|
||||||
File string `json:"file"`
|
|
||||||
Line int `json:"line"`
|
|
||||||
Defect string `json:"defect"`
|
|
||||||
FailureScenario string `json:"failure_scenario,omitempty"`
|
|
||||||
Verdict string `json:"verdict"`
|
|
||||||
Level string `json:"level"`
|
|
||||||
Category string `json:"category,omitempty"`
|
|
||||||
Blocking bool `json:"blocking"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChatPRReviewer is the surface review_pr needs. The gateway states what it
|
|
||||||
// needs and the daemon supplies an adapter over the forge, worktree manager
|
|
||||||
// and reviewer runtime, so this package keeps its independence from
|
|
||||||
// internal/forge, internal/worktree and internal/domain/workflow.
|
|
||||||
//
|
//
|
||||||
// identity follows the ChatTaskActor convention: nil denotes an
|
// The tool queues a pr-review task; it does not review in the turn. The
|
||||||
// authenticated dashboard operator who may review any configured
|
// pipeline needs a sandbox, a prefetched snapshot and minutes of model calls,
|
||||||
// repository; a non-nil identity is a chat identity scoped to its own
|
// so the operator gets a task ID back and watches the task like any other
|
||||||
// configured repositories.
|
// (docs/prds/pr-review-agent.md, "Triggers").
|
||||||
type ChatPRReviewer interface {
|
func ReviewTools(creator TaskCreator, identity string) []tools.ToolEntry {
|
||||||
ReviewPR(ctx context.Context, identity *string, repo string, number int) (PRReviewResult, error)
|
if creator == nil {
|
||||||
}
|
|
||||||
|
|
||||||
// ReviewTools builds the review_pr chat tool. A nil reviewer omits the tool
|
|
||||||
// rather than registering one that always fails, so a daemon without
|
|
||||||
// operator review support advertises nothing.
|
|
||||||
func ReviewTools(reviewer ChatPRReviewer, identity string) []tools.ToolEntry {
|
|
||||||
if reviewer == nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return []tools.ToolEntry{reviewPRTool(reviewer, identity)}
|
return []tools.ToolEntry{reviewPRTool(creator, identity)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func reviewPRTool(reviewer ChatPRReviewer, identity string) tools.ToolEntry {
|
// prReviewWorkflow is the workflow a queued operator review runs. Its
|
||||||
|
// declared interface requires pr_number, so the tool that names it is also
|
||||||
|
// the only chat path that can satisfy it.
|
||||||
|
const prReviewWorkflow = "pr-review"
|
||||||
|
|
||||||
|
func reviewPRTool(creator TaskCreator, identity string) tools.ToolEntry {
|
||||||
return tools.ToolEntry{
|
return tools.ToolEntry{
|
||||||
Name: "review_pr",
|
Name: "review_pr",
|
||||||
Toolset: "tasks",
|
Toolset: "tasks",
|
||||||
Description: "Run the adversarial reviewer against an existing pull request and return its structured findings. " +
|
Description: "Queue a review of an existing pull request. Use it when the user asks to review a PR, " +
|
||||||
"Use it when the user asks to review a PR, re-check one after a push, or see what the reviewer found. " +
|
"re-check one after a push, or see what the reviewer found. The review runs as a task in its own " +
|
||||||
"Only a confirmed error-level finding blocks; a clean result reports zero findings explicitly.",
|
"sandbox and posts its findings to the pull request; this returns the task ID immediately.",
|
||||||
Classification: tools.ClassMutating,
|
Classification: tools.ClassMutating,
|
||||||
Schema: tools.JSONSchema{
|
Schema: tools.JSONSchema{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -95,11 +59,26 @@ func reviewPRTool(reviewer ChatPRReviewer, identity string) tools.ToolEntry {
|
|||||||
if !ok || number <= 0 {
|
if !ok || number <= 0 {
|
||||||
return nil, fmt.Errorf("review_pr: pr_number must be a positive integer")
|
return nil, fmt.Errorf("review_pr: pr_number must be a positive integer")
|
||||||
}
|
}
|
||||||
result, err := reviewer.ReviewPR(ctx, &identity, repo, int(number))
|
id, err := creator.CreateTask(ctx, SpawnRequest{
|
||||||
|
Title: fmt.Sprintf("review %s#%d", repo, number),
|
||||||
|
Body: fmt.Sprintf("Operator-requested review of pull request %s#%d.", repo, number),
|
||||||
|
Repo: repo,
|
||||||
|
Workflow: prReviewWorkflow,
|
||||||
|
// int, not int64: task.Task.EffectivePRNumber reads the
|
||||||
|
// input as json.Number, float64 or int, and an int64 would
|
||||||
|
// resolve to 0 for a task that names a real PR.
|
||||||
|
Inputs: map[string]any{"pr_number": int(number)},
|
||||||
|
// The bound identity, never input["identity"]: CreateTask
|
||||||
|
// enforces the repository allow-list for it.
|
||||||
|
Identity: identity,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("review_pr: %w", err)
|
return nil, fmt.Errorf("review_pr: %w", err)
|
||||||
}
|
}
|
||||||
return result, nil
|
return TaskSpawnResult{
|
||||||
|
ID: id,
|
||||||
|
Message: fmt.Sprintf("queued pr-review task %d for %s#%d", id, repo, number),
|
||||||
|
}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,29 +6,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakePRReviewer struct {
|
func TestReviewToolOmittedWhenCreatorNil(t *testing.T) {
|
||||||
gotIdentity *string
|
|
||||||
gotRepo string
|
|
||||||
gotNumber int
|
|
||||||
result PRReviewResult
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fakePRReviewer) ReviewPR(_ context.Context, identity *string, repo string, number int) (PRReviewResult, error) {
|
|
||||||
f.gotIdentity = identity
|
|
||||||
f.gotRepo = repo
|
|
||||||
f.gotNumber = number
|
|
||||||
return f.result, f.err
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReviewToolOmittedWhenReviewerNil(t *testing.T) {
|
|
||||||
if entries := ReviewTools(nil, "archie"); len(entries) != 0 {
|
if entries := ReviewTools(nil, "archie"); len(entries) != 0 {
|
||||||
t.Fatalf("ReviewTools(nil) = %d entries, want 0 -- a tool that cannot run must not be advertised", len(entries))
|
t.Fatalf("ReviewTools(nil) = %d entries, want 0 -- a tool that cannot run must not be advertised", len(entries))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReviewToolAppearsWhenReviewerNonNil(t *testing.T) {
|
func TestReviewToolAppearsWhenCreatorNonNil(t *testing.T) {
|
||||||
entries := ReviewTools(&fakePRReviewer{}, "archie")
|
entries := ReviewTools(&fakeCreator{}, "archie")
|
||||||
if len(entries) != 1 {
|
if len(entries) != 1 {
|
||||||
t.Fatalf("ReviewTools() = %d entries, want 1", len(entries))
|
t.Fatalf("ReviewTools() = %d entries, want 1", len(entries))
|
||||||
}
|
}
|
||||||
@@ -37,14 +22,9 @@ func TestReviewToolAppearsWhenReviewerNonNil(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReviewPRToolBindsIdentityAndReturnsFindings(t *testing.T) {
|
func TestReviewPRToolQueuesReviewTask(t *testing.T) {
|
||||||
reviewer := &fakePRReviewer{
|
creator := &fakeCreator{id: 42}
|
||||||
result: PRReviewResult{
|
entry := toolNamed(t, ReviewTools(creator, "archie"), "review_pr")
|
||||||
Repo: "acme/widget", Number: 7, Model: "openai/gpt-5", Status: "completed",
|
|
||||||
Findings: []PRReviewFinding{{File: "a.go", Line: 3, Defect: "nil deref", FailureScenario: "x", Verdict: "confirmed", Level: "error", Category: "nil-risk", Blocking: true}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
entry := toolNamed(t, ReviewTools(reviewer, "archie"), "review_pr")
|
|
||||||
|
|
||||||
out, err := entry.Handler(context.Background(), map[string]any{
|
out, err := entry.Handler(context.Background(), map[string]any{
|
||||||
"repo": "acme/widget", "pr_number": float64(7), "identity": "someone-else",
|
"repo": "acme/widget", "pr_number": float64(7), "identity": "someone-else",
|
||||||
@@ -53,27 +33,37 @@ func TestReviewPRToolBindsIdentityAndReturnsFindings(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
got := creator.got
|
||||||
|
if got.Workflow != "pr-review" {
|
||||||
|
t.Errorf("workflow = %q, want pr-review -- the operator trigger runs the pipeline, it does not review in the turn", got.Workflow)
|
||||||
|
}
|
||||||
|
if got.Repo != "acme/widget" {
|
||||||
|
t.Errorf("repo = %q, want acme/widget -- CreateTask authorizes against it", got.Repo)
|
||||||
|
}
|
||||||
// The model supplied an identity; it must be ignored in favour of the
|
// The model supplied an identity; it must be ignored in favour of the
|
||||||
// bound identity.
|
// bound identity.
|
||||||
if reviewer.gotIdentity == nil || *reviewer.gotIdentity != "archie" {
|
if got.Identity != "archie" {
|
||||||
t.Fatalf("identity = %v, want bound \"archie\"", reviewer.gotIdentity)
|
t.Errorf("identity = %q, want bound %q", got.Identity, "archie")
|
||||||
}
|
}
|
||||||
if reviewer.gotRepo != "acme/widget" || reviewer.gotNumber != 7 {
|
if n, ok := got.Inputs["pr_number"].(int); !ok || n != 7 {
|
||||||
t.Fatalf("ReviewPR called with (%q, %d), want (acme/widget, 7)", reviewer.gotRepo, reviewer.gotNumber)
|
t.Errorf("inputs[pr_number] = %#v, want int 7", got.Inputs["pr_number"])
|
||||||
|
}
|
||||||
|
if got.Title == "" || got.Body == "" {
|
||||||
|
t.Errorf("title/body = %q/%q, want both set so the queued task is identifiable", got.Title, got.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
result, ok := out.(PRReviewResult)
|
result, ok := out.(TaskSpawnResult)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("handler returned %T, want PRReviewResult", out)
|
t.Fatalf("handler returned %T, want TaskSpawnResult", out)
|
||||||
}
|
}
|
||||||
if result.Status != "completed" || len(result.Findings) != 1 || !result.Findings[0].Blocking {
|
if result.ID != 42 {
|
||||||
t.Fatalf("result = %+v, want completed with one blocking finding", result)
|
t.Errorf("result.ID = %d, want 42", result.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReviewPRToolValidatesInput(t *testing.T) {
|
func TestReviewPRToolValidatesInput(t *testing.T) {
|
||||||
reviewer := &fakePRReviewer{}
|
creator := &fakeCreator{}
|
||||||
entry := toolNamed(t, ReviewTools(reviewer, "archie"), "review_pr")
|
entry := toolNamed(t, ReviewTools(creator, "archie"), "review_pr")
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -91,15 +81,18 @@ func TestReviewPRToolValidatesInput(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if len(creator.got.Inputs) != 0 || creator.got.Repo != "" {
|
||||||
|
t.Errorf("rejected input still reached CreateTask: %+v", creator.got)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReviewPRToolSurfacesReviewerError(t *testing.T) {
|
func TestReviewPRToolSurfacesCreatorError(t *testing.T) {
|
||||||
reviewer := &fakePRReviewer{err: errors.New("review already in progress")}
|
creator := &fakeCreator{err: errors.New("repo not configured")}
|
||||||
entry := toolNamed(t, ReviewTools(reviewer, "archie"), "review_pr")
|
entry := toolNamed(t, ReviewTools(creator, "archie"), "review_pr")
|
||||||
|
|
||||||
if _, err := entry.Handler(context.Background(), map[string]any{
|
if _, err := entry.Handler(context.Background(), map[string]any{
|
||||||
"repo": "acme/widget", "pr_number": float64(7),
|
"repo": "acme/widget", "pr_number": float64(7),
|
||||||
}); err == nil {
|
}); err == nil {
|
||||||
t.Fatal("handler error = nil, want the reviewer failure surfaced")
|
t.Fatal("handler error = nil, want the creator failure surfaced")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ type taskProfile struct {
|
|||||||
// internal/domain/workflow; the daemon supplies an adapter closure over
|
// internal/domain/workflow; the daemon supplies an adapter closure over
|
||||||
// the store.TaskStore method of the same name.
|
// the store.TaskStore method of the same name.
|
||||||
type chatTaskWriter interface {
|
type chatTaskWriter interface {
|
||||||
EnqueueChatTask(ctx context.Context, owner, repo, title, body, workflow, identity string) (taskID int64, err error)
|
EnqueueChatTask(ctx context.Context, owner, repo, title, body, workflow, identity string, inputs map[string]any) (taskID int64, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewStoreTaskCreator returns a TaskCreator that enqueues chat-spawned
|
// NewStoreTaskCreator returns a TaskCreator that enqueues chat-spawned
|
||||||
@@ -103,7 +103,7 @@ func (c *StoreTaskCreator) CreateTask(ctx context.Context, req SpawnRequest) (in
|
|||||||
if owner == "" || repo == "" {
|
if owner == "" || repo == "" {
|
||||||
return 0, fmt.Errorf("no repo configured for chat-spawned tasks")
|
return 0, fmt.Errorf("no repo configured for chat-spawned tasks")
|
||||||
}
|
}
|
||||||
return c.store.EnqueueChatTask(ctx, owner, repo, req.Title, req.Body, req.Workflow, req.Identity)
|
return c.store.EnqueueChatTask(ctx, owner, repo, req.Title, req.Body, req.Workflow, req.Identity, req.Inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitOwnerRepo(s string) (owner, repo string, ok bool) {
|
func splitOwnerRepo(s string) (owner, repo string, ok bool) {
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ import (
|
|||||||
|
|
||||||
type fakeChatTaskWriter struct {
|
type fakeChatTaskWriter struct {
|
||||||
owner, repo, title, body, workflow, identity string
|
owner, repo, title, body, workflow, identity string
|
||||||
|
inputs map[string]any
|
||||||
calls int
|
calls int
|
||||||
nextID int64
|
nextID int64
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeChatTaskWriter) EnqueueChatTask(ctx context.Context, owner, repo, title, body, workflow, identity string) (int64, error) {
|
func (f *fakeChatTaskWriter) EnqueueChatTask(ctx context.Context, owner, repo, title, body, workflow, identity string, inputs map[string]any) (int64, error) {
|
||||||
f.owner, f.repo, f.title, f.body, f.workflow, f.identity = owner, repo, title, body, workflow, identity
|
f.owner, f.repo, f.title, f.body, f.workflow, f.identity = owner, repo, title, body, workflow, identity
|
||||||
|
f.inputs = inputs
|
||||||
f.calls++
|
f.calls++
|
||||||
if f.err != nil {
|
if f.err != nil {
|
||||||
return 0, f.err
|
return 0, f.err
|
||||||
@@ -46,6 +48,26 @@ func TestStoreTaskCreatorCreatesTask(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStoreTaskCreatorForwardsInputs(t *testing.T) {
|
||||||
|
sw := &fakeChatTaskWriter{}
|
||||||
|
tc := NewStoreTaskCreator(sw, "acme", "example-service", []string{"acme/example-service"})
|
||||||
|
_, err := tc.CreateTask(context.Background(), SpawnRequest{
|
||||||
|
Title: "review",
|
||||||
|
Repo: "acme/example-service",
|
||||||
|
Workflow: "pr-review",
|
||||||
|
Inputs: map[string]any{"pr_number": 7},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("CreateTask: %v", err)
|
||||||
|
}
|
||||||
|
if sw.workflow != "pr-review" {
|
||||||
|
t.Errorf("workflow = %q, want pr-review", sw.workflow)
|
||||||
|
}
|
||||||
|
if n, ok := sw.inputs["pr_number"].(int); !ok || n != 7 {
|
||||||
|
t.Errorf("inputs = %#v, want pr_number 7", sw.inputs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestStoreTaskCreatorRejectsEmptyRepo(t *testing.T) {
|
func TestStoreTaskCreatorRejectsEmptyRepo(t *testing.T) {
|
||||||
tc := NewStoreTaskCreator(&fakeChatTaskWriter{}, "", "", nil)
|
tc := NewStoreTaskCreator(&fakeChatTaskWriter{}, "", "", nil)
|
||||||
_, err := tc.CreateTask(context.Background(), SpawnRequest{Title: "something"})
|
_, err := tc.CreateTask(context.Background(), SpawnRequest{Title: "something"})
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ type TurnRunnerConfig struct {
|
|||||||
TaskLogs ChatTaskLogReader
|
TaskLogs ChatTaskLogReader
|
||||||
TaskActor ChatTaskActor
|
TaskActor ChatTaskActor
|
||||||
TaskIdentity string
|
TaskIdentity string
|
||||||
PRReviewer ChatPRReviewer
|
|
||||||
Bus TurnEventPublisher
|
Bus TurnEventPublisher
|
||||||
BotUser string
|
BotUser string
|
||||||
Channel string
|
Channel string
|
||||||
@@ -314,7 +313,7 @@ func (r *TurnRunner) prepareTurn(ctx context.Context, sessionID string, in Inbou
|
|||||||
TaskTools(r.TaskLister, r.Tasks, r.TaskLogs, r.TaskActor, r.TaskIdentity),
|
TaskTools(r.TaskLister, r.Tasks, r.TaskLogs, r.TaskActor, r.TaskIdentity),
|
||||||
SessionTools(r.Sessions, r.Router.SessionTracker(), r.Router.sessionPlatform(in), in.Message)...,
|
SessionTools(r.Sessions, r.Router.SessionTracker(), r.Router.sessionPlatform(in), in.Message)...,
|
||||||
)
|
)
|
||||||
extraTools = append(extraTools, ReviewTools(r.PRReviewer, r.TaskIdentity)...)
|
extraTools = append(extraTools, ReviewTools(r.Tasks, r.TaskIdentity)...)
|
||||||
// The dashboard tools (page_index, dashboard_navigate) belong to the web
|
// The dashboard tools (page_index, dashboard_navigate) belong to the web
|
||||||
// UI only: a non-web channel has no dashboard to point at.
|
// UI only: a non-web channel has no dashboard to point at.
|
||||||
extraTools = append(extraTools, PageIndexTools(r.Channel)...)
|
extraTools = append(extraTools, PageIndexTools(r.Channel)...)
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ func titles(t *testing.T, pool *pgxpool.Pool) []string {
|
|||||||
|
|
||||||
func enqueue(t *testing.T, pool *pgxpool.Pool, title string) {
|
func enqueue(t *testing.T, pool *pgxpool.Pool, title string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if _, err := New(pool).EnqueueChatTask(t.Context(), "acme", "widget", title, "body", "implement", ""); err != nil {
|
if _, err := New(pool).EnqueueChatTask(t.Context(), "acme", "widget", title, "body", "implement", "", nil); err != nil {
|
||||||
t.Fatalf("enqueue %q: %v", title, err)
|
t.Fatalf("enqueue %q: %v", title, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func (q *Queries) EnqueueIssue(ctx context.Context, arg EnqueueIssueParams) (int
|
|||||||
}
|
}
|
||||||
|
|
||||||
const insertChatTask = `-- name: InsertChatTask :one
|
const insertChatTask = `-- name: InsertChatTask :one
|
||||||
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id)
|
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs)
|
||||||
VALUES (
|
VALUES (
|
||||||
$1, $2,
|
$1, $2,
|
||||||
COALESCE((
|
COALESCE((
|
||||||
@@ -266,7 +266,8 @@ VALUES (
|
|||||||
(SELECT m.org_id FROM memberships m WHERE m.identity_id = $7
|
(SELECT m.org_id FROM memberships m WHERE m.identity_id = $7
|
||||||
ORDER BY m.created_at, m.org_id, m.workspace_id NULLS LAST LIMIT 1),
|
ORDER BY m.created_at, m.org_id, m.workspace_id NULLS LAST LIMIT 1),
|
||||||
'default'
|
'default'
|
||||||
)
|
),
|
||||||
|
$8
|
||||||
)
|
)
|
||||||
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
|
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
|
||||||
`
|
`
|
||||||
@@ -279,12 +280,16 @@ type InsertChatTaskParams struct {
|
|||||||
Body string
|
Body string
|
||||||
Workflow string
|
Workflow string
|
||||||
Identity string
|
Identity string
|
||||||
|
Inputs string
|
||||||
}
|
}
|
||||||
|
|
||||||
// The synthetic issue number keeps chat-sourced tasks off the forge's real
|
// The synthetic issue number keeps chat-sourced tasks off the forge's real
|
||||||
// issue numbers; this allocator is the single source of truth for it.
|
// issue numbers; this allocator is the single source of truth for it.
|
||||||
// fallback_issue_number is only the seed for a repo's first chat task -- the
|
// fallback_issue_number is only the seed for a repo's first chat task -- the
|
||||||
// passed value is not the issue number that lands.
|
// passed value is not the issue number that lands.
|
||||||
|
// inputs is the chat task's own workflow inputs; a binding dispatch passes
|
||||||
|
// its inputs here too, so this insert is the single writer of the column and
|
||||||
|
// StampTaskBinding adds only the provenance.
|
||||||
func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams) (Task, error) {
|
func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams) (Task, error) {
|
||||||
row := q.db.QueryRow(ctx, insertChatTask,
|
row := q.db.QueryRow(ctx, insertChatTask,
|
||||||
arg.Owner,
|
arg.Owner,
|
||||||
@@ -294,6 +299,7 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
|
|||||||
arg.Body,
|
arg.Body,
|
||||||
arg.Workflow,
|
arg.Workflow,
|
||||||
arg.Identity,
|
arg.Identity,
|
||||||
|
arg.Inputs,
|
||||||
)
|
)
|
||||||
var i Task
|
var i Task
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
@@ -599,23 +605,17 @@ func (q *Queries) SetReviewCursors(ctx context.Context, arg SetReviewCursorsPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
const stampTaskBinding = `-- name: StampTaskBinding :exec
|
const stampTaskBinding = `-- name: StampTaskBinding :exec
|
||||||
UPDATE tasks SET binding_id = $2, binding_version = $3, inputs = $4 WHERE id = $1
|
UPDATE tasks SET binding_id = $2, binding_version = $3 WHERE id = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
type StampTaskBindingParams struct {
|
type StampTaskBindingParams struct {
|
||||||
ID int64
|
ID int64
|
||||||
BindingID string
|
BindingID string
|
||||||
BindingVersion int64
|
BindingVersion int64
|
||||||
Inputs string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingParams) error {
|
func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingParams) error {
|
||||||
_, err := q.db.Exec(ctx, stampTaskBinding,
|
_, err := q.db.Exec(ctx, stampTaskBinding, arg.ID, arg.BindingID, arg.BindingVersion)
|
||||||
arg.ID,
|
|
||||||
arg.BindingID,
|
|
||||||
arg.BindingVersion,
|
|
||||||
arg.Inputs,
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ SELECT status, count(*)::int AS count FROM tasks GROUP BY status;
|
|||||||
-- issue numbers; this allocator is the single source of truth for it.
|
-- issue numbers; this allocator is the single source of truth for it.
|
||||||
-- fallback_issue_number is only the seed for a repo's first chat task -- the
|
-- fallback_issue_number is only the seed for a repo's first chat task -- the
|
||||||
-- passed value is not the issue number that lands.
|
-- passed value is not the issue number that lands.
|
||||||
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id)
|
-- inputs is the chat task's own workflow inputs; a binding dispatch passes
|
||||||
|
-- its inputs here too, so this insert is the single writer of the column and
|
||||||
|
-- StampTaskBinding adds only the provenance.
|
||||||
|
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs)
|
||||||
VALUES (
|
VALUES (
|
||||||
sqlc.arg(owner), sqlc.arg(repo),
|
sqlc.arg(owner), sqlc.arg(repo),
|
||||||
COALESCE((
|
COALESCE((
|
||||||
@@ -57,12 +60,13 @@ VALUES (
|
|||||||
(SELECT m.org_id FROM memberships m WHERE m.identity_id = sqlc.arg(identity)
|
(SELECT m.org_id FROM memberships m WHERE m.identity_id = sqlc.arg(identity)
|
||||||
ORDER BY m.created_at, m.org_id, m.workspace_id NULLS LAST LIMIT 1),
|
ORDER BY m.created_at, m.org_id, m.workspace_id NULLS LAST LIMIT 1),
|
||||||
'default'
|
'default'
|
||||||
)
|
),
|
||||||
|
sqlc.arg(inputs)
|
||||||
)
|
)
|
||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- name: StampTaskBinding :exec
|
-- name: StampTaskBinding :exec
|
||||||
UPDATE tasks SET binding_id = $2, binding_version = $3, inputs = $4 WHERE id = $1;
|
UPDATE tasks SET binding_id = $2, binding_version = $3 WHERE id = $1;
|
||||||
|
|
||||||
-- name: UpdateTask :exec
|
-- name: UpdateTask :exec
|
||||||
UPDATE tasks SET workflow = $2, branch = $3, plan = $4, notes = $5,
|
UPDATE tasks SET workflow = $2, branch = $3, plan = $4, notes = $5,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
// runningExecution enqueues and claims one task, the state a step runs in.
|
// runningExecution enqueues and claims one task, the state a step runs in.
|
||||||
func runningExecution(t *testing.T, s *Store) *workflow.Task {
|
func runningExecution(t *testing.T, s *Store) *workflow.Task {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
seed, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "")
|
seed, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "", nil)
|
||||||
if err != nil || seed == nil {
|
if err != nil || seed == nil {
|
||||||
t.Fatalf("EnqueueChatTask: %+v %v", seed, err)
|
t.Fatalf("EnqueueChatTask: %+v %v", seed, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,10 +148,17 @@ func (s *Store) EnqueueIssue(ctx context.Context, owner, repo string, number int
|
|||||||
|
|
||||||
// EnqueueChatTask inserts a queued chat-sourced task and returns the full row.
|
// EnqueueChatTask inserts a queued chat-sourced task and returns the full row.
|
||||||
// The store allocates the synthetic issue number durably so processes sharing
|
// The store allocates the synthetic issue number durably so processes sharing
|
||||||
// the database cannot generate the same value.
|
// the database cannot generate the same value. inputs are the task's workflow
|
||||||
func (s *Store) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity string) (*workflow.Task, error) {
|
// inputs (the operator trigger's pr_number, for instance); a chat task carries
|
||||||
|
// no binding provenance, so the insert is the only writer of that column.
|
||||||
|
func (s *Store) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity string, inputs map[string]any) (*workflow.Task, error) {
|
||||||
|
encoded, err := task.EncodeInputs(inputs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
t, err := s.queries().InsertChatTask(ctx, postgresdb.InsertChatTaskParams{
|
t, err := s.queries().InsertChatTask(ctx, postgresdb.InsertChatTaskParams{
|
||||||
Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity,
|
Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity,
|
||||||
|
Inputs: encoded,
|
||||||
FallbackIssueNumber: syntheticIssueNumberBase - 1,
|
FallbackIssueNumber: syntheticIssueNumberBase - 1,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -161,24 +168,21 @@ func (s *Store) EnqueueChatTask(ctx context.Context, owner, repo, title, body, w
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EnqueueBindingTask enqueues a binding-triggered task and stamps its binding
|
// EnqueueBindingTask enqueues a binding-triggered task and stamps its binding
|
||||||
// provenance in a second statement (best-effort, as in the SQLite store).
|
// provenance in a second statement (best-effort, as in the SQLite store). The
|
||||||
|
// inputs travel with the insert, so a failed stamp leaves a task whose inputs
|
||||||
|
// are already right and whose provenance is absent, never the reverse.
|
||||||
func (s *Store) EnqueueBindingTask(ctx context.Context, owner, repo, title, body, wf, identity, bindingID string, bindingVersion int, inputs map[string]any) (*workflow.Task, error) {
|
func (s *Store) EnqueueBindingTask(ctx context.Context, owner, repo, title, body, wf, identity, bindingID string, bindingVersion int, inputs map[string]any) (*workflow.Task, error) {
|
||||||
encoded, err := task.EncodeInputs(inputs)
|
t, err := s.EnqueueChatTask(ctx, owner, repo, title, body, wf, identity, inputs)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
t, err := s.EnqueueChatTask(ctx, owner, repo, title, body, wf, identity)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.queries().StampTaskBinding(ctx, postgresdb.StampTaskBindingParams{
|
if err := s.queries().StampTaskBinding(ctx, postgresdb.StampTaskBindingParams{
|
||||||
ID: t.ID, BindingID: bindingID, BindingVersion: int64(bindingVersion), Inputs: encoded,
|
ID: t.ID, BindingID: bindingID, BindingVersion: int64(bindingVersion),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, fmt.Errorf("store: stamp binding provenance: %w", err)
|
return nil, fmt.Errorf("store: stamp binding provenance: %w", err)
|
||||||
}
|
}
|
||||||
t.BindingID = bindingID
|
t.BindingID = bindingID
|
||||||
t.BindingVersion = bindingVersion
|
t.BindingVersion = bindingVersion
|
||||||
t.Inputs = inputs
|
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func TestIllegalTransitionsAreRejected(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
s := storeFor(t)
|
s := storeFor(t)
|
||||||
task, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "")
|
task, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ func TestIllegalTransitionsAreRejected(t *testing.T) {
|
|||||||
// conformance battery has always asserted).
|
// conformance battery has always asserted).
|
||||||
func TestStaleFromBeatsIllegalPair(t *testing.T) {
|
func TestStaleFromBeatsIllegalPair(t *testing.T) {
|
||||||
s := storeFor(t)
|
s := storeFor(t)
|
||||||
task, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "")
|
task, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ func TestStaleFromBeatsIllegalPair(t *testing.T) {
|
|||||||
// and the audit row is written as before.
|
// and the audit row is written as before.
|
||||||
func TestLegalTransitionStillWrites(t *testing.T) {
|
func TestLegalTransitionStillWrites(t *testing.T) {
|
||||||
s := storeFor(t)
|
s := storeFor(t)
|
||||||
task, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "")
|
task, err := s.EnqueueChatTask(t.Context(), "acme", "widgets", "t", "b", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func TestEventAttributionSurvivesTheStateStoreBoundary(t *testing.T) {
|
|||||||
c = remoteTaskStore(t, local, nil, nil)
|
c = remoteTaskStore(t, local, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
task, err := c.EnqueueChatTask(ctx, "acme", "widget", "title", "body", "implement", "")
|
task, err := c.EnqueueChatTask(ctx, "acme", "widget", "title", "body", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("EnqueueChatTask = (%+v, %v)", task, err)
|
t.Fatalf("EnqueueChatTask = (%+v, %v)", task, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,8 +75,12 @@ func (c *Client) EnqueueIssue(ctx context.Context, owner, repo string, number in
|
|||||||
return r.Inserted, nil
|
return r.Inserted, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity string) (*task.Task, error) {
|
func (c *Client) EnqueueChatTask(ctx context.Context, owner, repo, title, body, wf, identity string, inputs map[string]any) (*task.Task, error) {
|
||||||
r, err := c.client.EnqueueChatTask(ctx, &pb.EnqueueChatTaskRequest{Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity})
|
encoded, err := task.EncodeInputs(inputs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
r, err := c.client.EnqueueChatTask(ctx, &pb.EnqueueChatTaskRequest{Owner: owner, Repo: repo, Title: title, Body: body, Workflow: wf, Identity: identity, InputsJson: encoded})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, unmapError(err)
|
return nil, unmapError(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,10 +133,21 @@ func TestStateStoreConformance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// workflow.Store view: EnqueueChatTask, Transition, Update, InsertEvent.
|
// workflow.Store view: EnqueueChatTask, Transition, Update, InsertEvent.
|
||||||
task, err := c.EnqueueChatTask(ctx, "acme", "widget", "title", "body", "implement", "")
|
task, err := c.EnqueueChatTask(ctx, "acme", "widget", "title", "body", "implement", "", nil)
|
||||||
if err != nil || task == nil {
|
if err != nil || task == nil {
|
||||||
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
t.Fatalf("EnqueueChatTask: %+v %v", task, err)
|
||||||
}
|
}
|
||||||
|
// A chat task's workflow inputs travel with it across the wire
|
||||||
|
// and back out of the store: the operator trigger's pr-review
|
||||||
|
// task names its pull request through this input, and drops it
|
||||||
|
// silently if either mapping forgets it.
|
||||||
|
triggered, err := c.EnqueueChatTask(ctx, "acme", "widget", "review", "body", "pr-review", "", map[string]any{"pr_number": 7})
|
||||||
|
if err != nil || triggered == nil {
|
||||||
|
t.Fatalf("EnqueueChatTask with inputs: %+v %v", triggered, err)
|
||||||
|
}
|
||||||
|
if got := triggered.EffectivePRNumber(); got != 7 {
|
||||||
|
t.Fatalf("queued task EffectivePRNumber = %d, want 7 -- inputs did not round trip", got)
|
||||||
|
}
|
||||||
if err := c.Transition(ctx, task.ID, task.Status, "running", "started"); err != nil {
|
if err := c.Transition(ctx, task.ID, task.Status, "running", "started"); err != nil {
|
||||||
t.Fatalf("Transition: %v", err)
|
t.Fatalf("Transition: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,11 @@ func (s *server) EnqueueIssue(ctx context.Context, r *pb.EnqueueIssueRequest) (*
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) EnqueueChatTask(ctx context.Context, r *pb.EnqueueChatTaskRequest) (*pb.EnqueueChatTaskResponse, error) {
|
func (s *server) EnqueueChatTask(ctx context.Context, r *pb.EnqueueChatTaskRequest) (*pb.EnqueueChatTaskResponse, error) {
|
||||||
t, err := s.deps.Tasks.EnqueueChatTask(ctx, r.Owner, r.Repo, r.Title, r.Body, r.Workflow, r.Identity)
|
inputs, err := task.DecodeInputs(r.InputsJson)
|
||||||
|
if err != nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||||
|
}
|
||||||
|
t, err := s.deps.Tasks.EnqueueChatTask(ctx, r.Owner, r.Repo, r.Title, r.Body, r.Workflow, r.Identity, inputs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, s.logErr("EnqueueChatTask", err)
|
return nil, s.logErr("EnqueueChatTask", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ func TestTaskGrantAuthorizesTheWorkflowCallRPCs(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
caller, err := admin.EnqueueChatTask(ctx, "acme", "widget", "caller", "body", "implement", "")
|
caller, err := admin.EnqueueChatTask(ctx, "acme", "widget", "caller", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
other, err := admin.EnqueueChatTask(ctx, "acme", "widget", "other", "body", "implement", "")
|
other, err := admin.EnqueueChatTask(ctx, "acme", "widget", "other", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,11 +174,11 @@ func TestTaskGrantScopesWorkerToItsOwnRPCs(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
taskA, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
taskA, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
taskB, err := admin.EnqueueChatTask(ctx, "acme", "widget", "b", "body", "implement", "")
|
taskB, err := admin.EnqueueChatTask(ctx, "acme", "widget", "b", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ func TestOnlyAdminPublishesTheConfigSnapshot(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ func TestOnlyAdminReportsApplyStatus(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ func TestOnlyAdminOwnsThePlaybookLedger(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -379,7 +379,7 @@ func TestOnlyAdminCanRegisterOrRevokeTaskGrants(t *testing.T) {
|
|||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
taskA, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
taskA, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ func TestRunCredentialRecordsItsOwnSteps(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
own, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
own, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -421,7 +421,7 @@ func TestRunCredentialRecordsItsOwnSteps(t *testing.T) {
|
|||||||
if err != nil || own == nil {
|
if err != nil || own == nil {
|
||||||
t.Fatalf("TaskByID: %+v %v", own, err)
|
t.Fatalf("TaskByID: %+v %v", own, err)
|
||||||
}
|
}
|
||||||
other, err := admin.EnqueueChatTask(ctx, "acme", "widget", "b", "body", "implement", "")
|
other, err := admin.EnqueueChatTask(ctx, "acme", "widget", "b", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ func TestTaskGrantCannotCancelAnExecution(t *testing.T) {
|
|||||||
admin := dial(t, adminToken)
|
admin := dial(t, adminToken)
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "")
|
task, err := admin.EnqueueChatTask(ctx, "acme", "widget", "a", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func TestWorkflowCallerConformance(t *testing.T) {
|
|||||||
c = remoteTaskStore(t, local, nil, nil)
|
c = remoteTaskStore(t, local, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
caller, err := local.EnqueueChatTask(ctx, "acme", "widget", "caller", "body", "implement", "")
|
caller, err := local.EnqueueChatTask(ctx, "acme", "widget", "caller", "body", "implement", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("EnqueueChatTask: %v", err)
|
t.Fatalf("EnqueueChatTask: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ func TestRejectDoesNotCloseAChatTaskIssue(t *testing.T) {
|
|||||||
operatorActions(t, srv).issues = closer
|
operatorActions(t, srv).issues = closer
|
||||||
operatorActions(t, srv).cfg = config.NewHolder(config.Config{MaxRetries: 3})
|
operatorActions(t, srv).cfg = config.NewHolder(config.Config{MaxRetries: 3})
|
||||||
|
|
||||||
task, err := srv.Store.EnqueueChatTask(ctx, "acme", "widget", "chat task", "", "", "")
|
task, err := srv.Store.EnqueueChatTask(ctx, "acme", "widget", "chat task", "", "", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func TestWorkRequestRejectsDisabledWorkflow(t *testing.T) {
|
|||||||
if w.Code != http.StatusConflict {
|
if w.Code != http.StatusConflict {
|
||||||
t.Fatalf("status = %d, body = %s", w.Code, w.Body)
|
t.Fatalf("status = %d, body = %s", w.Code, w.Body)
|
||||||
}
|
}
|
||||||
if creator.request != (gateway.SpawnRequest{}) {
|
if got := creator.request; got.Title != "" || got.Body != "" || got.Repo != "" || got.Workflow != "" || got.Identity != "" || len(got.Inputs) != 0 {
|
||||||
t.Fatalf("creator called with %#v", creator.request)
|
t.Fatalf("creator called with %#v", got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -512,6 +512,10 @@ message EnqueueChatTaskRequest {
|
|||||||
string body = 4;
|
string body = 4;
|
||||||
string workflow = 5;
|
string workflow = 5;
|
||||||
string identity = 6;
|
string identity = 6;
|
||||||
|
// inputs_json assigns workflow inputs, a JSON object of the same form
|
||||||
|
// EnqueueBindingTaskRequest carries. A chat task sets them at insert
|
||||||
|
// time: it has no binding provenance to stamp afterwards.
|
||||||
|
string inputs_json = 7;
|
||||||
}
|
}
|
||||||
message EnqueueChatTaskResponse { Task task = 1; }
|
message EnqueueChatTaskResponse { Task task = 1; }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user