Files
weichen 83561682eb feat(swboot): wire SWBOOT-10 controlled patch executor (fail-closed)
DB-backed repo_path_allowlist reader (deny-all until admin seeds), per-prefix
admin test_commands (goose 00075), execution evidence table (goose 00074),
isolated git-worktree patch executor with command allowlist/time/output caps
and failure-stops evidence; controlled_patch creation/preview unlocked only
with an allowlisted repo binding (projectworkflow gate + catalog flag);
creator-only server endpoints for bindings/executions; merge/push/deploy stay
behind a typed separate-authorization boundary. Module boundary: app->swboot
composition import registered.
2026-09-26 00:56:59 +00:00

52 lines
2.6 KiB
Go

package projectworkflow
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
)
// Store 数据存储层接口
type Store interface {
CreateProject(ctx context.Context, p *Project) (*Project, error)
SaveProjectSourceBinding(ctx context.Context, projectID int64, repoPath, permissionScope string, createdBy int64) error
GetProjectByID(ctx context.Context, id int64) (*Project, error)
GetProjectByCode(ctx context.Context, code string) (*Project, error)
GetProjectByClientKey(ctx context.Context, creatorUserID int64, clientKey string) (*Project, error)
FindProjectByCreatorAndName(ctx context.Context, creatorUserID int64, name string) (*Project, error)
FindProjectByName(ctx context.Context, name string) (*Project, error)
ListAllProjects(ctx context.Context) ([]*Project, error)
ListProjectsForUser(ctx context.Context, userID int64) ([]*Project, error)
ListProjectWorkflows(ctx context.Context, projectID int64) ([]*ProjectWorkflow, error)
EnsureProjectWorkflows(ctx context.Context, projectID int64, defaultKeys []string) error
UpdateActiveWorkflow(ctx context.Context, projectID int64, toWorkflowKey string, expectedVersion int, changedBy int64, reason string) (*Project, *WorkflowActivationAudit, error)
CreateWorkflowRun(ctx context.Context, run *WorkflowRun) (*WorkflowRun, error)
UpdateWorkflowRun(ctx context.Context, runID string, status string, outputDocID string, summary string, errMsg string) error
GetWorkflowRun(ctx context.Context, runID string) (*WorkflowRun, error)
ListWorkflowRuns(ctx context.Context, projectID int64, workflowKey string, limit int) ([]*WorkflowRun, error)
RecordLineage(ctx context.Context, lineage *DocumentLineage) error
GetLineageForDownstream(ctx context.Context, docID string, version int) ([]*DocumentLineage, error)
// GetLineageForProjectDownstream 只返回属于该项目的边,避免用他项目 doc_id 读出血缘。
GetLineageForProjectDownstream(ctx context.Context, projectID int64, docID string, version int) ([]*DocumentLineage, error)
GetLineagesForUpstream(ctx context.Context, upstreamDocID string) ([]*DocumentLineage, error)
MarkDownstreamStale(ctx context.Context, upstreamDocID string, staleReason string) ([]*DocumentLineage, error)
}
// NewStore 根据 pgxpool 是否可用构建 PGStore 或内存 Fallback Store
func NewStore(pool *pgxpool.Pool) Store {
if pool != nil {
return &pgStore{pool: pool}
}
return newMemStore()
}
// =============================================================================
// PostgreSQL 权威持久化实现
// =============================================================================
type pgStore struct {
pool *pgxpool.Pool
}