feat: deepen machine and storage contracts

This commit is contained in:
Harivansh Rathi 2026-04-08 02:32:48 +00:00
parent 6f0f0643fe
commit 04575d111c
5 changed files with 77 additions and 27 deletions

View file

@ -6,22 +6,40 @@ import (
contracthost "github.com/getcompanion-ai/computer-host/contract"
)
type MachineRecord struct {
ID contracthost.MachineID
Phase contracthost.MachinePhase
RuntimeHost string
Error string
CreatedAt time.Time
StartedAt *time.Time
}
type StoragePool string
type VolumeRecord struct {
ID contracthost.VolumeID
MachineID contracthost.MachineID
Kind contracthost.VolumeKind
Pool StoragePool
Path string
CreatedAt time.Time
const (
StoragePoolArtifacts StoragePool = "artifacts"
StoragePoolMachineDisks StoragePool = "machine-disks"
StoragePoolState StoragePool = "state"
StoragePoolUserVolumes StoragePool = "user-volumes"
)
type ArtifactRecord struct {
Ref contracthost.ArtifactRef
KernelImagePath string
RootFSPath string
CreatedAt time.Time
}
type MachineRecord struct {
ID contracthost.MachineID
Artifact contracthost.ArtifactRef
SystemVolumeID contracthost.VolumeID
UserVolumeIDs []contracthost.VolumeID
Phase contracthost.MachinePhase
RuntimeHost string
Error string
CreatedAt time.Time
StartedAt *time.Time
}
type VolumeRecord struct {
ID contracthost.VolumeID
Kind contracthost.VolumeKind
AttachedMachineID *contracthost.MachineID
SourceArtifact *contracthost.ArtifactRef
Pool StoragePool
Path string
CreatedAt time.Time
}

View file

@ -8,9 +8,17 @@ import (
)
type Store interface {
PutArtifact(context.Context, model.ArtifactRecord) error
GetArtifact(context.Context, contracthost.ArtifactRef) (*model.ArtifactRecord, error)
ListArtifacts(context.Context) ([]model.ArtifactRecord, error)
CreateMachine(context.Context, model.MachineRecord) error
GetMachine(context.Context, contracthost.MachineID) (*model.MachineRecord, error)
ListMachines(context.Context) ([]model.MachineRecord, error)
UpdateMachine(context.Context, model.MachineRecord) error
DeleteMachine(context.Context, contracthost.MachineID) error
CreateVolume(context.Context, model.VolumeRecord) error
GetVolume(context.Context, contracthost.VolumeID) (*model.VolumeRecord, error)
ListVolumes(context.Context) ([]model.VolumeRecord, error)
UpdateVolume(context.Context, model.VolumeRecord) error
DeleteVolume(context.Context, contracthost.VolumeID) error
}