MCard: Local-first Content Addressable Storage with Content Type Detection
Project description
MCard
MCard is a local-first, content-addressable storage platform with cryptographic integrity, temporal ordering, and a Polynomial Type Runtime (PTR) that orchestrates polyglot execution. It gives teams a verifiable data backbone without sacrificing developer ergonomics or observability.
Highlights
- 🔐 Hash-verifiable storage: SHA-256 hashing, handle registry with history, immutable audit trail output.
- ♻️ Deterministic execution: PTR mediates 8 polyglot runtimes (Python, JavaScript, Rust, C, WASM, Lean, R, Julia).
- 📊 Enterprise ready: Structured logging, CI/CD pipeline, security auditing, 99%+ automated test coverage.
- 🧠 AI-native extensions: GraphRAG engine, optional LLM runtime, and optimized multimodal vision (
moondream). - 🧰 Developer friendly: Rich Python API, TypeScript SDK, BMAD-driven TDD workflow, numerous examples.
- 📐 Algorithm Benchmarks: Sine comparison (Taylor vs Chebyshev) across Python, C, and Rust.
- ⚡ High Performance: Optimized test suite (~37s) with runtime caching and session-scoped fixtures.
For the long-form narrative and chapter roadmap, see docs/Narrative_Roadmap.md. Architectural philosophy is captured in docs/architecture/Monadic_Duality.md.
Quick Start (Python)
git clone https://github.com/xlp0/MCard_TDD.git
cd MCard_TDD
./activate_venv.sh # installs uv & dependencies
uv run pytest -q -m "not slow" # run the fast Python test suite
uv run python -m mcard.ptr.cli run chapters/chapter_01_arithmetic/addition.yaml
Create and retrieve a card:
from mcard import MCard, default_collection
card = MCard("Hello MCard")
hash_value = default_collection.add(card)
retrieved = default_collection.get(hash_value)
print(retrieved.get_content(as_text=True))
Quick Start (JavaScript / WASM)
See mcard-js/README.md for build, testing, and npm publishing instructions for the TypeScript implementation.
Polyglot Runtime Matrix
| Runtime | Status | Notes |
|---|---|---|
| Python | ✅ | Reference implementation, CLM runner |
| JavaScript | ✅ | Node + browser (WASM) + Full RAG Support |
| Rust | ✅ | High-performance adapter & WASM target |
| C | ✅ | Low-level runtime integration |
| WASM | ✅ | Edge and sandbox execution |
| Lean | ⚙️ | Formal verification pipeline (experimental) |
| R | ✅ | Statistical computing runtime |
| Julia | ✅ | High-performance scientific computing |
Project Structure (abridged)
MCard_TDD/
├── mcard/ # Python package (engines, models, PTR)
├── mcard-js/ # TypeScript implementation & npm package
├── chapters/ # CLM specifications (polyglot demos)
├── docs/ # Architecture, PRD, guides, reports
├── scripts/ # Automation & demo scripts
├── tests/ # >450 automated tests
└── requirements.txt / pyproject.toml
Documentation
- Product requirements: docs/prd.md
- Architecture overview: docs/architecture.md
- Monad–Polynomial philosophy: docs/architecture/Monadic_Duality.md
- Narrative roadmap & chapters: docs/Narrative_Roadmap.md
- Logging system: docs/LOGGING_GUIDE.md
- PTR & CLM reference: docs/CLM_Language_Specification.md, docs/PCard%20Architecture.md
- Reports & execution summaries: docs/reports/
Recent Updates (December 2025)
CLM Test Infrastructure Improvements
- Execution Timing: Added timing logs to
run-all-clms.tsto identify slow CLMs. - Floating-Point Tolerance: Numeric comparisons now use configurable tolerance (1e-6) for floating-point precision.
- Input Context Handling: Introduced
__input_content__key to preserve originalgivenvalues when mergingwhenblocks.
Runtime Fixes
- JavaScript Runtime: Changed
runtime: nodetoruntime: javascriptacross CLMs; updated code to usetargetvariable. - Python Input Parsing: All Python implementations now handle
bytes,str, anddictinputs with robust parsing. - Lambda Calculus: Fixed parser to correctly handle parenthesized applications like
(\\x.x) y. - Orchestrator: Fixed
run_clm_backgroundto strip file extensions for proper filter matching.
Chapter-Specific Fixes
- chapter_01_arithmetic: All 32 CLMs passing (Python, JavaScript, Lean, multi-runtime).
- chapter_03_llm: Replaced LLM-dependent logic with mock implementations for test stability.
- chapter_05_reflection: Fixed meta-interpreter and module syntax CLMs.
- chapter_06_lambda: Fixed beta reduction and Church numerals parsers.
- chapter_07_network: Updated expected outputs and runtime configurations.
Testing
Note: All commands below should be run from the project root (
MCard_TDD/).
# Python Suite
uv run pytest -q # Run all tests (~37s)
uv run pytest -q -m "not slow" # Run fast tests only (~34s)
uv run pytest -m "not network" # Skip tests requiring LLM/Ollama
# CLM Verification (Python)
uv run python scripts/run_all_clms.py
# JavaScript Suite
npm --prefix mcard-js test
# CLM Verification (JavaScript)
npm --prefix mcard-js run clm:all
Contributing
- Fork the repository and create a feature branch.
- Run the tests (
uv run pytest,npm testinmcard-js). - Submit a pull request describing your change and tests.
We follow the BMAD (Red/Green/Refactor) loop – see BMAD_GUIDE.md.
License
This project is licensed under the MIT License – see LICENSE.
For release notes, check CHANGELOG.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcard-0.1.27.tar.gz.
File metadata
- Download URL: mcard-0.1.27.tar.gz
- Upload date:
- Size: 200.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c5d5e9382fb96eccdb532e6ccbb54ad724f6ea104cc19aa1f63f020549a08ce
|
|
| MD5 |
49a6b49068a0168999cfac389284496b
|
|
| BLAKE2b-256 |
bbf3f3bc45731ed067f100e4028fc3996f3d9972a729e20bf025689c8235861a
|
File details
Details for the file mcard-0.1.27-py3-none-any.whl.
File metadata
- Download URL: mcard-0.1.27-py3-none-any.whl
- Upload date:
- Size: 243.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08377e0c9842f9016c74811df5f69546424e4b5a3eb1c15c2c1f5c2dc444bb39
|
|
| MD5 |
1ca09621014a48be3ed89eda622accad
|
|
| BLAKE2b-256 |
2ba872ed9a416caf0a4ffc65f08432229376ade41e45f12cdecb915e7d53dbf6
|