Skip to main content

SplitTrace — trace data leakage back to its source

Tests License: MIT

Experimental Python library for auditing existing EEG and sensor-data splits.

Audit existing train/validation/test assignments for EEG and sensor experiments. Trace derived examples back through declared parent IDs, inspect intervals in original-recording coordinates, and return evidence for each violation.

Different filenames and different pixel values can still come from the same source epoch. SplitTrace accepts declared parent relationships and reports the path that connects a training example to an evaluation example:

train: a → image-01 → epoch-01 ← b :test
                     ^ shared source example

It also checks subject mixing, overlapping source intervals and, under an explicit policy, chronological ordering. Missing metadata is UNKNOWN, not a clean bill of health. All bundled examples are synthetic; no patient data is included.

Early prototype: small manifests only, with no real-user validation yet. The distribution name and import name are both splittrace.

日本語の試用手順は PILOT.md。実行済みの比較結果は results/comparison.html、派生元追跡の出力例は results/derived-audit.html を開いてください。

Install from PyPI / pipでインストール

Python 3.10 or later. Create and activate a virtual environment first:

python3 -m venv .venv

macOS / Linux: source .venv/bin/activate

Windows PowerShell: .venv\Scripts\Activate.ps1

python -m pip install splittrace
splittrace --help

The help screen confirms that the command is available. Install only the tools you need. PyPI package · Source and examples

サンプルCSV・Notebookなどはpipでは配置されません。公開デモはブラウザで開けます。自分でサンプルを実行する場合はGitHubの「Code → Download ZIP」で取得・展開し、READMEの相対パスをそのフォルダー内から指定してください。

Article & live demo / 紹介記事と公開デモ

公開デモは合成データの出力例です。自分のファイルをアップロードする画面ではありません。 The hosted demo is a sample report, not a file-upload service.

Run without installing anything

Python 3.10+; the core and CLI use only the standard library.

git clone https://github.com/R-Koda/splittrace.git
cd splittrace

From the repository directory:

PYTHONPATH=src python3 -m splittrace.cli \
  examples/derived-samples.json examples/derived-assignments.json \
  --policy cross_subject --lineage-complete \
  --output results/local-audit.json --html results/local-audit.html

This intentionally leaking example exits 1; that is the expected result, not an installation error. The report contains the paths a → image-01 → epoch-01 and b → epoch-01. No signal values are read. CLI exit codes: 0 = all applicable checks PASS; 1 = a declared policy violation; 2 = UNKNOWN coverage or invalid input (inspect status to distinguish them).

For an editable install in your own virtual environment:

python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/splittrace --help

Python API

from splittrace import audit, map_interval

samples = [
    {"sample_id": "epoch-01"},
    {"sample_id": "image-01", "parent_ids": ["epoch-01"]},
    {"sample_id": "a", "parent_ids": ["image-01"]},
    {"sample_id": "b", "parent_ids": ["epoch-01"]},
]
assignments = [
    {"sample_id": "a", "split": "train", "fold": "0"},
    {"sample_id": "b", "split": "test", "fold": "0"},
]
report = audit(samples, assignments, policy="cross_subject", lineage_complete=True)
assert report["status"] == "FAIL"
# Other checks remain UNKNOWN when their required metadata is absent.

# Convert a local, resampled interval to original sample coordinates explicitly:
start, end = map_interval(0, 128, origin_offset=256, original_units_per_local_unit=2)
assert (start, end) == (256, 512)

Data contract

Samples are dictionaries / JSON objects. CSV is also accepted; its parent_ids cell must be a JSON array, quoted following normal CSV rules. Blank optional CSV cells are missing metadata. Numeric interval cells are parsed as floats.

  • sample_id: nonempty, globally unique string. Reference nodes may exist without assignment to a split. Parent references must resolve; cycles are rejected.
  • parent_ids: list of directly contributing source-example IDs. Declare all parents for mixtures. Examples sharing a sample ancestor are flagged across partitions. This is a conservative source-example separation policy, not a statistical proof that all shared ancestry invalidates every evaluation.
  • kind: sample (default) or recording. A whole raw recording used as a graph parent should be recording; merely sharing that parent does not fail lineage. Interval or subject checks still apply. Do not label an actual shared training example as a recording to bypass the check.
  • subject_id: canonical ID; namespace IDs that are only unique within a site.
  • recording_id: canonical original-recording ID, not a derived filename.
  • coordinate_system: explicit common coordinate label, e.g. original-samples-256hz or original-seconds.
  • start, end: finite values in that original coordinate system, [start,end). Touching intervals are not overlapping. Values are not rounded implicitly.

The library does not automatically inherit time intervals or subject metadata through arbitrary transformations. Attach canonical metadata to assigned leaves. map_interval only implements a supplied positive affine mapping. Nonlinear warps, filter support, padding and unknown clock shifts require user-provided provenance or must remain unverified.

Assignments contain sample_id, split (train, validation, test) and fold (string, default "0"). Each fold needs train and an evaluation partition. All partition pairs within a fold are checked. Ordinary reuse across independent folds is allowed; nested-CV semantics are not implemented.

Policies and coverage

  • cross_subject: subject IDs must not cross partitions. No global time ordering is required. Shared source examples and raw interval overlap are also checked.
  • within_recording_future: subject sharing is allowed; within each common recording/coordinate system, train must end no later than validation/test starts, and validation must precede test. Cross-recording chronological claims are UNKNOWN because clocks are not assumed comparable. This narrowly scoped policy does not audit future-target availability or preprocessing fit history.

lineage_complete=True is a declaration by the caller, not something the library can prove. Omitting it makes lineage coverage UNKNOWN even if no shared ancestor was found. Missing subject or interval metadata makes affected checks UNKNOWN. A proven violation makes the overall result FAIL even if other checks are UNKNOWN. PASS means only that the supplied metadata satisfies the applicable rules.

Results include per-fold checks, unknown-pair counts, violation counts and evidence paths. max_findings limits returned examples, not failure counts. HTML/JSON reports include identifiers and paths; keep them local or redact before sharing. The tool performs no network requests, uploads, model training or automatic edits.

Validation performed

On 2026-11-09, Python 3.14.7:

  • 23 standard-library tests passed, including malformed manifests, parent cycles, multiple parents, interval boundaries, coordinate mapping, missing metadata, ordinary K-fold reuse, validation/test contamination and HTML escaping.
  • 7 synthetic scenarios matched their expected PASS/FAIL/UNKNOWN outcomes.
  • Compared against leakfence 0.5.0, NumPy 2.5.4 in an isolated environment. Subject mixing and interval overlap were detected by both tools. Clean splits were not flagged. The full machine-readable output is results/comparison.json.

In the derived-source case, leakfence's native input has no parent-graph field. Calling it with only the available native metadata produced no flag; that is not a safety verdict. Manually grouping leaves by source also made leakfence detect the problem. Our demonstrated distinction is accepting the parent graph and returning the chain of evidence, not a uniquely powerful detection algorithm.

The comparison uses the same available supported metadata, with the manual source-group adapter shown separately. It is a small functional comparison, not an independent benchmark, speed test, accuracy improvement, or proof of demand. Deepchecks and other competitors were not executed in this prototype comparison.

Reproduce tests and the nearest-competitor comparison:

PYTHONPATH=src python3 -m unittest discover -s tests -v
python3 -m venv /tmp/splittrace-comparison
/tmp/splittrace-comparison/bin/python -m pip install -r requirements-comparison.txt
/tmp/splittrace-comparison/bin/python scripts/compare.py

Deliberate limits

Pairwise scanning is quadratic in partition sizes; ancestor-path storage also grows with graph size/depth. Use small manifests. There is no performance claim. No approximate content matching, nested-CV audit, persistent exception management, automatic clock recovery, preprocessing tracing, causal/label leakage analysis or proof of independence is implemented. Synthetic tests are not real-user validation.

Feedback is welcome from EEG, wearable-sensor and other windowed-signal projects: can you supply source IDs/coordinates, and does a provenance path help you fix a split? See CONTRIBUTING.md and the Japanese trial guide.

References

This prototype contains no copied competitor implementation. Optional comparison dependencies retain their own licenses and are installed separately.

License

MIT. Copyright (c) 2026 Ryu Koda.

Metadata

Release files for splittrace 0.1.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 splittrace 0.1.0
File Size Uploaded Provenance Actions
splittrace-0.1.0.tar.gz 20.6 kB With provenance Details for splittrace-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for splittrace 0.1.0
File Interpreter ABI Platform Actions
splittrace-0.1.0-py3-none-any.whl Python 3 none any Details for splittrace-0.1.0-py3-none-any.whl

Total release size: 33.7 kB

Release files / splittrace-0.1.0.tar.gz

Download URL splittrace-0.1.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ea1ee16255c8904f7c3ec9108c87ca71c1bd9ba7cea35b8cf131a6f64375c24
BLAKE2b-256 checksum
How to use checksums
95854ae2edcb7b0ec5643657ebc46df45b6c21d214ac00a58034d29db31e7883
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 9, 2026.

Transparency log

Release files / splittrace-0.1.0-py3-none-any.whl

Download URL splittrace-0.1.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
688f6a30d366951965a984b07dc72fc7fd737ed608ff26e8d73cb212bd20d9bb
BLAKE2b-256 checksum
How to use checksums
e316d1655a749f4f6d3ac466cc3b6b498e71c9fda970607bb9f408711d66efa6
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 9, 2026.

Transparency log

Security for splittrace 0.1.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.

Full provenance

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

Select from 2 files

Attestation for splittrace-0.1.0.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 9, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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