HRCP¶
Hierarchical Resource Configuration with Provenance
-
Hierarchical
Build tree structures that mirror your organization, infrastructure, or domain model.
-
Inheritance
Set defaults at the top, override at any level. Values cascade naturally.
-
Aggregation
Roll up values from children. Collect metrics, sum headcounts, gather configs.
-
Provenance
Always know where a value came from. Debug config issues in seconds.
The Problem¶
Configuration in hierarchical systems (orgs → teams → projects, regions → clusters → services) needs:
- Inheritance: Set defaults at the top, override below
- Aggregation: Roll up values from children
- Traceability: Know exactly which node provided each value
HRCP solves this with ~1000 lines of dependency-free Python.
Quick Example¶
from hrcp import ResourceTree, PropagationMode, get_value
# Build a hierarchy
tree = ResourceTree(root_name="platform")
tree.root.set_attribute("timeout", 30)
tree.root.set_attribute("env", "prod")
tree.create("/platform/us-east/api", attributes={"timeout": 60})
tree.create("/platform/us-east/db")
# Inheritance: values flow DOWN
api = tree.get("/platform/us-east/api")
timeout = get_value(api, "timeout", PropagationMode.INHERIT)
# timeout == 60 (local override)
db = tree.get("/platform/us-east/db")
timeout = get_value(db, "timeout", PropagationMode.INHERIT)
# timeout == 30 (inherited from root)
Why HRCP?¶
| Feature | HRCP | Flat Config | Environment Variables |
|---|---|---|---|
| Hierarchical inheritance | ✅ | ❌ | ❌ |
| Value aggregation | ✅ | ❌ | ❌ |
| Provenance tracking | ✅ | ❌ | ❌ |
| Zero dependencies | ✅ | Varies | ✅ |
Installation¶
Ready to dive in? Check out the Quick Start guide.