Skip to content

Hinge Package Manager

Status: Active (Phase A-H implemented) Audience: Compiler contributors, package authors, federation operators, AI assistants Purpose: Define the sovereign supply chain architecture for Janus packages


Hinge is Janus’s sovereign package manager — 18K lines of Zig, 25 modules, ~265 tests. It implements a cryptographically verifiable, federated supply chain where trust is computed, not assumed.

Key Properties:

  • Zero external dependencies: Every module imports only const std = @import("std")
  • Standalone reusability: Any module can be extracted and used independently (e.g., by the Libertaria SDK)
  • Location: tools/hinge/ in the Janus repository
  • Principle: The Garden Wall doctrine — “only proven code survives publication”
janus init mylib # Create project with janus.kdl manifest
janus build src/main.jan main # Compile
janus pkg pack # Normalize + archive into .jpk
janus pkg seal # Ed25519 sign the archive
janus pkg publish # DMP gossip announcement + transparency log entry

+-----------------------------------------------------------------------+
| JANUS CLI (main.zig) |
| init | build | pkg pack | pkg seal | pkg publish | pkg resolve |
+-----------------------------------------------------------------------+
| | | |
v v v v
+----------------+ +----------------+ +----------------+ +----------------+
| FOUNDATION | | PACKING | | IDENTITY & | | QUALITY |
| (Phase A) | | (Phase B) | | TRUST (C) | | (Phase D) |
| | | | | | | |
| semver | | packer | | crypto_sign | | proof_cert |
| resolver | | sbom | | identity | | quality_gate |
| lockfile | | cid_verify | | trust_policy | | |
+----------------+ +----------------+ +----------------+ +----------------+
| | | |
v v v v
+----------------+ +----------------+ +----------------------------------+
| TRANSPARENCY | | FEDERATION | | POST-QUANTUM & POLICY (G) |
| (Phase E) | | (Phase F) | | |
| | | | | crypto_dilithium |
| transparency | | chapter | | profile_enforce |
| _log | | witness | | org_policy |
| revocation | | trust_graph | +----------------------------------+
| | | reputation |
| | | dmp_announce | +----------------------------------+
| | | registry | | PERFORMANCE & OBSERVABILITY (H) |
+----------------+ +----------------+ | |
| fetch_pool | resolution_cache |
| ci_mode | json_output |
| cache_mgr | dep_graph |
| audit | |
+----------------------------------+

Core dependency management primitives. These modules form the backbone of every janus build and janus pkg resolve operation.

ModuleFileTestsPurpose
semversemver.zig~30Semantic versioning: parse, compare, range matching (>=1.2.0 <2.0.0)
resolverresolver.zig~25Dependency resolution with backtracking and conflict reporting
lockfilelockfile.zig~15Deterministic lockfile generation and parsing (janus.lock)
mainmain.zigCLI command dispatch and argument parsing

Resolution Algorithm:

┌──────────────────────┐
│ janus.kdl manifest │
└──────────┬───────────┘
│ parse deps
v
┌──────────────────────┐
│ Version Ranges │
│ foo >= 1.2 < 2.0 │
│ bar ^3.1.0 │
└──────────┬───────────┘
│ query registry
v
┌──────────────────────┐
│ Candidate Sets │──┐
│ foo: [1.2.0, 1.3.1]│ │ backtrack
│ bar: [3.1.0, 3.2.0]│ │ on conflict
└──────────┬───────────┘<─┘
│ solve
v
┌──────────────────────┐
│ janus.lock │
│ (pinned versions) │
└──────────────────────┘

Content normalization and archive creation. Transforms a project directory into a reproducible, content-addressed .jpk archive.

ModuleFileTestsPurpose
packerpacker.zig~20Content normalization, .jpk archive creation
sbomsbom.zig~10Software Bill of Materials generation (dependency tree snapshot)
cid_verifycid_verify.zig~15BLAKE3 content-addressed identity verification

Content Identity (CID) Format:

blake3:a7f3b2c1d4e5f6789012345678901234567890123456789012345678901234ab
└─────────────── 64-char hex of BLAKE3 hash ───────────────────┘

The packer normalizes file order, strips timestamps, and produces a deterministic archive. Two identical source trees always produce the same CID, regardless of filesystem metadata.


Cryptographic identity management and trust policy enforcement. Every package author has a sovereign identity; every operation is signed.

ModuleFileTestsPurpose
crypto_signcrypto_sign.zig~20Ed25519 signing and signature verification
identityidentity.zig~15DID:sovereign generation and management
trust_policytrust_policy.zig~12Trust graph configuration and policy enforcement

DID Format:

did:sovereign:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK
│└─────────────── base58btc(ed25519_pubkey) ──┘
└── multibase prefix: 'z' = base58btc

Signing Flow:

// 1. Generate identity
const keypair = try identity.generate();
// DID: did:sovereign:z<base58btc(keypair.public_key)>
// 2. Sign package archive
const signature = try crypto_sign.sign(archive_bytes, keypair.secret_key);
// 3. Verify on consumer side
const valid = try crypto_sign.verify(archive_bytes, signature, author_public_key);

Proof certificates and quality gates. Packages carry embedded evidence that they were tested and meet configurable quality thresholds.

ModuleFileTestsPurpose
proof_certproof_cert.zig~12Proof certificates: test results embedded in packages
quality_gatequality_gate.zig~10Configurable quality gates (coverage, lint, etc.)

The Capsule Standard:

Every publishable package (Capsule) contains three indivisible elements:

  1. The Source — Logic (structs, functions, modules)
  2. The Proof — Test results + Proof Certificate generated by the compiler
  3. The Contract — Capability Manifest (what it touches: FS, Net, etc.)

hinge rejects any publish attempt without a valid Proof Certificate. This is enforced at the protocol level, not by convention.


Append-only transparency log and revocation infrastructure. Every publication creates a Merkle tree entry; every revocation is cryptographically signed.

ModuleFileTestsPurpose
transparency_logtransparency_log.zig~18BLAKE3 Merkle tree, DID-signed checkpoints
revocationrevocation.zig~10Revocation certificates (advisory + critical severity)

Merkle Tree Structure:

┌──────────┐
│ Root CID │ ← DID-signed checkpoint
└────┬─────┘
┌─────┴─────┐
│ │
┌────┴────┐ ┌───┴─────┐
│ H(A|B) │ │ H(C|D) │
└────┬────┘ └────┬────┘
┌─────┴──┐ ┌────┴──┐
│ │ │ │
┌─┴─┐ ┌──┴┐ ┌┴──┐ ┌─┴─┐
│ A │ │ B │ │ C │ │ D │ ← Package publication entries
└───┘ └───┘ └───┘ └───┘

Each leaf contains: package name, version, CID, author DID, timestamp, and signature. Checkpoints are signed by the registry operator’s DID, enabling third-party audit of the entire publication history.

Revocation Severities:

  • advisory — Soft warning, consumer decides whether to continue
  • critical — Hard block, package cannot be resolved until replacement is published

The core of Hinge’s decentralized governance model. No single entity controls the registry. Trust is computed from a graph of cryptographic attestations.

ModuleFileTestsPurpose
chapterchapter.zig~15Chapter formation, N-of-M governance, charter signing
witnesswitness.zig~12Cross-Chapter attestation, consensus evaluation
trust_graphtrust_graph.zig~14BFS trust distance computation, path reconstruction
reputationreputation.zig~12Weighted reputation formula, catastrophic drop detection
dmp_announcedmp_announce.zig~10DMP gossip topic namespace, announcement serialization
registryregistry.zig~15Federated registry queries, result merging, deduplication

Federation Model:

┌─────────────────────────────────────────────────────────┐
│ FEDERATION LAYER │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Chapter │<──>│ Chapter │<──>│ Chapter │ │
│ │ "Core" │ │ "Crypto" │ │ "WebDev" │ │
│ │ 5 members│ │ 3 members│ │ 4 members│ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ │ Witness │ Witness │ │
│ │ Attestations │ Attestations │ │
│ │ │ │ │
│ ┌────v───────────────v───────────────v─────┐ │
│ │ TRUST GRAPH (BFS) │ │
│ │ max_distance: 3 hops │ │
│ │ reputation threshold: 0.4 │ │
│ └────────────────────┬─────────────────────┘ │
│ │ │
│ ┌────────────────────v─────────────────────┐ │
│ │ DMP GOSSIP TRANSPORT │ │
│ │ topics: hinge/announce/<name>/<ver> │ │
│ │ hinge/revoke/<name>/<ver> │ │
│ │ hinge/witness/<chapter>/<cid> │ │
│ └──────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘

Chapter Governance:

A Chapter is a group of 3+ maintainers who form a shared trust unit:

  1. Formation: Founding members sign a charter document with their DIDs
  2. Charter: Defines Chapter DID, governance rules, and domain focus
  3. Admission: N-of-M vote required to add new members (e.g., 3-of-5)
  4. Removal: N-of-M vote required to remove members (higher threshold than admission)
  5. Chapter DID: Derived from the charter hash, not from any single member

Witness Consensus:

When a package is published, Chapters can attest to its quality:

Package "[email protected]" published by did:sovereign:zAlice
├── Chapter "Core" attests ✓ (3/5 members reviewed)
├── Chapter "Crypto" attests ✓ (2/3 members reviewed)
└── Chapter "WebDev" — no attestation
Consensus: K=2 attestations from N=2 distinct Chapters → VERIFIED

Trust Graph (BFS):

Trust distance is computed as the shortest path in the attestation graph:

// BFS from consumer's trusted root to package author
const path = try trust_graph.findShortestPath(
consumer_did, // starting node
author_did, // target node
max_distance, // default: 3 hops
);
// path: [consumer] -> [Chapter "Core"] -> [Chapter "Crypto"] -> [author]
// distance: 3 (within threshold)

Reputation Formula:

score = 0.4 * accuracy + 0.2 * frequency + 0.2 * cross_verify + 0.2 * tenure
ComponentWeightDescription
accuracy0.4Ratio of attestations that proved correct over time
frequency0.2How regularly the entity participates in reviews
cross_verify0.2How often the entity’s attestations are confirmed by other Chapters
tenure0.2Length of active participation in the federation

Catastrophic Drop Detection: If an entity’s accuracy drops below a threshold within a time window (e.g., 3 false attestations in 30 days), the reputation score is immediately halved and a review is triggered.


Forward-looking cryptographic migration and organizational policy enforcement.

ModuleFileTestsPurpose
crypto_dilithiumcrypto_dilithium.zig~12Dilithium3 backend, Ed25519+Dilithium3 hybrid signatures
profile_enforceprofile_enforce.zig~8Profile capability ladder enforcement
org_policyorg_policy.zig~8Organization-level license and capability policies

Hybrid Signature Model:

┌─────────────────────────────────────────────┐
│ SIGNED PACKAGE │
│ │
│ archive_cid: blake3:a7f3b2... │
│ │
│ signatures: │
│ ├── ed25519: <64 bytes> ← Classical │
│ └── dilithium3: <2420 bytes> ← PQ-safe │
│ │
│ Legacy clients verify Ed25519 alone. │
│ PQ-aware clients verify both. │
└─────────────────────────────────────────────┘

Dilithium3 is currently in simulation mode pending PQClean integration. The signature format is fixed; only the backend implementation will change when production-ready PQ libraries are available.

Profile Enforcement:

Packages declare their minimum profile requirement. The resolver rejects dependencies that exceed the consumer’s profile level:

:core package cannot depend on :service package
:service package cannot depend on :sovereign package

This enforces the capability ladder at the supply chain level, not just at compile time.


Production-grade tooling for CI/CD pipelines, caching, visualization, and security auditing.

ModuleFileTestsPurpose
fetch_poolfetch_pool.zig~10Concurrent package fetching with adaptive concurrency
resolution_cacheresolution_cache.zig~8LRU resolution cache, incremental resolution
ci_modeci_mode.zig~6CI/CD environment detection, strict defaults
json_outputjson_output.zig~8Machine-readable JSON output for all commands
cache_mgrcache_mgr.zig~10Content-addressed storage management, LRU pruning
dep_graphdep_graph.zig~8Dependency graph visualization (text tree, DOT, JSON)
auditaudit.zig~10Security audit reports, license scanning, risk assessment

CI Mode Behavior:

When CI=true is detected (or --ci flag is passed):

  • Resolution uses lockfile only (no network queries)
  • All quality gates enforced at maximum strictness
  • JSON output enabled by default
  • Non-zero exit on any warning

Content-Addressed Cache:

~/.janus/cache/
├── objects/
│ ├── blake3/
│ │ ├── a7f3b2c1d4e5... ← raw .jpk archive
│ │ ├── 9d4e8f2a3b1c...
│ │ └── ...
│ └── metadata/
│ ├── a7f3b2c1d4e5.json ← package metadata
│ └── ...
├── resolution/
│ └── lru.db ← resolution cache (LRU eviction)
└── trust/
└── graph.db ← cached trust graph state

The complete journey of a package from creation to consumption:

AUTHOR SIDE CONSUMER SIDE
=========== =============
1. janus init mylib
└── Creates janus.kdl,
src/main.jan, .gitignore
2. Write code, run tests
└── janus test
└── Generates Proof Certificate
3. janus pkg pack
└── Normalize files
└── Create .jpk archive
└── Compute CID (blake3:<hex>)
└── Embed SBOM + Proof Certificate
4. janus pkg seal 5. janus pkg resolve
└── Ed25519 sign archive └── Parse janus.kdl deps
└── Dilithium3 sign (hybrid) └── Query federated registry
└── Attach signatures to .jpk └── Check trust graph distance
└── Verify reputation threshold
5. janus pkg publish └── Generate janus.lock
└── DMP gossip announcement
└── Transparency log entry 6. janus pkg fetch
└── Registry index update └── Download .jpk archives
└── Verify CID integrity
6. Chapter witnesses review └── Verify Ed25519 signature
└── Attest package quality └── Check trust policy
└── Cross-verify with other Chapters └── Validate Proof Certificate
└── Update reputation scores └── Extract to cache

All package identity is derived from content, not from names or URLs:

PropertyValue
Hash FunctionBLAKE3
Formatblake3:<64-char-hex>
InputNormalized archive bytes (deterministic order, no timestamps)
Collision Resistance256-bit (equivalent to SHA-256)
Tree HashingSupported (enables parallel verification of large archives)
Length ExtensionImmune (BLAKE3 is not Merkle-Damgard)
SchemeKey SizeSignature SizePurpose
Ed2551932 bytes64 bytesPrimary signing (classical)
Dilithium31952 bytes2420 bytesPost-quantum transition

Hybrid verification: Both signatures are attached to every package. Legacy clients that do not support Dilithium3 can verify Ed25519 alone and remain functional. PQ-aware clients verify both signatures and reject packages where either fails.

The transparency log is a BLAKE3 Merkle tree with DID-signed checkpoints:

  • Leaf entries: BLAKE3(package_name || version || cid || author_did || timestamp)
  • Internal nodes: BLAKE3(left_child || right_child)
  • Checkpoints: Registry operator signs the root hash with their DID at regular intervals
  • Audit: Any third party can reconstruct the tree and verify checkpoint signatures

Following the Law of Representation: “KDL is for Intent (Humans). JSON is for State (Machines).”

  • janus.kdl — Human-editable manifest with comments, vague versions, readable structure
  • Wire protocol — Canonical JSON (RFC 8785) for registry queries, transparency log entries, and signatures

KDL lacks a canonicalization standard. A single extra space changes the hash. JSON has RFC 8785, ensuring deterministic serialization for cryptographic operations.

  • Performance: BLAKE3 is ~5x faster than SHA-256 on modern CPUs
  • Tree hashing: Native support for parallel hashing of large files
  • No length extension: BLAKE3 is immune to length extension attacks (unlike SHA-256)
  • Consistency: The Janus compiler already uses BLAKE3 for CID computation in the ASTDB
  • Ed25519: Small signatures (64 bytes), fast verification, universally supported
  • Dilithium3: NIST PQC Level 3, safe against quantum computers
  • Hybrid: Transition strategy — if either scheme is broken, the other provides fallback
  • Legacy support: Clients that only understand Ed25519 can still verify packages

Every Hinge module imports only const std = @import("std"). No cross-module dependencies beyond the standard library. This enables:

  • Libertaria SDK reuse: Any module can be extracted into a standalone library
  • Independent testing: Each module has its own test suite with zero setup
  • Auditing: Security review of a single module does not require understanding the entire system
  • Parallel development: Modules can be developed and released independently

Hinge uses federated gossip via DMP topic namespaces instead of a central registry:

  • hinge/announce/<name>/<version> — Package publication announcements
  • hinge/revoke/<name>/<version> — Revocation notices
  • hinge/witness/<chapter>/<cid> — Chapter attestation messages

Any node running DMP can participate in the registry. There is no single point of failure, no single entity that can censor packages, and no corporate gatekeeper.

Trust is mathematical, not political:

  • No curated “official” packages — Reputation scores are computed from verifiable attestation history
  • No “admin” accounts — Chapter governance is N-of-M voting, not single-operator fiat
  • Transparent scoring — The reputation formula is public; anyone can verify any entity’s score
  • Catastrophic accountability — False attestations immediately damage reputation

All Hinge modules follow the Janus allocator discipline:

pub fn init(allocator: std.mem.Allocator) HingeModule {
return .{
.allocator = allocator,
// ...
};
}
pub fn deinit(self: *HingeModule) void {
// Release all owned resources
self.entries.deinit(self.allocator);
}

Rules:

  • All allocations use the caller-provided allocator
  • defer module.deinit() immediately after init()
  • No global state, no ambient allocators
  • Test allocator detects leaks in every test

PathPurpose
tools/hinge/All Hinge source code (25 modules)
tools/hinge/build.zigStandalone build configuration
std/encoding/json/Native SIMD JSON parser (174 tests, RFC 8785)
compiler/libjanus/ledger/kdl_parser.zigKDL manifest parser
std/bridge/dmp_core.zigDMP gossip broker (transport layer)
std/bridge/crypto_bridge.zigBLAKE3, SHA-256, HMAC primitives


TL;DR: Hinge is a federated, cryptographically sovereign package manager. Trust is computed from attestation graphs, not granted by authority. Every package carries its own proof of correctness. Every module stands alone.