SciTeX Clew (scitex-clew)
Full Documentation · uv pip install scitex-clew[all]
Problem
Scientific publications are growing exponentially — accelerated by LLM-assisted writing — yet peer review remains a manual bottleneck. 70% of researchers report failed replication attempts, and only 11-36% of high-profile findings are successfully reproduced. Existing tools (pre-registration, containerization, workflow managers) address whether research could be reproduced, but not whether it has been.
Solution
SciTeX Clew records every artifact produced during research — code, data, figures, statistics — into a hash-linked DAG (directed acyclic graph). This creates a verifiable knowledge graph of scientific experiments, which can be explored by humans or AI agents.
Named after the thread Ariadne gave Theseus to trace his path through the labyrinth, Clew serves two purposes:
- Reproducibility verification — confirm that outputs remain unchanged and that every step in the pipeline is intact.
- Research logic comprehension — visualize and navigate the structural skeleton of a research project, from raw data through analysis to manuscript claims.
The DAG is a structured, machine-readable representation of an entire research project — enabling both human reviewers and AI agents to inspect, verify, and understand the logic programmatically. It lets you:
- Verify that outputs remain consistent with recorded hashes
- Trace provenance chains from any file back to its source
- Visualize the structural logic of a research project as a navigable graph
- Re-execute scripts in a sandbox to confirm reproducibility
- Link manuscript claims to the computational sessions that produced them
Case Study: The Broken Twin
A real incident (NeuroVista seizure-forecasting analysis, 2026-06-30) shows why claim→source binding matters. Two same-named "warning-metrics Table 03/04" scripts coexisted in the repository:
- Broken twin —
compute_warning_tables.pyfabricated timestamps (times = arange(n) * 60 s) from a block-ordered CSV that had no time column. On that surrogate timeline, a uniform-Poisson alarm beat the real model: AUC 0.46, IoC < 0. - Valid script —
_table03_warning_fullwindow.pyused the realwindow_datetimecolumn withforecasting.evaluate_stream: sensitivity 0.70, specificity 0.96, 0.17 false positives/h, 10.7 min median lead time, IoC +0.56.
Without a claim→source→@stx.session binding, both scripts were equally plausible as "the source" of the table. Hours went into diagnosing the broken twin, and near-chance numbers were almost shipped. With clew, "which code produced this value?" has exactly one answer: the claim resolves to its registered source session, and the broken twin — which has no registered claim — cannot masquerade as evidence. This incident drove ADR-0021: clew registration is mandatory for every manuscript value.
Five Node Classes
Every node in the DAG is classified into one of five semantic roles:
| Class | Role | Examples |
|---|---|---|
| Source | Data acquisition scripts | 01_download.py, collect.sh |
| Input | Raw data and configuration | raw_data.csv, config.yaml |
| Processing | Transform and analysis scripts | 03_analyze.py, train.R |
| Output | Intermediate and final data products | results.csv, figure1.png |
| Claim | Manuscript assertions tied to evidence | "Fig 1 shows p<0.05", "Table 2" |
Table 1. Five node classes. Classification is inferred automatically from file extensions and session roles, or set explicitly via set_node_class().
This classification turns the DAG into a navigable map of the research project. The key operation is backpropagation from claims to sources: starting from a manuscript assertion (claim), Clew traces backward through outputs, processing scripts, and inputs to the original raw data — verifying every hash along the way.
Three Verification Modes
| Mode | Scope | API | Description |
|---|---|---|---|
| Project | Entire pipeline | clew.dag() |
Verifies every session recorded in the database in topological order. A navigation map for ongoing project monitoring. Answers: "Is the whole project intact?" |
| Files | Specific outputs | clew.dag(["output.csv"]) |
Traces backward from target files through their dependency chain and verifies each session. Answers: "Can I trust this specific file?" |
| Claims | Manuscript assertions | clew.verify_claim("Fig 1") |
Verifies individual claims linked to source sessions. Answers: "Is this figure/statistic still backed by the data?" |
Table 2. Three verification modes. Each mode supports both cache verification (millisecond hash comparison) and re-run verification (sandbox re-execution with rerun_dag / rerun_claims).
Verification Caching Guarantee
All caching in Clew is content-keyed: every cache key is a SHA-256 hash of live file bytes — no mtime logic exists anywhere in the package. Per-pass hash caches are created fresh for each verification pass and never persisted; the opt-in rerun_dag(skip_unchanged=True) skip re-hashes the script and every recorded input before skipping (skipped sessions are marked level=CACHE, never RERUN); and stored verdicts are an append-only history, never read back to skip live hashing. A cache can speed up verification but can never return "verified" for content that has changed. Full audited statement: Verification caching — correctness guarantee.
Capture Boundary: Inputs Outside the Project
Inside an @stx.session run, clew records every file the run opens under the project root, whichever library opened it. Data read from outside the root (a shared dataset on /data, /scratch, a NAS mount, ~/datasets, a sibling project's outputs, or an in-project symlink such as data/raw -> /mnt/shared/raw) is recorded as an external input: its resolved path, content hash, size, mtime (for information only; verification compares hashes) and the in-project path used. A slice cannot bundle these files, so clew slice lists them as required but not bundled. clew verify hash-checks them, and reports a missing one as EXTERNAL_MISSING (exit 22). Both the session close and add_claim warn about them. Interpreter, library, system and hidden tool-state files are never recorded; a temp-dir file is recorded only when it existed before the process started (staged by hand or by a wrapper), never when the run or its children made it. The include/exclude knobs and the full exclusion list are in Unconscious capture.
Turning Recording Off
SCITEX_CLEW_CAPTURE=0 turns all of clew's automatic recording off for a process: the @stx.session and stx.io hooks open no run, record no file, install no audit hook and never touch the store, and one WARNING says so. Use it for a no-recording baseline or a run you do not want recorded; explicit calls (clew.session(), clew.record_input, clew.add_claim, clew verify) still run. SCITEX_CLEW_AUDIT_CAPTURE=0 turns off only the open() capture. All variables: Environment variables.
Killed Runs Keep Their Record
clew writes a session's rows to the store in one transaction, so a process killed before it closes (SIGKILL, the OOM killer, a container or agent-harness timeout) cannot run that write. Each session therefore also appends every recorded row, and every file its open() capture hashed, to a per-session journal as it happens (~/.scitex/clew/journal/<host>/, one append per row, no fsync). The next session start or clew command on that machine replays the journal of any process that died: the rows it never wrote, the captured inputs it never recorded, and its producer links. The run is then closed as killed. SIGTERM and SIGHUP are handled before the process dies, and an interpreter that exits with a session still open closes it as incomplete. Replay is idempotent. It never touches a live process's journal, and it skips journals written for a different store. killed and incomplete runs are failed runs for clew verify, but their rows still show what they read and wrote up to the kill. Run it by hand with clew recover-journals [--dry-run] or clew.recover_journals(), and turn it off with SCITEX_CLEW_JOURNAL=0. Details: Killed runs.
Which Directory Is the Project
The project root decides clew's capture boundary, its store scope (<root>/.scitex/clew/project-id), the claims.json export location and the project-scope config (<root>/.scitex/clew/config.yaml). Inside an @stx.session run clew uses the root scitex-session recorded (project_root in the start metadata), so the two never disagree. Standalone (the clew CLI, the Python API) clew applies the same rule itself, first match wins: explicit project_root= > $SCITEX_SESSION_PROJECT_ROOT > git work-tree root (not one at $HOME) > nearest ancestor holding .git/.hg/.svn, pyproject.toml, setup.cfg, setup.py, scitex/.scitex-structure-version or scripts/ + config/ > the working directory. The search stays below $HOME and / and stops at mount points; .scitex/ is not a marker. scitex_clew._db._paths.project_root_info() reports the root and the rule that chose it, and every run records it as metadata["clew_project_root"]. A project id that older clew left in the wrong place (e.g. scripts/.scitex/clew/) is kept in use, never moved, and warned about with the exact mv command.
Conformance: tests/scitex_clew/conformance/project-root-vectors.json is byte-identical to scitex-session's tests/scitex_session/conformance/project-root-vectors.json, and both suites run their resolver against it. A change to the rule must update scitex_clew/_core/_project_root.py, scitex_session/_lifecycle/_project_root.py and the vector file in both repositories.
Evidence for scitex-live-paper
clew is an evidence provider for scitex-live-paper and implements its provider-neutral contract scitex-live-paper.evidence-report 1.1.0. Neither package imports the other. clew registers the entry point scitex.livepaper.renderers → clew (port = "evidence"). For each registered claim it reports the verify --strict outcome as supported / not_supported / not_checkable / no_evidence_graph with a plain reason, plus the claim's level-1 slice as its minimal evidence graph. clew export-evidence --out report.json writes the same report to a file. The schema is vendored version-pinned in src/scitex_clew/_evidence_provider/. Details: Evidence provider.
Grouping for Readable DAGs
Large pipelines emit many per-patient / per-fold files. The grouping API collapses related files into a single DAG node while preserving every underlying hash via a Merkle root — aggregate verification remains cryptographically meaningful.
from scitex_clew.groupers import pattern_grouper, auto, compose
import scitex_clew as clew
clew.mermaid(claims=True, grouper=compose(
pattern_grouper(r"P\d{2}"), # collapse P01, P02, ..., P15
auto(), # sensible directory + bundle fallbacks
))
Project default via <project_root>/.scitex/clew/config.yaml (auto-loaded):
grouper:
type: compose
steps:
- {type: pattern, regex: 'P\d{2}'}
- {type: directory, min_size: 10}
- {type: auto}
The same JSON/dict schema works across Python, CLI (--grouper), MCP ({"grouper": {...}}), and the YAML config file. See the grouping skill.
Installation
Requires Python >= 3.10. Provenance is recorded in the per-host PostgreSQL
store, reached through scitex_dev.store.host_store().
pip install scitex-clew
Architecture
graph LR
S[Source<br/>01_download.py] --> I[Input<br/>raw_data.csv]
I --> P[Processing<br/>03_analyze.py]
P --> O[Output<br/>figure1.png]
O --> C[Claim<br/>'Fig 1: p<0.05']
classDef src fill:#cfe8ff,stroke:#1f6feb
classDef inp fill:#e6ffec,stroke:#1a7f37
classDef proc fill:#fff8c5,stroke:#9a6700
classDef out fill:#ffe0b2,stroke:#bc4c00
classDef cl fill:#ffd6cc,stroke:#cf222e
class S src
class I inp
class P proc
class O out
class C cl
scitex-clew/
├── src/scitex_clew/
│ ├── __init__.py # status, run, chain, dag, rerun, mermaid
│ ├── _db/ # hash-linked DAG store, Store-backed (package)
│ │ ├── __init__.py
│ │ ├── _core.py # VerificationDB, connection mgmt
│ │ ├── _chain.py # ChainMixin: get_chain, get_children, set_parent
│ │ ├── _queries.py # VerificationQueryMixin
│ │ └── _parents.py # Parent-session operations
│ ├── _hash.py # file + directory Merkle hashing
│ ├── _chain/ # chain/DAG verification (types, ops, routes)
│ ├── _claim/ # Claim CRUD + verification
│ ├── _citation/ # \cite -> scholar-verified source gate
│ ├── _core/ # config, logging, node classes, public-API registry
│ ├── _attest/ # external attestation
│ │ ├── _stamp.py # Temporal stamping backends (file/RFC3161/Zenodo)
│ │ └── _registry.py # Clew Registry client (scitex.ai)
│ ├── _rerun.py # Sandbox re-execution
│ ├── _tracker.py # Session tracking
│ ├── _register_intermediate.py# Agentic intermediate-value registration
│ ├── _viz/ # Mermaid/HTML/Graphviz DAG rendering
│ ├── _estimate.py # Pre-flight runtime/success estimate
│ ├── _examples.py # Bundled example locator
│ ├── _linter_plugin.py # scitex-linter plugin entry point
│ ├── _observers/ # scitex-io / scitex-session hook subscribers
│ ├── _groupers/ # Pattern / directory / auto / compose
│ │ ├── __init__.py
│ │ └── _config.py # Per-project grouper config loader
│ ├── groupers.py # Public re-exports
│ ├── _cli/ # clew entrypoint (recursive --help)
│ ├── _mcp/ # MCP server for AI agents
│ │ ├── server.py # FastMCP server
│ │ └── tools/ # Tool definitions (skills, claims, hashing, stamping, verification)
│ └── _skills/scitex-clew/ # Workflow skill pages
└── tests/
Quickstart
import scitex_clew as clew
# Git-status-like overview
clew.status()
# Verify a run (hash check)
result = clew.run("session_20250301_143022")
# Trace a file's provenance chain
chain = clew.chain("output/figure.png")
# Verify the full DAG
dag_result = clew.dag(["output/figure.png"])
# Re-execute in sandbox and compare
rerun_result = clew.rerun("session_20250301_143022")
Figure 1. Example DAG visualization. Green nodes indicate verified sessions; red nodes indicate hash mismatches. Clew traces the dependency graph backward from target files to raw data sources.
Four Interfaces
Python API
import scitex_clew as clew
clew.status() # overview
clew.run("session_id") # verify one run
clew.chain("output/figure.png") # trace provenance
clew.dag(["output/figure.png"]) # verify full DAG
clew.rerun("session_id") # sandbox re-execution
clew.mermaid(claims=True) # Mermaid DAG diagram
clew.add_claim("Fig 1 shows p<0.05", source_files=["fig1.png"])
CLI Commands
clew --help-recursive # Show all commands
clew status # Git-status-like overview
clew verify <session_id> # Verify a run
clew list # List tracked runs
clew stats # Database statistics
clew mermaid # Generate Mermaid diagram
clew list-python-apis # List Python API tree
clew mcp list-tools # List MCP tools
# Claims, hashing, stamping (F1)
clew claim add --file-path paper.tex --type statistic --value "p=0.003"
clew claim list
clew claim verify <claim_id>
clew hash-file path/to/data.csv
clew hash-directory path/to/dir/
clew stamp --backend file
clew list-stamps
clew check-stamp [STAMP_ID]
# Universal --json on every command (F5)
clew --json status
clew status --json
clew --json list --limit 20
# Strict DAG verification with failure attribution (F2)
clew dag --strict --json --target results/figure.csv
MCP Server — for AI Agents
AI agents can verify reproducibility and trace provenance autonomously.
| Tool | Description |
|---|---|
clew_status |
Git-status-like overview |
clew_run |
Verify a specific run |
clew_chain |
Trace file provenance chain |
clew_dag |
Verify full DAG (strict=True returns failure attribution, F2) |
clew_list_runs |
List tracked runs |
clew_stats |
Database statistics |
clew_mermaid |
Generate Mermaid DAG diagram |
clew_rerun_dag |
Rerun full DAG in sandbox |
clew_rerun_claims |
Rerun all claim-backing sessions |
clew_add_claim / clew_list_claims / clew_verify_claim |
Claim CRUD (F1) |
clew_hash_file / clew_hash_directory |
File/directory hashing (F1) |
clew_stamp / clew_list_stamps / clew_check_stamp |
Temporal stamping (F1) |
Table 3. MCP tools available for AI-assisted verification. All tools accept JSON parameters and return JSON results.
clew mcp start
Skills
Skills provide workflow-oriented guides that AI agents query to discover capabilities and usage patterns.
clew skills list # List available skill pages
clew skills get SKILL # Show main skill page
scitex-dev skills export --package scitex-clew # Export to Claude Code
| Skill | Content |
|---|---|
quick-start |
Basic API, session tracking, first verification |
cli-commands |
CLI reference (clew status, clew verify, etc.) |
mcp-tools-for-ai-agents |
MCP tool reference for AI agents |
common-workflows |
Claims, DAG patterns, stamps, reproducibility |
Demo
▶️ Watch: Clew — a thread of evidence (concept clip, narrated) — every claim linked back to its source.
Figure 2. Live DAG verification. Green nodes are sessions whose recorded hashes still match disk; red nodes flag a drift. clew dag --strict walks claims back to raw data and prints the first failure.
Part of SciTeX
scitex-clew is part of SciTeX. Install via
the umbrella with pip install scitex[clew] to use as
scitex.clew (Python) or scitex clew ... (CLI).
import scitex
@scitex.session
def main(CONFIG=scitex.INJECTED):
data = scitex.io.load("input.csv") # auto-tracked as input
result = process(data)
scitex.io.save(result, "output.csv") # auto-tracked as output
return 0
All file I/O through scitex.io is recorded in the clew database:
scitex.clew.status() # overview
scitex.clew.run("session_id") # verify
scitex.clew.mermaid(claims=True) # DAG diagram
The SciTeX system follows the Four Freedoms for Research below, inspired by the Free Software Definition:
Four Freedoms for Research
- The freedom to run your research anywhere — your machine, your terms.
- The freedom to study how every step works — from raw data to final manuscript.
- The freedom to redistribute your workflows, not just your papers.
- The freedom to modify any module and share improvements with the community.
AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.
GUI development follows the leaf plugin workflow. The new GUI and SDK capabilities are an unpublished local migration candidate.
Metadata
Release files for scitex-clew 0.34.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scitex_clew-0.34.0.tar.gz | 7.5 MB | Without provenance | Details for scitex_clew-0.34.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scitex_clew-0.34.0-py3-none-any.whl | Python 3 | none | any | Details for scitex_clew-0.34.0-py3-none-any.whl |
Total release size: 14.0 MB
Release files / scitex_clew-0.34.0.tar.gz
| Download URL | scitex_clew-0.34.0.tar.gz |
|---|---|
| Size | 7.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff7c5e76a9e5f9956916139d55b554bbc6ff2b104d18e1e768b6bce2b0c88444
|
|
BLAKE2b-256 checksum How to use checksums |
84f6e8f566181e647f6fa8e64c20debda518eff8f3c27d11790d24f410039b87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / scitex_clew-0.34.0-py3-none-any.whl
| Download URL | scitex_clew-0.34.0-py3-none-any.whl |
|---|---|
| Size | 6.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed84924826898cdc67b9ed54d901738bbb409e17a08a5f8d74a930a658a153d7
|
|
BLAKE2b-256 checksum How to use checksums |
d1adf0bbc2de8456575308c2e189d1e499212bd0dc548e4ab5dfc1f9ab75762c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for scitex-clew 0.34.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.