Files
archie/internal/infrastructure/postgres/postgresdb/call_tasks.sql.go
T
sam cf2942c97a feat(workflow): render a PRD's generated view on the plan approval card
agent.run gains views: the agent may return an OpenUI Lang view of its
answer through an optional view tool, read as steps.<id>.view. human.approve
stores it as the task's plan_view, and the approval card renders it with
the dashboard's own components, falling back to the plan text when there
is no view or it does not parse. The feasibility prd step uses it.
2026-10-25 16:33:04 +11:00

143 lines
5.4 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, t.resume_from, t.resume_results, t.pending_reviews, t.origin, t.call_key, t.binding_signature, t.binding_addr, t.park_blocker, t.outcome_posted_status, t.plan_view FROM tasks t WHERE t.id = $1 FOR UPDATE
), number AS (
INSERT INTO chat_issue_numbers (owner, repo, last_number)
SELECT caller.owner, caller.repo, $9::bigint + 1 FROM caller
ON CONFLICT (owner, repo) DO UPDATE SET last_number = chat_issue_numbers.last_number + 1
RETURNING last_number
)
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
caller.owner,
caller.repo,
number.last_number,
$2, $3, 'chat', $4,
CASE WHEN caller.source = 'test' THEN 'test' ELSE 'chat' END, $5,
caller.org_id, caller.workspace_id, $6,
caller.id, caller.call_depth + 1, $7
FROM caller, number
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, binding_signature, binding_addr, park_blocker, outcome_posted_status, plan_view
`
type EnqueueCallTaskParams struct {
ID int64
Title string
Body string
Workflow string
Identity string
Inputs string
CallKey string
MaxDepth int32
FallbackIssueNumber int64
}
// The callee of a workflow.call step (docs/prds/workflow-calls.md)
//
// The call key makes this the one write that can be retried: a call site that
// already started its child gets that child back rather than a second one. The
// upsert only fires for a keyed callee whose child can still do the work -- a
// child that ended dead or closed_wont_do freed its key -- and the WHERE below
// still decides whether the caller may call at all: a caller that is missing,
// not running or past the depth limit inserts nothing and returns no row,
// conflict or not. The issue number comes from chat_issue_numbers, as for
// InsertChatTask. The callee is started by the identity the caller's
// workflow declares, read from its pinned definition: a callee never inherits the
// identity that started its caller, and runs as the one its own workflow
// declares. A callee of a test run is a test run too, so it cannot write to a
// forge either.
func (q *Queries) EnqueueCallTask(ctx context.Context, arg EnqueueCallTaskParams) (Task, error) {
row := q.db.QueryRow(ctx, enqueueCallTask,
arg.ID,
arg.Title,
arg.Body,
arg.Workflow,
arg.Identity,
arg.Inputs,
arg.CallKey,
arg.MaxDepth,
arg.FallbackIssueNumber,
)
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,
&i.ResumeFrom,
&i.ResumeResults,
&i.PendingReviews,
&i.Origin,
&i.CallKey,
&i.BindingSignature,
&i.BindingAddr,
&i.ParkBlocker,
&i.OutcomePostedStatus,
&i.PlanView,
)
return i, err
}