These docs are under active development and cover the v0.20 Kobicha security model.
§1.1 1 Introduction

Scope

This specification defines peinit, the init system for the Peios operating system. peinit is PID 1 -- a single-threaded Rust process responsible for service lifecycle management from boot to shutdown.

peinit is the sole service manager in Peios. All supervised process execution -- service starts, stops, restarts, health monitoring, and ad-hoc job submission -- passes through peinit. Services are identity-aware: each service process runs with a KACS token that determines its access rights, and each service object carries a Security Descriptor that controls who may manage it.

This specification covers:

  • The boot sequence -- two-phase bootstrap (hardcoded Phase 1, registry-driven Phase 2), boot modes (Full, Safe, Recovery), and the escalation path between them
  • The service model -- definition schema, registry layout, configuration generations, service types, triggers, and the Disabled flag
  • Service identity -- token materialisation for SYSTEM and authd-minted identities, per-service SIDs, privilege restriction
  • Services as securable objects -- ServiceSecurity descriptors, access rights, and peinit's own control security descriptor
  • The pre-exec sequence -- the exact operations between "peinit decides to start service X" and "the service binary is running"
  • The service state machine -- states, transitions, transition causes, restart semantics, reload semantics, and invariants
  • Dependencies -- Requires, Wants, BindsTo, and Conflicts relationships, graph validation, parallel start, failure propagation, conflict resolution, and shutdown ordering
  • Jobs -- supervised process execution as first-class objects, lifecycle, types, ad-hoc jobs, and the JFS consumption protocol
  • Operations -- queued state machine actions, lifecycle, conflict resolution, dependency propagation, and retention
  • Timers -- calendar expressions, evaluation, persistence, jitter, and clock behaviour
  • Shutdown -- triggers, the graceful shutdown sequence, signal handling, and global timeout enforcement
  • The control interface -- control socket wire protocol, peer authentication, the command set, wait semantics, and the notify socket
  • Service output handling -- stdout/stderr wiring, pre-eventd buffering, flood protection, eventd handoff, and console output
  • The security model -- trust boundaries, peinit's privilege requirements, service identity security, control socket security, notify socket security, and the attack surface

This specification does not cover:

  • KACS (covered by the KACS v0.20 specification)
  • LCS (covered by the LCS v0.21 specification)
  • registryd internals (storage engine, schema, caching)
  • authd (authentication, token minting, identity source routing)
  • lpsd (local principal store)
  • eventd (event storage, indexing, query API)
  • JFS kernel internals (token capture, privilege validation, the char device implementation)
  • Specific registry key schemas defined by other subsystems
  • Admin tooling (peiosctl, peinit-analyze)
  • The role system and package management
  • FACS (File Access Control via Security Descriptors)
  • Network-level service management (future remote SCM)
§1.2 1 Introduction

Terminology

This section defines terms used throughout the specification. Terms defined inline in later sections (activation generation, boot generation, transition cause, cgroup generation, etc.) are not duplicated here.

  • PKM (Peios Kernel Module): The single compiled-in kernel module containing all Peios kernel extensions. PKM is the boundary between Peios kernel code and the upstream Linux kernel.

  • KACS (Kernel-based Access Control System): The access control subsystem within PKM. Implements per-thread tokens, Security Descriptors, and AccessCheck. peinit depends on KACS for service identity (token installation on child processes), control interface authentication (peer token retrieval and AccessCheck), and service object access control (ServiceSecurity descriptors). Specified separately in the KACS v0.20 specification.

  • LCS (Layered Configuration Subsystem): The configuration subsystem within PKM, peer to KACS. Implements the kernel-side registry: syscall dispatch, hive routing, access control enforcement, layer resolution, watch dispatch, and transaction coordination. peinit reads service definitions and configuration from the registry via LCS syscalls. Specified separately in the LCS v0.21 specification.

  • Registry: The user-facing configuration system provided by LCS and its sources working together. peinit reads service definitions from Machine\System\Services\, boot configuration from Machine\System\Boot\, and its own operational parameters from Machine\System\Init\. When precision matters, use "LCS" for the kernel subsystem and the relevant source name for the userspace component.

  • registryd: The userspace registry source daemon. peinit starts registryd during Phase 1 boot using a compiled-in service definition. registryd implements the Registry Source Interface for persistent hives. peinit treats registryd as an opaque dependency -- it does not interact with registryd's storage internals. In Recovery mode, the administrator interacts directly with the registryd implementation (loregd) via diagnostic command-line flags. See the Boot Modes section.

  • Token: A per-thread identity object maintained by KACS. Contains a user SID, group SIDs, a privilege bitmask, an integrity level, and metadata. peinit requests tokens from authd for service processes and installs them before exec. For SYSTEM services, peinit clones its own token. Tokens are the sole identity mechanism -- peinit never sets Linux UIDs, GIDs, or capabilities on service processes.

  • SID (Security Identifier): A unique principal identifier (e.g., S-1-5-18 for SYSTEM, S-1-5-32-544 for Administrators). SIDs appear in tokens (as identity), in Security Descriptors (as access rules), and in registry paths (Users\<SID>\).

  • Security Descriptor (SD): A KACS structure controlling access to a securable object. Contains a DACL (who can access, and how) and optionally a SACL (audit policy). peinit uses SDs in two contexts: ServiceSecurity descriptors control who may manage a service via the control interface, and peinit's own control SD controls who may perform system-level operations (shutdown, reload-config).

  • AccessCheck: The KACS kernel function that evaluates a caller's token against an object's SD to produce an access decision. peinit calls AccessCheck to authorize every control interface command. Single code path for all access control decisions across all Peios subsystems.

  • Privilege: A granular system-wide right carried on a token. Privileges are checked by name and enforced by KACS. peinit uses RequiredPrivileges to restrict service tokens -- privileges not in the list are removed before exec.

  • Impersonation: A thread temporarily assuming a different identity. The thread's effective token changes; its primary token is preserved. peinit uses impersonation indirectly -- KACS captures client identity on control socket connections, and peinit evaluates that identity via AccessCheck.

  • SYSTEM: The highest-privilege built-in identity (S-1-5-18). peinit runs as SYSTEM for the lifetime of the system. Platform services (registryd, authd, lpsd, eventd) also run as SYSTEM. SYSTEM carries all defined privileges.

  • authd: The central identity authority. Handles authentication, token minting, logon session creation, and identity source routing. peinit requests service tokens from authd for non-SYSTEM services. authd automatically adds a per-service SID to each minted token.

  • lpsd (Local Principal Store): The local identity database. Users, groups, SID allocation, password hashes. One of potentially many identity sources that authd routes to.

  • eventd: The logging and audit daemon. Drains the kernel audit ring buffer, captures service logs, stores events, and serves the query API. peinit forwards service stdout/stderr to eventd and emits structured lifecycle events. eventd is ErrorControl=Critical -- its failure triggers a reboot. Observability is a foundational guarantee in Peios, not an optional layer.

  • Service: A named, supervised unit of execution managed by peinit. A service has a definition (registry schema), a runtime state (state machine), and optionally a running process. Services are securable objects -- each carries a Security Descriptor controlling who may manage it.

  • Job: A single supervised process execution. Every time peinit forks a process -- starting a service, running a hook, executing a health check, or handling an ad-hoc run request -- the execution is a job with a GUID, lifecycle tracking, and log correlation. Jobs are the observable unit of "what actually ran."

  • Operation: A first-class object representing a requested state machine action on a service. Control commands (start, stop, restart, reload, reset) create operations that are validated, queued, and executed. Operations provide conflict resolution for concurrent commands and observable lifecycle tracking via GUIDs.

  • JFS (Job Forwarding Subsystem): A kernel subsystem within PKM that provides a secure bridge for ad-hoc job submission. JFS captures the caller's effective KACS token and delivers it to peinit via /dev/jfs. peinit consumes JFS requests from its event loop. JFS kernel internals are outside the scope of this specification.

  • KMES (Kernel Mediated Event Subsystem): The kernel-side observability component within PKM. Manages the kernel ring buffer, trusted metadata stamping, and event persistence across reboots. KMES ensures audit data survives eventd restarts and system reboots.

  • TCB (Trusted Computing Base): The set of components whose correct behaviour is necessary for the system's security guarantees. In peinit's context, the TCB comprises the kernel, KACS, LCS, KMES, peinit, registryd, authd, lpsd, and eventd. A compromise of any TCB component compromises the entire system.

  • sd_notify: A datagram-based readiness and health signalling protocol. Services send structured messages (e.g., READY=1, WATCHDOG=1) to peinit via a Unix datagram socket whose path is provided in the NOTIFY_SOCKET environment variable. Sender authentication uses kernel-attested PID matching.

  • pidfd: A file descriptor referring to a specific process, obtained atomically at fork time via clone3(CLONE_PIDFD). pidfds eliminate PID reuse races and provide race-free process supervision. peinit tracks every managed process via a pidfd.

  • cgroup: A Linux kernel mechanism for grouping processes. peinit uses cgroups v2 exclusively, for process tracking and clean kill. Every service runs in its own cgroup tree under /sys/fs/cgroup/peinit/. peinit does not use cgroups for resource accounting or limits.

  • Phase 1: The hardcoded bootstrap phase. peinit remounts root read-write, mounts virtual filesystems, sets the system clock, starts registryd, and performs infrastructure setup (control socket, JFS device, loopback interface). No registry access occurs during Phase 1.

  • Phase 2: The registry-driven boot phase. With registryd running, peinit reads service definitions from the registry and starts all boot-triggered services in dependency order.

  • Mount pseudo-service: A synthetic Oneshot service generated by peinit from mount entries in Machine\System\Boot\Mounts\. Named mount:<mountpoint> (e.g., mount:/data). Behaves as a Oneshot with RemainAfterExit -- the mount completes, the pseudo-service stays in Completed, and dependents can start. Participates in the dependency graph like any other service.

  • ErrorControl: A per-service policy that determines peinit's response when a service fails irrecoverably. Normal (default): service remains in Failed state. Critical: peinit syncs filesystems and reboots.

§1.3 1 Introduction

Conventions

This specification uses the key words MUST, MUST NOT, SHALL, SHALL NOT, SHOULD, SHOULD NOT, MAY, REQUIRED, and OPTIONAL as described in RFC 2119.

ⓘ Informative
"MUST" and "SHALL" indicate absolute requirements. "MUST NOT" and "SHALL NOT" indicate absolute prohibitions. "SHOULD" indicates a recommendation that may be departed from in particular circumstances with full understanding of the implications. "MAY" indicates a truly optional feature.

Pseudocode in this specification uses the following conventions:

  • & as a parameter prefix denotes an in-out parameter (the caller's value is read and may be modified).
  • = is assignment. == is equality comparison.
  • and, or, not are boolean operators.
  • | denotes bitwise OR. & in expressions denotes bitwise AND.
  • // introduces a comment.
  • -> denotes field access on a structure.
  • Functions return values via return. Error conditions return named error codes (e.g., return ETIMEDOUT).

Structure definitions use the following format:

ServiceDefinition {
    field_name:  type       // description
    field_name:  type?      // nullable (absent or not set)
    field_name:  type[]     // array
}

State machine transitions are written as:

From -> To [guard condition] / action

Registry paths use backslash as the path separator (e.g., Machine\System\Services\). This matches the LCS convention.

All timeout and interval values in the service definition schema are in seconds unless explicitly stated otherwise.

JSON examples in the control interface sections represent the exact wire format. Field names, types, and value formats are normative. Enum values in JSON use snake_case (e.g., "start", "admin", "active", "explicit_start", "service_main"). Error codes in JSON use UPPER_SNAKE_CASE (e.g., "ACCESS_DENIED"). Enum values in structure definitions and prose use PascalCase (e.g., Start, Admin, Active, ExplicitStart, ServiceMain).

Section references within this specification use page titles (e.g., "see the States and Transitions section").

§1.4 1 Introduction

Compatibility

peinit is the init system of Peios. It is not a port or reimplementation of systemd, Windows SCM, or any other service manager. The design choices -- KACS-integrated identity, registry- based configuration, operations as first-class objects, jobs as observable execution units -- were made because they solve the problems Peios needs solved.

Several interfaces are compatible with existing conventions where compatibility serves Peios's goals. This compatibility is intentional and maintained.

§1.4.1 sd_notify protocol

peinit supports the sd_notify datagram protocol for service-to- init communication. Services send KEY=VALUE messages to a Unix datagram socket whose path is provided via the NOTIFY_SOCKET environment variable. peinit authenticates senders via kernel- attested PID matching.

The following sd_notify fields are supported:

Field Behaviour
READY=1 Service has completed startup and is ready to serve. Gates dependent startup for services using Notify readiness.
RELOADING=1 Service is reloading configuration. Extends the reload detection window so peinit waits for READY=1 completion (see the Restart and Reload section).
STOPPING=1 Service is shutting down gracefully. Acknowledged by peinit.
STATUS=... Human-readable status string. Forwarded to eventd and exposed via status queries.
ERRNO=... Errno-style error number. Forwarded to eventd.
EXIT_STATUS=... Exit status for informational purposes. Forwarded to eventd.
WATCHDOG=1 Keepalive ping. Resets the watchdog timer.
WATCHDOG_USEC=... Updates the watchdog timeout at runtime.
EXTEND_TIMEOUT_USEC=... Requests additional time during start, stop, or reload transitions.
FDSTORE=1 Pushes the accompanying file descriptor into peinit's per-service fd store for persistence across restarts.
FDNAME=... Names a stored file descriptor. Used with FDSTORE for retrieval after restart.
FDSTOREREMOVE=1 Removes a previously stored file descriptor by name.
FDPOLL=0 Marks a stored fd as not requiring poll monitoring.

The following fields are not supported:

Field Reason
MAINPID=... peinit does not support forking daemons. peinit tracks the process it spawned via pidfd. There is no mechanism for a service to redirect supervision to a different PID.
BUSERROR=... D-Bus error reporting. Peios does not use D-Bus.

Unrecognised fields are silently ignored. This ensures forward compatibility -- a service compiled against a newer sd_notify specification will not break when running under peinit.

The exact semantics of each field are defined in their respective sections: sender authentication and peer identity in the Control Interface section, state transitions (READY=1, RELOADING=1) and watchdog keepalives (WATCHDOG=1, WATCHDOG_USEC) and timeout extension (EXTEND_TIMEOUT_USEC) in the Restart and Reload section, STOPPING=1 acknowledgement in the Shutdown section, fd store lifecycle (FDSTORE, FDNAME, FDSTOREREMOVE, FDPOLL) in the Control Interface section, and STATUS= exposure in the Command Set section.

STATUS=, ERRNO=, and EXIT_STATUS= are forwarding fields: peinit MUST authenticate the sender, then forward the value to eventd as a structured event tagged with the service name and job GUID. STATUS= is additionally stored on the service's runtime state and exposed via the status_text field in status query responses. ERRNO= and EXIT_STATUS= are not stored -- they are forwarded to eventd and discarded. All three fields MUST be subject to the same sender authentication as other sd_notify messages.

§1.4.2 Calendar expressions

Timer schedules use systemd's OnCalendar expression format:

DayOfWeek Year-Month-Day Hour:Minute:Second Timezone

Each field supports wildcards (*), lists (1,15), ranges (Mon..Fri), repetition (*-*-* *:00/15:00), and last-day-of- month (~). Timezone specifiers (e.g., Europe/London, US/Eastern) are supported; expressions without a timezone are interpreted in system-local time. The shortcuts daily, hourly, weekly, and monthly are supported.

DST transitions are handled as follows:

  • Spring forward (clock skips an hour): scheduled times that fall within the skipped interval MUST NOT fire. The next valid occurrence fires normally.
  • Fall back (clock repeats an hour): scheduled times that fall within the repeated interval MUST fire exactly once, on the first occurrence.

The exact parsing rules and next-occurrence computation are defined in the Timers section.

§1.4.3 systemd unit files

peinit does not read, parse, or translate systemd unit files. Service definitions are stored in the registry under Machine\System\Services\. There is no compatibility layer, generator, or migration path at the init level. Role definitions are the mechanism for declaring service configuration in Peios.

§1.4.4 Windows SCM

peinit's service model is influenced by Windows Service Control Manager concepts: services as securable objects with per-service Security Descriptors, token-based service identity, a control interface with access-controlled operations, and a structured service state machine. This influence is architectural, not interface-level. peinit does not implement the Windows SCM RPC protocol, Windows service types (kernel driver, shared process), or Windows-specific control codes.

§1.4.5 Features handled by other subsystems

The following features relevant to a complete service management posture are not part of peinit:

Feature Subsystem
Authentication and token minting authd
Local identity database lpsd
Log storage, indexing, and queries eventd
Registry storage registryd (via LCS)
Software packaging and installation Role system, pacman
Device management eudev
Network configuration Dedicated network service
DNS, DHCP, and infrastructure services Role-installed services
File access control enforcement FACS