global: improve par writes

This commit is contained in:
nym21
2025-12-21 16:22:25 +01:00
parent 26c6c92bb8
commit 6e0ac138d8
29 changed files with 378 additions and 139 deletions
+81
View File
@@ -4,6 +4,87 @@ All notable changes to the Bitcoin Research Kit (BRK) project will be documented
> *This changelog was generated by Claude Code*
## [v0.1.0-alpha.1](https://github.com/bitcoinresearchkit/brk/releases/tag/v0.1.0-alpha.1) - 2025-12-21
### New Features
#### `brk_binder`
- Implemented complete multi-language client generation system that produces typed API clients from the metric catalog and OpenAPI specification ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/lib.rs))
- Added JavaScript client generator with full JSDoc type annotations for IDE autocomplete support across 20k+ metrics ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/javascript.rs))
- Added Python client generator with type hints and httpx for HTTP requests ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/python.rs))
- Added Rust client generator with strong typing using reqwest ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/rust.rs))
- Implemented OpenAPI 3.1 integration using the `oas3` crate for parsing endpoint definitions ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/openapi.rs))
- Created structural pattern detection system that identifies repeating tree structures for type reuse ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/types/patterns.rs))
- Added generic pattern detection that groups type-parameterized structures to reduce generated code size
- Created `ClientMetadata` for extracting catalog structure, patterns, and index sets from `brk_query::Vecs` ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_binder/src/types/mod.rs))
#### `brk_types`
- Added `MetricLeaf` struct containing metric name, value type, and available indexes ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_types/src/treenode.rs))
- Added `MetricLeafWithSchema` that wraps `MetricLeaf` with a JSON Schema for client type generation
- Changed `TreeNode::Leaf` from `String` to `MetricLeafWithSchema` to carry full metadata through the tree
- Added `JsonSchema` derive to byte array types (`U8x2`, `U8x20`, `U8x32`) with custom implementations for `U8x33` and `U8x65`
- Added `JsonSchema` derive to OHLC types (`OHLCCents`, `OHLCDollars`, `OHLCSats`, `Open`, `High`, `Low`, `Close`)
- Added `JsonSchema` derive to all index types (date, week, month, quarter, semester, year, decade, halving epoch, difficulty epoch)
- Added `JsonSchema` derive to address index types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR, P2PK33, P2PK65, P2A, OP_RETURN, empty, unknown)
- Implemented index merging when collapsing tree nodes with the same metric name
#### `brk_traversable`
- Added `make_leaf` helper function that generates `MetricLeafWithSchema` nodes with schemars-based JSON Schema generation ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_traversable/src/lib.rs))
- Updated all `Traversable` implementations to require `JsonSchema` bound and generate full leaf metadata
#### `brk_computer`
- Added `neg_realized_loss` metric (realized_loss * -1) for charting convenience ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_computer/src/stateful/metrics/realized.rs))
- Added `net_realized_pnl` metric (realized_profit - realized_loss)
- Added `realized_value` metric (realized_profit + realized_loss)
- Added `total_realized_pnl` at both height and dateindex levels
- Added `realized_price` metric (realized_cap / supply)
- Added `realized_cap_30d_delta` for 30-day realized cap changes
- Added `sopr` (Spent Output Profit Ratio) with 7-day and 30-day EMA variants
- Added `adjusted_sopr` with EMA variants for coinbase-adjusted analysis
- Added `sell_side_risk_ratio` (realized_value / realized_cap) with 7-day and 30-day EMAs
- Added realized profit/loss ratios relative to realized cap
- Added `net_realized_pnl_cumulative_30d_delta` with ratios relative to realized cap and market cap
- Added `neg_unrealized_loss_rel_to_market_cap` and `net_unrealized_pnl_rel_to_market_cap` metrics ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_computer/src/stateful/metrics/relative.rs))
- Added `supply_in_profit/loss_rel_to_circulating_supply` metrics
- Added unrealized profit/loss relative to own market cap at both height and indexes levels
- Added full benchmark example with indexer, computer, and bencher integration ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_computer/examples/full_bench.rs))
#### `brk_grouper`
- Added public constants for age boundaries (`DAYS_1D`, `DAYS_1W`, `DAYS_1M`, etc.) for external use ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_grouper/src/by_age_range.rs))
- Added `get_mut_by_days_old()` method to `ByAgeRange` for O(1) direct bucket access by days
- Added `AmountBucket` type for O(1) amount range classification ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_grouper/src/by_amount_range.rs))
- Added `amounts_in_different_buckets()` helper for cheap bucket comparison
- Optimized `get()` and `get_mut()` in `ByAmountRange` using match on bucket index instead of if-else chain
#### `brk_server`
- Integrated automatic client generation on startup when `brk_binder/clients/` directory exists ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_server/src/lib.rs))
- Added panic catching for client generation to prevent server startup failures
#### `brk_cli`
- Enabled distribution via cargo-dist (`dist = true` in package metadata)
- Added performance benchmarks section to README with timing and resource usage data
#### `workspace`
- Added `rust-toolchain.toml` pinning toolchain to Rust 1.92.0
- Created comprehensive `scripts/publish.sh` for automated crate publishing in dependency order ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/scripts/publish.sh))
- Updated `scripts/update.sh` to also update rust-toolchain version
### Internal Changes
#### `brk_computer`
- Removed `FenwickTree` state module (O(log n) prefix sum data structure)
- Removed `PriceBuckets` state module (logarithmic price bucket distribution)
- Simplified cohort state management after removal of Fenwick-based percentile computation
#### `brk_indexer`
- Renamed `push_if_needed()` to `checked_push()` throughout for API consistency ([source](https://github.com/bitcoinresearchkit/brk/blob/v0.1.0-alpha.1/crates/brk_indexer/src/processor.rs))
- Renamed `Indexes::push_if_needed()` to `Indexes::checked_push()`
#### `brk_cli`
- Updated `zip` dependency from 6.0.0 to 7.0.0
[View changes](https://github.com/bitcoinresearchkit/brk/compare/v0.1.0-alpha.0...v0.1.0-alpha.1)
## [v0.1.0-alpha.0](https://github.com/bitcoinresearchkit/brk/releases/tag/v0.1.0-alpha.0) - 2025-12-18
### Breaking Changes