Artifact and media metadata were previously reconstructed from job result refs and JSON sidecar files. This change regularizes metadata into SQLite, keeps filesystem blobs in place, and preserves backward compatibility via lazy fallback and backfill from existing job refs and JSON metadata. Constraint: Blob storage remains on the local filesystem in this phase Rejected: Migrate blobs into SQLite | larger scope and worse operational profile for current media sizes Rejected: Hard cutover without fallback | unsafe for historical data already on the test server Confidence: medium Scope-risk: moderate Directive: Treat SQLite as the metadata source of truth; JSON sidecars are compatibility fallback only Tested: go test ./...; deployed to test server 101.42.99.35; verified /v1/artifacts, /v1/artifacts/:id, signed media URL 200, unsigned content 401 Not-tested: Full historical backfill sweep over all existing artifact rows under production-sized data volume
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package server
|
|
|
|
import "time"
|
|
|
|
type SessionRepository interface {
|
|
CreateSession(upstreamKey string, u user, ttl time.Duration) (session, error)
|
|
GetSession(token string) (session, bool, error)
|
|
DeleteSession(token string) error
|
|
RotateSession(oldToken string, ttl time.Duration) (session, bool, error)
|
|
}
|
|
|
|
type JobRepository interface {
|
|
CreateJob(record *job) (*job, int, error)
|
|
GetJob(jobID string) (*job, bool, error)
|
|
ListJobs(userID, status, skillID, projectID string, limit, offset int) ([]job, int, error)
|
|
MarkJobRunning(jobID string) (*job, bool, error)
|
|
LinkUpstreamTask(jobID, upstreamTaskID string) error
|
|
FailJob(jobID, code, message string, details map[string]any) error
|
|
CompleteSyncResult(jobID string, refs []resultRef, usage map[string]any) error
|
|
CancelJob(userID, jobID string) (*job, bool, bool, error)
|
|
}
|
|
|
|
type RouteRepository interface {
|
|
GetRoutes(projectID string) (map[string]string, error)
|
|
SetRoute(projectID, routeKey, modelID string) error
|
|
UnsetRoute(projectID, routeKey string) error
|
|
}
|
|
|
|
type MediaRepository interface {
|
|
UpsertMedia(record mediaRecord) error
|
|
GetMedia(mediaID string) (*mediaRecord, bool, error)
|
|
}
|
|
|
|
type ArtifactRepository interface {
|
|
UpsertArtifacts(userID, projectID string, items []artifact) error
|
|
GetArtifact(userID, artifactID string) (*artifact, resultRef, bool, error)
|
|
ListArtifacts(userID, projectID, jobID string, limit, offset int) ([]artifact, int, error)
|
|
}
|