Reference Python implementation of the Draw Tree Protocol (v0.3) — JSON schema validation, six-state verdict aggregation, and Fibonacci-default branch weighting.
This library is intentionally small and dependency-light. It does not implement Phase 1 / Phase 2 research; it only implements the deterministic parts of the protocol that a compliant server can be checked against.
- Spec: Draw-Tree/drawtree-protocol
- License: MIT
pip install drawtree-validatorOr install from source:
git clone https://github.com/Draw-Tree/drawtree-validator
cd drawtree-validator
pip install -e .from drawtree_validator import validate_tree, aggregate_tree
with open("my_tree.json") as f:
tree = json.load(f)
# 1. Structural validation against the v0.3 JSON Schema.
result = validate_tree(tree)
if not result.is_valid:
for err in result.errors:
print(err)
# 2. Aggregate leaf verdicts into branch and root conviction scores.
agg = aggregate_tree(tree)
print(agg.root_score, agg.root_label)
for b in agg.branches:
print(b.branch_id, b.score, b.label)- It does not generate trees. There is no LLM call here.
- It does not perform deep research, Tavily integration, or any evidence ingestion. Those are server concerns.
- It does not enforce the Phase 1 client contract — that is a client responsibility. See drawtree-skill for the canonical client behaviour rules.
Branch conviction is the weighted mean of leaf verdict scores within the branch (default leaf weight 1.0). Root conviction is the weighted mean of branch scores (default branch weight 1.0, or Fibonacci normalisation if the server chooses to apply the default scheme).
Verdict-to-score mapping (normative per spec §3):
| Verdict | Score |
|---|---|
validated |
1.00 |
trending_positive |
0.75 |
inconclusive |
0.50 |
trending_negative |
0.25 |
approaching_falsification |
0.10 |
falsified |
0.00 |
Unknown or missing verdicts default to 0.50 so unresearched leaves do
not artificially depress a branch's score.
pip install -e ".[dev]"
pytestThis library tracks the protocol's MAJOR.MINOR.PATCH:
- The library's
MAJOR.MINORmatches the protocol spec version it validates against (so0.3.xvalidates v0.3 trees). PATCHincrements are bug fixes and clarifications, never new invariants.