Skip to main content

Parser and v3.0 trim-aware validator for CLM (Claude Memory Format)

Project description

tunc-clm (Python)

Parser and v3.0 trim-aware validator for the Claude Memory Format. Pure Python, no runtime dependencies, type-hinted.

pip install tunc-clm
from clm import Document, validate_v3, validate_v3_with_filesystem

doc = Document.parse(open("MANIFESTO.clm").read())
assert str(doc) == open("MANIFESTO.clm").read()  # round-trip byte-identical

report = validate_v3(doc)
print(f"{len(report.errors)} errors, {len(report.warnings)} warnings")

# Filesystem-aware variant cross-checks the sibling archive
report = validate_v3_with_filesystem(doc, base_dir=".")

CLI

clm validate path/to/file.clm

What CLM is for

CLM/3.0 is a write-ahead log for multi-session AI handoff threads. Four axes; this package implements two of them:

  1. Read retrieval — prose summary wins this axis; don't pick CLM for one-shot Q&A.
  2. Write cost — CLM wins by 4.2× at 100 sessions, 12.2× at 500. (See experiments/v3/RESULTS-compounding-cost.md.)
  3. Audit integrity — verbatim preservation, signed deltas. CLM by ritual.
  4. Tooling — parser round-trip + validator. This package implements axes 3 and 4 in Python; the Rust and TypeScript packages do the same.

See the main README for the full positioning, including links to the four review rounds where each marketing claim was iteratively narrowed by @copyleftdev's empirical work.

What this validator checks

Per SPEC.clm validation.posture.v3.0:

  • Header declarations: trim.mode, trim.config, archive.mode, archive.path
  • Trim-config grammar: keys / duplicates / missing values / unknown keys
  • Lifecycle states A/B/C; declared offload via (last X of Y archived) form
  • Sentinel placement (BEFORE entries, not after)
  • Per-entry shape (ROLL.CALL needs · YYYY-MM-DD ·; DREAM.LOG needs | YYYY-MM-DD |); malformed quarantined
  • Cross-doc sentinel symmetry (live ↔ archive)
  • Archive structural check (must contain trim ARCHIVE sections, not just any file)
  • Filesystem-aware variant (state.B → warning, state.C → error)
  • Chained archive validation (warnings propagate from archive into live report)

Mirror of the Rust reference

This package mirrors clm-rs and is paired with clm-js. All three implementations validate the same set of behaviors against the same canonical artifacts (MANIFESTO.clm, SPEC.clm, the experiments/v3/ bench docs). 117 tests across all three.

Known limitations (parity with clm-rs v0.2.0)

Three follow-ups from Codex round-8 review apply equally:

  1. [DECISIONS.ARCHIVE] cross-doc sentinel check is missing (symmetric gap to [ROLL.CALL.ARCHIVE] / [DREAM.LOG.ARCHIVE]).
  2. Malformed lines in decisions.live aren't quarantined (counted toward overflow).
  3. Generator (experiments/v3/gen_50_session.py) emits nonsense metadata for depths ≤ 5.

License

MIT.

Audit thread

CLM is itself an append-only audit-thread format. The thread for MANIFESTO.clm and SPEC.clm is at https://github.com/TUNC-AI/tunc-clm — read it like any CLM file: open, sign, append.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tunc_clm-0.2.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tunc_clm-0.2.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file tunc_clm-0.2.0.tar.gz.

File metadata

  • Download URL: tunc_clm-0.2.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for tunc_clm-0.2.0.tar.gz
Algorithm Hash digest
SHA256 249e7fb6ca8405c92dbf2883a89f7f97bba50431a7fd35b78c74adb5a0196d5a
MD5 211792938dc1846b9be4bbb4e5b0cb80
BLAKE2b-256 e1536d421c06cecd7e758d96e8fb4291dab86fc17cb5d0828a7cbd595a3964e1

See more details on using hashes here.

File details

Details for the file tunc_clm-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tunc_clm-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for tunc_clm-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec3776e22d0e911a104c30411a390c424aaa16e69acc91f91ef828394f426d65
MD5 2227035d4866789a09c0172549506a92
BLAKE2b-256 c6d2c8e5d7a576afc1918d27309dc29df7cbb0701077a779fdf60932d815e28a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page