Progressive Formalization for Markdown using Pydantic and Pytest
Project description
Typedown: The Consensus Modeling Language (CML)
Typedown is a language designed for Literate Modeling. It bridges the gap between the fluidity of human thought (Markdown) and the rigor of engineering (Pydantic + Pytest).
"You don't know it until you model it." — Manifesto
The Trinity
Typedown treats Markdown as a first-class language for Consensus as Code (CaC), built on three pillars:
- Markdown (Interface): Retains nature language expressiveness. It's the habitat for humans and AI.
- Pydantic (Structure): Defines strict data schemas via
modelblocks. - Pytest (Logic): Enforces business rules and constraints via
specblocks.
Why Typedown?
Traditional tools force a binary choice:
- Liquids (Text/Markdown): High fluidity but zero structural integrity. Documentation rots instantly.
- Crystals (Code/JSON/SQL): High integrity but zero flexibility. Hard for humans to browse and for AI to grasp intent.
Typedown is Active Soft Matter. It allows information to "phase transition" from loose notes into solid, validated models within the same document.
Core Features
- Progressive Formalization: Start with a sketch, end with a verified system.
- Triple Resolution: Resolve references
[[ref]]through Hash (L0), Handle (L1), and Logical ID (L2). - Evolution Semantics: Track time using
former(versioning) andderived_from(prototyping). - Context-Aware Scoping: Implicit hierarchy via
config.tdand directory inheritance. - QC Pipeline: Four-layered validation from syntax (Lint) to external facts (Test).
Quick Start
1. Define a Model
Define your schema directly in Markdown using Python:
```model:UserAccount
class UserAccount(BaseModel):
name: str
age: int = Field(..., ge=18)
role: str = "member"
```
2. Declare an Entity
Instantiate data using YAML with smart reference unboxing:
```entity UserAccount: alice
id: "iam/user/alice-v1"
name: "Alice"
age: 30
role: "admin"
```
3. Write a Specification
Add business logic that targets your data:
```spec id=check_roles
@target(type="UserAccount")
def validate_admin(subject: UserAccount):
if subject.role == "admin":
assert subject.age >= 25, "Admins must be senior"
```
CLI Usage
The td tool is your companion for the development loop:
td lint: (L1) Check Markdown syntax and YAML formatting.td check: (L2) Validate entities against Pydantic models.td validate: (L3) Check references and runspecblocks (Internal Logic).td test: (L4) Run external verification (Oracles/APIs).td run <script>: Execute scripts defined in Front Matter.
Installation
Typedown thrives in the uv ecosystem.
# Clone and sync
git clone https://github.com/IndenScale/Typedown.git
cd Typedown
uv sync
# Run help
uv run td --help
# Or use the alias
uv run typedown --help
Documentation
- GEMINI.md: AI Agent Guidance (Start here for AI dev).
- Chinese Documentation: The current primary source of truth.
- Manifesto: Why we built this.
License
MIT © IndenScale
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 typedown-0.2.4.tar.gz.
File metadata
- Download URL: typedown-0.2.4.tar.gz
- Upload date:
- Size: 203.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7666be8851ba864948278e3439726546f0e15b93aae774b3d26d7ec2fee09304
|
|
| MD5 |
23c7b496b7ac2de7f789bcb796a1534e
|
|
| BLAKE2b-256 |
2602b73e79bc83dd7a3363fa2fd8a66284368801b429d6d01330c20e2f1dfa0d
|
Provenance
The following attestation bundles were made for typedown-0.2.4.tar.gz:
Publisher:
publish-pypi.yml on IndenScale/Typedown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typedown-0.2.4.tar.gz -
Subject digest:
7666be8851ba864948278e3439726546f0e15b93aae774b3d26d7ec2fee09304 - Sigstore transparency entry: 788363514
- Sigstore integration time:
-
Permalink:
IndenScale/Typedown@517107703b5a5b83877f295df71f32c91709fe80 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/IndenScale
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@517107703b5a5b83877f295df71f32c91709fe80 -
Trigger Event:
push
-
Statement type:
File details
Details for the file typedown-0.2.4-py3-none-any.whl.
File metadata
- Download URL: typedown-0.2.4-py3-none-any.whl
- Upload date:
- Size: 73.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8efee7c6d5f3a061166b03dc674b67b7103dff9cf27a7a92607749c2c1f13ab8
|
|
| MD5 |
e6c6956c985401bb3fd35768893f9bdd
|
|
| BLAKE2b-256 |
f08f81178ee569b2c800963a67f6f1f0ca3394d12f9333d30986737c7422ccd6
|
Provenance
The following attestation bundles were made for typedown-0.2.4-py3-none-any.whl:
Publisher:
publish-pypi.yml on IndenScale/Typedown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
typedown-0.2.4-py3-none-any.whl -
Subject digest:
8efee7c6d5f3a061166b03dc674b67b7103dff9cf27a7a92607749c2c1f13ab8 - Sigstore transparency entry: 788363515
- Sigstore integration time:
-
Permalink:
IndenScale/Typedown@517107703b5a5b83877f295df71f32c91709fe80 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/IndenScale
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@517107703b5a5b83877f295df71f32c91709fe80 -
Trigger Event:
push
-
Statement type: