feat(workflows): test-run unsaved drafts and browse workflow version history
A test run pins a validated draft, runs with forge and push writes suppressed and recorded per step, and is excluded from workflow stats. The History tab lists revisions that changed a workflow, diffs them as YAML and on the canvas, restores into the editor, and ties runs to the revision they used.
This commit is contained in:
37 files changed
+677
-132
No files matched your search
@@ -391,24 +391,28 @@ func (q *Queries) EnqueueIssue(ctx context.Context, arg EnqueueIssueParams) (int
|
||||
const insertChatTask = `-- name: InsertChatTask :one
|
||||
WITH number AS (
|
||||
INSERT INTO chat_issue_numbers (owner, repo, last_number)
|
||||
VALUES ($1, $2, $10::bigint + 1)
|
||||
VALUES ($1, $2, $12::bigint + 1)
|
||||
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, inputs, origin)
|
||||
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity, org_id, inputs, origin, workflow_definition_yaml, workflow_definition_digest)
|
||||
SELECT
|
||||
$1, $2, number.last_number,
|
||||
$3, $4, 'chat', $5, 'chat', $6,
|
||||
owner_org.id,
|
||||
$3, $4, 'chat', $5,
|
||||
CASE WHEN $6::text = '' THEN 'chat' ELSE 'test' END,
|
||||
$7,
|
||||
$8
|
||||
owner_org.id,
|
||||
$8,
|
||||
$9,
|
||||
$6::text,
|
||||
$10::text
|
||||
FROM number, (SELECT COALESCE(
|
||||
(SELECT a.org_id FROM org_agents a WHERE a.identity_id = $6),
|
||||
(SELECT m.org_id FROM memberships m WHERE m.identity_id = $6
|
||||
(SELECT a.org_id FROM org_agents a WHERE a.identity_id = $7),
|
||||
(SELECT m.org_id FROM memberships m WHERE m.identity_id = $7
|
||||
ORDER BY m.created_at, m.org_id, m.workspace_id NULLS LAST LIMIT 1),
|
||||
'org-sys'
|
||||
) AS id) AS owner_org
|
||||
WHERE $9::text IS NULL OR owner_org.id = $9
|
||||
WHERE $11::text IS NULL OR owner_org.id = $11
|
||||
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
|
||||
`
|
||||
|
||||
@@ -418,9 +422,11 @@ type InsertChatTaskParams struct {
|
||||
Title string
|
||||
Body string
|
||||
Workflow string
|
||||
DraftYaml string
|
||||
Identity string
|
||||
Inputs string
|
||||
Origin string
|
||||
DraftDigest string
|
||||
ScopeOrg pgtype.Text
|
||||
FallbackIssueNumber int64
|
||||
}
|
||||
@@ -435,6 +441,8 @@ type InsertChatTaskParams struct {
|
||||
// StampTaskBinding adds only the provenance.
|
||||
// The task runs in its identity's org; a caller confined to another org
|
||||
// inserts nothing, so it cannot start work under an identity it does not own.
|
||||
// A non-empty draft_yaml makes the task a test run: it is pinned to that
|
||||
// definition and its source is 'test'.
|
||||
func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, insertChatTask,
|
||||
arg.Owner,
|
||||
@@ -442,9 +450,11 @@ func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams)
|
||||
arg.Title,
|
||||
arg.Body,
|
||||
arg.Workflow,
|
||||
arg.DraftYaml,
|
||||
arg.Identity,
|
||||
arg.Inputs,
|
||||
arg.Origin,
|
||||
arg.DraftDigest,
|
||||
arg.ScopeOrg,
|
||||
arg.FallbackIssueNumber,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user