hpc-node
Shared contracts for node-level resource management between HPC systems. This crate defines traits and types for cgroup v2 management, Linux namespace handoff, mount lifecycle, and boot readiness signaling.
This crate enables multiple applications (like Pact and Lattice) to share common node management conventions while implementing their own backends independently.
Features
- cgroup v2 Conventions: Shared slice naming (
pact.slice/,workload.slice/), ownership model, scope management trait, resource limits - Namespace Handoff: Protocol for passing Linux namespace FDs between processes via unix socket (
SCM_RIGHTS) - Mount Management: Refcounted mount trait with lazy unmount and crash-recovery reconstruction
- Readiness Signaling: Boot readiness gate trait for coordinating init and workload systems
Installation
Add to your Cargo.toml:
[]
= "2026.1"
Or to use the latest development version from git:
[]
= { = "https://github.com/witlox/hpc-core" }
Usage
1. Implement the CgroupManager Trait
Each application provides its own cgroup management backend:
use ;
;
2. Query Slice Ownership
use ;
// Determine who owns a cgroup path
assert_eq!;
assert_eq!;
3. Namespace Handoff
use ;
// Lattice requests namespaces from pact via unix socket
let request = NamespaceRequest ;
// Send request over HANDOFF_SOCKET_PATH, receive FDs via SCM_RIGHTS
4. Mount Refcounting
use MountManager;
// Implementer provides refcounted mount management
// acquire_mount() → increments refcount (mounts if first)
// release_mount() → decrements refcount (starts hold timer at zero)
// force_unmount() → immediate unmount (emergency mode only)
// reconstruct_state() → rebuild refcounts from /proc/mounts after crash
Architecture
What's Provided (Shared Contract)
| Component | Description |
|---|---|
CgroupManager trait |
Hierarchy creation, scope lifecycle, metrics reading |
SliceOwner enum |
Ownership model: Pact (system services) vs Workload (allocations) |
slices constants |
Well-known cgroup paths for consistent hierarchy |
NamespaceProvider / NamespaceConsumer traits |
FD handoff protocol |
MountManager trait |
Refcounted mount lifecycle with lazy unmount |
ReadinessGate trait |
Boot readiness signaling |
| Well-known paths | Socket paths, mount base directories |
What You Provide (Application-Specific)
| Component | Description |
|---|---|
CgroupManager impl |
Your cgroup v2 filesystem operations |
NamespaceProvider impl |
Your unshare(2) + FD management |
MountManager impl |
Your mount(2) + refcount tracking |
ReadinessGate impl |
Your boot sequence completion signal |
Design Principles
- Traits and types only — no Linux-specific code, no implementations
- No runtime coupling — pact and lattice have no runtime dependency on each other
- Convention over configuration — well-known paths prevent drift
- Both systems work independently — lattice creates its own hierarchy when pact is absent