Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix(project): allow redeploy with restricted bind sources (#4260)
Kyle Mendell48a22df95de8
diff --git a/backend/internal/bootstrap/bootstrap_test.go b/backend/internal/bootstrap/bootstrap_test.goindex c4994c2c4..6ab121e22 100644--- a/backend/internal/bootstrap/bootstrap_test.go+++ b/backend/internal/bootstrap/bootstrap_test.go@@ -15,9 +15,13 @@ import ("github.com/getarcaneapp/arcane/backend/v2/internal/actors""github.com/getarcaneapp/arcane/backend/v2/internal/auth""github.com/getarcaneapp/arcane/backend/v2/internal/config"+ "github.com/getarcaneapp/arcane/backend/v2/internal/container""github.com/getarcaneapp/arcane/backend/v2/internal/database""github.com/getarcaneapp/arcane/backend/v2/internal/job""github.com/getarcaneapp/arcane/backend/v2/internal/kv"+ "github.com/getarcaneapp/arcane/backend/v2/internal/project"+ "github.com/getarcaneapp/arcane/backend/v2/internal/swarm"+ "github.com/getarcaneapp/arcane/backend/v2/internal/system""github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge""github.com/getarcaneapp/arcane/backend/v2/pkg/utils/httpx"tunnelpb "github.com/getarcaneapp/arcane/backend/v2/proto/tunnel/v1"@@ -186,9 +190,14 @@ func TestHTTP2APIResponsesDoNotUseAPIGzipInternal(t *testing.T) {Environment: config.AppEnvironmentTest,}router, _ := newRouter(RouterParams{- Context: context.Background(),- Config: cfg,- HandlerDeps: api.HandlerDeps{},+ Context: context.Background(),+ Config: cfg,+ HandlerDeps: api.HandlerDeps{+ Project: &project.Module{Service: &project.ProjectService{}},+ Container: &container.Module{Service: &container.ContainerService{}},+ Swarm: &swarm.Module{Service: &swarm.SwarmService{}},+ System: &system.Module{Service: &system.SystemService{}},+ },AuthMiddleware: auth.NewAuthMiddleware(nil, cfg),TunnelRegistry: edge.NewTunnelRegistry(),})diff --git a/backend/internal/bootstrap/playwright_router_bootstrap.go b/backend/internal/bootstrap/playwright_router_bootstrap.goindex 3057eab3b..fdf70e90b 100644--- a/backend/internal/bootstrap/playwright_router_bootstrap.go+++ b/backend/internal/bootstrap/playwright_router_bootstrap.go@@ -15,12 +15,12 @@ func init() {func(apiGroup *echo.Group, deps api.HandlerDeps) {apiKeyService := deps.ApiKey.Service()userService := deps.User.Service()- if apiKeyService == nil || userService == nil || deps.Federated == nil || deps.GitRepository.Service() == nil || deps.GitOpsSync.Service() == nil || deps.Project.Service() == nil {+ if apiKeyService == nil || userService == nil || deps.Federated == nil || deps.GitRepository.Service() == nil || deps.GitOpsSync.Service() == nil {slog.Warn("Playwright service not available, skipping playwright routes")return}- playwrightService := playwright.NewPlaywrightService(apiKeyService, userService, deps.GitRepository.Service(), deps.GitOpsSync.Service(), deps.Project.Service())+ playwrightService := playwright.NewPlaywrightService(apiKeyService, userService, deps.GitRepository.Service(), deps.GitOpsSync.Service(), deps.Project.Service)playwright.SetupRoutes(apiGroup, playwrightService, deps.Federated)slog.Info("Playwright routes registered for E2E testing")},diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.goindex e395876ed..7a25634d6 100644--- a/backend/internal/bootstrap/router_bootstrap.go+++ b/backend/internal/bootstrap/router_bootstrap.go@@ -273,9 +273,6 @@ func newRouter(p RouterParams) (*echo.Echo, *edge.TunnelServer) {createAuthValidatorInternal(deps),permissionMatcher,p.TunnelRegistry,- // Proxied WebSocket upgrades enforce the same Origin policy as the local- // endpoints, so a cross-origin page cannot ride a session cookie into a- // remote environment.httpx.ValidateWebSocketOrigin(cfg.GetAppURL()),)apiGroup.Use(envProxyMiddleware)@@ -294,7 +291,7 @@ func newRouter(p RouterParams) (*echo.Echo, *edge.TunnelServer) {}// Remaining echo handlers (WebSocket/streaming)- ws.NewWebSocketHandler(apiGroup, deps.Project.Service(), deps.Container.Service(), deps.Swarm.Service(), deps.System.Service(), deps.Diagnostics, authMiddleware, cfg)+ ws.NewWebSocketHandler(apiGroup, deps.Project.Service, deps.Container.Service, deps.Swarm.Service, deps.System.Service, deps.Diagnostics, authMiddleware, cfg)// Register edge tunnel endpoint for manager to accept agent connections// This is only registered when NOT in agent mode (i.e., running as manager)@@ -309,11 +306,6 @@ func newRouter(p RouterParams) (*echo.Echo, *edge.TunnelServer) {}}- // Unknown API endpoints respond with JSON 404. This must be registered- // after every apiGroup.Use call: each Use re-registers the group's- // auto-404 routes, which would overwrite these. Without an explicit- // handler those auto-404 routes return echo v5's unexported sentinel- // error, which slog-echo rewrites into a 500.apiNotFound := func(c *echo.Context) error {return c.JSON(http.StatusNotFound, map[string]any{"success": false,diff --git a/backend/internal/container/module.go b/backend/internal/container/module.goindex 0202dd01c..bfcaf2ba5 100644--- a/backend/internal/container/module.go+++ b/backend/internal/container/module.go@@ -25,26 +25,18 @@ type Dependencies struct {// Module wires the container domain and mounts its routes.type Module struct {- service *ContainerService+ Service *ContainerServicedeps Dependencies}// New builds the container domain from its dependencies.func New(deps Dependencies) *Module {return &Module{- service: NewContainerService(deps.Event, deps.Docker, deps.Image, deps.Settings, deps.Project),+ Service: NewContainerService(deps.Event, deps.Docker, deps.Image, deps.Settings, deps.Project),deps: deps,}}-// Service exposes the container service to collaborators that use it directly.-func (m *Module) Service() *ContainerService {- if m == nil {- return nil- }- return m.service-}-// RegisterRoutes mounts the container endpoints. A nil module still registers,// so OpenAPI spec generation can discover the routes without a service graph.func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext) {@@ -52,5 +44,5 @@ func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContRegisterContainers(api, nil, nil, nil, nil, appCtx)return}- RegisterContainers(api, m.service, m.deps.Docker, m.deps.Settings, m.deps.Activity, appCtx)+ RegisterContainers(api, m.Service, m.deps.Docker, m.deps.Settings, m.deps.Activity, appCtx)}diff --git a/backend/internal/di/providers.go b/backend/internal/di/providers.goindex f494feb39..5d4ba5c55 100644--- a/backend/internal/di/providers.go+++ b/backend/internal/di/providers.go@@ -239,7 +239,7 @@ func provideVolumeModuleInternal(lc fx.Lifecycle, db *database.DB, dockerServiceImage: imageService,Activity: activityService,Environment: environmentService,- Container: containerModule.Service(),+ Container: containerModule.Service,Engine: engine,S3: s3Service,Config: cfg,@@ -280,9 +280,10 @@ func provideContainerRegistryModuleInternal(db *database.DB, dockerService *dock}func provideProjectServiceInternal(db *database.DB, settings *settings.SettingsService, event *event.EventService, image *image.ImageService, docker *docker.DockerClientService, build *build.BuildService, lifecycleService *project.LifecycleService, kv *kv.KVService, registry *registry.ContainerRegistryService, environment *environment.EnvironmentService, cfg *config.Config) *project.ProjectService {- return project.NewProjectService(db, settings, event, image, docker, build, lifecycleService, registry, cfg).- WithKVService(kv).- WithRegistryCredentialsProvider(environment.GetEnabledRegistryCredentials)+ service := project.NewProjectService(db, settings, event, image, docker, build, lifecycleService, registry, cfg)+ service.KVService = kv+ service.RegistryCredentialsProvider = environment.GetEnabledRegistryCredentials+ return service}// updaterServiceParams collects the updater's dependencies. The dedicated@@ -417,7 +418,7 @@ func provideDashboardModuleInternal(db *database.DB, docker *docker.DockerClientreturn dashboard.New(dashboard.Dependencies{DB: db,Docker: docker,- Container: containerModule.Service(),+ Container: containerModule.Service,Project: project,Image: image,Settings: settings,@@ -433,7 +434,7 @@ func provideSystemModuleInternal(db *database.DB, cfg *config.Config, docker *doDB: db,Config: cfg,Docker: docker,- Container: containerModule.Service(),+ Container: containerModule.Service,Image: image,ImageUpdate: imageUpdate,Volume: volumeModule.Service(),@@ -448,7 +449,7 @@ func provideSystemModuleInternal(db *database.DB, cfg *config.Config, docker *dofunc provideWebhookModuleInternal(lc fx.Lifecycle, db *database.DB, containerModule *container.Module, updaterModule *updater.Module, project *project.ProjectService, gitOpsSync *gitops.GitOpsSyncService, event *event.EventService, environment *environment.EnvironmentService) *webhook.Module {module := webhook.New(webhook.Dependencies{DB: db,- Container: containerModule.Service(),+ Container: containerModule.Service,Updater: updaterModule.Service(),Project: project,GitOpsSync: gitOpsSync,diff --git a/backend/internal/gitops/backup.go b/backend/internal/gitops/backup.goindex 2c4d031eb..c3ed54eca 100644--- a/backend/internal/gitops/backup.go+++ b/backend/internal/gitops/backup.go@@ -208,7 +208,7 @@ func ensureBackupDestinationFreeInternal(tx *gorm.DB, excludeSyncID, repositoryI// applyModeUpdatesInternal validates mode-specific update fields and appends the column updates.func (s *GitOpsSyncService) applyModeUpdatesInternal(ctx context.Context, current *projectpkg.GitOpsSync, req gitops.UpdateSyncRequest, updates map[string]any) error {- if !current.IsBackup() {+ if current.Mode != gitops.SyncModeBackup {if req.HasBackupOptions() {return common.Classify(common.ErrValidation, errors.WithDetails(errors.New("backup options cannot be set on a deployment sync"), "field", "mode"))}@@ -539,7 +539,7 @@ func (s *GitOpsSyncService) SubscribeProjectFileChanges(ctx context.Context) {return}runCtx := s.jobs.Context(ctx)- s.projectService.FilesChanged().Subscribe(func(projectID string) {+ s.projectService.FilesChanged.Subscribe(func(projectID string) {var syncs []projectpkg.GitOpsSyncif err := s.db.WithContext(runCtx).Where("mode = ? AND project_id = ?", gitops.SyncModeBackup, projectID).@@ -799,7 +799,7 @@ func (s *GitOpsSyncService) getBackupSyncInternal(ctx context.Context, environmeif err != nil {return nil, err}- if !syncRecord.IsBackup() {+ if syncRecord.Mode != gitops.SyncModeBackup {return nil, common.Classify(common.ErrBadRequest, errors.New("sync does not back up to Git"))}if syncRecord.Repository == nil {diff --git a/backend/internal/gitops/backup_test.go b/backend/internal/gitops/backup_test.goindex f347cb958..062c541ba 100644--- a/backend/internal/gitops/backup_test.go+++ b/backend/internal/gitops/backup_test.go@@ -530,7 +530,7 @@ func TestGitOpsBackup_SaveSignalMarksPendingAndRunsAfterDebounce(t *testing.T) {env.service.SubscribeProjectFileChanges(t.Context())writeBackupProjectFileInternal(t, env.projectPath, "compose.yaml", "services:\n app:\n image: nginx:1.29-alpine\n")- env.service.projectService.FilesChanged().Publish(env.project.ID)+ env.service.projectService.FilesChanged.Publish(env.project.ID)require.Eventually(t, func() bool {head, exists, err := env.remote.RemoteBranchHead(t.Context(), env.repoURL, "main", git.AuthConfig{AuthType: "none"})@@ -558,7 +558,7 @@ func TestGitOpsBackup_SaveSignalOnlyMarksPendingWhenAutoSyncIsOff(t *testing.T)env.service.SubscribeProjectFileChanges(t.Context())writeBackupProjectFileInternal(t, env.projectPath, "compose.yaml", "services:\n app:\n image: nginx:1.29-alpine\n")- env.service.projectService.FilesChanged().Publish(env.project.ID)+ env.service.projectService.FilesChanged.Publish(env.project.ID)require.Eventually(t, func() bool {return env.reloadInternal(t, syncRecord.ID).BackupPendingdiff --git a/backend/internal/gitops/gitops_sync.go b/backend/internal/gitops/gitops_sync.goindex 8f6db734f..ef4c7b93e 100644--- a/backend/internal/gitops/gitops_sync.go+++ b/backend/internal/gitops/gitops_sync.go@@ -462,7 +462,7 @@ func (s *GitOpsSyncService) RegisterAutoSyncJobsOnStartup(ctx context.Context) {for i := range syncs {syncRecord := syncs[i]s.registerSyncJobInternal(ctx, syncRecord.ID, syncRecord.EnvironmentID, syncRecord.SyncInterval)- if isGitOpsSyncOverdueInternal(&syncRecord) || (syncRecord.IsBackup() && syncRecord.BackupPending) {+ if isGitOpsSyncOverdueInternal(&syncRecord) || (syncRecord.Mode == gitops.SyncModeBackup && syncRecord.BackupPending) {s.kickSyncInternal(ctx, syncRecord.ID)}}@@ -1071,7 +1071,7 @@ func (s *GitOpsSyncService) performSyncAdmittedInternal(ctx context.Context, envSyncedAt: time.Now(),}- if syncRecord.IsBackup() {+ if syncRecord.Mode == gitops.SyncModeBackup {return s.performBackupInternal(syncCtx, syncRecord, actor, result, backupAdopt)}diff --git a/backend/internal/gitops/handler.go b/backend/internal/gitops/handler.goindex a100bec5b..9edd77db8 100644--- a/backend/internal/gitops/handler.go+++ b/backend/internal/gitops/handler.go@@ -172,7 +172,7 @@ func (h *GitOpsSyncHandler) requireBackupSyncPermissionInternal(ctx context.ContapiErr := common.ToAPIError(err)return huma.NewError(apiErr.HTTPStatus(), "Failed to retrieve GitOps sync")}- return requireBackupPermissionInternal(ctx, environmentID, sync.IsBackup())+ return requireBackupPermissionInternal(ctx, environmentID, sync.Mode == gitops.SyncModeBackup)}// ============================================================================diff --git a/backend/internal/project/project_lifecycle.go b/backend/internal/project/deployment.gosimilarity index 96%rename from backend/internal/project/project_lifecycle.gorename to backend/internal/project/deployment.goindex 9677f8206..734d0bb9a 100644--- a/backend/internal/project/project_lifecycle.go+++ b/backend/internal/project/deployment.go@@ -5,6 +5,7 @@ import (stderrors "errors""fmt""io"+ "io/fs""log/slog""maps""path/filepath"@@ -139,7 +140,7 @@ func (s *ProjectService) updateProjectServicesInternal(ctx context.Context, projif err := s.composeCoordinator.UpdateServices(ctx, projecttypes.ComposeServiceUpdate{Project: compProj, Services: servicesToUpdate, Dependents: dependents, StoppedDependents: stoppedDependents,Images: s.composeImageOperationsInternal(&user, credentials), Progress: progressWriter,- AuthConfigs: s.composeRegistryAuthConfigsInternal(ctx), WaitTimeout: s.deployWaitTimeoutInternal(),+ AuthConfigs: s.composeRegistryAuthConfigsInternal(ctx), WaitTimeout: timeouts.GetDuration(s.settingsService.GetSettingsConfig().DeployWaitTimeout.AsInt(), timeouts.DefaultDeployWait),RestoreBeforeMutation: func(ctx context.Context) {if statusErr := s.updateProjectStatusInternal(ctx, projectID, previousStatus); statusErr != nil {slog.ErrorContext(ctx, "failed to restore project status before service update", "projectID", projectID, "error", statusErr)@@ -209,16 +210,16 @@ func (s *ProjectService) existingNamespaceDependentsInternal(ctx context.Context}// prepareProjectBindDirectoriesInternal returns the load-time preparation for-// deployments: missing bind-mount sources inside projectPath are created as-// Arcane's runtime user before any container is stopped or created. Left to-// the Docker daemon, those directories would be created as root (#4132).+// deployments: bind-mount sources confirmed missing inside projectPath are+// created as Arcane's runtime user before containers are stopped or created.+// Left to Docker, those directories would be created as root (#4132).//// Only bind sources with Compose's automatic host path creation enabled are// considered (short syntax, or long syntax without create_host_path: false),// mirroring what the daemon would otherwise do. Existing files, directories,// and symlinks are left untouched, as are sources outside the project-// directory or reached through a symlink escaping it (#4195); those are left-// to Docker.+// directory or reached through a symlink escaping it (#4195). Those sources+// and sources Arcane cannot inspect are left to Docker, even if missing.func prepareProjectBindDirectoriesInternal(projectPath string) projects.PrepareProjectFunc {return func(ctx context.Context, project *composetypes.Project) error {for _, serviceName := range slices.Sorted(maps.Keys(project.Services)) {@@ -254,6 +255,10 @@ func ensureProjectBindDirectoryInternal(ctx context.Context, projectPath, sourceif errors.Is(err, acfs.ErrOutsideRoot) || exists {return nil}+ if errors.Is(err, fs.ErrPermission) {+ // Leave sources Arcane cannot inspect to the Docker daemon.+ return nil+ }if err != nil {return err}@@ -265,13 +270,6 @@ func ensureProjectBindDirectoryInternal(ctx context.Context, projectPath, sourcereturn nil}-func ensureProjectMutableInternal(proj *Project) error {- if proj != nil && proj.IsArchived {- return common.Classify(common.ErrProjectArchived, errors.New("project is archived and must be unarchived before this action"))- }- return nil-}-func (s *ProjectService) ArchiveProject(ctx context.Context, projectID string, user common.User) error {proj, err := s.GetProjectFromDatabaseByID(ctx, projectID)if err != nil {@@ -331,19 +329,13 @@ func (s *ProjectService) UnarchiveProject(ctx context.Context, projectID string,return nil}-// deployWaitTimeoutInternal resolves how long compose up waits for depends_on-// health/completion conditions, from the deployWaitTimeout setting.-func (s *ProjectService) deployWaitTimeoutInternal() time.Duration {- return timeouts.GetDuration(s.settingsService.GetSettingsConfig().DeployWaitTimeout.AsInt(), timeouts.DefaultDeployWait)-}-func (s *ProjectService) DeployProject(ctx context.Context, projectID string, user common.User, options *projecttypes.DeployOptions) error {projectFromDb, err := s.GetProjectFromDatabaseByID(ctx, projectID)if err != nil {return errors.WrapIf(err, "failed to get project")}- if err := ensureProjectMutableInternal(projectFromDb); err != nil {- return err+ if projectFromDb != nil && projectFromDb.IsArchived {+ return common.Classify(common.ErrProjectArchived, errors.New("project is archived and must be unarchived before this action"))}if _, err := s.ResolveProjectComposeFile(ctx, projectFromDb); err != nil {return err@@ -364,7 +356,7 @@ func (s *ProjectService) DeployProject(ctx context.Context, projectID string, usProjectID: projectID, ProjectPath: projectFromDb.Path, Options: options,DefaultPullPolicy: s.settingsService.GetStringSetting(ctx, "defaultDeployPullPolicy", "missing"),GitOpsManaged: projectFromDb.GitOpsManagedBy != nil && *projectFromDb.GitOpsManagedBy != "",- WaitTimeout: s.deployWaitTimeoutInternal(), AuthConfigs: s.composeRegistryAuthConfigsInternal(ctx), Progress: progressWriter,+ WaitTimeout: timeouts.GetDuration(s.settingsService.GetSettingsConfig().DeployWaitTimeout.AsInt(), timeouts.DefaultDeployWait), AuthConfigs: s.composeRegistryAuthConfigsInternal(ctx), Progress: progressWriter,PreDeploy: func(ctx context.Context) error {if s.lifecycleService == nil {return nildiff --git a/backend/internal/project/project_details.go b/backend/internal/project/details.gosimilarity index 99%rename from backend/internal/project/project_details.gorename to backend/internal/project/details.goindex c1e43dd38..fd0e6cb10 100644--- a/backend/internal/project/project_details.go+++ b/backend/internal/project/details.go@@ -285,7 +285,8 @@ func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID stringresp.RelativePath = getProjectRelativePathInternal(projectsDir, proj.Path)resp.GitOpsManagedBy = proj.GitOpsManagedBymeta := s.ProjectMetadata(ctx, *proj, nil)- applyResolvedProjectIconInternal(&resp, iconcatalog.Resolve(IconCatalogForContext(ctx), meta.ProjectIcon))+ icon := iconcatalog.Resolve(IconCatalogForContext(ctx), meta.ProjectIcon)+ resp.IconLightURL, resp.IconDarkURL = icon.IconLightURL, icon.IconDarkURLresp.URLs = meta.ProjectURLSresp.Tags, err = s.GetProjectTags(ctx, projectID)if err != nil {diff --git a/backend/internal/project/lifecycle.go b/backend/internal/project/lifecycle.goindex 950188ca9..ed6cb41aa 100644--- a/backend/internal/project/lifecycle.go+++ b/backend/internal/project/lifecycle.go@@ -276,7 +276,7 @@ func (s *LifecycleService) runScriptInContainerInternal(// primitives off the table even if a malicious script gets in.hostConfig := &containertypes.HostConfig{Mounts: buildLifecycleMountsInternal(workspaceMount, extraMounts),- NetworkMode: resolveLifecycleNetworkModeInternal(networkMode),+ NetworkMode: containertypes.NetworkMode(cmp.Or(strings.TrimSpace(networkMode), "none")),SecurityOpt: []string{"no-new-privileges:true"},CapDrop: []string{"ALL"},AutoRemove: false,@@ -657,15 +657,6 @@ func buildLifecycleMountsInternal(workspace *mounttypes.Mount, extras []lifecyclreturn mounts}-// resolveLifecycleNetworkModeInternal maps the stored PreDeployNetworkMode-// string to the containertypes.NetworkMode value used by the Docker SDK.-// An empty stored value is treated as "none" so scripts never accidentally-// run on the default bridge network.-func resolveLifecycleNetworkModeInternal(mode string) containertypes.NetworkMode {- trimmed := cmp.Or(strings.TrimSpace(mode), "none")- return containertypes.NetworkMode(trimmed)-}-func lifecycleStatusForResultInternal(exitCode int64, runErr error) string {if runErr != nil {return kit.Ternary(errors.Is(runErr, context.DeadlineExceeded), lifecycleStatusTimeout, lifecycleStatusFailed)diff --git a/backend/internal/project/project_listing.go b/backend/internal/project/listing.gosimilarity index 98%rename from backend/internal/project/project_listing.gorename to backend/internal/project/listing.goindex dc4cb12b4..b6d0677ce 100644--- a/backend/internal/project/project_listing.go+++ b/backend/internal/project/listing.go@@ -749,7 +749,11 @@ func buildProjectUpdatesFilterAccessorInternal() pagination.FilterAccessor[projereturn pagination.FilterAccessor[project.Details]{Key: "updates",Fn: func(p project.Details, filterValue string) bool {- return strings.EqualFold(strings.TrimSpace(getProjectUpdateStatusInternal(p.UpdateInfo)), strings.TrimSpace(filterValue))+ status := "unknown"+ if p.UpdateInfo != nil && strings.TrimSpace(p.UpdateInfo.Status) != "" {+ status = p.UpdateInfo.Status+ }+ return strings.EqualFold(strings.TrimSpace(status), strings.TrimSpace(filterValue))},}}@@ -767,14 +771,6 @@ func buildProjectArchivedFilterAccessorInternal() pagination.FilterAccessor[proj}}-func getProjectUpdateStatusInternal(updateInfo *project.UpdateInfo) string {- if updateInfo == nil || strings.TrimSpace(updateInfo.Status) == "" {- return "unknown"- }-- return updateInfo.Status-}-// CountProjectsWithPendingUpdates counts non-archived projects with at// least one visible service with an image update pending, plus compose projects running on the daemon// that Arcane does not track. It deliberately avoids the project-list pipeline:@@ -934,7 +930,8 @@ func (s *ProjectService) applyProjectPresentationInternal(ctx context.Context, pcatalog := IconCatalogForContext(ctx)for i := range projectsList {resp := &details[i]- applyResolvedProjectIconInternal(resp, iconcatalog.Resolve(catalog, metas[i].ProjectIcon))+ icon := iconcatalog.Resolve(catalog, metas[i].ProjectIcon)+ resp.IconLightURL, resp.IconDarkURL = icon.IconLightURL, icon.IconDarkURLresp.URLs = metas[i].ProjectURLSresp.ConfigurationError = projects.CheckProjectEnvAccess(ctx, metaEnv.projectsDirectory, projectsList[i].Path)for k := range resp.RuntimeServices {@@ -1115,11 +1112,3 @@ func IconCatalogForContext(ctx context.Context) string {}return iconcatalog.DefaultCatalog}--func applyResolvedProjectIconInternal(resp *project.Details, icon iconcatalog.ResolvedIconSet) {- if resp == nil {- return- }- resp.IconLightURL = icon.IconLightURL- resp.IconDarkURL = icon.IconDarkURL-}diff --git a/backend/internal/project/model.go b/backend/internal/project/model.goindex 1457f5118..09116dfca 100644--- a/backend/internal/project/model.go+++ b/backend/internal/project/model.go@@ -116,14 +116,9 @@ type GitOpsSync struct {LastBackupSnapshot *string `json:"-" gorm:"column:last_backup_snapshot"`}-// IsBackup reports whether the sync commits project files to Git.-func (s GitOpsSync) IsBackup() bool {- return s.Mode == gitopstypes.SyncModeBackup-}-// BackupState derives the persisted backup lifecycle state.func (s GitOpsSync) BackupState() string {- if !s.IsBackup() {+ if s.Mode != gitopstypes.SyncModeBackup {return ""}status := ""diff --git a/backend/internal/project/module.go b/backend/internal/project/module.goindex e35d847a4..664fef4aa 100644--- a/backend/internal/project/module.go+++ b/backend/internal/project/module.go@@ -8,19 +8,12 @@ import ()type Module struct {- service *ProjectService+ Service *ProjectServiceactivity *activity.ActivityService}func New(service *ProjectService, activityService *activity.ActivityService) *Module {- return &Module{service: service, activity: activityService}-}--func (m *Module) Service() *ProjectService {- if m == nil {- return nil- }- return m.service+ return &Module{Service: service, activity: activityService}}func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext) {@@ -28,5 +21,5 @@ func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContRegisterProjects(api, nil, nil, appCtx)return}- RegisterProjects(api, m.service, m.activity, appCtx)+ RegisterProjects(api, m.Service, m.activity, appCtx)}diff --git a/backend/internal/project/project.go b/backend/internal/project/service.gosimilarity index 96%rename from backend/internal/project/project.gorename to backend/internal/project/service.goindex 8aa9be896..cb3c9c577 100644--- a/backend/internal/project/project.go+++ b/backend/internal/project/service.go@@ -48,10 +48,10 @@ type ProjectService struct {dockerService *docker.DockerClientServicebuildService buildServiceInternallifecycleService *LifecycleService- kvService *kv.KVService+ KVService *kv.KVServicecontainerRegistryService *registry.ContainerRegistryServiceconfig *config.Config- registryCredentialsProvider registryCredentialsProviderInternal+ RegistryCredentialsProvider func(context.Context) ([]containerregistry.Credential, error)// syncMu serializes SyncProjectsFromFileSystem: its discovery walk and its// cleanup pass must not interleave with another run's.@@ -65,17 +65,9 @@ type ProjectService struct {// Entries are validated by compose/include/env file mtimes rather than a TTL.metaCache projecttypes.ComposeCache[projects.ArcaneComposeMetadata]- // filesChanged fires with the project ID after project files are saved+ // FilesChanged fires with the project ID after project files are saved// through Arcane, so Git backups can react without polling.- filesChanged *actors.Signal[string]-}--// FilesChanged exposes the project-file-change signal for subscribers.-func (s *ProjectService) FilesChanged() *actors.Signal[string] {- if s == nil {- return nil- }- return s.filesChanged+ FilesChanged *actors.Signal[string]}// EnsureGitOpsProjectLinked persists the bidirectional GitOps/project binding@@ -310,8 +302,6 @@ func (env *projectMetadataEnvInternal) composeFileInternal(projectID string, resreturn path, nil}-type registryCredentialsProviderInternal func(context.Context) ([]containerregistry.Credential, error)-func NewProjectService(db *database.DB, settingsService *settings.SettingsService, eventService *event.EventService, imageService *image.ImageService, dockerService *docker.DockerClientService, buildService buildServiceInternal, lifecycleService *LifecycleService, containerRegistryService *registry.ContainerRegistryService, cfg *config.Config) *ProjectService {return &ProjectService{composeCoordinator: projects.NewCoordinator(projecttypes.ComposeCommands{Stop: composeStopProjectServicesInternal, Up: composeUpProjectServicesInternal, Create: projects.ComposeCreate}),@@ -326,32 +316,16 @@ func NewProjectService(db *database.DB, settingsService *settings.SettingsServicconfig: cfg,parsedCompose: projects.NewParsedComposeCache(),metaCache: projects.NewComposeCache[projects.ArcaneComposeMetadata](1024, nil),- filesChanged: actors.NewSignal[string](),- }-}--func (s *ProjectService) WithRegistryCredentialsProvider(provider func(context.Context) ([]containerregistry.Credential, error)) *ProjectService {- if s == nil {- return nil+ FilesChanged: actors.NewSignal[string](),}- s.registryCredentialsProvider = provider- return s-}--func (s *ProjectService) WithKVService(kvService *kv.KVService) *ProjectService {- if s == nil {- return nil- }- s.kvService = kvService- return s}func (s *ProjectService) ResolveRegistryCredentials(ctx context.Context) ([]containerregistry.Credential, error) {- if s == nil || s.registryCredentialsProvider == nil {+ if s == nil || s.RegistryCredentialsProvider == nil {return nil, nil}- credentials, err := s.registryCredentialsProvider(ctx)+ credentials, err := s.RegistryCredentialsProvider(ctx)if err != nil {return nil, errors.WrapIf(err, "get enabled registry credentials")}@@ -397,8 +371,8 @@ func (s *ProjectService) getMutableProjectInternal(ctx context.Context, projectIif err != nil {return nil, err}- if err := ensureProjectMutableInternal(proj); err != nil {- return nil, err+ if proj != nil && proj.IsArchived {+ return nil, common.Classify(common.ErrProjectArchived, errors.New("project is archived and must be unarchived before this action"))}return proj, nil}diff --git a/backend/internal/project/service_test.go b/backend/internal/project/service_test.goindex 44d12d26a..2f2e90d5b 100644--- a/backend/internal/project/service_test.go+++ b/backend/internal/project/service_test.go@@ -1561,7 +1561,8 @@ func TestProjectService_UpdateProject_ClearsJournalForNonRenameWhenRecoveryDockeeventService := event.NewEventService(db, nil, nil)kvService := kv.NewKVService(db)- svc := NewProjectService(db, settingsService, eventService, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, settingsService, eventService, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServiceoldDir := "nginx"projectPath := createComposeProjectDir(t, projectsDir, oldDir)@@ -1613,7 +1614,7 @@ func TestProjectService_UpdateProject_ClearsJournalForNonRenameWhenRecoveryDockerequire.False(t, ok)}-func TestProjectService_UpdateProject_AllowsRenameAfterJournalRecoveryDockerUnavailable(t *testing.T) {+func TestProjectService_UpdateProject_AllowsRenameAfterJournalRecoveryWithoutDockerService(t *testing.T) {db := setupProjectTestDB(t)require.NoError(t, db.AutoMigrate(&kv.KVEntry{}))ctx := context.Background()@@ -1627,7 +1628,9 @@ func TestProjectService_UpdateProject_AllowsRenameAfterJournalRecoveryDockerUnaveventService := event.NewEventService(db, nil, nil)kvService := kv.NewKVService(db)- svc := NewProjectService(db, settingsService, eventService, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, settingsService, eventService, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvService+ configureProjectRuntimeDockerInternal(t, nil)oldDir := "nginx"projectPath := createComposeProjectDir(t, projectsDir, oldDir)@@ -4375,6 +4378,7 @@ func TestProjectService_ListProjects_WithDerivedStatusFilter_AllowsAllPageSizeSe}svc := NewProjectService(db, settingsService, nil, nil, nil, nil, nil, nil, config.Load())+ configureProjectRuntimeDockerInternal(t, nil)items, page, err := svc.ListProjects(ctx, pagination.QueryParams{Filters: map[string]string{@@ -5553,7 +5557,8 @@ func TestProjectService_RecoverProjectRenameJournals_RollsBackUncommittedDirectorequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5607,7 +5612,8 @@ func TestProjectService_RecoverProjectRenameJournals_StartedPhaseSkipsVolumeRollrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5670,7 +5676,8 @@ func TestProjectService_RecoverProjectRenameJournals_RelocatesTargetWhenBothPathrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5733,7 +5740,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsStartedJournalWhenDirrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5798,7 +5806,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsPreservedTargetJournat.Cleanup(server.Close)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5851,7 +5860,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsCommittedJournal(t *trequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5891,7 +5901,8 @@ func TestProjectService_FinalizeProjectRenameAfterCommit_ClearsJournalAfterSourcrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := &projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -5932,7 +5943,8 @@ func TestProjectService_FinalizeProjectRenameAfterCommit_KeepsJournalWhenSourceCrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := &projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6017,7 +6029,8 @@ func TestProjectService_RecoverProjectRenameJournals_KeepsJournalWhenDirectoryRokvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6111,7 +6124,8 @@ func TestProjectService_RecoverProjectRenameJournals_CompletesCommittedVolumeJoukvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6184,7 +6198,8 @@ func TestProjectService_RecoverProjectRenameJournals_RollsBackCommittedJournalWhkvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6294,7 +6309,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsJournalAfterDBRestorekvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6371,7 +6387,8 @@ func TestProjectService_RecoverProjectRenameJournals_KeepsRollbackCleanupWhenDocrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicecleanup := projecttypes.RenameRollbackCleanup{ProjectID: project.ID,OldName: "nginx",@@ -6434,7 +6451,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsCommittedJournalWhenSkvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6520,7 +6538,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsCommittedJournalAndClkvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6603,7 +6622,8 @@ func TestProjectService_RecoverProjectRenameJournals_MarksSourceCleanupPendingWhkvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6688,7 +6708,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsSourceCleanupPendingJkvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6787,7 +6808,8 @@ func TestProjectService_RecoverProjectRenameJournals_RollsBackSourceCleanupPendikvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6877,7 +6899,8 @@ func TestProjectService_RecoverProjectRenameJournals_KeepsSourceCleanupPendingJokvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -6943,7 +6966,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsStartedJournalWhenDirrequire.NoError(t, db.Create(project).Error)kvService := kv.NewKVService(db)- svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -7013,7 +7037,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsMissingPathJournalWhekvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -7087,7 +7112,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsJournalWhenRollbackSokvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -7166,7 +7192,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsJournalWhenRollbackTakvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",@@ -7251,7 +7278,8 @@ func TestProjectService_RecoverProjectRenameJournals_ClearsJournalWhenTargetPreskvService := kv.NewKVService(db)dockerService := &docker.DockerClientService{Client: newTestDockerClientInternal(t, server)}- svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load()).WithKVService(kvService)+ svc := NewProjectService(db, nil, nil, nil, dockerService, nil, nil, nil, config.Load())+ svc.KVService = kvServicejournal := projecttypes.RenameJournal{ProjectID: project.ID,OldName: "nginx",diff --git a/backend/internal/project/service_unix_test.go b/backend/internal/project/service_unix_test.goindex 7b327df6b..072f70d6a 100644--- a/backend/internal/project/service_unix_test.go+++ b/backend/internal/project/service_unix_test.go@@ -4,6 +4,7 @@ package projectimport ("context"+ "io/fs""os""path/filepath""testing"@@ -80,22 +81,80 @@ func TestPrepareProjectBindDirectoriesInternal_PermissionFailure(t *testing.T) {t.Skip("permission bits are ignored when running as root")}- projectPath := t.TempDir()- locked := filepath.Join(projectPath, "locked")- require.NoError(t, os.Mkdir(locked, 0o500))- t.Cleanup(func() { assert.NoError(t, os.Chmod(locked, 0o755)) })-- project := &composetypes.Project{Services: composetypes.Services{- "app": {Name: "app", Volumes: []composetypes.ServiceVolumeConfig{{- Type: composetypes.VolumeTypeBind, Source: filepath.Join(locked, "conf"), Target: "/etc/caddy",- }}},- }}-- err := prepareProjectBindDirectoriesInternal(projectPath)(context.Background(), project)- require.Error(t, err)- assert.Contains(t, err.Error(), filepath.Join(locked, "conf"))- assert.Contains(t, err.Error(), "service app")- assert.NoDirExists(t, filepath.Join(locked, "conf"))+ for _, tc := range []struct {+ name string+ dirMode os.FileMode+ fileMode os.FileMode+ createFile bool+ wantError bool+ }{+ {name: "missing directory in unwritable parent", dirMode: 0o500, wantError: true},+ {name: "missing directory in non-searchable parent", dirMode: 0o600},+ {name: "existing file in non-searchable parent", dirMode: 0o600, fileMode: 0o640, createFile: true},+ {name: "unreadable file in searchable parent", dirMode: 0o700, fileMode: 0o000, createFile: true},+ } {+ t.Run(tc.name, func(t *testing.T) {+ projectPath := t.TempDir()+ locked := filepath.Join(projectPath, "locked")+ require.NoError(t, os.Mkdir(locked, 0o700))+ t.Cleanup(func() { assert.NoError(t, os.Chmod(locked, 0o700)) })+ source := filepath.Join(locked, "conf")+ var originalInfo os.FileInfo+ if tc.createFile {+ require.NoError(t, os.WriteFile(source, []byte("config"), tc.fileMode))+ var err error+ originalInfo, err = os.Stat(source)+ require.NoError(t, err)+ }+ require.NoError(t, os.Chmod(locked, tc.dirMode))+ if tc.createFile {+ _, err := os.ReadFile(source)+ require.ErrorIs(t, err, fs.ErrPermission)+ }+ _, statErr := os.Lstat(source)+ switch {+ case tc.dirMode&0o100 == 0:+ require.ErrorIs(t, statErr, fs.ErrPermission)+ case tc.createFile:+ require.NoError(t, statErr)+ default:+ require.ErrorIs(t, statErr, fs.ErrNotExist)+ }++ project := &composetypes.Project{Services: composetypes.Services{+ "app": {Name: "app", Volumes: []composetypes.ServiceVolumeConfig{{+ Type: composetypes.VolumeTypeBind, Source: source, Target: "/etc/caddy",+ }}},+ }}++ err := prepareProjectBindDirectoriesInternal(projectPath)(context.Background(), project)+ if tc.wantError {+ require.ErrorIs(t, err, fs.ErrPermission)+ assert.Contains(t, err.Error(), source)+ assert.Contains(t, err.Error(), "service app")+ } else {+ require.NoError(t, err)+ }+ dirInfo, err := os.Stat(locked)+ require.NoError(t, err)+ assert.Equal(t, tc.dirMode, dirInfo.Mode().Perm())+ require.NoError(t, os.Chmod(locked, 0o700))+ if !tc.createFile {+ _, err := os.Lstat(source)+ require.ErrorIs(t, err, fs.ErrNotExist)+ return+ }+ info, err := os.Stat(source)+ require.NoError(t, err)+ assert.True(t, os.SameFile(originalInfo, info))+ assert.Equal(t, originalInfo.Mode(), info.Mode())+ assert.Equal(t, originalInfo.ModTime(), info.ModTime())+ require.NoError(t, os.Chmod(source, 0o600))+ content, err := os.ReadFile(source)+ require.NoError(t, err)+ assert.Equal(t, "config", string(content))+ })+ }}func newEnvDirectoryProjectInternal(t *testing.T, id string) (*ProjectService, *Project, string, context.Context) {diff --git a/backend/internal/project/project_sync.go b/backend/internal/project/sync.gosimilarity index 100%rename from backend/internal/project/project_sync.gorename to backend/internal/project/sync.godiff --git a/backend/internal/project/project_tags.go b/backend/internal/project/tags.gosimilarity index 100%rename from backend/internal/project/project_tags.gorename to backend/internal/project/tags.godiff --git a/backend/internal/project/project_tags_test.go b/backend/internal/project/tags_test.gosimilarity index 100%rename from backend/internal/project/project_tags_test.gorename to backend/internal/project/tags_test.godiff --git a/backend/internal/project/project_update.go b/backend/internal/project/update.gosimilarity index 96%rename from backend/internal/project/project_update.gorename to backend/internal/project/update.goindex 00f4895f3..63c99ade9 100644--- a/backend/internal/project/project_update.go+++ b/backend/internal/project/update.go@@ -56,8 +56,8 @@ func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, naname = resolveAuthoritativeProjectNameInternal(ctx, &proj, name, composeContent)}- if err := ensureProjectMutableInternal(&proj); err != nil {- return nil, err+ if proj.IsArchived {+ return nil, common.Classify(common.ErrProjectArchived, errors.New("project is archived and must be unarchived before this action"))}if err := ensureProjectEnvReadableInternal(ctx, projectsDirectory, proj.Path); err != nil {return nil, err@@ -79,9 +79,11 @@ func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, na}defer cleanupBackup()- journalActive, err := s.startProjectRenameJournalInternal(ctx, renameJournal)- if err != nil {- return nil, err+ journalActive := renameJournal != nil+ if journalActive {+ if err := s.writeProjectRenameJournalInternal(ctx, renameJournal, projecttypes.RenameJournalPhaseStarted); err != nil {+ return nil, err+ }}projectStateCommitted := false@@ -95,7 +97,7 @@ func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, nas.refreshProjectAfterContentUpdateInternal(ctx, &proj, composeContent, overrideContent)s.logProjectUpdateEventInternal(ctx, &proj, composeContent, envContent, overrideContent, user)if composeContent != nil || envContent != nil || overrideContent != nil {- s.filesChanged.Publish(proj.ID)+ s.FilesChanged.Publish(proj.ID)}slog.InfoContext(ctx, "project updated", "projectID", proj.ID, "name", proj.Name)@@ -257,8 +259,8 @@ func (s *ProjectService) ApplyGitSyncProjectFiles(ctx context.Context, projectIDif err != nil {return nil, false, err}- if err := ensureProjectMutableInternal(&proj); err != nil {- return nil, false, err+ if proj.IsArchived {+ return nil, false, common.Classify(common.ErrProjectArchived, errors.New("project is archived and must be unarchived before this action"))}before := s.readGitSyncProjectContentInternal(ctx, proj.ID)@@ -649,11 +651,11 @@ func (s *ProjectService) activeProjectRenameSyncStateInternal(ctx context.ContexskipDiscoveredPaths: make(map[string]struct{}),protectSeenPaths: make(map[string]struct{}),}- if s == nil || s.kvService == nil {+ if s == nil || s.KVService == nil {return state}- entries, err := s.kvService.ListByPrefix(ctx, projecttypes.RenameJournalKeyPrefix)+ entries, err := s.KVService.ListByPrefix(ctx, projecttypes.RenameJournalKeyPrefix)if err != nil {slog.WarnContext(ctx, "failed to list project rename journals during filesystem sync", "error", err)return state@@ -690,16 +692,6 @@ func (s activeProjectRenameSyncStateInternal) markProtectedPathsSeenInternal(see}}-func (s *ProjectService) startProjectRenameJournalInternal(ctx context.Context, journal *projecttypes.RenameJournal) (bool, error) {- if journal == nil {- return false, nil- }- if err := s.writeProjectRenameJournalInternal(ctx, journal, projecttypes.RenameJournalPhaseStarted); err != nil {- return false, err- }- return true, nil-}-func withProjectRenameRollbackInternal(ctx context.Context, proj *Project, projectStateCommitted *bool, run func() error) error {originalPath := proj.PathoriginalDirName := proj.DirName@@ -737,7 +729,7 @@ func withProjectRenameRollbackInternal(ctx context.Context, proj *Project, proje}func (s *ProjectService) prepareProjectRenameJournalInternal(proj *Project, name *string, projectsDirectory string, migration volumetypes.Migration) *projecttypes.RenameJournal {- if s == nil || s.kvService == nil || proj == nil || name == nil {+ if s == nil || s.KVService == nil || proj == nil || name == nil {return nil}@@ -757,10 +749,12 @@ func (s *ProjectService) prepareProjectRenameJournalInternal(proj *Project, nameNewName: newName,OldPath: filepath.Clean(proj.Path),NewPath: filepath.Clean(filepath.Join(projectsDirectory, newDirName)),- OldDirName: cloneStringPtrInternal(proj.DirName),NewDirName: newDirName,Phase: projecttypes.RenameJournalPhaseStarted,}+ if proj.DirName != nil {+ journal.OldDirName = new(*proj.DirName)+ }if source, ok := migration.(volumetypes.JournalSource); ok {journal.Volumes = source.JournalVolumes()@@ -770,7 +764,7 @@ func (s *ProjectService) prepareProjectRenameJournalInternal(proj *Project, name}func (s *ProjectService) writeProjectRenameJournalInternal(ctx context.Context, journal *projecttypes.RenameJournal, phase string) error {- if s == nil || s.kvService == nil || journal == nil {+ if s == nil || s.KVService == nil || journal == nil {return nil}journal.Phase = phase@@ -781,21 +775,21 @@ func (s *ProjectService) writeProjectRenameJournalInternal(ctx context.Context,return errors.WrapIf(err, "marshal project rename journal")}- if err := s.kvService.Set(ctx, projecttypes.RenameJournalKeyPrefix+journal.ProjectID, string(payload)); err != nil {+ if err := s.KVService.Set(ctx, projecttypes.RenameJournalKeyPrefix+journal.ProjectID, string(payload)); err != nil {return errors.WrapIf(err, "write project rename journal")}return nil}func (s *ProjectService) clearProjectRenameJournalInternal(ctx context.Context, projectID string) error {- if s == nil || s.kvService == nil || strings.TrimSpace(projectID) == "" {+ if s == nil || s.KVService == nil || strings.TrimSpace(projectID) == "" {return nil}- return s.kvService.Delete(ctx, projecttypes.RenameJournalKeyPrefix+projectID)+ return s.KVService.Delete(ctx, projecttypes.RenameJournalKeyPrefix+projectID)}func (s *ProjectService) writeProjectRenameRollbackCleanupInternal(ctx context.Context, journal *projecttypes.RenameJournal) error {- if s == nil || s.kvService == nil || journal == nil || strings.TrimSpace(journal.ProjectID) == "" || len(journal.Volumes) == 0 {+ if s == nil || s.KVService == nil || journal == nil || strings.TrimSpace(journal.ProjectID) == "" || len(journal.Volumes) == 0 {return nil}@@ -812,25 +806,25 @@ func (s *ProjectService) writeProjectRenameRollbackCleanupInternal(ctx context.Cif err != nil {return errors.WrapIf(err, "marshal project rename rollback cleanup")}- if err := s.kvService.Set(ctx, projecttypes.RenameRollbackCleanupKeyPrefix+journal.ProjectID, string(payload)); err != nil {+ if err := s.KVService.Set(ctx, projecttypes.RenameRollbackCleanupKeyPrefix+journal.ProjectID, string(payload)); err != nil {return errors.WrapIf(err, "write project rename rollback cleanup")}return nil}func (s *ProjectService) clearProjectRenameRollbackCleanupInternal(ctx context.Context, projectID string) error {- if s == nil || s.kvService == nil || strings.TrimSpace(projectID) == "" {+ if s == nil || s.KVService == nil || strings.TrimSpace(projectID) == "" {return nil}- return s.kvService.Delete(ctx, projecttypes.RenameRollbackCleanupKeyPrefix+projectID)+ return s.KVService.Delete(ctx, projecttypes.RenameRollbackCleanupKeyPrefix+projectID)}func (s *ProjectService) RecoverProjectRenameJournals(ctx context.Context) error {- if s == nil || s.kvService == nil {+ if s == nil || s.KVService == nil {return nil}- entries, err := s.kvService.ListByPrefix(ctx, projecttypes.RenameJournalKeyPrefix)+ entries, err := s.KVService.ListByPrefix(ctx, projecttypes.RenameJournalKeyPrefix)if err != nil {return err}@@ -851,11 +845,11 @@ func (s *ProjectService) RecoverProjectRenameJournals(ctx context.Context) error}func (s *ProjectService) recoverProjectRenameJournalForProjectInternal(ctx context.Context, projectID string) error {- if s == nil || s.kvService == nil || strings.TrimSpace(projectID) == "" {+ if s == nil || s.KVService == nil || strings.TrimSpace(projectID) == "" {return nil}- raw, ok, err := s.kvService.Get(ctx, projecttypes.RenameJournalKeyPrefix+projectID)+ raw, ok, err := s.KVService.Get(ctx, projecttypes.RenameJournalKeyPrefix+projectID)if err != nil || !ok {return err}@@ -883,11 +877,11 @@ func (s *ProjectService) recoverProjectRenameJournalInternal(ctx context.Context}func (s *ProjectService) recoverProjectRenameRollbackCleanupsInternal(ctx context.Context) error {- if s == nil || s.kvService == nil {+ if s == nil || s.KVService == nil {return nil}- entries, err := s.kvService.ListByPrefix(ctx, projecttypes.RenameRollbackCleanupKeyPrefix)+ entries, err := s.KVService.ListByPrefix(ctx, projecttypes.RenameRollbackCleanupKeyPrefix)if err != nil {return err}@@ -949,14 +943,6 @@ func (s *ProjectService) projectRenameRecoveryDockerInternal(ctx context.Contextreturn dockerClient, nil}-func cloneStringPtrInternal(value *string) *string {- if value == nil {- return nil- }- cloned := *value- return &cloned-}-func (s *ProjectService) renameRecoveryOperationsInternal() projecttypes.RenameRecoveryOperations {return projecttypes.RenameRecoveryOperations{Docker: s.projectRenameRecoveryDockerInternal,diff --git a/backend/internal/project/workspace.go b/backend/internal/project/workspace.goindex 99f85e758..2152e391a 100644--- a/backend/internal/project/workspace.go+++ b/backend/internal/project/workspace.go@@ -156,7 +156,11 @@ func (s *ProjectService) UpdateProjectWorkspace(ctx context.Context, projectID sif err := ensureProjectEnvReadableInternal(ctx, projectsDirectory, proj.Path); err != nil {return nil, err}- backup, cleanup, err := s.prepareProjectWorkspaceBackupInternal(ctx, projectsDirectory, proj.Path, manifest.FileChanges)+ scope := projects.ProjectUpdateBackupScope{}+ for _, change := range manifest.FileChanges {+ scope.Paths = append(scope.Paths, workspaceChangeTargetPathsInternal(change)...)+ }+ backup, cleanup, err := projects.BackupProjectDirectory(ctx, projectsDirectory, proj.Path, ".project-update-backup-*", scope)if err != nil {return nil, err}@@ -178,7 +182,7 @@ func (s *ProjectService) UpdateProjectWorkspace(ctx context.Context, projectID s"action": "update_project_workspace","fileChangeCount": len(manifest.FileChanges),}, "could not log project workspace update")- s.filesChanged.Publish(proj.ID)+ s.FilesChanged.Publish(proj.ID)return s.GetProjectWorkspace(ctx, projectID)}@@ -243,18 +247,6 @@ func (s *ProjectService) projectWorkspaceApplyOptionsInternal(ctx context.Contex}}-func (s *ProjectService) prepareProjectWorkspaceBackupInternal(ctx context.Context, projectsDirectory, projectPath string, changes []projecttypes.WorkspaceFileChange) (*projects.ProjectUpdateBackup, func(), error) {- scope := projects.ProjectUpdateBackupScope{}- for _, change := range changes {- scope.Paths = append(scope.Paths, workspaceChangeTargetPathsInternal(change)...)- }- return projects.BackupProjectDirectory(ctx, projectsDirectory, projectPath, ".project-update-backup-*", scope)-}--func isGitOpsManagedProjectInternal(proj *Project) bool {- return proj != nil && proj.GitOpsManagedBy != nil && strings.TrimSpace(*proj.GitOpsManagedBy) != ""-}-// gitOpsOwnedWorkspacePathsInternal returns the workspace-relative paths owned// by the project's GitOps sync — the files git writes on every sync. Only// these are locked for workspace editing; anything else in the directory is@@ -262,7 +254,7 @@ func isGitOpsManagedProjectInternal(proj *Project) bool {// sync engine deliberately never prunes (#3634). Returns nil for projects// without a live sync, including a stale gitops_managed_by marker.func (s *ProjectService) gitOpsOwnedWorkspacePathsInternal(ctx context.Context, proj *Project) (map[string]struct{}, error) {- if !isGitOpsManagedProjectInternal(proj) {+ if gitOpsSyncIDInternal(proj) == "" {return nil, nil}sync, err := loadGitOpsSyncForProjectInternal(ctx, s.db, proj.ID)diff --git a/backend/internal/swarm/module.go b/backend/internal/swarm/module.goindex b179a23b5..ff2fc7450 100644--- a/backend/internal/swarm/module.go+++ b/backend/internal/swarm/module.go@@ -15,19 +15,12 @@ type Dependencies struct {}type Module struct {- service *SwarmService+ Service *SwarmServicedeps Dependencies}func New(service *SwarmService, deps Dependencies) *Module {- return &Module{service: service, deps: deps}-}--func (m *Module) Service() *SwarmService {- if m == nil {- return nil- }- return m.service+ return &Module{Service: service, deps: deps}}func (m *Module) RegisterRoutes(api huma.API) {@@ -35,5 +28,5 @@ func (m *Module) RegisterRoutes(api huma.API) {RegisterSwarm(api, nil, nil, nil, nil)return}- RegisterSwarm(api, m.service, m.deps.Environment, m.deps.Event, m.deps.Config)+ RegisterSwarm(api, m.Service, m.deps.Environment, m.deps.Event, m.deps.Config)}diff --git a/backend/internal/system/module.go b/backend/internal/system/module.goindex 5bccac71e..e0bd84eb0 100644--- a/backend/internal/system/module.go+++ b/backend/internal/system/module.go@@ -36,14 +36,14 @@ type Dependencies struct {// Module wires the system domain and mounts its routes.type Module struct {- service *SystemService+ Service *SystemServicedeps Dependencies}// New builds the system domain from its dependencies.func New(deps Dependencies) *Module {return &Module{- service: NewSystemService(+ Service: NewSystemService(deps.DB,deps.Docker,deps.Container,@@ -58,15 +58,6 @@ func New(deps Dependencies) *Module {}}-// Service exposes the system service to collaborators that need it directly,-// such as the scheduled prune job.-func (m *Module) Service() *SystemService {- if m == nil {- return nil- }- return m.service-}-// RegisterRoutes mounts the system endpoints. A nil module still registers, so// OpenAPI spec generation can discover the routes without a service graph.func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext) {@@ -74,5 +65,5 @@ func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContRegisterSystem(api, nil, nil, nil, nil, nil, nil, appCtx)return}- RegisterSystem(api, m.deps.Docker, m.service, m.deps.SystemUpgrade, m.deps.Environment, m.deps.Config, m.deps.Activity, appCtx)+ RegisterSystem(api, m.deps.Docker, m.Service, m.deps.SystemUpgrade, m.deps.Environment, m.deps.Config, m.deps.Activity, appCtx)}diff --git a/backend/internal/updater/service_test.go b/backend/internal/updater/service_test.goindex 95c48ff91..9ce57735c 100644--- a/backend/internal/updater/service_test.go+++ b/backend/internal/updater/service_test.go@@ -495,8 +495,8 @@ func TestUpdaterService_PullImageAdapterInternal(t *testing.T) {registrySvc := registry.NewContainerRegistryService(db, nil, kv.NewKVService(db))imageSvc := image.NewImageService(db, dockerSvc, registrySvc, nil, nil, event.NewEventService(db, nil, nil))envSvc := environment.NewEnvironmentService(db, nil, nil, nil, nil, nil)- projectSvc := project.NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, nil).- WithRegistryCredentialsProvider(envSvc.GetEnabledRegistryCredentials)+ projectSvc := project.NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, nil)+ projectSvc.RegistryCredentialsProvider = envSvc.GetEnabledRegistryCredentialssvc, svcErr := NewUpdaterService(db, nil, dockerSvc, projectSvc, nil, nil, nil, imageSvc, nil, nil, nil)require.NoError(t, svcErr)var progress bytes.Bufferdiff --git a/backend/pkg/scheduler/scheduled_prune_job.go b/backend/pkg/scheduler/scheduled_prune_job.goindex c5e2c6806..0d2d787a5 100644--- a/backend/pkg/scheduler/scheduled_prune_job.go+++ b/backend/pkg/scheduler/scheduled_prune_job.go@@ -24,7 +24,7 @@ type ScheduledPruneJob struct {func NewScheduledPruneJob(systemModule *system.Module, settingsService *settings.SettingsService, notificationService *notification.NotificationService) *ScheduledPruneJob {return &ScheduledPruneJob{- systemService: systemModule.Service(),+ systemService: systemModule.Service,settingsService: settingsService,notificationService: notificationService,}