Skip to main content

Path Format Descriptors

Built-in file format descriptors (HDF5, CAX, JSON, NPY, NPZ, CSV) for the vcti-path-format identification framework

Overview

vcti-path-format-descriptors ships ready-made FormatDescriptor instances for the file formats VCTI tooling needs to recognize: HDF5, VCollab CAX, JSON, NumPy NPY/NPZ, and CSV. Each descriptor is built by a factory function that wires a file-only precondition and the appropriate magic-byte and/or extension validators onto a HeuristicEvaluator, tags the result with attributes from the shared vocabulary (vcti-path-format-attributes), and returns it for registration with a FormatRegistry. Applications register the descriptors they need (or all of them at once) and let FormatIdentifier do the identification.

Installation

pip install "vcti-path-format-descriptors>=2.0.1"

In pyproject.toml dependencies

dependencies = [
    "vcti-path-format-descriptors>=2.0.1",
]

Quick Start

from pathlib import Path

from vcti.pathformat.core import FormatIdentifier, FormatRegistry
from vcti.pathformat.descriptors import HDF5_SIGNATURE, register_all_formats

# Register all built-in format descriptors
registry = FormatRegistry()
register_all_formats(registry)

# Identify a file
path = Path("data.h5")
path.write_bytes(HDF5_SIGNATURE + b"\x00" * 64)

identifier = FormatIdentifier(registry)
best = identifier.get_best_match(path)
print(best.id if best else "unknown")  # hdf5-file

for result in identifier.identify_file_format(path)[:2]:
    print(result.descriptor.id, result.confidence.name)

Fast identification at ingest

When every incoming file is identified before it is stored, run only the cheap checks (a few bytes and the name) and leave deeper checks, and integrity, to a later pass or to the format's reader:

from vcti.pathformat.core import MatchConfidence, ValidationTier
from vcti.pathformat.descriptors import __version__ as descriptors_version

# Results are ranked, so the first is the best; keep its confidence too.
top = identifier.identify_file_format(path, max_tier=ValidationTier.IDENTIFICATION)[0]
matched = top.confidence.value >= MatchConfidence.LIKELY.value
record = {
    "format": top.descriptor.id if matched else None,
    "confidence": top.confidence.name,
    "tier": ValidationTier.IDENTIFICATION.name,
    "descriptors_version": descriptors_version,
}
print(record)  # {'format': 'hdf5-file', 'confidence': 'DEFINITE', 'tier': 'IDENTIFICATION', ...}

# Later, a refinement pass can run every tier. CANT_EVALUATE means "no
# evidence yet" (keep the earlier answer); CERTAINLY_NOT means "evidence
# against".
refined = identifier.identify_file_format(path)[0]
assert refined.confidence is MatchConfidence.DEFINITE

See docs/design.md (Identify fast, refine later) for what each format reads at each tier and what the results mean.

Individual descriptors

from vcti.pathformat.core import FormatRegistry
from vcti.pathformat.descriptors import (
    get_csv_file_descriptor,
    get_hdf5_file_descriptor,
)

registry = FormatRegistry()
registry.register(get_hdf5_file_descriptor())
registry.register(get_csv_file_descriptor())

Each factory returns a new descriptor on every call, so a descriptor can be registered in several registries or adjusted without affecting others.


API

Name Kind Purpose
register_all_formats(registry) function Register all six built-in descriptors, or none if any ID is taken
get_<format>_file_descriptor() function Build one descriptor (hdf5, cax, json, npy, npz, csv)
<FORMAT>_FILE_FORMAT_DESCRIPTOR_ID constant The descriptor's registry ID
HDF5_SIGNATURE, CAX_FILE_SIGNATURE, NPY_SIGNATURE, NPZ_SIGNATURE, NPZ_EMPTY_SIGNATURE constant Magic-byte signatures, as bytes
HDF5_SUPERBLOCK_OFFSETS constant Offsets at which the HDF5 signature is accepted
NpzMembersValidator class STRUCTURE-tier GATE: every ZIP member is an .npy file
GENERATOR_APPLICATION constant The CAX descriptor's generator attribute value

Built-in Formats

Every descriptor first requires a regular file (a PathKind.FILE precondition), so a directory is ruled out before any file is read.

ID Signature Extensions Best confidence Attributes
hdf5-file \x89HDF\r\n\x1a\n at offset 0, 512, 1024, 2048, … .h5, .hdf5 DEFINITE structure=hdf5
vcti-cax \x89VCF\r\n\x1a\n — DEFINITE structure=binary, generator=VCollab, content=[4 values]
json-file — (text format) .json LIKELY structure=json
npy-file \x93NUMPY .npy DEFINITE structure=binary
npz-file PK\x03\x04, or PK\x05\x06 for an empty archive; members all .npy .npz DEFINITE structure=binary
csv-file — (text format) .csv LIKELY structure=csv

How the validators combine:

  • Signature and extension both match — DEFINITE.
  • Signature matches, extension does not (a renamed file) — LIKELY, so get_best_match() still finds it.
  • Signature does not match — CERTAINLY_NOT, whatever the extension.
  • Text formats (JSON, CSV) have no signature; the extension alone gives LIKELY, and the content is not inspected. They have priority=-1, so when a renamed binary file is LIKELY for both its own format and a text format, its own format ranks first.
  • Extensions are compared case-insensitively.

An HDF5 file may start with a user block, so the signature is accepted at any offset the HDF5 specification allows. A MATLAB v7.3 .mat file, which is HDF5 behind a 512-byte header, is therefore LIKELY as HDF5.

The NPZ signature is a generic ZIP signature. At the STRUCTURE tier, the NPZ descriptor also lists the archive's members (reading only the ZIP central directory) and rules out an archive with any member that is not an .npy file. A caller that passes max_tier=ValidationTier.IDENTIFICATION skips that check and relies on the signature and the .npz extension.


Dependencies

Documentation

If you want to… Read
Get started using the package Quick Start above
Understand where identification sits in the file lifecycle, and how to identify fast and refine later docs/design.md (Identify fast, refine later)
Understand the design decisions docs/design.md
Navigate and understand the source docs/source-guide.md
Add a new format descriptor docs/extending.md

Metadata

Release files for vcti-path-format-descriptors 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcti-path-format-descriptors 2.0.1
File Size Uploaded Provenance Actions
vcti_path_format_descriptors-2.0.1.tar.gz 26.1 kB With provenance Details for vcti_path_format_descriptors-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vcti-path-format-descriptors 2.0.1
File Interpreter ABI Platform Actions
vcti_path_format_descriptors-2.0.1-py3-none-any.whl Python 3 none any Details for vcti_path_format_descriptors-2.0.1-py3-none-any.whl

Total release size: 40.0 kB

Release files / vcti_path_format_descriptors-2.0.1.tar.gz

Download URL vcti_path_format_descriptors-2.0.1.tar.gz
Size 26.1 kB
Tags Source
SHA-256 checksum
How to use checksums
035aa0c743b6541fff1883786415abf42d5957c7d1f1674f4da919c35da7fb09
BLAKE2b-256 checksum
How to use checksums
1a4d3da6e7b3c2029893b884b61ea2269ba4148d4fc95f103824861d20330f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / vcti_path_format_descriptors-2.0.1-py3-none-any.whl

Download URL vcti_path_format_descriptors-2.0.1-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c8bf1e80eae47d24673fb7fe27746c9493373222918bd99819469cbaa6338f0
BLAKE2b-256 checksum
How to use checksums
4a2f9e9cd1939c7d55ba2732e4f1a371efbb690c4c21bf28f7728a1f8c5cf2bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for vcti-path-format-descriptors 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vcti_path_format_descriptors-2.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page