You've already forked agentic-coding-workflow
bugfix
This commit is contained in:
@@ -11,10 +11,38 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const approveRequirementArtifact = `-- name: ApproveRequirementArtifact :one
|
||||
UPDATE requirement_artifacts SET verdict = $2 WHERE id = $1
|
||||
RETURNING id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at, verdict
|
||||
`
|
||||
|
||||
type ApproveRequirementArtifactParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Verdict string `json:"verdict"`
|
||||
}
|
||||
|
||||
func (q *Queries) ApproveRequirementArtifact(ctx context.Context, arg ApproveRequirementArtifactParams) (RequirementArtifact, error) {
|
||||
row := q.db.QueryRow(ctx, approveRequirementArtifact, arg.ID, arg.Verdict)
|
||||
var i RequirementArtifact
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.RequirementID,
|
||||
&i.Phase,
|
||||
&i.Version,
|
||||
&i.Content,
|
||||
&i.Note,
|
||||
&i.SourceMessageID,
|
||||
&i.CreatedBy,
|
||||
&i.CreatedAt,
|
||||
&i.Verdict,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const createRequirementArtifact = `-- name: CreateRequirementArtifact :one
|
||||
INSERT INTO requirement_artifacts (id, requirement_id, phase, version, content, note, source_message_id, created_by)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at
|
||||
RETURNING id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at, verdict
|
||||
`
|
||||
|
||||
type CreateRequirementArtifactParams struct {
|
||||
@@ -50,6 +78,7 @@ func (q *Queries) CreateRequirementArtifact(ctx context.Context, arg CreateRequi
|
||||
&i.SourceMessageID,
|
||||
&i.CreatedBy,
|
||||
&i.CreatedAt,
|
||||
&i.Verdict,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -71,8 +100,32 @@ func (q *Queries) GetMaxRequirementArtifactVersion(ctx context.Context, arg GetM
|
||||
return column_1, err
|
||||
}
|
||||
|
||||
const getRequirementArtifactByID = `-- name: GetRequirementArtifactByID :one
|
||||
SELECT id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at, verdict
|
||||
FROM requirement_artifacts
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetRequirementArtifactByID(ctx context.Context, id pgtype.UUID) (RequirementArtifact, error) {
|
||||
row := q.db.QueryRow(ctx, getRequirementArtifactByID, id)
|
||||
var i RequirementArtifact
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.RequirementID,
|
||||
&i.Phase,
|
||||
&i.Version,
|
||||
&i.Content,
|
||||
&i.Note,
|
||||
&i.SourceMessageID,
|
||||
&i.CreatedBy,
|
||||
&i.CreatedAt,
|
||||
&i.Verdict,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getRequirementArtifactByVersion = `-- name: GetRequirementArtifactByVersion :one
|
||||
SELECT id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at
|
||||
SELECT id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at, verdict
|
||||
FROM requirement_artifacts
|
||||
WHERE requirement_id = $1 AND phase = $2 AND version = $3
|
||||
`
|
||||
@@ -96,12 +149,13 @@ func (q *Queries) GetRequirementArtifactByVersion(ctx context.Context, arg GetRe
|
||||
&i.SourceMessageID,
|
||||
&i.CreatedBy,
|
||||
&i.CreatedAt,
|
||||
&i.Verdict,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listRequirementArtifactsByRequirement = `-- name: ListRequirementArtifactsByRequirement :many
|
||||
SELECT id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at
|
||||
SELECT id, requirement_id, phase, version, content, note, source_message_id, created_by, created_at, verdict
|
||||
FROM requirement_artifacts
|
||||
WHERE requirement_id = $1 AND ($2::text = '' OR phase = $2)
|
||||
ORDER BY phase ASC, version ASC
|
||||
@@ -131,6 +185,7 @@ func (q *Queries) ListRequirementArtifactsByRequirement(ctx context.Context, arg
|
||||
&i.SourceMessageID,
|
||||
&i.CreatedBy,
|
||||
&i.CreatedAt,
|
||||
&i.Verdict,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: dependencies.sql
|
||||
|
||||
package projectsqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const countActiveSessionsForProject = `-- name: CountActiveSessionsForProject :one
|
||||
SELECT COUNT(*) FROM acp_sessions
|
||||
WHERE project_id = $1 AND status IN ('starting', 'running')
|
||||
`
|
||||
|
||||
// Active (starting/running) acp_sessions in a project. Used by the scheduler's
|
||||
// soft per-project concurrency pre-check.
|
||||
func (q *Queries) CountActiveSessionsForProject(ctx context.Context, projectID pgtype.UUID) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countActiveSessionsForProject, projectID)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const createDependency = `-- name: CreateDependency :one
|
||||
INSERT INTO issue_dependencies (id, project_id, blocked_id, blocker_id, created_by)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING id, project_id, blocked_id, blocker_id, created_by, created_at
|
||||
`
|
||||
|
||||
type CreateDependencyParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
BlockedID pgtype.UUID `json:"blocked_id"`
|
||||
BlockerID pgtype.UUID `json:"blocker_id"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateDependency(ctx context.Context, arg CreateDependencyParams) (IssueDependency, error) {
|
||||
row := q.db.QueryRow(ctx, createDependency,
|
||||
arg.ID,
|
||||
arg.ProjectID,
|
||||
arg.BlockedID,
|
||||
arg.BlockerID,
|
||||
arg.CreatedBy,
|
||||
)
|
||||
var i IssueDependency
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.BlockedID,
|
||||
&i.BlockerID,
|
||||
&i.CreatedBy,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const deleteDependency = `-- name: DeleteDependency :execrows
|
||||
DELETE FROM issue_dependencies
|
||||
WHERE project_id = $1 AND blocked_id = $2 AND blocker_id = $3
|
||||
`
|
||||
|
||||
type DeleteDependencyParams struct {
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
BlockedID pgtype.UUID `json:"blocked_id"`
|
||||
BlockerID pgtype.UUID `json:"blocker_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteDependency(ctx context.Context, arg DeleteDependencyParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, deleteDependency, arg.ProjectID, arg.BlockedID, arg.BlockerID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const listBlocked = `-- name: ListBlocked :many
|
||||
SELECT i.id, i.project_id, i.requirement_id, i.number, i.title, i.description, i.status,
|
||||
i.assignee_id, i.created_by, i.closed_at, i.created_at, i.updated_at, i.workspace_id, i.parent_id, i.priority
|
||||
FROM issue_dependencies d
|
||||
JOIN issues i ON i.id = d.blocked_id
|
||||
WHERE d.blocker_id = $1
|
||||
ORDER BY i.number ASC
|
||||
`
|
||||
|
||||
// Issues blocked by $1 (issues that depend on blocker $1).
|
||||
func (q *Queries) ListBlocked(ctx context.Context, blockerID pgtype.UUID) ([]Issue, error) {
|
||||
rows, err := q.db.Query(ctx, listBlocked, blockerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Issue
|
||||
for rows.Next() {
|
||||
var i Issue
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.RequirementID,
|
||||
&i.Number,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Status,
|
||||
&i.AssigneeID,
|
||||
&i.CreatedBy,
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listBlockerIDs = `-- name: ListBlockerIDs :many
|
||||
SELECT blocker_id FROM issue_dependencies WHERE blocked_id = $1
|
||||
`
|
||||
|
||||
// Direct blocker issue ids of $1 (one hop along blocked-by edges). Used by the
|
||||
// service-layer iterative reachability cycle check in AddDependency.
|
||||
func (q *Queries) ListBlockerIDs(ctx context.Context, blockedID pgtype.UUID) ([]pgtype.UUID, error) {
|
||||
rows, err := q.db.Query(ctx, listBlockerIDs, blockedID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []pgtype.UUID
|
||||
for rows.Next() {
|
||||
var blocker_id pgtype.UUID
|
||||
if err := rows.Scan(&blocker_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, blocker_id)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listBlockers = `-- name: ListBlockers :many
|
||||
SELECT i.id, i.project_id, i.requirement_id, i.number, i.title, i.description, i.status,
|
||||
i.assignee_id, i.created_by, i.closed_at, i.created_at, i.updated_at, i.workspace_id, i.parent_id, i.priority
|
||||
FROM issue_dependencies d
|
||||
JOIN issues i ON i.id = d.blocker_id
|
||||
WHERE d.blocked_id = $1
|
||||
ORDER BY i.number ASC
|
||||
`
|
||||
|
||||
// Issues that block $1 (the dependencies of blocked issue $1).
|
||||
func (q *Queries) ListBlockers(ctx context.Context, blockedID pgtype.UUID) ([]Issue, error) {
|
||||
rows, err := q.db.Query(ctx, listBlockers, blockedID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Issue
|
||||
for rows.Next() {
|
||||
var i Issue
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.RequirementID,
|
||||
&i.Number,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Status,
|
||||
&i.AssigneeID,
|
||||
&i.CreatedBy,
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listReadyLeafSubtasks = `-- name: ListReadyLeafSubtasks :many
|
||||
SELECT i.id, i.project_id, i.requirement_id, i.number, i.title, i.description, i.status,
|
||||
i.assignee_id, i.created_by, i.closed_at, i.created_at, i.updated_at, i.workspace_id, i.parent_id, i.priority
|
||||
FROM issues i
|
||||
WHERE i.project_id = $1
|
||||
AND i.status = 'open'
|
||||
AND i.parent_id IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM issue_dependencies d
|
||||
JOIN issues b ON b.id = d.blocker_id
|
||||
WHERE d.blocked_id = i.id AND b.status <> 'closed'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM acp_sessions s
|
||||
WHERE s.issue_id = i.id AND s.status IN ('starting', 'running')
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM issues c
|
||||
WHERE c.parent_id = i.id AND c.status = 'open'
|
||||
)
|
||||
ORDER BY i.priority DESC, i.number ASC
|
||||
LIMIT $2
|
||||
`
|
||||
|
||||
type ListReadyLeafSubtasksParams struct {
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
Limit int32 `json:"limit"`
|
||||
}
|
||||
|
||||
// Ready leaf subtasks for a project: open subtasks (parent_id NOT NULL) whose
|
||||
// every blocker is closed, with no active (starting/running) acp_session, and
|
||||
// no open child issue (leaf). Ordered by priority DESC, number ASC. LIMIT $2.
|
||||
func (q *Queries) ListReadyLeafSubtasks(ctx context.Context, arg ListReadyLeafSubtasksParams) ([]Issue, error) {
|
||||
rows, err := q.db.Query(ctx, listReadyLeafSubtasks, arg.ProjectID, arg.Limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Issue
|
||||
for rows.Next() {
|
||||
var i Issue
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.RequirementID,
|
||||
&i.Number,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Status,
|
||||
&i.AssigneeID,
|
||||
&i.CreatedBy,
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listSchedulableProjects = `-- name: ListSchedulableProjects :many
|
||||
SELECT DISTINCT i.project_id
|
||||
FROM issues i
|
||||
WHERE i.status = 'open'
|
||||
AND i.parent_id IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM issue_dependencies d
|
||||
JOIN issues b ON b.id = d.blocker_id
|
||||
WHERE d.blocked_id = i.id AND b.status <> 'closed'
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM acp_sessions s
|
||||
WHERE s.issue_id = i.id AND s.status IN ('starting', 'running')
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM issues c
|
||||
WHERE c.parent_id = i.id AND c.status = 'open'
|
||||
)
|
||||
`
|
||||
|
||||
// Distinct project ids that currently have at least one ready leaf subtask
|
||||
// (open subtask whose blockers are all closed and no active session). Cheap
|
||||
// pre-filter so the scheduler only iterates projects with pending work.
|
||||
func (q *Queries) ListSchedulableProjects(ctx context.Context) ([]pgtype.UUID, error) {
|
||||
rows, err := q.db.Query(ctx, listSchedulableProjects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []pgtype.UUID
|
||||
for rows.Next() {
|
||||
var project_id pgtype.UUID
|
||||
if err := rows.Scan(&project_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, project_id)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listSubtasks = `-- name: ListSubtasks :many
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
FROM issues
|
||||
WHERE parent_id = $1
|
||||
ORDER BY priority DESC, number ASC
|
||||
`
|
||||
|
||||
func (q *Queries) ListSubtasks(ctx context.Context, parentID pgtype.UUID) ([]Issue, error) {
|
||||
rows, err := q.db.Query(ctx, listSubtasks, parentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Issue
|
||||
for rows.Next() {
|
||||
var i Issue
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.RequirementID,
|
||||
&i.Number,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Status,
|
||||
&i.AssigneeID,
|
||||
&i.CreatedBy,
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
@@ -22,14 +22,14 @@ func (q *Queries) CloseIssue(ctx context.Context, id pgtype.UUID) error {
|
||||
}
|
||||
|
||||
const createIssue = `-- name: CreateIssue :one
|
||||
INSERT INTO issues (id, project_id, requirement_id, number, title, description, assignee_id, created_by, workspace_id)
|
||||
INSERT INTO issues (id, project_id, requirement_id, number, title, description, assignee_id, created_by, workspace_id, parent_id, priority)
|
||||
VALUES (
|
||||
$1, $2, $3,
|
||||
(SELECT COALESCE(MAX(number), 0) + 1 FROM issues WHERE project_id = $2),
|
||||
$4, $5, $6, $7, $8
|
||||
$4, $5, $6, $7, $8, $9, $10
|
||||
)
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
`
|
||||
|
||||
type CreateIssueParams struct {
|
||||
@@ -41,6 +41,8 @@ type CreateIssueParams struct {
|
||||
AssigneeID pgtype.UUID `json:"assignee_id"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
ParentID pgtype.UUID `json:"parent_id"`
|
||||
Priority int32 `json:"priority"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue, error) {
|
||||
@@ -53,6 +55,8 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
|
||||
arg.AssigneeID,
|
||||
arg.CreatedBy,
|
||||
arg.WorkspaceID,
|
||||
arg.ParentID,
|
||||
arg.Priority,
|
||||
)
|
||||
var i Issue
|
||||
err := row.Scan(
|
||||
@@ -69,13 +73,45 @@ func (q *Queries) CreateIssue(ctx context.Context, arg CreateIssueParams) (Issue
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getIssueByID = `-- name: GetIssueByID :one
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
FROM issues
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetIssueByID(ctx context.Context, id pgtype.UUID) (Issue, error) {
|
||||
row := q.db.QueryRow(ctx, getIssueByID, id)
|
||||
var i Issue
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.RequirementID,
|
||||
&i.Number,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Status,
|
||||
&i.AssigneeID,
|
||||
&i.CreatedBy,
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getIssueByNumber = `-- name: GetIssueByNumber :one
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
FROM issues
|
||||
WHERE project_id = $1 AND number = $2
|
||||
`
|
||||
@@ -102,13 +138,15 @@ func (q *Queries) GetIssueByNumber(ctx context.Context, arg GetIssueByNumberPara
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listIssues = `-- name: ListIssues :many
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
FROM issues
|
||||
WHERE project_id = $1
|
||||
AND ($2::text IS NULL OR status = $2)
|
||||
@@ -158,6 +196,8 @@ func (q *Queries) ListIssues(ctx context.Context, arg ListIssuesParams) ([]Issue
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,7 +211,7 @@ func (q *Queries) ListIssues(ctx context.Context, arg ListIssuesParams) ([]Issue
|
||||
|
||||
const listIssuesByRequirement = `-- name: ListIssuesByRequirement :many
|
||||
SELECT id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
FROM issues
|
||||
WHERE requirement_id = $1
|
||||
ORDER BY number DESC
|
||||
@@ -200,6 +240,8 @@ func (q *Queries) ListIssuesByRequirement(ctx context.Context, requirementID pgt
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -226,7 +268,7 @@ UPDATE issues
|
||||
SET assignee_id = $2, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
`
|
||||
|
||||
type UpdateIssueAssigneeParams struct {
|
||||
@@ -251,6 +293,8 @@ func (q *Queries) UpdateIssueAssignee(ctx context.Context, arg UpdateIssueAssign
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@@ -264,7 +308,7 @@ SET title = $2,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
`
|
||||
|
||||
type UpdateIssueCoreParams struct {
|
||||
@@ -298,6 +342,44 @@ func (q *Queries) UpdateIssueCore(ctx context.Context, arg UpdateIssueCoreParams
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateIssuePriority = `-- name: UpdateIssuePriority :one
|
||||
UPDATE issues
|
||||
SET priority = $2, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, project_id, requirement_id, number, title, description, status,
|
||||
assignee_id, created_by, closed_at, created_at, updated_at, workspace_id, parent_id, priority
|
||||
`
|
||||
|
||||
type UpdateIssuePriorityParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Priority int32 `json:"priority"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateIssuePriority(ctx context.Context, arg UpdateIssuePriorityParams) (Issue, error) {
|
||||
row := q.db.QueryRow(ctx, updateIssuePriority, arg.ID, arg.Priority)
|
||||
var i Issue
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.ProjectID,
|
||||
&i.RequirementID,
|
||||
&i.Number,
|
||||
&i.Title,
|
||||
&i.Description,
|
||||
&i.Status,
|
||||
&i.AssigneeID,
|
||||
&i.CreatedBy,
|
||||
&i.ClosedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.WorkspaceID,
|
||||
&i.ParentID,
|
||||
&i.Priority,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: members.sql
|
||||
|
||||
package projectsqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const deleteProjectMember = `-- name: DeleteProjectMember :execrows
|
||||
DELETE FROM project_members
|
||||
WHERE project_id = $1 AND user_id = $2
|
||||
`
|
||||
|
||||
type DeleteProjectMemberParams struct {
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteProjectMember(ctx context.Context, arg DeleteProjectMemberParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, deleteProjectMember, arg.ProjectID, arg.UserID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const getProjectMember = `-- name: GetProjectMember :one
|
||||
SELECT project_id, user_id, role, created_at, added_by
|
||||
FROM project_members
|
||||
WHERE project_id = $1 AND user_id = $2
|
||||
`
|
||||
|
||||
type GetProjectMemberParams struct {
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetProjectMember(ctx context.Context, arg GetProjectMemberParams) (ProjectMember, error) {
|
||||
row := q.db.QueryRow(ctx, getProjectMember, arg.ProjectID, arg.UserID)
|
||||
var i ProjectMember
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.UserID,
|
||||
&i.Role,
|
||||
&i.CreatedAt,
|
||||
&i.AddedBy,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listProjectMembers = `-- name: ListProjectMembers :many
|
||||
SELECT project_id, user_id, role, created_at, added_by
|
||||
FROM project_members
|
||||
WHERE project_id = $1
|
||||
ORDER BY created_at ASC
|
||||
`
|
||||
|
||||
func (q *Queries) ListProjectMembers(ctx context.Context, projectID pgtype.UUID) ([]ProjectMember, error) {
|
||||
rows, err := q.db.Query(ctx, listProjectMembers, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ProjectMember
|
||||
for rows.Next() {
|
||||
var i ProjectMember
|
||||
if err := rows.Scan(
|
||||
&i.ProjectID,
|
||||
&i.UserID,
|
||||
&i.Role,
|
||||
&i.CreatedAt,
|
||||
&i.AddedBy,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const upsertProjectMember = `-- name: UpsertProjectMember :one
|
||||
INSERT INTO project_members (project_id, user_id, role, added_by)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
ON CONFLICT (project_id, user_id)
|
||||
DO UPDATE SET role = EXCLUDED.role
|
||||
RETURNING project_id, user_id, role, created_at, added_by
|
||||
`
|
||||
|
||||
type UpsertProjectMemberParams struct {
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
Role string `json:"role"`
|
||||
AddedBy pgtype.UUID `json:"added_by"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertProjectMember(ctx context.Context, arg UpsertProjectMemberParams) (ProjectMember, error) {
|
||||
row := q.db.QueryRow(ctx, upsertProjectMember,
|
||||
arg.ProjectID,
|
||||
arg.UserID,
|
||||
arg.Role,
|
||||
arg.AddedBy,
|
||||
)
|
||||
var i ProjectMember
|
||||
err := row.Scan(
|
||||
&i.ProjectID,
|
||||
&i.UserID,
|
||||
&i.Role,
|
||||
&i.CreatedAt,
|
||||
&i.AddedBy,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
+240
-17
@@ -8,6 +8,7 @@ import (
|
||||
"net/netip"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/pgvector/pgvector-go"
|
||||
)
|
||||
|
||||
type AcpAgentKind struct {
|
||||
@@ -25,6 +26,11 @@ type AcpAgentKind struct {
|
||||
ToolAllowlist []string `json:"tool_allowlist"`
|
||||
ClientType string `json:"client_type"`
|
||||
EncryptedMcpServers []byte `json:"encrypted_mcp_servers"`
|
||||
ModelID pgtype.UUID `json:"model_id"`
|
||||
MaxCostUsd pgtype.Numeric `json:"max_cost_usd"`
|
||||
MaxTokens *int64 `json:"max_tokens"`
|
||||
MaxWallClockSeconds *int32 `json:"max_wall_clock_seconds"`
|
||||
KeyVersion int16 `json:"key_version"`
|
||||
}
|
||||
|
||||
type AcpAgentKindConfigFile struct {
|
||||
@@ -35,6 +41,7 @@ type AcpAgentKindConfigFile struct {
|
||||
UpdatedBy pgtype.UUID `json:"updated_by"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
KeyVersion int16 `json:"key_version"`
|
||||
}
|
||||
|
||||
type AcpEvent struct {
|
||||
@@ -64,23 +71,64 @@ type AcpPermissionRequest struct {
|
||||
}
|
||||
|
||||
type AcpSession struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
AgentKindID pgtype.UUID `json:"agent_kind_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
IssueID pgtype.UUID `json:"issue_id"`
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
AgentSessionID *string `json:"agent_session_id"`
|
||||
Branch string `json:"branch"`
|
||||
CwdPath string `json:"cwd_path"`
|
||||
IsMainWorktree bool `json:"is_main_worktree"`
|
||||
Status string `json:"status"`
|
||||
Pid *int32 `json:"pid"`
|
||||
ExitCode *int32 `json:"exit_code"`
|
||||
LastError *string `json:"last_error"`
|
||||
StartedAt pgtype.Timestamptz `json:"started_at"`
|
||||
EndedAt pgtype.Timestamptz `json:"ended_at"`
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
AgentKindID pgtype.UUID `json:"agent_kind_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
IssueID pgtype.UUID `json:"issue_id"`
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
AgentSessionID *string `json:"agent_session_id"`
|
||||
Branch string `json:"branch"`
|
||||
CwdPath string `json:"cwd_path"`
|
||||
IsMainWorktree bool `json:"is_main_worktree"`
|
||||
Status string `json:"status"`
|
||||
Pid *int32 `json:"pid"`
|
||||
ExitCode *int32 `json:"exit_code"`
|
||||
LastError *string `json:"last_error"`
|
||||
StartedAt pgtype.Timestamptz `json:"started_at"`
|
||||
EndedAt pgtype.Timestamptz `json:"ended_at"`
|
||||
LastStopReason *string `json:"last_stop_reason"`
|
||||
OrchestratorStepID pgtype.UUID `json:"orchestrator_step_id"`
|
||||
PromptTokens int64 `json:"prompt_tokens"`
|
||||
CompletionTokens int64 `json:"completion_tokens"`
|
||||
ThinkingTokens int64 `json:"thinking_tokens"`
|
||||
TotalCostUsd pgtype.Numeric `json:"total_cost_usd"`
|
||||
LastActivityAt pgtype.Timestamptz `json:"last_activity_at"`
|
||||
BudgetMaxCostUsd pgtype.Numeric `json:"budget_max_cost_usd"`
|
||||
BudgetMaxTokens *int64 `json:"budget_max_tokens"`
|
||||
BudgetMaxWallClockSeconds *int32 `json:"budget_max_wall_clock_seconds"`
|
||||
TerminatedReason *string `json:"terminated_reason"`
|
||||
SandboxMode *string `json:"sandbox_mode"`
|
||||
CostUsd pgtype.Numeric `json:"cost_usd"`
|
||||
TokensTotal int64 `json:"tokens_total"`
|
||||
}
|
||||
|
||||
type AcpSessionUsage struct {
|
||||
ID int64 `json:"id"`
|
||||
SessionID pgtype.UUID `json:"session_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
AgentKindID pgtype.UUID `json:"agent_kind_id"`
|
||||
ModelID pgtype.UUID `json:"model_id"`
|
||||
PromptTokens int64 `json:"prompt_tokens"`
|
||||
CompletionTokens int64 `json:"completion_tokens"`
|
||||
ThinkingTokens int64 `json:"thinking_tokens"`
|
||||
CostUsd pgtype.Numeric `json:"cost_usd"`
|
||||
SourceEventID *int64 `json:"source_event_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type AcpTurn struct {
|
||||
ID int64 `json:"id"`
|
||||
SessionID pgtype.UUID `json:"session_id"`
|
||||
TurnIndex int32 `json:"turn_index"`
|
||||
PromptRequestID *string `json:"prompt_request_id"`
|
||||
Status string `json:"status"`
|
||||
StopReason *string `json:"stop_reason"`
|
||||
UpdateCount int32 `json:"update_count"`
|
||||
StartedAt pgtype.Timestamptz `json:"started_at"`
|
||||
CompletedAt pgtype.Timestamptz `json:"completed_at"`
|
||||
}
|
||||
|
||||
type AuditLog struct {
|
||||
@@ -94,6 +142,81 @@ type AuditLog struct {
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type ChangeRequest struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
IssueID pgtype.UUID `json:"issue_id"`
|
||||
Number int32 `json:"number"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
SourceBranch string `json:"source_branch"`
|
||||
TargetBranch string `json:"target_branch"`
|
||||
State string `json:"state"`
|
||||
ReviewVerdict string `json:"review_verdict"`
|
||||
CiState string `json:"ci_state"`
|
||||
Provider string `json:"provider"`
|
||||
ExternalID *int64 `json:"external_id"`
|
||||
ExternalUrl string `json:"external_url"`
|
||||
MergeCommitSha string `json:"merge_commit_sha"`
|
||||
ReviewedBy pgtype.UUID `json:"reviewed_by"`
|
||||
ReviewedAt pgtype.Timestamptz `json:"reviewed_at"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
MergedAt pgtype.Timestamptz `json:"merged_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CodeChunk struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
RunID pgtype.UUID `json:"run_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
CommitSha string `json:"commit_sha"`
|
||||
FilePath string `json:"file_path"`
|
||||
Lang *string `json:"lang"`
|
||||
StartLine int32 `json:"start_line"`
|
||||
EndLine int32 `json:"end_line"`
|
||||
Content string `json:"content"`
|
||||
ContentSha []byte `json:"content_sha"`
|
||||
TokenCount *int32 `json:"token_count"`
|
||||
Embedding *pgvector.Vector `json:"embedding"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type CodeIndexRun struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
WorktreeID pgtype.UUID `json:"worktree_id"`
|
||||
Branch string `json:"branch"`
|
||||
CommitSha string `json:"commit_sha"`
|
||||
Status string `json:"status"`
|
||||
EmbeddingEndpointID pgtype.UUID `json:"embedding_endpoint_id"`
|
||||
EmbeddingModel string `json:"embedding_model"`
|
||||
Dims int32 `json:"dims"`
|
||||
FilesIndexed int32 `json:"files_indexed"`
|
||||
ChunksIndexed int32 `json:"chunks_indexed"`
|
||||
Error *string `json:"error"`
|
||||
StartedAt pgtype.Timestamptz `json:"started_at"`
|
||||
FinishedAt pgtype.Timestamptz `json:"finished_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type CommitSummary struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
WorktreeID pgtype.UUID `json:"worktree_id"`
|
||||
Branch string `json:"branch"`
|
||||
CommitSha string `json:"commit_sha"`
|
||||
Kind string `json:"kind"`
|
||||
Title *string `json:"title"`
|
||||
BodyMd string `json:"body_md"`
|
||||
Model *string `json:"model"`
|
||||
Status string `json:"status"`
|
||||
Error *string `json:"error"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type Conversation struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
@@ -110,6 +233,14 @@ type Conversation struct {
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
}
|
||||
|
||||
type CryptoKey struct {
|
||||
Version int32 `json:"version"`
|
||||
Provider string `json:"provider"`
|
||||
KeyRef *string `json:"key_ref"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type GitCredential struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
@@ -119,6 +250,7 @@ type GitCredential struct {
|
||||
Fingerprint *string `json:"fingerprint"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
KeyVersion int16 `json:"key_version"`
|
||||
}
|
||||
|
||||
type Issue struct {
|
||||
@@ -135,6 +267,17 @@ type Issue struct {
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
ParentID pgtype.UUID `json:"parent_id"`
|
||||
Priority int32 `json:"priority"`
|
||||
}
|
||||
|
||||
type IssueDependency struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
BlockedID pgtype.UUID `json:"blocked_id"`
|
||||
BlockerID pgtype.UUID `json:"blocker_id"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
@@ -162,6 +305,7 @@ type LlmEndpoint struct {
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
KeyVersion int16 `json:"key_version"`
|
||||
}
|
||||
|
||||
type LlmModel struct {
|
||||
@@ -252,6 +396,50 @@ type Notification struct {
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
}
|
||||
|
||||
type NotificationPref struct {
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
EmailEnabled bool `json:"email_enabled"`
|
||||
ImEnabled bool `json:"im_enabled"`
|
||||
ImWebhookUrlEnc []byte `json:"im_webhook_url_enc"`
|
||||
MinSeverity string `json:"min_severity"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type OrchestratorRun struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
OwnerID pgtype.UUID `json:"owner_id"`
|
||||
Status string `json:"status"`
|
||||
CurrentPhase string `json:"current_phase"`
|
||||
Config []byte `json:"config"`
|
||||
LastError *string `json:"last_error"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
EndedAt pgtype.Timestamptz `json:"ended_at"`
|
||||
}
|
||||
|
||||
type OrchestratorStep struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
RunID pgtype.UUID `json:"run_id"`
|
||||
Phase string `json:"phase"`
|
||||
Attempt int32 `json:"attempt"`
|
||||
ParentStepID pgtype.UUID `json:"parent_step_id"`
|
||||
Depth int32 `json:"depth"`
|
||||
Status string `json:"status"`
|
||||
AgentKindID pgtype.UUID `json:"agent_kind_id"`
|
||||
AcpSessionID pgtype.UUID `json:"acp_session_id"`
|
||||
Prompt string `json:"prompt"`
|
||||
StopReason *string `json:"stop_reason"`
|
||||
GateResult []byte `json:"gate_result"`
|
||||
LastError *string `json:"last_error"`
|
||||
JobID pgtype.UUID `json:"job_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
EndedAt pgtype.Timestamptz `json:"ended_at"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Slug string `json:"slug"`
|
||||
@@ -264,6 +452,30 @@ type Project struct {
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type ProjectMember struct {
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
UserID pgtype.UUID `json:"user_id"`
|
||||
Role string `json:"role"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
AddedBy pgtype.UUID `json:"added_by"`
|
||||
}
|
||||
|
||||
type ProjectMemory struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
||||
Kind string `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Tags []string `json:"tags"`
|
||||
Source string `json:"source"`
|
||||
Embedding *pgvector.Vector `json:"embedding"`
|
||||
EmbeddingModel *string `json:"embedding_model"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type PromptTemplate struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -299,6 +511,16 @@ type RequirementArtifact struct {
|
||||
SourceMessageID *int64 `json:"source_message_id"`
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
Verdict string `json:"verdict"`
|
||||
}
|
||||
|
||||
type RequirementPhasePointer struct {
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
Phase string `json:"phase"`
|
||||
ApprovedArtifactID pgtype.UUID `json:"approved_artifact_id"`
|
||||
ApprovedBy pgtype.UUID `json:"approved_by"`
|
||||
ApprovedAt pgtype.Timestamptz `json:"approved_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
@@ -354,6 +576,7 @@ type WorkspaceRunProfile struct {
|
||||
CreatedBy pgtype.UUID `json:"created_by"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
KeyVersion int16 `json:"key_version"`
|
||||
}
|
||||
|
||||
type WorkspaceWorktree struct {
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: phase_pointers.sql
|
||||
|
||||
package projectsqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getRequirementPhasePointer = `-- name: GetRequirementPhasePointer :one
|
||||
SELECT requirement_id, phase, approved_artifact_id, approved_by, approved_at, updated_at
|
||||
FROM requirement_phase_pointers
|
||||
WHERE requirement_id = $1 AND phase = $2
|
||||
`
|
||||
|
||||
type GetRequirementPhasePointerParams struct {
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
Phase string `json:"phase"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetRequirementPhasePointer(ctx context.Context, arg GetRequirementPhasePointerParams) (RequirementPhasePointer, error) {
|
||||
row := q.db.QueryRow(ctx, getRequirementPhasePointer, arg.RequirementID, arg.Phase)
|
||||
var i RequirementPhasePointer
|
||||
err := row.Scan(
|
||||
&i.RequirementID,
|
||||
&i.Phase,
|
||||
&i.ApprovedArtifactID,
|
||||
&i.ApprovedBy,
|
||||
&i.ApprovedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listRequirementPhasePointers = `-- name: ListRequirementPhasePointers :many
|
||||
SELECT requirement_id, phase, approved_artifact_id, approved_by, approved_at, updated_at
|
||||
FROM requirement_phase_pointers
|
||||
WHERE requirement_id = $1
|
||||
ORDER BY phase ASC
|
||||
`
|
||||
|
||||
func (q *Queries) ListRequirementPhasePointers(ctx context.Context, requirementID pgtype.UUID) ([]RequirementPhasePointer, error) {
|
||||
rows, err := q.db.Query(ctx, listRequirementPhasePointers, requirementID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []RequirementPhasePointer
|
||||
for rows.Next() {
|
||||
var i RequirementPhasePointer
|
||||
if err := rows.Scan(
|
||||
&i.RequirementID,
|
||||
&i.Phase,
|
||||
&i.ApprovedArtifactID,
|
||||
&i.ApprovedBy,
|
||||
&i.ApprovedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const upsertRequirementPhasePointer = `-- name: UpsertRequirementPhasePointer :one
|
||||
INSERT INTO requirement_phase_pointers (requirement_id, phase, approved_artifact_id, approved_by, approved_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, now(), now())
|
||||
ON CONFLICT (requirement_id, phase) DO UPDATE
|
||||
SET approved_artifact_id = EXCLUDED.approved_artifact_id,
|
||||
approved_by = EXCLUDED.approved_by,
|
||||
approved_at = EXCLUDED.approved_at,
|
||||
updated_at = now()
|
||||
RETURNING requirement_id, phase, approved_artifact_id, approved_by, approved_at, updated_at
|
||||
`
|
||||
|
||||
type UpsertRequirementPhasePointerParams struct {
|
||||
RequirementID pgtype.UUID `json:"requirement_id"`
|
||||
Phase string `json:"phase"`
|
||||
ApprovedArtifactID pgtype.UUID `json:"approved_artifact_id"`
|
||||
ApprovedBy pgtype.UUID `json:"approved_by"`
|
||||
}
|
||||
|
||||
func (q *Queries) UpsertRequirementPhasePointer(ctx context.Context, arg UpsertRequirementPhasePointerParams) (RequirementPhasePointer, error) {
|
||||
row := q.db.QueryRow(ctx, upsertRequirementPhasePointer,
|
||||
arg.RequirementID,
|
||||
arg.Phase,
|
||||
arg.ApprovedArtifactID,
|
||||
arg.ApprovedBy,
|
||||
)
|
||||
var i RequirementPhasePointer
|
||||
err := row.Scan(
|
||||
&i.RequirementID,
|
||||
&i.Phase,
|
||||
&i.ApprovedArtifactID,
|
||||
&i.ApprovedBy,
|
||||
&i.ApprovedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
Reference in New Issue
Block a user