Skip to main content

Crystalia Collector

Generate dataset descriptors for large S3-hosted datasets as RDF annotations.

For architecture, extensibility, and infrastructure details see docs/architecture.md.

Installation

uv sync

Usage

# List files in an S3 prefix
crystalia-collector list my-bucket/path/to/data

# List and generate task files for parallel processing
crystalia-collector list my-bucket/path/to/data --task-dir ./tasks --method-id md5-8gb

# Compute checksum for a single S3 object
crystalia-collector checksum s3://my-bucket/path/to/file.gz

# Compute checksum for a byte range
crystalia-collector checksum s3://my-bucket/path/to/file.gz --offset 0 --length 8589934592

# Process a task file and generate RDF annotations
crystalia-collector annotate tasks/task_1 --output-file annotations.rdf

# Combine per-item Turtle files into one catalog
crystalia-collector combine ./annotations -o catalog.ttl

# Local end-to-end run (list, hash, combine); fail-closed
crystalia-collector run /abs/path/data -o catalog.ttl --method md5-8gb --partials-dir ./partials

# Merge annotate partitions into one catalog with one harvest record
crystalia-collector merge tasks/listing_manifest.json out1.ttl out2.ttl -o catalog.ttl --root s3://my-bucket/path

Operator procedures (failure policy, patch-up, merge): docs/runbook.md.

Checksum Methods

Method ID Block Size Description
md5 Unbounded MD5 of the entire file
md5-2gb 2 GB MD5 in 2 GB blocks
md5-8gb 8 GB MD5 in 8 GB blocks (default)

Block-based methods split large files into offset/length pairs in task files, enabling parallel checksum computation.

Output format

Every descriptor's IRI is content-addressed and minted by crystalia-data-model (the DM), the single source of identity for the RDF output. Two descriptors of the same type and value are the same IRI, regardless of which file or run produced them.

Two CURIE namespaces, split by role: cryd: (https://crystalia.link/data/) is instance-data-only — every Descriptor and Item id. crys: (https://w3id.org/crystalia/) is reserved for type/schema CURIEs, e.g. a descriptor's hasType value crys:dtype/<name>. This is a breaking consumer-contract change from DM v2.0.0, where the type registry lived under cryd:desc-type/<name> and Items defaulted to crys:<uuid>; every content-addressed descriptor id changed with it (the type CURIE is hashed into the id). Every collection produced before this change is invalid under the new namespace and needs a full re-harvest.

The DM does not store a coverage field on descriptors. Consumers derive coverage from length and the file's own size via the DM API (crystalia_data_model.types), rather than reading a stored value that could drift from the bytes actually hashed.

The glimpse, glimpse-slim, glimpse-light, glimpse-meta and glimpse-dir* methods are classified by the DM registry as authority/recency-grade: fast to compute, useful for change detection and dataset comparison, but not a cryptographic proof of content over the full file (only the file's head bytes are hashed). Use md5, md5-2gb or md5-8gb where a full-content checksum is required.

glimpse-content and glimpse-dir-content are comparison-grade instead; see Content-comparison methods.

Content-comparison methods

glimpse-content and glimpse-dir-content let the viz judge "same content?" across a timestamp rewrite — neither method's identity depends on a filename, ctime or mtime.

Method Identity IS sensitive to Identity is NOT sensitive to
glimpse-content file size; MD5 of the first 2 KB filename, ctime, mtime; bytes after the first 2 KB
glimpse-dir-content count and name of each direct child; each child's glimpse-content identity the directory's own name or mtime

glimpse-dir-content is a count + name-aware (git-tree style) rollup over glimpse-content children: renaming a child changes the directory's IRI; renaming the directory itself, or touching any mtime in the tree, does not.

Both methods are comparison-grade: safe for a "same content?" judgement across a timestamp rewrite, but not a cryptographic proof of full-file content (glimpse-content hashes only the first 2 KB). The legacy glimpse / glimpse-dir* family (see Output format) is authority/recency-grade instead, because its identity embeds mtime.

See Bookend and zip methods for large-file and archive identity, cheaper than a full-content checksum and strength-graded.

Bookend and zip methods

bookend, bookend-dir, zip-cd and zip-manifest give large files and zip-family archives cheap comparison identity without hashing the whole object.

Method Identity IS sensitive to Identity is NOT sensitive to
bookend the first 16 KB, the last 16 KB, detected format, file size every byte strictly between the head and tail windows; filename; ctime/mtime
bookend-dir each direct child's chosen candidate (zip-manifest for a zip-family child, else that child's own bookend/bookend-dir) the directory's own name or mtime
zip-cd the raw Central Directory bytes only file size; every byte outside the archive
zip-manifest sorted NFC member name + CRC-32 + uncompressed size, per member file length; compression method

bookend is stored as bookend-strong when every byte is captured outright (file size ≤ 32 KB) or the captured head/tail wholly pin a verified format rule (a zip whose End-Of-Central-Directory record and Central Directory lie entirely inside the 16 KB tail); otherwise bookend-weak, with gzip always weak once the file exceeds 32 KB (gzip carries no strong rule at all). bookend-dir is bookend-dir-strong iff every one of its children is strong, else bookend-dir-weak.

zip-cd is authority-grade (its identity moves under a re-zip that changes per-member timestamps); zip-manifest is comparison-grade instead, so re-zipping or recompressing identical member content reproduces the same IRI. zip-cd and zip-manifest apply only to zip-family files (including npz); a non-zip file yields neither descriptor.

Failure policy

run and annotate are fail-closed: a harvest with any unhashed entry never reaches the central output. run collects every task outcome and, if any task failed, raises before combining descriptors — the output path is untouched (it is written to a temp file beside the target and renamed only on success). annotate (task-file mode, the primary consumer of a failed harvest's patch-up) reports the same way per line.

Pass --partials-dir <dir> to either command to capture a patch-up manifest on failure — partials_manifest.txt, holding the task-file lines that were not hashed (directly re-feedable to annotate for MY-NF-PIPELINE-01's patch-up job) followed by the descriptors already completed before the failure. Nothing is written to the central output on failure, and the partials manifest is never relayed or uploaded on its own. --partials-dir may not equal or contain the output path, and does not accept an S3 URI.

An internal inconsistency (an unknown descriptor type, or a descriptor whose stored id does not match its recomputed identity) aborts the harvest the same way: a structured error is logged, a Sentry event is captured when SENTRY_DSN is configured, and the process exits non-zero.

--fail-fast has been removed; every harvest is fail-closed by default.

Harvest provenance

Every successful run emits two kinds of provenance node alongside its descriptors and items:

  • Method — one node per (method name, canonical parameters), minted by crystalia_data_model.types.provenance.mint_method. A harvest reuses the same Method IRI whenever it runs the same method with the same parameters, so the node is shared across every harvest that used it. A method's canonical parameters are whatever GenericMethod.parameters() returns for it — block size for the md5* methods, field set and robustness for glimpse*, plus rollup and pairing for glimpse-dir*.
  • HarvestRecord — one node per run, minted by crystalia_data_model.types.provenance.record_harvest and linked to the Method nodes used and the root Items produced. It carries the run's start and end time, the collector version, and the source root scanned. It also records who and where: operator (OS user, getpass.getuser()), hostname (socket.gethostname()), and cliOptions (a JSON object with sorted keys holding the resolved options after defaults: command, methods, workers, format, exclude for run; command, methods, root for merge). annotate emits no HarvestRecord. All three are optional, so harvests made before they existed stay valid. It is emitted exactly once, after the write check succeeds, and only for a fully successful harvest — a failed run (HarvestIncompleteError) writes nothing to the central output, so no HarvestRecord for it exists anywhere.

Versioning rule: a method's parameters are part of its content address. Changing an algorithm or its parameters without giving the method a new registry name would silently change what its existing Method IRI means for every harvest that already used it. tests/method_params_snapshot.json pins each registered method's canonical parameters and fails the build the moment they drift without a new name.

Configuration

Settings load in this order (highest priority first):

  1. Environment variables (CRYSTALIA_* prefix, or bare SENTRY_DSN)
  2. ./crystalia.toml in the current directory
  3. ~/.config/crystalia-collector/config.toml
  4. Built-in defaults

Environment Variables

Variable Default Description
CRYSTALIA_DEFAULT_METHOD_ID md5-8gb Checksum method
CRYSTALIA_DEFAULT_OUTPUT_FILE out.rdf Output file for annotations
CRYSTALIA_ENABLE_TELEMETRY false Send crash reports to Sentry
CRYSTALIA_SENTRY_DSN project default Override Sentry DSN
SENTRY_DSN — Bare DSN fallback
CRYSTALIA_LOG_JSON true JSON-formatted log output
AWS_PROFILE default AWS credentials profile
AWS_DEFAULT_REGION us-east-1 AWS region

Config File

# crystalia.toml or ~/.config/crystalia-collector/config.toml
default_method_id = "md5-8gb"
default_output_file = "out.rdf"
enable_telemetry = false
log_json = false

Copy .envrc.example to .envrc and adjust as needed.

Docker

docker build -t crystalia-collector .
docker run --rm crystalia-collector --help

Development

uv sync
uv run pytest
uv run ruff check .
uv run mypy src/

License

Apache-2.0

Metadata

Release files for crystalia-collector 1.0.0

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

Source distribution (sdist)

Source distribution for crystalia-collector 1.0.0
File Size Uploaded Provenance Actions
crystalia_collector-1.0.0.tar.gz 132.5 kB Without provenance Details for crystalia_collector-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crystalia-collector 1.0.0
File Interpreter ABI Platform Actions
crystalia_collector-1.0.0-py3-none-any.whl Python 3 none any Details for crystalia_collector-1.0.0-py3-none-any.whl

Total release size: 241.3 kB

Release files / crystalia_collector-1.0.0.tar.gz

Download URL crystalia_collector-1.0.0.tar.gz
Size 132.5 kB
Tags Source
SHA-256 checksum
How to use checksums
952fe904df7201b47f14c6135001d23428aa5ecd405b621a12618f8133413923
BLAKE2b-256 checksum
How to use checksums
715e96ca8b5e0eb94fd63a41a8c61b8710267d12c023015f5ebe96234685e5af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / crystalia_collector-1.0.0-py3-none-any.whl

Download URL crystalia_collector-1.0.0-py3-none-any.whl
Size 108.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3042b7235b168e55fb375fc800293870214cc36d9a7abf135b54b29d6494ef4
BLAKE2b-256 checksum
How to use checksums
d5d702486acc915e9d2e1352b9471fa61ccc8015ef6342a0597f7bba485390b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for crystalia-collector 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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