Decision 1 of docs/prds/pr-review-operator-response.md: the dashboard's
POST /api/tasks/{id}/action is the authoritative surface, chat's /approve
is a shortcut that posts every offered finding, and both reach the same
Service.Apply so one operator intent cannot be recorded as two decisions.
The action body now carries instructions (required by rereview) and the
finding keys an approve posts. taskactions.Service answers an offer
through the guarded RespondReviewGate write: approve records the
selection on the offer, rereview records the instructions, increments the
round and clears the offer, and a rereview with no instructions, with no
offer, or at the cap is refused as a conflict with nothing written. Chat
reaches the same service: chatTaskControllerAdapter.ApproveChatTask
delegates to b.taskActions() instead of its own requeue, which is what
removed the handler's hardcoded implement handoff -- feasibility's deliver
stage now names implement on the task before it waits, the invariant the
handler needs.
The payload crosses every hop it must: the NATS action request, the
gateway.v1 gRPC contract (regenerated), the LocalChatAdapter, and the
webui handler, which answers 400 for a rereview without instructions and
409 for the cap. A rereview event kind names its actor the way the
approval and rejection trios do.
taskactions.Task gains review_gate and rereview_rounds, and the two
surfaces' tests assert they agree.
92 lines
3.1 KiB
Go
92 lines
3.1 KiB
Go
package telegram
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/messaging"
|
|
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
|
"github.com/samcharles93/archie-core/internal/taskstate"
|
|
)
|
|
|
|
type fakeChatContract struct {
|
|
snapshot messaging.ChatSnapshot
|
|
snapshotErr error
|
|
routeFunc func(ctx context.Context, in messaging.Inbound) (messaging.ChatReply, error)
|
|
streamFunc func(ctx context.Context, in messaging.Inbound) (<-chan messaging.ChatEvent, error)
|
|
cancelFunc func(ctx context.Context, id string) (messaging.ChatCancellation, error)
|
|
setPersonaFunc func(ctx context.Context, id, name string) (bool, error)
|
|
details map[string]messaging.ModelDetails
|
|
}
|
|
|
|
var (
|
|
_ messaging.ChatContract = (*fakeChatContract)(nil)
|
|
_ messaging.DetailedModelManager = (*fakeChatContract)(nil)
|
|
)
|
|
|
|
func (f *fakeChatContract) ModelDetails(ref string) (messaging.ModelDetails, bool) {
|
|
if f.details == nil {
|
|
return messaging.ModelDetails{}, false
|
|
}
|
|
d, ok := f.details[ref]
|
|
return d, ok
|
|
}
|
|
|
|
func (f *fakeChatContract) Snapshot(ctx context.Context) (messaging.ChatSnapshot, error) {
|
|
if f.snapshotErr != nil {
|
|
return messaging.ChatSnapshot{}, f.snapshotErr
|
|
}
|
|
return f.snapshot, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) GetSession(ctx context.Context, id string) (messaging.SessionContext, bool, error) {
|
|
return messaging.SessionContext{}, false, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) RecentMessages(ctx context.Context, id string, n int) ([]messaging.Message, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) RecentTurns(ctx context.Context, id string, n int) ([]messaging.TurnRecord, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) Route(ctx context.Context, in messaging.Inbound) (messaging.ChatReply, error) {
|
|
if f.routeFunc != nil {
|
|
return f.routeFunc(ctx, in)
|
|
}
|
|
return messaging.ChatReply{Text: "ok"}, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) Stream(ctx context.Context, in messaging.Inbound) (<-chan messaging.ChatEvent, error) {
|
|
if f.streamFunc != nil {
|
|
return f.streamFunc(ctx, in)
|
|
}
|
|
ch := make(chan messaging.ChatEvent, 2)
|
|
ch <- messaging.ChatEvent{Kind: "started", SessionID: "s1"}
|
|
ch <- messaging.ChatEvent{Kind: "done", Text: "done", SessionID: "s1"}
|
|
close(ch)
|
|
return ch, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) Cancel(ctx context.Context, id string) (messaging.ChatCancellation, error) {
|
|
if f.cancelFunc != nil {
|
|
return f.cancelFunc(ctx, id)
|
|
}
|
|
return messaging.ChatCancellation{Cancelled: true}, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) SetPersona(ctx context.Context, id, name string) (bool, error) {
|
|
if f.setPersonaFunc != nil {
|
|
return f.setPersonaFunc(ctx, id, name)
|
|
}
|
|
return true, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) ApplyTaskAction(ctx context.Context, identity string, taskID int64, action taskstate.Action, _ taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
|
|
return messaging.TaskActionResult{}, nil
|
|
}
|
|
|
|
func (f *fakeChatContract) ApplyOperatorTaskAction(ctx context.Context, actor taskactions.Actor, taskID int64, action taskstate.Action, _ taskactions.ReviewResponse) (messaging.TaskActionResult, error) {
|
|
return messaging.TaskActionResult{}, nil
|
|
}
|