ADR Ledger β Architectural Decision Record Ledger
    
Computable registry of architectural decisions. Each ADR is versioned in Git, cryptographically signed, validated against a strict schema, evaluated by OPA policy, and exported as JSON for AI agent consumption and programmatic governance enforcement.
Beta β The project has reached Beta. The cryptographic blockchain layer, advanced CLI, OPA policy validation, Temporal Anchoring (OpenTimestamps), Bitcoin-compatible secp256k1 receipts, SBOM governance, and 80+ MCP tools are operational in the Nix environment. Cross-platform non-Nix support is currently in progress.
Why it existsβ
Architectural decisions tend to scatter β Notion, Slack, the memory of whoever was in the room. When someone asks "why NixOS?", the answer is reconstructed from fragments, if at all.
This project can enhance the quality from the model languages training and promisse a better experience for organizations and individual developers.
ADR Ledger treats decisions as structured data: YAML frontmatter for machines, Markdown for humans, Git as an audit trail, and cryptographic chains for immutability. Five autonomous agents consume this knowledge:
| Agent | Function | Consumes |
|---|---|---|
| CEREBRO | RAG Retrieval & Knowledge Vault | knowledge_base.json |
| SPECTRE | Pattern & Sentiment Analysis (NLP) | spectre_corpus.json |
| PHANTOM | ML Classification & Sanitization | phantom_training.json |
| NEUTRON | Declarative Infra & Compliance | ADR compliance tags |
| IntelSense | Security Ops & Intelligence (OSINT) | Security tagged ADRs |
The result: decisions that are traceable, versioned, cryptographically verifiable, and queryable by both humans and machines.
Architectureβ
adr-ledger/
βββ .schema/ # JSON Schema for strict validation
βββ .governance/ # Governance as code (roles, approval matrix)
βββ .parsers/ # AST Parser (Python 3.13)
βββ .chain/ # Cryptographic Governance Layer
βββ .hooks/ # Git hooks (Pre-commit, Post-commit)
βββ adr/ # ADRs by lifecycle status (proposed/accepted/etc)
βββ agents/ # Agent environment and local handlers
βββ chain/ # Core blockchain logic (Rust & Python)
βββ crates/ # Rust crates (ledger-subscriber, etc)
βββ docs/ # Comprehensive documentation & guides
βββ knowledge/ # Generated artifacts for Agent Ingestion
βββ nix/ # NixOS modules and flake components
βββ policies/ # OPA/Rego governance policies
βββ scripts/ # Operational CLI and utilities
βββ tests/ # Smoke tests and validation suites
Core Agentsβ
The ADR Ledger serves as the primary source of truth for the following specialized agents:
- CEREBRO (RAG Retrieval): Consumes
knowledge_base.jsonto provide accurate, source-backed answers about system architecture and past decisions. - SPECTRE (NLP Analysis): Analyzes
spectre_corpus.jsonfor pattern detection, sentiment analysis, and architectural drift. - PHANTOM (Sanitization): Uses
phantom_training.jsonto classify documents and ensure sensitive data is sanitized before synchronization. - NEUTRON (Infrastructure): Integrates directly with NixOS modules to enforce architectural constraints (e.g., mandatory disk encryption) declaratively.
- IntelSense (Security Ops): Monitors security-tagged ADRs to provide threat intelligence and compliance alerts.
For deep dive into agent interactions, see docs/AGENT_INTEGRATION.md.
SecureLLM-MCP Integrationβ
ADR Ledger is the foundational knowledge layer for the SecureLLM-MCP ecosystem. It provides over 80+ native MCP tools enabling autonomous agents to interact with the system architecture deeply and securely:
- Provider & API Management: LLM connectivity testing, TLS generation.
- Emergency Framework: CPU/Memory/SWAP rescue operations, thermal protection.
- Laptop Defense Framework: Thermal forensics, rebuild safety checks.
- Code Analysis: Deep AST debugging, complexity metrics, dead code detection.
- Browser Automation: Web research, scraping, form interaction.
- Secure Execution: Ephemeral Nix sandboxes for safe command execution.
Agents can natively query the ADR Ledger, validate new proposals against existing knowledge_base.json, and enforce rules during CI/CD.
Quick Startβ
NixOS / Nix (Recommended)β
git clone https://github.com/marcosfpina/adr-ledger.git
cd adr-ledger
nix develop # enters devShell, provisions Python, hooks, and deps
adr list
adr list --delivery-status completed
adr new -t "My Decision" -p CEREBRO -c major
adr validate
adr policy-check
adr bitcoin list
adr sync
Linux (non-Nix)β
Requires: bash, python3.13, pyyaml, pynacl, jsonschema, git, opa, openssl.
git clone https://github.com/marcosfpina/adr-ledger.git
cd adr-ledger
# Install Python deps
pip install pyyaml pynacl jsonschema
# Install CLI and git hooks
bash scripts/install.sh
# Usage
adr list
adr new -t "Adopt Redis" -p SPECTRE -c major
bash scripts/opa-validate.sh
./scripts/phantom-scan-check.sh .
adr sync
Validation Pipelineβ
The default validator is now layered:
scripts/validate_adr.pymerges YAML frontmatter with Markdown sections and validates against.schema/adr.schema.json.scripts/opa-validate.shevaluates each ADR throughpolicies/adr/validation.rego..chain/bitcoin_attestation.pyverifies local secp256k1 snapshot receipts under.chain/bitcoin/receipts/.
The main entrypoints are:
adr validate
adr policy-check
adr bitcoin verify-all
Implementation details and tradeoffs are documented in docs/VALIDATION.md.
Workflowβ
Scenario 1: New Decision & Cryptographic Pre-Signingβ
# Propose a new architecture change
$ adr new -t "Add Redis for API Caching" -p SPECTRE -c critical
# Critical ADRs require multi-sig (e.g., Architect + Security Lead)
$ adr pre-sign ADR-0042
# Generates a pending signature block in .chain/pending_signatures/
# After all required approvals, accept the ADR into the ledger
$ adr accept ADR-0042
# Sync agents, rebuild the Merkle tree, and check SBOM drift
$ adr sync
Scenario 2: Temporal Anchoring (OpenTimestamps)β
# Anchor the current blockchain state to the Bitcoin blockchain for immutable proof
$ adr anchor
# Output: Creating OpenTimestamps proof for chain height 42...
Scenario 3: Policy Validation (OPA)β
# Evaluate ADRs against the local governance policy bundle
$ adr policy-check
# Output: hard denies fail the command, soft warnings are printed per ADR.
Scenario 4: Bitcoin-compatible Snapshot Receiptβ
# Generate local secp256k1 key material for attestations
$ adr bitcoin keygen --name kernelcore
# Sign the latest snapshot receipt
$ adr bitcoin attest --signer kernelcore
# Verify every receipt currently stored
$ adr bitcoin verify-all
Scenario 5: Supply Chain Governance (SBOM)β
# Check if current flake.lock dependencies drift from the accepted ADRs
$ adr sbom
# Output: Validating CycloneDX 1.6 SBOM... No drift detected.
CLI Referenceβ
# Core Operations
adr new # Create new ADR
adr list # List ADRs by status/project
adr show # Show ADR details
adr accept # Accept proposed ADR (triggers blockchain state transition)
adr supersede # Mark as superseded and link bidirectional graph
adr search # Semantic and full-text search
adr validate # Validate schema, OPA policy, and cryptographic health report
adr policy-check # Evaluate OPA/Rego governance policy only
adr sync # Sync knowledge base, generate JSON artifacts
# Export & Visualization
adr export # Export as JSON/JSONL (RAG-optimized streaming)
adr graph # Generate Mermaid graph
adr viz # Generate visual knowledge graph (dot/svg/html)
adr-phantom-scan # Run Phantom-backed leak scan with allowlist enforcement
# Cryptographic Governance (.chain)
adr sbom # Supply chain SBOM & dependency inventory
adr anchor # Temporal anchoring (OpenTimestamps proofs)
adr pre-sign # Pre-sign an ADR (Multi-sig setup)
adr pending-sigs # Manage and view pending signatures
adr bitcoin # Bitcoin-compatible secp256k1 attestation helpers
Governance as Codeβ
Governance is automated, not a manual process. Defined in .governance/governance.yaml:
Compliance Automationβ
The system uses Git hooks (Pre-commit/Post-commit) to enforce:
- Approval Matrix:
criticalrequires 2 signatures (Architect + Security Lead). - Compliance Triggers: ADRs modifying
datalayers automatically require theLGPDtag. - Supply Chain Drift:
post-commitverifies if new Nix flake inputs map to an accepted ADR. - Integrity: Validates the private blockchain Merkle root against tampered markdown files.
compliance:
lgpd:
trigger_keywords: ["PII", "personal data", "user data"]
required_tags: ["LGPD"]
required_sections: ["data_retention"]
required_reviewer_role: "security_lead"
chain:
require_signatures: true
merkle_tree:
enabled: true
supply_chain:
drift_detection:
enabled: true
check_on_commit: true
ADR Schemaβ
Each ADR is validated against .schema/adr.schema.json:
---
id: "ADR-0042"
title: "Decision Title"
status: accepted # proposed | accepted | rejected | deprecated | superseded
date: "2026-02-15"
authors:
- name: "Pina"
role: "Security Engineer"
governance:
classification: "major" # critical | major | minor | patch
compliance_tags: ["SECURITY", "INFRA"]
scope:
projects: [IntelSense, NEUTRON, INTELAGENT]
layers: [infrastructure, security, application]
environments: [production]
delivery:
status: completed # planned | in_progress | completed | blocked | deferred | cancelled
completed_at: "2026-04-01"
evidence:
- "crates/core/tests/phantom_worker.rs"
- "docs/release-checklist.md"
knowledge_extraction:
keywords: ["OSINT", "spider-nix"]
concepts: ["Threat Intelligence"]
questions_answered:
- "How do we gather external threat feeds?"
---
## Context
...
Roadmapβ
v0.1.0 β Beta Release (Current)β
- JSON Schema, AST Parser, Advanced CLI
- Pre-commit & Post-commit Git hooks integration
- JSON/JSONL streaming export with deep filtering
- Cryptographic private blockchain layer (Provenance + Immutability)
- Ed25519 Cryptographic signing & Multi-sig (
pre-sign) - Temporal Anchoring via OpenTimestamps
- Supply Chain drift detection (SBOM Governance)
- 80+ MCP tools for SecureLLM-MCP Integration
- CI/CD (GitHub Actions + Phantom secret scan wrapper)
Phase 3: Security & Ecosystem Integrationβ
NixOS moduleβservices.adr-ledger.enable = true- Integration with GitHub Teams as the source of truth for IAM roles
- Standalone Binary Packaging (Linux x86_64,
.deb,.rpm) - Package submission to official
nixpkgs(unstablechannel) nix-darwin+ Home Manager for declarative macOS
Phase 4: Full Automationβ
- Automatic ADR generation from Git commits (Detection Engine)
- Predictive impact analysis using
SPECTRE - Decentralized multi-repo federation (ADR-0049)
Contributingβ
Areas of interest:
- Parsers: Support for other formats (MADR, Y-statements)
- Validators: New compliance frameworks (HIPAA, PCI-DSS)
- Visualizations: Advanced interactive graph layouts
Licenseβ
Apache 2.0 β see LICENSE.
Additional documentation:
- Architecture β Design principles and detailed vision
- Daemon Integration β NixOS modules, agent users, and SecureLLM-MCP backend model
- Export Guide β Complete export documentation
- Release Roadmap β Publication plan for the next public release
- Platforms β Setup on NixOS, Linux, macOS, and Windows
- Contributing β Setup and contribution guide