Python reference implementation of matrix256v1 — a SHA-256 fingerprint over the (path, size) records of a rooted filesystem tree.
Project description
matrix256-py
Python reference implementation of matrix256v1 — a SHA-256 fingerprint over the (path, size) records of a rooted filesystem tree.
Zero runtime dependencies — stdlib only, Python 3.10+. One of several language implementations of the same normative spec; every implementation must produce byte-identical digests on the same input.
The project's only dev dependency is ruff (declared under [dependency-groups.dev] in pyproject.toml) — used to enforce the library discipline below. Dev deps are not installed when consumers pip install matrix256 or uv add matrix256; they only land in a contributor's environment via uv sync --group dev.
Library discipline
The library promise is: a consumer's process must never break because of code in this package. The rules below are enforced by ruff (CI runs uv run ruff check . on every push); a few rows are intent rules that still require code review.
| Category | What's guarded | Enforced by |
|---|---|---|
| Exception discipline | No assert in library code (stripped under python -O), no bare except:, no sys.exit. Failures raise specific, typed exceptions — OSError from filesystem calls is propagated unchanged per spec §3. |
S101, E722, BLE001, TID251 (banned-api on sys.exit) |
| Output discipline | No print(...), no logging configuration, no writes to sys.stdout / sys.stderr from library code. A fingerprint call has no business producing output. |
T201, T203 (in T20); logging/direct sys.stdout writes are intent rules |
| Total functions | Where reasonable, public functions are made total by construction. _utf8_encode substitutes U+FFFD for any lone surrogate so no caller can hand it a string that triggers UnicodeEncodeError. |
code review |
| Side effects at import | No top-level work beyond imports and the VERSION constant. Importing the package never touches the filesystem, the network, or os.environ. |
code review |
| Documentation | Every public class and function carries a """...""" docstring. Public API stays self-describing. |
D100–D104 |
Tests under tests/ are exempt via [tool.ruff.lint.per-file-ignores] — they use assert, print, and sys.exit freely, as Python's testing idiom expects.
uv sync --group dev # install ruff into a contributor venv
uv run ruff check . # run the discipline checks
Usage
from matrix256 import v1
digest = v1.fingerprint("/media/user/DISC")
The package exposes nothing at the top level. Future algorithm versions will be added as sibling submodules (matrix256.v2, …) so callers always address an explicit version.
Conformance
This implementation's Tier-1 conformance test is the synthetic fixture suite at tests/generate_fixtures.py. The script constructs each fixture in a temporary directory, runs matrix256.v1.fingerprint against it, and verifies the produced digest against the canonical value published in the spec repo's conformance_fixtures.json (human-readable companion: CONFORMANCE_FIXTURES.md). The suite has no external data dependency and runs on every commit in CI.
python tests/generate_fixtures.py # run all fixtures
python tests/generate_fixtures.py --fixture 14 # one fixture
python tests/generate_fixtures.py --range 1-10 # a range
python tests/generate_fixtures.py --generate # emit JSON for the spec repo
By default the runner expects the spec repo to be cloned alongside this one as ../matrix256/. Override with --fixtures PATH. Platform-incompatible fixtures (e.g. case-sensitive sort on a case-insensitive filesystem, surrogate-escape paths off Linux) are reported as skips rather than failures.
The script doubles as the canonical fixture generator: implementers in other languages should mirror its construction logic in their own runner so all language implementations agree on the on-disk state under test.
See also (in the spec repo)
SPEC.md— normative algorithmRATIONALE.md— design rationaleIMPLEMENTERS.md— practical guidance (encoding, mount handling, bridge discs)CORPUS.md— known-good digests across real discsCONFORMANCE_FIXTURES.md/conformance_fixtures.json— Tier-1 synthetic fixture suite
License
Licensed under the Apache License, Version 2.0. Apache 2.0 grants an explicit patent license to users and includes a patent-retaliation clause that terminates those rights for anyone who sues a contributor over the licensed work.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matrix256-1.0.3.tar.gz.
File metadata
- Download URL: matrix256-1.0.3.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21735fe9bfbe8a0651fbcb86dddff8c2f9d000c934da655bdafdbec92a4b2c67
|
|
| MD5 |
1bb4603262cf461efc83d2583b786f25
|
|
| BLAKE2b-256 |
bb2234319aae1d134c08233d2249b97c7dd1c05956fbbef156437689f81d21a9
|
Provenance
The following attestation bundles were made for matrix256-1.0.3.tar.gz:
Publisher:
release.yml on shitwolfymakes/matrix256-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix256-1.0.3.tar.gz -
Subject digest:
21735fe9bfbe8a0651fbcb86dddff8c2f9d000c934da655bdafdbec92a4b2c67 - Sigstore transparency entry: 1416661132
- Sigstore integration time:
-
Permalink:
shitwolfymakes/matrix256-py@0aec5c7f047d7c52a0174b7bdd941bdcced72b63 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/shitwolfymakes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0aec5c7f047d7c52a0174b7bdd941bdcced72b63 -
Trigger Event:
push
-
Statement type:
File details
Details for the file matrix256-1.0.3-py3-none-any.whl.
File metadata
- Download URL: matrix256-1.0.3-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06ddf1377297882d559e470147858e2a32d2c1568691404958dd90a439aa0603
|
|
| MD5 |
3f6507e388abcc94c74e9cd8eefb287b
|
|
| BLAKE2b-256 |
87f79b525d3a39cd477f5093493ab77747214ec33f4a91ae2ea8bcd4dd2348a5
|
Provenance
The following attestation bundles were made for matrix256-1.0.3-py3-none-any.whl:
Publisher:
release.yml on shitwolfymakes/matrix256-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matrix256-1.0.3-py3-none-any.whl -
Subject digest:
06ddf1377297882d559e470147858e2a32d2c1568691404958dd90a439aa0603 - Sigstore transparency entry: 1416661245
- Sigstore integration time:
-
Permalink:
shitwolfymakes/matrix256-py@0aec5c7f047d7c52a0174b7bdd941bdcced72b63 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/shitwolfymakes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0aec5c7f047d7c52a0174b7bdd941bdcced72b63 -
Trigger Event:
push
-
Statement type: