store

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicate = errors.New("project work plan resource already exists")
View Source
var ErrNotFound = errors.New("project work plan resource not found")

Functions

func MigrateLadybugMetadata added in v0.2.4

func MigrateLadybugMetadata(ctx context.Context, source ladybug.Graph, target ladybug.Graph, projectIDs []string) error

Types

type LadybugStore

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

func NewBootstrappedLadybugStore

func NewBootstrappedLadybugStore(ctx context.Context, graph ladybug.Graph) (*LadybugStore, error)

func NewLadybugStore

func NewLadybugStore(graph ladybug.Graph, options ...LadybugStoreOption) *LadybugStore

func (*LadybugStore) CreateAttachment

func (store *LadybugStore) CreateAttachment(ctx context.Context, attachment model.Attachment) (model.Attachment, error)

func (*LadybugStore) CreateWorkPlan

func (store *LadybugStore) CreateWorkPlan(ctx context.Context, plan model.WorkPlan) (model.WorkPlan, error)

func (*LadybugStore) CreateWorkTask

func (store *LadybugStore) CreateWorkTask(ctx context.Context, task model.WorkTask) (model.WorkTask, error)

func (*LadybugStore) DeleteAttachmentsForTask added in v0.3.0

func (store *LadybugStore) DeleteAttachmentsForTask(ctx context.Context, projectID, taskID string) (int, error)

DeleteAttachmentsForTask permanently removes every attachment node owned by the given task across all 6 attachment kinds, and mirrors the delete into the SQLite read index when present. Returns the total count removed. Scoped by project; idempotent (0, nil) when none exist.

func (*LadybugStore) DeleteWorkPlan added in v0.3.0

func (store *LadybugStore) DeleteWorkPlan(ctx context.Context, projectID, planID string) error

DeleteWorkPlan permanently removes the work plan node (not its tasks). Scoped by project; idempotent (nil when absent).

func (*LadybugStore) DeleteWorkTask added in v0.3.0

func (store *LadybugStore) DeleteWorkTask(ctx context.Context, projectID, taskID string) error

DeleteWorkTask permanently removes the work task node. It does NOT remove the task's attachments (call DeleteAttachmentsForTask) or its plan. Scoped by project; idempotent.

func (*LadybugStore) GetWorkPlan

func (store *LadybugStore) GetWorkPlan(ctx context.Context, projectID string, planID string) (model.WorkPlan, error)

func (*LadybugStore) GetWorkPlansByIDs added in v0.3.0

func (store *LadybugStore) GetWorkPlansByIDs(ctx context.Context, projectID string, planIDs []string) ([]model.WorkPlan, error)

func (*LadybugStore) GetWorkTask

func (store *LadybugStore) GetWorkTask(ctx context.Context, projectID string, taskID string) (model.WorkTask, error)

func (*LadybugStore) ListAttachments

func (store *LadybugStore) ListAttachments(ctx context.Context, projectID string, taskID string) ([]model.Attachment, error)

func (*LadybugStore) ListWorkPlans

func (store *LadybugStore) ListWorkPlans(ctx context.Context, filter model.WorkPlanFilter) ([]model.WorkPlan, error)

func (*LadybugStore) ListWorkTasks

func (store *LadybugStore) ListWorkTasks(ctx context.Context, filter model.WorkTaskFilter) ([]model.WorkTask, error)

func (*LadybugStore) ListWorkTasksByPlanIDs added in v0.3.0

func (store *LadybugStore) ListWorkTasksByPlanIDs(ctx context.Context, projectID string, planIDs []string) ([]model.WorkTask, error)

func (*LadybugStore) SetAttachmentIndex added in v0.3.0

func (store *LadybugStore) SetAttachmentIndex(index *SQLiteAttachmentStore)

SetAttachmentIndex attaches a SQLite attachment read index after construction. Used when the index is opened after the store (e.g. shared SQLite engine in cmd/mivia-server). Safe to call once at startup; not concurrency-safe for later re-assignment.

func (*LadybugStore) UpdateWorkPlan

func (store *LadybugStore) UpdateWorkPlan(ctx context.Context, plan model.WorkPlan) (model.WorkPlan, error)

func (*LadybugStore) UpdateWorkTask

func (store *LadybugStore) UpdateWorkTask(ctx context.Context, task model.WorkTask) (model.WorkTask, error)

type LadybugStoreOption added in v0.3.0

type LadybugStoreOption func(*LadybugStore)

LadybugStoreOption configures a LadybugStore at construction.

func WithAttachmentIndex added in v0.3.0

func WithAttachmentIndex(index *SQLiteAttachmentStore) LadybugStoreOption

WithAttachmentIndex routes attachment reads (ListAttachments / listAttachmentNodes, used by GetWorkTask/ListWorkTasks hydration and validateIndependentReviewRefs) to a purpose-built SQLite index instead of the graph's 6x full-project-prefix scan. Attachments are dual-written: the graph remains the source of truth; SQLite mirrors it for fast indexed reads. When nil, the store falls back to the original graph scan (tests / non-SQLite deployments).

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) CreateAttachment

func (store *MemoryStore) CreateAttachment(_ context.Context, attachment projectworkplan.Attachment) (projectworkplan.Attachment, error)

func (*MemoryStore) CreateWorkPlan

func (*MemoryStore) CreateWorkTask

func (*MemoryStore) DeleteAttachmentsForTask added in v0.3.0

func (store *MemoryStore) DeleteAttachmentsForTask(_ context.Context, projectID, taskID string) (int, error)

DeleteAttachmentsForTask permanently removes every attachment owned by the given task, across all kinds. Returns the count removed. Scoped by project; idempotent (0, nil) when none exist.

func (*MemoryStore) DeleteWorkPlan added in v0.3.0

func (store *MemoryStore) DeleteWorkPlan(_ context.Context, projectID, planID string) error

DeleteWorkPlan permanently removes a work plan node. It does NOT remove the plan's tasks (call DeleteWorkTask per task). Scoped by project; idempotent.

func (*MemoryStore) DeleteWorkTask added in v0.3.0

func (store *MemoryStore) DeleteWorkTask(_ context.Context, projectID, taskID string) error

DeleteWorkTask permanently removes a work task node. It does NOT remove the task's attachments (call DeleteAttachmentsForTask) or its plan. Scoped by project; idempotent.

func (*MemoryStore) GetWorkPlan

func (store *MemoryStore) GetWorkPlan(_ context.Context, projectID, planID string) (projectworkplan.WorkPlan, error)

func (*MemoryStore) GetWorkPlansByIDs added in v0.3.0

func (store *MemoryStore) GetWorkPlansByIDs(_ context.Context, projectID string, planIDs []string) ([]projectworkplan.WorkPlan, error)

func (*MemoryStore) GetWorkTask

func (store *MemoryStore) GetWorkTask(_ context.Context, projectID, taskID string) (projectworkplan.WorkTask, error)

func (*MemoryStore) ListAttachments

func (store *MemoryStore) ListAttachments(_ context.Context, projectID, taskID string) ([]projectworkplan.Attachment, error)

func (*MemoryStore) ListWorkPlans

func (*MemoryStore) ListWorkTasks

func (*MemoryStore) ListWorkTasksByPlanIDs added in v0.3.0

func (store *MemoryStore) ListWorkTasksByPlanIDs(_ context.Context, projectID string, planIDs []string) ([]projectworkplan.WorkTask, error)

func (*MemoryStore) UpdateWorkPlan

func (*MemoryStore) UpdateWorkTask

type SQLiteAttachmentStore added in v0.3.0

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

SQLiteAttachmentStore is a purpose-built read index over Work Task attachments. It replaces the Ladybug graph's 6x full-project-prefix scan per GetWorkTask (listAttachmentNodes loops over 6 attachment labels, each an unindexed task_id scan) with a single indexed SQL query. The graph remains the source of truth for task *Refs slices and task/plan nodes; this index mirrors attachment nodes via dual-write at CreateAttachment time.

func NewSQLiteAttachmentStore added in v0.3.0

func NewSQLiteAttachmentStore(db *sql.DB) *SQLiteAttachmentStore

NewSQLiteAttachmentStore returns a SQLite-backed attachment read index. The work_task_attachments table is created by the shared schema bootstrap (internal/platform/sqlite/schema); this constructor only holds the connection.

func (*SQLiteAttachmentStore) CreateAttachment added in v0.3.0

func (store *SQLiteAttachmentStore) CreateAttachment(ctx context.Context, attachment projectworkplan.Attachment) error

CreateAttachment writes one attachment row. It is idempotent (INSERT OR IGNORE keyed on the composite primary key) so dual-write from the graph path is safe to retry. It does NOT validate the task exists; that guard is the caller's responsibility (the graph CreateAttachment already enforces it).

func (*SQLiteAttachmentStore) DeleteAttachmentsForTask added in v0.3.0

func (store *SQLiteAttachmentStore) DeleteAttachmentsForTask(ctx context.Context, projectID, taskID string) (int, error)

DeleteAttachmentsForTask removes every attachment row owned by the given task. Scoped by project_id + task_id. Idempotent: returns nil when no rows match. Returns the count of removed rows. Used by the cascade delete path to keep the read index consistent with the graph source of truth.

func (*SQLiteAttachmentStore) ListAttachments added in v0.3.0

func (store *SQLiteAttachmentStore) ListAttachments(ctx context.Context, projectID, taskID string) ([]projectworkplan.Attachment, error)

ListAttachments returns all attachments for a task, sorted by (CreatedAt, ID) to match the Ladybug store's ordering.

func (*SQLiteAttachmentStore) ListAttachmentsByKind added in v0.3.0

func (store *SQLiteAttachmentStore) ListAttachmentsByKind(ctx context.Context, projectID, taskID, kind string) ([]projectworkplan.Attachment, error)

ListAttachmentsByKind returns attachments for a task filtered by kind. Useful for the independence-gate path (validateIndependentReviewRefs) which only needs review_result_ref rows.

Jump to

Keyboard shortcuts

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