Core domain and utility updates: - domain/task.go: Task model with visibility system * Visibility enum: private, lab, institution, open * Group associations for lab-scoped access * CreatedBy tracking for ownership * Sharing metadata with expiry - config/paths.go: Group-scoped data directories and audit log paths - crypto/signing.go: Key management for audit sealing, token signature verification - container/supply_chain.go: Image provenance tracking, vulnerability scanning - fileutil/filetype.go: MIME type detection and security validation - fileutil/secure.go: Protected file permissions, secure deletion - jupyter/: Package and service manager updates - experiment/manager.go: Visibility cascade from experiments to tasks - network/ssh.go: SSH tunneling improvements - queue/: Filesystem queue enhancements
82 lines
3.7 KiB
Go
82 lines
3.7 KiB
Go
// Package domain provides core domain types for fetch_ml.
|
|
// These types have zero internal dependencies and are used across all packages.
|
|
package domain
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Task represents an ML experiment task
|
|
type Task struct {
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
EndedAt *time.Time `json:"ended_at,omitempty"`
|
|
Tracking *TrackingConfig `json:"tracking,omitempty"`
|
|
NextRetry *time.Time `json:"next_retry,omitempty"`
|
|
LeaseExpiry *time.Time `json:"lease_expiry,omitempty"`
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
Username string `json:"username"`
|
|
LeasedBy string `json:"leased_by,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
Output string `json:"output,omitempty"`
|
|
SnapshotID string `json:"snapshot_id,omitempty"`
|
|
Status string `json:"status"`
|
|
LastError string `json:"last_error,omitempty"`
|
|
ID string `json:"id"`
|
|
Args string `json:"args"`
|
|
WorkerID string `json:"worker_id,omitempty"`
|
|
JobName string `json:"job_name"`
|
|
GPUMemory string `json:"gpu_memory,omitempty"`
|
|
UserID string `json:"user_id"`
|
|
CreatedBy string `json:"created_by"`
|
|
Datasets []string `json:"datasets,omitempty"`
|
|
Attempts []Attempt `json:"attempts,omitempty"`
|
|
DatasetSpecs []DatasetSpec `json:"dataset_specs,omitempty"`
|
|
MemoryGB int `json:"memory_gb,omitempty"`
|
|
CPU int `json:"cpu,omitempty"`
|
|
GPU int `json:"gpu,omitempty"`
|
|
RetryCount int `json:"retry_count"`
|
|
MaxRetries int `json:"max_retries"`
|
|
Priority int64 `json:"priority"`
|
|
|
|
// FirstAssignedAt is set once when the task is first assigned to a worker.
|
|
// It never changes, even on re-queue after worker failure.
|
|
FirstAssignedAt time.Time `json:"first_assigned_at"`
|
|
|
|
// MaxRuntime is the cached computed value from JobSpec.MaxRuntimeHours.
|
|
// 0 means use default (24h), capped at 168h (7d).
|
|
MaxRuntime time.Duration `json:"max_runtime,omitempty"`
|
|
|
|
// RemainingTime is the wall-clock budget left when assigned to a worker.
|
|
// Set by the scheduler on assignment.
|
|
RemainingTime time.Duration `json:"remaining_time,omitempty"`
|
|
|
|
// Visibility controls who can access this task
|
|
Visibility VisibilityLevel `json:"visibility,omitempty"`
|
|
// ExperimentID optionally groups this task into an experiment
|
|
ExperimentID string `json:"experiment_id,omitempty"`
|
|
}
|
|
|
|
// Attempt represents a single execution attempt of a task
|
|
type Attempt struct {
|
|
StartedAt time.Time `json:"started_at"`
|
|
EndedAt *time.Time `json:"ended_at,omitempty"`
|
|
WorkerID string `json:"worker_id,omitempty"`
|
|
Status string `json:"status"`
|
|
FailureClass FailureClass `json:"failure_class,omitempty"`
|
|
Signal string `json:"signal,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
LogTail string `json:"log_tail,omitempty"`
|
|
Attempt int `json:"attempt"`
|
|
ExitCode int `json:"exit_code,omitempty"`
|
|
}
|
|
|
|
// VisibilityLevel defines task sharing visibility
|
|
type VisibilityLevel string
|
|
|
|
const (
|
|
VisibilityPrivate VisibilityLevel = "private" // Owner only (opt-down)
|
|
VisibilityLab VisibilityLevel = "lab" // Selected lab group — DEFAULT
|
|
VisibilityInstitution VisibilityLevel = "institution" // All authenticated users
|
|
VisibilityOpen VisibilityLevel = "open" // Anyone with a signed link token
|
|
)
|