diff --git a/.gitignore b/.gitignore index 2ec1dba..ba86414 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,24 @@ __pycache__/ *.pyc .pytest_cache/ *.egg-info/ +node_modules/ +.npmrc +.env +.env.* +__tests__/ +coverage/ +.nyc_output/ +dist/ +build/ +.cache/ +*.log +.DS_Store +tmp/ +.tmp/ +__pycache__/ +*.pyc +.venv/ +venv/ +*.egg-info/ +.pytest_cache/ +READY_TO_PUBLISH diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..464cf9a --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,31 @@ +# AGENTS.md + +## Architecture + +- Python package: `deltatrace` +- Core modules: + - `event_graph.py` for causal event DAGs + - `replay_engine.py` for deterministic replay + - `audit_log.py` for signed audit trails + - `adapters.py` for market-data and exchange adapters + - `demo.py` for an end-to-end pipeline example + +## Tech Stack + +- Python 3.10+ +- `setuptools` for packaging +- `cryptography` for Ed25519 signing +- `pytest` for test execution when available + +## Verification + +- `bash test.sh` +- `python -m build` +- `python -m pytest tests/ -v` + +## Contribution Rules + +- Keep changes minimal and focused. +- Preserve deterministic behavior in replay and tests. +- Prefer standard library code unless a dependency is clearly justified. +- Update this file when packaging, test commands, or module layout changes. diff --git a/README.md b/README.md index 053e5fa..649f31b 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,53 @@ # DeltaTrace -Deterministic Replayable Latency & Compliance Tracing for Live Market-Execution Pipelines. +Deterministic replay, latency accounting, and compliance tracing for live market-execution pipelines. -A cross-layer traceability toolkit for high-frequency trading systems that enables deterministic replay of order lifecycles, end-to-end latency accounting, governance-ready audit trails, and vendor-agnostic adapters. +DeltaTrace provides a small, production-oriented Python package for capturing market events as a causal graph, replaying them deterministically, and writing a tamper-evident audit trail for governance review. -## Core Components +## What It Does -- **Event Graph**: Models market events (ticks, signals, orders, fills, risk checks) as a DAG with causal edges and latency budgets -- **Replay Engine**: Deterministically replays captured event streams to reproduce decision paths -- **Audit Log**: Crypto-signed, tamper-evident governance log for regulatory reviews -- **Adapters**: Pluggable adapters for FIX feeds and exchange gateways +- Models market-data ticks, signals, plan deltas, orders, fills, and risk checks as graph nodes. +- Links nodes with causal edges and latency measurements. +- Replays captured traces in deterministic order for incident analysis. +- Signs audit entries with Ed25519 and chains them with SHA-256 hashes. +- Includes two starter adapters: + - FIX feed adapter for FIX-like market data messages. + - Sandbox exchange adapter for order/fill simulation. -## Quick Start +## Package Layout + +- `deltatrace.event_graph`: event and DAG primitives. +- `deltatrace.replay_engine`: deterministic replay runner. +- `deltatrace.audit_log`: signed audit log with hash chaining. +- `deltatrace.adapters`: FIX and sandbox adapters. +- `deltatrace.demo`: end-to-end example pipeline. + +## Install + +```bash +pip install -e . +``` + +## Run the Demo ```bash -pip install -r requirements.txt python -m deltatrace.demo ``` -## Testing +## Test And Build ```bash ./test.sh ``` +This script installs dependencies, verifies `python -m build`, runs the test suite, and executes the demo. + +## Publishing Notes + +- Project metadata lives in `pyproject.toml`. +- The package README is wired as the long description for distribution builds. +- The build backend is setuptools and supports standard wheel/sdist creation. + ## License MIT diff --git a/pyproject.toml b/pyproject.toml index 897d099..6c0588f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,27 @@ [build-system] -requires = ["setuptools>=68.0"] -build-backend = "setuptools.backends._legacy:_Backend" +requires = ["setuptools>=68.0", "wheel"] +build-backend = "setuptools.build_meta" [project] name = "deltatrace" version = "0.1.0" description = "Deterministic Replayable Latency & Compliance Tracing for Live Market-Execution Pipelines" +readme = "README.md" requires-python = ">=3.10" dependencies = [ "cryptography>=41.0.0", ] +[project.urls] +Homepage = "https://example.com/deltatrace" +Repository = "https://example.com/deltatrace.git" + [project.optional-dependencies] test = ["pytest>=7.0"] + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +where = ["."] +include = ["deltatrace*"] diff --git a/test.sh b/test.sh index 89087f2..f336d23 100755 --- a/test.sh +++ b/test.sh @@ -3,11 +3,16 @@ set -e echo "=== DeltaTrace Test Suite ===" echo "Installing dependencies..." -pip install -q cryptography>=41.0.0 +python -m pip install -q --upgrade pip +python -m pip install -q build +python -m pip install -q -e ".[test]" + +echo "" +echo "Verifying package build..." +python -m build echo "" echo "Running unit tests..." -cd "$(dirname "$0")" python -m pytest tests/ -v --tb=short 2>/dev/null || python -m unittest discover -s tests -v echo ""