Skip to content

File layout

A v1 .tet file is a fixed 32-byte superblock at offset 0, followed (when dataset_count > 0) by a dataset directory blob, an 8-byte-aligned chunk index, and chunk payloads.

Regions at a glance

#RegionStarts atSizeWhen present
1Superblock032 Balways
2Dataset directory328 + dataset_blob_lendataset_count > 0
3Padding40 + dataset_blob_len0–7 Bbytes needed for 8-byte alignment
4Chunk indexchunk_index_offset32 + entry_count × 104dataset_count > 0
5Chunk payloadsper index rowper stored_byte_lenone span per index row

Empty file (dataset_count = 0): regions 2–5 are absent; chunk_index_offset = 32, chunk_index_length = 0; the file may end at byte 32.

Populated file: the reference writer packs payloads after the index, but v1 only requires payload_offset + stored_byte_len ≤ file_len for every row.

Superblock (32 bytes)

OffsetSizeFieldNotes
04magicMust be TETR
44layout_versionMust be 1
84dataset_countNumber of dataset records; 0 = no directory
124flagsBit 1: optional history footer at EOF
168chunk_index_offsetByte offset to chunk index
248chunk_index_lengthLength of chunk index region

Readers must ensure chunk_index_offset + chunk_index_length fits within the file.

Alignment

align8(n) = (n + 7) & !7 — round up to an 8-byte boundary. The chunk index base offset must equal align8(40 + dataset_blob_len) when datasets are present.

When superblock flags & 1, the file ends with a self-describing footer after all chunk payloads:

Region (at EOF)Notes
history_jsonUTF-8 JSON: {"history":[…], "metadata":{…}}
metadata_spillOptional spill for large metadata (> 64 KiB inline budget)
history_json_lenu64 LE
history_versionu32 LE; must be 1
magicASCII THST

The footer carries convert provenance (history rows) and per-dataset axis metadata (dim_names, coords, attrs). See Catalog & datasets.

How regions connect

┌─────────────┐
│ Superblock  │  magic, version, index pointer
├─────────────┤
│  Datasets   │  name, dtype, shape, chunk_shape
├─────────────┤
│ Chunk index │  TIDX header + fixed 104 B rows
├─────────────┤
│  Payloads   │  raw or zstd tensor bytes
├─────────────┤
│ THST footer │  optional history + metadata
└─────────────┘

Each index row's payload_offset selects a byte span in the payload region. Dataset metadata supplies shape, chunk_shape, and dtype for interpreting those bytes.

File health

Use tet verify to check superblock, catalog, index, payload bounds, and footer integrity. See tet verify & repair.

Latka Industries