Evidence-first model lifecycle for AI agents. Every evaluation run becomes a tamper-evident record, and model promotion fails closed until the evidence actually justifies it. No model gets promoted on vibes.
Package & CLI Disambiguation:
hardonian-foundry(hfoundry/foundryCLI) — zero-dependency cryptographic evidence ledger, prompt/tool-schema lockfile,pytestgate plugin, and fail-closed promotion gate (not affiliated with Paradigm Foundryforge, Palantir Foundry, CrowdStrike Foundry, or Azure AI Foundry; usehfoundrywhenever anotherfoundrybinary is onPATH).
AI pipelines treat model promotion as a vibe check: the loss curve looked fine, the demo worked, so the artifact shipped. When a model makes decisions — exception triage, tool calls, money-adjacent judgments — nobody can show what evidence justified deploying it.
Foundry makes that evidence the gate. Dataset validation, preflight safety/licensing/resource checks, hash-chained run records, external head anchoring, M-of-N Ed25519 keyring verification, and a promotion verdict that refuses to say yes without complete, untampered evidence.
Promotion is the interesting output. Missing or invalid evidence blocks it (BLOCKED, exit 2); eligible runs with complete signed evidence produce ALLOWED_REVIEW_REQUIRED (exit 0), where a human still signs off. See the refinery documentation for the full gate specification.
Security: v0.2.0's promotion gate is vulnerable; upgrade to v0.2.1+ / v0.3.0 and reassess its promotion decisions. Legacy v1 signatures are blocked: create a new run, supply or attach an allowed license before signing, then sign, anchor, and promote the new run. A signature binds supplied evidence, not actual model weights, predictor execution, or the truth of a license claim. Detecting ledger rollback requires a trusted external head/checkpoint (--expected-head / refinery anchor). See CHANGELOG.md.
Every command below is cross-platform (ubuntu-latest, windows-latest, macos-latest) and verified offline on every push:
| Command | What it does |
|---|---|
foundry / hfoundry --version / doctor [--verbose] |
Package version and offline environment/extra diagnostics (hfoundry avoids PATH clashes with other Foundry tools) |
foundry init / schema |
Scaffold runnable synthetic projects (classifier, tool-gate, trajectory, reconciliation) and export Draft 2020-12 JSON Schemas |
foundry import --from {promptfoo,inspect-ai,lm-eval,mlflow} |
Convert external eval logs into hash-chained Foundry task directories |
foundry lock / verify-lock |
Cryptographic foundry.lock.json pinning prompts, MCP tool schemas, and task specs (JSON or SARIF 2.1.0) |
foundry weights {inspect,catalog} |
Pure-stdlib .safetensors / .gguf header inspector, pickle RCE blocker, and OSI-permissive RAM fit catalog |
foundry arena / passport |
Head-to-head local contender Elo + critical-FN safety shield + ASCII battle card & dark-mode SVG passport |
foundry interop {unsloth,abliteration,quant-ladder,llama-pack,hf-card} |
Unsloth PEFT/SLSA inspector, abliteration F1-retention gate, GGUF quant ladder, Modelfile, and HF Model Card |
foundry-verify {proofpack,registry,bundle,lockfile} |
Air-gapped standalone verifier supporting keyring quorum, federated orgs/expiry, and --crl revocation |
foundry ship |
One-command pipeline: validate -> scan-pii -> preflight -> run -> sign -> anchor -> promote -> proofpack -> report |
foundry mcp {generate-suite,serve} |
Generate adversarial MCP tool suites or run a read-only JSON-RPC 2.0 governance MCP server |
foundry demo / eval / policy-demo |
Deterministic synthetic reconciliation & tool-policy demonstrations |
foundry refinery validate-dataset / dataset-card |
Integrity, uniqueness, leakage, PII, and SHA-256 dataset cards (--data or --task-spec) |
foundry refinery scan-pii / eval-trajectories / kappa / drift |
Pre-ingestion PII scan, trajectory safety gate, Cohen/Fleiss kappa, and PSI/TVD calibration drift (JSON or SARIF 2.1.0) |
foundry refinery preflight |
Safety, runtime, storage, and licensing checks (--task-spec, --manifest) |
foundry refinery run |
End-to-end evaluation with hash-chained ledger and portable run.json |
foundry refinery inspect <run_id> |
Re-verify run provenance from genesis (plus --expected-head / --expected-count) |
foundry refinery promote <run_id> |
Fail-closed promotion gate with --keyring (M-of-N quorum/revocation) & anchor checks |
foundry refinery attach-license |
Bind SPDX allowlist and data-origin decision into the ledger before signing |
foundry refinery keygen --out <pem> |
Generate an Ed25519 private key (mode 0600 on POSIX, owner-restricted on Windows) |
foundry refinery sign <run_id> |
Verify run.json against seq-1 digest and append v2 Ed25519 signature |
foundry refinery list / diff |
List tracked runs and diff metrics/provenance between runs |
foundry refinery anchor / export-bundle / verify-bundle |
Emit external/WORM head checkpoints and export/verify SHA-256 evidence bundles |
foundry refinery report / compare |
Render JSON/Markdown/HTML/SARIF reports (--compliance-profile) and McNemar + bootstrap comparisons |
foundry refinery proofpack / verify-proofpack |
Build and verify self-contained signed Proofpack v2 contracts (--keyring, --expected-head, --consumers) |
foundry refinery artifact {add,verify,list,attest,verify-attestation} |
Local content-addressed artifact store and SLSA/in-toto build attestations |
foundry provider / provider predict |
Opt-in loopback provider probe & batch JSONL predictions (--preset ollama, vllm, llama-cpp, lmstudio; fails closed to UNAVAILABLE) |
foundry registry {list,promote,register,get,verify} |
Fail-closed SHA-256 model registry & promotion gate requiring --keyring and verified evidence |
| Capability | Foundry | MLflow / W&B | Promptfoo / Inspect AI | Sigstore / SLSA |
|---|---|---|---|---|
| Mutable experiment tracking dashboards | No (immutable append ledger) | Yes | Partial | No |
| Hash-chained evidence & anti-rollback anchoring | Yes (evidence.jsonl / WORM / TSA) |
No | No | Transparency logs only |
| Domain safety & zero-critical-FN promotion gates | Yes (fail-closed exit 2) |
Manual | Metric assertions only | Binary artifact only |
Self-contained signed Proofpack v2 + M-of-N quorum |
Yes (verify-proofpack --keyring) |
No | No | Artifact attestation |
| Imports external eval suites into signed gates | Yes (foundry import) |
Exports UI | Native runner | No |
pip install "hardonian-foundry[signing]"
# Or run zero-setup diagnostics via uv:
uvx hardonian-foundry doctor --verbose
# Or from a local checkout:
git clone https://github.com/Hardonian/Foundry && cd Foundry
python3 -m venv .venv && .venv/bin/pip install ".[signing]"
foundry init my-gate --template classifier
foundry refinery run --task-spec my-gate/spec.json --baseline-predictions my-gate/baseline.jsonl --model-predictions my-gate/model.jsonl --output-root .foundry/runs
foundry refinery promote <run_id> --output-root .foundry/runs # exits 2, by designSource-tree mode without install: PYTHONPATH=src python3 -m hardonian_foundry <command> (or $env:PYTHONPATH="src" on Windows PowerShell).
Python SDK (import hardonian_foundry):
import hardonian_foundry as hf
# Single-call Python CI gate or pytest fixture (`foundry_gate`):
qg = hf.quick_gate(records, labels=["ALLOW_PROPOSAL", "DENY", "ESCALATE_REVIEW"], baseline_fn=base_fn, model_fn=model_fn)
res = hf.evaluate_promotion("<run_id>", output_root=".foundry/runs", keyring="keyring.json")
report = hf.generate_audit_report("<run_id>", output_root=".foundry/runs", fmt="sarif")# 1. Pick an OSI-permissive open-weight model fitting your local RAM/VRAM budget
hfoundry weights catalog --ram-gb 16 --quant q4_k_m
# 2. Inspect binary .safetensors / .gguf headers safely (blocks .pt/.pkl pickle RCE) & emit manifest
hfoundry weights inspect adapter.safetensors --emit-manifest manifest.json
# 3. Pit local candidates head-to-head with Elo + Crit-FN safety shield
hfoundry arena --task-spec my-gate/spec.json --contender qwen3=qwen3.jsonl --contender regex=baseline.jsonl --format card
# 4. Ship signed Proofpack v2, SARIF report, and mint a shareable SVG Model Passport
hfoundry ship --task-spec my-gate/spec.json --baseline-predictions my-gate/baseline.jsonl --model-predictions my-gate/model.jsonl --manifest manifest.json --key-file sign.pem --keyring keyring.json --proofpack-out pack.json --report-out report.sarif.json --report-format sarif
hfoundry passport pack.json --out passport.svg
# 5. Unsloth, uncensored/abliterated, llama.cpp GGUF & Hugging Face Hub interoperability
hfoundry interop unsloth ./my-unsloth-lora/
hfoundry interop abliteration --data my-gate/data.jsonl --base-outputs aligned.jsonl --candidate-outputs abliterated.jsonl --labels ALLOW_PROPOSAL,DENY,ESCALATE_REVIEW
hfoundry interop quant-ladder --task-spec my-gate/spec.json --reference bf16=bf16.jsonl --quant q8_0=q8.jsonl --quant q4_k_m=q4.jsonl --quant-gguf q4_k_m=model-q4_k_m.gguf
hfoundry interop llama-pack model-q4_k_m.gguf --proofpack pack.json --require-promoted --modelfile-out Modelfile
hfoundry interop hf-card pack.json --model-id org/my-sovereign-gate --base-model Qwen/Qwen3-4B --out README.mdOptional extras in pyproject.toml:
.[signing]— Ed25519 signing/verification (cryptography).[dev]— signing +pytest,pytest-cov,ruff,mypy,bandit,build,pillow,pyyaml.[train]— offline LoRA training stack (torch,transformers,peft,accelerate,safetensors).[all]— all optional dependencies
| Case Study | Offline Weights Needed? | What It Demonstrates |
|---|---|---|
| examples/case-study-exception-codes | Optional (committed signed evidence replays offline) | Qwen2.5-Coder-0.5B LoRA vs Settler keyword regex, plus standard, adversarial-noisy, and imbalanced (4% critical) dataset profiles |
| examples/case-study-agent-tool-gate | None (runs in seconds) | Agent tool-call safety (ALLOW_PROPOSAL, DENY, ESCALATE_REVIEW) against prompt injection, path traversal, and argument smuggling |
| examples/case-study-reconciliation-policy | None (runs in seconds) | synthetic_policy.assess_with_suggestion deterministic minor-unit arithmetic overriding untrusted model suggestions |
Replay the committed signed exception-codes evidence chain on any OS without modifying committed run files:
PYTHONPATH=src python3 -m hardonian_foundry.cli refinery inspect run-20261111T031107Z-6a0895d1 --output-root examples/case-study-exception-codes/task/runs
PYTHONPATH=src python3 -m hardonian_foundry.cli refinery promote run-20261111T031107Z-6a0895d1 --output-root examples/case-study-exception-codes/task/runs --keyring examples/case-study-exception-codes/task/keyring.json| Document | Covers |
|---|---|
| docs/architecture.md | Mermaid architecture/sequence diagrams, module boundaries, threat model, task_eval / signing / training_utils contracts |
| docs/refinery.md | Full refinery CLI reference, gate semantics, exit codes, anchoring, Windows/POSIX behavior |
| docs/training.md | Cross-platform preflight, batched CPU LoRA training/eval, model registry config, DPO/RLVR/GPU adapter contracts |
| docs/dataset-card.md | Dataset taxonomies, spurious-shortcut warnings, and consented pilot migration checklist |
| docs/roadmap.md | Long-term product roadmap (v1.0.0 shipped through v2.0 KMS/WORM/agentic/federated proofpacks) |
Read this before building on Foundry:
- Synthetic-first baseline: Built-in fixtures and case studies use synthetic data only. Optional
consented_pilot/redacted_evaltiers inlicensing.pyandevidence.pyrequire explicitgovernance_attestationand remain disallowed by default. - Human review is mandatory:
ALLOWED_REVIEW_REQUIREDcertifies evidence completeness at a verified ledger head—never production accuracy or unattended deployment readiness (review_rate = 1.0,financial_write = false,executed = false). - No production serving or managed cloud KMS/TSA daemon in core package: Foundry provides pluggable
SignerProvider/AnchorSink(WormDirectoryAnchorSink) SPIs, SLSA/in-toto artifact attestations, agentic trajectory &scan_dataset_piigates,cohens_kappa/fleiss_kappa, local SHA-256registry.json, and frozen read-onlyProofpack v2contracts. Live production inference gateways, IAM/SSO services, and vendor-specific cloud KMS/TSA adapters remain external SPI plugins tracked in docs/roadmap.md. - Loopback provider guard: The opt-in
provideradapter defaults to operator-approved loopback origins (optional TLS/bearer env auth requires explicit opt-in), disables redirects/proxies, enforces timeouts/circuit breakers, and never substitutes heuristics on failure (UNAVAILABLE). - Synthetic self-consistency is not pilot accuracy: High synthetic scores (such as
1.000on closed-vocabulary templates) demonstrate structural gate behavior, not real-world generalization. See docs/dataset-card.md.
See CONTRIBUTING.md. Security vulnerabilities: see SECURITY.md — never open public GitHub issues for vulnerabilities or submit credentials/customer data.
Apache-2.0. See LICENSE.
