Documentation
¶
Index ¶
- Constants
- Variables
- type ActiveRunsError
- type ArtifactSnapshotInput
- type ArtifactSnapshotRow
- type GlobalDB
- func (g *GlobalDB) Close() error
- func (g *GlobalDB) CloseContext(ctx context.Context) error
- func (g *GlobalDB) CountActiveRuns(ctx context.Context) (int, error)
- func (g *GlobalDB) CountWorkspaces(ctx context.Context) (int, error)
- func (g *GlobalDB) DeleteRun(ctx context.Context, runID string) error
- func (g *GlobalDB) DeleteRuns(ctx context.Context, runIDs []string) error
- func (g *GlobalDB) DeleteWorkspaceIfNoCatalogData(ctx context.Context, workspaceID string) (bool, error)
- func (g *GlobalDB) Get(ctx context.Context, idOrPath string) (Workspace, error)
- func (g *GlobalDB) GetActiveWorkflowBySlug(ctx context.Context, workspaceID string, slug string) (Workflow, error)
- func (g *GlobalDB) GetLatestArchivedWorkflowBySlug(ctx context.Context, workspaceID string, slug string) (Workflow, error)
- func (g *GlobalDB) GetLatestReviewRound(ctx context.Context, workflowID string) (ReviewRound, error)
- func (g *GlobalDB) GetReviewRound(ctx context.Context, workflowID string, round int) (ReviewRound, error)
- func (g *GlobalDB) GetRun(ctx context.Context, runID string) (Run, error)
- func (g *GlobalDB) GetTaskItemByTaskID(ctx context.Context, workflowID string, taskID string) (TaskItemRow, error)
- func (g *GlobalDB) GetWorkflow(ctx context.Context, id string) (Workflow, error)
- func (g *GlobalDB) GetWorkflowArchiveEligibility(ctx context.Context, workspaceID string, slug string) (WorkflowArchiveEligibility, error)
- func (g *GlobalDB) List(ctx context.Context) ([]Workspace, error)
- func (g *GlobalDB) ListArtifactSnapshots(ctx context.Context, workflowID string) ([]ArtifactSnapshotRow, error)
- func (g *GlobalDB) ListInterruptedRuns(ctx context.Context) ([]Run, error)
- func (g *GlobalDB) ListReviewIssues(ctx context.Context, roundID string) ([]ReviewIssue, error)
- func (g *GlobalDB) ListReviewRounds(ctx context.Context, workflowID string) ([]ReviewRound, error)
- func (g *GlobalDB) ListRuns(ctx context.Context, opts ListRunsOptions) ([]Run, error)
- func (g *GlobalDB) ListTaskItems(ctx context.Context, workflowID string) ([]TaskItemRow, error)
- func (g *GlobalDB) ListTerminalRunsForPurge(ctx context.Context, policy RunRetentionPolicy) ([]Run, error)
- func (g *GlobalDB) ListWorkflows(ctx context.Context, opts ListWorkflowsOptions) ([]Workflow, error)
- func (g *GlobalDB) MarkRunCrashed(ctx context.Context, runID string, endedAt time.Time, errorText string) (Run, error)
- func (g *GlobalDB) MarkRunsCrashed(ctx context.Context, updates []RunCrashUpdate) error
- func (g *GlobalDB) MarkWorkflowArchived(ctx context.Context, workflowID string, archivedAt time.Time) (Workflow, error)
- func (g *GlobalDB) Path() string
- func (g *GlobalDB) PruneMissingActiveWorkflows(ctx context.Context, workspaceID string, presentSlugs []string) (WorkflowPruneResult, error)
- func (g *GlobalDB) PutRun(ctx context.Context, run Run) (Run, error)
- func (g *GlobalDB) PutWorkflow(ctx context.Context, workflow Workflow) (Workflow, error)
- func (g *GlobalDB) ReconcileWorkflowSync(ctx context.Context, input WorkflowSyncInput) (result WorkflowSyncResult, retErr error)
- func (g *GlobalDB) Register(ctx context.Context, path string, name string) (Workspace, error)
- func (g *GlobalDB) Resolve(ctx context.Context, path string) (Workspace, error)
- func (g *GlobalDB) ResolveOrRegister(ctx context.Context, path string) (Workspace, error)
- func (g *GlobalDB) TaskCountsByWorkflowIDs(ctx context.Context, workflowIDs []string) (map[string]WorkflowTaskCountsRow, error)
- func (g *GlobalDB) Unregister(ctx context.Context, idOrPath string) error
- func (g *GlobalDB) UpdateRun(ctx context.Context, run Run) (Run, error)
- func (g *GlobalDB) UpdateWorkspaceState(ctx context.Context, update WorkspaceStateUpdate) (Workspace, error)
- func (g *GlobalDB) WorkflowArchiveEligibilityByIDs(ctx context.Context, workflows []Workflow) (map[string]WorkflowArchiveEligibility, error)
- func (g *GlobalDB) WorkflowSlugsByIDs(ctx context.Context, ids []string) (map[string]string, error)
- func (g *GlobalDB) WorkspaceCatalogStats(ctx context.Context, workspaceID string) (WorkspaceCatalogStats, error)
- type ListRunsOptions
- type ListWorkflowsOptions
- type ReviewIssue
- type ReviewIssueInput
- type ReviewRound
- type ReviewRoundInput
- type Run
- type RunCrashUpdate
- type RunRetentionPolicy
- type SchemaTooNewError
- type TaskItemInput
- type TaskItemRow
- type Workflow
- type WorkflowActiveRunsError
- type WorkflowArchiveEligibility
- type WorkflowArchivedError
- type WorkflowNotArchivableError
- type WorkflowPruneResult
- type WorkflowPruneSkipped
- type WorkflowSyncInput
- type WorkflowSyncResult
- type WorkflowSyncValidationError
- type WorkflowTaskCountsRow
- type Workspace
- type WorkspaceCatalogStats
- type WorkspaceRegistry
- type WorkspaceStateUpdate
Constants ¶
const ( // WorkspaceFilesystemStatePresent means the workspace root exists on disk. WorkspaceFilesystemStatePresent = "present" // WorkspaceFilesystemStateMissing means the registry row is retained only // because durable catalog data still exists in global.db. WorkspaceFilesystemStateMissing = "missing" )
Variables ¶
var ( // ErrWorkflowArchived reports an archive request against an archived workflow identity. ErrWorkflowArchived = errors.New("globaldb: workflow archived") // ErrWorkflowHasActiveRuns reports archive conflicts caused by active runs. ErrWorkflowHasActiveRuns = errors.New("globaldb: workflow has active runs") // ErrWorkflowNotArchivable reports archive conflicts caused by incomplete synced state. ErrWorkflowNotArchivable = errors.New("globaldb: workflow not archivable") )
var ( // ErrWorkspaceNotFound reports missing workspace registrations. ErrWorkspaceNotFound = errors.New("globaldb: workspace not found") // ErrWorkflowNotFound reports missing workflow rows. ErrWorkflowNotFound = errors.New("globaldb: workflow not found") // ErrRunNotFound reports missing run rows. ErrRunNotFound = errors.New("globaldb: run not found") // ErrWorkspaceHasActiveRuns reports unregister conflicts. ErrWorkspaceHasActiveRuns = errors.New("globaldb: workspace has active runs") // ErrWorkflowSlugConflict reports an active workflow slug collision. ErrWorkflowSlugConflict = errors.New("globaldb: workflow slug conflict") // ErrRunAlreadyExists reports a duplicate run identifier. ErrRunAlreadyExists = errors.New("globaldb: run already exists") )
var ErrReviewRoundNotFound = errors.New("globaldb: review round not found")
ErrReviewRoundNotFound reports a missing review round.
var ErrSchemaTooNew = errors.New("globaldb: schema too new")
ErrSchemaTooNew reports that a database carries a migration newer than this binary understands.
var ErrTaskItemNotFound = errors.New("globaldb: task item not found")
ErrTaskItemNotFound reports a missing synced task-item projection row.
var ErrWorkflowSyncInvalid = errors.New("globaldb: workflow sync invalid")
Functions ¶
This section is empty.
Types ¶
type ActiveRunsError ¶
ActiveRunsError reports how many active runs blocked a workspace unregister.
func (ActiveRunsError) Error ¶
func (e ActiveRunsError) Error() string
func (ActiveRunsError) Is ¶
func (e ActiveRunsError) Is(target error) bool
type ArtifactSnapshotInput ¶
type ArtifactSnapshotInput struct {
ArtifactKind string
RelativePath string
Checksum string
FrontmatterJSON string
BodyText string
SourceMTime time.Time
}
ArtifactSnapshotInput describes one authored workflow artifact snapshot that should be mirrored into global.db.
type ArtifactSnapshotRow ¶
type ArtifactSnapshotRow struct {
WorkflowID string
ArtifactKind string
RelativePath string
Checksum string
FrontmatterJSON string
BodyText string
BodyStorageKind string
SourceMTime time.Time
SyncedAt time.Time
}
ArtifactSnapshotRow captures one durable authored-artifact snapshot row.
type GlobalDB ¶
type GlobalDB struct {
// contains filtered or unexported fields
}
GlobalDB owns the durable home-scoped catalog used by the daemon.
func (*GlobalDB) CloseContext ¶
CloseContext checkpoints the SQLite WAL and closes the underlying handle.
func (*GlobalDB) CountActiveRuns ¶
CountActiveRuns returns the number of non-terminal runs across all workspaces.
func (*GlobalDB) CountWorkspaces ¶
CountWorkspaces returns the number of registered workspaces.
func (*GlobalDB) DeleteRuns ¶
DeleteRuns removes multiple durable run index rows in one transaction.
func (*GlobalDB) DeleteWorkspaceIfNoCatalogData ¶
func (g *GlobalDB) DeleteWorkspaceIfNoCatalogData(ctx context.Context, workspaceID string) (bool, error)
DeleteWorkspaceIfNoCatalogData removes an empty workspace registry row.
func (*GlobalDB) GetActiveWorkflowBySlug ¶
func (g *GlobalDB) GetActiveWorkflowBySlug(ctx context.Context, workspaceID string, slug string) (Workflow, error)
GetActiveWorkflowBySlug loads the active workflow row for one workspace and slug.
func (*GlobalDB) GetLatestArchivedWorkflowBySlug ¶
func (g *GlobalDB) GetLatestArchivedWorkflowBySlug( ctx context.Context, workspaceID string, slug string, ) (Workflow, error)
GetLatestArchivedWorkflowBySlug returns the most recently archived row for one workflow slug.
func (*GlobalDB) GetLatestReviewRound ¶
func (g *GlobalDB) GetLatestReviewRound(ctx context.Context, workflowID string) (ReviewRound, error)
GetLatestReviewRound loads the newest review round for one workflow.
func (*GlobalDB) GetReviewRound ¶
func (g *GlobalDB) GetReviewRound(ctx context.Context, workflowID string, round int) (ReviewRound, error)
GetReviewRound loads one review round by workflow and round number.
func (*GlobalDB) GetTaskItemByTaskID ¶
func (g *GlobalDB) GetTaskItemByTaskID( ctx context.Context, workflowID string, taskID string, ) (TaskItemRow, error)
GetTaskItemByTaskID returns one synced task-item row by stable task id.
func (*GlobalDB) GetWorkflow ¶
GetWorkflow loads one workflow by primary key.
func (*GlobalDB) GetWorkflowArchiveEligibility ¶
func (g *GlobalDB) GetWorkflowArchiveEligibility( ctx context.Context, workspaceID string, slug string, ) (WorkflowArchiveEligibility, error)
GetWorkflowArchiveEligibility reads the synced daemon catalog state used to archive one workflow.
func (*GlobalDB) ListArtifactSnapshots ¶
func (g *GlobalDB) ListArtifactSnapshots(ctx context.Context, workflowID string) ([]ArtifactSnapshotRow, error)
ListArtifactSnapshots returns authored-artifact snapshot rows for one workflow.
func (*GlobalDB) ListInterruptedRuns ¶
ListInterruptedRuns returns runs left in non-terminal daemon-owned states that must be reconciled on startup.
func (*GlobalDB) ListReviewIssues ¶
ListReviewIssues loads the durable issue rows for one review round.
func (*GlobalDB) ListReviewRounds ¶
ListReviewRounds returns persisted review rounds for one workflow in round order.
func (*GlobalDB) ListTaskItems ¶
ListTaskItems returns synced task-item rows for one workflow in task order.
func (*GlobalDB) ListTerminalRunsForPurge ¶
func (g *GlobalDB) ListTerminalRunsForPurge( ctx context.Context, policy RunRetentionPolicy, ) ([]Run, error)
ListTerminalRunsForPurge selects terminal runs in oldest-first order while respecting the configured keep-count and keep-days bounds.
func (*GlobalDB) ListWorkflows ¶
func (g *GlobalDB) ListWorkflows(ctx context.Context, opts ListWorkflowsOptions) ([]Workflow, error)
ListWorkflows returns workflow rows for one workspace.
func (*GlobalDB) MarkRunCrashed ¶
func (g *GlobalDB) MarkRunCrashed( ctx context.Context, runID string, endedAt time.Time, errorText string, ) (Run, error)
MarkRunCrashed mirrors startup reconciliation into the durable run index.
func (*GlobalDB) MarkRunsCrashed ¶
func (g *GlobalDB) MarkRunsCrashed(ctx context.Context, updates []RunCrashUpdate) error
MarkRunsCrashed updates multiple runs inside one transaction.
func (*GlobalDB) MarkWorkflowArchived ¶
func (g *GlobalDB) MarkWorkflowArchived( ctx context.Context, workflowID string, archivedAt time.Time, ) (Workflow, error)
MarkWorkflowArchived persists the archived state for one active workflow row.
func (*GlobalDB) PruneMissingActiveWorkflows ¶
func (g *GlobalDB) PruneMissingActiveWorkflows( ctx context.Context, workspaceID string, presentSlugs []string, ) (WorkflowPruneResult, error)
PruneMissingActiveWorkflows removes active workflow rows whose source directories were absent from a successful root sync.
func (*GlobalDB) PutWorkflow ¶
PutWorkflow inserts or updates one workflow identity row.
func (*GlobalDB) ReconcileWorkflowSync ¶
func (g *GlobalDB) ReconcileWorkflowSync( ctx context.Context, input WorkflowSyncInput, ) (result WorkflowSyncResult, retErr error)
ReconcileWorkflowSync upserts the authored workflow state into the daemon catalog and removes stale projection rows that no longer exist on disk.
func (*GlobalDB) Register ¶
Register explicitly registers a workspace path and is idempotent on normalized roots.
func (*GlobalDB) Resolve ¶
Resolve resolves a filesystem path and lazily registers the owning workspace.
func (*GlobalDB) ResolveOrRegister ¶
ResolveOrRegister resolves a filesystem path and returns one stable workspace row.
func (*GlobalDB) TaskCountsByWorkflowIDs ¶
func (g *GlobalDB) TaskCountsByWorkflowIDs( ctx context.Context, workflowIDs []string, ) (map[string]WorkflowTaskCountsRow, error)
TaskCountsByWorkflowIDs returns aggregated task counts keyed by workflow id.
func (*GlobalDB) Unregister ¶
Unregister removes a workspace only when no active runs are present.
func (*GlobalDB) UpdateWorkspaceState ¶
func (g *GlobalDB) UpdateWorkspaceState(ctx context.Context, update WorkspaceStateUpdate) (Workspace, error)
UpdateWorkspaceState records derived filesystem/sync state for a workspace.
func (*GlobalDB) WorkflowArchiveEligibilityByIDs ¶
func (g *GlobalDB) WorkflowArchiveEligibilityByIDs( ctx context.Context, workflows []Workflow, ) (map[string]WorkflowArchiveEligibility, error)
WorkflowArchiveEligibilityByIDs returns archive-eligibility snapshots keyed by workflow id.
func (*GlobalDB) WorkflowSlugsByIDs ¶
WorkflowSlugsByIDs returns workflow slugs for the supplied workflow ids.
func (*GlobalDB) WorkspaceCatalogStats ¶
func (g *GlobalDB) WorkspaceCatalogStats(ctx context.Context, workspaceID string) (WorkspaceCatalogStats, error)
WorkspaceCatalogStats returns durable catalog counts for one workspace.
type ListRunsOptions ¶
ListRunsOptions controls durable run listing behavior.
type ListWorkflowsOptions ¶
ListWorkflowsOptions controls workflow listing behavior.
type ReviewIssue ¶
type ReviewIssue struct {
ID string
RoundID string
IssueNumber int
Severity string
Status string
SourcePath string
UpdatedAt time.Time
}
ReviewIssue captures one durable review-issue projection row.
type ReviewIssueInput ¶
ReviewIssueInput describes one parsed review issue projection row.
type ReviewRound ¶
type ReviewRound struct {
ID string
WorkflowID string
RoundNumber int
Provider string
PRRef string
ResolvedCount int
UnresolvedCount int
UpdatedAt time.Time
}
ReviewRound captures one durable review-round projection row.
type ReviewRoundInput ¶
type ReviewRoundInput struct {
RoundNumber int
Provider string
PRRef string
ResolvedCount int
UnresolvedCount int
Issues []ReviewIssueInput
}
ReviewRoundInput describes one parsed review round plus its issue rows.
type Run ¶
type Run struct {
RunID string
WorkspaceID string
WorkflowID *string
ParentRunID string
Mode string
Status string
PresentationMode string
StartedAt time.Time
EndedAt *time.Time
ErrorText string
RequestID string
}
Run captures one durable global run index row.
type RunCrashUpdate ¶
RunCrashUpdate captures one durable crash reconciliation update.
type RunRetentionPolicy ¶
RunRetentionPolicy describes the terminal-run retention rules used when selecting purge candidates.
type SchemaTooNewError ¶
SchemaTooNewError carries the current database and binary migration versions.
func (SchemaTooNewError) Error ¶
func (e SchemaTooNewError) Error() string
func (SchemaTooNewError) Is ¶
func (e SchemaTooNewError) Is(target error) bool
type TaskItemInput ¶
type TaskItemInput struct {
TaskNumber int
TaskID string
Title string
Status string
Kind string
DependsOn []string
SourcePath string
}
TaskItemInput describes one parsed task file projection row.
type TaskItemRow ¶
type TaskItemRow struct {
ID string
WorkflowID string
TaskNumber int
TaskID string
Title string
Status string
Kind string
DependsOn []string
SourcePath string
UpdatedAt time.Time
}
TaskItemRow captures one durable task projection row.
type Workflow ¶
type Workflow struct {
ID string
WorkspaceID string
Slug string
ArchivedAt *time.Time
LastSyncedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
Workflow captures one durable workflow identity row.
type WorkflowActiveRunsError ¶
type WorkflowActiveRunsError struct {
WorkspaceID string
WorkflowID string
Slug string
ActiveRuns int
}
WorkflowActiveRunsError reports how many active runs block archiving one workflow.
func (WorkflowActiveRunsError) Error ¶
func (e WorkflowActiveRunsError) Error() string
func (WorkflowActiveRunsError) Is ¶
func (e WorkflowActiveRunsError) Is(target error) bool
type WorkflowArchiveEligibility ¶
type WorkflowArchiveEligibility struct {
Workflow Workflow
TaskTotal int
PendingTasks int
ReviewRoundCount int
ReviewIssueTotal int
UnresolvedReviewIssues int
ActiveRuns int
}
WorkflowArchiveEligibility captures the synced daemon state used to decide whether one workflow can be archived.
func (WorkflowArchiveEligibility) Archivable ¶
func (e WorkflowArchiveEligibility) Archivable() bool
Archivable reports whether the workflow can be archived.
func (WorkflowArchiveEligibility) ConflictError ¶
func (e WorkflowArchiveEligibility) ConflictError() error
ConflictError converts one ineligible workflow snapshot into the canonical typed conflict.
func (WorkflowArchiveEligibility) SkipReason ¶
func (e WorkflowArchiveEligibility) SkipReason() string
SkipReason reports why the workflow is not archivable.
type WorkflowArchivedError ¶
WorkflowArchivedError reports an archive request against an already archived workflow identity.
func (WorkflowArchivedError) Error ¶
func (e WorkflowArchivedError) Error() string
func (WorkflowArchivedError) Is ¶
func (e WorkflowArchivedError) Is(target error) bool
type WorkflowNotArchivableError ¶
type WorkflowNotArchivableError struct {
WorkspaceID string
WorkflowID string
Slug string
Reason string
}
WorkflowNotArchivableError reports a synced-state reason that blocks archiving one workflow.
func (WorkflowNotArchivableError) Error ¶
func (e WorkflowNotArchivableError) Error() string
func (WorkflowNotArchivableError) Is ¶
func (e WorkflowNotArchivableError) Is(target error) bool
type WorkflowPruneResult ¶
type WorkflowPruneResult struct {
PrunedSlugs []string
Skipped []WorkflowPruneSkipped
}
WorkflowPruneResult reports stale active workflow rows removed during a root sync plus rows deliberately kept for conflict reasons.
type WorkflowPruneSkipped ¶
WorkflowPruneSkipped reports a stale active workflow row that pruning kept because durable state still indicates active work.
type WorkflowSyncInput ¶
type WorkflowSyncInput struct {
WorkspaceID string
WorkflowSlug string
SyncedAt time.Time
CheckpointScope string
CheckpointChecksum string
ArtifactSnapshots []ArtifactSnapshotInput
TaskItems []TaskItemInput
ReviewRounds []ReviewRoundInput
}
WorkflowSyncInput captures one workflow reconciliation payload.
type WorkflowSyncResult ¶
type WorkflowSyncResult struct {
Workflow Workflow
SnapshotsUpserted int
TaskItemsUpserted int
ReviewRoundsUpserted int
ReviewIssuesUpserted int
CheckpointsUpdated int
}
WorkflowSyncResult reports the durable rows touched by one reconciliation.
type WorkflowSyncValidationError ¶
type WorkflowSyncValidationError struct {
Message string
}
WorkflowSyncValidationError reports invalid authored workflow state that prevents sync from projecting the workflow into global.db.
func (WorkflowSyncValidationError) Error ¶
func (e WorkflowSyncValidationError) Error() string
func (WorkflowSyncValidationError) Is ¶
func (e WorkflowSyncValidationError) Is(target error) bool
type WorkflowTaskCountsRow ¶
WorkflowTaskCountsRow captures aggregated task counts for one workflow.
type Workspace ¶
type Workspace struct {
ID string
RootDir string
Name string
FilesystemState string
LastCheckedAt *time.Time
LastSyncedAt *time.Time
LastSyncError string
WorkflowCount int
RunCount int
HasCatalogData bool
ReadOnly bool
CreatedAt time.Time
UpdatedAt time.Time
}
Workspace captures one durable workspace registration.
type WorkspaceCatalogStats ¶
WorkspaceCatalogStats captures durable data counts owned by one workspace.
type WorkspaceRegistry ¶
type WorkspaceRegistry interface {
Resolve(context.Context, string) (Workspace, error)
ResolveOrRegister(context.Context, string) (Workspace, error)
Register(context.Context, string, string) (Workspace, error)
Get(context.Context, string) (Workspace, error)
List(context.Context) ([]Workspace, error)
Unregister(context.Context, string) error
}
WorkspaceRegistry exposes durable workspace registration operations.