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.
55 lines
2.8 KiB
Go
55 lines
2.8 KiB
Go
package messaging
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
|
"github.com/samcharles93/archie-core/internal/taskstate"
|
|
)
|
|
|
|
// ChatContract is the conversational boundary consumed by channel frontends.
|
|
// Results are snapshots: callers must not rely on shared object identity.
|
|
// It moved here from internal/gateway (archie-core-8cda.5.6) so the webui
|
|
// and archie-ui processes can hold the contract without linking the gateway
|
|
// runtime (and, transitively, its SQLite session store).
|
|
type ChatContract interface { //nolint:interfacebloat // wire contract intentionally covers the complete Gateway facade
|
|
Snapshot(context.Context) (ChatSnapshot, error)
|
|
GetSession(context.Context, string) (SessionContext, bool, error)
|
|
RecentMessages(context.Context, string, int) ([]Message, error)
|
|
RecentTurns(context.Context, string, int) ([]TurnRecord, error)
|
|
Route(context.Context, Inbound) (ChatReply, error)
|
|
// Stream emits started, delta/tool/media, then done or error, in order.
|
|
// Callers must drain the stream or cancel the context. Cancellation closes it.
|
|
Stream(context.Context, Inbound) (<-chan ChatEvent, error)
|
|
Cancel(context.Context, string) (ChatCancellation, error)
|
|
SetPersona(context.Context, string, string) (bool, error)
|
|
ChatTaskActionContract
|
|
}
|
|
|
|
// ChatTaskActionContract is the operator task mutation capability exposed by
|
|
// the Gateway. It is separate so read/turn consumers do not need to model it.
|
|
type ChatTaskActionContract interface {
|
|
// ApplyTaskAction applies an action on behalf of a chat identity, which
|
|
// may only act on its own tasks. res carries the review gate answer
|
|
// payload; the chat surface has no instruction or selection syntax, so it
|
|
// is the zero value there.
|
|
ApplyTaskAction(context.Context, string, int64, taskstate.Action, taskactions.ReviewResponse) (TaskActionResult, error)
|
|
// ApplyOperatorTaskAction applies an action on behalf of an authenticated
|
|
// dashboard caller, who acts across identities. The actor is who the
|
|
// credential resolved to, or the zero Actor when the caller presented
|
|
// nothing archie could verify -- which is recorded unattributed rather than
|
|
// credited to a human. It is a separate method rather than an empty identity
|
|
// because "" is a real identity in a single-identity deployment (see
|
|
// chatTaskProfiles in the daemon). res carries the review gate answer
|
|
// payload: the operator's finding selection for approve, and the
|
|
// instructions a rereview requires.
|
|
ApplyOperatorTaskAction(context.Context, taskactions.Actor, int64, taskstate.Action, taskactions.ReviewResponse) (TaskActionResult, error)
|
|
}
|
|
|
|
// TaskActionResult is what task_action returns.
|
|
type TaskActionResult struct {
|
|
TaskID int64 `json:"task_id"`
|
|
Action string `json:"action"`
|
|
Message string `json:"message"`
|
|
}
|