Sokrates Permission Model and Hermes Agent Privileges

Summary

This law defines the security architecture and permission model for the Hermes agent on NixOS host systems. It establishes a least-privilege framework that allows the agent to manage the Sokrates stack—including Docker containers, systemd units, and specific data directories—while ensuring these configurations are declarative and persist across NixOS rebuilds.

Details

The Sokrates permission model is designed to enable the Hermes agent to act as an operational “Fleet Command” without granting it unrestricted root access. The model centers on the creation of a dedicated sokrates Unix group and the strategic assignment of directory permissions and group memberships.

Directory Access and Ownership

The primary data root for the stack is /var/lib/sokrates/. Access is partitioned based on the functional requirements of the Hermes agent:

PathPermissionRationale
/var/lib/sokrates/hermes/rwxPrimary home directory for the Hermes agent service.
/var/lib/sokrates/eidos/rwxStorage for Eidos configuration and the knowledge graph data; Hermes requires full access to update and debug the graph.
/var/lib/sokrates/neo4j/rxAccess to Neo4j configuration and health check endpoints.
/var/lib/sokrates/secrets/rAccess to API keys and service credentials required for agent functionality.
/var/lib/sokrates/skills/rShared logic and agent skills used across the Sokrates ecosystem.
/var/lib/sokrates/periphery/rxMonitoring of peripheral services without modification rights.

These permissions are enforced via NixOS systemd.tmpfiles.rules, ensuring that directory ownership and modes are reset to the correct state upon every system boot or configuration activation.

Group Memberships and System Capabilities

To interact with the host system and the containerized stack, the hermes user is assigned to specific groups:

  • sokrates group: A custom group created to own the shared directories under /var/lib/sokrates/.
  • docker group: Grants the agent the ability to manage containerized services via the Docker socket.

The agent is granted access to a specific subset of system tools required for diagnostics and lifecycle management. These include docker (or podman), systemctl (specifically for status and restart operations on sokrates-* units), journalctl (for log retrieval and debugging), and network diagnostic tools like curl and ss.

Implementation via NixOS

The permission model is implemented declaratively within the NixOS configuration. This prevents “configuration drift” where manual chmod or chown commands are lost after a system update. The configuration includes:

  1. Definition of the sokrates group in users.groups.
  2. Addition of the hermes user to extraGroups = [ "sokrates" "docker" ];.
  3. systemd.tmpfiles.rules entries that specify the UID/GID and permissions for the /var/lib/sokrates/ subdirectories.
  4. Environment path configurations to ensure the necessary system binaries are available to the Hermes service.