idea109-secureex-hardware-a.../README.md

87 lines
2.4 KiB
Markdown

# SecureEx
SecureEx is a deterministic compliance and replay core for cross-venue trading workflows.
It provides:
- Canonical market primitives for venue normalization.
- FIX and WebSocket adapters.
- A deterministic enclave execution model with attestation.
- A SQLite-backed hash-chained governance ledger.
- Delta reconciliation helpers for disconnect recovery.
- An offline replay harness for regression testing.
## What This Repository Does
This codebase models the minimum trusted control plane needed for a SecureEx-style system:
- normalize market data into `LocalMarket`
- aggregate it into `SharedSignals`
- produce a deterministic `PlanDelta`
- attest the enclave measurement and decision path
- persist the decision trail into an auditable SQLite ledger
- replay the same inputs deterministically after a disconnect
## Architecture
### Canonical primitives
- `LocalMarket`: venue-level bid/ask state.
- `SharedSignals`: aggregated cross-venue signal output.
- `PlanDelta`: the next hedge or quote action.
- `PrivacyBudget`: guards signal leakage.
- `AuditLogEntry`: the attested event record.
### Adapters
- `FixAdapter`: parses FIX-style tag/value payloads.
- `WebSocketAdapter`: parses JSON market updates.
### Enclave and attestation
- `SecureEnclave.compute()` is deterministic for a given market set.
- `SecureEnclave.attest()` returns a signed measurement report.
- `verify_attestation()` checks the report signature and measurement.
### Governance ledger
- `GovernanceLedger` stores an append-only hash chain in SQLite.
- `verify_chain()` recomputes the full chain for audit validation.
### Delta sync and replay
- `DeltaSync` tracks sequence progress per venue and asset.
- `reconcile_markets()` computes the deterministic recovery delta.
- `replay.py` can run a local replay from a JSON event file.
## Install
```bash
python3 -m pip install -e .
```
## Run Tests
```bash
bash test.sh
```
## Replay CLI
```bash
secureex-replay --events events.json
```
Example `events.json`:
```json
[
{"adapter": "fix", "venue": "VENUE_A", "message": "55=ABC|132=10.1|133=10.2|134=100|135=120|34=7|52=1.5"},
{"adapter": "ws", "venue": "VENUE_B", "message": {"asset": "ABC", "bid": 10.0, "ask": 10.3, "bid_size": 80, "ask_size": 60, "sequence": 8, "timestamp": 1.7}}
]
```
## Packaging
The package name is `idea109-secureex-hardware-accelerated` and the long description is sourced from this `README.md`.