feat(postgres): State Store schema and sqlc queries, with the claim path proven on PG 18
goose migration 0001 lands the twelve State Store tables on Postgres, and sqlc generates the task queries from it. Two behaviours that genuinely differ from SQLite are pinned by tests against a real PG 18: claiming takes the oldest queued row with FOR UPDATE SKIP LOCKED (without the clause a second claimer blocks, which the test shows by timing out), and every column behind a Go int is bigint -- SQLite's INTEGER is 64-bit, and the chat issue-number allocator seeds at 10^15, which does not fit an int4. task db:generate writes the committed postgresdb package; task db:check regenerates it in the gate, as proto:check and ui:check do. The remaining store methods (events, resources, identities, the status tables) still run on SQLite: porting them is the rest of archie-core-7r0x.2.
This commit is contained in:
11 files changed
+1408
No files matched your search
@@ -53,6 +53,22 @@ tasks:
|
||||
cmds:
|
||||
- bash tools/proto.sh lint
|
||||
|
||||
db:generate:
|
||||
desc: "Regenerate the sqlc query code from the schema and query files"
|
||||
summary: |
|
||||
Writes internal/infrastructure/postgres/postgresdb. The output is
|
||||
committed, so this dirties the tree deliberately: review the diff and
|
||||
commit it with the schema or query change that caused it. Never
|
||||
hand-edit the generated package.
|
||||
cmds:
|
||||
- go -C tools tool sqlc generate -f {{.ROOT_DIR}}/internal/infrastructure/postgres/sqlc.yaml
|
||||
|
||||
db:check:
|
||||
desc: "Regenerate the sqlc code and reject uncommitted generated differences"
|
||||
cmds:
|
||||
- task: db:generate
|
||||
- git diff --exit-code -- internal/infrastructure/postgres/postgresdb
|
||||
|
||||
proto:check:
|
||||
desc: Regenerate contracts and reject uncommitted generated differences
|
||||
cmds:
|
||||
@@ -507,6 +523,7 @@ tasks:
|
||||
# after them only reads it, so it runs concurrently.
|
||||
- task: fmt
|
||||
- task: proto:check
|
||||
- task: db:check
|
||||
- task: check:readonly
|
||||
|
||||
check:readonly:
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
-- State Store schema: tasks, transitions, events, resources, the control-plane
|
||||
-- resource documents, channel/apply status, config snapshots and identities.
|
||||
--
|
||||
-- Translations from the SQLite schema this replaces, and why:
|
||||
-- * AUTOINCREMENT becomes GENERATED BY DEFAULT AS IDENTITY. BY DEFAULT
|
||||
-- rather than ALWAYS so the one-time import can insert historical ids and
|
||||
-- then advance the sequence.
|
||||
-- * Times become timestamptz. SQLite stored them as fixed-width text and
|
||||
-- ordered them lexicographically; Postgres orders them natively, so the
|
||||
-- layout normalisation that step needed does not exist here.
|
||||
-- * Blobs become bytea; the 0/1 flag columns become boolean.
|
||||
-- * `events.data` stays text even though it holds JSON: nothing queries into
|
||||
-- it, and jsonb would reorder keys and reject what the writer accepted.
|
||||
-- * identity_aliases is unique on lower(alias) rather than using citext, so
|
||||
-- a deployment needs no extension.
|
||||
-- * Every column behind a Go int is bigint. SQLite's INTEGER is 64-bit, so
|
||||
-- a 32-bit column here would narrow silently: the chat issue-number
|
||||
-- allocator seeds at 10^15, which does not fit an int4.
|
||||
|
||||
-- +goose Up
|
||||
|
||||
CREATE TABLE tasks (
|
||||
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
owner text NOT NULL,
|
||||
repo text NOT NULL,
|
||||
issue_number bigint NOT NULL,
|
||||
title text NOT NULL DEFAULT '',
|
||||
body text NOT NULL DEFAULT '',
|
||||
labels text NOT NULL DEFAULT '',
|
||||
status text NOT NULL DEFAULT 'queued',
|
||||
workflow text NOT NULL DEFAULT '',
|
||||
stage text NOT NULL DEFAULT '',
|
||||
branch text NOT NULL DEFAULT '',
|
||||
plan text NOT NULL DEFAULT '',
|
||||
notes text NOT NULL DEFAULT '',
|
||||
pr_number bigint NOT NULL DEFAULT 0,
|
||||
tokens_used bigint NOT NULL DEFAULT 0,
|
||||
iterations bigint NOT NULL DEFAULT 0,
|
||||
attempt bigint NOT NULL DEFAULT 0,
|
||||
park_reason text NOT NULL DEFAULT '',
|
||||
watch_comment_id bigint NOT NULL DEFAULT 0,
|
||||
park_class text NOT NULL DEFAULT 'needs_human',
|
||||
remediation_rounds bigint NOT NULL DEFAULT 0,
|
||||
retry_count bigint NOT NULL DEFAULT 0,
|
||||
source text NOT NULL DEFAULT 'forge',
|
||||
identity text NOT NULL DEFAULT '',
|
||||
binding_id text NOT NULL DEFAULT '',
|
||||
binding_version bigint NOT NULL DEFAULT 0,
|
||||
review_payload text NOT NULL DEFAULT '',
|
||||
workflow_definition_version bigint NOT NULL DEFAULT 0,
|
||||
workflow_definition_digest text NOT NULL DEFAULT '',
|
||||
workflow_definition_yaml text NOT NULL DEFAULT '',
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
UNIQUE (owner, repo, issue_number)
|
||||
);
|
||||
CREATE INDEX idx_tasks_pr ON tasks (owner, repo, pr_number);
|
||||
CREATE INDEX idx_tasks_status ON tasks (status);
|
||||
|
||||
CREATE TABLE transitions (
|
||||
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
task_id bigint NOT NULL,
|
||||
at timestamptz NOT NULL DEFAULT now(),
|
||||
from_status text NOT NULL,
|
||||
to_status text NOT NULL,
|
||||
detail text NOT NULL DEFAULT ''
|
||||
);
|
||||
CREATE INDEX idx_transitions_task ON transitions (task_id, id);
|
||||
|
||||
CREATE TABLE events (
|
||||
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
at timestamptz NOT NULL,
|
||||
kind text NOT NULL,
|
||||
task_id bigint NOT NULL DEFAULT 0,
|
||||
repo text NOT NULL DEFAULT '',
|
||||
issue bigint NOT NULL DEFAULT 0,
|
||||
workflow text NOT NULL DEFAULT '',
|
||||
stage text NOT NULL DEFAULT '',
|
||||
attempt bigint NOT NULL DEFAULT 0,
|
||||
actor_id text NOT NULL DEFAULT '',
|
||||
actor_kind text NOT NULL DEFAULT '',
|
||||
principal_id text NOT NULL DEFAULT '',
|
||||
detail text NOT NULL DEFAULT '',
|
||||
data text NOT NULL DEFAULT '{}'
|
||||
);
|
||||
CREATE INDEX idx_events_task ON events (task_id, id);
|
||||
CREATE INDEX idx_events_kind ON events (kind, id);
|
||||
CREATE INDEX idx_events_at ON events (at, id);
|
||||
|
||||
CREATE TABLE resources (
|
||||
kind text PRIMARY KEY,
|
||||
value bytea NOT NULL,
|
||||
version bigint NOT NULL,
|
||||
updated_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE resource_history (
|
||||
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
kind text NOT NULL,
|
||||
value bytea NOT NULL,
|
||||
version bigint NOT NULL,
|
||||
actor text NOT NULL,
|
||||
source text NOT NULL,
|
||||
request_id text NOT NULL,
|
||||
expected_version bigint NOT NULL,
|
||||
current_version bigint NOT NULL,
|
||||
at timestamptz NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_resource_history_kind_version ON resource_history (kind, version);
|
||||
-- The request-ID idempotency key is per kind, not global: a resource write
|
||||
-- replays only the same kind's prior write (resourceByRequest).
|
||||
CREATE UNIQUE INDEX idx_resource_history_kind_request ON resource_history (kind, request_id);
|
||||
|
||||
CREATE TABLE channel_status (
|
||||
id text PRIMARY KEY,
|
||||
name text NOT NULL DEFAULT '',
|
||||
state text NOT NULL DEFAULT '',
|
||||
detail text NOT NULL DEFAULT '',
|
||||
configured boolean NOT NULL DEFAULT false,
|
||||
reload_supported boolean NOT NULL DEFAULT false,
|
||||
observed_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE apply_status (
|
||||
process text NOT NULL,
|
||||
kind text NOT NULL,
|
||||
applied_version bigint NOT NULL DEFAULT 0,
|
||||
error text NOT NULL DEFAULT '',
|
||||
reported_at timestamptz NOT NULL,
|
||||
PRIMARY KEY (process, kind)
|
||||
);
|
||||
|
||||
CREATE TABLE config_snapshot (
|
||||
id bigint PRIMARY KEY CHECK (id = 1),
|
||||
schema text NOT NULL DEFAULT '',
|
||||
document text NOT NULL DEFAULT '',
|
||||
published_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE identities (
|
||||
id text PRIMARY KEY,
|
||||
kind text NOT NULL,
|
||||
display_name text NOT NULL,
|
||||
lifecycle text NOT NULL,
|
||||
version bigint NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE identity_aliases (
|
||||
alias text PRIMARY KEY,
|
||||
identity_id text NOT NULL REFERENCES identities (id)
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_identity_aliases_alias ON identity_aliases (lower(alias));
|
||||
|
||||
CREATE TABLE identity_events (
|
||||
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
identity_id text NOT NULL,
|
||||
event_type text NOT NULL,
|
||||
from_lifecycle text NOT NULL,
|
||||
to_lifecycle text NOT NULL,
|
||||
display_name text NOT NULL,
|
||||
actor_id text NOT NULL,
|
||||
source text NOT NULL,
|
||||
request_id text NOT NULL UNIQUE,
|
||||
at timestamptz NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_identity_events_identity ON identity_events (identity_id, id);
|
||||
|
||||
CREATE TABLE identity_subjects (
|
||||
issuer text NOT NULL,
|
||||
subject text NOT NULL,
|
||||
identity_id text NOT NULL REFERENCES identities (id),
|
||||
bound_at timestamptz NOT NULL,
|
||||
PRIMARY KEY (issuer, subject)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
DROP TABLE identity_subjects;
|
||||
DROP TABLE identity_events;
|
||||
DROP TABLE identity_aliases;
|
||||
DROP TABLE identities;
|
||||
DROP TABLE config_snapshot;
|
||||
DROP TABLE apply_status;
|
||||
DROP TABLE channel_status;
|
||||
DROP TABLE resource_history;
|
||||
DROP TABLE resources;
|
||||
DROP TABLE events;
|
||||
DROP TABLE transitions;
|
||||
DROP TABLE tasks;
|
||||
@@ -4,6 +4,7 @@ package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
@@ -17,6 +18,19 @@ import (
|
||||
// minServerVersion is PostgreSQL 18 in server_version_num form.
|
||||
const minServerVersion = 180000
|
||||
|
||||
//go:embed migrations/*.sql
|
||||
var migrations embed.FS
|
||||
|
||||
// Migrations is the State Store schema, rooted at the migration files.
|
||||
func Migrations() fs.FS {
|
||||
sub, err := fs.Sub(migrations, "migrations")
|
||||
if err != nil {
|
||||
// Unreachable: the pattern above embeds the directory.
|
||||
panic(err)
|
||||
}
|
||||
return sub
|
||||
}
|
||||
|
||||
// ErrServerTooOld is returned for a server older than PostgreSQL 18.
|
||||
var ErrServerTooOld = errors.New("postgres: server is older than PostgreSQL 18")
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package postgresdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
|
||||
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(context.Context, string, ...interface{}) pgx.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
|
||||
package postgresdb
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type ApplyStatus struct {
|
||||
Process string
|
||||
Kind string
|
||||
AppliedVersion int64
|
||||
Error string
|
||||
ReportedAt time.Time
|
||||
}
|
||||
|
||||
type ChannelStatus struct {
|
||||
ID string
|
||||
Name string
|
||||
State string
|
||||
Detail string
|
||||
Configured bool
|
||||
ReloadSupported bool
|
||||
ObservedAt time.Time
|
||||
}
|
||||
|
||||
type ConfigSnapshot struct {
|
||||
ID int64
|
||||
Schema string
|
||||
Document string
|
||||
PublishedAt time.Time
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
ID int64
|
||||
At time.Time
|
||||
Kind string
|
||||
TaskID int64
|
||||
Repo string
|
||||
Issue int64
|
||||
Workflow string
|
||||
Stage string
|
||||
Attempt int64
|
||||
ActorID string
|
||||
ActorKind string
|
||||
PrincipalID string
|
||||
Detail string
|
||||
Data string
|
||||
}
|
||||
|
||||
type Identity struct {
|
||||
ID string
|
||||
Kind string
|
||||
DisplayName string
|
||||
Lifecycle string
|
||||
Version int64
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type IdentityAlias struct {
|
||||
Alias string
|
||||
IdentityID string
|
||||
}
|
||||
|
||||
type IdentityEvent struct {
|
||||
ID int64
|
||||
IdentityID string
|
||||
EventType string
|
||||
FromLifecycle string
|
||||
ToLifecycle string
|
||||
DisplayName string
|
||||
ActorID string
|
||||
Source string
|
||||
RequestID string
|
||||
At time.Time
|
||||
}
|
||||
|
||||
type IdentitySubject struct {
|
||||
Issuer string
|
||||
Subject string
|
||||
IdentityID string
|
||||
BoundAt time.Time
|
||||
}
|
||||
|
||||
type Resource struct {
|
||||
Kind string
|
||||
Value []byte
|
||||
Version int64
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type ResourceHistory struct {
|
||||
ID int64
|
||||
Kind string
|
||||
Value []byte
|
||||
Version int64
|
||||
Actor string
|
||||
Source string
|
||||
RequestID string
|
||||
ExpectedVersion int64
|
||||
CurrentVersion int64
|
||||
At time.Time
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
ID int64
|
||||
Owner string
|
||||
Repo string
|
||||
IssueNumber int64
|
||||
Title string
|
||||
Body string
|
||||
Labels string
|
||||
Status string
|
||||
Workflow string
|
||||
Stage string
|
||||
Branch string
|
||||
Plan string
|
||||
Notes string
|
||||
PrNumber int64
|
||||
TokensUsed int64
|
||||
Iterations int64
|
||||
Attempt int64
|
||||
ParkReason string
|
||||
WatchCommentID int64
|
||||
ParkClass string
|
||||
RemediationRounds int64
|
||||
RetryCount int64
|
||||
Source string
|
||||
Identity string
|
||||
BindingID string
|
||||
BindingVersion int64
|
||||
ReviewPayload string
|
||||
WorkflowDefinitionVersion int64
|
||||
WorkflowDefinitionDigest string
|
||||
WorkflowDefinitionYaml string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type Transition struct {
|
||||
ID int64
|
||||
TaskID int64
|
||||
At time.Time
|
||||
FromStatus string
|
||||
ToStatus string
|
||||
Detail string
|
||||
}
|
||||
@@ -0,0 +1,567 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: tasks.sql
|
||||
|
||||
package postgresdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const claimNextTask = `-- name: ClaimNextTask :one
|
||||
UPDATE tasks
|
||||
SET status = 'running', attempt = attempt + 1, updated_at = now()
|
||||
WHERE id = (
|
||||
SELECT id FROM tasks
|
||||
WHERE status = 'queued'
|
||||
ORDER BY id
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
)
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, 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
|
||||
`
|
||||
|
||||
// FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
||||
// claimers running at once take different rows instead of blocking, so the
|
||||
// daemon no longer depends on holding the only connection to the file.
|
||||
func (q *Queries) ClaimNextTask(ctx context.Context) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, claimNextTask)
|
||||
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.Stage,
|
||||
&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,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const clearTerminalTasks = `-- name: ClearTerminalTasks :execrows
|
||||
DELETE FROM tasks
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do')
|
||||
`
|
||||
|
||||
func (q *Queries) ClearTerminalTasks(ctx context.Context) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, clearTerminalTasks)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const countTasksByStatus = `-- name: CountTasksByStatus :many
|
||||
SELECT status, count(*)::int AS count FROM tasks GROUP BY status
|
||||
`
|
||||
|
||||
type CountTasksByStatusRow struct {
|
||||
Status string
|
||||
Count int32
|
||||
}
|
||||
|
||||
func (q *Queries) CountTasksByStatus(ctx context.Context) ([]CountTasksByStatusRow, error) {
|
||||
rows, err := q.db.Query(ctx, countTasksByStatus)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []CountTasksByStatusRow
|
||||
for rows.Next() {
|
||||
var i CountTasksByStatusRow
|
||||
if err := rows.Scan(&i.Status, &i.Count); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const insertChatTask = `-- name: InsertChatTask :one
|
||||
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity)
|
||||
VALUES (
|
||||
$1, $2,
|
||||
COALESCE((
|
||||
SELECT MAX(existing.issue_number) FROM tasks existing
|
||||
WHERE existing.owner = $1
|
||||
AND existing.repo = $2
|
||||
AND existing.source = 'chat'
|
||||
), $3) + 1,
|
||||
$4, $5, 'chat', $6, 'chat', $7
|
||||
)
|
||||
RETURNING id, owner, repo, issue_number, title, body, labels, status, workflow, stage, 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
|
||||
`
|
||||
|
||||
type InsertChatTaskParams struct {
|
||||
Owner string
|
||||
Repo string
|
||||
FallbackIssueNumber int64
|
||||
Title string
|
||||
Body string
|
||||
Workflow string
|
||||
Identity string
|
||||
}
|
||||
|
||||
// The synthetic issue number keeps chat-sourced tasks off the forge's real
|
||||
// issue numbers; this allocator is the single source of truth for it.
|
||||
// fallback_issue_number is only the seed for a repo's first chat task -- the
|
||||
// passed value is not the issue number that lands.
|
||||
func (q *Queries) InsertChatTask(ctx context.Context, arg InsertChatTaskParams) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, insertChatTask,
|
||||
arg.Owner,
|
||||
arg.Repo,
|
||||
arg.FallbackIssueNumber,
|
||||
arg.Title,
|
||||
arg.Body,
|
||||
arg.Workflow,
|
||||
arg.Identity,
|
||||
)
|
||||
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.Stage,
|
||||
&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,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertTransition = `-- name: InsertTransition :exec
|
||||
INSERT INTO transitions (task_id, from_status, to_status, detail)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
`
|
||||
|
||||
type InsertTransitionParams struct {
|
||||
TaskID int64
|
||||
FromStatus string
|
||||
ToStatus string
|
||||
Detail string
|
||||
}
|
||||
|
||||
func (q *Queries) InsertTransition(ctx context.Context, arg InsertTransitionParams) error {
|
||||
_, err := q.db.Exec(ctx, insertTransition,
|
||||
arg.TaskID,
|
||||
arg.FromStatus,
|
||||
arg.ToStatus,
|
||||
arg.Detail,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const listTaskSummaries = `-- name: ListTaskSummaries :many
|
||||
SELECT id, owner, repo, issue_number, title, status, workflow, stage,
|
||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||
created_at, updated_at, plan, source, identity, binding_id, binding_version
|
||||
FROM tasks ORDER BY updated_at DESC LIMIT $1
|
||||
`
|
||||
|
||||
type ListTaskSummariesRow struct {
|
||||
ID int64
|
||||
Owner string
|
||||
Repo string
|
||||
IssueNumber int64
|
||||
Title string
|
||||
Status string
|
||||
Workflow string
|
||||
Stage string
|
||||
PrNumber int64
|
||||
TokensUsed int64
|
||||
Iterations int64
|
||||
Attempt int64
|
||||
ParkReason string
|
||||
RetryCount int64
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
Plan string
|
||||
Source string
|
||||
Identity string
|
||||
BindingID string
|
||||
BindingVersion int64
|
||||
}
|
||||
|
||||
// The dashboard's list. This projection is deliberately narrow: Plan gates
|
||||
// the "Decision required" panel and Source labels the row, and widening it
|
||||
// back would send rows without them.
|
||||
func (q *Queries) ListTaskSummaries(ctx context.Context, limit int32) ([]ListTaskSummariesRow, error) {
|
||||
rows, err := q.db.Query(ctx, listTaskSummaries, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListTaskSummariesRow
|
||||
for rows.Next() {
|
||||
var i ListTaskSummariesRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Owner,
|
||||
&i.Repo,
|
||||
&i.IssueNumber,
|
||||
&i.Title,
|
||||
&i.Status,
|
||||
&i.Workflow,
|
||||
&i.Stage,
|
||||
&i.PrNumber,
|
||||
&i.TokensUsed,
|
||||
&i.Iterations,
|
||||
&i.Attempt,
|
||||
&i.ParkReason,
|
||||
&i.RetryCount,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Plan,
|
||||
&i.Source,
|
||||
&i.Identity,
|
||||
&i.BindingID,
|
||||
&i.BindingVersion,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const parkTask = `-- name: ParkTask :execrows
|
||||
UPDATE tasks
|
||||
SET status = 'parked', park_reason = $2, park_class = $3, updated_at = now()
|
||||
WHERE id = $1 AND status = $4
|
||||
`
|
||||
|
||||
type ParkTaskParams struct {
|
||||
ID int64
|
||||
ParkReason string
|
||||
ParkClass string
|
||||
Status string
|
||||
}
|
||||
|
||||
func (q *Queries) ParkTask(ctx context.Context, arg ParkTaskParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, parkTask,
|
||||
arg.ID,
|
||||
arg.ParkReason,
|
||||
arg.ParkClass,
|
||||
arg.Status,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const recoverStaleTasks = `-- name: RecoverStaleTasks :execrows
|
||||
UPDATE tasks SET status = 'queued', updated_at = now() WHERE status = 'running'
|
||||
`
|
||||
|
||||
func (q *Queries) RecoverStaleTasks(ctx context.Context) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, recoverStaleTasks)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const stampTaskBinding = `-- name: StampTaskBinding :exec
|
||||
UPDATE tasks SET binding_id = $2, binding_version = $3 WHERE id = $1
|
||||
`
|
||||
|
||||
type StampTaskBindingParams struct {
|
||||
ID int64
|
||||
BindingID string
|
||||
BindingVersion int64
|
||||
}
|
||||
|
||||
func (q *Queries) StampTaskBinding(ctx context.Context, arg StampTaskBindingParams) error {
|
||||
_, err := q.db.Exec(ctx, stampTaskBinding, arg.ID, arg.BindingID, arg.BindingVersion)
|
||||
return err
|
||||
}
|
||||
|
||||
const taskByID = `-- name: TaskByID :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, 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 FROM tasks WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) TaskByID(ctx context.Context, id int64) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, taskByID, id)
|
||||
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.Stage,
|
||||
&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,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const taskByIssue = `-- name: TaskByIssue :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, 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 FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3
|
||||
`
|
||||
|
||||
type TaskByIssueParams struct {
|
||||
Owner string
|
||||
Repo string
|
||||
IssueNumber int64
|
||||
}
|
||||
|
||||
func (q *Queries) TaskByIssue(ctx context.Context, arg TaskByIssueParams) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, taskByIssue, arg.Owner, arg.Repo, arg.IssueNumber)
|
||||
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.Stage,
|
||||
&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,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const taskByPR = `-- name: TaskByPR :one
|
||||
SELECT id, owner, repo, issue_number, title, body, labels, status, workflow, stage, 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 FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3
|
||||
`
|
||||
|
||||
type TaskByPRParams struct {
|
||||
Owner string
|
||||
Repo string
|
||||
PrNumber int64
|
||||
}
|
||||
|
||||
func (q *Queries) TaskByPR(ctx context.Context, arg TaskByPRParams) (Task, error) {
|
||||
row := q.db.QueryRow(ctx, taskByPR, arg.Owner, arg.Repo, arg.PrNumber)
|
||||
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.Stage,
|
||||
&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,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const transitionTask = `-- name: TransitionTask :execrows
|
||||
UPDATE tasks
|
||||
SET status = $2,
|
||||
park_reason = CASE WHEN $2 = 'parked' THEN $3 ELSE park_reason END,
|
||||
park_class = CASE WHEN $2 = 'parked' THEN $4 ELSE park_class END,
|
||||
updated_at = now()
|
||||
WHERE id = $1 AND status = $5
|
||||
`
|
||||
|
||||
type TransitionTaskParams struct {
|
||||
ID int64
|
||||
Status string
|
||||
ParkReason string
|
||||
ParkClass string
|
||||
Status_2 string
|
||||
}
|
||||
|
||||
// Arriving at 'parked' also records why. The class is normalized by the
|
||||
// caller, so an unknown value persists as needs_human rather than as itself.
|
||||
func (q *Queries) TransitionTask(ctx context.Context, arg TransitionTaskParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, transitionTask,
|
||||
arg.ID,
|
||||
arg.Status,
|
||||
arg.ParkReason,
|
||||
arg.ParkClass,
|
||||
arg.Status_2,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return result.RowsAffected(), nil
|
||||
}
|
||||
|
||||
const updateTask = `-- name: UpdateTask :exec
|
||||
UPDATE tasks SET workflow = $2, stage = $3, branch = $4, plan = $5, notes = $6,
|
||||
pr_number = $7, tokens_used = $8, iterations = $9, park_reason = $10,
|
||||
watch_comment_id = $11, retry_count = $12, remediation_rounds = $13,
|
||||
review_payload = $14, workflow_definition_version = $15,
|
||||
workflow_definition_digest = $16, workflow_definition_yaml = $17,
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
type UpdateTaskParams struct {
|
||||
ID int64
|
||||
Workflow string
|
||||
Stage string
|
||||
Branch string
|
||||
Plan string
|
||||
Notes string
|
||||
PrNumber int64
|
||||
TokensUsed int64
|
||||
Iterations int64
|
||||
ParkReason string
|
||||
WatchCommentID int64
|
||||
RetryCount int64
|
||||
RemediationRounds int64
|
||||
ReviewPayload string
|
||||
WorkflowDefinitionVersion int64
|
||||
WorkflowDefinitionDigest string
|
||||
WorkflowDefinitionYaml string
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateTask(ctx context.Context, arg UpdateTaskParams) error {
|
||||
_, err := q.db.Exec(ctx, updateTask,
|
||||
arg.ID,
|
||||
arg.Workflow,
|
||||
arg.Stage,
|
||||
arg.Branch,
|
||||
arg.Plan,
|
||||
arg.Notes,
|
||||
arg.PrNumber,
|
||||
arg.TokensUsed,
|
||||
arg.Iterations,
|
||||
arg.ParkReason,
|
||||
arg.WatchCommentID,
|
||||
arg.RetryCount,
|
||||
arg.RemediationRounds,
|
||||
arg.ReviewPayload,
|
||||
arg.WorkflowDefinitionVersion,
|
||||
arg.WorkflowDefinitionDigest,
|
||||
arg.WorkflowDefinitionYaml,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
-- name: ClaimNextTask :one
|
||||
-- FOR UPDATE SKIP LOCKED replaces the SQLite single-writer assumption: two
|
||||
-- claimers running at once take different rows instead of blocking, so the
|
||||
-- daemon no longer depends on holding the only connection to the file.
|
||||
UPDATE tasks
|
||||
SET status = 'running', attempt = attempt + 1, updated_at = now()
|
||||
WHERE id = (
|
||||
SELECT id FROM tasks
|
||||
WHERE status = 'queued'
|
||||
ORDER BY id
|
||||
FOR UPDATE SKIP LOCKED
|
||||
LIMIT 1
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: TaskByID :one
|
||||
SELECT * FROM tasks WHERE id = $1;
|
||||
|
||||
-- name: TaskByIssue :one
|
||||
SELECT * FROM tasks WHERE owner = $1 AND repo = $2 AND issue_number = $3;
|
||||
|
||||
-- name: TaskByPR :one
|
||||
SELECT * FROM tasks WHERE owner = $1 AND repo = $2 AND pr_number = $3;
|
||||
|
||||
-- name: ListTaskSummaries :many
|
||||
-- The dashboard's list. This projection is deliberately narrow: Plan gates
|
||||
-- the "Decision required" panel and Source labels the row, and widening it
|
||||
-- back would send rows without them.
|
||||
SELECT id, owner, repo, issue_number, title, status, workflow, stage,
|
||||
pr_number, tokens_used, iterations, attempt, park_reason, retry_count,
|
||||
created_at, updated_at, plan, source, identity, binding_id, binding_version
|
||||
FROM tasks ORDER BY updated_at DESC LIMIT $1;
|
||||
|
||||
-- name: CountTasksByStatus :many
|
||||
SELECT status, count(*)::int AS count FROM tasks GROUP BY status;
|
||||
|
||||
-- name: InsertChatTask :one
|
||||
-- The synthetic issue number keeps chat-sourced tasks off the forge's real
|
||||
-- issue numbers; this allocator is the single source of truth for it.
|
||||
-- fallback_issue_number is only the seed for a repo's first chat task -- the
|
||||
-- passed value is not the issue number that lands.
|
||||
INSERT INTO tasks (owner, repo, issue_number, title, body, labels, workflow, source, identity)
|
||||
VALUES (
|
||||
sqlc.arg(owner), sqlc.arg(repo),
|
||||
COALESCE((
|
||||
SELECT MAX(existing.issue_number) FROM tasks existing
|
||||
WHERE existing.owner = sqlc.arg(owner)
|
||||
AND existing.repo = sqlc.arg(repo)
|
||||
AND existing.source = 'chat'
|
||||
), sqlc.arg(fallback_issue_number)) + 1,
|
||||
sqlc.arg(title), sqlc.arg(body), 'chat', sqlc.arg(workflow), 'chat', sqlc.arg(identity)
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: StampTaskBinding :exec
|
||||
UPDATE tasks SET binding_id = $2, binding_version = $3 WHERE id = $1;
|
||||
|
||||
-- name: UpdateTask :exec
|
||||
UPDATE tasks SET workflow = $2, stage = $3, branch = $4, plan = $5, notes = $6,
|
||||
pr_number = $7, tokens_used = $8, iterations = $9, park_reason = $10,
|
||||
watch_comment_id = $11, retry_count = $12, remediation_rounds = $13,
|
||||
review_payload = $14, workflow_definition_version = $15,
|
||||
workflow_definition_digest = $16, workflow_definition_yaml = $17,
|
||||
updated_at = now()
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: TransitionTask :execrows
|
||||
-- Arriving at 'parked' also records why. The class is normalized by the
|
||||
-- caller, so an unknown value persists as needs_human rather than as itself.
|
||||
UPDATE tasks
|
||||
SET status = $2,
|
||||
park_reason = CASE WHEN $2 = 'parked' THEN $3 ELSE park_reason END,
|
||||
park_class = CASE WHEN $2 = 'parked' THEN $4 ELSE park_class END,
|
||||
updated_at = now()
|
||||
WHERE id = $1 AND status = $5;
|
||||
|
||||
-- name: InsertTransition :exec
|
||||
INSERT INTO transitions (task_id, from_status, to_status, detail)
|
||||
VALUES ($1, $2, $3, $4);
|
||||
|
||||
-- name: ParkTask :execrows
|
||||
UPDATE tasks
|
||||
SET status = 'parked', park_reason = $2, park_class = $3, updated_at = now()
|
||||
WHERE id = $1 AND status = $4;
|
||||
|
||||
-- name: ClearTerminalTasks :execrows
|
||||
DELETE FROM tasks
|
||||
WHERE status IN ('merged', 'rejected', 'dead', 'closed_wont_do');
|
||||
|
||||
-- name: RecoverStaleTasks :execrows
|
||||
UPDATE tasks SET status = 'queued', updated_at = now() WHERE status = 'running';
|
||||
@@ -0,0 +1,18 @@
|
||||
version: "2"
|
||||
sql:
|
||||
- engine: "postgresql"
|
||||
schema: "migrations"
|
||||
queries: "queries"
|
||||
gen:
|
||||
go:
|
||||
package: "postgresdb"
|
||||
out: "postgresdb"
|
||||
sql_package: "pgx/v5"
|
||||
# The store's list methods return nil for an empty result and its
|
||||
# callers test that; empty slices here would be a silent change.
|
||||
emit_empty_slices: false
|
||||
overrides:
|
||||
# The domain carries every timestamp as time.Time; pgtype would put
|
||||
# a .Time unwrap at each of the mapping sites instead.
|
||||
- db_type: "timestamptz"
|
||||
go_type: "time.Time"
|
||||
@@ -0,0 +1,163 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgtest"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/postgresdb"
|
||||
)
|
||||
|
||||
// syntheticIssueBase mirrors the store's chat issue-number seed. It is the
|
||||
// fallback for a repo's first chat task, not the number that lands: the
|
||||
// allocator adds one to it.
|
||||
const syntheticIssueBase = 1_000_000_000_000_000
|
||||
|
||||
// migrated is a pool with the State Store schema applied, and its queries.
|
||||
func migrated(t *testing.T) (*pgxpool.Pool, *postgresdb.Queries) {
|
||||
t.Helper()
|
||||
pool, err := Open(t.Context(), pgtest.URL(t))
|
||||
if err != nil {
|
||||
t.Fatalf("Open: %v", err)
|
||||
}
|
||||
t.Cleanup(pool.Close)
|
||||
if err := Migrate(t.Context(), pool, Migrations()); err != nil {
|
||||
t.Fatalf("Migrate: %v", err)
|
||||
}
|
||||
return pool, postgresdb.New(pool)
|
||||
}
|
||||
|
||||
// queriesFor is migrated's queries without the pool, for tests that only read
|
||||
// and write through sqlc.
|
||||
func queriesFor(t *testing.T) *postgresdb.Queries {
|
||||
t.Helper()
|
||||
_, q := migrated(t)
|
||||
return q
|
||||
}
|
||||
|
||||
// insertChatTask queues one chat-sourced task.
|
||||
func insertChatTask(t *testing.T, q *postgresdb.Queries) postgresdb.Task {
|
||||
t.Helper()
|
||||
task, err := q.InsertChatTask(t.Context(), postgresdb.InsertChatTaskParams{
|
||||
Owner: "acme", Repo: "widget", Title: "t", Body: "b",
|
||||
Workflow: "tdd", Identity: "bot",
|
||||
FallbackIssueNumber: syntheticIssueBase,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("InsertChatTask: %v", err)
|
||||
}
|
||||
return task
|
||||
}
|
||||
|
||||
func TestSchemaAppliesAndTasksRoundTrip(t *testing.T) {
|
||||
q := queriesFor(t)
|
||||
|
||||
task := insertChatTask(t, q)
|
||||
if task.Status != "queued" {
|
||||
t.Fatalf("new task status = %q, want queued", task.Status)
|
||||
}
|
||||
if task.CreatedAt.IsZero() || task.UpdatedAt.IsZero() {
|
||||
t.Error("created_at/updated_at were not populated")
|
||||
}
|
||||
if task.IssueNumber != syntheticIssueBase+1 {
|
||||
t.Fatalf("first chat task issue number = %d, want %d", task.IssueNumber, syntheticIssueBase+1)
|
||||
}
|
||||
|
||||
got, err := q.TaskByIssue(t.Context(), postgresdb.TaskByIssueParams{
|
||||
Owner: task.Owner, Repo: task.Repo, IssueNumber: task.IssueNumber,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TaskByIssue: %v", err)
|
||||
}
|
||||
if got.ID != task.ID {
|
||||
t.Fatalf("TaskByIssue = %d, want %d", got.ID, task.ID)
|
||||
}
|
||||
}
|
||||
|
||||
// The chat allocator hands out the next number per repo, so two chat tasks in
|
||||
// one repo never share an issue number.
|
||||
func TestChatIssueNumberAllocatorIsPerRepo(t *testing.T) {
|
||||
q := queriesFor(t)
|
||||
|
||||
first := insertChatTask(t, q)
|
||||
second := insertChatTask(t, q)
|
||||
if second.IssueNumber != first.IssueNumber+1 {
|
||||
t.Fatalf("second chat issue number = %d, want %d", second.IssueNumber, first.IssueNumber+1)
|
||||
}
|
||||
}
|
||||
|
||||
// The issue-number uniqueness the SQLite schema carried as a table constraint
|
||||
// survives the move.
|
||||
func TestTaskIssueNumberIsUnique(t *testing.T) {
|
||||
pool, q := migrated(t)
|
||||
task := insertChatTask(t, q)
|
||||
|
||||
_, err := pool.Exec(t.Context(), `
|
||||
INSERT INTO tasks (owner, repo, issue_number) VALUES ($1, $2, $3)`,
|
||||
task.Owner, task.Repo, task.IssueNumber)
|
||||
if err == nil {
|
||||
t.Fatal("a second task for the same owner/repo/issue was accepted, want the unique constraint refused it")
|
||||
}
|
||||
}
|
||||
|
||||
// Claiming takes the oldest queued task, in id order, and counts the attempt.
|
||||
func TestClaimNextTakesTheOldestAndCountsTheAttempt(t *testing.T) {
|
||||
q := queriesFor(t)
|
||||
first := insertChatTask(t, q)
|
||||
second := insertChatTask(t, q)
|
||||
|
||||
claimed, err := q.ClaimNextTask(t.Context())
|
||||
if err != nil {
|
||||
t.Fatalf("ClaimNextTask: %v", err)
|
||||
}
|
||||
if claimed.ID != first.ID || claimed.Status != "running" || claimed.Attempt != 1 {
|
||||
t.Fatalf("first claim = {id:%d status:%q attempt:%d}, want {id:%d running 1}", claimed.ID, claimed.Status, claimed.Attempt, first.ID)
|
||||
}
|
||||
|
||||
claimed, err = q.ClaimNextTask(t.Context())
|
||||
if err != nil {
|
||||
t.Fatalf("second ClaimNextTask: %v", err)
|
||||
}
|
||||
if claimed.ID != second.ID {
|
||||
t.Fatalf("second claim = %d, want %d", claimed.ID, second.ID)
|
||||
}
|
||||
|
||||
if _, err := q.ClaimNextTask(t.Context()); !errors.Is(err, pgx.ErrNoRows) {
|
||||
t.Fatalf("claim on an empty queue = %v, want pgx.ErrNoRows", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A claimer must not wait behind a row another transaction holds: it takes the
|
||||
// next one. This is what FOR UPDATE SKIP LOCKED buys over the SQLite version,
|
||||
// where a second claimer could only ever have blocked on the writer lock.
|
||||
func TestClaimSkipsARowAnotherTransactionHolds(t *testing.T) {
|
||||
pool, q := migrated(t)
|
||||
held := insertChatTask(t, q)
|
||||
free := insertChatTask(t, q)
|
||||
|
||||
tx, err := pool.Begin(t.Context())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = tx.Rollback(t.Context()) }()
|
||||
var lockedID int64
|
||||
if err := tx.QueryRow(t.Context(),
|
||||
`SELECT id FROM tasks WHERE status = 'queued' ORDER BY id FOR UPDATE SKIP LOCKED LIMIT 1`,
|
||||
).Scan(&lockedID); err != nil {
|
||||
t.Fatalf("lock the oldest queued row: %v", err)
|
||||
}
|
||||
if lockedID != held.ID {
|
||||
t.Fatalf("locked row %d, want the oldest queued row %d", lockedID, held.ID)
|
||||
}
|
||||
|
||||
claimed, err := q.ClaimNextTask(t.Context())
|
||||
if err != nil {
|
||||
t.Fatalf("ClaimNextTask while a row is held: %v", err)
|
||||
}
|
||||
if claimed.ID != free.ID {
|
||||
t.Fatalf("claimed %d while %d was held, want the skipped-to row %d", claimed.ID, free.ID, held.ID)
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,61 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
cel.dev/expr v0.25.3 // indirect
|
||||
filippo.io/edwards25519 v1.1.1 // indirect
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/buger/jsonparser v1.6.1 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/cubicdaiya/gonp v1.0.4 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dustin/go-humanize v1.1.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.9.3 // indirect
|
||||
github.com/google/cel-go v0.28.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/pgx/v5 v5.11.0 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||
github.com/ncruces/go-sqlite3 v0.32.0 // indirect
|
||||
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||
github.com/ncruces/julianday v1.0.0 // indirect
|
||||
github.com/pb33f/ordered-map/v2 v2.3.1 // indirect
|
||||
github.com/pganalyze/pg_query_go/v6 v6.2.2 // indirect
|
||||
github.com/pingcap/errors v0.11.5-0.20250523034308-74f78ae071ee // indirect
|
||||
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
|
||||
github.com/pingcap/log v1.1.0 // indirect
|
||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20260418072757-ce92298d1124 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/riza-io/grpc-go v0.2.0 // indirect
|
||||
github.com/samcharles93/ai-sdk v0.1.39 // indirect
|
||||
github.com/spf13/cobra v1.10.2 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/sqlc-dev/doubleclick v1.0.0 // indirect
|
||||
github.com/sqlc-dev/sqlc v1.31.1 // indirect
|
||||
github.com/tetratelabs/wazero v1.11.0 // indirect
|
||||
github.com/traefik/yaegi v0.16.1 // indirect
|
||||
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 // indirect
|
||||
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba // indirect
|
||||
golang.org/x/net v0.59.0 // indirect
|
||||
golang.org/x/sync v0.23.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260921155816-b14227669459 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260921155816-b14227669459 // indirect
|
||||
google.golang.org/grpc v1.85.0-dev.0.20260825072537-93e31b48545e // indirect
|
||||
google.golang.org/protobuf v1.36.12 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/libc v1.77.1 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
@@ -29,3 +71,5 @@ require (
|
||||
)
|
||||
|
||||
replace github.com/samcharles93/archie-core => ../
|
||||
|
||||
tool github.com/sqlc-dev/sqlc/cmd/sqlc
|
||||
+121
@@ -1,56 +1,177 @@
|
||||
cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0=
|
||||
cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
|
||||
filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw=
|
||||
filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
|
||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk=
|
||||
github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs=
|
||||
github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
||||
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/cubicdaiya/gonp v1.0.4 h1:ky2uIAJh81WiLcGKBVD5R7KsM/36W6IqqTy6Bo6rGws=
|
||||
github.com/cubicdaiya/gonp v1.0.4/go.mod h1:iWGuP/7+JVTn02OWhRemVbMmG1DOUnmrGTYYACpOI0I=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
|
||||
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||
github.com/google/cel-go v0.28.0 h1:KjSWstCpz/MN5t4a8gnGJNIYUsJRpdi/r97xWDphIQc=
|
||||
github.com/google/cel-go v0.28.0/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8=
|
||||
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo=
|
||||
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/invopop/jsonschema v0.14.0 h1:MHQqLhvpNUZfw+hM3AZDYK7jxO8FZoQeQM77g8iyZjg=
|
||||
github.com/invopop/jsonschema v0.14.0/go.mod h1:ygm6C2EaVNMBDPpaPlnOA2pFAxBnxGjFlMZABxm9n2I=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.11.0 h1:IzBBtyK9AHqf98cctWFifYSci2hgQR/cd56wB4p+ogg=
|
||||
github.com/jackc/pgx/v5 v5.11.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
github.com/ncruces/go-sqlite3 v0.32.0 h1:hNBUXp88LrfQCsuyXLqWTbTUG35sUuktDsqhhgHvU20=
|
||||
github.com/ncruces/go-sqlite3 v0.32.0/go.mod h1:MIWTK60ONDl0oVY073zYvJP21C3Dly6P9bxVpgkLwdQ=
|
||||
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
|
||||
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
|
||||
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||
github.com/pb33f/ordered-map/v2 v2.3.1 h1:5319HDO0aw4DA4gzi+zv4FXU9UlSs3xGZ40wcP1nBjY=
|
||||
github.com/pb33f/ordered-map/v2 v2.3.1/go.mod h1:qxFQgd0PkVUtOMCkTapqotNgzRhMPL7VvaHKbd1HnmQ=
|
||||
github.com/pganalyze/pg_query_go/v6 v6.2.2 h1:O0L6zMC226R82RF3X5n0Ki6HjytDsoAzuzp4ATVAHNo=
|
||||
github.com/pganalyze/pg_query_go/v6 v6.2.2/go.mod h1:Cn6+j4870kJz3iYNsb0VsNG04vpSWgEvBwc590J4qD0=
|
||||
github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/pingcap/errors v0.11.5-0.20250523034308-74f78ae071ee h1:/IDPbpzkzA97t1/Z1+C3KlxbevjMeaI6BQYxvivu4u8=
|
||||
github.com/pingcap/errors v0.11.5-0.20250523034308-74f78ae071ee/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg=
|
||||
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 h1:tdMsjOqUR7YXHoBitzdebTvOjs/swniBTOLy5XiMtuE=
|
||||
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86/go.mod h1:exzhVYca3WRtd6gclGNErRWb1qEgff3LYta0LvRmON4=
|
||||
github.com/pingcap/log v1.1.0 h1:ELiPxACz7vdo1qAvvaWJg1NrYFoY6gqAh/+Uo6aXdD8=
|
||||
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20260418072757-ce92298d1124 h1:zYmP5fBH+i2yhhU6f5uOol6zxHtR2/sD47BsJLfy0oU=
|
||||
github.com/pingcap/tidb/pkg/parser v0.0.0-20260418072757-ce92298d1124/go.mod h1:zDLDsfNBU5+L6T4J9/OgWAHc/WZvMUjbpgHqQ/t3yKo=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/riza-io/grpc-go v0.2.0 h1:2HxQKFVE7VuYstcJ8zqpN84VnAoJ4dCL6YFhJewNcHQ=
|
||||
github.com/riza-io/grpc-go v0.2.0/go.mod h1:2bDvR9KkKC3KhtlSHfR3dAXjUMT86kg4UfWFyVGWqi8=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/samcharles93/ai-sdk v0.1.39 h1:gbNPYeA27MifReCruBiqMgb4fFSjCDi1Zv57a9bo0Vo=
|
||||
github.com/samcharles93/ai-sdk v0.1.39/go.mod h1:u4zrQ9/Q58L5mNEut4bNQ1ks+RCKq71LN5EDz2N/0Zk=
|
||||
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/sqlc-dev/doubleclick v1.0.0 h1:2/OApfQ2eLgcfa/Fqs8WSMA6atH0G8j9hHbQIgMfAXI=
|
||||
github.com/sqlc-dev/doubleclick v1.0.0/go.mod h1:ODHRroSrk/rr5neRHlWMSRijqOak8YmNaO3VAZCNl5Y=
|
||||
github.com/sqlc-dev/sqlc v1.31.1 h1:+V+BjBJfFNPX/RFfL8eiZD9jk9lVJUEGGllWvnYNqbc=
|
||||
github.com/sqlc-dev/sqlc v1.31.1/go.mod h1:6ZPww/Jd3G6MzJeW6NrqizjL+52vYNaaXP9yMeJ/Nao=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
|
||||
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
|
||||
github.com/traefik/yaegi v0.16.1 h1:f1De3DVJqIDKmnasUF6MwmWv1dSEEat0wcpXhD2On3E=
|
||||
github.com/traefik/yaegi v0.16.1/go.mod h1:4eVhbPb3LnD2VigQjhYbEJ69vDRFdT2HQNrXx8eEwUY=
|
||||
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07 h1:mJdDDPblDfPe7z7go8Dvv1AJQDI3eQ/5xith3q2mFlo=
|
||||
github.com/wasilibs/go-pgquery v0.0.0-20250409022910-10ac41983c07/go.mod h1:Ak17IJ037caFp4jpCw/iQQ7/W74Sqpb1YuKJU6HTKfM=
|
||||
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
|
||||
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.2 h1:/FrI8D64VSr4HtGIlUtlFMGsm7H7pWTbj6vOLVZcA6s=
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.2/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4=
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba h1:Ck8QetSgk912qxWLMCKxd0in+aiyBQyDSMae6e/xmpU=
|
||||
golang.org/x/exp v0.0.0-20260908205506-85c1c2202aba/go.mod h1:50RgIsmK7OwqzTTeqcSXQW8SswW0o8fRcDxmqGluJ8E=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
||||
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.50.0 h1:c2ifzfcuY7L90lZ2aKd8S4K2NpASF08SZx9ZuJkHmSU=
|
||||
golang.org/x/tools v0.50.0/go.mod h1:7ulVMw3831Mwi5EZD6RomGyffr4VFjuNYXf2BbCEAV0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260921155816-b14227669459 h1:GS9OIt/j7c8bvBjYNgnKQysVfmV7e4jM0H8ZK95G4t8=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260921155816-b14227669459/go.mod h1:PX5/4vemwVoXtwEcRDWwcR1/r0qrosfx3qoVADMwnVE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260921155816-b14227669459 h1:b0xCahf3FK2m2Cv0p4vTozGPWncCvLfwV86UNg8xWU8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260921155816-b14227669459/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||
google.golang.org/grpc v1.85.0-dev.0.20260825072537-93e31b48545e h1:ar+feAPij1Znzug45m6AoShUCc5AaR8FLA3I6LZd94k=
|
||||
google.golang.org/grpc v1.85.0-dev.0.20260825072537-93e31b48545e/go.mod h1:7aY/KlAHanMAVIWHnk8wloQsdlfwzDz/PP9vCbJG6CU=
|
||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
modernc.org/cc/v4 v4.29.7 h1:q+NXGJ0bK3b4TXFYQQVr9pYETGnmwFWkrUzJnMya/Tg=
|
||||
|
||||
Reference in new issue
Block a user