Repo archived 2026-07-25, read-only; see POST-MORTEM.md. The guidance below is historical.
This repository contains the Tokenese token-native interlingua specification (spec.md, DESIGN.md, CONFORMANCE.md, INTENT.md, GRAMMAR-v0.3.md) and a deterministic Tokenese→English translator + scorer under tools/translator/.
Read this file before making changes. It defines architecture, scope locks, conventions, and how to verify changes.
Repo root: spec + design + conformance + governance docs. Treat as read-mostly.
tools/translator/: Python package (tokenese_translator) + scorer package (tkab). Self-contained, installable with pip install -e ..
tokenese_translator/: base Tokenese→English translator originally built for the Turnfile project. Modules:handles.py— centralized handle lexer (kebab + snake + negation/hedge)parser.py— parse Tokenese transcript to AST nodes (Binding, Statement, ModeSwitch, Repair, PlainBlock, LevelDeclaration, GrammarVersion, Comment, Unparseable)renderer.py— render AST back to natural Englishmisparse.py— misparse-family classifier (dense-line scoped)score.py— pair scoring +_provenance()SHAsreadback.py,validator.py,session.py,lexicon.py,lexer.py,token_count.pycli.py—tokenese-translatecommand (decode + conformance summary;--jsonfor structured output)mcp_server.py— MCP server exposing translator + scorer tools
tkab/: deterministic per-pair scorer for the PRD-027 W1+L1 mini-pilot.checker.py—check_pair(...)classifier (output schematkab-check-1.1)cli.py—tokenese-checkcommandAUDIT_CARD.md— schema, outcome enum, decision orderfixtures/— 10 pair files (5 v0.2 + 5 v0.3)
tests/: 144 tests (as of v0.3.8).test_translator.py(base),test_golden.py,test_grammar_coverage.py,test_tkab.py,test_grammar_v03.py, and feature-specific suites added across v0.3.3 – v0.3.8.
- Scoring-only. Do NOT add English→Tokenese generation. The checker scores; it does not generate or repair.
- No Tokenese clone generation. Fixture
clone_textcontent is hand-authored, not produced by a model. - No Turnfile concepts. This repo is independent of Turnfile (the translator was originally built there; this repo is now its canonical home).
- Report, don't repair (R5.3). Mismatches, misparses, repair events, and source-authority conflicts are reported in the output. Never silently fixed.
- Source is authority (R1.3/R1.5). The clone's
source_textis preserved byte-for-byte in checker output. Clone bindings are never decoded as ground truth.
- Python: stdlib-only where possible. The only required runtime dep is
tiktoken(lexicon audit). The translator package itself is dep-free. - All new features must include tests in
tools/translator/tests/. Naming pattern:test_<feature>.pyor extend an existing file. - Grammar changes: bump
__version__(semver), add a[X.Y.Z]CHANGELOG entry, updateGRAMMAR-v0.3.mdor createGRAMMAR-v<new>.md, and add backward-compatibility tests proving older artifacts still parse. - Spec changes (
spec.md,DESIGN.md,CONFORMANCE.md,INTENT.md): require corresponding scorer updates so the checker stays in sync with the spec.
Before opening any PR, run:
cd tools/translator
pip install -e .
pytest -q
Must show 144 passed minimum as of v0.3.8 (more is fine; fewer means regression). Repo-root tests (test_audit_anthropic.py, test_audit_gemma4.py) add 7 more; intersection check runs in CI.
For grammar changes, also manually verify a v0.2 fixture still classifies correctly:
tokenese-check --pair tools/translator/tkab/fixtures/TKAB-W1.pair.json
Expected: outcome win-conformant.
Commit in logical chunks. Suggested chunking when adding features:
- Lexer / handle infrastructure
- Parser AST nodes
- Renderer
- Misparse detector
- Scorer (checker) logic
- Tests
- Fixtures
- Spec docs
- Branch naming:
tools/<area>for tooling,grammar/v<X.Y.Z>for grammar bumps,spec/<topic>for spec edits,fix/<short-description>for fixes. - PR title: declarative, mentions the spec reference(s) it touches (e.g.,
R6.3,R5.4). - PR body: summary, list of additions/changes, scope-locks-honored statement, pytest tally, link to relevant AUDIT_CARD or GRAMMAR doc.
gh pr edit and some gh pr view --json queries hit a deprecated GraphQL field (repository.pullRequest.projectCards) and fail. Workaround for body updates:
gh api --method PATCH /repos/snapsynapse/tokenese/pulls/<num> --input - <<'JSON'
{"body": "..."}
JSON
Stable enum (do not reorder; checker decision logic depends on iteration order in some tests):
win-conformant
l1-plain-success
fail-unparseable
fail-source-authority-conflict
fail-unsupported-causation # v0.3, step 3.5
fail-illegal-derivation
fail-three-repairs
fail-grammar
fail-misparse
fail-no-plain-exit
fail-mixed-exit
fail-declared-level-mismatch # v0.3, step 4.5
indeterminate
Decision order: see tools/translator/tkab/AUDIT_CARD.md.
Pinned SHAs for spec/design/conformance/intent/handoff/anthropic_costs live in tools/translator/data/source_provenance/SHA256SUMS.txt. _provenance() reads these at scorer-init time. Update SHAs when spec files change.