Merge branch 'work/mqti13'
# Conflicts: # internal/contracts/state/v1/state.pb.go
This commit is contained in:
commit
cac0f43b58
17 files changed
+1957
-1413
No files matched your search
@@ -0,0 +1,14 @@
|
||||
-- tasks.outcome_posted marks that a chat task's terminal outcome reached the
|
||||
-- conversation that created it. Tasks that finished before this column existed
|
||||
-- were never promised a report.
|
||||
|
||||
-- +goose Up
|
||||
|
||||
ALTER TABLE tasks ADD COLUMN outcome_posted boolean NOT NULL DEFAULT false;
|
||||
UPDATE tasks SET outcome_posted = true;
|
||||
CREATE INDEX idx_tasks_outcome_unposted ON tasks (id) WHERE origin <> '' AND NOT outcome_posted;
|
||||
|
||||
-- +goose Down
|
||||
|
||||
DROP INDEX idx_tasks_outcome_unposted;
|
||||
ALTER TABLE tasks DROP COLUMN outcome_posted;
|
||||
@@ -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 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.outcome_posted FROM tasks t WHERE t.id = $1 FOR UPDATE
|
||||
)
|
||||
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, workspace_id, inputs, call_parent_task_id, call_depth, call_key)
|
||||
SELECT
|
||||
@@ -42,7 +42,7 @@ SELECT
|
||||
FROM caller
|
||||
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
|
||||
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, outcome_posted
|
||||
`
|
||||
|
||||
type EnqueueCallTaskParams struct {
|
||||
@@ -124,6 +124,7 @@ func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -455,6 +455,7 @@ type Task struct {
|
||||
PendingReviews []byte
|
||||
Origin string
|
||||
CallKey string
|
||||
OutcomePosted bool
|
||||
}
|
||||
|
||||
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 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, outcome_posted FROM tasks
|
||||
WHERE origin = $1 AND origin <> '' AND status IN ('queued', 'running') AND ($2::text IS NULL OR org_id = $2)
|
||||
ORDER BY id
|
||||
`
|
||||
@@ -80,6 +80,7 @@ func (q *Queries) ActiveTasksByOrigin(ctx context.Context, arg ActiveTasksByOrig
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -159,7 +160,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
|
||||
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, outcome_posted
|
||||
`
|
||||
|
||||
type ClaimByIssueParams struct {
|
||||
@@ -220,6 +221,7 @@ func (q *Queries) ClaimByIssue(ctx context.Context, arg ClaimByIssueParams) (Tas
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -234,7 +236,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
|
||||
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, outcome_posted
|
||||
`
|
||||
|
||||
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
||||
@@ -293,6 +295,7 @@ func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -406,7 +409,7 @@ FROM (SELECT COALESCE(
|
||||
'org-sys'
|
||||
) AS id) AS owner_org
|
||||
WHERE $10::text IS NULL OR owner_org.id = $10
|
||||
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
|
||||
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, outcome_posted
|
||||
`
|
||||
|
||||
type InsertChatTaskParams struct {
|
||||
@@ -492,6 +495,7 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -719,6 +723,15 @@ func (q *Queries) LockTaskStatus(ctx context.Context, id int64) (string, error)
|
||||
return status, err
|
||||
}
|
||||
|
||||
const markOutcomePosted = `-- name: MarkOutcomePosted :exec
|
||||
UPDATE tasks SET outcome_posted = true WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) MarkOutcomePosted(ctx context.Context, id int64) error {
|
||||
_, err := q.db.Exec(ctx, markOutcomePosted, id)
|
||||
return err
|
||||
}
|
||||
|
||||
const parkTask = `-- name: ParkTask :execrows
|
||||
UPDATE tasks
|
||||
SET status = 'parked', park_reason = $2, park_class = $3, updated_at = now()
|
||||
@@ -934,7 +947,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 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, outcome_posted FROM tasks WHERE id = $1 AND ($2::text IS NULL OR org_id = $2)
|
||||
`
|
||||
|
||||
type TaskByIDParams struct {
|
||||
@@ -992,12 +1005,13 @@ func (q *Queries) TaskByID(ctx context.Context, arg TaskByIDParams) (Task, error
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
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 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, outcome_posted FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
|
||||
AND ($4::text IS NULL OR org_id = $4)
|
||||
`
|
||||
|
||||
@@ -1063,12 +1077,13 @@ func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task,
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
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 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, outcome_posted FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3 AND status = $4
|
||||
AND ($5::text IS NULL OR org_id = $5)
|
||||
`
|
||||
|
||||
@@ -1139,6 +1154,7 @@ func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error
|
||||
&i.PendingReviews,
|
||||
&i.Origin,
|
||||
&i.CallKey,
|
||||
&i.OutcomePosted,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -1176,6 +1192,84 @@ func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams)
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
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, outcome_posted FROM tasks
|
||||
WHERE origin <> '' AND NOT outcome_posted
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed')
|
||||
AND ($1::text IS NULL OR org_id = $1)
|
||||
ORDER BY id
|
||||
LIMIT 50
|
||||
`
|
||||
|
||||
// Finished chat tasks whose outcome has not reached their conversation yet.
|
||||
func (q *Queries) UnpostedOutcomes(ctx context.Context, scopeOrg pgtype.Text) ([]Task, error) {
|
||||
rows, err := q.db.Query(ctx, unpostedOutcomes, scopeOrg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Task
|
||||
for rows.Next() {
|
||||
var i Task
|
||||
if err := rows.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.OutcomePosted,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const updateTask = `-- name: UpdateTask :exec
|
||||
UPDATE tasks SET workflow = $1, branch = $2, plan = $3, notes = $4,
|
||||
pr_number = $5, tokens_used = $6, iterations = $7, park_reason = $8,
|
||||
|
||||
@@ -93,6 +93,18 @@ SELECT * FROM tasks
|
||||
WHERE origin = sqlc.arg(origin) AND origin <> '' AND status IN ('queued', 'running') AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
ORDER BY id;
|
||||
|
||||
-- name: UnpostedOutcomes :many
|
||||
-- Finished chat tasks whose outcome has not reached their conversation yet.
|
||||
SELECT * FROM tasks
|
||||
WHERE origin <> '' AND NOT outcome_posted
|
||||
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed')
|
||||
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
|
||||
ORDER BY id
|
||||
LIMIT 50;
|
||||
|
||||
-- name: MarkOutcomePosted :exec
|
||||
UPDATE tasks SET outcome_posted = true WHERE id = $1;
|
||||
|
||||
-- name: StampTaskBinding :exec
|
||||
UPDATE tasks SET binding_id = $2, binding_version = $3 WHERE id = $1;
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ func taskFromRow(t postgresdb.Task) *workflow.Task {
|
||||
RemediationRounds: int(t.RemediationRounds),
|
||||
CallParentTaskID: t.CallParentTaskID,
|
||||
CallDepth: int(t.CallDepth),
|
||||
Origin: t.Origin,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
}
|
||||
@@ -865,6 +866,28 @@ func (s *Store) CallStatus(ctx context.Context, callerTaskID, callTaskID int64)
|
||||
return callee.Status, detail, outputs, nil
|
||||
}
|
||||
|
||||
// UnpostedOutcomes returns finished chat tasks whose outcome has not been
|
||||
// posted to their conversation.
|
||||
func (s *Store) UnpostedOutcomes(ctx context.Context) ([]*workflow.Task, error) {
|
||||
rows, err := s.queries().UnpostedOutcomes(ctx, scopeOrg(ctx))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("store: unposted outcomes: %w", err)
|
||||
}
|
||||
out := make([]*workflow.Task, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
out = append(out, taskFromRow(row))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MarkOutcomePosted records that a task's outcome reached its conversation.
|
||||
func (s *Store) MarkOutcomePosted(ctx context.Context, taskID int64) error {
|
||||
if err := s.queries().MarkOutcomePosted(ctx, taskID); err != nil {
|
||||
return fmt.Errorf("store: mark outcome posted: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ActiveTasksByOrigin returns the queued and running tasks the conversation
|
||||
// origin created.
|
||||
func (s *Store) ActiveTasksByOrigin(ctx context.Context, origin string) ([]*workflow.Task, error) {
|
||||
|
||||
Reference in new issue
Block a user