0314.
Dual-Read .tn Source and Canonical Terse UTF-8
Surface
- Status: Accepted
- Date: 2026-11-28
- Plan: M26.1
- Amends: 0268
Context
ADR-0268
established versioned compact source (~1) as Tenon's
sole .tn authoring and interchange representation,
causing the compiler loader to reject ordinary UTF-8
.tn files with E0120. While
~1 (and generated ~1g) remains compact
and well-suited for generated companions and existing corpus
files, requiring every authoring and editing flow to read or
round-trip ~1 adds friction compared to clean, terse
UTF-8 Tenon source.
Decision
- Dual-Read
.tnLoader: Keep the.tnextension and inspect the file header on load. Files starting with~1or~1gcontinue to decode through the compact codec; ordinary UTF-8.tnfiles parse directly through the ordinary parser without triggeringE0120. - Canonical Terse UTF-8 Formatter
(
tenon fmt,tenon write): Ordinary UTF-8.tnfiles format idempotently as canonical terse UTF-8 Tenon. Existing~1files preserve~1formatting by default unless explicitly converted via--utf8ortenon fmt --migrate-utf8 <paths...>. Generated~1gfiles are never rewritten by migration. - Unified Tooling Surface:
tenon view,tenon outline,tenon edit, andtenon hashesoperate seamlessly on both UTF-8.tnand~1.tnfiles, yielding identical ASTs and semantic item hashes regardless of surface encoding. - Atomic Corpus Migration Script: Provide
scripts/migrate_utf8_corpus.shto atomically convert non-generated~1.tnfiles in a target tree to canonical UTF-8 Tenon while verifying byte-identical item hashes and lossless AST round-trips. Existing trackedplugins/**/*.tnandexamples/**/*.tnremain~1until a dedicated corpus migration step.
Consequences
- Supersedes ADR-0268's compact-only loader rule while
preserving full dual-read compatibility with all existing
~1and~1gsources and tooling. - Semantics are unchanged: both surfaces lower to the exact same
AST, typed IR, and C /
tenon interpbehavior. - Diagnostic code
E0120is retired from the normal.tnload path without renumbering any existing codes indocs/spec/diagnostics.md. docs/spec/LANGUAGE.mdanddocs/spec/diagnostics.mdupdate as slices land while staying strictly within the enforced 6250-token spec budget.