eggup-service
Manager-neutral service-registration, ownership, state, and lifecycle-snapshot model plus reusable Unix manager mechanics (systemd, launchd, user crontab) and a native Windows SCM adapter.
ServiceId/ServiceSpecidentify desired registrations with exact executable, arguments, and config evidence.Ownership::{Absent, Owned, Foreign, Unknown}reuses the canonical Eggup vocabulary: destructive manager operations are authorized only forOwned.LifecycleState::{Stopped, Running, Transitioning, Unknown}is distinct from application health (HealthState::{Healthy, Degraded, Unknown}).LifecycleSnapshotpreserves pre-update intent (was_running,was_registered) so orchestration can restore "was running" versus "was registered but stopped". Stopped services remain stopped by default.ServiceManagertrait plusTestDoubleManagerfor deterministic tests;HealthProbeseam is consumer-supplied and never mutates manager state.WindowsScmManageruses the safewindows-serviceSCM wrapper on Windows and a Windows command-line parser for exact executable/argument ownership. Service key name alone never authorizes a mutation; ambiguous registrations areUnknownand foreign registrations are denied.WindowsScmInstallsupplies caller-owned display/start/error settings. Creation never starts the service. Optional caller-supplied service or load-order-group dependencies are supported. Refresh preserves service type, unspecified dependencies, account, load-order group, and tag fields outside the adapter's ownership. Account selection is create-time only; custom passwords, descriptions, and recovery actions are not supported by this generic adapter.- Windows start/stop/restart polling shares one monotonic deadline per transition. Uninstall reports incomplete while SCM still exposes a marked-for-delete entry and completes only after confirmed absence. Access denial returns bounded remediation and never starts an elevation flow.
windows-serviceis a Windows-target dependency.windows-argsis the small cross-platform parser dependency used for the same ownership tests on Unix.- Bounded
TransitionResultwith conflict diagnostics; no automatic privilege elevation; no updater/release/network policy. commit_with_lifecyclecomposes an already validatedeggup_coretransaction with owned-service quiescence, successful-update restoration, a bounded caller-ownedPostInstallCheck, and Core'sKeepInstalled/RollBackpolicy. It requires an existingOwnedregistration inRunningorStoppedstate; it never installs or refreshes the registration.- With
RestoreIntent::Preserve, a stopped service stays stopped after success.RestoreIntentonly controls the successful new generation; after a successful artifact rollback, orchestration restores the pre-update running/stopped state. If Core reportsRecoveryRequired, it does not automatically start the service against uncertain artifacts. - The post-install check receives the remaining shared deadline and must
finish within it. Existing
HealthProbehas no timeout contract and alone does not meet this bound. Application health semantics remain caller-owned. - M003 hardening: each start/stop/restart validates one monotonic caller deadline shared by ownership queries, manager commands, and state polling. Zero transition timeouts are rejected; expiry is returned as an incomplete transition or a manager timeout.
- Production
SystemExecutorresolvessystemctl,launchctl, andcrontabonly from fixed absolute platform paths, never ambientPATH. It clears the child environment; only user-scoped systemd retainsDBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR, andSYSTEMD_BUS_ADDRESSwhen present. - systemd/launchd config ownership is proven by one exact config path occurrence
in canonical argv. Missing identity is
Foreign; repeated/ambiguous identity isUnknown. - M002 Unix adapters (
SystemdManager,LaunchdManager,CronManager) implementServiceManageron top of the M001 contract:- shared bounded command runner (literal argv, no shell, null/controlled
stdin, bounded output, deadline with kill/reap, injectable
FakeExecutorfor tests); - systemd: explicit
--system/--userscope, narrowExecStartparsing (ambiguous/specifier shapes yieldUnknown), atomic definition writes, explicitenable/daemon-reloadonly, boundedstart/stop/restartwith state confirmation, nosudo; - launchd: explicit
gui/<uid>vssystemtargets (never guessed), structuredProgramArgumentsparsing (malformed yieldsUnknown), label-only never proves ownership, boundedbootstrap/bootout/kickstart/stop, foreign labels fail closed; - cron: managed
# BEGIN/# END <marker>block (caller-owned marker + exact block), purecron_merge/cron_removepreserving unrelated bytes, idempotent install, owned-only removal, no redundantcrontab -writes, re-read before destructive writes to expose races, explicit "no start/stop semantics" errors; atomic_write_definition(same-dir exclusive temp, owner-safe mode,fsync, no-replace vs overwrite authority, owned-temp-only cleanup, never creates privileged parents);inspect_hostfacts vscandidate_managerspolicy (Linux systemd or cron; macOS launchd or cron; detection failure distinct from absent).
- shared bounded command runner (literal argv, no shell, null/controlled
stdin, bounded output, deadline with kill/reap, injectable
- Ownership for systemd/launchd uses exact executable plus critical args and reconciles optional config identity against those exact args. Consumer unit/plist bodies, usernames, paths, hardening text, health checks, and CLI messages stay consumer-owned. No consumer is migrated here.