Skip to content

Commit bbb96da

Browse files
committed
Refactor SDK packaging for public release
1 parent ad955d9 commit bbb96da

16 files changed

Lines changed: 652 additions & 396 deletions

.dockerignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.git
2+
.github
3+
.mypy_cache
4+
.pytest_cache
5+
.ruff_cache
6+
.venv
7+
__pycache__
8+
*.egg-info
9+
*.pyc
10+
*.pyo
11+
*.pyd
12+
.DS_Store
13+
.env
14+
api/.env
15+
artifacts
16+
build
17+
coverage.xml
18+
dist
19+
htmlcov
20+
hypercore_feed_compare.json

.github/workflows/ci.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
1-
name: CI
1+
name: ci
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: ["main", "master"]
76
pull_request:
87

98
jobs:
10-
validate:
9+
test:
1110
runs-on: ubuntu-latest
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
python-version: ["3.10", "3.11", "3.12"]
1611
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4
12+
- uses: actions/checkout@v4
1913

20-
- name: Setup Python
21-
uses: actions/setup-python@v5
14+
- uses: actions/setup-python@v5
2215
with:
23-
python-version: ${{ matrix.python-version }}
16+
python-version: "3.12"
2417

2518
- name: Install dependencies
2619
run: |
2720
python -m pip install --upgrade pip
28-
python -m pip install -e ".[dev]"
21+
python -m pip install -e '.[dev]'
2922
3023
- name: Run tests
31-
run: pytest -q
24+
run: pytest
3225

3326
- name: Run mypy
3427
run: mypy -p hypercore_sdk
3528

3629
- name: Build package
3730
run: python -m build
3831

39-
- name: Check package metadata
32+
- name: Validate distribution metadata
4033
run: python -m twine check dist/*

.github/workflows/release.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release
1+
name: release
22

33
on:
44
push:
@@ -11,34 +11,27 @@ jobs:
1111
permissions:
1212
contents: write
1313
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v4
14+
- uses: actions/checkout@v4
1615

17-
- name: Setup Python
18-
uses: actions/setup-python@v5
16+
- uses: actions/setup-python@v5
1917
with:
2018
python-version: "3.12"
2119

2220
- name: Install dependencies
2321
run: |
2422
python -m pip install --upgrade pip
25-
python -m pip install -e ".[dev]"
23+
python -m pip install -e '.[dev]'
2624
27-
- name: Run tests
28-
run: pytest -q
29-
30-
- name: Run mypy
31-
run: mypy -p hypercore_sdk
32-
33-
- name: Build package
34-
run: python -m build
35-
36-
- name: Check package metadata
37-
run: python -m twine check dist/*
25+
- name: Validate release
26+
run: |
27+
pytest
28+
mypy -p hypercore_sdk
29+
python -m build
30+
python -m twine check dist/*
3831
3932
- name: Publish GitHub release
4033
uses: softprops/action-gh-release@v2
4134
with:
42-
generate_release_notes: true
4335
files: |
44-
dist/*
36+
dist/*.whl
37+
dist/*.tar.gz

API_interface.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# HyperCore SDK API Interface Reference
1+
# Aleatoric Hypercore Python SDK API Interface Reference
22

33
This document is the interface contract for the Python SDK in this repository.
44

@@ -9,19 +9,19 @@ Scope:
99
- Status API client and stdio MCP server
1010
- Derived intelligence layer for indexing and analytics
1111

12-
As-of validation (March 7, 2026):
1312
As-of validation (March 13, 2026):
14-
- `pytest`: **127 passed**
15-
- `pytest` with coverage gate: **92.45% total coverage**
13+
- `pytest`: **128 passed**
14+
- `pytest` with coverage gate: **93.22% total coverage**
1615
- `mypy -p hypercore_sdk`: **no issues found** (16 source files)
17-
- `python -m build`: **passed**
16+
- `python -m build --no-isolation`: **passed**
1817
- `python -m twine check dist/*`: **passed**
1918

2019
## 1. Quality, Guarantees, and Limits
2120

2221
Objective quality facts:
2322
- The package is typed (`py.typed`) and mypy-clean under project settings.
2423
- CLI command paths are unit tested with mocked dependencies.
24+
- MCP tools are contract-tested across the full published tool matrix.
2525
- Core adapters validate response shapes and raise `RuntimeError` on incompatible payloads.
2626
- Coverage is above enforced gate (90%).
2727

@@ -215,6 +215,10 @@ Current MCP tools:
215215
- `status_get_private`
216216
- `rpc_call`
217217

218+
Operational contract notes:
219+
- The MCP tool names above are the supported outward-facing interface for editor and agent integrations.
220+
- Python MCP argument names use snake_case, matching the Python CLI and Python method naming.
221+
218222
## 5. WebSocket Interface
219223

220224
File: `hypercore_sdk/ws.py`

CHANGELOG.md

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,28 @@
22

33
All notable changes to this project are documented in this file.
44

5-
## [0.3.0] 2026-03-13
5+
## [0.3.0] - 2026-03-13
66

77
### Added
8-
- Browser-safe unified client parity for:
9-
- `all_mids()` / `sse_all_mids()`
10-
- `l2_book()` / `sse_l2_book()`
11-
- `asset_contexts()` / `sse_asset_contexts()`
12-
- Unified `consensus_pulse()` client method.
13-
- Status API client:
14-
- `hypercore_sdk/status.py`
15-
- Python stdio MCP server:
16-
- `hypercore_sdk/mcp.py`
17-
- `hypercore_sdk/mcp_cli.py`
18-
- Tests for unified snapshot/SSE parity, status client, and MCP server:
19-
- `tests/test_unified_stream.py`
20-
- `tests/test_status.py`
21-
- `tests/test_mcp.py`
22-
- `tests/test_cli.py`
23-
- Dedicated liquidation support in client and examples (`StreamLiquidations` path), plus unified `liquidation_cascade` helpers and MCP passthrough.
24-
- Provider matrix benchmark option for liquidation feed benchmarking.
25-
- Project tracking docs:
26-
- `PROJECT_STATE.md`
27-
- `AGENTS.md`
28-
- Container deployment artifacts:
29-
- `Dockerfile`
30-
- `docker-compose.yml`
31-
- `DEPLOYMENT.md`
32-
- Auth/key-scope preflight utility: `examples/preflight_feed_auth.py` for rpc/unified/disk-ws/grpc validation.
33-
- Provider benchmark JSON template now includes scoped key wiring guidance for gRPC vs unified/disk streams.
34-
- Live gRPC console example for side-by-side `l2Book` and `trades` bridge feeds (`examples/grpc_l2book_trades_console.py`).
8+
9+
- Public package metadata for Python distribution, including license, authors, URLs, classifiers, and package manifest controls.
10+
- Customer-facing documentation, contribution guide, and a basic connection example.
11+
- Refreshed API interface reference for external consumers and support handoff.
12+
- GitHub Actions workflows for CI and tagged releases.
13+
- Browser-safe unified stream parity for all-mids, L2 book, and asset contexts.
14+
- Status API client, stdio MCP server, and expanded test coverage.
3515

3616
### Changed
37-
- `hypercore_sdk/cli.py` now exposes unified commands for `consensus-pulse`, `all-mids`, `l2-book`, `asset-contexts`, `liquidations`, and `cascades`.
38-
- README and API reference now document the Python MCP server and the browser-safe unified interfaces.
39-
- Unified stream client query construction was cleaned up to remove repeated ad hoc param-building paths while keeping request semantics unchanged.
40-
- Feed benchmark split between market WS and disk-sync WS.
41-
- README setup/troubleshooting now documents virtualenv-first install flow.
42-
- `.gitignore` expanded for coverage, caches, local outputs, and egg metadata.
43-
- Default endpoint targets updated to Aleatoric stream infrastructure:
44-
- Market/disk WS default `wss://disk.grpc.aleatoric.systems/`
45-
- Unified API default `https://unified.grpc.aleatoric.systems`
46-
- gRPC default `hl.grpc.aleatoric.systems:443`
47-
- Feed latency benchmark now records per-attempt audit stamps, metric-kind summaries, and event-age stats where source timestamps exist.
48-
- Key selection hardened across feed benchmark, matrix runner, and preflight script to ignore malformed placeholder keys and prefer RPC-scoped keys for gRPC checks.
49-
- Provider benchmark and auth preflight output now make scoped endpoint auth failures explicit, reducing false attribution of partial-provider results to latency regressions.
50-
- Example credential loading and scoped key selection are now centralized in `hypercore_sdk/example_auth.py`, removing drift across benchmark, preflight, provider-matrix, and gRPC live examples.
51-
- Benchmark and preflight HTTP checks now classify upstream `502/503/504` responses as `upstream_unavailable`, and feed benchmark output now includes `auth_key_sources` plus `availability_alerts`.
52-
- Feed benchmark output is now typed via `hypercore_sdk/benchmark_models.py`, supports `--profile-json` / `--out-json`, ships reproducible benchmark profiles plus March 10, 2026 baseline snapshots, and can emit machine-readable availability exit codes.
53-
- `examples/grpc_l2book_trades_console.py` now:
54-
- reports which key source it selected
55-
- runs gRPC health and `PriceService` preflight before streaming
56-
- renders compact gRPC auth-preflight failures instead of raw `_InactiveRpcError` blobs
57-
- fails fast with a clear diagnosis when `PriceService` access returns `403/PERMISSION_DENIED`, including the broader case where health and stream RPCs are both denied by the endpoint
58-
- gRPC live examples now prefer `ALEATORIC_GRPC_KEY` and RPC-scoped keys before `GRPC_STREAM_KEY` / `UNIFIED_STREAM_KEY`, fixing false `403` failures in mixed-key environments.
59-
- README and project-state docs now explain how to distinguish local key-selection drift from endpoint-side gRPC authorization failures.
60-
- README and deployment docs now formalize the containerized SDK runtime/build model and explicitly scope out the external bridge server.
61-
- CI and release automation now run tests, mypy, package builds, and `twine check` for push/PR validation and tagged releases.
62-
- CI now also builds Docker `runtime`/`dev` targets, validates `docker-compose.yml`, runs a containerized CLI smoke, and tagged releases publish the runtime image to GHCR.
63-
- `AGENTS.md` now requires packaging validation alongside the existing gRPC local-vs-endpoint auth verification rules.
6417

65-
## [0.3.0] - 2026-03-08
18+
- Reframed the repository as a public Aleatoric Systems SDK for external customers.
19+
- Standardized release validation around `pytest`, `mypy`, `python -m build`, and `twine check`.
20+
- Rewrote the README around installation, authentication, examples, release flow, and support.
21+
- Expanded MCP tests to treat the published tool matrix as a contract.
22+
23+
## [0.2.0] - 2026-03-08
6624

6725
### Added
68-
- Read-only SDK architecture for RPC, WS, gRPC, unified stream, and high-value info surfaces.
69-
- CLI command groups for `price`, `intel`, `rpc`, `stream`, `grpc`, and `speed`.
70-
- Example scripts for auth preflight, latency benchmarking, and live stream consumers.
26+
27+
- Read-only SDK architecture for RPC, WebSocket, gRPC, unified stream, and higher-level info surfaces.
28+
- CLI commands for `price`, `intel`, `rpc`, `stream`, `grpc`, and `speed`.
29+
- Example scripts for auth preflight, live streams, and benchmark workflows.

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Contributing
2+
3+
## Scope
4+
5+
This repository is a customer-facing, read-only SDK for Aleatoric Hypercore services. Do not introduce signing, custody, or order-placement behavior.
6+
7+
## Workflow
8+
9+
1. Align on public API changes before implementation.
10+
2. Preserve backward compatibility unless a versioned breaking change is explicitly approved.
11+
3. Update tests, `README.md`, and `CHANGELOG.md` in the same pull request.
12+
4. Keep examples runnable from the repository root.
13+
14+
## Local Validation
15+
16+
```bash
17+
python3 -m venv .venv
18+
source .venv/bin/activate
19+
python -m pip install --upgrade pip
20+
python -m pip install -e '.[dev]'
21+
pytest
22+
mypy -p hypercore_sdk
23+
python -m build
24+
python -m twine check dist/*
25+
```
26+
27+
## Support
28+
29+
- Email: [github@aleatoric.systems](mailto:github@aleatoric.systems)
30+
- Discord: request the current customer support invite from the Aleatoric Systems team

DEPLOYMENT.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Deployment Model
2+
3+
This repository can be containerized end-to-end for the SDK, CLI, examples, benchmarks, and package build flow.
4+
5+
It does not contain the upstream Aleatoric bridge server itself. The containerized surface here is:
6+
7+
- `hypercore-sdk` CLI
8+
- runnable example scripts in `examples/`
9+
- benchmark and preflight tooling
10+
- Python package build and validation
11+
12+
It does not deploy:
13+
14+
- the Hyperliquid public WebSocket service
15+
- the Aleatoric gRPC bridge service
16+
- any signing, trading, or custody infrastructure
17+
18+
## Images
19+
20+
The repo now ships a multi-stage [Dockerfile](Dockerfile):
21+
22+
- `runtime`: installs the package and exposes `hypercore-sdk`
23+
- `dev`: adds test/build tooling for `pytest`, `mypy`, `build`, and `twine`
24+
25+
GitHub Actions CI now builds both targets on push/PR, and tagged releases publish the `runtime` image to GHCR.
26+
27+
Build locally:
28+
29+
```bash
30+
cd /Users/jaws/research/dev/aleatoric/public/hypercore-python-sdk
31+
docker build --target runtime -t hypercore-sdk:runtime .
32+
docker build --target dev -t hypercore-sdk:dev .
33+
```
34+
35+
## Runtime Configuration
36+
37+
Do not bake secrets into the image. Pass them at runtime with shell environment or `docker compose --env-file .env ...`.
38+
39+
Relevant variables include:
40+
41+
- `ALEATORIC_GRPC_TARGET`
42+
- `ALEATORIC_GRPC_SERVER_NAME`
43+
- `ALEATORIC_GRPC_KEY`
44+
- `RPC_GATEWAY_KEY`
45+
- `RPC_KEY`
46+
- `HYPER_API_KEY`
47+
- `ALEATORIC_MARKET_WS_KEY`
48+
- `UNIFIED_STREAM_KEY`
49+
50+
The example scripts still honor the same key alias logic implemented in [hypercore_sdk/example_auth.py](hypercore_sdk/example_auth.py).
51+
52+
## Compose Services
53+
54+
[docker-compose.yml](docker-compose.yml) formalizes the common flows:
55+
56+
- `cli`: run arbitrary `hypercore-sdk` commands
57+
- `ws-console`: live public WebSocket ladder + trades console
58+
- `grpc-console`: live gRPC `l2Book` + `trades` console
59+
- `benchmark`: feed latency benchmark with JSON output written to `./artifacts`
60+
- `validate`: repo quality gates inside the `dev` image
61+
- `package`: build wheel/sdist into `./dist`
62+
63+
Examples:
64+
65+
```bash
66+
cd /Users/jaws/research/dev/aleatoric/public/hypercore-python-sdk
67+
68+
docker compose run --rm cli price ws --coin BTC
69+
70+
docker compose --env-file .env run --rm ws-console
71+
72+
docker compose --env-file .env run --rm grpc-console --coin BTC --max-events 20
73+
74+
docker compose --env-file .env run --rm benchmark --coin BTC --runs 5 --skip-unified
75+
76+
docker compose run --rm validate
77+
78+
docker compose run --rm package
79+
```
80+
81+
## Network Boundary
82+
83+
These containers are outbound-only clients. No inbound ports are required.
84+
85+
If the gRPC endpoint is only reachable over VPN, the host VPN must already be connected before starting the container. On Docker Desktop, verify that container traffic can traverse the VPN; otherwise `grpc-console` will fail with `StatusCode.UNAVAILABLE` even if the same command works on the host shell.
86+
87+
## Recommended Deployment Pattern
88+
89+
For local/operator use:
90+
91+
1. Build the `runtime` image once.
92+
2. Pass credentials with `docker compose --env-file .env`.
93+
3. Run `grpc-console` or `benchmark` as short-lived jobs.
94+
4. Use `validate` in CI-equivalent checks before publishing package artifacts.
95+
96+
For automation:
97+
98+
1. Keep this image as a client/tooling container.
99+
2. Treat the Aleatoric gRPC bridge and unified feeds as external dependencies.
100+
3. Monitor network/VPN reachability separately from SDK correctness.

0 commit comments

Comments
 (0)