db

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvanceBackfillCursorParams

type AdvanceBackfillCursorParams struct {
	CursorLinkedAt   int64  `json:"cursor_linked_at"`
	CursorCommitHash string `json:"cursor_commit_hash"`
	UpdatedAt        int64  `json:"updated_at"`
	ConnectedRepoID  string `json:"connected_repo_id"`
}

type AgentEvent

type AgentEvent struct {
	EventID           string         `json:"event_id"`
	SessionID         string         `json:"session_id"`
	RepositoryID      string         `json:"repository_id"`
	Ts                int64          `json:"ts"`
	Kind              string         `json:"kind"`
	PayloadHash       sql.NullString `json:"payload_hash"`
	Role              sql.NullString `json:"role"`
	ToolUses          sql.NullString `json:"tool_uses"`
	TokensIn          sql.NullInt64  `json:"tokens_in"`
	TokensOut         sql.NullInt64  `json:"tokens_out"`
	TokensCacheRead   sql.NullInt64  `json:"tokens_cache_read"`
	TokensCacheCreate sql.NullInt64  `json:"tokens_cache_create"`
	Summary           sql.NullString `json:"summary"`
	ProviderEventID   sql.NullString `json:"provider_event_id"`
	TurnID            sql.NullString `json:"turn_id"`
	ToolUseID         sql.NullString `json:"tool_use_id"`
	ToolName          sql.NullString `json:"tool_name"`
	EventSource       string         `json:"event_source"`
	ProvenanceHash    sql.NullString `json:"provenance_hash"`
	InsertSeq         sql.NullInt64  `json:"insert_seq"`
}
type AgentEventEvidenceLink struct {
	EventID      string `json:"event_id"`
	EvidenceKind string `json:"evidence_kind"`
	EvidenceHash string `json:"evidence_hash"`
	GroupID      string `json:"group_id"`
	CreatedAt    int64  `json:"created_at"`
}

type AgentSession

type AgentSession struct {
	SessionID         string         `json:"session_id"`
	ProviderSessionID string         `json:"provider_session_id"`
	ParentSessionID   sql.NullString `json:"parent_session_id"`
	RepositoryID      string         `json:"repository_id"`
	Provider          string         `json:"provider"`
	SourceID          string         `json:"source_id"`
	StartedAt         int64          `json:"started_at"`
	LastSeenAt        int64          `json:"last_seen_at"`
	MetadataJson      string         `json:"metadata_json"`
	SourceRepoPath    sql.NullString `json:"source_repo_path"`
	Model             sql.NullString `json:"model"`
}

type AgentSource

type AgentSource struct {
	SourceID     string `json:"source_id"`
	RepositoryID string `json:"repository_id"`
	Provider     string `json:"provider"`
	SourceKey    string `json:"source_key"`
	LastSeenAt   int64  `json:"last_seen_at"`
	CreatedAt    int64  `json:"created_at"`
}

type Checkpoint

type Checkpoint struct {
	CheckpointID       string         `json:"checkpoint_id"`
	RepositoryID       string         `json:"repository_id"`
	CreatedAt          int64          `json:"created_at"`
	Kind               string         `json:"kind"`
	Trigger            sql.NullString `json:"trigger"`
	Message            sql.NullString `json:"message"`
	ManifestHash       sql.NullString `json:"manifest_hash"`
	SizeBytes          sql.NullInt64  `json:"size_bytes"`
	Status             string         `json:"status"`
	CompletedAt        sql.NullInt64  `json:"completed_at"`
	SummaryJson        sql.NullString `json:"summary_json"`
	SummaryModel       sql.NullString `json:"summary_model"`
	RepositorySequence int64          `json:"repository_sequence"`
	EventCursor        sql.NullInt64  `json:"event_cursor"`
	AttemptCount       int64          `json:"attempt_count"`
	LastError          sql.NullString `json:"last_error"`
	NextAttemptAt      int64          `json:"next_attempt_at"`
	LeaseOwner         sql.NullString `json:"lease_owner"`
	LeaseUntil         sql.NullInt64  `json:"lease_until"`
}

type CheckpointStat

type CheckpointStat struct {
	CheckpointID          string        `json:"checkpoint_id"`
	SessionCount          int64         `json:"session_count"`
	FilesChanged          int64         `json:"files_changed"`
	AiPercentage          float64       `json:"ai_percentage"`
	AttributionComputedAt sql.NullInt64 `json:"attribution_computed_at"`
	AttributionPushedAt   sql.NullInt64 `json:"attribution_pushed_at"`
}

type ClaimCheckpointParams added in v0.6.0

type ClaimCheckpointParams struct {
	LeaseOwner   sql.NullString `json:"lease_owner"`
	LeaseUntil   sql.NullInt64  `json:"lease_until"`
	CheckpointID string         `json:"checkpoint_id"`
	Now          int64          `json:"now"`
}
type CommitLink struct {
	CommitHash   string `json:"commit_hash"`
	RepositoryID string `json:"repository_id"`
	CheckpointID string `json:"checkpoint_id"`
	LinkedAt     int64  `json:"linked_at"`
}

type CompleteBackfillParams

type CompleteBackfillParams struct {
	UpdatedAt       int64  `json:"updated_at"`
	ConnectedRepoID string `json:"connected_repo_id"`
}

type CompleteCheckpointParams

type CompleteCheckpointParams struct {
	ManifestHash sql.NullString `json:"manifest_hash"`
	SizeBytes    sql.NullInt64  `json:"size_bytes"`
	CompletedAt  sql.NullInt64  `json:"completed_at"`
	CheckpointID string         `json:"checkpoint_id"`
}

type CountManifestsByStatusParams added in v0.3.9

type CountManifestsByStatusParams struct {
	RepositoryID string `json:"repository_id"`
	CreatedAt    int64  `json:"created_at"`
}

type CountManifestsByStatusRow added in v0.3.9

type CountManifestsByStatusRow struct {
	Status string `json:"status"`
	Count  int64  `json:"count"`
}

type CountWindowTurnProvenanceParams added in v0.6.0

type CountWindowTurnProvenanceParams struct {
	RepositoryID string        `json:"repository_id"`
	UseCursor    int64         `json:"use_cursor"`
	AfterTs      int64         `json:"after_ts"`
	AfterCursor  sql.NullInt64 `json:"after_cursor"`
	UpToTs       int64         `json:"up_to_ts"`
	UpToCursor   sql.NullInt64 `json:"up_to_cursor"`
}

type CountWindowTurnProvenanceRow added in v0.6.0

type CountWindowTurnProvenanceRow struct {
	TotalTurns        int64 `json:"total_turns"`
	PackagedTurns     int64 `json:"packaged_turns"`
	UploadedTurns     int64 `json:"uploaded_turns"`
	FailedUploadTurns int64 `json:"failed_upload_turns"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type FailCheckpointParams

type FailCheckpointParams struct {
	CompletedAt  sql.NullInt64  `json:"completed_at"`
	LastError    sql.NullString `json:"last_error"`
	CheckpointID string         `json:"checkpoint_id"`
}

type GetAgentSessionByProviderIDParams

type GetAgentSessionByProviderIDParams struct {
	RepositoryID      string `json:"repository_id"`
	Provider          string `json:"provider"`
	ProviderSessionID string `json:"provider_session_id"`
}

type GetCheckpointSummaryRow

type GetCheckpointSummaryRow struct {
	CheckpointID string         `json:"checkpoint_id"`
	SummaryJson  sql.NullString `json:"summary_json"`
	SummaryModel sql.NullString `json:"summary_model"`
}

type GetEvidenceLinkParams added in v0.6.0

type GetEvidenceLinkParams struct {
	EventID      string `json:"event_id"`
	EvidenceKind string `json:"evidence_kind"`
	GroupID      string `json:"group_id"`
}

type GetLatestCommitLinkRow

type GetLatestCommitLinkRow struct {
	CommitHash string `json:"commit_hash"`
	LinkedAt   int64  `json:"linked_at"`
}

type GetManifestCommitLinkParams

type GetManifestCommitLinkParams struct {
	SessionID string `json:"session_id"`
	CreatedAt int64  `json:"created_at"`
}

type GetManifestCommitLinkRow

type GetManifestCommitLinkRow struct {
	CommitHash   string `json:"commit_hash"`
	CheckpointID string `json:"checkpoint_id"`
}

type GetMostRecentParentSessionWithEventsParams added in v0.4.0

type GetMostRecentParentSessionWithEventsParams struct {
	RepositoryID string `json:"repository_id"`
	SinceTs      int64  `json:"since_ts"`
}

type GetMostRecentSessionByProviderWithEventsParams added in v0.4.0

type GetMostRecentSessionByProviderWithEventsParams struct {
	RepositoryID string `json:"repository_id"`
	Provider     string `json:"provider"`
	SinceTs      int64  `json:"since_ts"`
}

type GetNextToolResultAfterParams

type GetNextToolResultAfterParams struct {
	SessionID string         `json:"session_id"`
	TurnID    sql.NullString `json:"turn_id"`
	Ts        int64          `json:"ts"`
}

type GetNextToolResultAfterRow

type GetNextToolResultAfterRow struct {
	EventID     string         `json:"event_id"`
	PayloadHash sql.NullString `json:"payload_hash"`
	Summary     sql.NullString `json:"summary"`
	Role        sql.NullString `json:"role"`
	Kind        string         `json:"kind"`
	Ts          int64          `json:"ts"`
}

type GetPreviousCommitLinkedCheckpointParams

type GetPreviousCommitLinkedCheckpointParams struct {
	RepositoryID       string `json:"repository_id"`
	RepositorySequence int64  `json:"repository_sequence"`
}

type GetPreviousCompletedCheckpointParams

type GetPreviousCompletedCheckpointParams struct {
	RepositoryID       string `json:"repository_id"`
	RepositorySequence int64  `json:"repository_sequence"`
}

type GetPromptEventForTurnParams

type GetPromptEventForTurnParams struct {
	SessionID string         `json:"session_id"`
	TurnID    sql.NullString `json:"turn_id"`
}

type GetPromptEventForTurnRow

type GetPromptEventForTurnRow struct {
	EventID     string         `json:"event_id"`
	PayloadHash sql.NullString `json:"payload_hash"`
}

type GetSessionWithStatsRow

type GetSessionWithStatsRow struct {
	SessionID         string         `json:"session_id"`
	ProviderSessionID string         `json:"provider_session_id"`
	ParentSessionID   sql.NullString `json:"parent_session_id"`
	Provider          string         `json:"provider"`
	StartedAt         int64          `json:"started_at"`
	LastEventTs       int64          `json:"last_event_ts"`
	StepCount         int64          `json:"step_count"`
	ToolCallCount     int64          `json:"tool_call_count"`
	TokensIn          int64          `json:"tokens_in"`
	TokensOut         int64          `json:"tokens_out"`
	TokensCached      int64          `json:"tokens_cached"`
}

type InsertAgentEventParams

type InsertAgentEventParams struct {
	EventID           string         `json:"event_id"`
	SessionID         string         `json:"session_id"`
	RepositoryID      string         `json:"repository_id"`
	Ts                int64          `json:"ts"`
	Kind              string         `json:"kind"`
	PayloadHash       sql.NullString `json:"payload_hash"`
	Role              sql.NullString `json:"role"`
	ToolUses          sql.NullString `json:"tool_uses"`
	TokensIn          sql.NullInt64  `json:"tokens_in"`
	TokensOut         sql.NullInt64  `json:"tokens_out"`
	TokensCacheRead   sql.NullInt64  `json:"tokens_cache_read"`
	TokensCacheCreate sql.NullInt64  `json:"tokens_cache_create"`
	Summary           sql.NullString `json:"summary"`
	ProviderEventID   sql.NullString `json:"provider_event_id"`
	TurnID            sql.NullString `json:"turn_id"`
	ToolUseID         sql.NullString `json:"tool_use_id"`
	ToolName          sql.NullString `json:"tool_name"`
	EventSource       string         `json:"event_source"`
	ProvenanceHash    sql.NullString `json:"provenance_hash"`
}

type InsertCheckpointParams

type InsertCheckpointParams struct {
	CheckpointID string         `json:"checkpoint_id"`
	RepositoryID string         `json:"repository_id"`
	CreatedAt    int64          `json:"created_at"`
	Kind         string         `json:"kind"`
	Trigger      sql.NullString `json:"trigger"`
	Message      sql.NullString `json:"message"`
	ManifestHash sql.NullString `json:"manifest_hash"`
	SizeBytes    sql.NullInt64  `json:"size_bytes"`
	Status       string         `json:"status"`
	CompletedAt  sql.NullInt64  `json:"completed_at"`
}

type InsertCommitLinkParams

type InsertCommitLinkParams struct {
	CommitHash   string `json:"commit_hash"`
	RepositoryID string `json:"repository_id"`
	CheckpointID string `json:"checkpoint_id"`
	LinkedAt     int64  `json:"linked_at"`
}

type InsertEvidenceLinkIfAbsentParams added in v0.6.0

type InsertEvidenceLinkIfAbsentParams struct {
	EventID      string `json:"event_id"`
	EvidenceKind string `json:"evidence_kind"`
	EvidenceHash string `json:"evidence_hash"`
	GroupID      string `json:"group_id"`
	CreatedAt    int64  `json:"created_at"`
}

type InsertRepositoryParams

type InsertRepositoryParams struct {
	RepositoryID string `json:"repository_id"`
	RootPath     string `json:"root_path"`
	CreatedAt    int64  `json:"created_at"`
	EnabledAt    int64  `json:"enabled_at"`
}

type InsertSessionCheckpointParams

type InsertSessionCheckpointParams struct {
	SessionID    string `json:"session_id"`
	CheckpointID string `json:"checkpoint_id"`
}

type ListAgentEventsBySessionPagedParams added in v0.2.0

type ListAgentEventsBySessionPagedParams struct {
	SessionID    string `json:"session_id"`
	AfterTs      int64  `json:"after_ts"`
	AfterEventID string `json:"after_event_id"`
	PageLimit    int64  `json:"page_limit"`
}

type ListAgentEventsBySessionParams

type ListAgentEventsBySessionParams struct {
	SessionID string `json:"session_id"`
	Limit     int64  `json:"limit"`
}

type ListAgentSessionsByProviderSessionIDParams added in v0.2.0

type ListAgentSessionsByProviderSessionIDParams struct {
	RepositoryID      string `json:"repository_id"`
	ProviderSessionID string `json:"provider_session_id"`
}

type ListBackfillReplayCandidatesParams

type ListBackfillReplayCandidatesParams struct {
	RepositoryID     string `json:"repository_id"`
	CursorLinkedAt   int64  `json:"cursor_linked_at"`
	CursorCommitHash string `json:"cursor_commit_hash"`
	CutoffLinkedAt   int64  `json:"cutoff_linked_at"`
	CutoffCommitHash string `json:"cutoff_commit_hash"`
	BatchLimit       int64  `json:"batch_limit"`
}

type ListBackfillReplayCandidatesRow

type ListBackfillReplayCandidatesRow struct {
	CommitHash   string `json:"commit_hash"`
	CheckpointID string `json:"checkpoint_id"`
	LinkedAt     int64  `json:"linked_at"`
}

type ListCheckpointsByRepositoryParams

type ListCheckpointsByRepositoryParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListCheckpointsWithCommitParams

type ListCheckpointsWithCommitParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListCheckpointsWithCommitRow

type ListCheckpointsWithCommitRow struct {
	CheckpointID string         `json:"checkpoint_id"`
	CreatedAt    int64          `json:"created_at"`
	Kind         string         `json:"kind"`
	Trigger      sql.NullString `json:"trigger"`
	Message      sql.NullString `json:"message"`
	SizeBytes    sql.NullInt64  `json:"size_bytes"`
	Status       string         `json:"status"`
	CompletedAt  sql.NullInt64  `json:"completed_at"`
	CommitHash   sql.NullString `json:"commit_hash"`
	ManifestHash sql.NullString `json:"manifest_hash"`
}

type ListCommitLinksByRepositoryParams

type ListCommitLinksByRepositoryParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListCrossRepoSessionsParams

type ListCrossRepoSessionsParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListEventsByProviderInWindowParams added in v0.3.9

type ListEventsByProviderInWindowParams struct {
	RepositoryID string `json:"repository_id"`
	Ts           int64  `json:"ts"`
}

type ListEventsByProviderInWindowRow added in v0.3.9

type ListEventsByProviderInWindowRow struct {
	Provider     string      `json:"provider"`
	EventCount   int64       `json:"event_count"`
	MostRecentTs interface{} `json:"most_recent_ts"`
}

type ListEventsBySessionASCRow

type ListEventsBySessionASCRow struct {
	EventID           string         `json:"event_id"`
	SessionID         string         `json:"session_id"`
	RepositoryID      string         `json:"repository_id"`
	Ts                int64          `json:"ts"`
	Kind              string         `json:"kind"`
	PayloadHash       sql.NullString `json:"payload_hash"`
	Role              sql.NullString `json:"role"`
	ToolUses          sql.NullString `json:"tool_uses"`
	TokensIn          sql.NullInt64  `json:"tokens_in"`
	TokensOut         sql.NullInt64  `json:"tokens_out"`
	TokensCacheRead   sql.NullInt64  `json:"tokens_cache_read"`
	TokensCacheCreate sql.NullInt64  `json:"tokens_cache_create"`
	Summary           sql.NullString `json:"summary"`
	ProviderEventID   sql.NullString `json:"provider_event_id"`
	TurnID            sql.NullString `json:"turn_id"`
	ToolUseID         sql.NullString `json:"tool_use_id"`
	ToolName          sql.NullString `json:"tool_name"`
	EventSource       string         `json:"event_source"`
	ProvenanceHash    sql.NullString `json:"provenance_hash"`
	InsertSeq         sql.NullInt64  `json:"insert_seq"`
	Provider          string         `json:"provider"`
}

type ListEventsInWindowForAnnotationsParams added in v0.6.0

type ListEventsInWindowForAnnotationsParams struct {
	RepositoryID string        `json:"repository_id"`
	UseCursor    int64         `json:"use_cursor"`
	AfterTs      int64         `json:"after_ts"`
	AfterCursor  sql.NullInt64 `json:"after_cursor"`
	UpToTs       int64         `json:"up_to_ts"`
	UpToCursor   sql.NullInt64 `json:"up_to_cursor"`
}

type ListEventsInWindowForAnnotationsRow added in v0.6.0

type ListEventsInWindowForAnnotationsRow struct {
	EventID        string         `json:"event_id"`
	SessionID      string         `json:"session_id"`
	Provider       string         `json:"provider"`
	Ts             int64          `json:"ts"`
	Role           sql.NullString `json:"role"`
	ToolUses       sql.NullString `json:"tool_uses"`
	TurnID         sql.NullString `json:"turn_id"`
	ToolName       sql.NullString `json:"tool_name"`
	PayloadHash    sql.NullString `json:"payload_hash"`
	ProvenanceHash sql.NullString `json:"provenance_hash"`
}

type ListEventsInWindowParams

type ListEventsInWindowParams struct {
	RepositoryID string        `json:"repository_id"`
	UseCursor    int64         `json:"use_cursor"`
	AfterTs      int64         `json:"after_ts"`
	AfterCursor  sql.NullInt64 `json:"after_cursor"`
	UpToTs       int64         `json:"up_to_ts"`
	UpToCursor   sql.NullInt64 `json:"up_to_cursor"`
}

type ListEventsInWindowRow

type ListEventsInWindowRow struct {
	EventID           string         `json:"event_id"`
	SessionID         string         `json:"session_id"`
	Provider          string         `json:"provider"`
	Model             sql.NullString `json:"model"`
	Ts                int64          `json:"ts"`
	Kind              string         `json:"kind"`
	Role              sql.NullString `json:"role"`
	ToolUses          sql.NullString `json:"tool_uses"`
	TokensIn          sql.NullInt64  `json:"tokens_in"`
	TokensOut         sql.NullInt64  `json:"tokens_out"`
	TokensCacheRead   sql.NullInt64  `json:"tokens_cache_read"`
	TokensCacheCreate sql.NullInt64  `json:"tokens_cache_create"`
	Summary           sql.NullString `json:"summary"`
	ProviderEventID   sql.NullString `json:"provider_event_id"`
	PayloadHash       sql.NullString `json:"payload_hash"`
	InsertSeq         sql.NullInt64  `json:"insert_seq"`
}

type ListEvidenceLinksInWindowParams added in v0.6.0

type ListEvidenceLinksInWindowParams struct {
	RepositoryID string        `json:"repository_id"`
	UseCursor    int64         `json:"use_cursor"`
	AfterTs      int64         `json:"after_ts"`
	AfterCursor  sql.NullInt64 `json:"after_cursor"`
	UpToTs       int64         `json:"up_to_ts"`
	UpToCursor   sql.NullInt64 `json:"up_to_cursor"`
}

type ListEvidenceLinksInWindowRow added in v0.6.0

type ListEvidenceLinksInWindowRow struct {
	EventID      string        `json:"event_id"`
	EvidenceHash string        `json:"evidence_hash"`
	GroupID      string        `json:"group_id"`
	Provider     string        `json:"provider"`
	Ts           int64         `json:"ts"`
	InsertSeq    sql.NullInt64 `json:"insert_seq"`
}

type ListFailedManifestReasonsParams added in v0.3.9

type ListFailedManifestReasonsParams struct {
	RepositoryID string `json:"repository_id"`
	CreatedAt    int64  `json:"created_at"`
}

type ListFailedManifestReasonsRow added in v0.3.9

type ListFailedManifestReasonsRow struct {
	LastError string `json:"last_error"`
	Count     int64  `json:"count"`
}

type ListPackagedManifestsParams

type ListPackagedManifestsParams struct {
	RepositoryID string      `json:"repository_id"`
	Column2      interface{} `json:"column_2"`
	CreatedAt    int64       `json:"created_at"`
	Limit        int64       `json:"limit"`
}

type ListPendingCommitLinkedCheckpointsRow added in v0.6.0

type ListPendingCommitLinkedCheckpointsRow struct {
	CheckpointID       string         `json:"checkpoint_id"`
	RepositorySequence int64          `json:"repository_sequence"`
	Status             string         `json:"status"`
	CommitHash         string         `json:"commit_hash"`
	AttemptCount       int64          `json:"attempt_count"`
	LastError          sql.NullString `json:"last_error"`
	NextAttemptAt      int64          `json:"next_attempt_at"`
	LeaseUntil         sql.NullInt64  `json:"lease_until"`
}

type ListPendingManifestsParams

type ListPendingManifestsParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListRecentAIPercentagesParams

type ListRecentAIPercentagesParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListRecentAIPercentagesRow

type ListRecentAIPercentagesRow struct {
	CheckpointID string  `json:"checkpoint_id"`
	AiPercentage float64 `json:"ai_percentage"`
	CreatedAt    int64   `json:"created_at"`
	CommitHash   string  `json:"commit_hash"`
}

type ListRecentSessionsWithStatsParams

type ListRecentSessionsWithStatsParams struct {
	RepositoryID string `json:"repository_id"`
	SinceTs      int64  `json:"since_ts"`
	Limit        int64  `json:"limit"`
}

type ListRecentSessionsWithStatsRow

type ListRecentSessionsWithStatsRow struct {
	SessionID         string         `json:"session_id"`
	ProviderSessionID string         `json:"provider_session_id"`
	ParentSessionID   sql.NullString `json:"parent_session_id"`
	Provider          string         `json:"provider"`
	StartedAt         int64          `json:"started_at"`
	LastEventTs       int64          `json:"last_event_ts"`
	StepCount         int64          `json:"step_count"`
	TokensIn          int64          `json:"tokens_in"`
	TokensOut         int64          `json:"tokens_out"`
	TokensCached      int64          `json:"tokens_cached"`
}

type ListSessionsForRepositoryParams

type ListSessionsForRepositoryParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListSessionsWithEventsInWindowParams

type ListSessionsWithEventsInWindowParams struct {
	RepositoryID string        `json:"repository_id"`
	UseCursor    int64         `json:"use_cursor"`
	AfterTs      int64         `json:"after_ts"`
	AfterCursor  sql.NullInt64 `json:"after_cursor"`
	UpToTs       int64         `json:"up_to_ts"`
	UpToCursor   sql.NullInt64 `json:"up_to_cursor"`
}

type ListSessionsWithStatsAllParams

type ListSessionsWithStatsAllParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListSessionsWithStatsAllRow

type ListSessionsWithStatsAllRow struct {
	SessionID         string         `json:"session_id"`
	ProviderSessionID string         `json:"provider_session_id"`
	ParentSessionID   sql.NullString `json:"parent_session_id"`
	Provider          string         `json:"provider"`
	StartedAt         int64          `json:"started_at"`
	LastEventTs       int64          `json:"last_event_ts"`
	StepCount         int64          `json:"step_count"`
	ToolCallCount     int64          `json:"tool_call_count"`
	TokensIn          int64          `json:"tokens_in"`
	TokensOut         int64          `json:"tokens_out"`
	TokensCached      int64          `json:"tokens_cached"`
}

type ListSessionsWithStatsParams

type ListSessionsWithStatsParams struct {
	RepositoryID string `json:"repository_id"`
	Limit        int64  `json:"limit"`
}

type ListSessionsWithStatsRow

type ListSessionsWithStatsRow struct {
	SessionID         string         `json:"session_id"`
	ProviderSessionID string         `json:"provider_session_id"`
	ParentSessionID   sql.NullString `json:"parent_session_id"`
	Provider          string         `json:"provider"`
	StartedAt         int64          `json:"started_at"`
	LastEventTs       int64          `json:"last_event_ts"`
	StepCount         int64          `json:"step_count"`
	ToolCallCount     int64          `json:"tool_call_count"`
	TokensIn          int64          `json:"tokens_in"`
	TokensOut         int64          `json:"tokens_out"`
	TokensCached      int64          `json:"tokens_cached"`
}

type ListStalePendingCheckpointsParams

type ListStalePendingCheckpointsParams struct {
	RepositoryID string `json:"repository_id"`
	BeforeTs     int64  `json:"before_ts"`
}

type ListStalePendingCheckpointsRow

type ListStalePendingCheckpointsRow struct {
	CheckpointID string `json:"checkpoint_id"`
	CreatedAt    int64  `json:"created_at"`
}

type ListStepCompanionResultsParams

type ListStepCompanionResultsParams struct {
	SessionID string         `json:"session_id"`
	TurnID    sql.NullString `json:"turn_id"`
	ToolUseID sql.NullString `json:"tool_use_id"`
}

type ListStepCompanionResultsRow

type ListStepCompanionResultsRow struct {
	EventID     string         `json:"event_id"`
	PayloadHash sql.NullString `json:"payload_hash"`
	Summary     sql.NullString `json:"summary"`
	Role        sql.NullString `json:"role"`
	Kind        string         `json:"kind"`
	Ts          int64          `json:"ts"`
}

type ListStepEventsForTurnParams

type ListStepEventsForTurnParams struct {
	SessionID string         `json:"session_id"`
	TurnID    sql.NullString `json:"turn_id"`
}

type ListStepEventsForTurnRow

type ListStepEventsForTurnRow struct {
	EventID        string         `json:"event_id"`
	Ts             int64          `json:"ts"`
	ToolName       sql.NullString `json:"tool_name"`
	ToolUseID      sql.NullString `json:"tool_use_id"`
	ProvenanceHash sql.NullString `json:"provenance_hash"`
	PayloadHash    sql.NullString `json:"payload_hash"`
	Summary        sql.NullString `json:"summary"`
	EventSource    string         `json:"event_source"`
	ToolUses       sql.NullString `json:"tool_uses"`
}

type ListStepProvenanceForTurnParams

type ListStepProvenanceForTurnParams struct {
	SessionID string         `json:"session_id"`
	TurnID    sql.NullString `json:"turn_id"`
}

type ListStepProvenanceForTurnRow

type ListStepProvenanceForTurnRow struct {
	EventID        string         `json:"event_id"`
	ToolUseID      sql.NullString `json:"tool_use_id"`
	ToolName       sql.NullString `json:"tool_name"`
	ProvenanceHash sql.NullString `json:"provenance_hash"`
}

type ListTranscriptEventsParams

type ListTranscriptEventsParams struct {
	RepositoryID string        `json:"repository_id"`
	UseCursor    int64         `json:"use_cursor"`
	AfterTs      int64         `json:"after_ts"`
	AfterCursor  sql.NullInt64 `json:"after_cursor"`
	UntilTs      int64         `json:"until_ts"`
	UpToCursor   sql.NullInt64 `json:"up_to_cursor"`
}

type ListTranscriptEventsRow

type ListTranscriptEventsRow struct {
	EventID           string         `json:"event_id"`
	SessionID         string         `json:"session_id"`
	Provider          string         `json:"provider"`
	Ts                int64          `json:"ts"`
	Kind              string         `json:"kind"`
	Role              sql.NullString `json:"role"`
	ToolUses          sql.NullString `json:"tool_uses"`
	TokensIn          sql.NullInt64  `json:"tokens_in"`
	TokensOut         sql.NullInt64  `json:"tokens_out"`
	TokensCacheRead   sql.NullInt64  `json:"tokens_cache_read"`
	TokensCacheCreate sql.NullInt64  `json:"tokens_cache_create"`
	Summary           sql.NullString `json:"summary"`
	ProviderEventID   sql.NullString `json:"provider_event_id"`
	PayloadHash       sql.NullString `json:"payload_hash"`
}

type ListUserPromptsForCommitRow added in v0.5.4

type ListUserPromptsForCommitRow struct {
	EventID     string         `json:"event_id"`
	TurnID      sql.NullString `json:"turn_id"`
	Ts          int64          `json:"ts"`
	Summary     sql.NullString `json:"summary"`
	PayloadHash sql.NullString `json:"payload_hash"`
}

type MarkCheckpointAttributionComputedParams added in v0.6.0

type MarkCheckpointAttributionComputedParams struct {
	CheckpointID          string        `json:"checkpoint_id"`
	AttributionComputedAt sql.NullInt64 `json:"attribution_computed_at"`
}

type MarkCheckpointAttributionPushedParams added in v0.6.0

type MarkCheckpointAttributionPushedParams struct {
	CheckpointID        string        `json:"checkpoint_id"`
	AttributionPushedAt sql.NullInt64 `json:"attribution_pushed_at"`
}

type MarkManifestFailedParams

type MarkManifestFailedParams struct {
	LastError  sql.NullString `json:"last_error"`
	UpdatedAt  int64          `json:"updated_at"`
	ManifestID string         `json:"manifest_id"`
}

type MarkManifestUploadedParams

type MarkManifestUploadedParams struct {
	UpdatedAt  int64  `json:"updated_at"`
	ManifestID string `json:"manifest_id"`
}

type MarkManifestUploadingParams

type MarkManifestUploadingParams struct {
	UpdatedAt  int64  `json:"updated_at"`
	ManifestID string `json:"manifest_id"`
}

type ProvenanceManifest

type ProvenanceManifest struct {
	ManifestID             string         `json:"manifest_id"`
	RepositoryID           string         `json:"repository_id"`
	SessionID              string         `json:"session_id"`
	TurnID                 string         `json:"turn_id"`
	Provider               string         `json:"provider"`
	Kind                   string         `json:"kind"`
	TranscriptRef          sql.NullString `json:"transcript_ref"`
	ProvenanceBundleHash   sql.NullString `json:"provenance_bundle_hash"`
	StartedAt              int64          `json:"started_at"`
	CompletedAt            sql.NullInt64  `json:"completed_at"`
	Status                 string         `json:"status"`
	UploadAttempts         int64          `json:"upload_attempts"`
	LastError              sql.NullString `json:"last_error"`
	UploadTransformVersion sql.NullInt64  `json:"upload_transform_version"`
	RemoteVerifiedAt       sql.NullInt64  `json:"remote_verified_at"`
	CreatedAt              int64          `json:"created_at"`
	UpdatedAt              int64          `json:"updated_at"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func Prepare

func Prepare(ctx context.Context, db DBTX) (*Queries, error)

func (*Queries) AdvanceBackfillCursor

func (q *Queries) AdvanceBackfillCursor(ctx context.Context, arg AdvanceBackfillCursorParams) error

Advances the cursor past a successfully pushed or skipped commit. Also clears any failure state since the head-of-line commit moved.

func (*Queries) AgentEventExists added in v0.6.0

func (q *Queries) AgentEventExists(ctx context.Context, eventID string) (bool, error)

func (*Queries) ClaimCheckpoint added in v0.6.0

func (q *Queries) ClaimCheckpoint(ctx context.Context, arg ClaimCheckpointParams) (Checkpoint, error)

Atomic claim: takes a due pending checkpoint whose lease is free or expired and increments attempt_count exactly once. A live lease on a pending row represents processing. Returns no row when unavailable.

func (*Queries) Close

func (q *Queries) Close() error

func (*Queries) CompleteBackfill

func (q *Queries) CompleteBackfill(ctx context.Context, arg CompleteBackfillParams) error

func (*Queries) CompleteCheckpoint

func (q *Queries) CompleteCheckpoint(ctx context.Context, arg CompleteCheckpointParams) error

func (*Queries) CountCheckpointsWithSummary

func (q *Queries) CountCheckpointsWithSummary(ctx context.Context, repositoryID string) (int64, error)

func (*Queries) CountManifestsByStatus added in v0.3.9

func (q *Queries) CountManifestsByStatus(ctx context.Context, arg CountManifestsByStatusParams) ([]CountManifestsByStatusRow, error)

Counts manifests by status for the repository within the given window. Used by `semantica doctor` to summarize sync state.

func (*Queries) CountSessionsForCheckpoint

func (q *Queries) CountSessionsForCheckpoint(ctx context.Context, checkpointID string) (int64, error)

func (*Queries) CountWindowTurnProvenance added in v0.6.0

Counts turn bundles in the checkpoint event window. A non-empty bundle hash means local packaging succeeded; failed rows with a hash represent terminal upload failures. Joins use repository, session, turn, and kind. Window bounds use (ts, insert_seq).

func (*Queries) DeleteCheckpointByID

func (q *Queries) DeleteCheckpointByID(ctx context.Context, checkpointID string) error

func (*Queries) FailCheckpoint

func (q *Queries) FailCheckpoint(ctx context.Context, arg FailCheckpointParams) (int64, error)

Terminal failure: permanent error or attempts exhausted; the final error is preserved for doctor and manual retry.

func (*Queries) GetActiveAgentSessionForRepo

func (q *Queries) GetActiveAgentSessionForRepo(ctx context.Context, repositoryID string) (AgentSession, error)

func (*Queries) GetAgentSessionByID

func (q *Queries) GetAgentSessionByID(ctx context.Context, sessionID string) (AgentSession, error)

func (*Queries) GetAgentSessionByProviderID

func (q *Queries) GetAgentSessionByProviderID(ctx context.Context, arg GetAgentSessionByProviderIDParams) (AgentSession, error)

func (*Queries) GetAttributionBackfill

func (q *Queries) GetAttributionBackfill(ctx context.Context, connectedRepoID string) (RemoteAttributionBackfill, error)

func (*Queries) GetCheckpointByID

func (q *Queries) GetCheckpointByID(ctx context.Context, checkpointID string) (Checkpoint, error)

func (*Queries) GetCheckpointStats

func (q *Queries) GetCheckpointStats(ctx context.Context, checkpointID string) (CheckpointStat, error)

func (*Queries) GetCheckpointSummary

func (q *Queries) GetCheckpointSummary(ctx context.Context, checkpointID string) (GetCheckpointSummaryRow, error)

func (*Queries) GetCommitLinkByCommitHash

func (q *Queries) GetCommitLinkByCommitHash(ctx context.Context, commitHash string) (CommitLink, error)

func (*Queries) GetCommitLinksByCheckpoint

func (q *Queries) GetCommitLinksByCheckpoint(ctx context.Context, checkpointID string) ([]CommitLink, error)
func (q *Queries) GetEvidenceLink(ctx context.Context, arg GetEvidenceLinkParams) (AgentEventEvidenceLink, error)

func (*Queries) GetLatestCheckpointForRepo

func (q *Queries) GetLatestCheckpointForRepo(ctx context.Context, repositoryID string) (Checkpoint, error)
func (q *Queries) GetLatestCommitLink(ctx context.Context, repositoryID string) (GetLatestCommitLinkRow, error)

Returns the most recent commit link for a repository. Used to snapshot the backfill cutoff at connect time.

func (q *Queries) GetManifestCommitLink(ctx context.Context, arg GetManifestCommitLinkParams) (GetManifestCommitLinkRow, error)

Resolves the commit link for the checkpoint that covers a manifest. First finds the earliest checkpoint in the session created at or after the manifest's start time (the covering checkpoint), then joins to commit_links. Returns no rows if the covering checkpoint has no commit.

func (*Queries) GetMostRecentCommitLinkedCheckpoint added in v0.5.2

func (q *Queries) GetMostRecentCommitLinkedCheckpoint(ctx context.Context, repositoryID string) (Checkpoint, error)

Latest completed commit-linked checkpoint by repository sequence.

func (*Queries) GetMostRecentParentSessionWithEvents added in v0.4.0

func (q *Queries) GetMostRecentParentSessionWithEvents(ctx context.Context, arg GetMostRecentParentSessionWithEventsParams) (AgentSession, error)

Used by handoff's lineage fallback when no active capture state exists for the repo (e.g. between agent turns). Returns the most recently active parent session (no parent_session_id) within the supplied last_seen_at window that has at least one event in agent_events. The recency floor is the same 24h cutoff the capture-state resolver uses, applied here against the durable agent_sessions data.

func (*Queries) GetMostRecentSessionByProviderWithEvents added in v0.4.0

func (q *Queries) GetMostRecentSessionByProviderWithEvents(ctx context.Context, arg GetMostRecentSessionByProviderWithEventsParams) (AgentSession, error)

Used by handoff's --from override to source the bundle from a specific provider's most-recent parent session in the repo, regardless of whether a different agent currently holds the active capture state. Same recency and parent-only filters as the lineage fallback, plus a provider filter for explicit cross-agent handoff.

func (*Queries) GetNextToolResultAfter

func (q *Queries) GetNextToolResultAfter(ctx context.Context, arg GetNextToolResultAfterParams) (GetNextToolResultAfterRow, error)

Temporal fallback for companion matching when tool_use_id is empty. Returns the first tool_result in the same turn after the given timestamp. Used by Claude transcript enrichment where tool_result rows lack tool_use_id.

func (*Queries) GetPreviousCommitLinkedCheckpoint

func (q *Queries) GetPreviousCommitLinkedCheckpoint(ctx context.Context, arg GetPreviousCommitLinkedCheckpointParams) (Checkpoint, error)

Ignore manual and baseline checkpoints when anchoring attribution.

func (*Queries) GetPreviousCompletedCheckpoint

func (q *Queries) GetPreviousCompletedCheckpoint(ctx context.Context, arg GetPreviousCompletedCheckpointParams) (Checkpoint, error)

Sequence selects the predecessor; timestamps bound its event window.

func (*Queries) GetPromptEventForTurn

func (q *Queries) GetPromptEventForTurn(ctx context.Context, arg GetPromptEventForTurnParams) (GetPromptEventForTurnRow, error)

func (*Queries) GetRepositoryByID

func (q *Queries) GetRepositoryByID(ctx context.Context, repositoryID string) (Repository, error)

func (*Queries) GetRepositoryByRootPath

func (q *Queries) GetRepositoryByRootPath(ctx context.Context, rootPath string) (Repository, error)

func (*Queries) GetSessionWithStats

func (q *Queries) GetSessionWithStats(ctx context.Context, sessionID string) (GetSessionWithStatsRow, error)

Single session with computed stats. Same columns as ListSessionsWithStats.

func (*Queries) InsertAgentEvent

func (q *Queries) InsertAgentEvent(ctx context.Context, arg InsertAgentEventParams) error

Allocate insert_seq under SQLite's single-writer lock.

func (*Queries) InsertCheckpoint

func (q *Queries) InsertCheckpoint(ctx context.Context, arg InsertCheckpointParams) error

Allocate sequence and event cursor in the insert transaction.

func (q *Queries) InsertCommitLink(ctx context.Context, arg InsertCommitLinkParams) error

func (*Queries) InsertEvidenceLinkIfAbsent added in v0.6.0

func (q *Queries) InsertEvidenceLinkIfAbsent(ctx context.Context, arg InsertEvidenceLinkIfAbsentParams) error

Idempotent creation half; the caller re-reads the row and fails closed on an evidence hash mismatch instead of overwriting it.

func (*Queries) InsertRepository

func (q *Queries) InsertRepository(ctx context.Context, arg InsertRepositoryParams) error

func (*Queries) InsertSessionCheckpoint

func (q *Queries) InsertSessionCheckpoint(ctx context.Context, arg InsertSessionCheckpointParams) error

func (*Queries) ListAgentEventsBySession

func (q *Queries) ListAgentEventsBySession(ctx context.Context, arg ListAgentEventsBySessionParams) ([]AgentEvent, error)

func (*Queries) ListAgentEventsBySessionPaged added in v0.2.0

func (q *Queries) ListAgentEventsBySessionPaged(ctx context.Context, arg ListAgentEventsBySessionPagedParams) ([]AgentEvent, error)

Keyset pagination: returns the next page of events after the given cursor. Pass after_ts=0 and an empty after_event_id to fetch the first page. Order is ascending (chronological) for timeline construction.

func (*Queries) ListAgentSessionsByProviderSessionID added in v0.2.0

func (q *Queries) ListAgentSessionsByProviderSessionID(ctx context.Context, arg ListAgentSessionsByProviderSessionIDParams) ([]AgentSession, error)

Search by provider_session_id across all providers in a repo. Returns multiple rows if different providers reuse the same ID.

func (*Queries) ListBackfillReplayCandidates

func (q *Queries) ListBackfillReplayCandidates(ctx context.Context, arg ListBackfillReplayCandidatesParams) ([]ListBackfillReplayCandidatesRow, error)

Returns the next batch of commit links eligible for replay, ordered oldest-first. Uses (linked_at, commit_hash) tuple comparison for deterministic cursor-based pagination.

func (*Queries) ListCheckpointsByRepository

func (q *Queries) ListCheckpointsByRepository(ctx context.Context, arg ListCheckpointsByRepositoryParams) ([]Checkpoint, error)

func (*Queries) ListCheckpointsWithCommit

func (q *Queries) ListCheckpointsWithCommit(ctx context.Context, arg ListCheckpointsWithCommitParams) ([]ListCheckpointsWithCommitRow, error)

func (*Queries) ListCommitLinksByRepository

func (q *Queries) ListCommitLinksByRepository(ctx context.Context, arg ListCommitLinksByRepositoryParams) ([]CommitLink, error)

func (*Queries) ListCrossRepoSessions

func (q *Queries) ListCrossRepoSessions(ctx context.Context, arg ListCrossRepoSessionsParams) ([]AgentSession, error)

func (*Queries) ListDistinctProviders

func (q *Queries) ListDistinctProviders(ctx context.Context, repositoryID string) ([]string, error)

func (*Queries) ListEventsByProviderInWindow added in v0.3.9

func (q *Queries) ListEventsByProviderInWindow(ctx context.Context, arg ListEventsByProviderInWindowParams) ([]ListEventsByProviderInWindowRow, error)

Returns event count and most-recent event timestamp per provider for the repository in the given window (ts >= since_ts). Used by `semantica doctor` to surface per-provider activity. Providers with zero events are omitted by the GROUP BY; the doctor command joins this against the registered provider list to flag installed-but-silent providers.

func (*Queries) ListEventsBySessionASC

func (q *Queries) ListEventsBySessionASC(ctx context.Context, sessionID string) ([]ListEventsBySessionASCRow, error)

func (*Queries) ListEventsInWindow

func (q *Queries) ListEventsInWindow(ctx context.Context, arg ListEventsInWindowParams) ([]ListEventsInWindowRow, error)

Returns all events for a repository within a time window, without requiring session_checkpoints links. Used by attribution to query events directly by repository and time range. insert_seq feeds deterministic winner selection for equal-quality evidence.

func (*Queries) ListEventsInWindowForAnnotations added in v0.6.0

Returns events for a repository within a time window with the turn and provenance fields the timeline-annotation detector needs (turn_id and provenance_hash) alongside the payload pointer. Ordered chronologically so the detector can reason about authored-then-revised / authored-then-removed sequences directly.

func (*Queries) ListEvidenceLinksByEvent added in v0.6.0

func (q *Queries) ListEvidenceLinksByEvent(ctx context.Context, eventID string) ([]AgentEventEvidenceLink, error)

func (*Queries) ListEvidenceLinksByGroup added in v0.6.0

func (q *Queries) ListEvidenceLinksByGroup(ctx context.Context, groupID string) ([]AgentEventEvidenceLink, error)

func (*Queries) ListEvidenceLinksInWindow added in v0.6.0

func (q *Queries) ListEvidenceLinksInWindow(ctx context.Context, arg ListEvidenceLinksInWindowParams) ([]ListEvidenceLinksInWindowRow, error)

Lists tool-delta links and session providers in event-window order, with event recency for deterministic winner selection.

func (*Queries) ListFailedManifestReasons added in v0.3.9

func (q *Queries) ListFailedManifestReasons(ctx context.Context, arg ListFailedManifestReasonsParams) ([]ListFailedManifestReasonsRow, error)

Returns each distinct last_error and its count for failed manifests in the repository within the given window. No limit: doctor folds these into stable reason groups in Go (e.g. "redaction failed: prompt"). A SQL-side limit would cap raw rows before grouping, which can undercount stable groups that manifest as many per-instance error strings (one per blob hash). The result set is bounded by the number of *distinct* error strings within the 7d window, which is small in practice.

func (*Queries) ListPackagedManifests

func (q *Queries) ListPackagedManifests(ctx context.Context, arg ListPackagedManifestsParams) ([]ProvenanceManifest, error)

Returns manifests ready for upload, scoped to a watermark timestamp. Only packaged status with attempts below the retry cap. Pass 0 for watermark_ts to drain all.

func (*Queries) ListPendingCommitLinkedCheckpoints added in v0.6.0

func (q *Queries) ListPendingCommitLinkedCheckpoints(ctx context.Context, repositoryID string) ([]ListPendingCommitLinkedCheckpointsRow, error)

Include failed rows because a failed queue head blocks later work. Newest commit links sort first for deterministic deduplication.

func (*Queries) ListPendingManifests

func (q *Queries) ListPendingManifests(ctx context.Context, arg ListPendingManifestsParams) ([]ProvenanceManifest, error)

func (*Queries) ListProvidersByCheckpoint

func (q *Queries) ListProvidersByCheckpoint(ctx context.Context, checkpointID string) ([]string, error)

func (*Queries) ListRecentAIPercentages

func (q *Queries) ListRecentAIPercentages(ctx context.Context, arg ListRecentAIPercentagesParams) ([]ListRecentAIPercentagesRow, error)

func (*Queries) ListRecentSessionsWithStats

func (q *Queries) ListRecentSessionsWithStats(ctx context.Context, arg ListRecentSessionsWithStatsParams) ([]ListRecentSessionsWithStatsRow, error)

Same token separation as ListSessionsWithStats (see comment above).

func (*Queries) ListRepositories

func (q *Queries) ListRepositories(ctx context.Context) ([]Repository, error)

func (*Queries) ListSessionsForCheckpoint

func (q *Queries) ListSessionsForCheckpoint(ctx context.Context, checkpointID string) ([]AgentSession, error)

func (*Queries) ListSessionsForRepository

func (q *Queries) ListSessionsForRepository(ctx context.Context, arg ListSessionsForRepositoryParams) ([]AgentSession, error)

func (*Queries) ListSessionsWithEventsInWindow

func (q *Queries) ListSessionsWithEventsInWindow(ctx context.Context, arg ListSessionsWithEventsInWindowParams) ([]string, error)

Returns distinct session IDs that have at least one event in the given time window [after_ts, up_to_ts] for the specified repository.

func (*Queries) ListSessionsWithStats

func (q *Queries) ListSessionsWithStats(ctx context.Context, arg ListSessionsWithStatsParams) ([]ListSessionsWithStatsRow, error)

tokens_in is the non-cached input token count reported by the provider. tokens_cached is cache_read + cache_create. Claude's API reports input_tokens as only the non-cached portion; with heavy prompt caching the cached portion can be >99% of actual context, so we report them separately for clarity.

func (*Queries) ListSessionsWithStatsAll

func (q *Queries) ListSessionsWithStatsAll(ctx context.Context, arg ListSessionsWithStatsAllParams) ([]ListSessionsWithStatsAllRow, error)

Same as ListSessionsWithStats but includes sessions with zero events.

func (*Queries) ListStalePendingCheckpoints

func (q *Queries) ListStalePendingCheckpoints(ctx context.Context, arg ListStalePendingCheckpointsParams) ([]ListStalePendingCheckpointsRow, error)

Returns pending checkpoints older than the given threshold that have no manifest and no commit link. Used by tidy to mark abandoned checkpoints as failed.

func (*Queries) ListStepCompanionResults

func (q *Queries) ListStepCompanionResults(ctx context.Context, arg ListStepCompanionResultsParams) ([]ListStepCompanionResultsRow, error)

Returns tool_result events matching a step's tool_use_id, ordered by timestamp. Returned as :many so the provider enricher can choose the right pairing when multiple results exist (e.g., retried tool calls).

func (*Queries) ListStepEventsForTurn

func (q *Queries) ListStepEventsForTurn(ctx context.Context, arg ListStepEventsForTurnParams) ([]ListStepEventsForTurnRow, error)

Returns step events for provenance bundle packaging. Includes both hook-captured and transcript-sourced events so providers without direct hook capture are covered.

func (*Queries) ListStepProvenanceForTurn

func (q *Queries) ListStepProvenanceForTurn(ctx context.Context, arg ListStepProvenanceForTurnParams) ([]ListStepProvenanceForTurnRow, error)

Returns step provenance hashes for a turn, used to build the upload envelope.

func (*Queries) ListTranscriptEvents

func (q *Queries) ListTranscriptEvents(ctx context.Context, arg ListTranscriptEventsParams) ([]ListTranscriptEventsRow, error)

func (*Queries) ListUserPromptsForCommit added in v0.5.4

func (q *Queries) ListUserPromptsForCommit(ctx context.Context, commitHash string) ([]ListUserPromptsForCommitRow, error)

Returns user prompts attributable to a single commit.

Isolation rules:

  • User prompt events only; assistant and tool-result events are excluded.
  • Events must fall within the commit checkpoint window.
  • Duplicate turn IDs keep the earliest event for deterministic ordering.
  • Events without a turn ID are excluded because they cannot be cited.

func (*Queries) MarkCheckpointAttributionComputed added in v0.6.0

func (q *Queries) MarkCheckpointAttributionComputed(ctx context.Context, arg MarkCheckpointAttributionComputedParams) error

Records successful attribution, including an empty result. Upsert preserves the marker when the stats row does not exist yet.

func (*Queries) MarkCheckpointAttributionPushed added in v0.6.0

func (q *Queries) MarkCheckpointAttributionPushed(ctx context.Context, arg MarkCheckpointAttributionPushedParams) error

Records a successful hosted attribution push. Upsert creates missing stats rows.

func (*Queries) MarkManifestFailed

func (q *Queries) MarkManifestFailed(ctx context.Context, arg MarkManifestFailedParams) error

func (*Queries) MarkManifestUploaded

func (q *Queries) MarkManifestUploaded(ctx context.Context, arg MarkManifestUploadedParams) error

func (*Queries) MarkManifestUploading

func (q *Queries) MarkManifestUploading(ctx context.Context, arg MarkManifestUploadingParams) (int64, error)

Guards on status='packaged' so concurrent sync workers cannot both claim the same manifest. Caller checks rows affected: 0 means already claimed.

func (*Queries) PromptEventExists

func (q *Queries) PromptEventExists(ctx context.Context, turnID sql.NullString) (bool, error)

func (*Queries) RecordBackfillFailure

func (q *Queries) RecordBackfillFailure(ctx context.Context, arg RecordBackfillFailureParams) error

Records a retryable failure on the current head-of-line commit.

func (*Queries) RecoverStaleUploading

func (q *Queries) RecoverStaleUploading(ctx context.Context, arg RecoverStaleUploadingParams) error

Resets manifests stuck in uploading after a crash. Threshold is a unix ms timestamp; rows with updated_at older than this are reset to packaged.

func (*Queries) ReleaseCheckpointForRetry added in v0.6.0

func (q *Queries) ReleaseCheckpointForRetry(ctx context.Context, arg ReleaseCheckpointForRetryParams) (int64, error)

Transient failure: release the lease with a scheduled retry. The attempt counter was already incremented by the claim. Callers must require one affected row; zero means the lease was lost and the transition was not recorded.

func (*Queries) ResetManifestForRetry

func (q *Queries) ResetManifestForRetry(ctx context.Context, arg ResetManifestForRetryParams) error

Resets a failed or uploading manifest back to packaged for retry. Increments upload_attempts and records the error for diagnostics.

func (*Queries) ResetManifestToPackaged

func (q *Queries) ResetManifestToPackaged(ctx context.Context, arg ResetManifestToPackagedParams) error

Resets a manifest back to packaged without incrementing upload_attempts. Used for auth failures where the manifest itself is healthy and should not burn a retry attempt.

func (*Queries) ResolveCheckpointByPrefix

func (q *Queries) ResolveCheckpointByPrefix(ctx context.Context, arg ResolveCheckpointByPrefixParams) ([]string, error)

func (*Queries) ResolveCommitLinkByPrefix

func (q *Queries) ResolveCommitLinkByPrefix(ctx context.Context, arg ResolveCommitLinkByPrefixParams) ([]string, error)

func (*Queries) ResolveSessionByPrefix

func (q *Queries) ResolveSessionByPrefix(ctx context.Context, arg ResolveSessionByPrefixParams) ([]string, error)

func (*Queries) RetryFailedCheckpoint added in v0.6.0

func (q *Queries) RetryFailedCheckpoint(ctx context.Context, checkpointID string) (int64, error)

Manual retry: a human intervened, so the attempt budget resets.

func (*Queries) SaveCheckpointSummary

func (q *Queries) SaveCheckpointSummary(ctx context.Context, arg SaveCheckpointSummaryParams) error

func (*Queries) StepEventExists

func (q *Queries) StepEventExists(ctx context.Context, arg StepEventExistsParams) (bool, error)

func (*Queries) UpdateCheckpointAIPercentage

func (q *Queries) UpdateCheckpointAIPercentage(ctx context.Context, arg UpdateCheckpointAIPercentageParams) error

func (*Queries) UpdateRepositoryEnabledAt

func (q *Queries) UpdateRepositoryEnabledAt(ctx context.Context, arg UpdateRepositoryEnabledAtParams) error

func (*Queries) UpsertAgentSession

func (q *Queries) UpsertAgentSession(ctx context.Context, arg UpsertAgentSessionParams) (AgentSession, error)

func (*Queries) UpsertAgentSource

func (q *Queries) UpsertAgentSource(ctx context.Context, arg UpsertAgentSourceParams) (AgentSource, error)

func (*Queries) UpsertAttributionBackfill

func (q *Queries) UpsertAttributionBackfill(ctx context.Context, arg UpsertAttributionBackfillParams) error

Initializes replay state for a connected repo binding. If the row already exists, extends the cutoff if the new cutoff is newer (never shrinks).

func (*Queries) UpsertCheckpointStats

func (q *Queries) UpsertCheckpointStats(ctx context.Context, arg UpsertCheckpointStatsParams) error

func (*Queries) UpsertProvenanceManifest

func (q *Queries) UpsertProvenanceManifest(ctx context.Context, arg UpsertProvenanceManifestParams) error

func (*Queries) WithTx

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

type RecordBackfillFailureParams

type RecordBackfillFailureParams struct {
	FailedCommitHash sql.NullString `json:"failed_commit_hash"`
	LastError        sql.NullString `json:"last_error"`
	UpdatedAt        int64          `json:"updated_at"`
	ConnectedRepoID  string         `json:"connected_repo_id"`
}

type RecoverStaleUploadingParams

type RecoverStaleUploadingParams struct {
	UpdatedAt   int64 `json:"updated_at"`
	UpdatedAt_2 int64 `json:"updated_at_2"`
}

type ReleaseCheckpointForRetryParams added in v0.6.0

type ReleaseCheckpointForRetryParams struct {
	LastError     sql.NullString `json:"last_error"`
	NextAttemptAt int64          `json:"next_attempt_at"`
	CheckpointID  string         `json:"checkpoint_id"`
	LeaseOwner    sql.NullString `json:"lease_owner"`
}

type RemoteAttributionBackfill

type RemoteAttributionBackfill struct {
	ConnectedRepoID  string         `json:"connected_repo_id"`
	RepositoryID     string         `json:"repository_id"`
	CutoffLinkedAt   int64          `json:"cutoff_linked_at"`
	CutoffCommitHash string         `json:"cutoff_commit_hash"`
	CursorLinkedAt   int64          `json:"cursor_linked_at"`
	CursorCommitHash string         `json:"cursor_commit_hash"`
	Status           string         `json:"status"`
	FailedCommitHash sql.NullString `json:"failed_commit_hash"`
	RetryAttempts    int64          `json:"retry_attempts"`
	LastError        sql.NullString `json:"last_error"`
	UpdatedAt        int64          `json:"updated_at"`
}

type Repository

type Repository struct {
	RepositoryID string `json:"repository_id"`
	RootPath     string `json:"root_path"`
	CreatedAt    int64  `json:"created_at"`
	EnabledAt    int64  `json:"enabled_at"`
}

type ResetManifestForRetryParams

type ResetManifestForRetryParams struct {
	LastError  sql.NullString `json:"last_error"`
	UpdatedAt  int64          `json:"updated_at"`
	ManifestID string         `json:"manifest_id"`
}

type ResetManifestToPackagedParams

type ResetManifestToPackagedParams struct {
	UpdatedAt  int64  `json:"updated_at"`
	ManifestID string `json:"manifest_id"`
}

type ResolveCheckpointByPrefixParams

type ResolveCheckpointByPrefixParams struct {
	CheckpointID string `json:"checkpoint_id"`
	RepositoryID string `json:"repository_id"`
}

type ResolveCommitLinkByPrefixParams

type ResolveCommitLinkByPrefixParams struct {
	CommitHash   string `json:"commit_hash"`
	RepositoryID string `json:"repository_id"`
}

type ResolveSessionByPrefixParams

type ResolveSessionByPrefixParams struct {
	SessionID    string `json:"session_id"`
	RepositoryID string `json:"repository_id"`
}

type SaveCheckpointSummaryParams

type SaveCheckpointSummaryParams struct {
	SummaryJson  sql.NullString `json:"summary_json"`
	SummaryModel sql.NullString `json:"summary_model"`
	CheckpointID string         `json:"checkpoint_id"`
}

type SessionCheckpoint

type SessionCheckpoint struct {
	SessionID    string `json:"session_id"`
	CheckpointID string `json:"checkpoint_id"`
}

type StepEventExistsParams

type StepEventExistsParams struct {
	TurnID    sql.NullString `json:"turn_id"`
	ToolUseID sql.NullString `json:"tool_use_id"`
	ToolName  sql.NullString `json:"tool_name"`
}

type UpdateCheckpointAIPercentageParams

type UpdateCheckpointAIPercentageParams struct {
	AiPercentage float64 `json:"ai_percentage"`
	CheckpointID string  `json:"checkpoint_id"`
}

type UpdateRepositoryEnabledAtParams

type UpdateRepositoryEnabledAtParams struct {
	EnabledAt    int64  `json:"enabled_at"`
	RepositoryID string `json:"repository_id"`
}

type UpsertAgentSessionParams

type UpsertAgentSessionParams struct {
	SessionID         string         `json:"session_id"`
	ProviderSessionID string         `json:"provider_session_id"`
	ParentSessionID   sql.NullString `json:"parent_session_id"`
	RepositoryID      string         `json:"repository_id"`
	Provider          string         `json:"provider"`
	SourceID          string         `json:"source_id"`
	StartedAt         int64          `json:"started_at"`
	LastSeenAt        int64          `json:"last_seen_at"`
	MetadataJson      string         `json:"metadata_json"`
	SourceRepoPath    sql.NullString `json:"source_repo_path"`
	Model             sql.NullString `json:"model"`
}

type UpsertAgentSourceParams

type UpsertAgentSourceParams struct {
	SourceID     string `json:"source_id"`
	RepositoryID string `json:"repository_id"`
	Provider     string `json:"provider"`
	SourceKey    string `json:"source_key"`
	LastSeenAt   int64  `json:"last_seen_at"`
	CreatedAt    int64  `json:"created_at"`
}

type UpsertAttributionBackfillParams

type UpsertAttributionBackfillParams struct {
	ConnectedRepoID  string `json:"connected_repo_id"`
	RepositoryID     string `json:"repository_id"`
	CutoffLinkedAt   int64  `json:"cutoff_linked_at"`
	CutoffCommitHash string `json:"cutoff_commit_hash"`
	UpdatedAt        int64  `json:"updated_at"`
}

type UpsertCheckpointStatsParams

type UpsertCheckpointStatsParams struct {
	CheckpointID string `json:"checkpoint_id"`
	SessionCount int64  `json:"session_count"`
	FilesChanged int64  `json:"files_changed"`
}

type UpsertProvenanceManifestParams

type UpsertProvenanceManifestParams struct {
	ManifestID           string         `json:"manifest_id"`
	RepositoryID         string         `json:"repository_id"`
	SessionID            string         `json:"session_id"`
	TurnID               string         `json:"turn_id"`
	Provider             string         `json:"provider"`
	Kind                 string         `json:"kind"`
	TranscriptRef        sql.NullString `json:"transcript_ref"`
	ProvenanceBundleHash sql.NullString `json:"provenance_bundle_hash"`
	StartedAt            int64          `json:"started_at"`
	CompletedAt          sql.NullInt64  `json:"completed_at"`
	Status               string         `json:"status"`
	CreatedAt            int64          `json:"created_at"`
	UpdatedAt            int64          `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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