A retry now carries the operator's worktree choice (refresh onto the base branch or continue the work already pushed on the task branch) from the dashboard through the task action to the daemon dispatch, and persists it on the task row so it survives a reload. The daemon resolves the mode from the task, never from the workflow; BeginRemediation records continue explicitly so a remediation still resumes its pull request branch.
122 lines
4.2 KiB
Go
122 lines
4.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: call_tasks.sql
|
|
|
|
package postgresdb
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const callStatusDetail = `-- name: CallStatusDetail :one
|
|
SELECT detail FROM transitions WHERE task_id = $1 ORDER BY id DESC LIMIT 1
|
|
`
|
|
|
|
// The latest transition detail of one call's callee, the summary a wait:true
|
|
// caller receives (docs/prds/workflow-calls.md).
|
|
func (q *Queries) CallStatusDetail(ctx context.Context, taskID int64) (string, error) {
|
|
row := q.db.QueryRow(ctx, callStatusDetail, taskID)
|
|
var detail string
|
|
err := row.Scan(&detail)
|
|
return detail, err
|
|
}
|
|
|
|
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 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)
|
|
SELECT
|
|
caller.owner,
|
|
caller.repo,
|
|
COALESCE((
|
|
SELECT MAX(existing.issue_number) FROM tasks existing
|
|
WHERE existing.owner = caller.owner
|
|
AND existing.repo = caller.repo
|
|
AND existing.source = 'chat'
|
|
), $2::bigint) + 1,
|
|
$3, $4, 'chat', $5, 'chat', caller.identity,
|
|
caller.org_id, caller.workspace_id, $6,
|
|
caller.id, caller.call_depth + 1
|
|
FROM caller
|
|
WHERE caller.status = 'running' AND caller.call_depth + 1 <= $7::int
|
|
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
|
|
`
|
|
|
|
type EnqueueCallTaskParams struct {
|
|
ID int64
|
|
FallbackIssueNumber int64
|
|
Title string
|
|
Body string
|
|
Workflow string
|
|
Inputs string
|
|
MaxDepth int32
|
|
}
|
|
|
|
// The callee of a workflow.call step (docs/prds/workflow-calls.md). The
|
|
// caller row is read FOR UPDATE, so two steps of the same run cannot race a
|
|
// depth re-check, and the callee inherits the caller's org, workspace,
|
|
// identity, owner and repo: a called workflow works the same run's context
|
|
// under its own definition and profile. The issue number is a fresh
|
|
// synthetic one for the inherited owner/repo, the same allocator
|
|
// InsertChatTask uses. The insert refuses a caller that is not running and
|
|
// a call that would pass the depth limit (the engine checks it too; the
|
|
// store is what owns the table, so it re-checks).
|
|
func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams) (Task, error) {
|
|
row := q.db.QueryRow(ctx, enqueueCallTask,
|
|
arg.ID,
|
|
arg.FallbackIssueNumber,
|
|
arg.Title,
|
|
arg.Body,
|
|
arg.Workflow,
|
|
arg.Inputs,
|
|
arg.MaxDepth,
|
|
)
|
|
var i Task
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Owner,
|
|
&i.Repo,
|
|
&i.IssueNumber,
|
|
&i.Title,
|
|
&i.Body,
|
|
&i.Labels,
|
|
&i.Status,
|
|
&i.Workflow,
|
|
&i.Branch,
|
|
&i.Plan,
|
|
&i.Notes,
|
|
&i.PrNumber,
|
|
&i.TokensUsed,
|
|
&i.Iterations,
|
|
&i.Attempt,
|
|
&i.ParkReason,
|
|
&i.WatchCommentID,
|
|
&i.ParkClass,
|
|
&i.RemediationRounds,
|
|
&i.RetryCount,
|
|
&i.Source,
|
|
&i.Identity,
|
|
&i.BindingID,
|
|
&i.BindingVersion,
|
|
&i.ReviewPayload,
|
|
&i.WorkflowDefinitionVersion,
|
|
&i.WorkflowDefinitionDigest,
|
|
&i.WorkflowDefinitionYaml,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.ReviewCursor,
|
|
&i.Inputs,
|
|
&i.OrgID,
|
|
&i.WorkspaceID,
|
|
&i.CallParentTaskID,
|
|
&i.CallDepth,
|
|
&i.Outputs,
|
|
&i.ReviewGate,
|
|
&i.RereviewRounds,
|
|
&i.RetryMode,
|
|
)
|
|
return i, err
|
|
}
|