package activator import ( "context" "fmt" "os" "os/exec" "github.com/carlosframework/platform/internal/cgroup" "github.com/carlosframework/platform/internal/hostbox" "github.com/carlosframework/platform/internal/hostguard" "github.com/carlosframework/platform/internal/hostwrite" ) // ErrClaimIsolationUnavailable blocks every current launch shape until the // root instance-control protocol can validate a durable role reservation. var ErrClaimIsolationUnavailable = fmt.Errorf("%w: isolated root launcher cannot carry claim reservations", hostbox.ErrUnsupported) type RoleProducer struct { Context context.Context Finish func(error) } // RootRoleLauncher is the agent's client of the reservation-bearing // isolated root launch protocol (claim Plan 11, R10). Root, not the agent, // executes the role, in main's isolated instance unit. type RootRoleLauncher interface { Capability(context.Context) (string, error) Launch(context.Context, hostbox.RoleLaunchRequest) (hostbox.RoleLaunchGrant, error) Stop(context.Context, hostbox.RoleLaunchRequest) error } type RoleLaunch struct { Unit *hostbox.UnitLaunchInputs Spec *hostbox.LaunchSpec // Root carries a reservation to root's isolated launcher. Nil keeps // every claimed launch refused. Root RootRoleLauncher // LaunchDir is the instance directory the isolated unit binds and runs // in; RunDir holds the app socket; LogSocket is the unit's stdout // socket; MemoryMax is the host slice tier. LaunchDir, RunDir, LogSocket string MemoryMax int64 RegisterProducer func(context.Context, string) (RoleProducer, error) Initialize func(context.Context) error InitializeUnlocked func(context.Context) error Parent *cgroup.Prepared ParentPath string CgroupRoot string Target hostguard.FenceTarget Work hostwrite.Work Identity hostwrite.Identity Journal *hostbox.LaunchJournal Executable func(context.Context, *exec.Cmd) (*os.File, error) }