sqlc

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateCacheMetricsSinceRow

type AggregateCacheMetricsSinceRow struct {
	Turns             int64       `json:"turns"`
	TotalPromptTokens interface{} `json:"total_prompt_tokens"`
	TotalCachedTokens interface{} `json:"total_cached_tokens"`
	TotalCostUsd      interface{} `json:"total_cost_usd"`
}

type AuraAgentJobRuns

type AuraAgentJobRuns struct {
	ID                pgtype.UUID        `json:"id"`
	TaskID            pgtype.UUID        `json:"task_id"`
	Status            string             `json:"status"`
	StepBudget        pgtype.Int4        `json:"step_budget"`
	StartedAt         pgtype.Timestamptz `json:"started_at"`
	LastHeartbeatAt   pgtype.Timestamptz `json:"last_heartbeat_at"`
	CompletedWithHash pgtype.Text        `json:"completed_with_hash"`
	Summary           pgtype.Text        `json:"summary"`
	LastError         pgtype.Text        `json:"last_error"`
	MissedSince       pgtype.Timestamptz `json:"missed_since"`
	PausedStateToken  pgtype.UUID        `json:"paused_state_token"`
	CompletedAt       pgtype.Timestamptz `json:"completed_at"`
}

Per-run audit ledger (Slice 6 / Phase 10). Audit-forever (no aura_app DELETE, PRD OQ4). completed_with_hash is the SC#2 idempotency key (UNIQUE; a duplicate completion swallows 23505).

type AuraAssetEvents added in v1.0.0

type AuraAssetEvents struct {
	AssetID    pgtype.UUID        `json:"asset_id"`
	Seq        int32              `json:"seq"`
	FromStatus string             `json:"from_status"`
	ToStatus   string             `json:"to_status"`
	Reason     string             `json:"reason"`
	Detail     []byte             `json:"detail"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
}

type AuraAssets added in v1.0.0

type AuraAssets struct {
	ID                pgtype.UUID        `json:"id"`
	IdentityID        pgtype.UUID        `json:"identity_id"`
	SourceKind        string             `json:"source_kind"`
	SourceRef         string             `json:"source_ref"`
	ThreadID          string             `json:"thread_id"`
	Scope             string             `json:"scope"`
	Modality          string             `json:"modality"`
	Status            string             `json:"status"`
	FileName          string             `json:"file_name"`
	MimeType          string             `json:"mime_type"`
	DeclaredSizeBytes int64              `json:"declared_size_bytes"`
	SizeBytes         int64              `json:"size_bytes"`
	ContentHash       string             `json:"content_hash"`
	ObjectBucket      string             `json:"object_bucket"`
	ObjectKey         string             `json:"object_key"`
	ObjectEtag        string             `json:"object_etag"`
	DocumentID        string             `json:"document_id"`
	Summary           string             `json:"summary"`
	Metadata          []byte             `json:"metadata"`
	ErrorCode         string             `json:"error_code"`
	ErrorMessage      string             `json:"error_message"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UploadedAt        pgtype.Timestamptz `json:"uploaded_at"`
	AcceptedAt        pgtype.Timestamptz `json:"accepted_at"`
	ProcessedAt       pgtype.Timestamptz `json:"processed_at"`
	SearchableAt      pgtype.Timestamptz `json:"searchable_at"`
	CompletedAt       pgtype.Timestamptz `json:"completed_at"`
	DeletedAt         pgtype.Timestamptz `json:"deleted_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
}

type AuraCacheMetrics

type AuraCacheMetrics struct {
	ConversationID pgtype.UUID        `json:"conversation_id"`
	Seq            int32              `json:"seq"`
	Ts             pgtype.Timestamptz `json:"ts"`
	PromptTokens   int32              `json:"prompt_tokens"`
	CachedTokens   int32              `json:"cached_tokens"`
	CostUsd        pgtype.Numeric     `json:"cost_usd"`
}

Per-turn KV-cache metrics (Slice 4 / Phase 6, D-02). Append-only: one row per completed assistant turn from llm.Usage (token counts + cost only, no message content).

type AuraCapabilityGrants

type AuraCapabilityGrants struct {
	IdentityID pgtype.UUID        `json:"identity_id"`
	Capability string             `json:"capability"`
	GrantedAt  pgtype.Timestamptz `json:"granted_at"`
}

Per-identity capability grants. Wildcard `*` is system-managed (seeded, never grant/revoke via CLI).

type AuraContextRotEvents

type AuraContextRotEvents struct {
	Ts             pgtype.Timestamptz `json:"ts"`
	ConversationID pgtype.UUID        `json:"conversation_id"`
	Action         string             `json:"action"`
	PairsDropped   int32              `json:"pairs_dropped"`
	TokensBefore   int32              `json:"tokens_before"`
	TokensAfter    int32              `json:"tokens_after"`
}

L2.5 hard-rolling-buffer audit (amendment #22). One row per pair-drop; never written when L1 alone suffices (SC-1).

type AuraConversationTurns

type AuraConversationTurns struct {
	ConversationID     pgtype.UUID        `json:"conversation_id"`
	Seq                int32              `json:"seq"`
	Role               string             `json:"role"`
	Content            pgtype.Text        `json:"content"`
	ContentSidecarPath pgtype.Text        `json:"content_sidecar_path"`
	ToolCallID         pgtype.Text        `json:"tool_call_id"`
	ToolCalls          []byte             `json:"tool_calls"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	InputTokens        int32              `json:"input_tokens"`
	OutputTokens       int32              `json:"output_tokens"`
	CachedTokens       int32              `json:"cached_tokens"`
	// D-09 branch tree (CHAT-05): the branch a turn belongs to. All-zero UUID = the per-conversation canonical branch (pre-0017 backfill).
	BranchID pgtype.UUID `json:"branch_id"`
	// D-09 branch tree (CHAT-05): seq of the parent turn within the conversation; NULL at the root (seq=1). Canonical backfill: seq-1.
	ParentSeq pgtype.Int4 `json:"parent_seq"`
}

Per-turn rows (Slice 1.8). content NULL + content_sidecar_path set when content > AURA_CONVERSATION_TURN_CAP_BYTES.

type AuraConversations

type AuraConversations struct {
	ID                pgtype.UUID        `json:"id"`
	Title             pgtype.Text        `json:"title"`
	IdentityID        pgtype.UUID        `json:"identity_id"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	LastActiveAt      pgtype.Timestamptz `json:"last_active_at"`
	Status            string             `json:"status"`
	Model             string             `json:"model"`
	TotalInputTokens  int64              `json:"total_input_tokens"`
	TotalOutputTokens int64              `json:"total_output_tokens"`
	TotalCachedTokens int64              `json:"total_cached_tokens"`
	TotalCostUsd      pgtype.Numeric     `json:"total_cost_usd"`
	Metadata          []byte             `json:"metadata"`
}

Multi-thread persisted conversations (Slice 1.8). Aggregates token + USD totals per thread.

type AuraDocumentIngestJobs

type AuraDocumentIngestJobs struct {
	ID             pgtype.UUID        `json:"id"`
	SourceID       string             `json:"source_id"`
	SourceKind     string             `json:"source_kind"`
	DocumentID     string             `json:"document_id"`
	ContentHash    string             `json:"content_hash"`
	OriginalPath   string             `json:"original_path"`
	FileName       string             `json:"file_name"`
	MimeType       string             `json:"mime_type"`
	SizeBytes      int64              `json:"size_bytes"`
	Status         string             `json:"status"`
	SparseChunks   int32              `json:"sparse_chunks"`
	EmbeddedChunks int32              `json:"embedded_chunks"`
	Error          pgtype.Text        `json:"error"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	UpdatedAt      pgtype.Timestamptz `json:"updated_at"`
	SearchableAt   pgtype.Timestamptz `json:"searchable_at"`
	CompletedAt    pgtype.Timestamptz `json:"completed_at"`
}

Durable document ingestion job state. Neo4j stores document/chunk graph data; Postgres tracks lifecycle and progress.

type AuraIdentities

type AuraIdentities struct {
	ID        pgtype.UUID        `json:"id"`
	Name      string             `json:"name"`
	Kind      string             `json:"kind"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

Identity scaffolding (Slice 1.7). Single-user: one seeded `local`/system row with the fixed UUID ...001.

type AuraIdentityAudit added in v1.0.1

type AuraIdentityAudit struct {
	ID                  pgtype.UUID        `json:"id"`
	CreatedAt           pgtype.Timestamptz `json:"created_at"`
	ActorIdentityID     string             `json:"actor_identity_id"`
	NewIdentityID       pgtype.UUID        `json:"new_identity_id"`
	NewIdentityName     string             `json:"new_identity_name"`
	GrantedCapabilities []string           `json:"granted_capabilities"`
	AuthulaUserID       string             `json:"authula_user_id"`
}

Append-only identity-provisioning audit ledger (Phase 28, ONBD-01a). aura_app has SELECT+INSERT only; UPDATE/DELETE raise via a row trigger and TRUNCATE via a statement trigger (Pitfall 1/6). One immutable row per successful onboarding provision, written inside the provisioning db.WithTx.

type AuraIdentityAuthLinks struct {
	IdentityID    pgtype.UUID        `json:"identity_id"`
	AuthulaUserID string             `json:"authula_user_id"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
}

Maps an Authula user-id to a seeded aura.identities row (spec §5). Single-operator: the operator user pins to `local` (…0001). The A2 session-validate seam maps authula user-id -> this identity_id -> principalKey{}.

type AuraKnowledgeMigrations

type AuraKnowledgeMigrations struct {
	Version   int32              `json:"version"`
	Name      string             `json:"name"`
	Checksum  string             `json:"checksum"`
	AppliedAt pgtype.Timestamptz `json:"applied_at"`
}

Audit of applied Cypher migrations. Written by aura neo4j migrate; read by aura neo4j status.

type AuraPausedStates

type AuraPausedStates struct {
	Token              pgtype.UUID        `json:"token"`
	ConversationID     pgtype.UUID        `json:"conversation_id"`
	Kind               string             `json:"kind"`
	Question           string             `json:"question"`
	Options            []byte             `json:"options"`
	Priority           int32              `json:"priority"`
	ResumeContext      []byte             `json:"resume_context"`
	ToolCallID         string             `json:"tool_call_id"`
	ProxiedFromChildID pgtype.Text        `json:"proxied_from_child_id"`
	ProxiedToolCallID  pgtype.Text        `json:"proxied_tool_call_id"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	ResumedAt          pgtype.Timestamptz `json:"resumed_at"`
	ResumedAnswer      []byte             `json:"resumed_answer"`
}

ask_user HITL pauses (Slice 1.5). Pending = resumed_at IS NULL. FIFO order: priority DESC, created_at ASC, token ASC.

type AuraPendingNotifications

type AuraPendingNotifications struct {
	ID          pgtype.UUID        `json:"id"`
	RunID       pgtype.UUID        `json:"run_id"`
	NotifyRoute pgtype.Text        `json:"notify_route"`
	Body        string             `json:"body"`
	NotifyAfter pgtype.Timestamptz `json:"notify_after"`
	Attempts    int32              `json:"attempts"`
	LastError   pgtype.Text        `json:"last_error"`
	Status      string             `json:"status"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
	// Stable owning identity snapshot (Phase 20, Fork 1): the channel-independent delivery key for the deferred/failed sweep route-back. Plain text, no FK — survives a deleted origin conversation. NULL for legacy/CLI rows → falls back to notify_route.
	IdentityID pgtype.Text `json:"identity_id"`
}

Durable scheduler notification queue (Phase 19 H6/H7): quiet-hours deferred notifications and failed self-send retry state.

type AuraSchedulerTasks

type AuraSchedulerTasks struct {
	ID                   pgtype.UUID        `json:"id"`
	Kind                 string             `json:"kind"`
	ScheduleKind         string             `json:"schedule_kind"`
	CronExpr             pgtype.Text        `json:"cron_expr"`
	EveryMinutes         pgtype.Int4        `json:"every_minutes"`
	RunAt                pgtype.Timestamptz `json:"run_at"`
	Tz                   string             `json:"tz"`
	Payload              []byte             `json:"payload"`
	StepBudget           pgtype.Int4        `json:"step_budget"`
	Status               string             `json:"status"`
	NextRunAt            pgtype.Timestamptz `json:"next_run_at"`
	NotifyRoute          pgtype.Text        `json:"notify_route"`
	IdentityID           string             `json:"identity_id"`
	OriginConversationID pgtype.UUID        `json:"origin_conversation_id"`
	CreatedAt            pgtype.Timestamptz `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz `json:"updated_at"`
}

Scheduler task definitions (Slice 6 / Phase 10, amendment #46). Grammar triad at|every|cron with per-task IANA tz; next_run_at is UTC, recomputed in-zone (D-06/D-07).

type AuraSkillAudit

type AuraSkillAudit struct {
	ID             pgtype.UUID        `json:"id"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
	ActorID        string             `json:"actor_id"`
	IdentityID     string             `json:"identity_id"`
	SkillName      string             `json:"skill_name"`
	Action         string             `json:"action"`
	ContentHash    string             `json:"content_hash"`
	ApprovalSource pgtype.Text        `json:"approval_source"`
	// Historical ask_user pause token. Intentionally not a live FK: paused_states are ephemeral and may be cascade-deleted with their conversation while audit rows remain append-only.
	PausedStateToken  pgtype.UUID `json:"paused_state_token"`
	GateRecommended   bool        `json:"gate_recommended"`
	GateTaken         bool        `json:"gate_taken"`
	BlocklistOverride bool        `json:"blocklist_override"`
}

Append-only skill-mutation audit ledger (Slice 7c / Phase 11, D-29). aura_app has SELECT+INSERT only; UPDATE/DELETE raise via a row trigger and TRUNCATE via a statement trigger (Pitfall 1/6). The D-29 coherence CHECK constrains the approval tuple to five allowed events; content_hash is the D-23 recovery path on every row.

type AuraTelegramAccounts

type AuraTelegramAccounts struct {
	TelegramUserID int64              `json:"telegram_user_id"`
	IdentityID     pgtype.UUID        `json:"identity_id"`
	Username       pgtype.Text        `json:"username"`
	FirstName      pgtype.Text        `json:"first_name"`
	AddedAt        pgtype.Timestamptz `json:"added_at"`
	LastSeenAt     pgtype.Timestamptz `json:"last_seen_at"`
}

Known Telegram accounts (Slice 9a / Phase 13, amendment #58). PK telegram_user_id; identity_id FKs aura.identities (single-user `local` this phase, D-07).

type AuraTelegramSetupPending

type AuraTelegramSetupPending struct {
	OnboardingToken string             `json:"onboarding_token"`
	IdentityID      pgtype.UUID        `json:"identity_id"`
	GeneratedBy     pgtype.Text        `json:"generated_by"`
	CreatedAt       pgtype.Timestamptz `json:"created_at"`
	ExpiresAt       pgtype.Timestamptz `json:"expires_at"`
	ConsumedAt      pgtype.Timestamptz `json:"consumed_at"`
}

Single-use onboarding tokens (Slice 9a / Phase 13, amendment #58). consumed_at marks the token spent (T-13-01-TokenReplay); expires_at is a 1h TTL; the partial active index keys the cleanup scan.

type AuraToolInvocations

type AuraToolInvocations struct {
	ID                pgtype.UUID        `json:"id"`
	ConversationID    pgtype.UUID        `json:"conversation_id"`
	RequestID         pgtype.UUID        `json:"request_id"`
	ToolCallID        string             `json:"tool_call_id"`
	ToolName          string             `json:"tool_name"`
	EventKind         string             `json:"event_kind"`
	Seq               int32              `json:"seq"`
	Ts                pgtype.Timestamptz `json:"ts"`
	StartedAt         pgtype.Timestamptz `json:"started_at"`
	EndedAt           pgtype.Timestamptz `json:"ended_at"`
	DurationMs        pgtype.Int8        `json:"duration_ms"`
	ArgsRaw           pgtype.Text        `json:"args_raw"`
	ArgsBytes         pgtype.Int4        `json:"args_bytes"`
	Status            pgtype.Text        `json:"status"`
	Error             pgtype.Text        `json:"error"`
	ResultPreview     pgtype.Text        `json:"result_preview"`
	PreviewBytes      pgtype.Int4        `json:"preview_bytes"`
	ResultBytes       pgtype.Int4        `json:"result_bytes"`
	ResultTruncated   pgtype.Bool        `json:"result_truncated"`
	ResultSidecarPath pgtype.Text        `json:"result_sidecar_path"`
	ExitCode          pgtype.Int4        `json:"exit_code"`
	Meta              []byte             `json:"meta"`
}

Append-only tool invocation ledger: start/end facts for dispatched tools with args, timestamps, status, bytes, sidecar path, exit code, and typed metadata.

type AutoResolvePendingForConversationParams

type AutoResolvePendingForConversationParams struct {
	ConversationID pgtype.UUID `json:"conversation_id"`
	ResumedAnswer  []byte      `json:"resumed_answer"`
}

type CompleteRunParams

type CompleteRunParams struct {
	ID                pgtype.UUID `json:"id"`
	Status            string      `json:"status"`
	Summary           pgtype.Text `json:"summary"`
	LastError         pgtype.Text `json:"last_error"`
	CompletedWithHash pgtype.Text `json:"completed_with_hash"`
}

type CreateAssetParams added in v1.0.0

type CreateAssetParams struct {
	IdentityID        pgtype.UUID `json:"identity_id"`
	SourceKind        string      `json:"source_kind"`
	SourceRef         string      `json:"source_ref"`
	ThreadID          string      `json:"thread_id"`
	Scope             string      `json:"scope"`
	Modality          string      `json:"modality"`
	Status            string      `json:"status"`
	FileName          string      `json:"file_name"`
	MimeType          string      `json:"mime_type"`
	DeclaredSizeBytes int64       `json:"declared_size_bytes"`
	ObjectBucket      string      `json:"object_bucket"`
	ObjectKey         string      `json:"object_key"`
	Metadata          []byte      `json:"metadata"`
}

type CreateConversationParams

type CreateConversationParams struct {
	ID         pgtype.UUID `json:"id"`
	IdentityID pgtype.UUID `json:"identity_id"`
	Model      string      `json:"model"`
	Metadata   []byte      `json:"metadata"`
}

type CreateDocumentIngestJobParams

type CreateDocumentIngestJobParams struct {
	SourceID     string `json:"source_id"`
	SourceKind   string `json:"source_kind"`
	DocumentID   string `json:"document_id"`
	ContentHash  string `json:"content_hash"`
	OriginalPath string `json:"original_path"`
	FileName     string `json:"file_name"`
	MimeType     string `json:"mime_type"`
	SizeBytes    int64  `json:"size_bytes"`
	Status       string `json:"status"`
}

type CreateIdentityParams

type CreateIdentityParams struct {
	ID   pgtype.UUID `json:"id"`
	Name string      `json:"name"`
	Kind string      `json:"kind"`
}

type CreateTaskParams

type CreateTaskParams struct {
	ID                   pgtype.UUID        `json:"id"`
	Kind                 string             `json:"kind"`
	ScheduleKind         string             `json:"schedule_kind"`
	CronExpr             pgtype.Text        `json:"cron_expr"`
	EveryMinutes         pgtype.Int4        `json:"every_minutes"`
	RunAt                pgtype.Timestamptz `json:"run_at"`
	Tz                   string             `json:"tz"`
	Payload              []byte             `json:"payload"`
	StepBudget           pgtype.Int4        `json:"step_budget"`
	Status               string             `json:"status"`
	NextRunAt            pgtype.Timestamptz `json:"next_run_at"`
	NotifyRoute          pgtype.Text        `json:"notify_route"`
	IdentityID           string             `json:"identity_id"`
	OriginConversationID pgtype.UUID        `json:"origin_conversation_id"`
}

type DBTX

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
}

type GetAssetForIdentityParams added in v1.0.0

type GetAssetForIdentityParams struct {
	ID         pgtype.UUID `json:"id"`
	IdentityID pgtype.UUID `json:"identity_id"`
}

type GetTurnPointersParams added in v1.0.0

type GetTurnPointersParams struct {
	ConversationID pgtype.UUID `json:"conversation_id"`
	Seq            int32       `json:"seq"`
}

type GetTurnPointersRow added in v1.0.0

type GetTurnPointersRow struct {
	Seq       int32       `json:"seq"`
	BranchID  pgtype.UUID `json:"branch_id"`
	ParentSeq pgtype.Int4 `json:"parent_seq"`
	Role      string      `json:"role"`
}

type GrantCapabilityParams

type GrantCapabilityParams struct {
	IdentityID pgtype.UUID `json:"identity_id"`
	Capability string      `json:"capability"`
}

type HasCapabilityParams

type HasCapabilityParams struct {
	IdentityID pgtype.UUID `json:"identity_id"`
	Capability string      `json:"capability"`
}

type InsertAssetEventParams added in v1.0.0

type InsertAssetEventParams struct {
	AssetID    pgtype.UUID `json:"asset_id"`
	Seq        int32       `json:"seq"`
	FromStatus string      `json:"from_status"`
	ToStatus   string      `json:"to_status"`
	Reason     string      `json:"reason"`
	Detail     []byte      `json:"detail"`
}

type InsertCacheMetricParams

type InsertCacheMetricParams struct {
	ConversationID pgtype.UUID    `json:"conversation_id"`
	Seq            int32          `json:"seq"`
	PromptTokens   int32          `json:"prompt_tokens"`
	CachedTokens   int32          `json:"cached_tokens"`
	CostUsd        pgtype.Numeric `json:"cost_usd"`
}

type InsertContextRotEventParams

type InsertContextRotEventParams struct {
	ConversationID pgtype.UUID `json:"conversation_id"`
	Action         string      `json:"action"`
	PairsDropped   int32       `json:"pairs_dropped"`
	TokensBefore   int32       `json:"tokens_before"`
	TokensAfter    int32       `json:"tokens_after"`
}

type InsertConversationTurnParams

type InsertConversationTurnParams struct {
	ConversationID     pgtype.UUID `json:"conversation_id"`
	Seq                int32       `json:"seq"`
	Role               string      `json:"role"`
	Content            pgtype.Text `json:"content"`
	ContentSidecarPath pgtype.Text `json:"content_sidecar_path"`
	ToolCallID         pgtype.Text `json:"tool_call_id"`
	ToolCalls          []byte      `json:"tool_calls"`
	InputTokens        int32       `json:"input_tokens"`
	OutputTokens       int32       `json:"output_tokens"`
	CachedTokens       int32       `json:"cached_tokens"`
}

type InsertIdentityAuditParams added in v1.0.1

type InsertIdentityAuditParams struct {
	ActorIdentityID     string      `json:"actor_identity_id"`
	NewIdentityID       pgtype.UUID `json:"new_identity_id"`
	NewIdentityName     string      `json:"new_identity_name"`
	GrantedCapabilities []string    `json:"granted_capabilities"`
	AuthulaUserID       string      `json:"authula_user_id"`
}

type InsertPausedStateParams

type InsertPausedStateParams struct {
	Token              pgtype.UUID `json:"token"`
	ConversationID     pgtype.UUID `json:"conversation_id"`
	Kind               string      `json:"kind"`
	Question           string      `json:"question"`
	Options            []byte      `json:"options"`
	Priority           int32       `json:"priority"`
	ResumeContext      []byte      `json:"resume_context"`
	ToolCallID         string      `json:"tool_call_id"`
	ProxiedFromChildID pgtype.Text `json:"proxied_from_child_id"`
	ProxiedToolCallID  pgtype.Text `json:"proxied_tool_call_id"`
}

type InsertPendingNotificationParams

type InsertPendingNotificationParams struct {
	ID          pgtype.UUID        `json:"id"`
	RunID       pgtype.UUID        `json:"run_id"`
	NotifyRoute pgtype.Text        `json:"notify_route"`
	Body        string             `json:"body"`
	NotifyAfter pgtype.Timestamptz `json:"notify_after"`
	Attempts    int32              `json:"attempts"`
	LastError   pgtype.Text        `json:"last_error"`
	Status      string             `json:"status"`
	IdentityID  pgtype.Text        `json:"identity_id"`
}

type InsertRunParams

type InsertRunParams struct {
	ID         pgtype.UUID `json:"id"`
	TaskID     pgtype.UUID `json:"task_id"`
	StepBudget pgtype.Int4 `json:"step_budget"`
}

type InsertSkillAuditParams

type InsertSkillAuditParams struct {
	ActorID           string      `json:"actor_id"`
	IdentityID        string      `json:"identity_id"`
	SkillName         string      `json:"skill_name"`
	Action            string      `json:"action"`
	ContentHash       string      `json:"content_hash"`
	ApprovalSource    pgtype.Text `json:"approval_source"`
	PausedStateToken  pgtype.UUID `json:"paused_state_token"`
	GateRecommended   bool        `json:"gate_recommended"`
	GateTaken         bool        `json:"gate_taken"`
	BlocklistOverride bool        `json:"blocklist_override"`
}

type InsertTelegramAccountParams

type InsertTelegramAccountParams struct {
	TelegramUserID int64       `json:"telegram_user_id"`
	IdentityID     pgtype.UUID `json:"identity_id"`
	Username       pgtype.Text `json:"username"`
	FirstName      pgtype.Text `json:"first_name"`
}

type InsertTelegramSetupPendingParams

type InsertTelegramSetupPendingParams struct {
	OnboardingToken string             `json:"onboarding_token"`
	IdentityID      pgtype.UUID        `json:"identity_id"`
	GeneratedBy     pgtype.Text        `json:"generated_by"`
	ExpiresAt       pgtype.Timestamptz `json:"expires_at"`
}

type InsertToolInvocationParams

type InsertToolInvocationParams struct {
	ConversationID    pgtype.UUID        `json:"conversation_id"`
	RequestID         pgtype.UUID        `json:"request_id"`
	ToolCallID        string             `json:"tool_call_id"`
	ToolName          string             `json:"tool_name"`
	EventKind         string             `json:"event_kind"`
	Seq               int32              `json:"seq"`
	Ts                pgtype.Timestamptz `json:"ts"`
	StartedAt         pgtype.Timestamptz `json:"started_at"`
	EndedAt           pgtype.Timestamptz `json:"ended_at"`
	DurationMs        pgtype.Int8        `json:"duration_ms"`
	ArgsRaw           pgtype.Text        `json:"args_raw"`
	ArgsBytes         pgtype.Int4        `json:"args_bytes"`
	Status            pgtype.Text        `json:"status"`
	Error             pgtype.Text        `json:"error"`
	ResultPreview     pgtype.Text        `json:"result_preview"`
	PreviewBytes      pgtype.Int4        `json:"preview_bytes"`
	ResultBytes       pgtype.Int4        `json:"result_bytes"`
	ResultTruncated   pgtype.Bool        `json:"result_truncated"`
	ResultSidecarPath pgtype.Text        `json:"result_sidecar_path"`
	ExitCode          pgtype.Int4        `json:"exit_code"`
	Meta              []byte             `json:"meta"`
}

type ListAssetsForLibraryParams added in v1.0.0

type ListAssetsForLibraryParams struct {
	IdentityID pgtype.UUID `json:"identity_id"`
	Limit      int32       `json:"limit"`
}

type ListAssetsForThreadParams added in v1.0.0

type ListAssetsForThreadParams struct {
	IdentityID pgtype.UUID `json:"identity_id"`
	ThreadID   string      `json:"thread_id"`
}

type ListBranchLeavesRow added in v1.0.0

type ListBranchLeavesRow struct {
	Seq       int32       `json:"seq"`
	BranchID  pgtype.UUID `json:"branch_id"`
	ParentSeq pgtype.Int4 `json:"parent_seq"`
}

type ListIdentityAuditParams added in v1.0.1

type ListIdentityAuditParams struct {
	Limit         int32       `json:"limit"`
	NewIdentityID pgtype.UUID `json:"new_identity_id"`
}

type ListRunsForTaskParams added in v1.0.1

type ListRunsForTaskParams struct {
	TaskID pgtype.UUID `json:"task_id"`
	Limit  int32       `json:"limit"`
	Offset int32       `json:"offset"`
}

type ListSkillAuditParams

type ListSkillAuditParams struct {
	Limit     int32              `json:"limit"`
	SkillName pgtype.Text        `json:"skill_name"`
	Since     pgtype.Timestamptz `json:"since"`
}

type ListTurnsByBranchPathParams added in v1.0.0

type ListTurnsByBranchPathParams struct {
	ConversationID pgtype.UUID `json:"conversation_id"`
	Seq            int32       `json:"seq"`
}

type ListTurnsByBranchPathRow added in v1.0.0

type ListTurnsByBranchPathRow struct {
	ConversationID     pgtype.UUID        `json:"conversation_id"`
	Seq                int32              `json:"seq"`
	Role               string             `json:"role"`
	Content            pgtype.Text        `json:"content"`
	ContentSidecarPath pgtype.Text        `json:"content_sidecar_path"`
	ToolCallID         pgtype.Text        `json:"tool_call_id"`
	ToolCalls          []byte             `json:"tool_calls"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	InputTokens        int32              `json:"input_tokens"`
	OutputTokens       int32              `json:"output_tokens"`
	CachedTokens       int32              `json:"cached_tokens"`
}

type ListTurnsBySeqRow added in v1.0.0

type ListTurnsBySeqRow struct {
	ConversationID     pgtype.UUID        `json:"conversation_id"`
	Seq                int32              `json:"seq"`
	Role               string             `json:"role"`
	Content            pgtype.Text        `json:"content"`
	ContentSidecarPath pgtype.Text        `json:"content_sidecar_path"`
	ToolCallID         pgtype.Text        `json:"tool_call_id"`
	ToolCalls          []byte             `json:"tool_calls"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	InputTokens        int32              `json:"input_tokens"`
	OutputTokens       int32              `json:"output_tokens"`
	CachedTokens       int32              `json:"cached_tokens"`
}

type MarkNotificationFailedParams

type MarkNotificationFailedParams struct {
	ID        pgtype.UUID `json:"id"`
	LastError pgtype.Text `json:"last_error"`
}

type MarkPausedStateResumedParams

type MarkPausedStateResumedParams struct {
	Token         pgtype.UUID `json:"token"`
	ResumedAnswer []byte      `json:"resumed_answer"`
}

type PromoteAssetToLibraryParams added in v1.0.0

type PromoteAssetToLibraryParams struct {
	ID         pgtype.UUID `json:"id"`
	IdentityID pgtype.UUID `json:"identity_id"`
}

type Querier

type Querier interface {
	AggregateCacheMetricsSince(ctx context.Context, since pgtype.Timestamptz) (AggregateCacheMetricsSinceRow, error)
	AutoResolvePendingForConversation(ctx context.Context, arg AutoResolvePendingForConversationParams) error
	CancelTask(ctx context.Context, id pgtype.UUID) error
	// D-09 (CHAT-05): the leaf (deepest) seq of a conversation's canonical branch — the
	// all-zero sentinel branch every pre-0017 turn is backfilled onto. For a non-branched
	// conversation this is just MAX(seq), so a branch-path walk from this leaf reconstructs
	// the same linear history ListTurnsBySeq returns (byte-identity, store.go:250). Returns
	// 0 when the conversation has no turns.
	CanonicalBranchLeafSeq(ctx context.Context, conversationID pgtype.UUID) (int32, error)
	CleanupResumedOlderThan(ctx context.Context, resumedAt pgtype.Timestamptz) error
	CompleteRun(ctx context.Context, arg CompleteRunParams) error
	// ConsumeTelegramSetupPending atomically marks an unconsumed, unexpired token as
	// consumed and returns it. The consumed_at IS NULL guard makes the consume
	// single-use: a second consume of the same token matches no row (RETURNING is
	// empty → sql.ErrNoRows / pgx.ErrNoRows → ErrTokenConsumed). The expires_at guard
	// rejects a stale token in the same statement.
	ConsumeTelegramSetupPending(ctx context.Context, onboardingToken string) (AuraTelegramSetupPending, error)
	CountTelegramAccounts(ctx context.Context) (int64, error)
	CountTurns(ctx context.Context, conversationID pgtype.UUID) (int64, error)
	CreateAsset(ctx context.Context, arg CreateAssetParams) (AuraAssets, error)
	CreateConversation(ctx context.Context, arg CreateConversationParams) (AuraConversations, error)
	CreateDocumentIngestJob(ctx context.Context, arg CreateDocumentIngestJobParams) (AuraDocumentIngestJobs, error)
	CreateIdentity(ctx context.Context, arg CreateIdentityParams) (AuraIdentities, error)
	CreateTask(ctx context.Context, arg CreateTaskParams) (AuraSchedulerTasks, error)
	DeleteConversation(ctx context.Context, id pgtype.UUID) error
	DeleteExpiredTelegramSetupPending(ctx context.Context) (int64, error)
	DeleteIdentity(ctx context.Context, name string) error
	// Claim correctness is held by the per-task pg_try_advisory_lock (claim.go), NOT a
	// row lock here: this SELECT runs on the autocommit pool, so any FOR UPDATE SKIP
	// LOCKED would release the instant the SELECT returns (inert, L5). The advisory lock
	// is what makes each due task a singleton across concurrent workers.
	DueTasks(ctx context.Context, limit int32) ([]AuraSchedulerTasks, error)
	GetAsset(ctx context.Context, id pgtype.UUID) (AuraAssets, error)
	GetAssetForIdentity(ctx context.Context, arg GetAssetForIdentityParams) (AuraAssets, error)
	GetConversation(ctx context.Context, id pgtype.UUID) (AuraConversations, error)
	GetDocumentIngestJob(ctx context.Context, id pgtype.UUID) (AuraDocumentIngestJobs, error)
	GetDocumentIngestJobByDocumentID(ctx context.Context, documentID string) (AuraDocumentIngestJobs, error)
	GetIdentityByID(ctx context.Context, id pgtype.UUID) (AuraIdentities, error)
	GetIdentityByName(ctx context.Context, name string) (AuraIdentities, error)
	GetPausedStateByToken(ctx context.Context, token pgtype.UUID) (AuraPausedStates, error)
	GetRun(ctx context.Context, id pgtype.UUID) (AuraAgentJobRuns, error)
	GetTask(ctx context.Context, id pgtype.UUID) (AuraSchedulerTasks, error)
	GetTelegramAccountByIdentity(ctx context.Context, identityID pgtype.UUID) (AuraTelegramAccounts, error)
	GetTelegramAccountByTelegramID(ctx context.Context, telegramUserID int64) (AuraTelegramAccounts, error)
	GetTelegramSetupPending(ctx context.Context, onboardingToken string) (AuraTelegramSetupPending, error)
	// D-09 (CHAT-05): a turn's own branch/parent pointers, used by the fork path to read the
	// diverging turn's parent_seq (the new sibling chains off the SAME parent so it replaces
	// the diverging turn rather than appending after it). Returns pgx.ErrNoRows when the seq
	// is absent (mapped to a clean 404 at the boundary).
	GetTurnPointers(ctx context.Context, arg GetTurnPointersParams) (GetTurnPointersRow, error)
	GrantCapability(ctx context.Context, arg GrantCapabilityParams) error
	HasCapability(ctx context.Context, arg HasCapabilityParams) (bool, error)
	InsertAssetEvent(ctx context.Context, arg InsertAssetEventParams) error
	// Idempotent on (conversation_id, seq): the metric write is a separate, non-transactional
	// observation following the assistant turn (runner_persist.go). ON CONFLICT DO NOTHING
	// makes a re-run for an already-recorded turn a no-op rather than a PK violation or a
	// duplicate, so a retry after a transient failure can never double-count the metric (WR-03).
	InsertCacheMetric(ctx context.Context, arg InsertCacheMetricParams) error
	InsertContextRotEvent(ctx context.Context, arg InsertContextRotEventParams) error
	InsertConversationTurn(ctx context.Context, arg InsertConversationTurnParams) error
	InsertIdentityAudit(ctx context.Context, arg InsertIdentityAuditParams) (AuraIdentityAudit, error)
	InsertPausedState(ctx context.Context, arg InsertPausedStateParams) error
	InsertPendingNotification(ctx context.Context, arg InsertPendingNotificationParams) (AuraPendingNotifications, error)
	InsertRun(ctx context.Context, arg InsertRunParams) (AuraAgentJobRuns, error)
	InsertSkillAudit(ctx context.Context, arg InsertSkillAuditParams) (AuraSkillAudit, error)
	InsertTelegramAccount(ctx context.Context, arg InsertTelegramAccountParams) (AuraTelegramAccounts, error)
	InsertTelegramSetupPending(ctx context.Context, arg InsertTelegramSetupPendingParams) error
	InsertToolInvocation(ctx context.Context, arg InsertToolInvocationParams) error
	ListActiveTasks(ctx context.Context) ([]AuraSchedulerTasks, error)
	// Cross-thread pending list (APRV-01 / D-04): the same SELECT as
	// ListPendingPausedStates with NO conversation_id filter, so the approval center
	// can aggregate every still-pending pause across ALL conversations. KEEPS the
	// mandatory total-order tiebreaker (priority DESC, created_at ASC, token ASC) —
	// `token ASC` is non-negotiable because tx-batched rows share created_at = now()
	// (RESEARCH Pitfall 4 / askuser/store.go:158-160), so without it the order would
	// be non-deterministic. LIMIT $1 caps the scan (a single operator's pending set is
	// tiny; no new index is warranted — RESEARCH A4).
	ListAllPendingPausedStates(ctx context.Context, limit int32) ([]AuraPausedStates, error)
	ListAppliedKnowledgeMigrations(ctx context.Context) ([]AuraKnowledgeMigrations, error)
	ListAssetsForLibrary(ctx context.Context, arg ListAssetsForLibraryParams) ([]AuraAssets, error)
	ListAssetsForThread(ctx context.Context, arg ListAssetsForThreadParams) ([]AuraAssets, error)
	// D-09 (CHAT-05): the navigable branch set. A leaf is a turn that is NOT the parent of
	// any other turn (no row's parent_seq points at it) — i.e. the tip of a branch path. The
	// BranchPicker navigates among these sibling leaves; a re-run continues over the selected
	// leaf's path (ListTurnsByBranchPath). Ordered by branch_id then seq so the canonical
	// (all-zero) branch sorts first and the order is stable across calls.
	ListBranchLeaves(ctx context.Context, conversationID pgtype.UUID) ([]ListBranchLeavesRow, error)
	ListCacheMetricsSince(ctx context.Context, since pgtype.Timestamptz) ([]AuraCacheMetrics, error)
	ListCapabilities(ctx context.Context, identityID pgtype.UUID) ([]AuraCapabilityGrants, error)
	ListContextRotEvents(ctx context.Context, conversationID pgtype.UUID) ([]AuraContextRotEvents, error)
	ListConversations(ctx context.Context, includeArchived bool) ([]AuraConversations, error)
	ListIdentities(ctx context.Context) ([]AuraIdentities, error)
	ListIdentityAudit(ctx context.Context, arg ListIdentityAuditParams) ([]AuraIdentityAudit, error)
	ListPendingPausedStates(ctx context.Context, conversationID pgtype.UUID) ([]AuraPausedStates, error)
	ListRecentDocumentIngestJobs(ctx context.Context, limit int32) ([]AuraDocumentIngestJobs, error)
	ListRecentPausedStates(ctx context.Context, limit int32) ([]AuraPausedStates, error)
	ListRunsForTask(ctx context.Context, arg ListRunsForTaskParams) ([]AuraAgentJobRuns, error)
	ListSkillAudit(ctx context.Context, arg ListSkillAuditParams) ([]AuraSkillAudit, error)
	ListSkillAuditByName(ctx context.Context, skillName string) ([]AuraSkillAudit, error)
	ListTelegramAccounts(ctx context.Context) ([]AuraTelegramAccounts, error)
	ListToolInvocationsByConversation(ctx context.Context, conversationID pgtype.UUID) ([]AuraToolInvocations, error)
	// D-09 (CHAT-05): the deterministic leaf->root path walk. Given a selected leaf seq,
	// follow parent_seq up to the root, then return the turns in root->leaf (seq ASC) order
	// so the head (system seq=1 + the always-block) is byte-identical to the linear case —
	// only the body turns differ per branch (Pitfall 3 rule 1). The column list MIRRORS
	// ListTurnsBySeq exactly so turnFromRow rehydrates it unchanged. A leaf seq of 0 (or one
	// not present) yields an empty path. Walk terminates at parent_seq IS NULL (the root).
	ListTurnsByBranchPath(ctx context.Context, arg ListTurnsByBranchPathParams) ([]ListTurnsByBranchPathRow, error)
	ListTurnsBySeq(ctx context.Context, conversationID pgtype.UUID) ([]ListTurnsBySeqRow, error)
	LockConversationForTurnAppend(ctx context.Context, id pgtype.UUID) (pgtype.UUID, error)
	MarkNotificationDelivered(ctx context.Context, id pgtype.UUID) error
	MarkNotificationFailed(ctx context.Context, arg MarkNotificationFailedParams) error
	MarkPausedStateResumed(ctx context.Context, arg MarkPausedStateResumedParams) error
	MarkUnknownRecovery(ctx context.Context, id pgtype.UUID) error
	NextAssetEventSeq(ctx context.Context, assetID pgtype.UUID) (int32, error)
	NextConversationTurnSeq(ctx context.Context, conversationID pgtype.UUID) (int32, error)
	PromoteAssetToLibrary(ctx context.Context, arg PromoteAssetToLibraryParams) (AuraAssets, error)
	RecordKnowledgeMigration(ctx context.Context, arg RecordKnowledgeMigrationParams) error
	RenameConversation(ctx context.Context, arg RenameConversationParams) error
	RevokeCapability(ctx context.Context, arg RevokeCapabilityParams) error
	ScanStaleRuns(ctx context.Context, secs float64) ([]ScanStaleRunsRow, error)
	// LOCKED cross-slice contract (D-A5-03 / SPEC Req#13). Telegram /search (Phase 13)
	// reuses this EXACT query; only the excerpt rendering differs per channel.
	SearchConversationTurns(ctx context.Context, arg SearchConversationTurnsParams) ([]SearchConversationTurnsRow, error)
	SetConversationTitleIfNull(ctx context.Context, arg SetConversationTitleIfNullParams) error
	// D-09 (CHAT-05): set a turn's branch/parent pointers. The branch-write seam plan 25-07
	// uses when an edit/regenerate forks a new sibling branch off an existing parent turn.
	SetTurnBranchPointers(ctx context.Context, arg SetTurnBranchPointersParams) error
	SoftDeleteAsset(ctx context.Context, arg SoftDeleteAssetParams) (AuraAssets, error)
	SweepDueNotifications(ctx context.Context, arg SweepDueNotificationsParams) ([]AuraPendingNotifications, error)
	TouchTelegramLastSeen(ctx context.Context, telegramUserID int64) error
	UpdateAssetAccepted(ctx context.Context, arg UpdateAssetAcceptedParams) (AuraAssets, error)
	UpdateAssetResult(ctx context.Context, arg UpdateAssetResultParams) (AuraAssets, error)
	UpdateAssetStatus(ctx context.Context, arg UpdateAssetStatusParams) (AuraAssets, error)
	UpdateAssetUploaded(ctx context.Context, arg UpdateAssetUploadedParams) (AuraAssets, error)
	UpdateConversationAggregates(ctx context.Context, arg UpdateConversationAggregatesParams) error
	UpdateConversationStatus(ctx context.Context, arg UpdateConversationStatusParams) error
	UpdateDocumentIngestJobProgress(ctx context.Context, arg UpdateDocumentIngestJobProgressParams) (AuraDocumentIngestJobs, error)
	UpdateDocumentIngestJobStatus(ctx context.Context, arg UpdateDocumentIngestJobStatusParams) (AuraDocumentIngestJobs, error)
	UpdateHeartbeat(ctx context.Context, id pgtype.UUID) error
	UpdateNextRunAt(ctx context.Context, arg UpdateNextRunAtParams) error
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AggregateCacheMetricsSince

func (q *Queries) AggregateCacheMetricsSince(ctx context.Context, since pgtype.Timestamptz) (AggregateCacheMetricsSinceRow, error)

func (*Queries) AutoResolvePendingForConversation

func (q *Queries) AutoResolvePendingForConversation(ctx context.Context, arg AutoResolvePendingForConversationParams) error

func (*Queries) CancelTask

func (q *Queries) CancelTask(ctx context.Context, id pgtype.UUID) error

func (*Queries) CanonicalBranchLeafSeq added in v1.0.0

func (q *Queries) CanonicalBranchLeafSeq(ctx context.Context, conversationID pgtype.UUID) (int32, error)

D-09 (CHAT-05): the leaf (deepest) seq of a conversation's canonical branch — the all-zero sentinel branch every pre-0017 turn is backfilled onto. For a non-branched conversation this is just MAX(seq), so a branch-path walk from this leaf reconstructs the same linear history ListTurnsBySeq returns (byte-identity, store.go:250). Returns 0 when the conversation has no turns.

func (*Queries) CleanupResumedOlderThan

func (q *Queries) CleanupResumedOlderThan(ctx context.Context, resumedAt pgtype.Timestamptz) error

func (*Queries) CompleteRun

func (q *Queries) CompleteRun(ctx context.Context, arg CompleteRunParams) error

func (*Queries) ConsumeTelegramSetupPending

func (q *Queries) ConsumeTelegramSetupPending(ctx context.Context, onboardingToken string) (AuraTelegramSetupPending, error)

ConsumeTelegramSetupPending atomically marks an unconsumed, unexpired token as consumed and returns it. The consumed_at IS NULL guard makes the consume single-use: a second consume of the same token matches no row (RETURNING is empty → sql.ErrNoRows / pgx.ErrNoRows → ErrTokenConsumed). The expires_at guard rejects a stale token in the same statement.

func (*Queries) CountTelegramAccounts

func (q *Queries) CountTelegramAccounts(ctx context.Context) (int64, error)

func (*Queries) CountTurns

func (q *Queries) CountTurns(ctx context.Context, conversationID pgtype.UUID) (int64, error)

func (*Queries) CreateAsset added in v1.0.0

func (q *Queries) CreateAsset(ctx context.Context, arg CreateAssetParams) (AuraAssets, error)

func (*Queries) CreateConversation

func (q *Queries) CreateConversation(ctx context.Context, arg CreateConversationParams) (AuraConversations, error)

func (*Queries) CreateDocumentIngestJob

func (q *Queries) CreateDocumentIngestJob(ctx context.Context, arg CreateDocumentIngestJobParams) (AuraDocumentIngestJobs, error)

func (*Queries) CreateIdentity

func (q *Queries) CreateIdentity(ctx context.Context, arg CreateIdentityParams) (AuraIdentities, error)

func (*Queries) CreateTask

func (q *Queries) CreateTask(ctx context.Context, arg CreateTaskParams) (AuraSchedulerTasks, error)

func (*Queries) DeleteConversation

func (q *Queries) DeleteConversation(ctx context.Context, id pgtype.UUID) error

func (*Queries) DeleteExpiredTelegramSetupPending

func (q *Queries) DeleteExpiredTelegramSetupPending(ctx context.Context) (int64, error)

func (*Queries) DeleteIdentity

func (q *Queries) DeleteIdentity(ctx context.Context, name string) error

func (*Queries) DueTasks

func (q *Queries) DueTasks(ctx context.Context, limit int32) ([]AuraSchedulerTasks, error)

Claim correctness is held by the per-task pg_try_advisory_lock (claim.go), NOT a row lock here: this SELECT runs on the autocommit pool, so any FOR UPDATE SKIP LOCKED would release the instant the SELECT returns (inert, L5). The advisory lock is what makes each due task a singleton across concurrent workers.

func (*Queries) GetAsset added in v1.0.0

func (q *Queries) GetAsset(ctx context.Context, id pgtype.UUID) (AuraAssets, error)

func (*Queries) GetAssetForIdentity added in v1.0.0

func (q *Queries) GetAssetForIdentity(ctx context.Context, arg GetAssetForIdentityParams) (AuraAssets, error)

func (*Queries) GetConversation

func (q *Queries) GetConversation(ctx context.Context, id pgtype.UUID) (AuraConversations, error)

func (*Queries) GetDocumentIngestJob

func (q *Queries) GetDocumentIngestJob(ctx context.Context, id pgtype.UUID) (AuraDocumentIngestJobs, error)

func (*Queries) GetDocumentIngestJobByDocumentID

func (q *Queries) GetDocumentIngestJobByDocumentID(ctx context.Context, documentID string) (AuraDocumentIngestJobs, error)

func (*Queries) GetIdentityByID

func (q *Queries) GetIdentityByID(ctx context.Context, id pgtype.UUID) (AuraIdentities, error)

func (*Queries) GetIdentityByName

func (q *Queries) GetIdentityByName(ctx context.Context, name string) (AuraIdentities, error)

func (*Queries) GetPausedStateByToken

func (q *Queries) GetPausedStateByToken(ctx context.Context, token pgtype.UUID) (AuraPausedStates, error)

func (*Queries) GetRun

func (q *Queries) GetRun(ctx context.Context, id pgtype.UUID) (AuraAgentJobRuns, error)

func (*Queries) GetTask

func (q *Queries) GetTask(ctx context.Context, id pgtype.UUID) (AuraSchedulerTasks, error)

func (*Queries) GetTelegramAccountByIdentity

func (q *Queries) GetTelegramAccountByIdentity(ctx context.Context, identityID pgtype.UUID) (AuraTelegramAccounts, error)

func (*Queries) GetTelegramAccountByTelegramID

func (q *Queries) GetTelegramAccountByTelegramID(ctx context.Context, telegramUserID int64) (AuraTelegramAccounts, error)

func (*Queries) GetTelegramSetupPending

func (q *Queries) GetTelegramSetupPending(ctx context.Context, onboardingToken string) (AuraTelegramSetupPending, error)

func (*Queries) GetTurnPointers added in v1.0.0

func (q *Queries) GetTurnPointers(ctx context.Context, arg GetTurnPointersParams) (GetTurnPointersRow, error)

D-09 (CHAT-05): a turn's own branch/parent pointers, used by the fork path to read the diverging turn's parent_seq (the new sibling chains off the SAME parent so it replaces the diverging turn rather than appending after it). Returns pgx.ErrNoRows when the seq is absent (mapped to a clean 404 at the boundary).

func (*Queries) GrantCapability

func (q *Queries) GrantCapability(ctx context.Context, arg GrantCapabilityParams) error

func (*Queries) HasCapability

func (q *Queries) HasCapability(ctx context.Context, arg HasCapabilityParams) (bool, error)

func (*Queries) InsertAssetEvent added in v1.0.0

func (q *Queries) InsertAssetEvent(ctx context.Context, arg InsertAssetEventParams) error

func (*Queries) InsertCacheMetric

func (q *Queries) InsertCacheMetric(ctx context.Context, arg InsertCacheMetricParams) error

Idempotent on (conversation_id, seq): the metric write is a separate, non-transactional observation following the assistant turn (runner_persist.go). ON CONFLICT DO NOTHING makes a re-run for an already-recorded turn a no-op rather than a PK violation or a duplicate, so a retry after a transient failure can never double-count the metric (WR-03).

func (*Queries) InsertContextRotEvent

func (q *Queries) InsertContextRotEvent(ctx context.Context, arg InsertContextRotEventParams) error

func (*Queries) InsertConversationTurn

func (q *Queries) InsertConversationTurn(ctx context.Context, arg InsertConversationTurnParams) error

func (*Queries) InsertIdentityAudit added in v1.0.1

func (q *Queries) InsertIdentityAudit(ctx context.Context, arg InsertIdentityAuditParams) (AuraIdentityAudit, error)

func (*Queries) InsertPausedState

func (q *Queries) InsertPausedState(ctx context.Context, arg InsertPausedStateParams) error

func (*Queries) InsertPendingNotification

func (q *Queries) InsertPendingNotification(ctx context.Context, arg InsertPendingNotificationParams) (AuraPendingNotifications, error)

func (*Queries) InsertRun

func (q *Queries) InsertRun(ctx context.Context, arg InsertRunParams) (AuraAgentJobRuns, error)

func (*Queries) InsertSkillAudit

func (q *Queries) InsertSkillAudit(ctx context.Context, arg InsertSkillAuditParams) (AuraSkillAudit, error)

func (*Queries) InsertTelegramAccount

func (q *Queries) InsertTelegramAccount(ctx context.Context, arg InsertTelegramAccountParams) (AuraTelegramAccounts, error)

func (*Queries) InsertTelegramSetupPending

func (q *Queries) InsertTelegramSetupPending(ctx context.Context, arg InsertTelegramSetupPendingParams) error

func (*Queries) InsertToolInvocation

func (q *Queries) InsertToolInvocation(ctx context.Context, arg InsertToolInvocationParams) error

func (*Queries) ListActiveTasks

func (q *Queries) ListActiveTasks(ctx context.Context) ([]AuraSchedulerTasks, error)

func (*Queries) ListAllPendingPausedStates added in v1.0.0

func (q *Queries) ListAllPendingPausedStates(ctx context.Context, limit int32) ([]AuraPausedStates, error)

Cross-thread pending list (APRV-01 / D-04): the same SELECT as ListPendingPausedStates with NO conversation_id filter, so the approval center can aggregate every still-pending pause across ALL conversations. KEEPS the mandatory total-order tiebreaker (priority DESC, created_at ASC, token ASC) — `token ASC` is non-negotiable because tx-batched rows share created_at = now() (RESEARCH Pitfall 4 / askuser/store.go:158-160), so without it the order would be non-deterministic. LIMIT $1 caps the scan (a single operator's pending set is tiny; no new index is warranted — RESEARCH A4).

func (*Queries) ListAppliedKnowledgeMigrations

func (q *Queries) ListAppliedKnowledgeMigrations(ctx context.Context) ([]AuraKnowledgeMigrations, error)

func (*Queries) ListAssetsForLibrary added in v1.0.0

func (q *Queries) ListAssetsForLibrary(ctx context.Context, arg ListAssetsForLibraryParams) ([]AuraAssets, error)

func (*Queries) ListAssetsForThread added in v1.0.0

func (q *Queries) ListAssetsForThread(ctx context.Context, arg ListAssetsForThreadParams) ([]AuraAssets, error)

func (*Queries) ListBranchLeaves added in v1.0.0

func (q *Queries) ListBranchLeaves(ctx context.Context, conversationID pgtype.UUID) ([]ListBranchLeavesRow, error)

D-09 (CHAT-05): the navigable branch set. A leaf is a turn that is NOT the parent of any other turn (no row's parent_seq points at it) — i.e. the tip of a branch path. The BranchPicker navigates among these sibling leaves; a re-run continues over the selected leaf's path (ListTurnsByBranchPath). Ordered by branch_id then seq so the canonical (all-zero) branch sorts first and the order is stable across calls.

func (*Queries) ListCacheMetricsSince

func (q *Queries) ListCacheMetricsSince(ctx context.Context, since pgtype.Timestamptz) ([]AuraCacheMetrics, error)

func (*Queries) ListCapabilities

func (q *Queries) ListCapabilities(ctx context.Context, identityID pgtype.UUID) ([]AuraCapabilityGrants, error)

func (*Queries) ListContextRotEvents

func (q *Queries) ListContextRotEvents(ctx context.Context, conversationID pgtype.UUID) ([]AuraContextRotEvents, error)

func (*Queries) ListConversations

func (q *Queries) ListConversations(ctx context.Context, includeArchived bool) ([]AuraConversations, error)

func (*Queries) ListIdentities

func (q *Queries) ListIdentities(ctx context.Context) ([]AuraIdentities, error)

func (*Queries) ListIdentityAudit added in v1.0.1

func (q *Queries) ListIdentityAudit(ctx context.Context, arg ListIdentityAuditParams) ([]AuraIdentityAudit, error)

func (*Queries) ListPendingPausedStates

func (q *Queries) ListPendingPausedStates(ctx context.Context, conversationID pgtype.UUID) ([]AuraPausedStates, error)

func (*Queries) ListRecentDocumentIngestJobs

func (q *Queries) ListRecentDocumentIngestJobs(ctx context.Context, limit int32) ([]AuraDocumentIngestJobs, error)

func (*Queries) ListRecentPausedStates

func (q *Queries) ListRecentPausedStates(ctx context.Context, limit int32) ([]AuraPausedStates, error)

func (*Queries) ListRunsForTask added in v1.0.1

func (q *Queries) ListRunsForTask(ctx context.Context, arg ListRunsForTaskParams) ([]AuraAgentJobRuns, error)

func (*Queries) ListSkillAudit

func (q *Queries) ListSkillAudit(ctx context.Context, arg ListSkillAuditParams) ([]AuraSkillAudit, error)

func (*Queries) ListSkillAuditByName

func (q *Queries) ListSkillAuditByName(ctx context.Context, skillName string) ([]AuraSkillAudit, error)

func (*Queries) ListTelegramAccounts

func (q *Queries) ListTelegramAccounts(ctx context.Context) ([]AuraTelegramAccounts, error)

func (*Queries) ListToolInvocationsByConversation

func (q *Queries) ListToolInvocationsByConversation(ctx context.Context, conversationID pgtype.UUID) ([]AuraToolInvocations, error)

func (*Queries) ListTurnsByBranchPath added in v1.0.0

func (q *Queries) ListTurnsByBranchPath(ctx context.Context, arg ListTurnsByBranchPathParams) ([]ListTurnsByBranchPathRow, error)

D-09 (CHAT-05): the deterministic leaf->root path walk. Given a selected leaf seq, follow parent_seq up to the root, then return the turns in root->leaf (seq ASC) order so the head (system seq=1 + the always-block) is byte-identical to the linear case — only the body turns differ per branch (Pitfall 3 rule 1). The column list MIRRORS ListTurnsBySeq exactly so turnFromRow rehydrates it unchanged. A leaf seq of 0 (or one not present) yields an empty path. Walk terminates at parent_seq IS NULL (the root).

func (*Queries) ListTurnsBySeq

func (q *Queries) ListTurnsBySeq(ctx context.Context, conversationID pgtype.UUID) ([]ListTurnsBySeqRow, error)

func (*Queries) LockConversationForTurnAppend

func (q *Queries) LockConversationForTurnAppend(ctx context.Context, id pgtype.UUID) (pgtype.UUID, error)

func (*Queries) MarkNotificationDelivered

func (q *Queries) MarkNotificationDelivered(ctx context.Context, id pgtype.UUID) error

func (*Queries) MarkNotificationFailed

func (q *Queries) MarkNotificationFailed(ctx context.Context, arg MarkNotificationFailedParams) error

func (*Queries) MarkPausedStateResumed

func (q *Queries) MarkPausedStateResumed(ctx context.Context, arg MarkPausedStateResumedParams) error

func (*Queries) MarkUnknownRecovery

func (q *Queries) MarkUnknownRecovery(ctx context.Context, id pgtype.UUID) error

func (*Queries) NextAssetEventSeq added in v1.0.0

func (q *Queries) NextAssetEventSeq(ctx context.Context, assetID pgtype.UUID) (int32, error)

func (*Queries) NextConversationTurnSeq

func (q *Queries) NextConversationTurnSeq(ctx context.Context, conversationID pgtype.UUID) (int32, error)

func (*Queries) PromoteAssetToLibrary added in v1.0.0

func (q *Queries) PromoteAssetToLibrary(ctx context.Context, arg PromoteAssetToLibraryParams) (AuraAssets, error)

func (*Queries) RecordKnowledgeMigration

func (q *Queries) RecordKnowledgeMigration(ctx context.Context, arg RecordKnowledgeMigrationParams) error

func (*Queries) RenameConversation

func (q *Queries) RenameConversation(ctx context.Context, arg RenameConversationParams) error

func (*Queries) RevokeCapability

func (q *Queries) RevokeCapability(ctx context.Context, arg RevokeCapabilityParams) error

func (*Queries) ScanStaleRuns

func (q *Queries) ScanStaleRuns(ctx context.Context, secs float64) ([]ScanStaleRunsRow, error)

func (*Queries) SearchConversationTurns

func (q *Queries) SearchConversationTurns(ctx context.Context, arg SearchConversationTurnsParams) ([]SearchConversationTurnsRow, error)

LOCKED cross-slice contract (D-A5-03 / SPEC Req#13). Telegram /search (Phase 13) reuses this EXACT query; only the excerpt rendering differs per channel.

func (*Queries) SetConversationTitleIfNull

func (q *Queries) SetConversationTitleIfNull(ctx context.Context, arg SetConversationTitleIfNullParams) error

func (*Queries) SetTurnBranchPointers added in v1.0.0

func (q *Queries) SetTurnBranchPointers(ctx context.Context, arg SetTurnBranchPointersParams) error

D-09 (CHAT-05): set a turn's branch/parent pointers. The branch-write seam plan 25-07 uses when an edit/regenerate forks a new sibling branch off an existing parent turn.

func (*Queries) SoftDeleteAsset added in v1.0.0

func (q *Queries) SoftDeleteAsset(ctx context.Context, arg SoftDeleteAssetParams) (AuraAssets, error)

func (*Queries) SweepDueNotifications

func (q *Queries) SweepDueNotifications(ctx context.Context, arg SweepDueNotificationsParams) ([]AuraPendingNotifications, error)

func (*Queries) TouchTelegramLastSeen

func (q *Queries) TouchTelegramLastSeen(ctx context.Context, telegramUserID int64) error

func (*Queries) UpdateAssetAccepted added in v1.0.0

func (q *Queries) UpdateAssetAccepted(ctx context.Context, arg UpdateAssetAcceptedParams) (AuraAssets, error)

func (*Queries) UpdateAssetResult added in v1.0.0

func (q *Queries) UpdateAssetResult(ctx context.Context, arg UpdateAssetResultParams) (AuraAssets, error)

func (*Queries) UpdateAssetStatus added in v1.0.0

func (q *Queries) UpdateAssetStatus(ctx context.Context, arg UpdateAssetStatusParams) (AuraAssets, error)

func (*Queries) UpdateAssetUploaded added in v1.0.0

func (q *Queries) UpdateAssetUploaded(ctx context.Context, arg UpdateAssetUploadedParams) (AuraAssets, error)

func (*Queries) UpdateConversationAggregates

func (q *Queries) UpdateConversationAggregates(ctx context.Context, arg UpdateConversationAggregatesParams) error

func (*Queries) UpdateConversationStatus

func (q *Queries) UpdateConversationStatus(ctx context.Context, arg UpdateConversationStatusParams) error

func (*Queries) UpdateDocumentIngestJobProgress

func (q *Queries) UpdateDocumentIngestJobProgress(ctx context.Context, arg UpdateDocumentIngestJobProgressParams) (AuraDocumentIngestJobs, error)

func (*Queries) UpdateDocumentIngestJobStatus

func (q *Queries) UpdateDocumentIngestJobStatus(ctx context.Context, arg UpdateDocumentIngestJobStatusParams) (AuraDocumentIngestJobs, error)

func (*Queries) UpdateHeartbeat

func (q *Queries) UpdateHeartbeat(ctx context.Context, id pgtype.UUID) error

func (*Queries) UpdateNextRunAt

func (q *Queries) UpdateNextRunAt(ctx context.Context, arg UpdateNextRunAtParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RecordKnowledgeMigrationParams

type RecordKnowledgeMigrationParams struct {
	Version  int32  `json:"version"`
	Name     string `json:"name"`
	Checksum string `json:"checksum"`
}

type RenameConversationParams

type RenameConversationParams struct {
	ID    pgtype.UUID `json:"id"`
	Title pgtype.Text `json:"title"`
}

type RevokeCapabilityParams

type RevokeCapabilityParams struct {
	IdentityID pgtype.UUID `json:"identity_id"`
	Capability string      `json:"capability"`
}

type ScanStaleRunsRow

type ScanStaleRunsRow struct {
	ID     pgtype.UUID `json:"id"`
	TaskID pgtype.UUID `json:"task_id"`
}

type SearchConversationTurnsParams

type SearchConversationTurnsParams struct {
	Similarity string `json:"similarity"`
	Limit      int32  `json:"limit"`
}

type SearchConversationTurnsRow

type SearchConversationTurnsRow struct {
	ConversationID pgtype.UUID `json:"conversation_id"`
	Seq            int32       `json:"seq"`
	Content        pgtype.Text `json:"content"`
	Sim            float32     `json:"sim"`
}

type SetConversationTitleIfNullParams

type SetConversationTitleIfNullParams struct {
	ID    pgtype.UUID `json:"id"`
	Title pgtype.Text `json:"title"`
}

type SetTurnBranchPointersParams added in v1.0.0

type SetTurnBranchPointersParams struct {
	ConversationID pgtype.UUID `json:"conversation_id"`
	Seq            int32       `json:"seq"`
	BranchID       pgtype.UUID `json:"branch_id"`
	ParentSeq      pgtype.Int4 `json:"parent_seq"`
}

type SoftDeleteAssetParams added in v1.0.0

type SoftDeleteAssetParams struct {
	ID         pgtype.UUID `json:"id"`
	IdentityID pgtype.UUID `json:"identity_id"`
}

type SweepDueNotificationsParams

type SweepDueNotificationsParams struct {
	Attempts int32 `json:"attempts"`
	Limit    int32 `json:"limit"`
}

type UpdateAssetAcceptedParams added in v1.0.0

type UpdateAssetAcceptedParams struct {
	ID          pgtype.UUID `json:"id"`
	IdentityID  pgtype.UUID `json:"identity_id"`
	SizeBytes   int64       `json:"size_bytes"`
	ContentHash string      `json:"content_hash"`
	MimeType    string      `json:"mime_type"`
}

type UpdateAssetResultParams added in v1.0.0

type UpdateAssetResultParams struct {
	ID         pgtype.UUID `json:"id"`
	IdentityID pgtype.UUID `json:"identity_id"`
	Status     string      `json:"status"`
	DocumentID string      `json:"document_id"`
	Summary    string      `json:"summary"`
	Metadata   []byte      `json:"metadata"`
}

type UpdateAssetStatusParams added in v1.0.0

type UpdateAssetStatusParams struct {
	ID           pgtype.UUID `json:"id"`
	IdentityID   pgtype.UUID `json:"identity_id"`
	Status       string      `json:"status"`
	ErrorCode    string      `json:"error_code"`
	ErrorMessage string      `json:"error_message"`
}

type UpdateAssetUploadedParams added in v1.0.0

type UpdateAssetUploadedParams struct {
	ID         pgtype.UUID `json:"id"`
	IdentityID pgtype.UUID `json:"identity_id"`
	SizeBytes  int64       `json:"size_bytes"`
	ObjectEtag string      `json:"object_etag"`
}

type UpdateConversationAggregatesParams

type UpdateConversationAggregatesParams struct {
	InputTokens  int64          `json:"input_tokens"`
	OutputTokens int64          `json:"output_tokens"`
	CachedTokens int64          `json:"cached_tokens"`
	CostUsd      pgtype.Numeric `json:"cost_usd"`
	ID           pgtype.UUID    `json:"id"`
}

type UpdateConversationStatusParams

type UpdateConversationStatusParams struct {
	ID     pgtype.UUID `json:"id"`
	Status string      `json:"status"`
}

type UpdateDocumentIngestJobProgressParams

type UpdateDocumentIngestJobProgressParams struct {
	ID             pgtype.UUID `json:"id"`
	Status         string      `json:"status"`
	SparseChunks   int32       `json:"sparse_chunks"`
	EmbeddedChunks int32       `json:"embedded_chunks"`
}

type UpdateDocumentIngestJobStatusParams

type UpdateDocumentIngestJobStatusParams struct {
	ID     pgtype.UUID `json:"id"`
	Status string      `json:"status"`
	Error  pgtype.Text `json:"error"`
}

type UpdateNextRunAtParams

type UpdateNextRunAtParams struct {
	ID        pgtype.UUID        `json:"id"`
	NextRunAt pgtype.Timestamptz `json:"next_run_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL