Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

Technical overview of HPM — system design, dependency resolution, cleanup, storage, and Python integration. Intended for contributors and integrators.

Table of contents

  1. System overview
  2. Crate layout
  3. Core types
  4. Dependency resolution
  5. Install flow
  6. Project-aware cleanup
  7. Storage architecture
  8. Python integration
  9. Security and performance
  10. Extension points

System overview

HPM is a modular monolith. A single binary (hpm-cli) drives a handful of focused library crates. Responsibilities are split along stable seams: manifest parsing, configuration, resolution, storage, Python, and errors all live in their own crates so they can be reused (e.g., a desktop app can depend on the library crates and skip the CLI entirely).

┌────────────────────────────────────────────────────────────────────────┐
│ CLI (hpm-cli)                                                          │
│   • subcommands: init, add, remove, install, update, list, search,     │
│     run, check, build, pack, audit, clean, registry, global,          │
│     completions                                                        │
│   • output formats: human, json, json-lines, json-compact              │
│   • shell completions: bash, zsh, fish, powershell, elvish             │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │
┌───────────────────────────────────▼────────────────────────────────────┐
│ Core orchestration (hpm-core)                                          │
│   • StorageManager: global package install/remove/list                 │
│   • ProjectDiscovery: scan configured paths for active projects        │
│   • LockFile / LockedDependency / PackageSource                        │
│   • Registry trait + ApiRegistry, GitRegistry                          │
│   • ArchiveFetcher, packer                                             │
└─────────┬──────────────────┬──────────────────┬─────────────────────────┘
          │                  │                  │
┌─────────▼────────┐   ┌───────────────┐   ┌───────────────┐
│ hpm-package      │   │ hpm-assets    │   │ hpm-config    │
│   PackageManifest│   │   Asset       │   │   Config      │
│   DependencySpec │   │   AssetKind   │   │   Storage/    │
│   StageConfig    │   └───────────────┘   │   Projects/   │
│   Platform       │                       │   Signing     │
│   HoudiniPackage │                       └───────────────┘
└──────────────────┘

Python tooling — bundled uv, content-addressable venvs, the Houdini→Python ABI mapping, and per-script venv resolution — lives in hpm_core::python.

hpm-package and hpm-assets are the workspace leaves — neither depends on another HPM crate. hpm-config depends on hpm-package (for the registry types and the shared TOML-file error and atomic-write helpers), so it is not a leaf despite sitting alongside them in the diagram above.

Each crate defines its own error type (e.g. StorageError, LockError) via thiserror; hpm-config has none and returns hpm_package::TomlFileError. Errors surface to the user through CliError in hpm-cli, which converts them to exit codes and help hints.

Key non-functional properties:

  • Language: Rust, edition 2024, MSRV 1.89.
  • Async runtime: Tokio, multi-thread.
  • Configuration: TOML throughout (manifests, lock file, global config).
  • Testing: unit, integration, and property-based (proptest) tests.

Crate layout

CrateResponsibility
hpm-cliCommand-line frontend (clap). Turns command-line invocations into calls on the library crates.
hpm-coreStorage, project discovery, lock file, registry trait + two implementations, archive fetching/packing, Python tooling (python submodule: bundled uv, venvs, cleanup).
hpm-packagehpm.toml parsing and validation, dependency/Python dependency types, Houdini package.json generation, platform enum.
hpm-assetsOperator asset-index model (Asset, AssetKind) emitted by hpm pack from [[operators]] declarations.
hpm-configGlobal and project configuration loading and merging.

Dependencies flow downward: hpm-cli depends on everything else, hpm-core depends on package, assets, and config, and so on. No crate depends upward. Domain errors (StorageError, LockError, …) live in the crate that produces them.

Core types

Selected public types. See cargo doc --workspace --no-deps --open for the full list.

hpm-package

#![allow(unused)]
fn main() {
pub struct PackageManifest {
    pub package: PackageInfo,
    pub compat: CompatConfig,
    pub stage: StageConfig,
    pub registries: Vec<RegistryConfig>,
    pub dependencies: IndexMap<String, DependencySpec>,
    pub python_dependencies: IndexMap<String, PythonDependencySpec>,
    pub runtime: IndexMap<String, ManifestEnvEntry>,
    pub scripts: PackageScripts,
    pub operators: Vec<OperatorDecl>,
}
// All collections and section structs use `#[serde(default,
// skip_serializing_if = ...)]` so an absent TOML section round-trips to
// the same in-memory representation as an empty one.

pub struct PackageScripts {
    pub commands: IndexMap<String, ScriptEntry>,  // flat entries under [scripts]
}

// Untagged: serialises as either a bare string ("cargo build") or a table
// form { cmd, python?, requirements?, label?, description?, package-env? }.
// The table form opts the script into
// a uv-managed venv resolved on demand by `hpm run`, and supports
// conditional cmd values via the same `when` grammar `[runtime]` uses.
pub enum ScriptEntry {
    Plain(String),
    WithEnv(ScriptEnv),
}

pub struct ScriptEnv {
    pub cmd: ScriptCommand,            // flat string or [{ when = { os }, set }, ...]
    pub python: Option<PythonTag>,     // e.g. "3.11"
    pub requirements: Vec<String>,     // e.g. ["PySide6>=6.6"]
    pub label: Option<String>,         // display name for UIs; hpm never acts on it
    pub description: Option<String>,   // one-line description for tooltips/help
    pub package_env: bool,             // run inside the package's full resolved env
}

pub struct PackageInfo {
    pub path: PackagePath,         // "creator/slug", validated kebab-case
    pub name: String,              // freeform display name
    pub version: String,           // semver
    pub description: Option<String>,
    pub authors: Vec<String>,      // empty vec encodes "no authors declared"
    pub license: Option<String>,
    pub readme: Option<String>,
    pub homepage: Option<String>,
    pub repository: Option<String>,
    pub documentation: Option<String>,
    pub keywords: Vec<String>,
    pub categories: Vec<String>,
}

pub enum DependencySpec {
    // The bare-string shorthand `pkg = "1.0.0"` (de)serializes as
    // Registry { registry: None, optional: false }.
    Registry { version: String, registry: Option<String>, optional: bool },
    Url { url: String, version: String, optional: bool },
    Path { path: String, optional: bool, link: bool },       // link=true → symlink/junction install
}

pub enum Platform {
    LinuxX86_64,       // "linux-x86_64"
    LinuxAarch64,      // "linux-aarch64"
    MacosX86_64,       // "macos-x86_64"
    MacosAarch64,      // "macos-aarch64"
    WindowsX86_64,     // "windows-x86_64"
    WindowsAarch64,    // "windows-aarch64"
    Universal,         // "universal" — OS-agnostic (pure-Python / data)
}
}

hpm-core

#![allow(unused)]
fn main() {
pub struct LockFile {
    pub package: LockPackageInfo,
    pub dependencies: BTreeMap<String, LockedDependency>,
    pub python_dependencies: BTreeMap<String, LockedPythonDependency>,
    pub metadata: Option<LockMetadata>,
}

pub struct LockedDependency {
    pub version: String,
    pub checksum: Option<String>,    // "v2:<hex>" SHA-256 of the installed tree (tree_hash); bare <hex> in older locks
    pub source: LockedSource,        // Url { url, version } | Path { path }
}

#[async_trait]
pub trait Registry: Send + Sync {
    async fn search(&self, query: &str) -> Result<SearchResults, RegistryError>;
    // One entry per *build*, not per version — see below.
    async fn get_versions(&self, name: &str) -> Result<Vec<RegistryEntry>, RegistryError>;
    async fn get_version(&self, name: &str, version: &str) -> Result<RegistryEntry, RegistryError>;
    async fn refresh(&self) -> Result<(), RegistryError>;
    fn name(&self) -> &str;
}
}

A RegistryEntry is one published archive, so a version released for Windows and Linux is two entries differing in dl, cksum and platform. The trait deliberately exposes them all: get_version picks the host’s with select_build_for_host, and it needs the full set to choose from.

RegistrySet::get_versions and RegistrySet::search are the version views on top of that. They collapse each (name, version)’s builds to a single entry — the host’s build, then a universal one, then the first row — so a version picker shows a two-platform release once rather than twice, and highest_matching (which compares version strings and nothing else) resolves an unpinned range to an archive this host can actually run. A version with no build for this host still lists, carrying its own metadata; deciding it is uninstallable stays select_build_for_host’s job at install time. search collapses per registry, so a package served by two registries still shows both.

hpm-core::python

#![allow(unused)]
fn main() {
pub struct PythonVersion {
    pub major: u8,
    pub minor: u8,
    pub patch: Option<u8>,
}

pub struct ResolvedDependencySet {
    pub python_version: PythonVersion,
    pub packages: BTreeMap<String, String>,   // name → exact version
}

pub struct VenvManager { /* … */ }

impl VenvManager {
    pub async fn ensure_virtual_environment(
        &self,
        resolved: &ResolvedDependencySet
    ) -> Result<PathBuf, PythonError>;
}
}

hpm-config

#![allow(unused)]
fn main() {
pub struct Config {
    pub install: InstallConfig,
    pub storage: StorageConfig,
    pub projects: ProjectsConfig,
    pub registries: Vec<RegistrySourceConfig>,
    pub signing: SigningConfig,
}

pub struct StorageConfig {
    pub home_dir: PathBuf,            // default: $HOME/.hpm
    pub cache_dir: PathBuf,
    pub packages_dir: PathBuf,
    pub registry_cache_dir: PathBuf,
}
}

Configuration is layered: defaults → ~/.hpm/config.toml → <cwd>/.hpm/config.toml. Files are parsed as presence-aware overlays (ConfigOverlay), so each layer overrides exactly the values it sets — a file that omits a section leaves the lower layers untouched.

Dependency resolution

hpm install installs the project’s dependencies and every package their versions require (ProjectManager::sync_dependencies_with): an exact version is a pin, a range takes the newest version in it that fits, and hpm add / hpm update write the version they choose back as an exact one. The set is chosen by registry::closure::select_closed, the same loop an application that embeds hpm runs, so the two install the same packages for the same project. A path dependency takes part as registry::closure::working_copy: the version its hpm.toml declares, held like a pin, requiring that file’s registry dependencies. A package the project does not list keeps the version hpm.lock recorded while the set still fits it (the lock’s versions are offered as pinned supplied packages); when it does not fit, or under SyncOptions::refresh (hpm update), it is chosen anew, and --frozen-lockfile fails instead (registry::closure::select_keeping). A pinned package already in the store contributes its requirements from its installed hpm.toml, so a project that is installed and locked syncs without asking a registry. SyncOptions::excluded names packages the sync must leave out unless the manifest lists them (an embedding application passes the ones it excluded when choosing the set: switched off, or not available to the account); a requirement on one is left unmet, so it is never looked up, installed, locked or loaded.

Choosing which versions a set of packages should use is hpm_core::registry::solve. A registry entry carries deps, the version ranges that version requires of other packages (its manifest’s [dependencies], as the registry stores them), and houdini_compat. solve takes the registry’s version lists for a set of packages, the target Houdini, and any pins, and returns one version per package such that every chosen version’s deps on the others hold: a pin stands as written, and an unpinned package takes its newest non-yanked version that supports the Houdini and has a build for the host (or a universal one), backtracking when that version cannot coexist with the rest. The platform rule is install’s, and registry::has_build_for is that rule on its own for an application that ranks versions itself: the version views list a version with no build for the host, and a solver that chose it would fail the install with NoCompatibleBuild even when an older version would have installed. A requirement on a package outside the set constrains nothing; it does not add the package.

solve_with also takes packages that are available. One of those is part of the answer exactly when a chosen version requires it, directly or through another available package, and it constrains nothing while it is not. A version whose requirements cannot be met, because the required package has no version that fits or rules that version out itself, is passed over for an older one. registry::closure::select_closed offers the required packages, and offers again whatever the answer’s versions require that it had not fetched yet, until nothing is missing; where versions come from is a VersionSource (the registries for hpm install). The choice has to be made inside the search: adding a required package to the set and removing it when the next answer no longer requires it can alternate between two answers and never finish.

When no set of versions works, the error is SolveError::Conflict, and it says in data, not only in its text, what went wrong. It names the package the search could not place and how that package came into the set, and for each version the package could have taken, every requirement that rules it out against the versions selected at the time (a Cause): a selected package that requires this one at versions this one is not, this version requiring a selected package at versions that package is not, or this version requiring a package that has no usable version at all. Each selected package carries its Origin: listed by the project (and whether pinned), or pulled in through a chain of requirements that starts at a listed package. An application can therefore tell a user which of the packages they listed to update or pin, even when the conflict is in a package they never listed. The selected versions are one witness that the package cannot be placed, not the only one.

An embedding application can write a project’s manifest from these selections, which is what keeps a release that breaks an older version of a dependent package from reaching projects on that version.

Version requirement grammar

HPM manifest values accept the usual semver constraint operators:

FormMeaning
=1.2.3, 1.2.3Exact.
^1.2.3Compatible with the given major (>=1.2.3, <2.0.0).
~1.2.3Patch updates allowed (>=1.2.3, <1.3.0).
>=1.0.0, <2.0.0Explicit range.

Install flow

The install command itself is a thin shell — it loads the manifest + lockfile, builds a ProjectManager, and calls sync_dependencies(). Embedding clients use the same ProjectManager entry point, so every client runs the same flow.

 ┌──────────────────────────────────────────────────────────────────────┐
 │ hpm install (CLI)            ── ProjectManager::sync_dependencies ── │
 ├──────────────────────────────────────────────────────────────────────┤
 │  1. Load hpm.toml                                                    │
 │  2. If hpm.lock exists (unreadable → stop):                          │
 │       each locked checksum is the expected tree digest: checked      │
 │       on the extracted archive before it reaches the store, and on   │
 │       a store copy before it is reused (--frozen-lockfile requires   │
 │       one per registry/URL package installed, required ones too)     │
 │       warn if metadata.generated_at > 90 days                        │
 │  3. Install URL deps; read path deps' hpm.toml                       │
 │  4. Choose the set: registry::closure::select_closed over the        │
 │     registry deps, path/URL deps as working copies, the lock's       │
 │     required versions supplied (unless refresh); a set that no       │
 │     longer fits the lock is chosen again unless --frozen-lockfile    │
 │  5. Fetch + install in parallel (one task per package, JoinSet):     │
 │       Registry        → query registry, chosen-version lookup        │
 │                       → ArchiveFetcher → ~/.hpm/fetch/               │
 │                       → install_into_cas → ~/.hpm/packages/<slug>@<v>/ │
 │                         (refused unless its manifest declares the    │
 │                         requested name and version)                  │
 │       Url             → ArchiveFetcher (no registry query)           │
 │                       → install_into_cas                             │
 │       Path            → install_as_dev_copy (or install_as_dev_link  │
 │                         if { link = true })                          │
 │                       → ~/.hpm/packages/_dev/<slug>@<v>/             │
 │                         (real dir for copy, symlink/junction for     │
 │                         link mode — both honor _dev/ CAS isolation)  │
 │     Already-in-CAS deps short-circuit (avoids the install_into_cas   │
 │     remove-and-recopy that breaks on Windows when Houdini is open),  │
 │     but still get one exec_mode::ensure_repaired sweep — nothing     │
 │     else ever revisits a tree installed by an older hpm.             │
 │  6. Merge [python_dependencies] from every installed dep manifest    │
 │     (the root manifest's own are used by package-env scripts only)   │
 │     Python ABI = root manifest's [compat].houdini lower bound        │
 │  7. Ensure managed CPython installed under ~/.hpm/uv-python/         │
 │     (uv python install <ver>) — auto-downloads on clean machines     │
 │  8. Resolve with bundled uv, hash the resolved set, pick or          │
 │     rebuild ~/.hpm/venvs/<hash>/                                     │
 │  9. uv pip install --python <venv>/bin/python                        │
 │ 10. Write <project>/.hpm/packages/{creator}.{slug}.json per package  │
 │ 11. Sweep stale <project>/.hpm/packages/ entries                     │
 │ 12. CLI step: build new lockfile from sync's InstallOutcomes         │
 │     (backfilled from the prior lockfile for short-circuited entries) │
 │     and write hpm.lock                                               │
 └──────────────────────────────────────────────────────────────────────┘

A registry dependency written as a full version is a pin; a range takes the newest version in it that fits the rest of the set (see Dependency resolution). hpm update rewrites each spec to the version it chose and installs with SyncOptions::refresh.

--frozen-lockfile aborts if loading the existing lockfile fails, if any cached checksum mismatches, or if the freshly-resolved set differs from the prior lockfile.

Project-aware cleanup

hpm clean removes packages and venvs no active project depends on. The identity of “active projects” comes from the [projects] config section.

  I = installed packages in ~/.hpm/packages/
  P = active projects discovered via ProjectDiscovery
  D(p) = deps declared by project p, plus every registry/URL package
         p's hpm.lock records, at the locked version
  T(I) = transitive closure over the dependency graph

  orphans = I \ T( ⋃ D(p) )

Implementation outline:

#![allow(unused)]
fn main() {
// crates/hpm-core/src/graph.rs
impl DependencyGraph {
    /// BFS from each root, returning every `PackageId` reachable along
    /// dependency edges. The roots themselves are included.
    pub fn mark_reachable_from_roots(&self, roots: &[PackageId]) -> HashSet<PackageId> {
        let mut reachable = HashSet::new();
        for root in roots {
            let Some(&start) = self.index_of.get(root) else {
                continue;
            };
            let mut bfs = Bfs::new(&self.graph, start);
            while let Some(idx) = bfs.next(&self.graph) {
                reachable.insert(self.graph[idx].id.clone());
            }
        }
        reachable
    }
}
}

DependencyGraph wraps a petgraph graph; its fields are private and it exposes no orphans() of its own. Taking the set difference against what is actually installed on disk is the cleanup plan’s orphan_packages (crates/hpm-core/src/storage/cleanup.rs, reached through cleanup_unused and cleanup_unused_dry_run), which calls mark_reachable_from_roots, adds the global ledger’s roots and subtracts the result from the installed set.

Project discovery scans explicit_paths plus recursive walks of search_roots, respecting max_search_depth and skipping directory names that match ignore_patterns. Only directories containing an hpm.toml are considered projects.

Python venv cleanup uses the same principle against the metadata.json files in each venv, which list the HPM packages using that venv.

Storage architecture

Files and directories is the reference for the on-disk layout. This section explains how the store is written. Two details of the layout matter below: the store is keyed <slug>@<version>/ with the .exec-modes stamp and .files.json install record beside each tree (the package checksum covers the tree’s contents, so nothing hpm adds may live inside it), and fetch/ is where ArchiveFetcher extracts an archive before install_into_cas copies it into the store.

hpm install routes URL/registry deps through a two-step flow: ArchiveFetcher downloads + extracts into ~/.hpm/fetch/, then StorageManager::install_into_cas copies into the canonical CAS at ~/.hpm/packages/<slug>@<version>/. Path deps skip the fetcher entirely and go straight to ~/.hpm/packages/_dev/<slug>@<version>/ via install_as_dev_copy.

Global packages are shared across projects; each project holds only the per-dependency Houdini manifest and a lockfile. This keeps disk usage sane across a studio’s worth of projects. The Houdini JSON manifests carry absolute CAS paths, so the project tree contains no symlinks pointing into the global storage.

Each per-package manifest is named <creator>.<slug>.json. The creator segment is part of the filename because the slug alone is not unique: two creators may publish the same slug, and keying the file on the slug let the second install silently overwrite the first, so Houdini loaded only one of them. . is the separator rather than - because both segments may themselves contain - (a-b/c and a/b-c would collide), while . is not a legal segment character.

sync_dependencies sweeps stale per-package manifests at the end of every install run: any .json in <project>/.hpm/packages/ whose stem is no longer in the resolved dependency set is removed. Without this, a manifest written by a previous run (e.g. for a path dependency that has since been removed) would keep loading the package on Houdini launch even though hpm.toml no longer asks for it. Manifests written by an older hpm under the bare <slug>.json name are not in the current scheme, so the same sweep clears them on the next install — otherwise the package would load twice, once per filename. Note this makes <project>/.hpm/packages/ an hpm-owned directory: unrecognized .json files placed there by hand do not survive a sync.

Global installs

hpm global writes the same Houdini manifest into Houdini’s per-user preferences directory (hpm_core::houdini_prefs resolves it per platform, honouring HOUDINI_USER_PREF_DIR and its __HVER__ placeholder) instead of into a project. It reuses the whole install path — the same RegistrySet, the same CAS, the same shared venvs, and the same manifest builder (build_houdini_package, a free function precisely so both callers produce byte-identical output).

The one structural difference is directory ownership, and it inverts the sweep described above. <project>/.hpm/packages/ belongs to hpm, so the project installer may delete anything it does not recognise there. Houdini’s user packages/ directory belongs to the user: it holds files written by SideFX, by other tools, and by hand. Applying the sweep there would delete them. So global installs are tracked in a ledger at ~/.hpm/global/houdini-<X.Y>.json, and every operation is driven off it — list reads it, remove deletes exactly the filename it records, and nothing ever scans the directory to decide what to delete.

The ledger is also a GC root. The cleanup plan marks reachability from discovered projects, and a globally installed package belongs to no project; without its ledger entry it is unreferenced by construction, so cleanup would delete the store directory while the manifest in Houdini’s preferences kept pointing at it. An unreadable ledger aborts cleanup rather than being treated as empty — “no global installs” and “cannot tell” must not look the same to a collector.

Compatibility is checked before anything is written. The emitted enable expression is evaluated by Houdini at startup, so a package whose [compat].houdini excludes the target version would install successfully and then load nothing, silently. check_compatible turns that into an install- time error.

Path dependencies install into ~/.hpm/packages/_dev/<slug>@<version>/ rather than the registry CAS at ~/.hpm/packages/<slug>@<version>/. The _dev subtree is invisible to list_installed, so a dev install of foo@1.0.0 cannot be served as the cached install for a registry resolution at the same coordinate from a different project.

_dev/ entries are garbage-collected by a parallel cleanup pass driven directly off project path-dependencies (since the CAS-orphan logic deliberately can’t see them). For each discovered project, dev_needs resolves every { path = "..." } dep’s source manifest to its (slug, version) and unions those into the “needed” set. An entry outside it is collected: a link install is unlinked through remove_install_entry (without traversal); a copy container is reclaimed copy by copy under the users rule (reclaim_dev_copies: a copy a running process or recorded project still uses is kept), and the container itself goes only once empty (remove_empty_container). A still-needed container loses only its superseded copies.

Path deps come in two install styles, selected by the link field on the manifest’s { path = "...", link = ? } spec:

  • Copy (default, link = false): install_as_dev_copy snapshot-copies the workspace’s install image into a content-addressed _dev/<slug>@<version>/<source-hash>/ directory (see below). The image is the file set hpm pack / hpm build would stage for the host platform (dev_copy_image): .gitignore + .hpmignore with ! re-includes, the [stage] include/exclude globs of the release profile, and the host’s [stage.platform.*] place rules, plus hpm.toml always. .git/, build trees and virtualenvs are never copied. The walk is the packer’s collect_stage_entries, shared with pack and build so the three cannot disagree (two files placed at one image path are refused by all three); it skips ignored directories without descending into them, but only when the ignore files have no ! rules, because a ! rule can re-include a file under an ignored directory (the nearest matching rule wins). Subsequent working-tree edits don’t reach the install until the next hpm install.
  • Link (link = true): install_as_dev_link creates a symlink (Unix) or NTFS junction (Windows) at _dev/<slug>@<version>/ pointing at the canonicalized workspace. Edits are live; Houdini’s HPATH resolution follows the link transparently. Junctions on Windows side-step the Developer Mode / admin requirement that NTFS directory symlinks carry, so the workflow is viable on a stock Houdini workstation.

Native-binary packages are the exception: when a link = true path dep declares concrete [compat].platforms (anything other than universal), install_inner downgrades it to a copy — see CompatConfig::declares_native_platforms. A junction/symlink would make the workspace’s build output the very DSO/DLL a running Houdini has memory-mapped, so an in-place rebuild fails (Windows LNK1104 / ERROR_SHARING_VIOLATION), and link-mode buys nothing for native code anyway — a mapped DSO can’t hot-reload into a live session; it needs a relaunch, which re-copies and re-runs prepack. Pure-data / pure-Python / universal-only link installs are unaffected.

Dev copies are content-addressed so a re-sync never clears a directory a running Houdini has mapped. dev_copy_image fingerprints the staged file set (destination path + length + mtime of every staged file, stat-only, so churn in ignored build trees does not force a recopy) and that hash names the install directory: the copy lands at _dev/<slug>@<version>/<source-hash>/, and the generated Houdini manifest points hpath there. install_inner stages the copy into a hidden .stage-<pid>-<n> directory and commits it with an atomic, race-tolerant rename (a concurrent install that loses the race drops its stage, since the content is identical by construction). If the target hash directory is already present and complete, the existing install is reused untouched — the copy-mode analogue of the “already installed” short-circuits the registry/URL specs have in install_one_dep.

The payoff is that a rebuild produces a new hash directory rather than overwriting the old one: a concurrently-running Houdini keeps mapping the directory it was launched from, so install_inner never remove_dir_alls a live copy. Before content addressing, an in-place clear-and-recopy of a package a second session still had mapped failed on Windows with os error 5 / StorageError::PackageInUse; that failure is now structurally impossible on all platforms. At install time only a stale link left by a prior link = true install is cleared (clear_container_link, link-safe); the directory of live hashes is left in place.

A copy is kept while something uses it, and removed once nothing does (storage::dev_users). Each user is a small record beside the copy, under <container>/.users/<hash>/, never inside it, so an embedder that copies the install onwards does not carry the records along:

  • A project, recorded when its Houdini manifest is written with hpath pointing at the copy. The record names the manifest, and counts for as long as that file still points there, so a later sync that repoints the manifest retires it without removing anything.
  • A process, recorded with its PID and the OS’s start time for it (a recycled PID is a different process; process_users). The install records its own process from before the copy exists until the project’s manifest points at it. Embedders record what they run against a project (hold_project_dev_copies for a run they wait on, record_project_process for a detached one), because such a run can outlast the project’s next sync.

Every sync_dependencies ends by reclaiming the containers it installed into (reclaim_dev_copies), and the same package’s other version containers (sibling_containers), removing a version’s container once nothing is left in it (remove_empty_container, non-recursive deletes only, so an install that has just started keeps it). This runs on a blocking thread the sync does not wait for, one reclaim at a time per process. A copy is renamed to a hidden tombstone before it is deleted: on Windows a directory with a file open inside cannot be renamed, so a copy read by a process nobody recorded stays whole. On macOS and Linux nothing blocks the rename, which is why the records, not the OS, are the rule. Just before the move the pass decides again, with the records listed afresh, under the lock holds are taken under: an install in the same process either shows there, or takes its hold after the move, finds no copy and makes a new one. An install in another process shares no lock, so the pass asks once more when the copy is aside, and a claimed copy goes back. A project record matches its copy by the canonical container and the hash, never by resolving the copy, which is not there at that moment. A tombstone left behind (a deletion or a move back that failed) is put back by the next pass when its copy is in use again and its place is free, and deleted otherwise. Anything that cannot be judged (an unreadable record, a process the OS cannot be asked about) keeps the copy. On Windows a record or Houdini package file that reads as missing is read again for a moment before it counts as gone, since Windows can report a file that exists as missing. The same pass removes the .stage-<pid>-<seq> directory a crashed or killed copy left behind, once the process its name records is gone.

Copies made before records existed have none, and that means unknown, not unused. The pass after a sync knows one project only and leaves them (Unrecorded::Keep). hpm clean (cleanup_unused_dev_installs) first records the copies every discovered project’s manifests point at, then removes the unrecorded rest, and removes the container of a version no project depends on once no copy in it is in use. It keeps the copy matching the current source, so an unchanged relaunch does not recopy.

Both install replacement (clear_existing_install) and orphan cleanup (remove_package) are symlink-safe: each checks symlink_metadata (is_link) before choosing between remove_dir_all (real dir) and remove_dev_link (remove_file on Unix; junction::delete plus remove_dir on Windows), via a shared remove_install_entry primitive. Without this, a remove_dir_all on a Windows junction would recurse into and delete the user’s workspace on the next sync or orphan sweep.

Both styles set InstalledPackage::is_dev = true. That flag flows through to build_houdini_package, which forwards it, as an InstallSource, to ManifestEnvEntry::lower. The install_source axis on each conditional [runtime] variant is filtered there: variants gated to "dev" only survive for path-installed packages, variants gated to "registry" only survive for registry/URL installs, and variants with no axis fire in both contexts. A registry-fetched install whose every matching variant is install_source = "dev" produces no entry for that key in the generated package.json, so dev-only paths never leak to a published consumer.

Emission targets Houdini’s actual env semantics, as verified with the hconfig conformance harness (hpm-core/src/houdini_conformance_tests.rs) and modeled executably in hpm-core/src/houdini_env_model.rs: prepend / append values are single-element JSON lists (a flat-string first definition makes a custom variable non-mergeable — every later entry overwrites it, whatever its method), set is emitted as a bare flat string (Houdini has no set method; a list-form replace appends onto a path-registered variable Houdini seeded flat-first, e.g. OCIO, so only a flat string overwrites it cleanly — a genuinely conditional set still falls back to replace since it can’t be flat), and conditional branches are compiled mutually exclusive because Houdini applies every matching conditional-array element, not the first match. Project-level [runtime] entries are written once to ~hpm-project-overrides.json in the project packages dir; Houdini processes package files in byte-wise ascending filename order and ~ sorts after every slug character, so that file always applies last — an override lands exactly once, after (or, for set, replacing) every package contribution.

Python integration

The Python layer runs on four ideas, in descending order of importance:

  1. Content-addressable venvs. Hash the resolved dependency set, use it as the venv directory name. Same hash → same venv → shared across packages.
  2. Bundled uv. HPM runs one pinned uv release, downloaded on first use to ~/.hpm/tools/uv-<version>/ and accepted only when it matches the SHA-256 compiled into HPM for that platform; a version bump installs the new release beside the old directory, and the unversioned ~/.hpm/tools/uv older HPM versions used is removed. Its cache (~/.hpm/uv-cache/), config (~/.hpm/uv-config/), and managed CPython installs (~/.hpm/uv-python/, pinned via UV_PYTHON_INSTALL_DIR) are isolated from any system uv so HPM never perturbs your other Python work. These paths, and the venvs, are under the configured [storage] home_dir (~/.hpm by default); in code the Python subsystem takes it as a python::PythonHome.
  3. Self-bootstrapping Python. uv pip compile and uv venv need an interpreter. Before invoking either, HPM runs uv python install <ver> to ensure a managed CPython matching the project’s Houdini ABI exists. This is what makes a clean Windows install (no system Python anywhere) Just Work — without it pip compile errors with No interpreter found in virtual environments, managed installations, search path, or registry. The ensure step is process-cached, so it costs one fast filesystem probe per resolution.
  4. Houdini manifest generation. For each HPM package that declares Python dependencies, HPM writes <project>/.hpm/packages/{creator}.{slug}.json with PYTHONPATH prepended at the shared venv’s site-packages.

Hash function

ResolvedDependencySet::hash (crates/hpm-core/src/python/types.rs) is a SHA-256 over python:<version> followed by each name:version pair, truncated to 16 hex characters. packages is a BTreeMap, so iteration is sorted without an explicit sort. Only names and versions are hashed; extras are not part of the resolved set.

Houdini→Python mapping

map_houdini_to_python_version (python/collection.rs) holds the table shown in Python environments. It is applied to the lower bound of the root manifest’s [compat].houdini; a dependency’s own range is not consulted. Unsupported versions return an error rather than a fallback. Adding a Houdini major means adding an arm there and updating the table in the user docs.

Generated Houdini manifest

How Houdini loads hpm packages shows the emitted file.

method: "prepend" delegates path-separator handling to Houdini so the same manifest works on Windows (;) and Unix (:) without embedding an OS-specific joiner. The generator is hpm_core::project::houdini_emit::build_houdini_package, a free function shared by the project installer and hpm global so both emit identical manifests.

Security and performance

Security

  • Transport: TLS through rustls (pure Rust, no OpenSSL). Certificate verification against the platform trust store. HTTPS only, or plain HTTP to this machine; redirects never step down to HTTP (http::check_transport).
  • Integrity: the archive is checked against the registry’s SHA-256 when it is downloaded (a missing checksum only warns); the SHA-256 of the installed tree is recorded in hpm.lock, and a sync verifies every package the lock pins, fetched (before it reaches the store) or reused, against it (ProjectManager::sync_dependencies_with_lock).
  • Signing: hpm pack --key signs archives with Ed25519 over PKCS#8 PEM private keys. keyId = first 8 bytes of public key, hex-encoded. See Security for the wire format.
  • Isolation: bundled uv runs out-of-process with its own cache and config, never touching system state.

Performance

  • Concurrent downloads: registry-fronted installs run in parallel, bounded by [install].parallel_downloads (default 8).
  • Content-addressable dedup: both HPM packages (keyed by slug@version in the global CAS) and Python venvs (keyed by resolved-set hash) are deduplicated globally.
  • Cache hits: uv’s cache eliminates wheel re-downloads across projects; HPM’s venv cache eliminates install work when a matching set is found.
  • Atomic filesystem ops: packages are extracted to a temp directory and renamed into place to avoid partial states.

Extension points

Programmatic configuration

The library crates can be used without the CLI. Embedders (desktop apps, pipeline tools) build a Config in-memory by starting from Config::default() and setting the fields they need:

#![allow(unused)]
fn main() {
use hpm_config::{Config, RegistrySourceConfig, RegistryType};

let mut config = Config::default();
config.add_registry(RegistrySourceConfig {
    name: "studio".into(),
    url: "git@git.studio.example:pipeline/hpm-index.git".into(),
    registry_type: RegistryType::Git,
});
config.install.parallel_downloads = std::num::NonZeroUsize::new(4).unwrap();
}

Registry trait

Any type that implements the Registry async trait can be plugged into a RegistrySet and used for resolution. The built-in ApiRegistry and GitRegistry are reference implementations.

For visibility-gated API registries (e.g. private packages an authenticated user is entitled to see), embedders can pass a bearer token through RegistrySet::from_configs_with_auth — the token is attached as Authorization: Bearer <token> on every API-registry request and marked sensitive so reqwest won’t log it. The token is baked into the HTTP client at construction, so callers tracking a refreshing token rebuild the RegistrySet per operation rather than mutating one in place. Git registries currently ignore the token.

ProjectManager mirrors that contract via ProjectManager::new_with_auth(.., Option<String>). The token is stashed on the manager and forwarded to every RegistrySet it builds internally (RegistrySet::for_project, used by sync and by lock resolution), which constructs them through from_configs_with_auth. ProjectManager::new delegates with None, so anonymous use is unchanged. As with the RegistrySet variant, refreshing tokens are handled by rebuilding the ProjectManager per operation.